DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

xdr(NS)


xdr -- library routines for external data representation

Syntax

cc ... -lsocket

xdr_accepted_reply(xdrs, ar)
XDR *xdrs;
struct accepted_reply *ar;

xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc) XDR *xdrs; char **arrp; uint *sizep, maxsize, elsize; xdrproc_t elproc;

xdr_authunix_parms(xdrs, aupp) XDR *xdrs; struct authunix_parms *aupp;

xdr_bool(xdrs, bp) XDR *xdrs; bool_t *bp;

xdr_bytes(xdrs, sp, sizep, maxsize) XDR *xdrs; char **sp; uint *sizep, maxsize;

void xdr_callhdr(xdrs, chdr) XDR *xdrs; struct rpc_msg *chdr;

xdr_callmsg(xdrs, cmsg) XDR *xdrs; struct rpc_msg *cmsg;

xdr_char(xdrs, cp) XDR *xdrs; char *cp;

void xdr_destroy(xdrs) XDR *xdrs;

xdr_double(xdrs, dp) XDR *xdrs; double *dp;

xdr_enum(xdrs, ep) XDR *xdrs; enum_t *ep;

xdr_float(xdrs, fp) XDR *xdrs; float *fp;

void xdr_free(proc, objp) xdrproc_t proc; char *objp;

uint xdr_getpos(xdrs) XDR *xdrs;

long *xdr_inline(xdrs, len) XDR *xdrs; int len;

xdr_int(xdrs, ip) XDR *xdrs; int *ip;

xdr_long(xdrs, lp) XDR *xdrs; long *lp;

xdr_opaque(xdrs, cp, cnt) XDR *xdrs; char *cp; uint cnt;

xdr_opaque_auth(xdrs, ap) XDR *xdrs; struct opaque_auth *ap;

xdr_pmap(xdrs, regs) XDR *xdrs; struct pmap *regs;

xdr_pmaplist(xdrs, rp) XDR *xdrs; struct pmaplist **rp;

xdr_pointer(xdrs, objpp, objsize, xdrobj) XDR *xdrs; char **objpp; uint objsize; xdrproc_t xdrobj;

xdr_reference(xdrs, pp, size, proc) XDR *xdrs; char **pp; uint size; xdrproc_t proc;

xdr_rejected_reply(xdrs, rr) XDR *xdrs; struct rejected_reply *rr;

xdr_replymsg(xdrs, rmsg) XDR *xdrs; struct rpc_msg *rmsg;

xdr_setpos(xdrs, pos) XDR *xdrs; uint pos;

xdr_short(xdrs, sp) XDR *xdrs; short *sp;

xdr_string(xdrs, sp, maxsize) XDR *xdrs; char **sp; uint maxsize;

xdr_u_char(xdrs, ucp) XDR *xdrs; unsigned char *ucp;

xdr_u_int(xdrs, up) XDR *xdrs; unsigned *up;

xdr_u_long(xdrs, ulp) XDR *xdrs; unsigned long *ulp;

xdr_u_short(xdrs, usp) XDR *xdrs; unsigned short *usp;

xdr_union(xdrs, dscmp, unp, choices, dfault) XDR *xdrs; int *dscmp; char *unp; struct xdr_discrim *choices; xdrproc_t dfault;

xdr_vector(xdrs, arrp, size, elsize, elproc) XDR *xdrs; char *arrp; uint size, elsize; xdrproc_t elproc;

xdr_void()

xdr_wrapstring(xdrs, sp) XDR *xdrs; char **sp;

void xdrmem_create(xdrs, addr, size, op) XDR *xdrs; char *addr; uint size; enum xdr_op op;

void xdrrec_create(xdrs, sendsize, recvsize, handle, readit, writeit) XDR *xdrs; uint sendsize, recvsize; char *handle; int (*readit)(), (*writeit)();

xdrrec_endofrecord(xdrs, sendnow) XDR *xdrs; int sendnow;

xdrrec_eof(xdrs) XDR *xdrs; int empty;

xdrrec_readbytes(xdrs, addr, nbytes) XDR *xdrs; caddr_t addr; u_int nbytes;

xdrrec_skiprecord(xdrs) XDR *xdrs;

void xdrstdio_create(xdrs, file, op) XDR *xdrs; FILE *file; enum xdr_op op;

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.


NOTE: All routines in librpc and libyp have been incorporated into libsocket. libyp and libsocket have been retained so that existing Makefiles will continue to work. New code should be linked with libsocket.

xdr_accepted_reply is used for encoding reply messages. It encodes the status of the RPC call in the XDR language format and in the case of success, it encodes the call results as well. This routine is useful for generating RPC-style messages without using the RPC package. This routine returns TRUE if it succeeds, FALSE otherwise.

xdr_array ia 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 1 if it succeeds, 0 otherwise.

xdr_authunix_parms is used for describing externally the authentication credentials supported in SCO OpenServer NFS. It is useful for generating these credentials without using the RPC authentication package.

xdr_bool is a filter primitive that translates between booleans (C integers) and their external representations. When encoding data, this filter produces values of either 1 or 0. This routine returns 1 if it succeeds, 0 otherwise.

xdr_bytes is 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 1 if it succeeds, 0 otherwise.

xdr_callhdr is used for describing RPC messages externally; it is useful for generating RPC-style messages without using the RPC package.

xdr_callmsg is used for describing RPC messages externally; it is useful for generating RPC-style messages without using the RPC package.

xdr_char is a filter primitive that translates between C characters and their external representations. This routine returns 1 if it succeeds, 0 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.

xdr_destroy is 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 is a filter primitive that translates between C double precision numbers and their external representations. This routine returns 1 if it succeeds, 0 otherwise.

xdr_enum is a filter primitive that translates between C enums (actually integers) and their external representations. This routine returns 1 if it succeeds, 0 otherwise.

xdr_float is a filter primitive that translates between C floats and their external representations. This routine returns 1 if it succeeds, 0 otherwise.

xdr_free is a 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).

xdr_getpos is 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.

xdr_inline is 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 that pointer is cast to long *.


NOTE: 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 is a filter primitive that translates between C integers and their external representations. It returns 1 if it succeeds, 0 otherwise.

xdr_long is a filter primitive that translates between C long integers and their external representations. It returns 1 if it succeeds, 0 otherwise.

xdr_opaque is 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 1 if it succeeds, 0 otherwise.

xdr_opaque_auth is used for describing RPC messages externally; it is useful for generating RPC-style messages without using the RPC package.

xdr_pmap is used for describing parameters to various portmap procedures externally; it is useful for generating these parameters without using the pmap interface.

xdr_pmaplist is used for describing a list of port mappings externally; it is useful for generating these parameters without using the pmap interface.

xdr_pointer is like xdr_reference in that it XDR's pointers, but the difference is that xdr_pointer serializes NULL pointers, whereas xdr_reference does not. Thus xdr_pointer can XDR recursive data structures, such as binary trees or linked lists, correctly, whereas xdr_reference will fail.

xdr_reference is a primitive that provides pointer-chasing within structures. The parameter pp is the address of the pointer; size is the sizeof the structure to which *pp points, and proc is an XDR procedure that filters the structure between its C form and its external representation. This routine returns 1 if it succeeds, 0 otherwise.


NOTE: This routine does not understand NULL pointers. Use xdr_pointer instead.

xdr_rejected_reply is used for describing RPC messages externally; it is useful for generating RPC-style messages without using the RPC package.

xdr_replymsg is used for describing RPC messages externally; it is useful for generating RPC style messages without using the RPC package.

xdr_setpos is 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 1 if the XDR stream could be repositioned, 0 otherwise.


NOTE: 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 is a filter primitive that translates between C short integers and their external representations. It returns 1 if it succeeds, 0 otherwise.

xdr_string is a filter primitive that translates between C strings and their corresponding external representations. Strings cannot be longer than maxsize. Note that sp is the address of the string's pointer. This routine returns 1 if it succeeds, 0 otherwise.

xdr_u_char is a filter primitive that translates between unsigned C characters and their external representations. It returns 1 if it succeeds, 0 otherwise.

xdr_u_int is a filter primitive that translates between C unsigned integers and their external representations. It returns 1 if it succeeds, 0 otherwise.

xdr_u_long is a filter primitive that translates between C unsigned long integers and their external representations. It returns 1 if it succeeds, 0 otherwise.

xdr_u_short is a filter primitive that translates between C unsigned short integers and their external representations. It returns 1 if it succeeds, 0 otherwise.

xdr_union is 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 xdrproc_t procedure is called (if it is not NULL). This routine returns 1 if it succeeds, 0 otherwise.

xdr_vector is 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 and 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 1 if it succeeds, 0 otherwise.

xdr_void always returns one. It may be passed to RPC routines that require a function parameter, where nothing is to be done.

xdr_wrapstring is a primitive that calls xdr_string(xdrs, sp, LASTUNSIGNED); where LASTUNSIGNED is the maximum value of an unsigned integer. xdr_wrapstring is useful 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. This routine returns 1 if it succeeds, 0 otherwise.

xdrmem_create initializes the XDR stream object to which xdrs points. 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).

xdrrec_create initializes the XDR stream object to which xdrs points. The stream's data is written to a buffer of size sendsize; a value of 0 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 UNIX system calls read and write, except that handle is passed to the former routines as the first parameter. Note that the XDR stream's op field must be set by the caller.


NOTE: This XDR stream implements an intermediate record stream. Therefore, there are additional bytes in the stream to provide record boundary information.

xdrrec_endofrecord 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 1 if it succeeds, 0 otherwise.

xdrrec_eof can be invoked only on streams created by xdrrec_create. After consuming the rest of the current record in the stream, this routine returns 1 if the stream has no more input, 0 otherwise.

xdrrec_readbytes can be invoked only on streams created by xdrrec_create. It attempts to read nbytes bytes from the XDR stream into the buffer pointed to by addr. On success it returns the number of bytes read. On failure, it returns -1. A return value of 0 indicates an end of record.

xdrrec_skiprecord 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 1 if it succeeds, 0 otherwise.

xdrstdio_create initializes the XDR stream object to which xdrs points. 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).


NOTE: The destroy routine associated with such XDR streams calls fflush on the file stream, but never fclose.

See also

rpc(NS)
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003