1 .\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
2 .\" $NetBSD: xdr.3,v 1.14 2011/07/08 19:28:22 wiz Exp $
28 .Nm xdrrec_endofrecord ,
30 .Nm xdrrec_skiprecord ,
40 .Nm xdr_u_longlong_t ,
46 .Nd library routines for external data representation
49 .Fn xdr_array "XDR *xdrs" "char **arrp" "u_int *sizep" "u_int maxsize" \
50 "u_int elsize" "xdrproc_t elproc"
52 .Fn xdr_bool "XDR *xdrs" "bool_t *bp"
54 .Fn xdr_bytes "XDR *xdrs" "char **sp" "u_int *sizep" "u_int maxsize"
56 .Fn xdr_char "XDR *xdrs" "char *cp"
58 .Fn xdr_destroy "XDR *xdrs"
60 .Fn xdr_double "XDR *xdrs" "double *dp"
62 .Fn xdr_enum "XDR *xdrs" "enum_t *ep"
64 .Fn xdr_float "XDR *xdrs" "float *fp"
66 .Fn xdr_free "xdrproc_t proc" "char *objp"
68 .Fn xdr_getpos "XDR *xdrs"
70 .Fn xdr_hyper "XDR *xdrs" "longlong_t *llp"
72 .Fn xdr_inline "XDR *xdrs" "int len"
74 .Fn xdr_int "XDR *xdrs" "int *ip"
76 .Fn xdr_long "XDR *xdrs" "long *lp"
78 .Fn xdr_longlong_t "XDR *xdrs" "longlong_t *llp"
80 .Fn xdrmem_create "XDR *xdrs" "char *addr" "u_int size" \
83 .Fn xdr_opaque "XDR *xdrs" "char *cp" "u_int cnt"
85 .Fn xdr_pointer "XDR *xdrs" "char **objpp" "u_int objsize" \
88 .Fn xdrrec_create "XDR *xdrs" "u_int sendsize" "u_int recvsize" \
89 "char *handle" "int (*readit)()" "int (*writeit)()"
91 .Fn xdrrec_endofrecord "XDR *xdrs" "int sendnow"
93 .Fn xdrrec_eof "XDR *xdrs"
95 .Fn xdrrec_skiprecord "XDR *xdrs"
97 .Fn xdr_reference "XDR *xdrs" "char **pp" "u_int size" \
100 .Fn xdr_setpos "XDR *xdrs" "u_int pos"
102 .Fn xdr_short "XDR *xdrs" "short *sp"
104 .Fn xdr_sizeof "xdrproc_t func" "void *data"
106 .Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op"
108 .Fn xdr_string "XDR *xdrs" "char **sp" "u_int maxsize"
110 .Fn xdr_u_char "XDR *xdrs" "unsigned char *ucp"
112 .Fn xdr_u_hyper "XDR *xdrs" "u_longlong_t *ullp"
114 .Fn xdr_u_int "XDR *xdrs" "unsigned *up"
116 .Fn xdr_u_long "XDR *xdrs" "unsigned long *ulp"
118 .Fn xdr_u_longlong_t "XDR *xdrs" "u_longlong_t *ullp"
120 .Fn xdr_u_short "XDR *xdrs" "unsigned short *usp"
122 .Fn xdr_union "XDR *xdrs" "int *dscmp" "char *unp" \
123 "struct xdr_discrim *choices" "bool_t (*defaultarm)(\|)"
125 .Fn xdr_vector "XDR *xdrs" "char *arrp" "u_int size" \
126 "u_int elsize" "xdrproc_t elproc"
130 .Fn xdr_wrapstring "XDR *xdrs" "char **sp"
132 These routines allow C programmers to describe
133 arbitrary data structures in a machine-independent fashion.
134 Data for remote procedure calls are transmitted using these
138 A filter primitive that translates between variable-length
139 arrays and their corresponding external representations.
142 is the address of the pointer to the array, while
144 is the address of the element count of the array;
145 this element count cannot exceed
151 each of the array's elements, and
153 is an XDR filter that translates between the array elements' C form,
154 and their external representation.
155 This routine returns one if it succeeds, zero otherwise.
157 A filter primitive that translates between booleans (C integers)
158 and their external representations.
159 When encoding data, this filter produces values of either one or
161 This routine returns one if it succeeds, zero otherwise.
163 A filter primitive that translates between counted byte
164 strings and their external representations.
167 is the address of the string pointer.
168 The length of the string is located at address
170 strings cannot be longer than
172 This routine returns one if it succeeds, zero otherwise.
174 A filter primitive that translates between C characters
175 and their external representations.
176 This routine returns one if it succeeds, zero otherwise.
177 Note: encoded characters are not packed, and occupy 4 bytes each.
178 For arrays of characters, it is worthwhile to consider
184 A macro that invokes the destroy routine associated with the XDR
187 Destruction usually involves freeing private data structures
188 associated with the stream.
195 A filter primitive that translates between C double precision numbers
196 and their external representations.
197 This routine returns one if it succeeds, zero otherwise.
199 A filter primitive that translates between C enums (actually integers)
200 and their external representations.
201 This routine returns one if it succeeds, zero otherwise.
203 A filter primitive that translates between C floats
204 and their external representations.
205 This routine returns one if it succeeds, zero otherwise.
207 Generic freeing routine.
208 The first argument is the XDR routine for the object being freed.
209 The second argument is a pointer to the object itself.
210 Note: the pointer passed to this routine is
212 freed, but what it points to
216 A macro that invokes the get-position routine associated with the XDR
219 The routine returns an unsigned integer, which indicates the position
220 of the XDR byte stream.
221 A desirable feature of XDR streams is that simple arithmetic works
222 with this number, although the XDR stream instances need not guarantee
225 A filter primitive that translates between ANSI C long long integers
226 and their external representations.
227 This routine returns one if it succeeds, zero otherwise.
229 A macro that invokes the in-line routine associated with the XDR
232 The routine returns a pointer
233 to a contiguous piece of the stream's buffer;
235 is the byte length of the desired buffer.
236 Note: pointer is cast to
243 if it cannot allocate a contiguous piece of a buffer.
244 Therefore the behavior may vary among stream instances;
245 it exists for the sake of efficiency.
247 A filter primitive that translates between C integers
248 and their external representations.
249 This routine returns one if it succeeds, zero otherwise.
251 A filter primitive that translates between C long integers
252 and their external representations.
253 This routine returns one if it succeeds, zero otherwise.
254 .It Fn xdr_longlong_t
255 A filter primitive that translates between ANSI C long long integers
256 and their external representations.
257 This routine returns one if it succeeds, zero otherwise.
259 This routine initializes the XDR stream object pointed to by
261 The stream's data is written to, or read from,
262 a chunk of memory at location
264 whose length is no more than
269 determines the direction of the XDR stream (either
275 A filter primitive that translates between fixed size opaque data
276 and its external representation.
279 is the address of the opaque object, and
281 is its size in bytes.
282 This routine returns one if it succeeds, zero otherwise.
286 except that it serializes
293 can represent recursive data structures, such as binary trees or
296 This routine initializes the XDR stream object pointed to by
298 The stream's data is written to a buffer of size
300 a value of zero indicates the system should use a suitable default.
301 The stream's data is read from a buffer of size
303 it too can be set to a suitable default by passing a zero value.
304 When a stream's output buffer is full,
307 Similarly, when a stream's input buffer is empty,
310 The behavior of these two routines is similar to the system calls
316 is passed to the former routines as the first parameter.
317 Note: the XDR stream's
319 field must be set by the caller.
321 Warning: this XDR stream implements an intermediate record stream.
322 Therefore there are additional bytes in the stream
323 to provide record boundary information.
324 .It Fn xdrrec_endofrecord
325 This routine can be invoked only on streams created by
327 The data in the output buffer is marked as a completed record,
328 and the output buffer is optionally written out if
331 This routine returns one if it succeeds, zero otherwise.
333 This routine can be invoked only on streams created by
335 After consuming the rest of the current record in the stream,
336 this routine returns one if the stream has no more input,
338 .It Fn xdrrec_skiprecord
339 This routine can be invoked only on streams created by
341 It tells the XDR implementation that the rest of the current record
342 in the stream's input buffer should be discarded.
343 This routine returns one if it succeeds, zero otherwise.
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
367 A macro that invokes the set position routine associated with the XDR
372 is a position value obtained from
374 This routine returns one if the XDR stream could be repositioned,
377 Warning: it is difficult to reposition some types of XDR streams, so
378 this routine may fail with one type of stream and succeed with
381 A filter primitive that translates between C short integers
382 and their external representations.
383 This routine returns one if it succeeds, zero otherwise.
385 This routine returns the amount of memory required to encode
389 .It Fn xdrstdio_create
390 This routine initializes the XDR stream object pointed to by
392 The XDR stream data is written to, or read from, the Standard I/O
397 determines the direction of the XDR stream (either
403 Warning: the destroy routine associated with such XDR streams calls
405 on the file stream, but never
408 A filter primitive that translates between C strings and
409 their corresponding external representations.
410 Strings cannot be longer than
414 is the address of the string's pointer.
415 This routine returns one if it succeeds, zero otherwise.
417 A filter primitive that translates between unsigned C characters
418 and their external representations.
419 This routine returns one if it succeeds, zero otherwise.
421 A filter primitive that translates between unsigned ANSI C long long
422 integers and their external representations.
423 This routine returns one if it succeeds, zero otherwise.
425 A filter primitive that translates between C unsigned integers
426 and their external representations.
427 This routine returns one if it succeeds, zero otherwise.
429 A filter primitive that translates between C unsigned long integers
430 and their external representations.
431 This routine returns one if it succeeds, zero otherwise.
432 .It Fn xdr_u_longlong_t
433 A filter primitive that translates between unsigned ANSI C long long
434 integers and their external representations.
435 This routine returns one if it succeeds, zero otherwise.
437 A filter primitive that translates between C unsigned short integers
438 and their external representations.
439 This routine returns one if it succeeds, zero otherwise.
441 A filter primitive that translates between a discriminated C union
442 and its corresponding external representation.
443 It first translates the discriminant of the union located at
445 This discriminant is always an enum_t.
446 Next the union located at
451 is a pointer to an array of
454 Each structure contains an ordered pair of
457 If the union's discriminant is equal to the associated
461 is called to translate the union.
464 structure array is denoted by a routine of value
466 If the discriminant is not found in the
470 procedure is called (if it is not
472 Returns one if it succeeds, zero otherwise.
474 A filter primitive that translates between fixed-length
475 arrays and their corresponding external representations.
478 is the address of the pointer to the array, while
480 is the element count of the array.
485 each of the array's elements, and
487 is an XDR filter that translates between the array elements' C form,
488 and their external representation.
489 This routine returns one if it succeeds, zero otherwise.
491 This routine always returns one.
492 It may be passed to RPC routines that require a function parameter,
493 where nothing is to be done.
494 .It Fn xdr_wrapstring
495 A primitive that calls
496 .Fn xdr_string "xdrs" "sp" "MAXUN.UNSIGNED" ;
499 is the maximum value of an unsigned integer.
501 is handy because the RPC package passes a maximum of two XDR
502 routines as parameters, and
504 one of the most frequently used primitives, requires three.
505 Returns one if it succeeds, zero otherwise.
510 The following manuals:
512 .%B "eXternal Data Representation Standard: Protocol Specification"
515 .%B "eXternal Data Representation: Sun Technical Notes"
518 .%A Sun Microsystems, Inc., USC-ISI
519 .%T "XDR: External Data Representation Standard"
520 .%R "RFC 1014, USC-ISI"