Networking Services Library Functions xdrcreate(3NSL)
NAME
xdrcreate, xdrdestroy, xdrmemcreate, xdrreccreate,
xdrstdiocreate - library routines for external data
representation stream creation
SYNOPSIS
#include
void xdrdestroy(XDR *xdrs);
void xdrmemcreate(XDR *xdrs, const caddrt addr, const uintt size,
const enum xdrop op);
void xdrreccreate(XDR *xdrs, const uintt sendsz, const uintt recvsz,
const caddrt handle, const int (*readit)const void *readhandle,
char *buf, const int len, const int (*writeit)
const void *writehandle, const char *buf, const int len);
void xdrstdiocreate(XDR *xdrs, FILE *
file, const enum xdrop op);
DESCRIPTION
The 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, which
must be created before any data can be translated into XDR
format.
Routines
See rpc(3NSL) for the definition of the XDR CLIENT and
SVCXPRT data structures. Any buffers passed to the XDR rou-
tines must be properly aligned. Use malloc(3C) to allocate
these buffers or be sure that the buffer address is divisi-
ble evenly by four.
xdrdestroy() A macro that invokes the destroy rou-
tine associated with the XDR stream,
xdrs. Private data structures associ-
ated with the stream are freed. Using
xdrs after xdrdestroy() is invoked is
undefined.
SunOS 5.11 Last change: 26 Sep 2000 1
Networking Services Library Functions xdrcreate(3NSL)
xdrmemcreate() 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 less than size bytes long. The
op determines the direction of the XDR
stream. The value of op can be either
XDRENCODE, XDRDECODE, or XDRFRE.
xdrreccreate() This routine initializes the read-
oriented XDR stream object pointed to
by xdrs. The stream's data is written
to a buffer of size sendsz. A value of
0 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 0 value. When a stream's
output buffer is full, writeit is
called. Similarly, when a stream's
input buffer is empty, xdrreccreate()
calls readit. The behavior of these two
routines is similar to the system calls
read() and write(), except that an
appropriate handle, readhandle or
writehandle, is passed to the former
routines as the first parameter instead
of a file descriptor. See read(2) and
write(2), respectively. The XDR
stream's op field must be set by the
caller.
This XDR stream implements an inter-
mediate record stream. Therefore, addi-
tional bytes in the stream are provided
for record boundary information.
xdrstdiocreate() 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. The value of op can
be either XDRENCODE, XDRDECODE, or
XDRFRE.
The destroy routine associated with XDR
streams calls fflush() on the file
stream, but never fclose(). See
fclose(3C).
SunOS 5.11 Last change: 26 Sep 2000 2
Networking Services Library Functions xdrcreate(3NSL)
A failure of any of these functions can be detected by first
initializing the xops field in the XDR structure (xdrs->
xops) to NUL before calling the xdr*create() function.
If the xops field is still NUL, after the return from the
xdr*create() function, the call has failed. If the xops
field contains some other value, assume that the call has
succeeded.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
MT-Level MT-Safe
SEE ALSO
read(2), write(2), fclose(3C), malloc(3C), rpc(3NSL),
xdradmin(3NSL), xdrcomplex(3NSL), xdrsimple(3NSL), attri-
butes(5)
SunOS 5.11 Last change: 26 Sep 2000 3
|