freebsd-dev/lib/libc/xdr/xdr.3

734 lines
14 KiB
Groff
Raw Normal View History

1994-08-07 18:39:35 +00:00
.\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
1999-08-28 00:22:10 +00:00
.\" $FreeBSD$
.\"
2001-01-18 12:56:17 +00:00
.Dd February 16, 1988
.Dt XDR 3
.Os
.Sh NAME
.Nm xdr
.Nd "library routines for external data representation"
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.Fd "#include <rpc/types.h>"
2001-01-18 12:56:17 +00:00
.Fd "#include <rpc/xdr.h>"
.Pp
See
.Sx DESCRIPTION
for function declarations.
.Sh DESCRIPTION
1994-08-07 18:39:35 +00:00
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.
2001-01-18 12:56:17 +00:00
.Pp
.Bl -tag -width indent -compact
.It Xo
.Ft int
.Xc
.It Xo
.Fo xdr_array
.Fa "XDR *xdrs"
.Fa "char **arrp"
.Fa "u_int *sizep"
.Fa "u_int maxsize"
.Fa "u_int elsize"
.Fa "xdrproc_t elproc"
.Fc
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between variable-length
arrays
and their corresponding external representations.
The
1994-08-07 18:39:35 +00:00
parameter
2001-01-18 12:56:17 +00:00
.Fa arrp
1994-08-07 18:39:35 +00:00
is the address of the pointer to the array, while
2001-01-18 12:56:17 +00:00
.Fa sizep
1994-08-07 18:39:35 +00:00
is the address of the element count of the array;
this element count cannot exceed
2001-01-18 12:56:17 +00:00
.Fa maxsize .
1994-08-07 18:39:35 +00:00
The parameter
2001-01-18 12:56:17 +00:00
.Fa elsize
1994-08-07 18:39:35 +00:00
is the
2001-01-18 12:56:17 +00:00
.Ic sizeof
1994-08-07 18:39:35 +00:00
each of the array's elements, and
2001-01-18 12:56:17 +00:00
.Fa elproc
1994-08-07 18:39:35 +00:00
is an
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
filter that translates between
the array elements' C form, and their external
representation.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_bool "XDR *xdrs" "bool_t *bp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between booleans (C
integers)
and their external representations.
When encoding data, this
1994-08-07 18:39:35 +00:00
filter produces values of either one or zero.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_bytes "XDR *xdrs" "char **sp" "u_int *sizep" "u_int maxsize"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between counted byte
strings and their external representations.
The parameter
2001-01-18 12:56:17 +00:00
.Fa sp
is the address of the string pointer.
The length of the
1994-08-07 18:39:35 +00:00
string is located at address
2001-01-18 12:56:17 +00:00
.Fa sizep ;
1994-08-07 18:39:35 +00:00
strings cannot be longer than
2001-01-18 12:56:17 +00:00
.Fa maxsize .
1994-08-07 18:39:35 +00:00
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_char "XDR *xdrs" "char *cp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
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
1994-08-07 18:39:35 +00:00
consider
2001-01-18 12:56:17 +00:00
.Fn xdr_bytes ,
.Fn xdr_opaque
1994-08-07 18:39:35 +00:00
or
2001-01-18 12:56:17 +00:00
.Fn xdr_string .
.Pp
.It Xo
.Ft void
.Xc
.It Xo
.Fn xdr_destroy "XDR *xdrs"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A macro that invokes the destroy routine associated with the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream,
2001-01-18 12:56:17 +00:00
.Fa xdrs .
1994-08-07 18:39:35 +00:00
Destruction usually involves freeing private data structures
2001-01-18 12:56:17 +00:00
associated with the stream.
Using
.Fa xdrs
1994-08-07 18:39:35 +00:00
after invoking
2001-01-18 12:56:17 +00:00
.Fn xdr_destroy
1994-08-07 18:39:35 +00:00
is undefined.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_double "XDR *xdrs" "double *dp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C
2001-01-18 12:56:17 +00:00
.Vt double
1994-08-07 18:39:35 +00:00
precision numbers and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_enum "XDR *xdrs" "enum_t *ep"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C
2001-01-18 12:56:17 +00:00
.Vt enum Ns s
1994-08-07 18:39:35 +00:00
(actually integers) and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_float "XDR *xdrs" "float *fp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C
2001-01-18 12:56:17 +00:00
.Vt float Ns s
1994-08-07 18:39:35 +00:00
and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft void
.Xc
.It Xo
.Fn xdr_free "xdrproc_t proc" "char *objp"
.Xc
.Pp
Generic freeing routine.
The first argument is the
2001-01-18 12:56:17 +00:00
.Tn XDR
routine for the object being freed.
The second argument
is a pointer to the object itself.
Note: the pointer passed
1994-08-07 18:39:35 +00:00
to this routine is
2001-01-18 12:56:17 +00:00
.Em not
1994-08-07 18:39:35 +00:00
freed, but what it points to
2001-01-18 12:56:17 +00:00
.Em is
1994-08-07 18:39:35 +00:00
freed (recursively).
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft u_int
.Xc
.It Xo
.Fn xdr_getpos "XDR *xdrs"
.Xc
.Pp
A macro that invokes the get\-position routine
1994-08-07 18:39:35 +00:00
associated with the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream,
2001-01-18 12:56:17 +00:00
.Fa xdrs .
1994-08-07 18:39:35 +00:00
The routine returns an unsigned integer,
which indicates the position of the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
byte stream.
A desirable feature of
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
streams is that simple arithmetic works with this number,
although the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream instances need not guarantee this.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft "long *"
.Xc
.It Xo
.Fn xdr_inline "XDR *xdrs" "int len"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A macro that invokes the in-line routine associated with the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream,
2001-01-18 12:56:17 +00:00
.Fa xdrs .
1994-08-07 18:39:35 +00:00
The routine returns a pointer
to a contiguous piece of the stream's buffer;
2001-01-18 12:56:17 +00:00
.Fa len
1994-08-07 18:39:35 +00:00
is the byte length of the desired buffer.
Note: pointer is cast to
2001-01-18 12:56:17 +00:00
.Vt "long *" .
.Pp
1994-08-07 18:39:35 +00:00
Warning:
2001-01-18 12:56:17 +00:00
.Fn xdr_inline
1994-08-07 18:39:35 +00:00
may return
2001-01-18 12:56:17 +00:00
.Dv NULL
1994-08-07 18:39:35 +00:00
(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.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_int "XDR *xdrs" "int *ip"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C integers
and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_long "XDR *xdrs" "long *lp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C
2001-01-18 12:56:17 +00:00
.Vt long
1994-08-07 18:39:35 +00:00
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft void
.Xc
.It Xo
.Fn xdrmem_create "XDR *xdrs" "char *addr" "u_int size" "enum xdr_op op"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
This routine initializes the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream object pointed to by
2001-01-18 12:56:17 +00:00
.Fa xdrs .
1994-08-07 18:39:35 +00:00
The stream's data is written to, or read from,
a chunk of memory at location
2001-01-18 12:56:17 +00:00
.Fa addr
1994-08-07 18:39:35 +00:00
whose length is no more than
2001-01-18 12:56:17 +00:00
.Fa size
bytes long.
The
.Fa op
1994-08-07 18:39:35 +00:00
determines the direction of the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream
(either
2001-01-18 12:56:17 +00:00
.Dv XDR_ENCODE ,
.Dv XDR_DECODE ,
1994-08-07 18:39:35 +00:00
or
2001-01-18 12:56:17 +00:00
.Dv XDR_FREE ) .
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_opaque "XDR *xdrs" "char *cp" "u_int cnt"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between fixed size opaque
data
and its external representation.
The parameter
2001-01-18 12:56:17 +00:00
.Fa cp
1994-08-07 18:39:35 +00:00
is the address of the opaque object, and
2001-01-18 12:56:17 +00:00
.Fa cnt
1994-08-07 18:39:35 +00:00
is its size in bytes.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_pointer "XDR *xdrs" "char **objpp" "u_int objsize" "xdrproc_t xdrobj"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
Like
2001-01-18 12:56:17 +00:00
.Fn xdr_reference
except that it serializes
.Dv NULL
1994-08-07 18:39:35 +00:00
pointers, whereas
2001-01-18 12:56:17 +00:00
.Fn xdr_reference
does not.
Thus,
.Fn xdr_pointer
1994-08-07 18:39:35 +00:00
can represent
recursive data structures, such as binary trees or
linked lists.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft void
.Xc
.It Xo
.Fo xdrrec_create
.Fa "XDR *xdrs"
.Fa "u_int sendsize"
.Fa "u_int recvsize"
.Fa "char *handle"
.Fa "int \*(lp*readit\*(rp\*(lp\*(rp"
.Fa "int \*(lp*writeit\*(rp\*(lp\*(rp"
.Fc
.Xc
.Pp
1994-08-07 18:39:35 +00:00
This routine initializes the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream object pointed to by
2001-01-18 12:56:17 +00:00
.Fa xdrs .
1994-08-07 18:39:35 +00:00
The stream's data is written to a buffer of size
2001-01-18 12:56:17 +00:00
.Fa sendsize ;
1994-08-07 18:39:35 +00:00
a value of zero indicates the system should use a suitable
default.
The stream's data is read from a buffer of size
2001-01-18 12:56:17 +00:00
.Fa recvsize ;
1994-08-07 18:39:35 +00:00
it too can be set to a suitable default by passing a zero
value.
When a stream's output buffer is full,
2001-01-18 12:56:17 +00:00
.Fn writeit
is called.
Similarly, when a stream's input buffer is empty,
.Fn readit
is called.
The behavior of these two routines is similar to
1994-08-07 18:39:35 +00:00
the
system calls
2001-01-18 12:56:17 +00:00
.Xr read 2
1994-08-07 18:39:35 +00:00
and
2001-01-18 12:56:17 +00:00
.Xr write 2 ,
1994-08-07 18:39:35 +00:00
except that
2001-01-18 12:56:17 +00:00
.Fa handle
1994-08-07 18:39:35 +00:00
is passed to the former routines as the first parameter.
Note: the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream's
2001-01-18 12:56:17 +00:00
.Fa op
1994-08-07 18:39:35 +00:00
field must be set by the caller.
2001-01-18 12:56:17 +00:00
.Pp
1994-08-07 18:39:35 +00:00
Warning: this
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream implements an intermediate record stream.
Therefore there are additional bytes in the stream
to provide record boundary information.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdrrec_endofrecord "XDR *xdrs" "int sendnow"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
This routine can be invoked only on
streams created by
2001-01-18 12:56:17 +00:00
.Fn xdrrec_create .
1994-08-07 18:39:35 +00:00
The data in the output buffer is marked as a completed
record,
and the output buffer is optionally written out if
2001-01-18 12:56:17 +00:00
.Fa sendnow
is non-zero.
This routine returns one if it succeeds, zero
1994-08-07 18:39:35 +00:00
otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdrrec_eof "XDR *xdrs"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
This routine can be invoked only on
streams created by
2001-01-18 12:56:17 +00:00
.Fn xdrrec_create .
1994-08-07 18:39:35 +00:00
After consuming the rest of the current record in the stream,
this routine returns one if the stream has no more input,
zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdrrec_skiprecord "XDR *xdrs"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
This routine can be invoked only on
streams created by
2001-01-18 12:56:17 +00:00
.Fn xdrrec_create .
1994-08-07 18:39:35 +00:00
It tells the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
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.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_reference "XDR *xdrs" "char **pp" "u_int size" "xdrproc_t proc"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A primitive that provides pointer chasing within structures.
The parameter
2001-01-18 12:56:17 +00:00
.Fa pp
1994-08-07 18:39:35 +00:00
is the address of the pointer;
2001-01-18 12:56:17 +00:00
.Fa size
1994-08-07 18:39:35 +00:00
is the
2001-01-18 12:56:17 +00:00
.Ic sizeof
1994-08-07 18:39:35 +00:00
the structure that
2001-01-18 12:56:17 +00:00
.Fa *pp
1994-08-07 18:39:35 +00:00
points to; and
2001-01-18 12:56:17 +00:00
.Fa proc
1994-08-07 18:39:35 +00:00
is an
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
procedure that filters the structure
between its C form and its external representation.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
1994-08-07 18:39:35 +00:00
Warning: this routine does not understand
2001-01-18 12:56:17 +00:00
.Dv NULL
pointers.
Use
2001-01-18 12:56:17 +00:00
.Fn xdr_pointer
1994-08-07 18:39:35 +00:00
instead.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_setpos "XDR *xdrs" "u_int pos"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A macro that invokes the set position routine associated with
the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream
2001-01-18 12:56:17 +00:00
.Fa xdrs .
1994-08-07 18:39:35 +00:00
The parameter
2001-01-18 12:56:17 +00:00
.Fa pos
1994-08-07 18:39:35 +00:00
is a position value obtained from
2001-01-18 12:56:17 +00:00
.Fn xdr_getpos .
1994-08-07 18:39:35 +00:00
This routine returns one if the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream could be repositioned,
and zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
1994-08-07 18:39:35 +00:00
Warning: it is difficult to reposition some types of
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
streams, so this routine may fail with one
type of stream and succeed with another.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_short "XDR *xdrs" "short *sp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C
2001-01-18 12:56:17 +00:00
.Vt short
1994-08-07 18:39:35 +00:00
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.Fd #ifdef _STDIO_H_
.Fd /* XDR using stdio library */
2001-01-18 12:56:17 +00:00
.It Xo
.Ft void
.Xc
.It Xo
.Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op"
.Xc
.Fd #endif
2001-01-18 12:56:17 +00:00
.Pp
1994-08-07 18:39:35 +00:00
This routine initializes the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream object pointed to by
2001-01-18 12:56:17 +00:00
.Fa xdrs .
1994-08-07 18:39:35 +00:00
The
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream data is written to, or read from, the Standard
2001-01-18 12:56:17 +00:00
.Tn I/O
1994-08-07 18:39:35 +00:00
stream
2001-01-18 12:56:17 +00:00
.Fa file .
1994-08-07 18:39:35 +00:00
The parameter
2001-01-18 12:56:17 +00:00
.Fa op
1994-08-07 18:39:35 +00:00
determines the direction of the
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
stream (either
2001-01-18 12:56:17 +00:00
.Dv XDR_ENCODE ,
.Dv XDR_DECODE ,
1994-08-07 18:39:35 +00:00
or
2001-01-18 12:56:17 +00:00
.Dv XDR_FREE ) .
.Pp
1994-08-07 18:39:35 +00:00
Warning: the destroy routine associated with such
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
streams calls
2001-01-18 12:56:17 +00:00
.Xr fflush 3
1994-08-07 18:39:35 +00:00
on the
2001-01-18 12:56:17 +00:00
.Fa file
1994-08-07 18:39:35 +00:00
stream, but never
2001-01-18 12:56:17 +00:00
.Xr fclose 3 .
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_string "XDR *xdrs" "char **sp" "u_int maxsize"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C strings and
their
corresponding external representations.
Strings cannot be longer than
2001-01-18 12:56:17 +00:00
.Fa maxsize .
Note:
.Fa sp
1994-08-07 18:39:35 +00:00
is the address of the string's pointer.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_u_char "XDR *xdrs" "unsigned char *ucp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between
2001-01-18 12:56:17 +00:00
.Vt unsigned
1994-08-07 18:39:35 +00:00
C characters and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_u_int "XDR *xdrs" "unsigned *up"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C
2001-01-18 12:56:17 +00:00
.Vt unsigned
1994-08-07 18:39:35 +00:00
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_u_long "XDR *xdrs" "unsigned long *ulp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C
2001-01-18 12:56:17 +00:00
.Vt "unsigned long"
1994-08-07 18:39:35 +00:00
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_u_short "XDR *xdrs" "unsigned short *usp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between C
2001-01-18 12:56:17 +00:00
.Vt "unsigned short"
1994-08-07 18:39:35 +00:00
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fo xdr_union
.Fa "XDR *xdrs"
.Fa "int *dscmp"
.Fa "char *unp"
.Fa "struct xdr_discrim *choices"
.Fa "bool_t \*(lp*defaultarm\*(rp\*(lp\*(rp"
.Fc
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between a discriminated C
2001-01-18 12:56:17 +00:00
.Vt union
and its corresponding external representation.
It first
1994-08-07 18:39:35 +00:00
translates the discriminant of the union located at
2001-01-18 12:56:17 +00:00
.Fa dscmp .
1994-08-07 18:39:35 +00:00
This discriminant is always an
2001-01-18 12:56:17 +00:00
.Vt enum_t .
1994-08-07 18:39:35 +00:00
Next the union located at
2001-01-18 12:56:17 +00:00
.Fa unp
is translated.
The parameter
.Fa choices
1994-08-07 18:39:35 +00:00
is a pointer to an array of
2001-01-18 12:56:17 +00:00
.Vt xdr_discrim
structures.
Each structure contains an ordered pair of
2001-01-18 12:56:17 +00:00
.Bq Va value , proc .
1994-08-07 18:39:35 +00:00
If the union's discriminant is equal to the associated
2001-01-18 12:56:17 +00:00
.Va value ,
1994-08-07 18:39:35 +00:00
then the
2001-01-18 12:56:17 +00:00
.Fn proc
is called to translate the union.
The end of the
.Vt xdr_discrim
1994-08-07 18:39:35 +00:00
structure array is denoted by a routine of value
2001-01-18 12:56:17 +00:00
.Dv NULL .
1994-08-07 18:39:35 +00:00
If the discriminant is not found in the
2001-01-18 12:56:17 +00:00
.Fa choices
1994-08-07 18:39:35 +00:00
array, then the
2001-01-18 12:56:17 +00:00
.Fn defaultarm
1994-08-07 18:39:35 +00:00
procedure is called (if it is not
2001-01-18 12:56:17 +00:00
.Dv NULL ) .
1994-08-07 18:39:35 +00:00
Returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fo xdr_vector
.Fa "XDR *xdrs"
.Fa "char *arrp"
.Fa "u_int size"
.Fa "u_int elsize"
.Fa "xdrproc_t elproc"
.Fc
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A filter primitive that translates between fixed-length
arrays
2001-01-18 12:56:17 +00:00
and their corresponding external representations.
The
1994-08-07 18:39:35 +00:00
parameter
2001-01-18 12:56:17 +00:00
.Fa arrp
1994-08-07 18:39:35 +00:00
is the address of the pointer to the array, while
2001-01-18 12:56:17 +00:00
.Fa size
is the element count of the array.
The parameter
.Fa elsize
1994-08-07 18:39:35 +00:00
is the
2001-01-18 12:56:17 +00:00
.Ic sizeof
1994-08-07 18:39:35 +00:00
each of the array's elements, and
2001-01-18 12:56:17 +00:00
.Fa elproc
1994-08-07 18:39:35 +00:00
is an
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
filter that translates between
the array elements' C form, and their external
representation.
This routine returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_void void
.Xc
.Pp
1994-08-07 18:39:35 +00:00
This routine always returns one.
It may be passed to
2001-01-18 12:56:17 +00:00
.Tn RPC
1994-08-07 18:39:35 +00:00
routines that require a function parameter,
where nothing is to be done.
2001-01-18 12:56:17 +00:00
.Pp
.It Xo
.Ft int
.Xc
.It Xo
.Fn xdr_wrapstring "XDR *xdrs" "char **sp"
.Xc
.Pp
1994-08-07 18:39:35 +00:00
A primitive that calls
2001-01-18 12:56:17 +00:00
.Fn xdr_string xdrs sp MAXUN.UNSIGNED ;
1994-08-07 18:39:35 +00:00
where
2001-01-18 12:56:17 +00:00
.Dv MAXUN.UNSIGNED
1994-08-07 18:39:35 +00:00
is the maximum value of an unsigned integer.
2001-01-18 12:56:17 +00:00
.Fn xdr_wrapstring
1994-08-07 18:39:35 +00:00
is handy because the
2001-01-18 12:56:17 +00:00
.Tn RPC
1994-08-07 18:39:35 +00:00
package passes a maximum of two
2001-01-18 12:56:17 +00:00
.Tn XDR
1994-08-07 18:39:35 +00:00
routines as parameters, and
2001-01-18 12:56:17 +00:00
.Fn xdr_string ,
1994-08-07 18:39:35 +00:00
one of the most frequently used primitives, requires three.
Returns one if it succeeds, zero otherwise.
2001-01-18 12:56:17 +00:00
.El
.Sh SEE ALSO
.Xr rpc 3
.Rs
.%T "eXternal Data Representation Standard: Protocol Specification"
.Re
.Rs
.%T "eXternal Data Representation: Sun Technical Notes"
.Re
.Rs
.%T "XDR: External Data Representation Standard"
.%O RFC1014
.%Q "Sun Microsystems, Inc., USC\-ISI"
.Re