]>
Commit | Line | Data |
---|---|---|
b3dd680f | 1 | .\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI |
d49d4c81 | 2 | .\" $FreeBSD: src/lib/libc/xdr/xdr.3,v 1.17 2005/11/24 07:12:01 ru Exp $ |
b3dd680f A |
3 | .\" |
4 | .Dd February 16, 1988 | |
5 | .Dt XDR 3 | |
6 | .Os | |
7 | .Sh NAME | |
8 | .Nm xdr , | |
9 | .Nm xdr_array , | |
10 | .Nm xdr_bool , | |
11 | .Nm xdr_bytes , | |
12 | .Nm xdr_char , | |
13 | .Nm xdr_destroy , | |
14 | .Nm xdr_double , | |
15 | .Nm xdr_enum , | |
16 | .Nm xdr_float , | |
17 | .Nm xdr_free , | |
18 | .Nm xdr_getpos , | |
19 | .Nm xdr_hyper , | |
20 | .Nm xdr_inline , | |
21 | .Nm xdr_int , | |
22 | .Nm xdr_long , | |
23 | .Nm xdr_longlong_t , | |
24 | .Nm xdrmem_create , | |
25 | .Nm xdr_opaque , | |
26 | .Nm xdr_pointer , | |
27 | .Nm xdrrec_create , | |
28 | .Nm xdrrec_endofrecord , | |
29 | .Nm xdrrec_eof , | |
30 | .Nm xdrrec_skiprecord , | |
31 | .Nm xdr_reference , | |
32 | .Nm xdr_setpos , | |
33 | .Nm xdr_short , | |
34 | .Nm xdrstdio_create , | |
35 | .Nm xdr_string , | |
36 | .Nm xdr_u_char , | |
37 | .Nm xdr_u_hyper , | |
38 | .Nm xdr_u_int , | |
39 | .Nm xdr_u_long , | |
40 | .Nm xdr_u_longlong_t , | |
41 | .Nm xdr_u_short , | |
42 | .Nm xdr_union , | |
43 | .Nm xdr_vector , | |
44 | .Nm xdr_void , | |
45 | .Nm xdr_wrapstring | |
46 | .Nd "library routines for external data representation" | |
47 | .Sh LIBRARY | |
48 | .Lb libc | |
49 | .Sh SYNOPSIS | |
50 | .In rpc/types.h | |
51 | .In rpc/xdr.h | |
52 | .Pp | |
53 | See | |
54 | .Sx DESCRIPTION | |
55 | for function declarations. | |
56 | .Sh DESCRIPTION | |
57 | These routines allow C programmers to describe | |
58 | arbitrary data structures in a machine-independent fashion. | |
59 | Data for remote procedure calls are transmitted using these | |
60 | routines. | |
61 | .Pp | |
62 | .Bl -tag -width indent -compact | |
63 | .It Xo | |
64 | .Ft int | |
65 | .Xc | |
66 | .It Xo | |
67 | .Fo xdr_array | |
68 | .Fa "XDR *xdrs" | |
69 | .Fa "char **arrp" | |
70 | .Fa "u_int *sizep" | |
71 | .Fa "u_int maxsize" | |
72 | .Fa "u_int elsize" | |
73 | .Fa "xdrproc_t elproc" | |
74 | .Fc | |
75 | .Xc | |
76 | .Pp | |
77 | A filter primitive that translates between variable-length | |
78 | arrays | |
79 | and their corresponding external representations. | |
80 | The | |
81 | .Fa arrp | |
82 | argument | |
83 | is the address of the pointer to the array, while | |
84 | .Fa sizep | |
85 | is the address of the element count of the array; | |
86 | this element count cannot exceed | |
87 | .Fa maxsize . | |
88 | The | |
89 | .Fa elsize | |
90 | argument | |
91 | is the | |
92 | .Ic sizeof | |
93 | each of the array's elements, and | |
94 | .Fa elproc | |
95 | is an | |
96 | .Tn XDR | |
97 | filter that translates between | |
98 | the array elements' C form, and their external | |
99 | representation. | |
100 | This routine returns one if it succeeds, zero otherwise. | |
101 | .Pp | |
102 | .It Xo | |
103 | .Ft int | |
104 | .Xc | |
105 | .It Xo | |
106 | .Fn xdr_bool "XDR *xdrs" "bool_t *bp" | |
107 | .Xc | |
108 | .Pp | |
109 | A filter primitive that translates between booleans (C | |
110 | integers) | |
111 | and their external representations. | |
112 | When encoding data, this | |
113 | filter produces values of either one or zero. | |
114 | This routine returns one if it succeeds, zero otherwise. | |
115 | .Pp | |
116 | .It Xo | |
117 | .Ft int | |
118 | .Xc | |
119 | .It Xo | |
120 | .Fn xdr_bytes "XDR *xdrs" "char **sp" "u_int *sizep" "u_int maxsize" | |
121 | .Xc | |
122 | .Pp | |
123 | A filter primitive that translates between counted byte | |
124 | strings and their external representations. | |
125 | The | |
126 | .Fa sp | |
127 | argument | |
128 | is the address of the string pointer. | |
129 | The length of the | |
130 | string is located at address | |
131 | .Fa sizep ; | |
132 | strings cannot be longer than | |
133 | .Fa maxsize . | |
134 | This routine returns one if it succeeds, zero otherwise. | |
135 | .Pp | |
136 | .It Xo | |
137 | .Ft int | |
138 | .Xc | |
139 | .It Xo | |
140 | .Fn xdr_char "XDR *xdrs" "char *cp" | |
141 | .Xc | |
142 | .Pp | |
143 | A filter primitive that translates between C characters | |
144 | and their external representations. | |
145 | This routine returns one if it succeeds, zero otherwise. | |
146 | Note: encoded characters are not packed, and occupy 4 bytes | |
147 | each. | |
148 | For arrays of characters, it is worthwhile to | |
149 | consider | |
150 | .Fn xdr_bytes , | |
151 | .Fn xdr_opaque | |
152 | or | |
153 | .Fn xdr_string . | |
154 | .Pp | |
155 | .It Xo | |
156 | .Ft void | |
157 | .Xc | |
158 | .It Xo | |
159 | .Fn xdr_destroy "XDR *xdrs" | |
160 | .Xc | |
161 | .Pp | |
162 | A macro that invokes the destroy routine associated with the | |
163 | .Tn XDR | |
164 | stream, | |
165 | .Fa xdrs . | |
166 | Destruction usually involves freeing private data structures | |
167 | associated with the stream. | |
168 | Using | |
169 | .Fa xdrs | |
170 | after invoking | |
171 | .Fn xdr_destroy | |
172 | is undefined. | |
173 | .Pp | |
174 | .It Xo | |
175 | .Ft int | |
176 | .Xc | |
177 | .It Xo | |
178 | .Fn xdr_double "XDR *xdrs" "double *dp" | |
179 | .Xc | |
180 | .Pp | |
181 | A filter primitive that translates between C | |
182 | .Vt double | |
183 | precision numbers and their external representations. | |
184 | This routine returns one if it succeeds, zero otherwise. | |
185 | .Pp | |
186 | .It Xo | |
187 | .Ft int | |
188 | .Xc | |
189 | .It Xo | |
190 | .Fn xdr_enum "XDR *xdrs" "enum_t *ep" | |
191 | .Xc | |
192 | .Pp | |
193 | A filter primitive that translates between C | |
194 | .Vt enum Ns s | |
195 | (actually integers) and their external representations. | |
196 | This routine returns one if it succeeds, zero otherwise. | |
197 | .Pp | |
198 | .It Xo | |
199 | .Ft int | |
200 | .Xc | |
201 | .It Xo | |
202 | .Fn xdr_float "XDR *xdrs" "float *fp" | |
203 | .Xc | |
204 | .Pp | |
205 | A filter primitive that translates between C | |
206 | .Vt float Ns s | |
207 | and their external representations. | |
208 | This routine returns one if it succeeds, zero otherwise. | |
209 | .Pp | |
210 | .It Xo | |
211 | .Ft void | |
212 | .Xc | |
213 | .It Xo | |
d49d4c81 | 214 | .Fn xdr_free "xdrproc_t proc" "void *objp" |
b3dd680f A |
215 | .Xc |
216 | .Pp | |
217 | Generic freeing routine. | |
218 | The first argument is the | |
219 | .Tn XDR | |
220 | routine for the object being freed. | |
221 | The second argument | |
222 | is a pointer to the object itself. | |
223 | Note: the pointer passed | |
224 | to this routine is | |
225 | .Em not | |
226 | freed, but what it points to | |
227 | .Em is | |
228 | freed (recursively). | |
229 | .Pp | |
230 | .It Xo | |
231 | .Ft u_int | |
232 | .Xc | |
233 | .It Xo | |
234 | .Fn xdr_getpos "XDR *xdrs" | |
235 | .Xc | |
236 | .Pp | |
237 | A macro that invokes the get\-position routine | |
238 | associated with the | |
239 | .Tn XDR | |
240 | stream, | |
241 | .Fa xdrs . | |
242 | The routine returns an unsigned integer, | |
243 | which indicates the position of the | |
244 | .Tn XDR | |
245 | byte stream. | |
246 | A desirable feature of | |
247 | .Tn XDR | |
248 | streams is that simple arithmetic works with this number, | |
249 | although the | |
250 | .Tn XDR | |
251 | stream instances need not guarantee this. | |
252 | .Pp | |
253 | .It Xo | |
254 | .Ft int | |
255 | .Xc | |
256 | .It Xo | |
257 | .Fn xdr_hyper "XDR *xdrs" "quad_t *llp" | |
258 | .Xc | |
259 | A filter primitive that translates between ANSI C | |
260 | .Vt "long long" | |
261 | integers and their external representations. | |
262 | This routine returns one if it succeeds, zero otherwise. | |
263 | .Pp | |
264 | .It Xo | |
265 | .Ft "long *" | |
266 | .Xc | |
267 | .It Xo | |
268 | .Fn xdr_inline "XDR *xdrs" "int len" | |
269 | .Xc | |
270 | .Pp | |
271 | A macro that invokes the in-line routine associated with the | |
272 | .Tn XDR | |
273 | stream, | |
274 | .Fa xdrs . | |
275 | The routine returns a pointer | |
276 | to a contiguous piece of the stream's buffer; | |
277 | .Fa len | |
278 | is the byte length of the desired buffer. | |
279 | Note: pointer is cast to | |
280 | .Vt "long *" . | |
281 | .Pp | |
282 | Warning: | |
283 | .Fn xdr_inline | |
284 | may return | |
285 | .Dv NULL | |
286 | (0) | |
287 | if it cannot allocate a contiguous piece of a buffer. | |
288 | Therefore the behavior may vary among stream instances; | |
289 | it exists for the sake of efficiency. | |
290 | .Pp | |
291 | .It Xo | |
292 | .Ft int | |
293 | .Xc | |
294 | .It Xo | |
295 | .Fn xdr_int "XDR *xdrs" "int *ip" | |
296 | .Xc | |
297 | .Pp | |
298 | A filter primitive that translates between C integers | |
299 | and their external representations. | |
300 | This routine returns one if it succeeds, zero otherwise. | |
301 | .Pp | |
302 | .It Xo | |
303 | .Ft int | |
304 | .Xc | |
305 | .It Xo | |
306 | .Fn xdr_long "XDR *xdrs" "long *lp" | |
307 | .Xc | |
308 | .Pp | |
309 | A filter primitive that translates between C | |
310 | .Vt long | |
311 | integers and their external representations. | |
312 | This routine returns one if it succeeds, zero otherwise. | |
313 | .Pp | |
314 | .It Xo | |
315 | .Ft int | |
316 | .Xc | |
317 | .It Xo | |
318 | .Fn xdr_longlong_t "XDR *xdrs" "quad_t *llp" | |
319 | .Xc | |
320 | A filter primitive that translates between ANSI C | |
321 | .Vt "long long" | |
322 | integers and their external representations. | |
323 | This routine returns one if it succeeds, zero otherwise. | |
324 | .Pp | |
325 | .It Xo | |
326 | .Ft void | |
327 | .Xc | |
328 | .It Xo | |
329 | .Fn xdrmem_create "XDR *xdrs" "char *addr" "u_int size" "enum xdr_op op" | |
330 | .Xc | |
331 | .Pp | |
332 | This routine initializes the | |
333 | .Tn XDR | |
334 | stream object pointed to by | |
335 | .Fa xdrs . | |
336 | The stream's data is written to, or read from, | |
337 | a chunk of memory at location | |
338 | .Fa addr | |
339 | whose length is no more than | |
340 | .Fa size | |
341 | bytes long. | |
342 | The | |
343 | .Fa op | |
344 | argument | |
345 | determines the direction of the | |
346 | .Tn XDR | |
347 | stream | |
348 | (either | |
349 | .Dv XDR_ENCODE , | |
350 | .Dv XDR_DECODE , | |
351 | or | |
352 | .Dv XDR_FREE ) . | |
353 | .Pp | |
354 | .It Xo | |
355 | .Ft int | |
356 | .Xc | |
357 | .It Xo | |
358 | .Fn xdr_opaque "XDR *xdrs" "char *cp" "u_int cnt" | |
359 | .Xc | |
360 | .Pp | |
361 | A filter primitive that translates between fixed size opaque | |
362 | data | |
363 | and its external representation. | |
364 | The | |
365 | .Fa cp | |
366 | argument | |
367 | is the address of the opaque object, and | |
368 | .Fa cnt | |
369 | is its size in bytes. | |
370 | This routine returns one if it succeeds, zero otherwise. | |
371 | .Pp | |
372 | .It Xo | |
373 | .Ft int | |
374 | .Xc | |
375 | .It Xo | |
376 | .Fn xdr_pointer "XDR *xdrs" "char **objpp" "u_int objsize" "xdrproc_t xdrobj" | |
377 | .Xc | |
378 | .Pp | |
379 | Like | |
380 | .Fn xdr_reference | |
381 | except that it serializes | |
382 | .Dv NULL | |
383 | pointers, whereas | |
384 | .Fn xdr_reference | |
385 | does not. | |
386 | Thus, | |
387 | .Fn xdr_pointer | |
388 | can represent | |
389 | recursive data structures, such as binary trees or | |
390 | linked lists. | |
391 | .Pp | |
392 | .It Xo | |
393 | .Ft void | |
394 | .Xc | |
395 | .It Xo | |
396 | .Fo xdrrec_create | |
397 | .Fa "XDR *xdrs" | |
398 | .Fa "u_int sendsize" | |
399 | .Fa "u_int recvsize" | |
d49d4c81 | 400 | .Fa "void *handle" |
b3dd680f A |
401 | .Fa "int \*(lp*readit\*(rp\*(lp\*(rp" |
402 | .Fa "int \*(lp*writeit\*(rp\*(lp\*(rp" | |
403 | .Fc | |
404 | .Xc | |
405 | .Pp | |
406 | This routine initializes the | |
407 | .Tn XDR | |
408 | stream object pointed to by | |
409 | .Fa xdrs . | |
410 | The stream's data is written to a buffer of size | |
411 | .Fa sendsize ; | |
412 | a value of zero indicates the system should use a suitable | |
413 | default. | |
414 | The stream's data is read from a buffer of size | |
415 | .Fa recvsize ; | |
416 | it too can be set to a suitable default by passing a zero | |
417 | value. | |
418 | When a stream's output buffer is full, | |
419 | .Fn writeit | |
420 | is called. | |
421 | Similarly, when a stream's input buffer is empty, | |
422 | .Fn readit | |
423 | is called. | |
424 | The behavior of these two routines is similar to | |
425 | the | |
426 | system calls | |
427 | .Xr read 2 | |
428 | and | |
429 | .Xr write 2 , | |
430 | except that | |
431 | .Fa handle | |
432 | is passed to the former routines as the first argument. | |
433 | Note: the | |
434 | .Tn XDR | |
435 | stream's | |
436 | .Fa op | |
437 | field must be set by the caller. | |
438 | .Pp | |
439 | Warning: this | |
440 | .Tn XDR | |
441 | stream implements an intermediate record stream. | |
442 | Therefore there are additional bytes in the stream | |
443 | to provide record boundary information. | |
444 | .Pp | |
445 | .It Xo | |
446 | .Ft int | |
447 | .Xc | |
448 | .It Xo | |
449 | .Fn xdrrec_endofrecord "XDR *xdrs" "int sendnow" | |
450 | .Xc | |
451 | .Pp | |
452 | This routine can be invoked only on | |
453 | streams created by | |
454 | .Fn xdrrec_create . | |
455 | The data in the output buffer is marked as a completed | |
456 | record, | |
457 | and the output buffer is optionally written out if | |
458 | .Fa sendnow | |
459 | is non-zero. | |
460 | This routine returns one if it succeeds, zero | |
461 | otherwise. | |
462 | .Pp | |
463 | .It Xo | |
464 | .Ft int | |
465 | .Xc | |
466 | .It Xo | |
467 | .Fn xdrrec_eof "XDR *xdrs" | |
468 | .Xc | |
469 | .Pp | |
470 | This routine can be invoked only on | |
471 | streams created by | |
472 | .Fn xdrrec_create . | |
473 | After consuming the rest of the current record in the stream, | |
474 | this routine returns one if the stream has no more input, | |
475 | zero otherwise. | |
476 | .Pp | |
477 | .It Xo | |
478 | .Ft int | |
479 | .Xc | |
480 | .It Xo | |
481 | .Fn xdrrec_skiprecord "XDR *xdrs" | |
482 | .Xc | |
483 | .Pp | |
484 | This routine can be invoked only on | |
485 | streams created by | |
486 | .Fn xdrrec_create . | |
487 | It tells the | |
488 | .Tn XDR | |
489 | implementation that the rest of the current record | |
490 | in the stream's input buffer should be discarded. | |
491 | This routine returns one if it succeeds, zero otherwise. | |
492 | .Pp | |
493 | .It Xo | |
494 | .Ft int | |
495 | .Xc | |
496 | .It Xo | |
497 | .Fn xdr_reference "XDR *xdrs" "char **pp" "u_int size" "xdrproc_t proc" | |
498 | .Xc | |
499 | .Pp | |
500 | A primitive that provides pointer chasing within structures. | |
501 | The | |
502 | .Fa pp | |
503 | argument | |
504 | is the address of the pointer; | |
505 | .Fa size | |
506 | is the | |
507 | .Ic sizeof | |
508 | the structure that | |
509 | .Fa *pp | |
510 | points to; and | |
511 | .Fa proc | |
512 | is an | |
513 | .Tn XDR | |
514 | procedure that filters the structure | |
515 | between its C form and its external representation. | |
516 | This routine returns one if it succeeds, zero otherwise. | |
517 | .Pp | |
518 | Warning: this routine does not understand | |
519 | .Dv NULL | |
520 | pointers. | |
521 | Use | |
522 | .Fn xdr_pointer | |
523 | instead. | |
524 | .Pp | |
525 | .It Xo | |
526 | .Ft int | |
527 | .Xc | |
528 | .It Xo | |
529 | .Fn xdr_setpos "XDR *xdrs" "u_int pos" | |
530 | .Xc | |
531 | .Pp | |
532 | A macro that invokes the set position routine associated with | |
533 | the | |
534 | .Tn XDR | |
535 | stream | |
536 | .Fa xdrs . | |
537 | The | |
538 | .Fa pos | |
539 | argument | |
540 | is a position value obtained from | |
541 | .Fn xdr_getpos . | |
542 | This routine returns one if the | |
543 | .Tn XDR | |
544 | stream could be repositioned, | |
545 | and zero otherwise. | |
546 | .Pp | |
547 | Warning: it is difficult to reposition some types of | |
548 | .Tn XDR | |
549 | streams, so this routine may fail with one | |
550 | type of stream and succeed with another. | |
551 | .Pp | |
552 | .It Xo | |
553 | .Ft int | |
554 | .Xc | |
555 | .It Xo | |
556 | .Fn xdr_short "XDR *xdrs" "short *sp" | |
557 | .Xc | |
558 | .Pp | |
559 | A filter primitive that translates between C | |
560 | .Vt short | |
561 | integers and their external representations. | |
562 | This routine returns one if it succeeds, zero otherwise. | |
563 | .Pp | |
564 | .It Li "#ifdef _STDIO_H_" | |
565 | .It Li "/* XDR using stdio library */" | |
566 | .It Xo | |
567 | .Ft void | |
568 | .Xc | |
569 | .It Xo | |
570 | .Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op" | |
571 | .Xc | |
572 | .It Li "#endif" | |
573 | .Pp | |
574 | This routine initializes the | |
575 | .Tn XDR | |
576 | stream object pointed to by | |
577 | .Fa xdrs . | |
578 | The | |
579 | .Tn XDR | |
580 | stream data is written to, or read from, the Standard | |
581 | .Tn I/O | |
582 | stream | |
583 | .Fa file . | |
584 | The | |
585 | .Fa op | |
586 | argument | |
587 | determines the direction of the | |
588 | .Tn XDR | |
589 | stream (either | |
590 | .Dv XDR_ENCODE , | |
591 | .Dv XDR_DECODE , | |
592 | or | |
593 | .Dv XDR_FREE ) . | |
594 | .Pp | |
595 | Warning: the destroy routine associated with such | |
596 | .Tn XDR | |
597 | streams calls | |
598 | .Xr fflush 3 | |
599 | on the | |
600 | .Fa file | |
601 | stream, but never | |
602 | .Xr fclose 3 . | |
603 | .Pp | |
604 | .It Xo | |
605 | .Ft int | |
606 | .Xc | |
607 | .It Xo | |
608 | .Fn xdr_string "XDR *xdrs" "char **sp" "u_int maxsize" | |
609 | .Xc | |
610 | .Pp | |
611 | A filter primitive that translates between C strings and | |
612 | their | |
613 | corresponding external representations. | |
614 | Strings cannot be longer than | |
615 | .Fa maxsize . | |
616 | Note: | |
617 | .Fa sp | |
618 | is the address of the string's pointer. | |
619 | This routine returns one if it succeeds, zero otherwise. | |
620 | .Pp | |
621 | .It Xo | |
622 | .Ft int | |
623 | .Xc | |
624 | .It Xo | |
625 | .Fn xdr_u_char "XDR *xdrs" "unsigned char *ucp" | |
626 | .Xc | |
627 | .Pp | |
628 | A filter primitive that translates between | |
629 | .Vt unsigned | |
630 | C characters and their external representations. | |
631 | This routine returns one if it succeeds, zero otherwise. | |
632 | .Pp | |
633 | .It Xo | |
634 | .Ft int | |
635 | .Xc | |
636 | .It Xo | |
637 | .Fn xdr_u_hyper "XDR *xdrs" "u_quad_t *ullp" | |
638 | .Xc | |
639 | A filter primitive that translates between | |
640 | .Vt unsigned | |
641 | ANSI C | |
642 | .Vt long long | |
643 | integers and their external representations. | |
644 | This routine returns one if it succeeds, zero otherwise. | |
645 | .Pp | |
646 | .It Xo | |
647 | .Ft int | |
648 | .Xc | |
649 | .It Xo | |
650 | .Fn xdr_u_int "XDR *xdrs" "unsigned *up" | |
651 | .Xc | |
652 | .Pp | |
653 | A filter primitive that translates between C | |
654 | .Vt unsigned | |
655 | integers and their external representations. | |
656 | This routine returns one if it succeeds, zero otherwise. | |
657 | .Pp | |
658 | .It Xo | |
659 | .Ft int | |
660 | .Xc | |
661 | .It Xo | |
662 | .Fn xdr_u_long "XDR *xdrs" "unsigned long *ulp" | |
663 | .Xc | |
664 | .Pp | |
665 | A filter primitive that translates between C | |
666 | .Vt "unsigned long" | |
667 | integers and their external representations. | |
668 | This routine returns one if it succeeds, zero otherwise. | |
669 | .Pp | |
670 | .It Xo | |
671 | .Ft int | |
672 | .Xc | |
673 | .It Xo | |
674 | .Fn xdr_u_longlong_t "XDR *xdrs" "u_quad_t *ullp" | |
675 | .Xc | |
676 | A filter primitive that translates between | |
677 | .Vt unsigned | |
678 | ANSI C | |
679 | .Vt "long long" | |
680 | integers and their external representations. | |
681 | This routine returns one if it succeeds, zero otherwise. | |
682 | .Pp | |
683 | .It Xo | |
684 | .Ft int | |
685 | .Xc | |
686 | .It Xo | |
687 | .Fn xdr_u_short "XDR *xdrs" "unsigned short *usp" | |
688 | .Xc | |
689 | .Pp | |
690 | A filter primitive that translates between C | |
691 | .Vt "unsigned short" | |
692 | integers and their external representations. | |
693 | This routine returns one if it succeeds, zero otherwise. | |
694 | .Pp | |
695 | .It Xo | |
696 | .Ft int | |
697 | .Xc | |
698 | .It Xo | |
699 | .Fo xdr_union | |
700 | .Fa "XDR *xdrs" | |
701 | .Fa "enum_t *dscmp" | |
702 | .Fa "char *unp" | |
703 | .Fa "const struct xdr_discrim *choices" | |
704 | .Fa "xdrproc_t defaultarm" | |
705 | .Fc | |
706 | .Xc | |
707 | .Pp | |
708 | A filter primitive that translates between a discriminated C | |
709 | .Vt union | |
710 | and its corresponding external representation. | |
711 | It first | |
712 | translates the discriminant of the union located at | |
713 | .Fa dscmp . | |
714 | This discriminant is always an | |
715 | .Vt enum_t . | |
716 | Next the union located at | |
717 | .Fa unp | |
718 | is translated. | |
719 | The | |
720 | .Fa choices | |
721 | argument | |
722 | is a pointer to an array of | |
723 | .Vt xdr_discrim | |
724 | structures. | |
725 | Each structure contains an ordered pair of | |
726 | .Bq Va value , proc . | |
727 | If the union's discriminant is equal to the associated | |
728 | .Va value , | |
729 | then the | |
730 | .Fn proc | |
731 | is called to translate the union. | |
732 | The end of the | |
733 | .Vt xdr_discrim | |
734 | structure array is denoted by a routine of value | |
735 | .Dv NULL . | |
736 | If the discriminant is not found in the | |
737 | .Fa choices | |
738 | array, then the | |
739 | .Fn defaultarm | |
740 | procedure is called (if it is not | |
741 | .Dv NULL ) . | |
742 | Returns one if it succeeds, zero otherwise. | |
743 | .Pp | |
744 | .It Xo | |
745 | .Ft int | |
746 | .Xc | |
747 | .It Xo | |
748 | .Fo xdr_vector | |
749 | .Fa "XDR *xdrs" | |
750 | .Fa "char *arrp" | |
751 | .Fa "u_int size" | |
752 | .Fa "u_int elsize" | |
753 | .Fa "xdrproc_t elproc" | |
754 | .Fc | |
755 | .Xc | |
756 | .Pp | |
757 | A filter primitive that translates between fixed-length | |
758 | arrays | |
759 | and their corresponding external representations. | |
760 | The | |
761 | .Fa arrp | |
762 | argument | |
763 | is the address of the pointer to the array, while | |
764 | .Fa size | |
765 | is the element count of the array. | |
766 | The | |
767 | .Fa elsize | |
768 | argument | |
769 | is the | |
770 | .Ic sizeof | |
771 | each of the array's elements, and | |
772 | .Fa elproc | |
773 | is an | |
774 | .Tn XDR | |
775 | filter that translates between | |
776 | the array elements' C form, and their external | |
777 | representation. | |
778 | This routine returns one if it succeeds, zero otherwise. | |
779 | .Pp | |
780 | .It Xo | |
781 | .Ft int | |
782 | .Xc | |
783 | .It Xo | |
784 | .Fn xdr_void void | |
785 | .Xc | |
786 | .Pp | |
787 | This routine always returns one. | |
788 | It may be passed to | |
789 | .Tn RPC | |
790 | routines that require a function argument, | |
791 | where nothing is to be done. | |
792 | .Pp | |
793 | .It Xo | |
794 | .Ft int | |
795 | .Xc | |
796 | .It Xo | |
797 | .Fn xdr_wrapstring "XDR *xdrs" "char **sp" | |
798 | .Xc | |
799 | .Pp | |
800 | A primitive that calls | |
801 | .Fn xdr_string xdrs sp MAXUN.UNSIGNED ; | |
802 | where | |
803 | .Dv MAXUN.UNSIGNED | |
804 | is the maximum value of an unsigned integer. | |
805 | The | |
806 | .Fn xdr_wrapstring | |
807 | function | |
808 | is handy because the | |
809 | .Tn RPC | |
810 | package passes a maximum of two | |
811 | .Tn XDR | |
812 | routines as arguments, and | |
813 | .Fn xdr_string , | |
814 | one of the most frequently used primitives, requires three. | |
815 | Returns one if it succeeds, zero otherwise. | |
816 | .El | |
817 | .Sh SEE ALSO | |
818 | .Xr rpc 3 | |
819 | .Rs | |
820 | .%T "eXternal Data Representation Standard: Protocol Specification" | |
821 | .Re | |
822 | .Rs | |
823 | .%T "eXternal Data Representation: Sun Technical Notes" | |
824 | .Re | |
825 | .Rs | |
826 | .%T "XDR: External Data Representation Standard" | |
827 | .%O RFC1014 | |
828 | .%Q "Sun Microsystems, Inc., USC\-ISI" | |
829 | .Re |