1XDR(3)                     Linux Programmer's Manual                    XDR(3)
2
3
4

NAME

6       xdr - library routines for external data representation
7

SYNOPSIS AND DESCRIPTION

9       These  routines  allow  C programmers to describe arbitrary data struc‐
10       tures in a machine-independent  fashion.   Data  for  remote  procedure
11       calls are transmitted using these routines.
12
13       The  prototypes  below  are declared in <rpc/xdr.h> and make use of the
14       following types:
15
16           typedef int bool_t;
17
18       typedef bool_t (*xdrproc_t) (XDR *, void *,...);
19
20       For the declaration of the XDR type, see <rpc/xdr.h>.
21
22       bool_t xdr_array(XDR *xdrs, char **arrp, unsigned int *sizep,
23                        unsigned int maxsize, unsigned int elsize,
24                        xdrproc_t elproc);
25
26              A  filter  primitive  that  translates  between  variable-length
27              arrays  and  their  corresponding external representations.  The
28              argument arrp is the address of the pointer to the array,  while
29              sizep  is  the  address  of the element count of the array; this
30              element count cannot exceed maxsize.  The argument elsize is the
31              sizeof each of the array's elements, and elproc is an XDR filter
32              that translates between the array elements' C  form,  and  their
33              external  representation.   This  routine returns one if it suc‐
34              ceeds, zero otherwise.
35
36       bool_t xdr_bool(XDR *xdrs, bool_t *bp);
37
38              A filter primitive that translates between booleans (C integers)
39              and  their  external  representations.  When encoding data, this
40              filter produces values of either  one  or  zero.   This  routine
41              returns one if it succeeds, zero otherwise.
42
43       bool_t xdr_bytes(XDR *xdrs, char **sp, unsigned int *sizep,
44                        unsigned int maxsize);
45
46              A  filter primitive that translates between counted byte strings
47              and their external representations.   The  argument  sp  is  the
48              address  of  the  string  pointer.   The length of the string is
49              located at address sizep; strings cannot be longer than maxsize.
50              This routine returns one if it succeeds, zero otherwise.
51
52       bool_t xdr_char(XDR *xdrs, char *cp);
53
54              A  filter  primitive  that  translates  between C characters and
55              their external representations.  This routine returns one if  it
56              succeeds,  zero  otherwise.   Note:  encoded  characters are not
57              packed, and occupy 4 bytes each.  For arrays of  characters,  it
58              is   worthwhile   to   consider   xdr_bytes(),  xdr_opaque()  or
59              xdr_string().
60
61       void xdr_destroy(XDR *xdrs);
62
63              A macro that invokes the destroy routine associated with the XDR
64              stream, xdrs.  Destruction usually involves freeing private data
65              structures associated with the stream.  Using xdrs after  invok‐
66              ing xdr_destroy() is undefined.
67
68       bool_t xdr_double(XDR *xdrs, double *dp);
69
70              A  filter  primitive  that translates between C double precision
71              numbers  and  their  external  representations.   This   routine
72              returns one if it succeeds, zero otherwise.
73
74       bool_t xdr_enum(XDR *xdrs, enum_t *ep);
75
76              A  filter  primitive  that  translates between C enums (actually
77              integers) and  their  external  representations.   This  routine
78              returns one if it succeeds, zero otherwise.
79
80       bool_t xdr_float(XDR *xdrs, float *fp);
81
82              A  filter  primitive  that translates between C floats and their
83              external representations.  This routine returns one if  it  suc‐
84              ceeds, zero otherwise.
85
86       void xdr_free(xdrproc_t proc, char *objp);
87
88              Generic  freeing routine.  The first argument is the XDR routine
89              for the object being freed.  The second argument is a pointer to
90              the  object itself.  Note: the pointer passed to this routine is
91              not freed, but what it points to is freed (recursively).
92
93       unsigned int xdr_getpos(XDR *xdrs);
94
95              A macro that invokes the get-position  routine  associated  with
96              the  XDR stream, xdrs.  The routine returns an unsigned integer,
97              which indicates the position of the XDR byte stream.   A  desir‐
98              able feature of XDR streams is that simple arithmetic works with
99              this number, although the XDR stream instances need not  guaran‐
100              tee this.
101
102       long *xdr_inline(XDR *xdrs, int len);
103
104              A  macro that invokes the inline routine associated with the XDR
105              stream, xdrs.  The routine returns a  pointer  to  a  contiguous
106              piece  of  the  stream's  buffer;  len is the byte length of the
107              desired buffer.  Note: pointer is cast to long *.
108
109              Warning: xdr_inline() may return NULL (0) if it cannot  allocate
110              a contiguous piece of a buffer.  Therefore the behavior may vary
111              among stream instances; it exists for the sake of efficiency.
112
113       bool_t xdr_int(XDR *xdrs, int *ip);
114
115              A filter primitive that translates between C integers and  their
116              external  representations.   This routine returns one if it suc‐
117              ceeds, zero otherwise.
118
119       bool_t xdr_long(XDR *xdrs, long *lp);