1 .\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
2 .\" $NetBSD: xdr.3,v 1.12 2009/10/13 21:39:55 joerg Exp $
28 .Nm xdrrec_endofrecord ,
30 .Nm xdrrec_skiprecord ,
39 .Nm xdr_u_longlong_t ,
45 .Nd library routines for external data representation
48 .Fn xdr_array "XDR *xdrs" "char **arrp" "u_int *sizep" "u_int maxsize" \
49 "u_int elsize" "xdrproc_t elproc"
51 .Fn xdr_bool "XDR *xdrs" "bool_t *bp"
53 .Fn xdr_bytes "XDR *xdrs" "char **sp" "u_int *sizep" "u_int maxsize"
55 .Fn xdr_char "XDR *xdrs" "char *cp"
57 .Fn xdr_destroy "XDR *xdrs"
59 .Fn xdr_double "XDR *xdrs" "double *dp"
61 .Fn xdr_enum "XDR *xdrs" "enum_t *ep"
63 .Fn xdr_float "XDR *xdrs" "float *fp"
65 .Fn xdr_free "xdrproc_t proc" "char *objp"
67 .Fn xdr_getpos "XDR *xdrs"
69 .Fn xdr_hyper "XDR *xdrs" "longlong_t *llp"
71 .Fn xdr_inline "XDR *xdrs" "int len"
73 .Fn xdr_int "XDR *xdrs" "int *ip"
75 .Fn xdr_long "XDR *xdrs" "long *lp"
77 .Fn xdr_longlong_t "XDR *xdrs" "longlong_t *llp"
79 .Fn xdrmem_create "XDR *xdrs" "char *addr" "u_int size" \
82 .Fn xdr_opaque "XDR *xdrs" "char *cp" "u_int cnt"
84 .Fn xdr_pointer "XDR *xdrs" "char **objpp" "u_int objsize" \
87 .Fn xdrrec_create "XDR *xdrs" "u_int sendsize" "u_int recvsize" \
88 "char *handle" "int (*readit)()" "int (*writeit)()"
90 .Fn xdrrec_endofrecord "XDR *xdrs" "int sendnow"
92 .Fn xdrrec_eof "XDR *xdrs"
94 .Fn xdrrec_skiprecord "XDR *xdrs"
96 .Fn xdr_reference "XDR *xdrs" "char **pp" "u_int size" \
99 .Fn xdr_setpos "XDR *xdrs" "u_int pos"
101 .Fn xdr_short "XDR *xdrs" "short *sp"
103 .Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op"
105 .Fn xdr_string "XDR *xdrs" "char **sp" "u_int maxsize"
107 .Fn xdr_u_char "XDR *xdrs" "unsigned char *ucp"
109 .Fn xdr_u_hyper "XDR *xdrs" "u_longlong_t *ullp"
111 .Fn xdr_u_int "XDR *xdrs" "unsigned *up"
113 .Fn xdr_u_long "XDR *xdrs" "unsigned long *ulp"
115 .Fn xdr_u_longlong_t "XDR *xdrs" "u_longlong_t *ullp"
117 .Fn xdr_u_short "XDR *xdrs" "unsigned short *usp"
119 .Fn xdr_union "XDR *xdrs" "int *dscmp" "char *unp" \
120 "struct xdr_discrim *choices" "bool_t (*defaultarm)(\|)"
122 .Fn xdr_vector "XDR *xdrs" "char *arrp" "u_int size" \
123 "u_int elsize" "xdrproc_t elproc"
127 .Fn xdr_wrapstring "XDR *xdrs" "char **sp"
129 These routines allow C programmers to describe
130 arbitrary data structures in a machine-independent fashion.
131 Data for remote procedure calls are transmitted using these
135 A filter primitive that translates between variable-length
136 arrays and their corresponding external representations.
139 is the address of the pointer to the array, while
141 is the address of the element count of the array;
142 this element count cannot exceed
148 each of the array's elements, and
150 is an XDR filter that translates between the array elements' C form,
151 and their external representation.
152 This routine returns one if it succeeds, zero otherwise.
154 A filter primitive that translates between booleans (C integers)
155 and their external representations.
156 When encoding data, this filter produces values of either one or
158 This routine returns one if it succeeds, zero otherwise.
160 A filter primitive that translates between counted byte
161 strings and their external representations.
164 is the address of the string pointer.
165 The length of the string is located at address
167 strings cannot be longer than
169 This routine returns one if it succeeds, zero otherwise.
171 A filter primitive that translates between C characters
172 and their external representations.
173 This routine returns one if it succeeds, zero otherwise.
174 Note: encoded characters are not packed, and occupy 4 bytes each.
175 For arrays of characters, it is worthwhile to consider
181 A macro that invokes the destroy routine associated with the XDR
184 Destruction usually involves freeing private data structures
185 associated with the stream.
192 A filter primitive that translates between C double precision numbers
193 and their external representations.
194 This routine returns one if it succeeds, zero otherwise.
196 A filter primitive that translates between C enums (actually integers)
197 and their external representations.
198 This routine returns one if it succeeds, zero otherwise.
200 A filter primitive that translates between C floats
201 and their external representations.
202 This routine returns one if it succeeds, zero otherwise.
204 Generic freeing routine.
205 The first argument is the XDR routine for the object being freed.
206 The second argument is a pointer to the object itself.
207 Note: the pointer passed to this routine is
209 freed, but what it points to
213 A macro that invokes the get-position routine associated with the XDR
216 The routine returns an unsigned integer, which indicates the position
217 of the XDR byte stream.
218 A desirable feature of XDR streams is that simple arithmetic works
219 with this number, although the XDR stream instances need not guarantee
222 A filter primitive that translates between ANSI C long long integers
223 and their external representations.
224 This routine returns one if it succeeds, zero otherwise.
226 A macro that invokes the in-line routine associated with the XDR
229 The routine returns a pointer
230 to a contiguous piece of the stream's buffer;
232 is the byte length of the desired buffer.
233 Note: pointer is cast to
240 if it cannot allocate a contiguous piece of a buffer.
241 Therefore the behavior may vary among stream instances;
242 it exists for the sake of efficiency.
244 A filter primitive that translates between C integers
245 and their external representations.
246 This routine returns one if it succeeds, zero otherwise.
248 A filter primitive that translates between C long integers
249 and their external representations.
250 This routine returns one if it succeeds, zero otherwise.
251 .It Fn xdr_longlong_t
252 A filter primitive that translates between ANSI C long long integers
253 and their external representations.
254 This routine returns one if it succeeds, zero otherwise.
256 This routine initializes the XDR stream object pointed to by
258 The stream's data is written to, or read from,
259 a chunk of memory at location
261 whose length is no more than
266 determines the direction of the XDR stream (either
272 A filter primitive that translates between fixed size opaque data
273 and its external representation.
276 is the address of the opaque object, and
278 is its size in bytes.
279 This routine returns one if it succeeds, zero otherwise.
283 except that it serializes
290 can represent recursive data structures, such as binary trees or
293 This routine initializes the XDR stream object pointed to by
295 The stream's data is written to a buffer of size
297 a value of zero indicates the system should use a suitable default.
298 The stream's data is read from a buffer of size
300 it too can be set to a suitable default by passing a zero value.
301 When a stream's output buffer is full,
304 Similarly, when a stream's input buffer is empty,
307 The behavior of these two routines is similar to the system calls
313 is passed to the former routines as the first parameter.
314 Note: the XDR stream's
316 field must be set by the caller.
318 Warning: this XDR stream implements an intermediate record stream.
319 Therefore there are additional bytes in the stream
320 to provide record boundary information.
321 .It Fn xdrrec_endofrecord
322 This routine can be invoked only on streams created by
324 The data in the output buffer is marked as a completed record,
325 and the output buffer is optionally written out if
328 This routine returns one if it succeeds, zero otherwise.
330 This routine can be invoked only on streams created by
332 After consuming the rest of the current record in the stream,
333 this routine returns one if the stream has no more input,
335 .It Fn xdrrec_skiprecord
336 This routine can be invoked only on streams created by
338 It tells the XDR implementation that the rest of the current record
339 in the stream's input buffer should be discarded.
340 This routine returns one if it succeeds, zero otherwise.
342 A primitive that provides pointer chasing within structures.
345 is the address of the pointer;
353 is an XDR procedure that filters the structure
354 between its C form and its external representation.
355 This routine returns one if it succeeds, zero otherwise.
357 Warning: this routine does not understand
364 A macro that invokes the set position routine associated with the XDR
369 is a position value obtained from
371 This routine returns one if the XDR stream could be repositioned,
374 Warning: it is difficult to reposition some types of XDR streams, so
375 this routine may fail with one type of stream and succeed with
378 A filter primitive that translates between C short integers
379 and their external representations.
380 This routine returns one if it succeeds, zero otherwise.
381 .It Fn xdrstdio_create
382 This routine initializes the XDR stream object pointed to by
384 The XDR stream data is written to, or read from, the Standard I/O
389 determines the direction of the XDR stream (either
395 Warning: the destroy routine associated with such XDR streams calls
397 on the file stream, but never
400 A filter primitive that translates between C strings and
401 their corresponding external representations.
402 Strings cannot be longer than
406 is the address of the string's pointer.
407 This routine returns one if it succeeds, zero otherwise.
409 A filter primitive that translates between unsigned C characters
410 and their external representations.
411 This routine returns one if it succeeds, zero otherwise.
413 A filter primitive that translates between unsigned ANSI C long long
414 integers and their external representations.
415 This routine returns one if it succeeds, zero otherwise.
417 A filter primitive that translates between C unsigned integers
418 and their external representations.
419 This routine returns one if it succeeds, zero otherwise.
421 A filter primitive that translates between C unsigned long integers
422 and their external representations.
423 This routine returns one if it succeeds, zero otherwise.
424 .It Fn xdr_u_longlong_t
425 A filter primitive that translates between unsigned ANSI C long long
426 integers and their external representations.
427 This routine returns one if it succeeds, zero otherwise.
429 A filter primitive that translates between C unsigned short integers
430 and their external representations.
431 This routine returns one if it succeeds, zero otherwise.
433 A filter primitive that translates between a discriminated C union
434 and its corresponding external representation.
435 It first translates the discriminant of the union located at
437 This discriminant is always an enum_t.
438 Next the union located at
443 is a pointer to an array of
446 Each structure contains an ordered pair of
449 If the union's discriminant is equal to the associated
453 is called to translate the union.
456 structure array is denoted by a routine of value
458 If the discriminant is not found in the
462 procedure is called (if it is not
464 Returns one if it succeeds, zero otherwise.
466 A filter primitive that translates between fixed-length
467 arrays and their corresponding external representations.
470 is the address of the pointer to the array, while
472 is the element count of the array.
477 each of the array's elements, and
479 is an XDR filter that translates between the array elements' C form,
480 and their external representation.
481 This routine returns one if it succeeds, zero otherwise.
483 This routine always returns one.
484 It may be passed to RPC routines that require a function parameter,
485 where nothing is to be done.
486 .It Fn xdr_wrapstring
487 A primitive that calls
488 .Fn xdr_string "xdrs" "sp" "MAXUN.UNSIGNED" ;
491 is the maximum value of an unsigned integer.
493 is handy because the RPC package passes a maximum of two XDR
494 routines as parameters, and
496 one of the most frequently used primitives, requires three.
497 Returns one if it succeeds, zero otherwise.
502 The following manuals:
504 .%B "eXternal Data Representation Standard: Protocol Specification"
507 .%B "eXternal Data Representation: Sun Technical Notes"
510 .%A Sun Microsystems, Inc., USC-ISI
511 .%T "XDR: External Data Representation Standard"
512 .%R "RFC 1014, USC-ISI"