


XDR_COMPLEX(3N)         NETWORK FUNCTIONS         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 _N_e_t_w_o_r_k _P_r_o_g_r_a_m_m_i_n_g.

     #include <rpc/xdr.h>

     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 representa-
          tions.  The  parameter  _a_r_r_p  is  the  address  of  the
          pointer to the array, while _s_i_z_e_p 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 _m_a_x_s_i_z_e.
          The  parameter _e_l_s_i_z_e is the _s_i_z_e_o_f each of the array's
          elements, and _e_l_p_r_o_c 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  _a_r_r_p  is
          the  address  of the array of bytes.  While decoding if
          *_a_r_r_p 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)).  _s_i_z_e_p 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.  _m_a_x_s_i_z_e is the maximum length of



Sun Release 4.1   Last change: 20 January 1990                  1






XDR_COMPLEX(3N)         NETWORK FUNCTIONS         XDR_COMPLEX(3N)



          the array.  The routine fails if the actual  length  of
          the  array is greater than _m_a_x_s_i_z_e This routine returns
          TRUE if it succeeds, FALSE otherwise.

     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 _c_p is the address of the opaque  object,  and
          _c_n_t 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 represent recursive data  structures,
          such  as  binary  trees  or linked lists. The parameter
          _o_b_j_p_p is the address of the  pointer;  _o_b_j_s_i_z_e  is  the
          _s_i_z_e_o_f the structure that *_o_b_j_p_p points to; and _o_b_j_p_r_o_c
          is an XDR procedure that filters the structure  between
          its  C form and its external representation.  This rou-
          tine 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 struc-
          tures.  The parameter _p_p is the address of the pointer;
          _s_i_z_e is the _s_i_z_e_o_f the structure that  *_p_p  points  to;
          and _p_r_o_c is an XDR procedure that filters the structure
          between its C form  and  its  external  representation.
          This  routine returns TRUE if it succeeds, FALSE other-
          wise.

          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;



Sun Release 4.1   Last change: 20 January 1990                  2






XDR_COMPLEX(3N)         NETWORK FUNCTIONS         XDR_COMPLEX(3N)



          A filter primitive that translates  between  C  strings
          and  their corresponding external representations.  The
          routine fails if the string being translated is  longer
          than  _m_a_x_s_i_z_e.   _s_t_r_p  is the address of the pointer to
          the string. While decoding if *_s_t_r_p is NULL,  then  the
          necessary  storage  is  allocated  to  hold  this null-
          terminated string and *_s_t_r_p is set to  point  to  this.
          This  storage  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  discrim-
          inated C union and its corresponding external represen-
          tation. It first translates  the  discriminant  of  the
          union located at _d_s_c_m_p.  This discriminant is always an
          enum_t.  Next the union located at _u_n_p  is  translated.
          The  parameter  _c_h_o_i_c_e_s  is  a  pointer  to an array of
          xdr_discrim structures.   Each  structure  contains  an
          ordered  pair of [_v_a_l_u_e,_p_r_o_c].  If the union's discrim-
          inant is equal to any of the _v_a_l_u_es, then  the  associ-
          ated _p_r_o_c is called to translate the union.  The end of
          the xdr_discrim structure array is denoted  by  a  NULL
          pointer.   If  the  discriminant  is  not  found in the
          _c_h_o_i_c_e_s array, then the _d_e_f_a_u_l_t_a_r_m 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 representa-
          tions.  The parameter _a_r_r_p is the address of the array,
          while  _s_i_z_e  is  the  element  count of the array.  The
          parameter _e_l_s_i_z_e is the _s_i_z_e_o_f each of the array's ele-
          ments,  and  _e_l_p_r_o_c  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_wrapstring(xdrs, strp)
     XDR *xdrs;



Sun Release 4.1   Last change: 20 January 1990                  3






XDR_COMPLEX(3N)         NETWORK FUNCTIONS         XDR_COMPLEX(3N)



     char **strp;

          A primitive that calls xdr_string( xdrs,  strp,  MAXUN-
          SIGNED  ); where MAXUNSIGNED is the maximum value of an
          unsigned integer.  xdr_wrapstring()  is  handy  because
          the RPC package passes a maximum of two XDR routines as
          parameters, and xdr_string(),  one  of  the  most  fre-
          quently  used  primitives, requires three.  _s_t_r_p is the
          address of the pointer to the string.   While  decoding
          if  *_s_t_r_p  is NULL, then the necessary storage is allo-
          cated to hold the null-terminated string and  *_s_t_r_p  is
          set  to  point  to  this.  This storage can be freed by
          using xdr_free() (see  xdr_simple(3N)).   This  routine
          returns TRUE if it succeeds, FALSE otherwise.

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






































Sun Release 4.1   Last change: 20 January 1990                  4



