xdr_pointer (3) ( Русские man: Библиотечные вызовы )
xdr_pointer (3) ( Linux man: Библиотечные вызовы )
BSD mandoc
NAME
xdrxdr_arrayxdr_boolxdr_bytesxdr_charxdr_destroyxdr_doublexdr_enumxdr_floatxdr_freexdr_getposxdr_hyperxdr_inlinexdr_intxdr_longxdr_longlong_txdrmem_createxdr_opaquexdr_pointerxdrrec_createxdrrec_endofrecordxdrrec_eofxdrrec_skiprecordxdr_referencexdr_setposxdr_shortxdrstdio_createxdr_stringxdr_u_charxdr_u_hyperxdr_u_intxdr_u_longxdr_u_longlong_txdr_u_shortxdr_unionxdr_vectorxdr_voidxdr_wrapstring
- library routines for external data representation
LIBRARY
Lb libc
SYNOPSIS
#include <rpc/types.h>
#include <rpc/xdr.h>
See
Sx DESCRIPTION
for function declarations.
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.
int
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
A filter primitive that translates between variable-length
arrays
and their corresponding external representations.
The
Fa arrp
argument
is the address of the pointer to the array, while
Fa sizep
is the address of the element count of the array;
this element count cannot exceed
Fa maxsize .
The
Fa elsize
argument
is the
sizeof
each of the array's elements, and
Fa elproc
is an
XDR
filter that translates between
the array elements' C form, and their external
representation.
This routine returns one if it succeeds, zero otherwise.
int
xdr_bool (XDR *xdrs bool_t *bp);
A filter primitive that translates between booleans (C
integers)
and their external representations.
When encoding data, this
filter produces values of either one or zero.
This routine returns one if it succeeds, zero otherwise.
A filter primitive that translates between counted byte
strings and their external representations.
The
Fa sp
argument
is the address of the string pointer.
The length of the
string is located at address
Fa sizep ;
strings cannot be longer than
Fa maxsize .
This routine returns one if it succeeds, zero otherwise.
int
xdr_char (XDR *xdrs char *cp);
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
consider
xdr_bytes (,);
xdr_opaque ();
or
xdr_string (.);
void
xdr_destroy (XDR *xdrs);
A macro that invokes the destroy routine associated with the
XDR
stream,
Fa xdrs .
Destruction usually involves freeing private data structures
associated with the stream.
Using
Fa xdrs
after invoking
xdr_destroy ();
is undefined.
int
xdr_double (XDR *xdrs double *dp);
A filter primitive that translates between C
Vt double
precision numbers and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_enum (XDR *xdrs enum_t *ep);
A filter primitive that translates between C
Vt enum Ns s
(actually integers) and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_float (XDR *xdrs float *fp);
A filter primitive that translates between C
Vt float Ns s
and their external representations.
This routine returns one if it succeeds, zero otherwise.
void
xdr_free (xdrproc_t proc void *objp);
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).
u_int
xdr_getpos (XDR *xdrs);
A macro that invokes the get-position routine
associated with the
XDR
stream,
Fa 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.
int
xdr_hyper (XDR *xdrs quad_t *llp);
A filter primitive that translates between ANSI C
Vt long long
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
long *
xdr_inline (XDR *xdrs int len);
A macro that invokes the in-line routine associated with the
XDR
stream,
Fa xdrs .
The routine returns a pointer
to a contiguous piece of the stream's buffer;
Fa len
is the byte length of the desired buffer.
Note: pointer is cast to
Vt long * .
Warning:
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.
int
xdr_int (XDR *xdrs int *ip);
A filter primitive that translates between C integers
and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_long (XDR *xdrs long *lp);
A filter primitive that translates between C
Vt long
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_longlong_t (XDR *xdrs quad_t *llp);
A filter primitive that translates between ANSI C
Vt long long
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
This routine initializes the
XDR
stream object pointed to by
Fa xdrs .
The stream's data is written to, or read from,
a chunk of memory at location
Fa addr
whose length is no more than
Fa size
bytes long.
The
Fa op
argument
determines the direction of the
XDR
stream
(either
XDR_ENCODEXDR_DECODE
or
XDR_FREE )
int
xdr_opaque (XDR *xdrs char *cp u_int cnt);
A filter primitive that translates between fixed size opaque
data
and its external representation.
The
Fa cp
argument
is the address of the opaque object, and
Fa cnt
is its size in bytes.
This routine returns one if it succeeds, zero otherwise.
Like
xdr_reference ();
except that it serializes
NULL
pointers, whereas
xdr_reference ();
does not.
Thus,
xdr_pointer ();
can represent
recursive data structures, such as binary trees or
linked lists.
void
Fo xdrrec_create
Fa XDR *xdrs
Fa u_int sendsize
Fa u_int recvsize
Fa void *handle
Fa int *readit
Fa int *writeit
Fc
This routine initializes the
XDR
stream object pointed to by
Fa xdrs .
The stream's data is written to a buffer of size
Fa sendsize ;
a value of zero indicates the system should use a suitable
default.
The stream's data is read from a buffer of size
Fa 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
system calls
read(2)
and
write(2),
except that
Fa handle
is passed to the former routines as the first argument.
Note: the
XDR
stream's
Fa op
field must be set by the caller.
Warning: this
XDR
stream implements an intermediate record stream.
Therefore there are additional bytes in the stream
to provide record boundary information.
int
xdrrec_endofrecord (XDR *xdrs int sendnow);
This routine 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
Fa sendnow
is non-zero.
This routine returns one if it succeeds, zero
otherwise.
int
xdrrec_eof (XDR *xdrs);
This routine can be invoked only on
streams created by
xdrrec_create (.);
After consuming the rest of the current record in the stream,
this routine returns one if the stream has no more input,
zero otherwise.
int
xdrrec_skiprecord (XDR *xdrs);
This routine 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 one if it succeeds, zero otherwise.
A primitive that provides pointer chasing within structures.
The
Fa pp
argument
is the address of the pointer;
Fa size
is the
sizeof
the structure that
Fa *pp
points to; and
Fa proc
is an
XDR
procedure that filters the structure
between its C form and its external representation.
This routine returns one if it succeeds, zero otherwise.
Warning: this routine does not understand
NULL
pointers.
Use
xdr_pointer ();
instead.
int
xdr_setpos (XDR *xdrs u_int pos);
A macro that invokes the set position routine associated with
the
XDR
stream
Fa xdrs .
The
Fa pos
argument
is a position value obtained from
xdr_getpos (.);
This routine returns one if the
XDR
stream could be repositioned,
and zero otherwise.
Warning: it is difficult to reposition some types of
XDR
streams, so this routine may fail with one
type of stream and succeed with another.
int
xdr_short (XDR *xdrs short *sp);
A filter primitive that translates between C
Vt short
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
This routine initializes the
XDR
stream object pointed to by
Fa xdrs .
The
XDR
stream data is written to, or read from, the Standard
I/O
stream
Fa file .
The
Fa op
argument
determines the direction of the
XDR
stream (either
XDR_ENCODEXDR_DECODE
or
XDR_FREE )
Warning: the destroy routine associated with such
XDR
streams calls
fflush(3)
on the
Fa file
stream, but never
fclose(3).
int
xdr_string (XDR *xdrs char **sp u_int maxsize);
A filter primitive that translates between C strings and
their
corresponding external representations.
Strings cannot be longer than
Fa maxsize .
Note:
Fa sp
is the address of the string's pointer.
This routine returns one if it succeeds, zero otherwise.
int
xdr_u_char (XDR *xdrs unsigned char *ucp);
A filter primitive that translates between
Vt unsigned
C characters and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_u_hyper (XDR *xdrs u_quad_t *ullp);
A filter primitive that translates between
Vt unsigned
ANSI C
Vt long long
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_u_int (XDR *xdrs unsigned *up);
A filter primitive that translates between C
Vt unsigned
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_u_long (XDR *xdrs unsigned long *ulp);
A filter primitive that translates between C
Vt unsigned long
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_u_longlong_t (XDR *xdrs u_quad_t *ullp);
A filter primitive that translates between
Vt unsigned
ANSI C
Vt long long
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
xdr_u_short (XDR *xdrs unsigned short *usp);
A filter primitive that translates between C
Vt unsigned short
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
int
Fo xdr_union
Fa XDR *xdrs
Fa enum_t *dscmp
Fa char *unp
Fa const struct xdr_discrim *choices
Fa xdrproc_t defaultarm
Fc
A filter primitive that translates between a discriminated C
Vt union
and its corresponding external representation.
It first
translates the discriminant of the union located at
Fa dscmp .
This discriminant is always an
Vt enum_t .
Next the union located at
Fa unp
is translated.
The
Fa choices
argument
is a pointer to an array of
Vt xdr_discrim
structures.
Each structure contains an ordered pair of
Bq Va 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
Vt xdr_discrim
structure array is denoted by a routine of value
NULL
If the discriminant is not found in the
Fa choices
array, then the
defaultarm ();
procedure is called (if it is not
NULL )
Returns one if it succeeds, zero otherwise.
int
Fo xdr_vector
Fa XDR *xdrs
Fa char *arrp
Fa u_int size
Fa u_int elsize
Fa xdrproc_t elproc
Fc
A filter primitive that translates between fixed-length
arrays
and their corresponding external representations.
The
Fa arrp
argument
is the address of the pointer to the array, while
Fa size
is the element count of the array.
The
Fa elsize
argument
is the
sizeof
each of the array's elements, and
Fa elproc
is an
XDR
filter that translates between
the array elements' C form, and their external
representation.
This routine returns one if it succeeds, zero otherwise.
int
xdr_void (void);
This routine always returns one.
It may be passed to
RPC
routines that require a function argument,
where nothing is to be done.
int
xdr_wrapstring (XDR *xdrs char **sp);
A primitive that calls
xdr_string (xdrs sp MAXUN.UNSIGNED ;);
where
MAXUN.UNSIGNED
is the maximum value of an unsigned integer.
The
xdr_wrapstring ();
function
is handy because the
RPC
package passes a maximum of two
XDR
routines as arguments, and
xdr_string (,);
one of the most frequently used primitives, requires three.
Returns one if it succeeds, zero otherwise.