unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

XDR_COMPLEX(3N)                                                XDR_COMPLEX(3N)



NAME
       xdr_array,    xdr_bytes,    xdr_opaque,   xdr_pointer,   xdr_reference,
       xdr_string, xdr_union, xdr_vector, xdr_wrapstring  -  library  routines
       for translating complex data types

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.

   Routines
       The XDR data structure is defined in the RPC/XDR Library Definitions of
       the

       #include <&lt;rpc/xdr.h>&gt;

       bool_t xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc)
       XDR *xdrs;
       char **arrp;
       u_int *sizep, maxsize, elsize;
       xdrproc_t elproc;

              A  filter  primitive  that  translates between a variable-length
              array  and  its  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
              value  is  used  by  the  filter while encoding and is set by it
              while decoding; the routine fails if the element  count  exceeds
              maxsize.  The parameter elsize is the sizeof each of the array's
              elements, and elproc is an XDR filter  that  translates  between
              the  array  elements' C form, and their external representation.
              This routine returns TRUE if it succeeds, FALSE otherwise.

       bool_t xdr_bytes(xdrs, arrp, sizep, maxsize)
       XDR *xdrs;
       char **arrp;
       u_int *sizep, maxsize;

              A filter primitive that translates between an array of bytes and
              its  external  representation.   It treats the array of bytes as
              opaque data.  The parameter arrp is the address of the array  of
              bytes.   While  decoding  if  *arrp  is NULL, then the necessary
              storage is allocated to hold the array.   This  storage  can  be
              freed  by  using  xdr_free() (see xdr_simple(3N)).  sizep is the
              pointer to the actual length  specifier  for  the  array.   This
              value is used by the filter while encoding and is set by it when
              decoding.  maxsize is the maximum length of the array.  The rou-
              tine  fails  if  the  actual length of the array is greater than
              maxsize This routine returns TRUE if it succeeds,  FALSE  other-
              wise.

       bool_t xdr_opaque(xdrs, cp, cnt)
       XDR *xdrs;
       char *cp;
       u_int cnt;

              A  filter  primitive  that  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 in bytes.
              This routine returns TRUE if it succeeds, FALSE otherwise.

       bool_t xdr_pointer(xdrs, objpp, objsize, objproc)
       XDR *xdrs;
       char **objpp;
       u_int objsize;
       xdrproc_t objproc;

              Like xdr_reference() except that it  serializes  NULL  pointers,
              whereas  xdr_reference() does not.  Thus, xdr_pointer() can rep-
              resent recursive data structures, such as binary trees or linked
              lists.   The parameter objpp is the address of the pointer; obj-
              size is the sizeof the structure  that  *objpp  points  to;  and
              objproc  is  an XDR procedure that filters the structure between
              its C  form  and  its  external  representation.   This  routine
              returns TRUE if it succeeds, FALSE otherwise.

       bool_t xdr_reference(xdrs, pp, size, proc)
       XDR *xdrs;
       char **pp;
       u_int size;
       xdrproc_t proc;

              A  primitive  that  provides  pointer chasing within structures.
              The parameter pp is the address of  the  pointer;  size  is  the
              sizeof the structure that *pp points to; and proc is an XDR pro-
              cedure that filters the structure between its  C  form  and  its
              external  representation.   This routine returns TRUE if it suc-
              ceeds, FALSE otherwise.

              Warning: This routine does not  understand  NULL  pointers.  Use
              xdr_pointer() instead.

       bool_t xdr_string(xdrs, strp, maxsize)
       XDR *xdrs;
       char **strp;
       u_int maxsize;

              A  filter  primitive that translates between C strings and their
              corresponding external representations.  The  routine  fails  if
              the string being translated is longer than maxsize.  strp is the
              address of the pointer to the string. While decoding if *strp is
              NULL, then the necessary storage is allocated to hold this null-
              terminated string and *strp is set to point to this.  This stor-
              age can be freed by using xdr_free() (see xdr_simple(3N)).  This
              routine returns TRUE if it succeeds, FALSE otherwise.

       bool_t xdr_union(xdrs, dscmp, unp, choices, defaultarm)
       XDR *xdrs;
       int *dscmp;
       char *unp;
       struct xdr_discrim *choices;
       bool_t (*defaultarm) ();  /* may be NULL */

              A filter primitive that 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  structures.  Each structure contains an ordered
              pair of [value,proc].  If the union's discriminant is  equal  to
              any  of the values, then the associated proc is called to trans-
              late the union.  The end of the xdr_discrim structure  array  is
              denoted  by a NULL pointer.  If the discriminant is not found in
              the choices array, then the defaultarm procedure is  called  (if
              it  is  not  NULL).   This  routine returns TRUE if it succeeds,
              FALSE otherwise.

       bool_t xdr_vector(xdrs, arrp, size, elsize, elproc)
       XDR *xdrs;
       char *arrp;
       u_int size, elsize;
       xdrproc_t elproc;

              A filter primitive that translates between  fixed-length  arrays
              and their corresponding external representations.  The parameter
              arrp is the address of the array,  while  size  is  the  element
              count  of the array.  The parameter elsize is the sizeof each of
              the array's elements, and elproc is an XDR  filter  that  trans-
              lates  between  the  array  elements' C form, and their external
              representation.  This routine returns TRUE if it succeeds, FALSE
              otherwise.

       bool_t xdr_wrapstring(xdrs, strp)
       XDR *xdrs;
       char **strp;

              A  primitive  that  calls xdr_string( xdrs, strp, MAXUNSIGNED );
              where MAXUNSIGNED is the maximum value of an  unsigned  integer.
              xdr_wrapstring() is handy because the RPC package passes a maxi-
              mum of two XDR routines as parameters, and xdr_string(), one  of
              the  most  frequently  used primitives, requires three.  strp is
              the address of the pointer to the  string.   While  decoding  if
              *strp  is  NULL, then the necessary storage is allocated to hold
              the null-terminated string and *strp is set to  point  to  this.
              This  storage  can  be  freed  by using xdr_free() (see xdr_sim-
              ple(3N)).  This routine returns TRUE if it succeeds, FALSE  oth-
              erwise.

SEE ALSO
       xdr(3N), xdr_admin(3N), xdr_create(3N), xdr_simple(3N)



                                20 January 1990                XDR_COMPLEX(3N)