2 .\" This page was taken from the 4.4BSD-Lite CDROM (BSD license)
4 .\" %%%LICENSE_START(BSD_ONELINE_CDROM)
5 .\" This page was taken from the 4.4BSD-Lite CDROM (BSD license)
8 .\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
10 .\" 2007-12-30, mtk, Convert function prototypes to modern C syntax
12 .TH xdr 3 (date) "Linux man-pages (unreleased)"
14 xdr \- library routines for external data representation
17 .RI ( libc ", " \-lc )
18 .SH SYNOPSIS AND DESCRIPTION
19 These routines allow C programmers to describe
20 arbitrary data structures in a machine-independent fashion.
21 Data for remote procedure calls are transmitted using these
24 The prototypes below are declared in
26 and make use of the following types:
30 .BI "typedef int " bool_t ;
32 .BI "typedef bool_t (*" xdrproc_t ")(XDR *, void *,...);"
36 For the declaration of the
42 .BI "bool_t xdr_array(XDR *" xdrs ", char **" arrp ", unsigned int *" sizep ,
43 .BI " unsigned int " maxsize ", unsigned int " elsize ,
44 .BI " xdrproc_t " elproc );
47 A filter primitive that translates between variable-length arrays
48 and their corresponding external representations.
51 is the address of the pointer to the array, while
53 is the address of the element count of the array;
54 this element count cannot exceed
60 each of the array's elements, and
62 is an XDR filter that translates between
63 the array elements' C form, and their external
65 This routine returns one if it succeeds, zero otherwise.
68 .BI "bool_t xdr_bool(XDR *" xdrs ", bool_t *" bp );
71 A filter primitive that translates between booleans (C
73 and their external representations.
74 When encoding data, this
75 filter produces values of either one or zero.
76 This routine returns one if it succeeds, zero otherwise.
79 .BI "bool_t xdr_bytes(XDR *" xdrs ", char **" sp ", unsigned int *" sizep ,
80 .BI " unsigned int " maxsize );
83 A filter primitive that translates between counted byte
84 strings and their external representations.
87 is the address of the string pointer.
89 string is located at address
91 strings cannot be longer than
93 This routine returns one if it succeeds, zero otherwise.
96 .BI "bool_t xdr_char(XDR *" xdrs ", char *" cp );
99 A filter primitive that translates between C characters
100 and their external representations.
101 This routine returns one if it succeeds, zero otherwise.
102 Note: encoded characters are not packed, and occupy 4 bytes each.
103 For arrays of characters, it is worthwhile to
111 .BI "void xdr_destroy(XDR *" xdrs );
114 A macro that invokes the destroy routine associated with the XDR stream,
116 Destruction usually involves freeing private data structures
117 associated with the stream.
125 .BI "bool_t xdr_double(XDR *" xdrs ", double *" dp );
128 A filter primitive that translates between C
130 precision numbers and their external representations.
131 This routine returns one if it succeeds, zero otherwise.
134 .BI "bool_t xdr_enum(XDR *" xdrs ", enum_t *" ep );
137 A filter primitive that translates between C
139 (actually integers) and their external representations.
140 This routine returns one if it succeeds, zero otherwise.
143 .BI "bool_t xdr_float(XDR *" xdrs ", float *" fp );
146 A filter primitive that translates between C
148 and their external representations.
149 This routine returns one if it succeeds, zero otherwise.
152 .BI "void xdr_free(xdrproc_t " proc ", char *" objp );
155 Generic freeing routine.
156 The first argument is the XDR routine for the object being freed.
157 The second argument is a pointer to the object itself.
158 Note: the pointer passed to this routine is
160 freed, but what it points to
165 .BI "unsigned int xdr_getpos(XDR *" xdrs );
168 A macro that invokes the get-position routine
169 associated with the XDR stream,
171 The routine returns an unsigned integer,
172 which indicates the position of the XDR byte stream.
173 A desirable feature of XDR
174 streams is that simple arithmetic works with this number,
175 although the XDR stream instances need not guarantee this.
178 .BI "long *xdr_inline(XDR *" xdrs ", int " len );
181 A macro that invokes the inline routine associated with the XDR stream,
183 The routine returns a pointer
184 to a contiguous piece of the stream's buffer;
186 is the byte length of the desired buffer.
187 Note: pointer is cast to
193 if it cannot allocate a contiguous piece of a buffer.
194 Therefore the behavior may vary among stream instances;
195 it exists for the sake of efficiency.
198 .BI "bool_t xdr_int(XDR *" xdrs ", int *" ip );
201 A filter primitive that translates between C integers
202 and their external representations.
203 This routine returns one if it succeeds, zero otherwise.
206 .BI "bool_t xdr_long(XDR *" xdrs ", long *" lp );
209 A filter primitive that translates between C
211 integers and their external representations.
212 This routine returns one if it succeeds, zero otherwise.
215 .BI "void xdrmem_create(XDR *" xdrs ", char *" addr ", unsigned int " size ,
216 .BI " enum xdr_op " op );
219 This routine initializes the XDR stream object pointed to by
221 The stream's data is written to, or read from,
222 a chunk of memory at location
224 whose length is no more than
229 determines the direction of the XDR stream (either
236 .BI "bool_t xdr_opaque(XDR *" xdrs ", char *" cp ", unsigned int " cnt );
239 A filter primitive that translates between fixed size opaque data
240 and its external representation.
243 is the address of the opaque object, and
245 is its size in bytes.
246 This routine returns one if it succeeds, zero otherwise.
249 .BI "bool_t xdr_pointer(XDR *" xdrs ", char **" objpp ,
250 .BI " unsigned int " objsize ", xdrproc_t " xdrobj );
255 except that it serializes null pointers, whereas
261 recursive data structures, such as binary trees or
265 .BI "void xdrrec_create(XDR *" xdrs ", unsigned int " sendsize ,
266 .BI " unsigned int " recvsize ", char *" handle ,
267 .BI " int (*" readit ")(char *, char *, int),"
268 .BI " int (*" writeit ")(char *, char *, int));"
271 This routine initializes the XDR stream object pointed to by
273 The stream's data is written to a buffer of size
275 a value of zero indicates the system should use a suitable default.
276 The stream's data is read from a buffer of size
278 it too can be set to a suitable default by passing a zero value.
279 When a stream's output buffer is full,
282 Similarly, when a stream's input buffer is empty,
285 The behavior of these two routines is similar to
292 is passed to the former routines as the first argument.
293 Note: the XDR stream's
295 field must be set by the caller.
297 Warning: to read from an XDR stream created by this API,
299 .BR xdrrec_skiprecord ()
300 first before calling any other XDR APIs.
301 This inserts additional bytes in the stream to provide
302 record boundary information.
303 Also, XDR streams created with different
305 APIs are not compatible for the same reason.
308 .BI "bool_t xdrrec_endofrecord(XDR *" xdrs ", int " sendnow );
311 This routine can be invoked only on streams created by
312 .BR xdrrec_create ().
313 The data in the output buffer is marked as a completed record,
314 and the output buffer is optionally written out if
317 This routine returns one if it succeeds, zero otherwise.
320 .BI "bool_t xdrrec_eof(XDR *" xdrs );
323 This routine can be invoked only on streams created by
324 .BR xdrrec_create ().
325 After consuming the rest of the current record in the stream,
326 this routine returns one if the stream has no more input,
330 .BI "bool_t xdrrec_skiprecord(XDR *" xdrs );
333 This routine can be invoked only on
335 .BR xdrrec_create ().
336 It tells the XDR implementation that the rest of the current record
337 in the stream's input buffer should be discarded.
338 This routine returns one if it succeeds, zero otherwise.
341 .BI "bool_t xdr_reference(XDR *" xdrs ", char **" pp ", unsigned int " size ,
342 .BI " xdrproc_t " proc );
345 A primitive that provides pointer chasing within structures.
348 is the address of the pointer;
356 is an XDR procedure that filters the structure
357 between its C form and its external representation.
358 This routine returns one if it succeeds, zero otherwise.
360 Warning: this routine does not understand null pointers.
366 .BI "xdr_setpos(XDR *" xdrs ", unsigned int " pos );
369 A macro that invokes the set position routine associated with
374 is a position value obtained from
376 This routine returns one if the XDR stream could be repositioned,
379 Warning: it is difficult to reposition some types of XDR
380 streams, so this routine may fail with one
381 type of stream and succeed with another.
384 .BI "bool_t xdr_short(XDR *" xdrs ", short *" sp );
387 A filter primitive that translates between C
389 integers and their external representations.
390 This routine returns one if it succeeds, zero otherwise.
393 .BI "void xdrstdio_create(XDR *" xdrs ", FILE *" file ", enum xdr_op " op );
396 This routine initializes the XDR stream object pointed to by
398 The XDR stream data is written to, or read from, the
404 determines the direction of the XDR stream (either
410 Warning: the destroy routine associated with such XDR streams calls
418 .BI "bool_t xdr_string(XDR *" xdrs ", char **" sp ", unsigned int " maxsize );
421 A filter primitive that translates between C strings and
422 their corresponding external representations.
423 Strings cannot be longer than
427 is the address of the string's pointer.
428 This routine returns one if it succeeds, zero otherwise.
431 .BI "bool_t xdr_u_char(XDR *" xdrs ", unsigned char *" ucp );
434 A filter primitive that translates between
436 C characters and their external representations.
437 This routine returns one if it succeeds, zero otherwise.
440 .BI "bool_t xdr_u_int(XDR *" xdrs ", unsigned int *" up );
443 A filter primitive that translates between C
445 integers and their external representations.
446 This routine returns one if it succeeds, zero otherwise.
449 .BI "bool_t xdr_u_long(XDR *" xdrs ", unsigned long *" ulp );
452 A filter primitive that translates between C
454 integers and their external representations.
455 This routine returns one if it succeeds, zero otherwise.
458 .BI "bool_t xdr_u_short(XDR *" xdrs ", unsigned short *" usp );
461 A filter primitive that translates between C
463 integers and their external representations.
464 This routine returns one if it succeeds, zero otherwise.
467 .BI "bool_t xdr_union(XDR *" xdrs ", enum_t *" dscmp ", char *" unp ,
468 .BI " const struct xdr_discrim *" choices ,
469 .BI " xdrproc_t " defaultarm "); /* may equal NULL */"
472 A filter primitive that translates between a discriminated C
474 and its corresponding external representation.
476 translates the discriminant of the union located at
478 This discriminant is always an
480 Next the union located at
485 is a pointer to an array of
488 Each structure contains an ordered pair of
489 .RI [ value , proc ].
490 If the union's discriminant is equal to the associated
494 is called to translate the union.
497 structure array is denoted by a routine of value NULL.
498 If the discriminant is not found in the
502 procedure is called (if it is not NULL).
503 Returns one if it succeeds, zero otherwise.
506 .BI "bool_t xdr_vector(XDR *" xdrs ", char *" arrp ", unsigned int " size ,
507 .BI " unsigned int " elsize ", xdrproc_t " elproc );
510 A filter primitive that translates between fixed-length arrays
511 and their corresponding external representations.
514 is the address of the pointer to the array, while
516 is the element count of the array.
521 each of the array's elements, and
523 is an XDR filter that translates between
524 the array elements' C form, and their external
526 This routine returns one if it succeeds, zero otherwise.
529 .B bool_t xdr_void(void);
532 This routine always returns one.
533 It may be passed to RPC routines that require a function argument,
534 where nothing is to be done.
537 .BI "bool_t xdr_wrapstring(XDR *" xdrs ", char **" sp );
540 A primitive that calls
541 .B "xdr_string(xdrs, sp,MAXUN.UNSIGNED );"
544 is the maximum value of an unsigned integer.
545 .BR xdr_wrapstring ()
546 is handy because the RPC package passes a maximum of two XDR
547 routines as arguments, and
549 one of the most frequently used primitives, requires three.
550 Returns one if it succeeds, zero otherwise.
552 For an explanation of the terms used in this section, see
558 Interface Attribute Value
575 .BR xdrmem_create (),
578 .BR xdrrec_create (),
580 .BR xdrrec_endofrecord (),
581 .BR xdrrec_skiprecord (),
582 .BR xdr_reference (),
585 .BR xdrstdio_create (),
594 .BR xdr_wrapstring ()
595 T} Thread safety MT-Safe
600 The following manuals:
602 eXternal Data Representation Standard: Protocol Specification
604 eXternal Data Representation: Sun Technical Notes
606 .IR "XDR: External Data Representation Standard" ,
607 RFC\ 1014, Sun Microsystems, Inc.,