xdr_complex(3N) LIBRARY FUNCTIONS xdr_complex(3N)
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 stream [see xdrcreate(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
in bytes. This routine returns 1 if it succeeds, 0
otherwise.
boolt
xdrpointer(XDR *xdrs, char **objpp, uint objsize,
1
xdr_complex(3N) LIBRARY FUNCTIONS xdr_complex(3N)
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 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 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);
2
xdr_complex(3N) LIBRARY FUNCTIONS xdr_complex(3N)
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 xdrproct,
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), xdradmin(3N), xdrcreate(3N), xdrsimple(3N).
3