Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ xdr_string(3N) — svr4 — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

rpc(3N)

xdr_admin(3N)

xdr_create(3N)

xdr_simple(3N)



XDRCOMPLEX(3N-SVR4)RISC/os Reference Manual XDRCOMPLEX(3N-SVR4)



NAME
     xdr_complex: xdr_array, xdr_bytes, xdr_opaque, xdr_pointer,
          xdr_reference, xdr_string, xdr_union, xdr_vector,
          xdr_wrapstring - library routines for external data
          representation

DESCRIPTION
     XDR library routines allow C programmers to describe complex
     data structures in a machine-independent fashion.  Protocols
     such as remote procedure calls (RPC) use these routines to
     describe the format of the data.  These routines are the XDR
     library routines for complex data structures.  They require
     the creation of XDR stream [see xdr_create(3N)].

   Routines
     See rpc(3N) for the definition of the XDR data structure.

     #include <rpc/xdr.h>

     boolt
     xdrarray(XDR *xdrs, caddrt *arrp, uint *sizep,
          const uint maxsize, const uint elsize,
          const xdrproct elproc);

          xdrarray translates between variable-length arrays and
          their corresponding external representations.  The
          parameter arrp is the address of the pointer to the
          array, while sizep is the address of the element count
          of the array; this element count cannot exceed maxsize.
          The parameter elsize is the sizeof each of the array's
          elements, and elproc is an XDR routine that translates
          between the array elements' C form and their external
          representation.  This routine returns 1 if it succeeds,
          0 otherwise.

     boolt
     xdrbytes(XDR *xdrs, char **sp, uint *sizep,
          const uint maxsize);

          xdrbytes translates between counted byte strings and
          their external representations.  The parameter sp is
          the address of the string pointer.  The length of the
          string is located at address sizep; strings cannot be
          longer than maxsize.  This routine returns 1 if it
          succeeds, 0 otherwise.

     boolt
     xdropaque(XDR *xdrs, caddrt cp, const uint cnt);

          xdropaque translates between fixed size opaque data
          and its external representation.  The parameter cp is
          the address of the opaque object, and cnt is its size



                        Printed 11/19/92                   Page 1





XDRCOMPLEX(3N-SVR4)RISC/os Reference Manual XDRCOMPLEX(3N-SVR4)



          in bytes.  This routine returns 1 if it succeeds, 0
          otherwise.

     boolt
     xdrpointer(XDR *xdrs, char **objpp, uint objsize,
          const xdrproct xdrobj);

          Like xdrreference except that it serializes NULL
          pointers, whereas xdrreference does not.  Thus,
          xdrpointer can represent recursive data structures,
          such as binary trees or linked lists.

     boolt
     xdrreference(XDR *xdrs, caddrt *pp, uint size,
          const xdrproct proc);

          xdrreference provides pointer chasing within struc-
          tures.  The parameter pp is the address of the pointer;
          size is the sizeof the structure that *pp points to;
          and proc is an XDR procedure that translates the struc-
          ture between its C form and its external representa-
          tion.  This routine returns 1 if it succeeds, 0 other-
          wise.

          Warning:  this routine does not understand NULL
          pointers.  Use xdrpointer instead.

     boolt
     xdrstring(XDR *xdrs, char **sp, const uint maxsize);

          xdrstring translates between C strings and their
          corresponding external representations.  Strings cannot
          be longer than maxsize.  Note:  sp is the address of
          the string's pointer.  This routine returns 1 if it
          succeeds, 0 otherwise.

     boolt
     xdrunion(XDR *xdrs, enumt *dscmp, char *unp,
          const struct xdrdiscrim *choices,
          const boolt (*defaultarm)(const XDR *, const char *,
               const int));

          xdrunion translates between a discriminated C union
          and its corresponding external representation.  It
          first translates the discriminant of the union located
          at dscmp.  This discriminant is always an enum_t.  Next
          the union located at unp is translated.  The parameter
          choices is a pointer to an array of xdr_discrim struc-
          tures.  Each structure contains an ordered pair of
          [value, proc].  If the union's discriminant is equal to
          the associated value, then the proc is called to
          translate the union.  The end of the xdr_discrim



 Page 2                 Printed 11/19/92





XDRCOMPLEX(3N-SVR4)RISC/os Reference Manual XDRCOMPLEX(3N-SVR4)



          structure array is denoted by a routine of value NULL.
          If the discriminant is not found in the choices array,
          then the defaultarm procedure is called (if it is not
          NULL).  Returns 1 if it succeeds, 0 otherwise.

     boolt
     xdrvector(XDR *xdrs, char *arrp, const uint size,
          const uint elsize, const xdrproct elproc);

          xdrvector translates between fixed-length arrays and
          their corresponding external representations.  The
          parameter arrp is the address of the pointer to the
          array, while size is is the element count of the array.
          The parameter elsize is the sizeof each of the array's
          elements, and elproc is an XDR routine that translates
          between the array elements' C form and their external
          representation.  This routine returns 1 if it succeeds,
          0 otherwise.

     boolt
     xdrwrapstring(XDR *xdrs, char **sp);

          A routine that calls xdrstring(xdrs, sp, maxuint);
          where maxuint is the maximum value of an unsigned
          integer.

          Many routines, such as xdrarray, xdrpointer and
          xdrvector take a function pointer of type xdrproc_t,
          which takes two arguments.  xdrstring, one of the most
          frequently used routines, requires three arguments,
          while xdrwrapstring only requires two.  For these rou-
          tines, xdrwrapstring is desirable.  This routine
          returns 1 if it succeeds, 0 otherwise.

SEE ALSO
     rpc(3N), xdr_admin(3N), xdr_create(3N), xdr_simple(3N).



















                        Printed 11/19/92                   Page 3



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026