Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
xdr(3)
Edit
PageHistory
Diff
Info
LikePages
XDR !!!XDR NAME SYNOPSIS AND DESCRIPTION SEE ALSO ---- !!NAME xdr - library routines for external data representation !!SYNOPSIS AND DESCRIPTION These routines allow C programmers to describe arbitrary data structures in a machine-independent fashion. Data for remote procedure calls are transmitted using these routines. __xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc) XDR *xdrs; char **arrp; u_int *sizep, maxsize, elsize; xdrproc_t elproc; __ A filter primitive that 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 filter that translates between the array elements' C form, and their external representation. This routine returns one if it succeeds, zero otherwise. __xdr_bool(xdrs, bp) XDR *xdrs; bool_t *bp; __ 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. __xdr_bytes(xdrs, sp, sizep, maxsize) XDR *xdrs; char **sp; u_int *sizep, maxsize; __ A filter primitive that 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 one if it succeeds, zero otherwise. __xdr_char(xdrs, cp) 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()__. __void xdr_destroy(xdrs) 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. __xdr_double(xdrs, dp) XDR *xdrs; double *dp; __ A filter primitive that translates between C __double__ precision numbers and their external representations. This routine returns one if it succeeds, zero otherwise. __xdr_enum(xdrs, ep) XDR *xdrs; enum_t *ep; __ A filter primitive that translates between C __enum__s (actually integers) and their external representations. This routine returns one if it succeeds, zero otherwise. __xdr_float(xdrs, fp) XDR *xdrs; float *fp; __ A filter primitive that translates between C __float__s and their external representations. This routine returns one if it succeeds, zero otherwise. __void xdr_free(proc, objp) xdrproc_t proc; char *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 routine is ''not'' freed, but what it points to ''is'' freed (recursively). __u_int xdr_getpos(xdrs) XDR *xdrs; __ A macro that invokes the get-position routine associated with the XDR stream, ''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. __long * xdr_inline(xdrs, len) XDR *xdrs; int len; __ 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. __xdr_int(xdrs, ip) 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. __xdr_long(xdrs, lp) 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. __void xdrmem_create(xdrs, addr, size, op) XDR *xdrs; char *addr; u_int size; enum xdr_op op; __ This routine initializes the XDR stream object pointed to by ''xdrs''. The stream's data is written to, or read from, a chunk of memory at location ''addr'' whose length is no more than ''size'' bytes long. The ''op'' determines the direction of the XDR stream (either __XDR_ENCODE__ , __XDR_DECODE__ , or __XDR_FREE__ ). __xdr_opaque(xdrs, cp, cnt) XDR *xdrs; char *cp; u_int cnt; __ A filter primitive that 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 one if it succeeds, zero otherwise. __xdr_pointer(xdrs, objpp, objsize, xdrobj) XDR *xdrs; char **objpp; u_int objsize; xdrproc_t xdrobj; __ Like __xdr_reference()__ execpt 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. __void xdrrec_create(xdrs, sendsize, recvsize, handle, readit, writeit) XDR *xdrs; u_int sendsize, recvsize; char *handle; int (*readit) (), (*writeit) (); __ This routine initializes the XDR stream object pointed to by ''xdrs''. The stream's data is written 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__ and __write__, except that ''handle'' is passed to the former routines as the first parameter. 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 additional bytes in the stream to provide record boundary information. __xdrrec_endofrecord(xdrs, sendnow) XDR *xdrs; int sendnow; __ 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. __xdrrec_eof(xdrs) XDR *xdrs; int empty; __ 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. __xdrrec_skiprecord(xdrs) 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 discarded. This routine returns one if it succeeds, zero otherwise. __xdr_reference(xdrs, pp, size, proc) XDR *xdrs; char **pp; u_int size; xdrproc_t proc; __ A primitive that 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 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. __xdr_setpos(xdrs, pos) XDR *xdrs; u_int pos; __ A macro that invokes the set position routine associated with the XDR stream ''xdrs''. The parameter ''pos'' 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. __xdr_short(xdrs, sp) 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. __void xdrstdio_create(xdrs, file, op) XDR *xdrs; FILE *file; enum xdr_op op; __ 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 parameter ''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 __fflush()__ on the ''file'' stream, but never __fclose()__. __xdr_string(xdrs, sp, maxsize) XDR *xdrs; char **sp; u_int maxsize; __ A filter primitive that 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 one if it succeeds, zero otherwise. __xdr_u_char(xdrs, ucp) XDR *xdrs; unsigned char *ucp; __ A filter primitive that translates between __unsigned__ C characters and their external representations. This routine returns one if it succeeds, zero otherwise. __xdr_u_int(xdrs, up) XDR *xdrs; unsigned *up; __ A filter primitive that translates between C __unsigned__ integers and their external representations. This routine returns one if it succeeds, zero otherwise. __xdr_u_long(xdrs, ulp) XDR *xdrs; unsigned long *ulp; __ A filter primitive that translates between C __unsigned long__ integers and their external representations. This routine returns one if it succeeds, zero otherwise. __xdr_u_short(xdrs, usp) XDR *xdrs; unsigned short *usp; __ A filter primitive that translates between C __unsigned short__ integers and their external representations. This routine returns one if it succeeds, zero otherwise. __xdr_union(xdrs, dscmp, unp, choices, dfault) XDR *xdrs; int *dscmp; char *unp; struct xdr_discrim *choices; bool_t (*defaultarm) (); /* may equal NULL */ __ A filter primitive that 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 __enum_t__. Next the union located at ''unp'' is translated. The parameter ''choices'' 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. __xdr_vector(xdrs, arrp, size, elsize, elproc) XDR *xdrs; char *arrp; u_int size, elsize; xdrproc_t elproc; __ A filter primitive that 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 filter that translates between the array elements' C form, and their external representation. This routine returns one if it succeeds, zero otherwise. __xdr_void() __ This routine always returns one. It may be passed to RPC routines that require a function parameter, where nothing is to be done. __xdr_wrapstring(xdrs, sp) XDR *xdrs; char **sp; __ A primitive that calls __xdr_string(xdrs, sp, MAXUN.UNSIGNED );__ where __MAXUN.UNSIGNED__ is the maximum value of an unsigned integer. __xdr_wrapstring()__ is handy because the RPC package passes a maximum of two XDR routines as parameters, and __xdr_string()__, one of the most frequently used primitives, requires three. Returns one if it succeeds, zero otherwise. !!SEE ALSO __rpc__(3N) The following manuals: ''eXternal Data Representation Standard: Protocol Specification eXternal Data Representation: Sun Technical Notes XDR : External Data Representation Standard'', RFC1014, Sun Microsystems, Inc., USC-ISI . ----
One page links to
xdr(3)
:
Man3x
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.