'\"macro stdmacro
.if n .pH g3n.xdr_create @(#)xdr_create	40.4 of 10/10/89
.\" Copyright 1989 AT&T
'\"macro stdmacro
.nr X
.if \nX=0 .ds x} xdr_create 3N "" "\&"
.if \nX=1 .ds x} xdr_create 3N ""
.if \nX=2 .ds x} xdr_create 3N "" "\&"
.if \nX=3 .ds x} xdr_create "" "" "\&"
.TH \*(x}
.SH NAME
.na
\f4xdr_create\fP:  \f4 xdr_destroy\f1, \f4xdrmem_create\f1, \f4xdrrec_create\f1, \f4xdrstdio_create\f1 \- library routines for external data representation stream creation
.ad
.SH DESCRIPTION
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.
.P
These routines deal with the creation of XDR streams.
XDR streams have to be created before any data can be translated into
XDR format.
.SS Routines
See \f4rpc\fP(3N) for the definition of the 
\f4XDR\f1,
\f4CLIENT\f1,
and
\f4SVCXPRT\f1
data structures.
.br
.P
.ft 4
.nf
#include <rpc/xdr.h>
.fi
.ft 1
.br
.if t .ne 8
.P
.ft 4
.nf
.sp .5
void
xdr_destroy(XDR *xdrs);
.fi
.ft 1
.IP
A macro that invokes the destroy routine associated with the
XDR stream,
\f2xdrs\f1.
Destruction usually involves freeing private data structures
associated with the stream.
Using
\f2xdrs\f1
after invoking
\f4xdr_destroy\f1
is undefined.
.br
.if t .ne 12
.P
.ft 4
.nf
.sp .5
void
xdrmem_create(XDR *xdrs, const caddr_t addr,
	const u_int size, const enum xdr_op op);
.fi
.ft 1
.IP
This routine initializes the
XDR stream object pointed to by
\f2xdrs\f1.
The stream's data is written to,
or read from,
a chunk of memory at location
\f2addr\f1
whose length is no more than
\f2size\f1
bytes long.
The
\f2op\f1
determines the direction of the
XDR stream (either
\f4XDR_ENCODE\f1,
\f4XDR_DECODE\f1,
or
\f4XDR_FREE\f1).
.br
.if t .ne 15
.P
.ft 4
.nf
.sp .5
void
xdrrec_create(XDR *xdrs, const u_int sendsz,
	const u_int recvsz, const caddr_t handle,
	const int (*readit)(const void *, char *, const int),
	const int (*writeit)(const void *, const char *, const int));
.fi
.ft 1
.IP
This routine initializes the
XDR stream object pointed to by
\f2xdrs\f1.
The stream's data is written to a buffer of size
\f2sendsz\f1;
a value of \f40\f1 indicates the system should use a suitable
default.
The stream's data is read from a buffer of size
\f2recvsz\f1;
it too can be set to a suitable default by passing a \f40\f1
value.
When a stream's output buffer is full,
\f2writeit\f1
is called.
Similarly,
when a stream's input buffer is empty,
\f2readit\f1
is called.
The behavior of these two routines is similar to
the system calls
\f4read\f1
and
\f4write\f1 [see \f4read\fP(2) and \f4write\fP(2), respectively],
except that
\f2handle\f1
(\f4CLIENT\f1, or
\f4SVCXPRT\f1)
is passed to the former routines as the first parameter
instead of a file descriptor.
Note:
the XDR stream's
\f2op\f1
field must be set by the caller.
.IP
Warning:
this XDR
stream implements an intermediate record stream.
Therefore there are additional bytes in the stream
to provide record boundary information.
.br
.if t .ne 10
.P
.ft 4
.nf
.sp .5
void
xdrstdio_create(XDR *xdrs, FILE *file, const enum xdr_op op);
.fi
.ft 1
.IP
This routine initializes the
XDR
stream object pointed to by
\f2xdrs\f1.
The
XDR
stream data is written to,
or read from,
the standard
I/O
stream
\f2file\f1.
The parameter
\f2op\f1
determines the direction of the
XDR
stream (either
\f4XDR_ENCODE\f1,
\f4XDR_DECODE\f1,
or
\f4XDR_FREE\f1).
.IP
Warning:
the destroy routine associated with such
XDR
streams calls
\f4fflush\f1
on the
\f2file\f1
stream,
but never
\f4fclose\f1
[see \f4fclose\fP(3S)].
.SH SEE ALSO
.na
\f4fclose\fP(3S),
\f4read\fP(2),
\f4rpc\fP(3N),
\f4write\fP(2),
\f4xdr_admin\fP(3N),
\f4xdr_complex\fP(3N),
\f4xdr_simple\fP(3N).
.ad
