MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Networking Services Library Functions           xdrcomplex(3NSL)



NAME
     xdrcomplex, xdrarray, xdrbytes, xdropaque,  xdrpointer,
     xdrreference,     xdrstring,     xdrunion,    xdrvector,
     xdrwrapstring  -  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 streams. See xdrcreate(3NSL).

  Routines
     See rpc(3NSL) for the definition of the XDR data  structure.
     Note  that  any  buffers  passed to the XDR routines must be
     properly aligned. It is suggested either  that  malloc()  be
     used  to  allocate  these  buffers,  or  that the programmer
     insure  that the buffer address is divisible evenly by four.


     #include 

     boolt xdrarray(XDR *xdrs, caddrt *arrp, uintt *sizep,
     const uintt maxsize, const uintt 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 size of each of the array's
         elements, and elproc is an XDR routine  that  translates
         between  the  array  elements' C form and their external
         representation.  If  *aarp  is   NUL   when   decoding,
         xdrarray()  allocates  memory  and  *aarp points to it.
         This routine returns TRUE if it succeeds,  FALSE  other-
         wise.


     boolt xdrbytes(XDR *xdrs, char **sp, uintt *sizep, const
     uintt 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. If *sp is  NUL when decoding, xdrbytes()
         allocates  memory  and  *sp  points  to it. This routine
         returns TRUE if it succeeds, FALSE otherwise.



SunOS 5.11          Last change: 30 Dec 1996                    1






Networking Services Library Functions           xdrcomplex(3NSL)



     boolt xdropaque(XDR *xdrs, caddrt cp, const uintt 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  in
         bytes.  This  routine returns TRUE if it succeeds, FALSE
         otherwise.


     boolt xdrpointer(XDR *xdrs, char **objpp, uintt 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. If *objpp is  NUL
         when decoding, xdrpointer() allocates memory and *objpp
         points to it.


     boolt xdrreference(XDR *xdrs, caddrt *pp, uintt 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 structure
         between its C form and its external  representation.  If
         *pp  is   NUL  when decoding, xdrreference() allocates
         memory and *pp points to it.  This routine returns 1  if
         it succeeds, 0 otherwise.

         Warning: this routine does not understand null pointers.
         Use xdrpointer() instead.


     boolt xdrstring(XDR *xdrs, char **sp, const uintt max-
     size);

         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.  If  *sp  is   NUL  when  decoding,
         xdrstring() allocates memory and *sp points to it. This
         routine  returns  TRUE  if it succeeds, FALSE otherwise.
         Note: xdrstring() can be used to send an  empty  string
         (""), but not a null string.


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




SunOS 5.11          Last change: 30 Dec 1996                    2






Networking Services Library Functions           xdrcomplex(3NSL)



         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 enumt. Next the
         union located  at  unp  is  translated.   The  parameter
         choices  is  a pointer to an array of xdrdiscrim 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 xdrdiscrim struc-
         ture array is denoted by a routine of value NUL. If the
         discriminant is not found in the choices array, then the
         defaultarm procedure is called (if it is not  NUL).  It
         returns TRUE if it succeeds, FALSE otherwise.


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

         xdrvector() translates between fixed-length arrays  and
         their corresponding external representations. The param-
         eter arrp is the address of the pointer  to  the  array,
         while size is the element count of the array. The param-
         eter 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  representa-
         tion.  This  routine  returns TRUE if it succeeds, FALSE
         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
         xdrproct(), which takes  two  arguments.  xdrstring(),
         one of the most frequently used routines, requires three
         arguments, while xdrwrapstring() only requires two. For
         these routines, xdrwrapstring() is desirable. This rou-
         tine returns TRUE if it succeeds, FALSE otherwise.


ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:







SunOS 5.11          Last change: 30 Dec 1996                    3






Networking Services Library Functions           xdrcomplex(3NSL)



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     MT-Level                     Safe                        
    


SEE ALSO
     malloc(3C),  rpc(3NSL),  xdradmin(3NSL),  xdrcreate(3NSL),
     xdrsimple(3NSL), attributes(5)













































SunOS 5.11          Last change: 30 Dec 1996                    4



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™