XDR library routines allow C programmers to describe arbitrary 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 deal with the creation of XDR streams. XDR streams have to be created before any data can be translated into XDR format.
The
XDR,
CLIENT,
and
SVCXPRT
data structures are defined in the
RPC/XDR
Library Definitions of the
[a manual with the abbreviation NETP].
#include <rpc/xdr.h>
void xdr_destroy(xdrs) XDR *xdrs;
Invoke 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.
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.
size
should be a multiple of 4.
The
op
determines the direction of the
XDR
stream
(either
XDR_ENCODE,
XDR_DECODE,
or
XDR_FREE).
void xdrrec_create(xdrs, sendsz, recvsz, handle, readit, writeit) XDR *xdrs; u_int sendsz, recvsz; 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 sendsz; a value of zero indicates the system should use a suitable default. The stream's data is read from a buffer of size recvsz; 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 read.2v and write.2v 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. sendsz and recvsz should be multiples of 4.
Warning:
This
XDR
stream implements an intermediate record stream.
Therefore there are additional bytes in the stream
to provide record boundary information.
void xdrstdio_create(xdrs, filep, op) XDR *xdrs; FILE *filep; 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 filep. 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.3v
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97