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.17 2005/11/24 07:12:01 ru Exp $
29 .Nm xdrrec_endofrecord ,
31 .Nm xdrrec_skiprecord ,
41 .Nm xdr_u_longlong_t ,
48 .Nd "library routines for external data representation"
57 for function declarations.
59 These routines allow C programmers to describe
60 arbitrary data structures in a machine-independent fashion.
61 Data for remote procedure calls are transmitted using these
64 .Bl -tag -width indent -compact
75 .Fa "xdrproc_t elproc"
79 A filter primitive that translates between variable-length
81 and their corresponding external representations.
85 is the address of the pointer to the array, while
87 is the address of the element count of the array;
88 this element count cannot exceed
95 each of the array's elements, and
99 filter that translates between
100 the array elements' C form, and their external
102 This routine returns one if it succeeds, zero otherwise.
108 .Fn xdr_bool "XDR *xdrs" "bool_t *bp"
111 A filter primitive that translates between booleans (C
113 and their external representations.
114 When encoding data, this
115 filter produces values of either one or zero.
116 This routine returns one if it succeeds, zero otherwise.
122 .Fn xdr_bytes "XDR *xdrs" "char **sp" "u_int *sizep" "u_int maxsize"
125 A filter primitive that translates between counted byte
126 strings and their external representations.
130 is the address of the string pointer.
132 string is located at address
134 strings cannot be longer than
136 This routine returns one if it succeeds, zero otherwise.
142 .Fn xdr_char "XDR *xdrs" "char *cp"
145 A filter primitive that translates between C characters
146 and their external representations.
147 This routine returns one if it succeeds, zero otherwise.
148 Note: encoded characters are not packed, and occupy 4 bytes
150 For arrays of characters, it is worthwhile to
161 .Fn xdr_destroy "XDR *xdrs"
164 A macro that invokes the destroy routine associated with the
168 Destruction usually involves freeing private data structures
169 associated with the stream.
180 .Fn xdr_double "XDR *xdrs" "double *dp"
183 A filter primitive that translates between C
185 precision numbers and their external representations.
186 This routine returns one if it succeeds, zero otherwise.
192 .Fn xdr_enum "XDR *xdrs" "enum_t *ep"
195 A filter primitive that translates between C
197 (actually integers) and their external representations.
198 This routine returns one if it succeeds, zero otherwise.
204 .Fn xdr_float "XDR *xdrs" "float *fp"
207 A filter primitive that translates between C
209 and their external representations.
210 This routine returns one if it succeeds, zero otherwise.
216 .Fn xdr_free "xdrproc_t proc" "void *objp"
219 Generic freeing routine.
220 The first argument is the
222 routine for the object being freed.
224 is a pointer to the object itself.
225 Note: the pointer passed
228 freed, but what it points to
236 .Fn xdr_getpos "XDR *xdrs"
239 A macro that invokes the get\-position routine
244 The routine returns an unsigned integer,
245 which indicates the position of the
248 A desirable feature of
250 streams is that simple arithmetic works with this number,
253 stream instances need not guarantee this.
259 .Fn xdr_hyper "XDR *xdrs" "quad_t *llp"
261 A filter primitive that translates between ANSI C
263 integers and their external representations.
264 This routine returns one if it succeeds, zero otherwise.
270 .Fn xdr_inline "XDR *xdrs" "int len"
273 A macro that invokes the in-line routine associated with the
277 The routine returns a pointer
278 to a contiguous piece of the stream's buffer;
280 is the byte length of the desired buffer.
281 Note: pointer is cast to
289 if it cannot allocate a contiguous piece of a buffer.
290 Therefore the behavior may vary among stream instances;
291 it exists for the sake of efficiency.
297 .Fn xdr_int "XDR *xdrs" "int *ip"
300 A filter primitive that translates between C integers
301 and their external representations.
302 This routine returns one if it succeeds, zero otherwise.
308 .Fn xdr_long "XDR *xdrs" "long *lp"
311 A filter primitive that translates between C
313 integers and their external representations.
314 This routine returns one if it succeeds, zero otherwise.
320 .Fn xdr_longlong_t "XDR *xdrs" "quad_t *llp"
322 A filter primitive that translates between ANSI C
324 integers and their external representations.
325 This routine returns one if it succeeds, zero otherwise.
331 .Fn xdr_int64_t "XDR *xdrs" "int64_t *llp"
333 A filter primitive that translates between ANSI C
335 integers and their external representations.
336 This routine returns one if it succeeds, zero otherwise.
342 .Fn xdrmem_create "XDR *xdrs" "char *addr" "u_int size" "enum xdr_op op"
345 This routine initializes the
347 stream object pointed to by
349 The stream's data is written to, or read from,
350 a chunk of memory at location
352 whose length is no more than
358 determines the direction of the
371 .Fn xdr_opaque "XDR *xdrs" "char *cp" "u_int cnt"
374 A filter primitive that translates between fixed size opaque
376 and its external representation.
380 is the address of the opaque object, and
382 is its size in bytes.
383 This routine returns one if it succeeds, zero otherwise.
389 .Fn xdr_pointer "XDR *xdrs" "char **objpp" "u_int objsize" "xdrproc_t xdrobj"
394 except that it serializes
402 recursive data structures, such as binary trees or
414 .Fa "int (*readit)(void)"
415 .Fa "int (*writeit)(void)"
419 This routine initializes the
421 stream object pointed to by
423 The stream's data is written to a buffer of size
425 a value of zero indicates the system should use a suitable
427 The stream's data is read from a buffer of size
429 it too can be set to a suitable default by passing a zero
431 When a stream's output buffer is full,
434 Similarly, when a stream's input buffer is empty,
437 The behavior of these two routines is similar to
445 is passed to the former routines as the first argument.
450 field must be set by the caller.
454 stream implements an intermediate record stream.
455 Therefore there are additional bytes in the stream
456 to provide record boundary information.
462 .Fn xdrrec_endofrecord "XDR *xdrs" "int sendnow"
465 This routine can be invoked only on
468 The data in the output buffer is marked as a completed
470 and the output buffer is optionally written out if
473 This routine returns one if it succeeds, zero
480 .Fn xdrrec_eof "XDR *xdrs"
483 This routine can be invoked only on
486 After consuming the rest of the current record in the stream,
487 this routine returns one if the stream has no more input,
494 .Fn xdrrec_skiprecord "XDR *xdrs"
497 This routine can be invoked only on
502 implementation that the rest of the current record
503 in the stream's input buffer should be discarded.
504 This routine returns one if it succeeds, zero otherwise.
510 .Fn xdr_reference "XDR *xdrs" "char **pp" "u_int size" "xdrproc_t proc"
513 A primitive that provides pointer chasing within structures.
517 is the address of the pointer;
527 procedure that filters the structure
528 between its C form and its external representation.
529 This routine returns one if it succeeds, zero otherwise.
531 Warning: this routine does not understand
542 .Fn xdr_setpos "XDR *xdrs" "u_int pos"
545 A macro that invokes the set position routine associated with
553 is a position value obtained from
555 This routine returns one if the
557 stream could be repositioned,
560 Warning: it is difficult to reposition some types of
562 streams, so this routine may fail with one
563 type of stream and succeed with another.
569 .Fn xdr_short "XDR *xdrs" "short *sp"
572 A filter primitive that translates between C
574 integers and their external representations.
575 This routine returns one if it succeeds, zero otherwise.
577 .It Li "#ifdef _STDIO_H_"
578 .It Li "/* XDR using stdio library */"
583 .Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op"
587 This routine initializes the
589 stream object pointed to by
593 stream data is written to, or read from, the Standard
600 determines the direction of the
608 Warning: the destroy routine associated with such
621 .Fn xdr_string "XDR *xdrs" "char **sp" "u_int maxsize"
624 A filter primitive that translates between C strings and
626 corresponding external representations.
627 Strings cannot be longer than
631 is the address of the string's pointer.
632 This routine returns one if it succeeds, zero otherwise.
638 .Fn xdr_u_char "XDR *xdrs" "unsigned char *ucp"
641 A filter primitive that translates between
643 C characters and their external representations.
644 This routine returns one if it succeeds, zero otherwise.
650 .Fn xdr_u_hyper "XDR *xdrs" "u_quad_t *ullp"
652 A filter primitive that translates between
656 integers and their external representations.
657 This routine returns one if it succeeds, zero otherwise.
663 .Fn xdr_u_int "XDR *xdrs" "unsigned *up"
666 A filter primitive that translates between C
668 integers and their external representations.
669 This routine returns one if it succeeds, zero otherwise.
675 .Fn xdr_u_long "XDR *xdrs" "unsigned long *ulp"
678 A filter primitive that translates between C
680 integers and their external representations.
681 This routine returns one if it succeeds, zero otherwise.
687 .Fn xdr_u_longlong_t "XDR *xdrs" "u_quad_t *ullp"
689 A filter primitive that translates between
693 integers and their external representations.
694 This routine returns one if it succeeds, zero otherwise.
700 .Fn xdr_u_int64_t "XDR *xdrs" "u_int64_t *llp"
702 A filter primitive that translates between C
704 integers and their external representations.
705 This routine returns one if it succeeds, zero otherwise.
711 .Fn xdr_u_short "XDR *xdrs" "unsigned short *usp"
714 A filter primitive that translates between C
716 integers and their external representations.
717 This routine returns one if it succeeds, zero otherwise.
727 .Fa "const struct xdr_discrim *choices"
728 .Fa "xdrproc_t defaultarm"
732 A filter primitive that translates between a discriminated C
734 and its corresponding external representation.
736 translates the discriminant of the union located at
738 This discriminant is always an
740 Next the union located at
746 is a pointer to an array of
749 Each structure contains an ordered pair of
750 .Bq Va value , proc .
751 If the union's discriminant is equal to the associated
755 is called to translate the union.
758 structure array is denoted by a routine of value
760 If the discriminant is not found in the
764 procedure is called (if it is not
766 Returns one if it succeeds, zero otherwise.
777 .Fa "xdrproc_t elproc"
781 A filter primitive that translates between fixed-length
783 and their corresponding external representations.
787 is the address of the pointer to the array, while
789 is the element count of the array.
795 each of the array's elements, and
799 filter that translates between
800 the array elements' C form, and their external
802 This routine returns one if it succeeds, zero otherwise.
811 This routine always returns one.
814 routines that require a function argument,
815 where nothing is to be done.
821 .Fn xdr_wrapstring "XDR *xdrs" "char **sp"
824 A primitive that calls
825 .Fn xdr_string xdrs sp MAXUN.UNSIGNED ;
828 is the maximum value of an unsigned integer.
834 package passes a maximum of two
836 routines as arguments, and
838 one of the most frequently used primitives, requires three.
839 Returns one if it succeeds, zero otherwise.
844 .%T "eXternal Data Representation Standard: Protocol Specification"
847 .%T "eXternal Data Representation: Sun Technical Notes"
850 .%T "XDR: External Data Representation Standard"
852 .%Q "Sun Microsystems, Inc., USC\-ISI"