1 .\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
2 .\" $FreeBSD: head/lib/libc/xdr/xdr.3 318712 2017-05-23 07:17:52Z ngie $
31 .Nm xdrrec_endofrecord ,
33 .Nm xdrrec_skiprecord ,
44 .Nm xdr_u_longlong_t ,
56 .Nd "library routines for external data representation"
65 for function declarations.
67 These routines allow C programmers to describe
68 arbitrary data structures in a machine-independent fashion.
69 Data for remote procedure calls are transmitted using these
72 .Bl -tag -width indent -compact
83 .Fa "xdrproc_t elproc"
87 A filter primitive that translates between variable-length
89 and their corresponding external representations.
93 is the address of the pointer to the array, while
95 is the address of the element count of the array;
96 this element count cannot exceed
103 each of the array's elements, and
107 filter that translates between
108 the array elements' C form, and their external
110 This routine returns one if it succeeds, zero otherwise.
116 .Fn xdr_bool "XDR *xdrs" "bool_t *bp"
119 A filter primitive that translates between booleans (C
121 and their external representations.
122 When encoding data, this
123 filter produces values of either one or zero.
124 This routine returns one if it succeeds, zero otherwise.
130 .Fn xdr_bytes "XDR *xdrs" "char **sp" "u_int *sizep" "u_int maxsize"
133 A filter primitive that translates between counted byte
134 strings and their external representations.
138 is the address of the string pointer.
140 string is located at address
142 strings cannot be longer than
144 This routine returns one if it succeeds, zero otherwise.
150 .Fn xdr_char "XDR *xdrs" "char *cp"
153 A filter primitive that translates between C characters
154 and their external representations.
155 This routine returns one if it succeeds, zero otherwise.
156 Note: encoded characters are not packed, and occupy 4 bytes
158 For arrays of characters, it is worthwhile to
169 .Fn xdr_destroy "XDR *xdrs"
172 A macro that invokes the destroy routine associated with the
176 Destruction usually involves freeing private data structures
177 associated with the stream.
188 .Fn xdr_double "XDR *xdrs" "double *dp"
191 A filter primitive that translates between C
193 precision numbers and their external representations.
194 This routine returns one if it succeeds, zero otherwise.
200 .Fn xdr_enum "XDR *xdrs" "enum_t *ep"
203 A filter primitive that translates between C
205 (actually integers) and their external representations.
206 This routine returns one if it succeeds, zero otherwise.
212 .Fn xdr_float "XDR *xdrs" "float *fp"
215 A filter primitive that translates between C
217 and their external representations.
218 This routine returns one if it succeeds, zero otherwise.
224 .Fn xdr_free "xdrproc_t proc" "void *objp"
227 Generic freeing routine.
228 The first argument is the
230 routine for the object being freed.
232 is a pointer to the object itself.
233 Note: the pointer passed
236 freed, but what it points to
244 .Fn xdr_getpos "XDR *xdrs"
247 A macro that invokes the get\-position routine
252 The routine returns an unsigned integer,
253 which indicates the position of the
256 A desirable feature of
258 streams is that simple arithmetic works with this number,
261 stream instances need not guarantee this.
267 .Fn xdr_hyper "XDR *xdrs" "quad_t *llp"
269 A filter primitive that translates between ANSI C
271 integers and their external representations.
272 This routine returns one if it succeeds, zero otherwise.
278 .Fn xdr_inline "XDR *xdrs" "int len"
281 A macro that invokes the in-line routine associated with the
285 The routine returns a pointer
286 to a contiguous piece of the stream's buffer;
288 is the byte length of the desired buffer.
289 Note: pointer is cast to
297 if it cannot allocate a contiguous piece of a buffer.
298 Therefore the behavior may vary among stream instances;
299 it exists for the sake of efficiency.
305 .Fn xdr_int "XDR *xdrs" "int *ip"
308 A filter primitive that translates between C integers
309 and their external representations.
310 This routine returns one if it succeeds, zero otherwise.
316 .Fn xdr_int16_t "XDR *xdrs" "int16_t *llp"
318 A filter primitive that translates between ANSI C
320 integers and their external representations.
321 This routine returns one if it succeeds, zero otherwise.
327 .Fn xdr_int32_t "XDR *xdrs" "int32_t *llp"
329 A filter primitive that translates between ANSI C
331 integers and their external representations.
332 This routine returns one if it succeeds, zero otherwise.
338 .Fn xdr_int64_t "XDR *xdrs" "int64_t *llp"
340 A filter primitive that translates between ANSI C
342 integers and their external representations.
343 This routine returns one if it succeeds, zero otherwise.
349 .Fn xdr_long "XDR *xdrs" "long *lp"
352 A filter primitive that translates between C
354 integers and their external representations.
355 This routine returns one if it succeeds, zero otherwise.
361 .Fn xdr_longlong_t "XDR *xdrs" "quad_t *llp"
363 A filter primitive that translates between ANSI C
365 integers and their external representations.
366 This routine returns one if it succeeds, zero otherwise.
372 .Fn xdrmem_create "XDR *xdrs" "char *addr" "u_int size" "enum xdr_op op"
375 This routine initializes the
377 stream object pointed to by
379 The stream's data is written to, or read from,
380 a chunk of memory at location
382 whose length is no more than
388 determines the direction of the
401 .Fn xdr_opaque "XDR *xdrs" "char *cp" "u_int cnt"
404 A filter primitive that translates between fixed size opaque
406 and its external representation.
410 is the address of the opaque object, and
412 is its size in bytes.
413 This routine returns one if it succeeds, zero otherwise.
419 .Fn xdr_pointer "XDR *xdrs" "char **objpp" "u_int objsize" "xdrproc_t xdrobj"
424 except that it serializes
432 recursive data structures, such as binary trees or
444 .Fa "int \*(lp*readit\*(rp\*(lp\*(rp"
445 .Fa "int \*(lp*writeit\*(rp\*(lp\*(rp"
449 This routine initializes the
451 stream object pointed to by
453 The stream's data is written to a buffer of size
455 a value of zero indicates the system should use a suitable
457 The stream's data is read from a buffer of size
459 it too can be set to a suitable default by passing a zero
461 When a stream's output buffer is full,
464 Similarly, when a stream's input buffer is empty,
467 The behavior of these two routines is similar to
475 is passed to the former routines as the first argument.
480 field must be set by the caller.
484 stream implements an intermediate record stream.
485 Therefore there are additional bytes in the stream
486 to provide record boundary information.
492 .Fn xdrrec_endofrecord "XDR *xdrs" "int sendnow"
495 This routine can be invoked only on
498 The data in the output buffer is marked as a completed
500 and the output buffer is optionally written out if
503 This routine returns one if it succeeds, zero
510 .Fn xdrrec_eof "XDR *xdrs"
513 This routine can be invoked only on
516 After consuming the rest of the current record in the stream,
517 this routine returns one if the stream has no more input,
524 .Fn xdrrec_skiprecord "XDR *xdrs"
527 This routine can be invoked only on
532 implementation that the rest of the current record
533 in the stream's input buffer should be discarded.
534 This routine returns one if it succeeds, zero otherwise.
540 .Fn xdr_reference "XDR *xdrs" "char **pp" "u_int size" "xdrproc_t proc"
543 A primitive that provides pointer chasing within structures.
547 is the address of the pointer;
557 procedure that filters the structure
558 between its C form and its external representation.
559 This routine returns one if it succeeds, zero otherwise.
561 Warning: this routine does not understand
572 .Fn xdr_setpos "XDR *xdrs" "u_int pos"
575 A macro that invokes the set position routine associated with
583 is a position value obtained from
585 This routine returns one if the
587 stream could be repositioned,
590 Warning: it is difficult to reposition some types of
592 streams, so this routine may fail with one
593 type of stream and succeed with another.
599 .Fn xdr_short "XDR *xdrs" "short *sp"
602 A filter primitive that translates between C
604 integers and their external representations.
605 This routine returns one if it succeeds, zero otherwise.
611 .Fn xdr_sizeof "xdrproc_t func" "void *data"
614 This routine returns the amount of memory required to encode
619 .It Li "#ifdef _STDIO_H_"
620 .It Li "/* XDR using stdio library */"
625 .Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op"
629 This routine initializes the
631 stream object pointed to by
635 stream data is written to, or read from, the Standard
642 determines the direction of the
650 Warning: the destroy routine associated with such
663 .Fn xdr_string "XDR *xdrs" "char **sp" "u_int maxsize"
666 A filter primitive that translates between C strings and
668 corresponding external representations.
669 Strings cannot be longer than
673 is the address of the string's pointer.
674 This routine returns one if it succeeds, zero otherwise.
680 .Fn xdr_u_char "XDR *xdrs" "unsigned char *ucp"
683 A filter primitive that translates between
685 C characters and their external representations.
686 This routine returns one if it succeeds, zero otherwise.
692 .Fn xdr_u_hyper "XDR *xdrs" "u_quad_t *ullp"
694 A filter primitive that translates between
698 integers and their external representations.
699 This routine returns one if it succeeds, zero otherwise.
705 .Fn xdr_u_int "XDR *xdrs" "unsigned *up"
708 A filter primitive that translates between C
710 integers and their external representations.
711 This routine returns one if it succeeds, zero otherwise.
717 .Fn xdr_uint16_t "XDR *xdrs" "uint16_t *llp"
723 .Fn xdr_u_int16_t "XDR *xdrs" "uint16_t *llp"
725 Filter primitives that translate between C
727 integers and their external representations.
728 These routines return one if they succeed, zero otherwise.
734 .Fn xdr_uint32_t "XDR *xdrs" "uint32_t *llp"
740 .Fn xdr_u_int32_t "XDR *xdrs" "uint32_t *llp"
742 Filter primitives that translate between C
744 integers and their external representations.
745 These routines return one if they succeed, zero otherwise.
751 .Fn xdr_uint64_t "XDR *xdrs" "uint64_t *llp"
757 .Fn xdr_u_int64_t "XDR *xdrs" "uint64_t *llp"
759 Filter primitives that translate between C
761 integers and their external representations.
762 These routines return one if they succeed, zero otherwise.
768 .Fn xdr_u_long "XDR *xdrs" "unsigned long *ulp"
771 A filter primitive that translates between C
773 integers and their external representations.
774 This routine returns one if it succeeds, zero otherwise.
780 .Fn xdr_u_longlong_t "XDR *xdrs" "u_quad_t *ullp"
782 A filter primitive that translates between
786 integers and their external representations.
787 This routine returns one if it succeeds, zero otherwise.
793 .Fn xdr_u_int64_t "XDR *xdrs" "uint64_t *llp"
795 A filter primitive that translates between C
797 integers and their external representations.
798 This routine returns one if it succeeds, zero otherwise.
804 .Fn xdr_u_short "XDR *xdrs" "unsigned short *usp"
807 A filter primitive that translates between C
809 integers and their external representations.
810 This routine returns one if it succeeds, zero otherwise.
820 .Fa "const struct xdr_discrim *choices"
821 .Fa "xdrproc_t defaultarm"
825 A filter primitive that translates between a discriminated C
827 and its corresponding external representation.
829 translates the discriminant of the union located at
831 This discriminant is always an
833 Next the union located at
839 is a pointer to an array of
842 Each structure contains an ordered pair of
843 .Bq Va value , proc .
844 If the union's discriminant is equal to the associated
848 is called to translate the union.
851 structure array is denoted by a routine of value
853 If the discriminant is not found in the
857 procedure is called (if it is not
859 Returns one if it succeeds, zero otherwise.
870 .Fa "xdrproc_t elproc"
874 A filter primitive that translates between fixed-length
876 and their corresponding external representations.
880 is the address of the pointer to the array, while
882 is the element count of the array.
888 each of the array's elements, and
892 filter that translates between
893 the array elements' C form, and their external
895 This routine returns one if it succeeds, zero otherwise.
904 This routine always returns one.
907 routines that require a function argument,
908 where nothing is to be done.
914 .Fn xdr_wrapstring "XDR *xdrs" "char **sp"
917 A primitive that calls
918 .Fn xdr_string xdrs sp MAXUN.UNSIGNED ;
921 is the maximum value of an unsigned integer.
927 package passes a maximum of two
929 routines as arguments, and
931 one of the most frequently used primitives, requires three.
932 Returns one if it succeeds, zero otherwise.
937 .%T "eXternal Data Representation Standard: Protocol Specification"
940 .%T "eXternal Data Representation: Sun Technical Notes"
943 .%T "XDR: External Data Representation Standard"
945 .%Q "Sun Microsystems, Inc., USC\-ISI"
950 function first appeared in