.H A "Synopsis of XDR Routines" .SH xdr_array() .LP .LS xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc) XDR *xdrs; char **arrp; u_int *sizep, maxsize, elsize; xdrproc_t elproc; .LE A filter primitive that translates between arrays and their corresponding external representations. The parameter .L arrp is the address of the pointer to the array, while .L sizep is the address of the element count of the array; this element count cannot exceed .L maxsize . The parameter .L elsize is the .L sizeof() each of the array's elements, and .L 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. .SH xdr_bool() .LP .LS xdr_bool(xdrs, bp) XDR *xdrs; bool_t *bp; .LE A filter primitive that translates between booleans (C integers) and their external representations. When encoding data, this filter produces values of either one or zero. This routine returns one if it succeeds, zero otherwise. .SH xdr_bytes() .LP .LS xdr_bytes(xdrs, sp, sizep, maxsize) XDR *xdrs; char **sp; u_int *sizep, maxsize; .LE A filter primitive that translates between counted byte strings and their external representations. The parameter .L sp is the address of the string pointer. The length of the string is located at address .L sizep ; strings cannot be longer than .L maxsize . This routine returns one if it succeeds, zero otherwise. .SH xdr_destroy() .LP .LS void xdr_destroy(xdrs) XDR *xdrs; .LE A macro that invokes the destroy routine associated with the XDR stream, .L xdrs . Destruction usually involves freeing private data structures associated with the stream. Using .L xdrs after invoking .L xdr_destroy() is undefined. .SH xdr_double() .LP .LS xdr_double(xdrs, dp) XDR *xdrs; double *dp; .LE A filter primitive that translates between C .L double precision numbers and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_enum() .LP .LS xdr_enum(xdrs, ep) XDR *xdrs; enum_t *ep; .LE A filter primitive that translates between C .L enum s (actually integers) and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_float() .LP .LS xdr_float(xdrs, fp) XDR *xdrs; float *fp; .LE A filter primitive that translates between C .L float s and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_getpos() .LP .LS u_int xdr_getpos(xdrs) XDR *xdrs; .LE A macro that invokes the get-position routine associated with the XDR stream, .L xdrs . The routine 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. .SH xdr_inline() .LP .LS long * xdr_inline(xdrs, len) XDR *xdrs; int len; .LE A macro that invokes the in-line routine associated with the XDR stream, .L xdrs . The routine returns a pointer to a contiguous piece of the stream's buffer; .L len is the byte length of the desired buffer. Note that the pointer is cast to .L "long *" . Warning: .L xdr_inline() may return 0 (NULL) 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. .SH xdr_int() .LP .LS xdr_int(xdrs, ip) XDR *xdrs; int *ip; .LE A filter primitive that translates between C integers and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_long() .LP .LS xdr_long(xdrs, lp) XDR *xdrs; long *lp; .LE A filter primitive that translates between C .L long integers and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_opaque() .LP .LS xdr_opaque(xdrs, cp, cnt) XDR *xdrs; char *cp; u_int cnt; .LE A filter primitive that translates between fixed size opaque data and its external representation. The parameter .L cp is the address of the opaque object, and .L cnt is its size in bytes. This routine returns one if it succeeds, zero otherwise. .SH xdr_reference() .LP .LS xdr_reference(xdrs, pp, size, proc) XDR *xdrs; char **pp; u_int size; xdrproc_t proc; .LE A primitive that provides pointer chasing within structures. The parameter .L pp is the address of the pointer; .L size is the .L sizeof() the structure that .L *pp points to; and .L 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. .SH xdr_setpos() .LP .LS xdr_setpos(xdrs, pos) XDR *xdrs; u_int pos; .LE A macro that invokes the set position routine associated with the XDR stream .L xdrs . The parameter .L pos is a position value obtained from .L 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. .SH xdr_short() .LP .LS xdr_short(xdrs, sp) XDR *xdrs; short *sp; .LE A filter primitive that translates between C .L short integers and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_string() .LP .LS xdr_string(xdrs, sp, maxsize) XDR *xdrs; char **sp; u_int maxsize; .LE A filter primitive that translates between C strings and their corresponding external representations. Strings cannot cannot be longer than .L maxsize . Note that .L sp is the address of the string's pointer. This routine returns one if it succeeds, zero otherwise. .SH xdr_u_int() .LP .LS xdr_u_int(xdrs, up) XDR *xdrs; unsigned *up; .LE A filter primitive that translates between C .L unsigned integers and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_u_long() .LP .LS xdr_u_long(xdrs, ulp) XDR *xdrs; unsigned long *ulp; .LE A filter primitive that translates between C .L "unsigned long" integers and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_u_short() .LP .LS xdr_u_short(xdrs, usp) XDR *xdrs; unsigned short *usp; .LE A filter primitive that translates between C .L "unsigned short" integers and their external representations. This routine returns one if it succeeds, zero otherwise. .SH xdr_union() .LP .LS xdr_union(xdrs, dscmp, unp, choices, dfault) XDR *xdrs; int *dscmp; char *unp; struct xdr_discrim *choices; xdrproc_t dfault; .LE A filter primitive that translates between a discriminated C .L union and its corresponding external representation. The parameter .L dscmp is the address of the union's discriminant, while .L unp in the address of the union. This routine returns one if it succeeds, zero otherwise. .SH xdr_void() .LP .LS xdr_void() .LE This routine always returns one. It may be passed to RPC routines that require a function parameter, where nothing is to be done. .SH xdr_wrapstring() .LP .LS xdr_wrapstring(xdrs, sp) XDR *xdrs; char **sp; .LE A primitive that calls .L xdr_string(xdrs,sp,MAXUNSIGNED); where MAXUNSIGNED is the maximum value of an unsigned integer. This is handy because the RPC package passes only two parameters XDR routines, whereas .L xdr_string() , one of the most frequently used primitives, requires three parameters. This routine returns one if it succeeds, zero otherwise. .SH xdrmem_create() .LP .LS void xdrmem_create(xdrs, addr, size, op) XDR *xdrs; char *addr; u_int size; enum xdr_op op; .LE This routine initializes the XDR stream object pointed to by .L xdrs . The stream's data is written to, or read from, a chunk of memory at location .L addr whose length is no more than .L size bytes long. The .L op determines the direction of the XDR stream (either XDR_ENCODE, XDR_DECODE, or XDR_FREE). .SH xdrrec_create() .LP .LS void xdrrec_create(xdrs, sendsize, recvsize, handle, readit, writeit) XDR *xdrs; u_int sendsize, recvsize; char *handle; int (*readit)(), (*writeit)(); .LE This routine initializes the XDR stream object pointed to by .L xdrs . The stream's data is written to a buffer of size .L sendsize ; a value of zero indicates the system should use a suitable default. The stream's data is read from a buffer of size .L recvsize ; it too can be set to a suitable default by passing a zero value. When a stream's output buffer is full, .L writeit() is called. Similarly, when a stream's input buffer is empty, .L readit() is called. The behavior of these two routines is similar to the UNIX system calls .L read and .L write , except that .L handle is passed to the former routines as the first parameter. Note that the XDR stream's .L op field must be set by the caller. Warning: this XDR stream implements an intermediate record stream. Therefore there are additional bytes in the stream to provide record boundary information. .SH xdrrec_endofrecord() .LP .LS xdrrec_endofrecord(xdrs, sendnow) XDR *xdrs; int sendnow; .LE This routine can be invoked only on streams created by .L xdrrec_create() . The data in the output buffer is marked as a completed record, and the output buffer is optionally written out if .L sendnow is non-zero. This routine returns one if it succeeds, zero otherwise. .SH xdrrec_eof() .LP .LS xdrrec_eof(xdrs) XDR *xdrs; int empty; .LE This routine can be invoked only on streams created by .L 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. .SH xdrrec_skiprecord() .LP .LS xdrrec_skiprecord(xdrs) XDR *xdrs; .LE This routine can be invoked only on streams created by .L xdrrec_create() . It tells the XDR implementation that the rest of the current record in the stream's input buffer should be discarded. This routine returns one if it succeeds, zero otherwise. .SH xdrstdio_create() .LP .LS void xdrstdio_create(xdrs, file, op) XDR *xdrs; FILE *file; enum xdr_op op; .LE This routine initializes the XDR stream object pointed to by .L xdrs . The XDR stream data is written to, or read from, the Standard I/O stream .L file . The parameter .L op determines the direction of the XDR stream (either XDR_ENCODE, XDR_DECODE, or XDR_FREE). Warning: the destroy routine associated with such XDR streams calls .L fflush() on the .L file stream, but never .L fclose() .