XDR(3) BSD Library Functions Manual XDR(3)
NAMExdr, xdr_array, xdr_bool, xdr_bytes, xdr_char, xdr_destroy, xdr_double, xdr_enum, xdr_float, xdr_free,
xdr_getpos, xdr_hyper, xdr_inline, xdr_int, xdr_long, xdr_longlong_t, xdrmem_create, xdr_opaque,
xdr_pointer, xdrrec_create, xdrrec_endofrecord, xdrrec_eof, xdrrec_skiprecord, xdr_reference,
xdr_setpos, xdr_short, xdrstdio_create, xdr_string, xdr_u_char, xdr_u_hyper, xdr_u_int, xdr_u_long,
xdr_u_longlong_t, xdr_u_short, xdr_union, xdr_vector, xdr_void, xdr_wrapstring -- library routines for
external data representation
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS#include<rpc/types.h>#include<rpc/xdr.h>
See DESCRIPTION for function declarations.
DESCRIPTION
These routines allow C programmers to describe arbitrary data structures in a machine-independent fash-ion. fashion.
ion. Data for remote procedure calls are transmitted using these routines.
intxdr_array(XDR*xdrs, char**arrp, u_int*sizep, u_intmaxsize, u_intelsize, xdrproc_telproc)
A filter primitive that translates between variable-length arrays and their corresponding
external representations. The arrp argument 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 elsize argument 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 one if it succeeds, zero otherwise.
intxdr_bool(XDR*xdrs, bool_t*bp)
A filter primitive that translates between booleans (C integers) and their external representa-tions. representations.
tions. When encoding data, this filter produces values of either one or zero. This routine
returns one if it succeeds, zero otherwise.
intxdr_bytes(XDR*xdrs, char**sp, u_int*sizep, u_intmaxsize)
A filter primitive that translates between counted byte strings and their external representa-tions. representations.
tions. The sp argument 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 one if
it succeeds, zero otherwise.
intxdr_char(XDR*xdrs, char*cp)
A filter primitive that translates between C characters and their external representations.
This routine returns one if it succeeds, zero otherwise. Note: encoded characters are not
packed, and occupy 4 bytes each. For arrays of characters, it is worthwhile to consider
xdr_bytes(), xdr_opaque() or xdr_string().
voidxdr_destroy(XDR*xdrs)
A macro that invokes the destroy routine associated with the XDR stream, xdrs. Destruction
usually involves freeing private data structures associated with the stream. Using xdrs after
invoking xdr_destroy() is undefined.
intxdr_double(XDR*xdrs, double*dp)
A filter primitive that translates between C double precision numbers and their external repre-sentations. representations.
sentations. This routine returns one if it succeeds, zero otherwise.
intxdr_enum(XDR*xdrs, enum_t*ep)
A filter primitive that translates between C enums (actually integers) and their external rep-resentations. representations.
resentations. This routine returns one if it succeeds, zero otherwise.
intxdr_float(XDR*xdrs, float*fp)
A filter primitive that translates between C floats and their external representations. This
routine returns one if it succeeds, zero otherwise.
voidxdr_free(xdrproc_tproc, void*objp)
Generic freeing routine. The first argument is the XDR routine for the object being freed.
The second argument is a pointer to the object itself. Note: the pointer passed to this rou-tine routine
tine is not freed, but what it points to is freed (recursively).
u_intxdr_getpos(XDR*xdrs)
A macro that invokes the get-position routine associated with the XDR stream, xdrs. The rou-tine routine
tine returns an unsigned integer, which indicates the position of the XDR byte stream. A
desirable feature of XDR streams is that simple arithmetic works with this number, although the
XDR stream instances need not guarantee this.
intxdr_hyper(XDR*xdrs, quad_t*llp)
A filter primitive that translates between ANSI C longlong integers and their external repre-sentations. representations.
sentations. This routine returns one if it succeeds, zero otherwise.
long*xdr_inline(XDR*xdrs, intlen)
A macro that invokes the in-line routine associated with the XDR stream, xdrs. The routine
returns a pointer to a contiguous piece of the stream's buffer; len is the byte length of the
desired buffer. Note: pointer is cast to long*.
Warning: xdr_inline() may return NULL (0) if it cannot allocate a contiguous piece of a buffer.
Therefore the behavior may vary among stream instances; it exists for the sake of efficiency.
intxdr_int(XDR*xdrs, int*ip)
A filter primitive that translates between C integers and their external representations. This
routine returns one if it succeeds, zero otherwise.
intxdr_long(XDR*xdrs, long*lp)
A filter primitive that translates between C long integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
intxdr_longlong_t(XDR*xdrs, quad_t*llp)
A filter primitive that translates between ANSI C longlong integers and their external repre-sentations. representations.
sentations. This routine returns one if it succeeds, zero otherwise.
voidxdrmem_create(XDR*xdrs, char*addr, u_intsize, enumxdr_opop)
This routine initializes the XDR stream object pointed to by xdrs. The stream's data is writ-ten written
ten to, or read from, a chunk of memory at location addr whose length is no more than size
bytes long. The op argument determines the direction of the XDR stream (either XDR_ENCODE,
XDR_DECODE, or XDR_FREE).
intxdr_opaque(XDR*xdrs, char*cp, u_intcnt)
A filter primitive that translates between fixed size opaque data and its external representa-tion. representation.
tion. The cp argument is the address of the opaque object, and cnt is its size in bytes. This
routine returns one if it succeeds, zero otherwise.
intxdr_pointer(XDR*xdrs, char**objpp, u_intobjsize, xdrproc_txdrobj)
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.
voidxdrrec_create(XDR*xdrs, u_intsendsize, u_intrecvsize, void*handle, int (*readit)(),
int (*writeit)())
This routine initializes the XDR stream object pointed to by xdrs. The stream's data is writ-ten written
ten to a buffer of size sendsize; a value of zero indicates the system should use a suitable
default. The stream's data is read from a buffer of size recvsize; it too can be set to a
suitable default by passing a zero value. When a stream's output buffer is full, writeit() is
called. Similarly, when a stream's input buffer is empty, readit() is called. The behavior of
these two routines is similar to the system calls read(2) and write(2), except that handle is
passed to the former routines as the first argument. Note: the XDR stream's op field must be
set by the caller.
Warning: this XDR stream implements an intermediate record stream. Therefore there are addi-tional additional
tional bytes in the stream to provide record boundary information.
intxdrrec_endofrecord(XDR*xdrs, intsendnow)
This routine can be invoked only on streams created by xdrrec_create(). The data in the output
buffer is marked as a completed record, and the output buffer is optionally written out if
sendnow is non-zero. This routine returns one if it succeeds, zero otherwise.
intxdrrec_eof(XDR*xdrs)
This routine can be invoked only on streams created by xdrrec_create(). After consuming the
rest of the current record in the stream, this routine returns one if the stream has no more
input, zero otherwise.
intxdrrec_skiprecord(XDR*xdrs)
This routine can be invoked only on streams created by xdrrec_create(). It tells the XDR
implementation that the rest of the current record in the stream's input buffer should be dis-carded. discarded.
carded. This routine returns one if it succeeds, zero otherwise.
intxdr_reference(XDR*xdrs, char**pp, u_intsize, xdrproc_tproc)
A primitive that provides pointer chasing within structures. The pp argument is the address of
the pointer; size is the sizeof the structure that *pp points to; and proc is an XDR procedure
that filters the structure between its C form and its external representation. This routine
returns one if it succeeds, zero otherwise.
Warning: this routine does not understand NULL pointers. Use xdr_pointer() instead.
intxdr_setpos(XDR*xdrs, u_intpos)
A macro that invokes the set position routine associated with the XDR stream xdrs. The pos
argument is a position value obtained from xdr_getpos(). This routine returns one if the XDR
stream could be repositioned, and zero otherwise.
Warning: it is difficult to reposition some types of XDR streams, so this routine may fail with
one type of stream and succeed with another.
intxdr_short(XDR*xdrs, short*sp)
A filter primitive that translates between C short integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
#ifdef _STDIO_H_
/* XDR using stdio library */
voidxdrstdio_create(XDR*xdrs, FILE*file, enumxdr_opop)
#endif
This routine initializes the XDR stream object pointed to by xdrs. The XDR stream data is
written to, or read from, the Standard I/O stream file. The op argument determines the direc-tion direction
tion of the XDR stream (either XDR_ENCODE, XDR_DECODE, or XDR_FREE).
Warning: the destroy routine associated with such XDR streams calls fflush(3) on the file
stream, but never fclose(3).
intxdr_string(XDR*xdrs, char**sp, u_intmaxsize)
A filter primitive that translates between C strings and their corresponding external represen-tations. representations.
tations. Strings cannot be longer than maxsize. Note: sp is the address of the string's
pointer. This routine returns one if it succeeds, zero otherwise.
intxdr_u_char(XDR*xdrs, unsignedchar*ucp)
A filter primitive that translates between unsigned C characters and their external representa-tions. representations.
tions. This routine returns one if it succeeds, zero otherwise.
intxdr_u_hyper(XDR*xdrs, u_quad_t*ullp)
A filter primitive that translates between unsigned ANSI C longlong integers and their exter-nal external
nal representations. This routine returns one if it succeeds, zero otherwise.
intxdr_u_int(XDR*xdrs, unsigned*up)
A filter primitive that translates between C unsigned integers and their external representa-tions. representations.
tions. This routine returns one if it succeeds, zero otherwise.
intxdr_u_long(XDR*xdrs, unsignedlong*ulp)
A filter primitive that translates between C unsignedlong integers and their external repre-sentations. representations.
sentations. This routine returns one if it succeeds, zero otherwise.
intxdr_u_longlong_t(XDR*xdrs, u_quad_t*ullp)
A filter primitive that translates between unsigned ANSI C longlong integers and their exter-nal external
nal representations. This routine returns one if it succeeds, zero otherwise.
intxdr_u_short(XDR*xdrs, unsignedshort*usp)
A filter primitive that translates between C unsignedshort integers and their external repre-sentations. representations.
sentations. This routine returns one if it succeeds, zero otherwise.
intxdr_union(XDR*xdrs, enum_t*dscmp, char*unp, conststructxdr_discrim*choices, xdrproc_tdefaultarm)
A filter primitive that translates between a discriminated C union and its corresponding exter-nal external
nal 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 choices
argument 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 the associated value,
then the proc() is called to translate the union. The end of the xdr_discrim structure 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 one if it succeeds,
zero otherwise.
intxdr_vector(XDR*xdrs, char*arrp, u_intsize, u_intelsize, xdrproc_telproc)
A filter primitive that translates between fixed-length arrays and their corresponding external
representations. The arrp argument is the address of the pointer to the array, while size is
the element count of the array. The elsize argument is the sizeof each of the array's ele-ments, elements,
ments, and elproc is an XDR filter that translates between the array elements' C form, and
their external representation. This routine returns one if it succeeds, zero otherwise.
intxdr_void(void)
This routine always returns one. It may be passed to RPC routines that require a function
argument, where nothing is to be done.
intxdr_wrapstring(XDR*xdrs, char**sp)
A primitive that calls xdr_string(xdrs, sp, MAXUN.UNSIGNED); where MAXUN.UNSIGNED is the maxi-mum maximum
mum value of an unsigned integer. The xdr_wrapstring() function is handy because the RPC pack-age package
age passes a maximum of two XDR routines as arguments, and xdr_string(), one of the most fre-quently frequently
quently used primitives, requires three. Returns one if it succeeds, zero otherwise.
SEEALSOrpc(3)eXternalDataRepresentationStandard:ProtocolSpecification.
eXternalDataRepresentation:SunTechnicalNotes.
XDR:ExternalDataRepresentationStandard, Sun Microsystems, Inc., USC-ISI, RFC1014.
BSD February 16, 1988 BSD

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors

Report errors in the content of this documentation with the feedback links below.

Bug reports

Report bugs in the functionality of the described tool or API through Bug Reporter.

Formatting problems

Report formatting mistakes in the online version of these pages with the feedback links below.