1 .\" This page was taken from the 4.4BSD-Lite CDROM (BSD license)
3 .\" %%%LICENSE_START(BSD_ONELINE_CDROM)
4 .\" This page was taken from the 4.4BSD-Lite CDROM (BSD license)
7 .\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
9 .\" 2007-12-30, mtk, Convert function prototypes to modern C syntax
11 .TH xdr 3 (date) "Linux man-pages (unreleased)"
13 xdr \- library routines for external data representation
16 .RI ( libc ", " \-lc )
17 .SH SYNOPSIS AND DESCRIPTION
18 These routines allow C programmers to describe
19 arbitrary data structures in a machine-independent fashion.
20 Data for remote procedure calls are transmitted using these
23 The prototypes below are declared in
25 and make use of the following types:
29 .BI "typedef int " bool_t ;
31 .BI "typedef bool_t (*" xdrproc_t ")(XDR *, void *,...);"
35 For the declaration of the
41 .BI "bool_t xdr_array(XDR *" xdrs ", char **" arrp ", unsigned int *" sizep ,
42 .BI " unsigned int " maxsize ", unsigned int " elsize ,
43 .BI " xdrproc_t " elproc );
46 A filter primitive that translates between variable-length arrays
47 and their corresponding external representations.
50 is the address of the pointer to the array, while
52 is the address of the element count of the array;
53 this element count cannot exceed
59 each of the array's elements, and
61 is an XDR filter that translates between
62 the array elements' C form, and their external
64 This routine returns one if it succeeds, zero otherwise.
67 .BI "bool_t xdr_bool(XDR *" xdrs ", bool_t *" bp );
70 A filter primitive that translates between booleans (C
72 and their external representations.
73 When encoding data, this
74 filter produces values of either one or zero.
75 This routine returns one if it succeeds, zero otherwise.
78 .BI "bool_t xdr_bytes(XDR *" xdrs ", char **" sp ", unsigned int *" sizep ,
79 .BI " unsigned int " maxsize );
82 A filter primitive that translates between counted byte
83 strings and their external representations.
86 is the address of the string pointer.
88 string is located at address
90 strings cannot be longer than
92 This routine returns one if it succeeds, zero otherwise.
95 .BI "bool_t xdr_char(XDR *" xdrs ", char *" cp );
98 A filter primitive that translates between C characters
99 and their external representations.
100 This routine returns one if it succeeds, zero otherwise.
101 Note: encoded characters are not packed, and occupy 4 bytes each.
102 For arrays of characters, it is worthwhile to
110 .BI "void xdr_destroy(XDR *" xdrs );
113 A macro that invokes the destroy routine associated with the XDR stream,
115 Destruction usually involves freeing private data structures
116 associated with the stream.
124 .BI "bool_t xdr_double(XDR *" xdrs ", double *" dp );
127 A filter primitive that translates between C
129 precision numbers and their external representations.
130 This routine returns one if it succeeds, zero otherwise.
133 .BI "bool_t xdr_enum(XDR *" xdrs ", enum_t *" ep );
136 A filter primitive that translates between C
138 (actually integers) and their external representations.
139 This routine returns one if it succeeds, zero otherwise.
142 .BI "bool_t xdr_float(XDR *" xdrs ", float *" fp );
145 A filter primitive that translates between C
147 and their external representations.
148 This routine returns one if it succeeds, zero otherwise.
151 .BI "void xdr_free(xdrproc_t " proc ", char *" objp );
154 Generic freeing routine.
155 The first argument is the XDR routine for the object being freed.
156 The second argument is a pointer to the object itself.
157 Note: the pointer passed to this routine is
159 freed, but what it points to
164 .BI "unsigned int xdr_getpos(XDR *" xdrs );
167 A macro that invokes the get-position routine
168 associated with the XDR stream,
170 The routine returns an unsigned integer,
171 which indicates the position of the XDR byte stream.
172 A desirable feature of XDR
173 streams is that simple arithmetic works with this number,
174 although the XDR stream instances need not guarantee this.
177 .BI "long *xdr_inline(XDR *" xdrs ", int " len );
180 A macro that invokes the inline routine associated with the XDR stream,
182 The routine returns a pointer
183 to a contiguous piece of the stream's buffer;
185 is the byte length of the desired buffer.
186 Note: pointer is cast to
192 if it cannot allocate a contiguous piece of a buffer.
193 Therefore the behavior may vary among stream instances;
194 it exists for the sake of efficiency.
197 .BI "bool_t xdr_int(XDR *" xdrs ", int *" ip );
200 A filter primitive that translates between C integers
201 and their external representations.
202 This routine returns one if it succeeds, zero otherwise.
205 .BI "bool_t xdr_long(XDR *" xdrs ", long *" lp );
208 A filter primitive that translates between C
210 integers and their external representations.
211 This routine returns one if it succeeds, zero otherwise.
214 .BI "void xdrmem_create(XDR *" xdrs ", char *" addr ", unsigned int " size ,
215 .BI " enum xdr_op " op );
218 This routine initializes the XDR stream object pointed to by
220 The stream's data is written to, or read from,
221 a chunk of memory at location
223 whose length is no more than
228 determines the direction of the XDR stream (either
235 .BI "bool_t xdr_opaque(XDR *" xdrs ", char *" cp ", unsigned int " cnt );
238 A filter primitive that translates between fixed size opaque data
239 and its external representation.
242 is the address of the opaque object, and
244 is its size in bytes.
245 This routine returns one if it succeeds, zero otherwise.
248 .BI "bool_t xdr_pointer(XDR *" xdrs ", char **" objpp ,
249 .BI " unsigned int " objsize ", xdrproc_t " xdrobj );
254 except that it serializes null pointers, whereas
260 recursive data structures, such as binary trees or
264 .BI "void xdrrec_create(XDR *" xdrs ", unsigned int " sendsize ,
265 .BI " unsigned int " recvsize ", char *" handle ,
266 .BI " int (*" readit ")(char *, char *, int),"
267 .BI " int (*" writeit ")(char *, char *, int));"
270 This routine initializes the XDR stream object pointed to by
272 The stream's data is written to a buffer of size
274 a value of zero indicates the system should use a suitable default.
275 The stream's data is read from a buffer of size
277 it too can be set to a suitable default by passing a zero value.
278 When a stream's output buffer is full,
281 Similarly, when a stream's input buffer is empty,
284 The behavior of these two routines is similar to
291 is passed to the former routines as the first argument.
292 Note: the XDR stream's
294 field must be set by the caller.
296 Warning: to read from an XDR stream created by this API,
298 .BR xdrrec_skiprecord ()
299 first before calling any other XDR APIs.
300 This inserts additional bytes in the stream to provide
301 record boundary information.
302 Also, XDR streams created with different
304 APIs are not compatible for the same reason.
307 .BI "bool_t xdrrec_endofrecord(XDR *" xdrs ", int " sendnow );
310 This routine can be invoked only on streams created by
311 .BR xdrrec_create ().
312 The data in the output buffer is marked as a completed record,
313 and the output buffer is optionally written out if
316 This routine returns one if it succeeds, zero otherwise.
319 .BI "bool_t xdrrec_eof(XDR *" xdrs );
322 This routine can be invoked only on streams created by
323 .BR xdrrec_create ().
324 After consuming the rest of the current record in the stream,
325 this routine returns one if the stream has no more input,
329 .BI "bool_t xdrrec_skiprecord(XDR *" xdrs );
332 This routine can be invoked only on
334 .BR xdrrec_create ().
335 It tells the XDR implementation that the rest of the current record
336 in the stream's input buffer should be discarded.
337 This routine returns one if it succeeds, zero otherwise.
340 .BI "bool_t xdr_reference(XDR *" xdrs ", char **" pp ", unsigned int " size ,
341 .BI " xdrproc_t " proc );
344 A primitive that provides pointer chasing within structures.
347 is the address of the pointer;
355 is an XDR procedure that filters the structure
356 between its C form and its external representation.
357 This routine returns one if it succeeds, zero otherwise.
359 Warning: this routine does not understand null pointers.
365 .BI "xdr_setpos(XDR *" xdrs ", unsigned int " pos );
368 A macro that invokes the set position routine associated with
373 is a position value obtained from
375 This routine returns one if the XDR stream could be repositioned,
378 Warning: it is difficult to reposition some types of XDR
379 streams, so this routine may fail with one
380 type of stream and succeed with another.
383 .BI "bool_t xdr_short(XDR *" xdrs ", short *" sp );
386 A filter primitive that translates between C
388 integers and their external representations.
389 This routine returns one if it succeeds, zero otherwise.
392 .BI "void xdrstdio_create(XDR *" xdrs ", FILE *" file ", enum xdr_op " op );
395 This routine initializes the XDR stream object pointed to by
397 The XDR stream data is written to, or read from, the
403 determines the direction of the XDR stream (either
409 Warning: the destroy routine associated with such XDR streams calls
417 .BI "bool_t xdr_string(XDR *" xdrs ", char **" sp ", unsigned int " maxsize );
420 A filter primitive that translates between C strings and
421 their corresponding external representations.
422 Strings cannot be longer than
426 is the address of the string's pointer.
427 This routine returns one if it succeeds, zero otherwise.
430 .BI "bool_t xdr_u_char(XDR *" xdrs ", unsigned char *" ucp );
433 A filter primitive that translates between
435 C characters and their external representations.
436 This routine returns one if it succeeds, zero otherwise.
439 .BI "bool_t xdr_u_int(XDR *" xdrs ", unsigned int *" up );
442 A filter primitive that translates between C
444 integers and their external representations.
445 This routine returns one if it succeeds, zero otherwise.
448 .BI "bool_t xdr_u_long(XDR *" xdrs ", unsigned long *" ulp );
451 A filter primitive that translates between C
453 integers and their external representations.
454 This routine returns one if it succeeds, zero otherwise.
457 .BI "bool_t xdr_u_short(XDR *" xdrs ", unsigned short *" usp );
460 A filter primitive that translates between C
462 integers and their external representations.
463 This routine returns one if it succeeds, zero otherwise.
466 .BI "bool_t xdr_union(XDR *" xdrs ", enum_t *" dscmp ", char *" unp ,
467 .BI " const struct xdr_discrim *" choices ,
468 .BI " xdrproc_t " defaultarm "); /* may equal NULL */"
471 A filter primitive that translates between a discriminated C
473 and its corresponding external representation.
475 translates the discriminant of the union located at
477 This discriminant is always an
479 Next the union located at
484 is a pointer to an array of
487 Each structure contains an ordered pair of
488 .RI [ value , proc ].
489 If the union's discriminant is equal to the associated
493 is called to translate the union.
496 structure array is denoted by a routine of value NULL.
497 If the discriminant is not found in the
501 procedure is called (if it is not NULL).
502 Returns one if it succeeds, zero otherwise.
505 .BI "bool_t xdr_vector(XDR *" xdrs ", char *" arrp ", unsigned int " size ,
506 .BI " unsigned int " elsize ", xdrproc_t " elproc );
509 A filter primitive that translates between fixed-length arrays
510 and their corresponding external representations.
513 is the address of the pointer to the array, while
515 is the element count of the array.
520 each of the array's elements, and
522 is an XDR filter that translates between
523 the array elements' C form, and their external
525 This routine returns one if it succeeds, zero otherwise.
528 .B bool_t xdr_void(void);
531 This routine always returns one.
532 It may be passed to RPC routines that require a function argument,
533 where nothing is to be done.
536 .BI "bool_t xdr_wrapstring(XDR *" xdrs ", char **" sp );
539 A primitive that calls
540 .B "xdr_string(xdrs, sp,MAXUN.UNSIGNED );"
543 is the maximum value of an unsigned integer.
544 .BR xdr_wrapstring ()
545 is handy because the RPC package passes a maximum of two XDR
546 routines as arguments, and
548 one of the most frequently used primitives, requires three.
549 Returns one if it succeeds, zero otherwise.
551 For an explanation of the terms used in this section, see
559 Interface Attribute Value
574 .BR xdrmem_create (),
577 .BR xdrrec_create (),
579 .BR xdrrec_endofrecord (),
580 .BR xdrrec_skiprecord (),
581 .BR xdr_reference (),
584 .BR xdrstdio_create (),
593 .BR xdr_wrapstring ()
594 T} Thread safety MT-Safe
602 The following manuals:
604 eXternal Data Representation Standard: Protocol Specification
606 eXternal Data Representation: Sun Technical Notes
608 .IR "XDR: External Data Representation Standard" ,
609 RFC\ 1014, Sun Microsystems, Inc.,