1 .\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
4 xdr \- library routines for external data representation
5 .SH "SYNOPSIS AND DESCRIPTION"
7 These routines allow C programmers to describe
8 arbitrary data structures in a machine-independent fashion.
9 Data for remote procedure calls are transmitted using these
15 xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc)
18 u_int *sizep, maxsize, elsize;
23 A filter primitive that translates between variable-length
25 and their corresponding external representations. The
28 is the address of the pointer to the array, while
30 is the address of the element count of the array;
31 this element count cannot exceed
37 each of the array's elements, and
41 filter that translates between
42 the array elements' C form, and their external
44 This routine returns one if it succeeds, zero otherwise.
57 A filter primitive that translates between booleans (C
59 and their external representations. When encoding data, this
60 filter produces values of either one or zero.
61 This routine returns one if it succeeds, zero otherwise.
68 xdr_bytes(xdrs, sp, sizep, maxsize)
71 u_int *sizep, maxsize;
75 A filter primitive that translates between counted byte
76 strings and their external representations.
79 is the address of the string pointer. The length of the
80 string is located at address
82 strings cannot be longer than
84 This routine returns one if it succeeds, zero otherwise.
97 A filter primitive that translates between C characters
98 and their external representations.
99 This routine returns one if it succeeds, zero otherwise.
100 Note: encoded characters are not packed, and occupy 4 bytes
101 each. For arrays of characters, it is worthwhile to
119 A macro that invokes the destroy routine associated with the
123 Destruction usually involves freeing private data structures
124 associated with the stream. Using
141 A filter primitive that translates between C
143 precision numbers and their external representations.
144 This routine returns one if it succeeds, zero otherwise.
157 A filter primitive that translates between C
159 (actually integers) and their external representations.
160 This routine returns one if it succeeds, zero otherwise.
173 A filter primitive that translates between C
175 and their external representations.
176 This routine returns one if it succeeds, zero otherwise.
190 Generic freeing routine. The first argument is the
192 routine for the object being freed. The second argument
193 is a pointer to the object itself. Note: the pointer passed
196 freed, but what it points to
211 A macro that invokes the get-position routine
216 The routine returns an unsigned integer,
217 which indicates the position of the
220 A desirable feature of
222 streams is that simple arithmetic works with this number,
225 stream instances need not guarantee this.
234 xdr_inline(xdrs, len)
240 A macro that invokes the in-line routine associated with the
244 The routine returns a pointer
245 to a contiguous piece of the stream's buffer;
247 is the byte length of the desired buffer.
248 Note: pointer is cast to
256 if it cannot allocate a contiguous piece of a buffer.
257 Therefore the behavior may vary among stream instances;
258 it exists for the sake of efficiency.
271 A filter primitive that translates between C integers
272 and their external representations.
273 This routine returns one if it succeeds, zero otherwise.
286 A filter primitive that translates between C
288 integers and their external representations.
289 This routine returns one if it succeeds, zero otherwise.
297 xdrmem_create(xdrs, addr, size, op)
305 This routine initializes the
307 stream object pointed to by
309 The stream's data is written to, or read from,
310 a chunk of memory at location
312 whose length is no more than
316 determines the direction of the
320 .BR \s-1XDR_ENCODE\s0 ,
321 .BR \s-1XDR_DECODE\s0 ,
323 .BR \s-1XDR_FREE\s0 ).
330 xdr_opaque(xdrs, cp, cnt)
337 A filter primitive that translates between fixed size opaque data
338 and its external representation.
341 is the address of the opaque object, and
343 is its size in bytes.
344 This routine returns one if it succeeds, zero otherwise.
351 xdr_pointer(xdrs, objpp, objsize, xdrobj)
361 except that it serializes
368 recursive data structures, such as binary trees or
377 xdrrec_create(xdrs, sendsize, recvsize, handle, readit, writeit)
379 u_int sendsize, recvsize;
381 int (*readit) (), (*writeit) ();
385 This routine initializes the
387 stream object pointed to by
389 The stream's data is written to a buffer of size
391 a value of zero indicates the system should use a suitable
392 default. The stream's data is read from a buffer of size
394 it too can be set to a suitable default by passing a zero
396 When a stream's output buffer is full,
398 is called. Similarly, when a stream's input buffer is empty,
400 is called. The behavior of these two routines is similar to
408 is passed to the former routines as the first parameter.
413 field must be set by the caller.
417 stream implements an intermediate record stream.
418 Therefore there are additional bytes in the stream
419 to provide record boundary information.
426 xdrrec_endofrecord(xdrs, sendnow)
432 This routine can be invoked only on
434 .BR xdrrec_create() .
435 The data in the output buffer is marked as a completed
437 and the output buffer is optionally written out if
439 is non-zero. This routine returns one if it succeeds, zero
453 This routine can be invoked only on
455 .BR xdrrec_create() .
456 After consuming the rest of the current record in the stream,
457 this routine returns one if the stream has no more input,
465 xdrrec_skiprecord(xdrs)
470 This routine can be invoked only on
472 .BR xdrrec_create() .
475 implementation that the rest of the current record
476 in the stream's input buffer should be discarded.
477 This routine returns one if it succeeds, zero otherwise.
484 xdr_reference(xdrs, pp, size, proc)
492 A primitive that provides pointer chasing within structures.
495 is the address of the pointer;
505 procedure that filters the structure
506 between its C form and its external representation.
507 This routine returns one if it succeeds, zero otherwise.
509 Warning: this routine does not understand
520 xdr_setpos(xdrs, pos)
526 A macro that invokes the set position routine associated with
533 is a position value obtained from
535 This routine returns one if the
537 stream could be repositioned,
540 Warning: it is difficult to reposition some types of
542 streams, so this routine may fail with one
543 type of stream and succeed with another.
556 A filter primitive that translates between C
558 integers and their external representations.
559 This routine returns one if it succeeds, zero otherwise.
567 xdrstdio_create(xdrs, file, op)
574 This routine initializes the
576 stream object pointed to by
580 stream data is written to, or read from, the Standard
586 determines the direction of the
589 .BR \s-1XDR_ENCODE\s0 ,
590 .BR \s-1XDR_DECODE\s0 ,
592 .BR \s-1XDR_FREE\s0 ).
594 Warning: the destroy routine associated with such
608 xdr_string(xdrs, sp, maxsize)
616 A filter primitive that translates between C strings and
618 corresponding external representations.
619 Strings cannot be longer than
623 is the address of the string's pointer.
624 This routine returns one if it succeeds, zero otherwise.
631 xdr_u_char(xdrs, ucp)
637 A filter primitive that translates between
639 C characters and their external representations.
640 This routine returns one if it succeeds, zero otherwise.
653 A filter primitive that translates between C
655 integers and their external representations.
656 This routine returns one if it succeeds, zero otherwise.
663 xdr_u_long(xdrs, ulp)
669 A filter primitive that translates between C
671 integers and their external representations.
672 This routine returns one if it succeeds, zero otherwise.
679 xdr_u_short(xdrs, usp)
685 A filter primitive that translates between C
687 integers and their external representations.
688 This routine returns one if it succeeds, zero otherwise.
695 xdr_union(xdrs, dscmp, unp, choices, dfault)
699 struct xdr_discrim *choices;
700 bool_t (*defaultarm) (); /* may equal \s-1NULL\s0 */
704 A filter primitive that translates between a discriminated C
706 and its corresponding external representation. It first
707 translates the discriminant of the union located at
709 This discriminant is always an
711 Next the union located at
713 is translated. The parameter
715 is a pointer to an array of
717 structures. Each structure contains an ordered pair of
718 .RI [ value , proc ].
719 If the union's discriminant is equal to the associated
723 is called to translate the union. The end of the
725 structure array is denoted by a routine of value
727 If the discriminant is not found in the
731 procedure is called (if it is not
733 Returns one if it succeeds, zero otherwise.
740 xdr_vector(xdrs, arrp, size, elsize, elproc)
748 A filter primitive that translates between fixed-length
750 and their corresponding external representations. The
753 is the address of the pointer to the array, while
755 is is the element count of the array. The parameter
759 each of the array's elements, and
763 filter that translates between
764 the array elements' C form, and their external
766 This routine returns one if it succeeds, zero otherwise.
777 This routine always returns one.
780 routines that require a function parameter,
781 where nothing is to be done.
788 xdr_wrapstring(xdrs, sp)
794 A primitive that calls
795 .B "xdr_string(xdrs, sp,\s-1MAXUN.UNSIGNED\s0 );"
799 is the maximum value of an unsigned integer.
803 package passes a maximum of two
805 routines as parameters, and
807 one of the most frequently used primitives, requires three.
808 Returns one if it succeeds, zero otherwise.
812 The following manuals:
815 eXternal Data Representation Standard: Protocol Specification
817 eXternal Data Representation: Sun Technical Notes
820 .IR "\s-1XDR\s0: External Data Representation Standard" ,
821 .SM RFC\ 1014, Sun Microsystems, Inc.,