1 .\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
2 .\" $FreeBSD: src/lib/libc/xdr/xdr.3,v 1.8.2.4 2001/12/14 18:34:06 ru Exp $
9 .Nd "library routines for external data representation"
18 for function declarations.
20 These routines allow C programmers to describe
21 arbitrary data structures in a machine-independent fashion.
22 Data for remote procedure calls are transmitted using these
25 .Bl -tag -width indent -compact
36 .Fa "xdrproc_t elproc"
40 A filter primitive that translates between variable-length
42 and their corresponding external representations.
46 is the address of the pointer to the array, while
48 is the address of the element count of the array;
49 this element count cannot exceed
55 each of the array's elements, and
59 filter that translates between
60 the array elements' C form, and their external
62 This routine returns one if it succeeds, zero otherwise.
68 .Fn 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.
82 .Fn xdr_bytes "XDR *xdrs" "char **sp" "u_int *sizep" "u_int maxsize"
85 A filter primitive that translates between counted byte
86 strings and their external representations.
89 is the address of the string pointer.
91 string is located at address
93 strings cannot be longer than
95 This routine returns one if it succeeds, zero otherwise.
101 .Fn xdr_char "XDR *xdrs" "char *cp"
104 A filter primitive that translates between C characters
105 and their external representations.
106 This routine returns one if it succeeds, zero otherwise.
107 Note: encoded characters are not packed, and occupy 4 bytes
109 For arrays of characters, it is worthwhile to
120 .Fn xdr_destroy "XDR *xdrs"
123 A macro that invokes the destroy routine associated with the
127 Destruction usually involves freeing private data structures
128 associated with the stream.
139 .Fn xdr_double "XDR *xdrs" "double *dp"
142 A filter primitive that translates between C
144 precision numbers and their external representations.
145 This routine returns one if it succeeds, zero otherwise.
151 .Fn xdr_enum "XDR *xdrs" "enum_t *ep"
154 A filter primitive that translates between C
156 (actually integers) and their external representations.
157 This routine returns one if it succeeds, zero otherwise.
163 .Fn xdr_float "XDR *xdrs" "float *fp"
166 A filter primitive that translates between C
168 and their external representations.
169 This routine returns one if it succeeds, zero otherwise.
175 .Fn xdr_free "xdrproc_t proc" "char *objp"
178 Generic freeing routine.
179 The first argument is the
181 routine for the object being freed.
183 is a pointer to the object itself.
184 Note: the pointer passed
187 freed, but what it points to
195 .Fn xdr_getpos "XDR *xdrs"
198 A macro that invokes the get\-position routine
203 The routine returns an unsigned integer,
204 which indicates the position of the
207 A desirable feature of
209 streams is that simple arithmetic works with this number,
212 stream instances need not guarantee this.
218 .Fn xdr_inline "XDR *xdrs" "int len"
221 A macro that invokes the in-line routine associated with the
225 The routine returns a pointer
226 to a contiguous piece of the stream's buffer;
228 is the byte length of the desired buffer.
229 Note: pointer is cast to
237 if it cannot allocate a contiguous piece of a buffer.
238 Therefore the behavior may vary among stream instances;
239 it exists for the sake of efficiency.
245 .Fn xdr_int "XDR *xdrs" "int *ip"
248 A filter primitive that translates between C integers
249 and their external representations.
250 This routine returns one if it succeeds, zero otherwise.
256 .Fn xdr_long "XDR *xdrs" "long *lp"
259 A filter primitive that translates between C
261 integers and their external representations.
262 This routine returns one if it succeeds, zero otherwise.
268 .Fn xdrmem_create "XDR *xdrs" "char *addr" "u_int size" "enum xdr_op op"
271 This routine initializes the
273 stream object pointed to by
275 The stream's data is written to, or read from,
276 a chunk of memory at location
278 whose length is no more than
283 determines the direction of the
296 .Fn xdr_opaque "XDR *xdrs" "char *cp" "u_int cnt"
299 A filter primitive that translates between fixed size opaque
301 and its external representation.
304 is the address of the opaque object, and
306 is its size in bytes.
307 This routine returns one if it succeeds, zero otherwise.
313 .Fn xdr_pointer "XDR *xdrs" "char **objpp" "u_int objsize" "xdrproc_t xdrobj"
318 except that it serializes
326 recursive data structures, such as binary trees or
338 .Fa "int \*(lp*readit\*(rp\*(lp\*(rp"
339 .Fa "int \*(lp*writeit\*(rp\*(lp\*(rp"
343 This routine initializes the
345 stream object pointed to by
347 The stream's data is written to a buffer of size
349 a value of zero indicates the system should use a suitable
351 The stream's data is read from a buffer of size
353 it too can be set to a suitable default by passing a zero
355 When a stream's output buffer is full,
358 Similarly, when a stream's input buffer is empty,
361 The behavior of these two routines is similar to
369 is passed to the former routines as the first parameter.
374 field must be set by the caller.
378 stream implements an intermediate record stream.
379 Therefore there are additional bytes in the stream
380 to provide record boundary information.
386 .Fn xdrrec_endofrecord "XDR *xdrs" "int sendnow"
389 This routine can be invoked only on
392 The data in the output buffer is marked as a completed
394 and the output buffer is optionally written out if
397 This routine returns one if it succeeds, zero
404 .Fn xdrrec_eof "XDR *xdrs"
407 This routine can be invoked only on
410 After consuming the rest of the current record in the stream,
411 this routine returns one if the stream has no more input,
418 .Fn xdrrec_skiprecord "XDR *xdrs"
421 This routine can be invoked only on
426 implementation that the rest of the current record
427 in the stream's input buffer should be discarded.
428 This routine returns one if it succeeds, zero otherwise.
434 .Fn xdr_reference "XDR *xdrs" "char **pp" "u_int size" "xdrproc_t proc"
437 A primitive that provides pointer chasing within structures.
440 is the address of the pointer;
450 procedure that filters the structure
451 between its C form and its external representation.
452 This routine returns one if it succeeds, zero otherwise.
454 Warning: this routine does not understand
465 .Fn xdr_setpos "XDR *xdrs" "u_int pos"
468 A macro that invokes the set position routine associated with
475 is a position value obtained from
477 This routine returns one if the
479 stream could be repositioned,
482 Warning: it is difficult to reposition some types of
484 streams, so this routine may fail with one
485 type of stream and succeed with another.
491 .Fn xdr_short "XDR *xdrs" "short *sp"
494 A filter primitive that translates between C
496 integers and their external representations.
497 This routine returns one if it succeeds, zero otherwise.
499 .It Li "#ifdef _STDIO_H_"
500 .It Li "/* XDR using stdio library */"
505 .Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op"
509 This routine initializes the
511 stream object pointed to by
515 stream data is written to, or read from, the Standard
521 determines the direction of the
529 Warning: the destroy routine associated with such
542 .Fn xdr_string "XDR *xdrs" "char **sp" "u_int maxsize"
545 A filter primitive that translates between C strings and
547 corresponding external representations.
548 Strings cannot be longer than
552 is the address of the string's pointer.
553 This routine returns one if it succeeds, zero otherwise.
559 .Fn xdr_u_char "XDR *xdrs" "unsigned char *ucp"
562 A filter primitive that translates between
564 C characters and their external representations.
565 This routine returns one if it succeeds, zero otherwise.
571 .Fn xdr_u_int "XDR *xdrs" "unsigned *up"
574 A filter primitive that translates between C
576 integers and their external representations.
577 This routine returns one if it succeeds, zero otherwise.
583 .Fn xdr_u_long "XDR *xdrs" "unsigned long *ulp"
586 A filter primitive that translates between C
588 integers and their external representations.
589 This routine returns one if it succeeds, zero otherwise.
595 .Fn xdr_u_short "XDR *xdrs" "unsigned short *usp"
598 A filter primitive that translates between C
600 integers and their external representations.
601 This routine returns one if it succeeds, zero otherwise.
611 .Fa "struct xdr_discrim *choices"
612 .Fa "bool_t \*(lp*defaultarm\*(rp\*(lp\*(rp"
616 A filter primitive that translates between a discriminated C
618 and its corresponding external representation.
620 translates the discriminant of the union located at
622 This discriminant is always an
624 Next the union located at
629 is a pointer to an array of
632 Each structure contains an ordered pair of
633 .Bq Va value , proc .
634 If the union's discriminant is equal to the associated
638 is called to translate the union.
641 structure array is denoted by a routine of value
643 If the discriminant is not found in the
647 procedure is called (if it is not
649 Returns one if it succeeds, zero otherwise.
660 .Fa "xdrproc_t elproc"
664 A filter primitive that translates between fixed-length
666 and their corresponding external representations.
670 is the address of the pointer to the array, while
672 is the element count of the array.
677 each of the array's elements, and
681 filter that translates between
682 the array elements' C form, and their external
684 This routine returns one if it succeeds, zero otherwise.
693 This routine always returns one.
696 routines that require a function parameter,
697 where nothing is to be done.
703 .Fn xdr_wrapstring "XDR *xdrs" "char **sp"
706 A primitive that calls
707 .Fn xdr_string xdrs sp MAXUN.UNSIGNED ;
710 is the maximum value of an unsigned integer.
714 package passes a maximum of two
716 routines as parameters, and
718 one of the most frequently used primitives, requires three.
719 Returns one if it succeeds, zero otherwise.
724 .%T "eXternal Data Representation Standard: Protocol Specification"
727 .%T "eXternal Data Representation: Sun Technical Notes"
730 .%T "XDR: External Data Representation Standard"
732 .%Q "Sun Microsystems, Inc., USC\-ISI"