HP-UX Reference (11i v1 05/09) - 3 Library Functions N-Z (vol 7)
x
xdr_complex(3N) xdr_complex(3N)
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
SYNOPSIS
#include <rpc/xdr.h>
bool_t xdr_array(XDR *
xdrs, caddr_t *arrp, u_int *sizep,
const u_int
maxsize, const u_int elsize
, const xdrproc_t elproc);
bool_t xdr_bytes(XDR *
xdrs, char **sp, u_int *sizep
, const u_int maxsize);
bool_t xdr_opaque(XDR *
xdrs, caddr_t cp, const u_int cnt
);
bool_t xdr_pointer(XDR *
xdrs, char **objpp, u_int objsize
,
const xdrproc_t
xdrobj);
bool_t xdr_reference(XDR *
xdrs, caddr_t *pp, u_int
size,
const xdrproc_t
proc);
bool_t xdr_string(XDR *
xdrs
, char **sp, const u_int maxsize);
bool_t xdr_union(XDR *
xdrs, enum_t *
dscmp, char *unp,
const struct xdr_discrim *
choices, const xdrproc_t (*defaultarm);
bool_t xdr_vector(XDR *
xdrs
, char *arrp, const u_int size,
const u_int
elsize, const xdrproc_t elproc);
bool_t xdr_wrapstring(XDR *
xdrs, char **sp);
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. Note that any buffers passed to the XDR routines
must be properly aligned. It is suggested that malloc() be used to allocate these buffers or that the pro-
grammer insure that the buffer address is divisible evenly by four.
bool_t xdr_array()
xdr_array()
translates between variable-length arrays and their corresponding external represen-
tations. 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
*arrp is null when decoding, xdr_array()
allocates memory and *aarp points to it. This routine returns TRUE if it succeeds, FALSE
otherwise.
bool_t xdr_bytes()
xdr_bytes()
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 null when decoding, xdr_bytes() allocates
memory and *sp points to it. This routine returns TRUE if it succeeds, FALSE otherwise.
bool_t xdr_opaque()
xdr_opaque()
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()
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. If *objpp is null when decoding, xdr_pointer() allocates memory and *objpp points
to it.
bool_t xdr_reference()
xdr_reference()
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 procedure that
Section 3−−1060 Hewlett-Packard Company − 1 − HP-UX 11i Version 1: September 2005