1xdr(3) Library Functions Manual xdr(3)
2
3
4
6 xdr - library routines for external data representation
7
9 Standard C library (libc, -lc)
10
12 These routines allow C programmers to describe arbitrary data struc‐
13 tures in a machine-independent fashion. Data for remote procedure
14 calls are transmitted using these routines.
15
16 The prototypes below are declared in <rpc/xdr.h> and make use of the
17 following types:
18
19 typedef int bool_t;
20
21 typedef bool_t (*xdrproc_t)(XDR *, void *,...);
22
23 For the declaration of the XDR type, see <rpc/xdr.h>.
24
25 bool_t xdr_array(XDR *xdrs, char **arrp, unsigned int *sizep,
26 unsigned int maxsize, unsigned int elsize,
27 xdrproc_t elproc);
28
29 A filter primitive that translates between variable-length ar‐
30 rays and their corresponding external representations. The ar‐
31 gument arrp is the address of the pointer to the array, while
32 sizep is the address of the element count of the array; this el‐
33 ement count cannot exceed maxsize. The argument elsize is the
34 sizeof each of the array's elements, and elproc is an XDR filter
35 that translates between the array elements' C form, and their
36 external representation. This routine returns one if it suc‐
37 ceeds, zero otherwise.
38
39 bool_t xdr_bool(XDR *xdrs, bool_t *bp);
40
41 A filter primitive that translates between booleans (C integers)
42 and their external representations. When encoding data, this
43 filter produces values of either one or zero. This routine re‐
44 turns one if it succeeds, zero otherwise.
45
46 bool_t xdr_bytes(XDR *xdrs, char **sp, unsigned int *sizep,
47 unsigned int maxsize);
48
49 A filter primitive that translates between counted byte strings
50 and their external representations. The argument sp is the ad‐
51 dress of the string pointer. The length of the string is lo‐
52 cated at address sizep; strings cannot be longer than maxsize.
53 This routine returns one if it succeeds, zero otherwise.
54
55 bool_t xdr_char(XDR *xdrs, char *cp);
56
57 A filter primitive that translates between C characters and
58 their external representations. This routine returns one if it
59 succeeds, zero otherwise. Note: encoded characters are not
60 packed, and occupy 4 bytes each. For arrays of characters, it
61 is worthwhile to consider xdr_bytes(), xdr_opaque(), or
62 xdr_string().
63
64 void xdr_destroy(XDR *xdrs);
65
66 A macro that invokes the destroy routine associated with the XDR
67 stream, xdrs. Destruction usually involves freeing private data
68 structures associated with the stream. Using xdrs after invok‐
69 ing xdr_destroy() is undefined.
70
71 bool_t xdr_double(XDR *xdrs, double *dp);
72
73 A filter primitive that translates between C double precision
74 numbers and