xref: /freebsd/lib/libc/xdr/xdr.3 (revision c6e2c333219cf7fce6f57928be4dcd7485178610)
1eae561b3SGarrett Wollman.\" @(#)xdr.3n	2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
27f3dea24SPeter Wemm.\" $FreeBSD$
3e83201b4SWolfram Schneider.\"
41abae7eeSRuslan Ermilov.Dd February 16, 1988
51abae7eeSRuslan Ermilov.Dt XDR 3
61abae7eeSRuslan Ermilov.Os
71abae7eeSRuslan Ermilov.Sh NAME
81abae7eeSRuslan Ermilov.Nm xdr
91abae7eeSRuslan Ermilov.Nd "library routines for external data representation"
101abae7eeSRuslan Ermilov.Sh LIBRARY
111abae7eeSRuslan Ermilov.Lb libc
121abae7eeSRuslan Ermilov.Sh SYNOPSIS
1314e6355fSBruce Evans.Fd "#include <rpc/types.h>"
141abae7eeSRuslan Ermilov.Fd "#include <rpc/xdr.h>"
151abae7eeSRuslan Ermilov.Pp
161abae7eeSRuslan ErmilovSee
171abae7eeSRuslan Ermilov.Sx DESCRIPTION
181abae7eeSRuslan Ermilovfor function declarations.
191abae7eeSRuslan Ermilov.Sh DESCRIPTION
20eae561b3SGarrett WollmanThese routines allow C programmers to describe
21eae561b3SGarrett Wollmanarbitrary data structures in a machine-independent fashion.
22eae561b3SGarrett WollmanData for remote procedure calls are transmitted using these
23eae561b3SGarrett Wollmanroutines.
241abae7eeSRuslan Ermilov.Pp
251abae7eeSRuslan Ermilov.Bl -tag -width indent -compact
261abae7eeSRuslan Ermilov.It Xo
271abae7eeSRuslan Ermilov.Ft int
281abae7eeSRuslan Ermilov.Xc
291abae7eeSRuslan Ermilov.It Xo
301abae7eeSRuslan Ermilov.Fo xdr_array
311abae7eeSRuslan Ermilov.Fa "XDR *xdrs"
321abae7eeSRuslan Ermilov.Fa "char **arrp"
331abae7eeSRuslan Ermilov.Fa "u_int *sizep"
341abae7eeSRuslan Ermilov.Fa "u_int maxsize"
351abae7eeSRuslan Ermilov.Fa "u_int elsize"
361abae7eeSRuslan Ermilov.Fa "xdrproc_t elproc"
371abae7eeSRuslan Ermilov.Fc
381abae7eeSRuslan Ermilov.Xc
391abae7eeSRuslan Ermilov.Pp
40eae561b3SGarrett WollmanA filter primitive that translates between variable-length
41eae561b3SGarrett Wollmanarrays
42c6ff3a1bSSheldon Hearnand their corresponding external representations.
43c6ff3a1bSSheldon HearnThe
44eae561b3SGarrett Wollmanparameter
451abae7eeSRuslan Ermilov.Fa arrp
46eae561b3SGarrett Wollmanis the address of the pointer to the array, while
471abae7eeSRuslan Ermilov.Fa sizep
48eae561b3SGarrett Wollmanis the address of the element count of the array;
49eae561b3SGarrett Wollmanthis element count cannot exceed
501abae7eeSRuslan Ermilov.Fa maxsize .
51eae561b3SGarrett WollmanThe parameter
521abae7eeSRuslan Ermilov.Fa elsize
53eae561b3SGarrett Wollmanis the
541abae7eeSRuslan Ermilov.Ic sizeof
55eae561b3SGarrett Wollmaneach of the array's elements, and
561abae7eeSRuslan Ermilov.Fa elproc
57eae561b3SGarrett Wollmanis an
581abae7eeSRuslan Ermilov.Tn XDR
59eae561b3SGarrett Wollmanfilter that translates between
60eae561b3SGarrett Wollmanthe array elements' C form, and their external
61eae561b3SGarrett Wollmanrepresentation.
62eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
631abae7eeSRuslan Ermilov.Pp
641abae7eeSRuslan Ermilov.It Xo
651abae7eeSRuslan Ermilov.Ft int
661abae7eeSRuslan Ermilov.Xc
671abae7eeSRuslan Ermilov.It Xo
681abae7eeSRuslan Ermilov.Fn xdr_bool "XDR *xdrs" "bool_t *bp"
691abae7eeSRuslan Ermilov.Xc
701abae7eeSRuslan Ermilov.Pp
71eae561b3SGarrett WollmanA filter primitive that translates between booleans (C
72eae561b3SGarrett Wollmanintegers)
73c6ff3a1bSSheldon Hearnand their external representations.
74c6ff3a1bSSheldon HearnWhen encoding data, this
75eae561b3SGarrett Wollmanfilter produces values of either one or zero.
76eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
771abae7eeSRuslan Ermilov.Pp
781abae7eeSRuslan Ermilov.It Xo
791abae7eeSRuslan Ermilov.Ft int
801abae7eeSRuslan Ermilov.Xc
811abae7eeSRuslan Ermilov.It Xo
821abae7eeSRuslan Ermilov.Fn xdr_bytes "XDR *xdrs" "char **sp" "u_int *sizep" "u_int maxsize"
831abae7eeSRuslan Ermilov.Xc
841abae7eeSRuslan Ermilov.Pp
85eae561b3SGarrett WollmanA filter primitive that translates between counted byte
86eae561b3SGarrett Wollmanstrings and their external representations.
87eae561b3SGarrett WollmanThe parameter
881abae7eeSRuslan Ermilov.Fa sp
89c6ff3a1bSSheldon Hearnis the address of the string pointer.
90c6ff3a1bSSheldon HearnThe length of the
91eae561b3SGarrett Wollmanstring is located at address
921abae7eeSRuslan Ermilov.Fa sizep ;
93eae561b3SGarrett Wollmanstrings cannot be longer than
941abae7eeSRuslan Ermilov.Fa maxsize .
95eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
961abae7eeSRuslan Ermilov.Pp
971abae7eeSRuslan Ermilov.It Xo
981abae7eeSRuslan Ermilov.Ft int
991abae7eeSRuslan Ermilov.Xc
1001abae7eeSRuslan Ermilov.It Xo
1011abae7eeSRuslan Ermilov.Fn xdr_char "XDR *xdrs" "char *cp"
1021abae7eeSRuslan Ermilov.Xc
1031abae7eeSRuslan Ermilov.Pp
104eae561b3SGarrett WollmanA filter primitive that translates between C characters
105eae561b3SGarrett Wollmanand their external representations.
106eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
107eae561b3SGarrett WollmanNote: encoded characters are not packed, and occupy 4 bytes
108c6ff3a1bSSheldon Hearneach.
109c6ff3a1bSSheldon HearnFor arrays of characters, it is worthwhile to
110eae561b3SGarrett Wollmanconsider
1111abae7eeSRuslan Ermilov.Fn xdr_bytes ,
1121abae7eeSRuslan Ermilov.Fn xdr_opaque
113eae561b3SGarrett Wollmanor
1141abae7eeSRuslan Ermilov.Fn xdr_string .
1151abae7eeSRuslan Ermilov.Pp
1161abae7eeSRuslan Ermilov.It Xo
1171abae7eeSRuslan Ermilov.Ft void
1181abae7eeSRuslan Ermilov.Xc
1191abae7eeSRuslan Ermilov.It Xo
1201abae7eeSRuslan Ermilov.Fn xdr_destroy "XDR *xdrs"
1211abae7eeSRuslan Ermilov.Xc
1221abae7eeSRuslan Ermilov.Pp
123eae561b3SGarrett WollmanA macro that invokes the destroy routine associated with the
1241abae7eeSRuslan Ermilov.Tn XDR
125eae561b3SGarrett Wollmanstream,
1261abae7eeSRuslan Ermilov.Fa xdrs .
127eae561b3SGarrett WollmanDestruction usually involves freeing private data structures
1281abae7eeSRuslan Ermilovassociated with the stream.
1291abae7eeSRuslan ErmilovUsing
1301abae7eeSRuslan Ermilov.Fa xdrs
131eae561b3SGarrett Wollmanafter invoking
1321abae7eeSRuslan Ermilov.Fn xdr_destroy
133eae561b3SGarrett Wollmanis undefined.
1341abae7eeSRuslan Ermilov.Pp
1351abae7eeSRuslan Ermilov.It Xo
1361abae7eeSRuslan Ermilov.Ft int
1371abae7eeSRuslan Ermilov.Xc
1381abae7eeSRuslan Ermilov.It Xo
1391abae7eeSRuslan Ermilov.Fn xdr_double "XDR *xdrs" "double *dp"
1401abae7eeSRuslan Ermilov.Xc
1411abae7eeSRuslan Ermilov.Pp
142eae561b3SGarrett WollmanA filter primitive that translates between C
1431abae7eeSRuslan Ermilov.Vt double
144eae561b3SGarrett Wollmanprecision numbers and their external representations.
145eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
1461abae7eeSRuslan Ermilov.Pp
1471abae7eeSRuslan Ermilov.It Xo
1481abae7eeSRuslan Ermilov.Ft int
1491abae7eeSRuslan Ermilov.Xc
1501abae7eeSRuslan Ermilov.It Xo
1511abae7eeSRuslan Ermilov.Fn xdr_enum "XDR *xdrs" "enum_t *ep"
1521abae7eeSRuslan Ermilov.Xc
1531abae7eeSRuslan Ermilov.Pp
154eae561b3SGarrett WollmanA filter primitive that translates between C
1551abae7eeSRuslan Ermilov.Vt enum Ns s
156eae561b3SGarrett Wollman(actually integers) and their external representations.
157eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
1581abae7eeSRuslan Ermilov.Pp
1591abae7eeSRuslan Ermilov.It Xo
1601abae7eeSRuslan Ermilov.Ft int
1611abae7eeSRuslan Ermilov.Xc
1621abae7eeSRuslan Ermilov.It Xo
1631abae7eeSRuslan Ermilov.Fn xdr_float "XDR *xdrs" "float *fp"
1641abae7eeSRuslan Ermilov.Xc
1651abae7eeSRuslan Ermilov.Pp
166eae561b3SGarrett WollmanA filter primitive that translates between C
1671abae7eeSRuslan Ermilov.Vt float Ns s
168eae561b3SGarrett Wollmanand their external representations.
169eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
1701abae7eeSRuslan Ermilov.Pp
1711abae7eeSRuslan Ermilov.It Xo
1721abae7eeSRuslan Ermilov.Ft void
1731abae7eeSRuslan Ermilov.Xc
1741abae7eeSRuslan Ermilov.It Xo
1751abae7eeSRuslan Ermilov.Fn xdr_free "xdrproc_t proc" "char *objp"
1761abae7eeSRuslan Ermilov.Xc
1771abae7eeSRuslan Ermilov.Pp
178c6ff3a1bSSheldon HearnGeneric freeing routine.
179c6ff3a1bSSheldon HearnThe first argument is the
1801abae7eeSRuslan Ermilov.Tn XDR
181c6ff3a1bSSheldon Hearnroutine for the object being freed.
182c6ff3a1bSSheldon HearnThe second argument
183c6ff3a1bSSheldon Hearnis a pointer to the object itself.
184c6ff3a1bSSheldon HearnNote: the pointer passed
185eae561b3SGarrett Wollmanto this routine is
1861abae7eeSRuslan Ermilov.Em not
187eae561b3SGarrett Wollmanfreed, but what it points to
1881abae7eeSRuslan Ermilov.Em is
189eae561b3SGarrett Wollmanfreed (recursively).
1901abae7eeSRuslan Ermilov.Pp
1911abae7eeSRuslan Ermilov.It Xo
1921abae7eeSRuslan Ermilov.Ft u_int
1931abae7eeSRuslan Ermilov.Xc
1941abae7eeSRuslan Ermilov.It Xo
1951abae7eeSRuslan Ermilov.Fn xdr_getpos "XDR *xdrs"
1961abae7eeSRuslan Ermilov.Xc
1971abae7eeSRuslan Ermilov.Pp
1981abae7eeSRuslan ErmilovA macro that invokes the get\-position routine
199eae561b3SGarrett Wollmanassociated with the
2001abae7eeSRuslan Ermilov.Tn XDR
201eae561b3SGarrett Wollmanstream,
2021abae7eeSRuslan Ermilov.Fa xdrs .
203eae561b3SGarrett WollmanThe routine returns an unsigned integer,
204eae561b3SGarrett Wollmanwhich indicates the position of the
2051abae7eeSRuslan Ermilov.Tn XDR
206eae561b3SGarrett Wollmanbyte stream.
207eae561b3SGarrett WollmanA desirable feature of
2081abae7eeSRuslan Ermilov.Tn XDR
209eae561b3SGarrett Wollmanstreams is that simple arithmetic works with this number,
210eae561b3SGarrett Wollmanalthough the
2111abae7eeSRuslan Ermilov.Tn XDR
212eae561b3SGarrett Wollmanstream instances need not guarantee this.
2131abae7eeSRuslan Ermilov.Pp
2141abae7eeSRuslan Ermilov.It Xo
2151abae7eeSRuslan Ermilov.Ft "long *"
2161abae7eeSRuslan Ermilov.Xc
2171abae7eeSRuslan Ermilov.It Xo
2181abae7eeSRuslan Ermilov.Fn xdr_inline "XDR *xdrs" "int len"
2191abae7eeSRuslan Ermilov.Xc
2201abae7eeSRuslan Ermilov.Pp
221eae561b3SGarrett WollmanA macro that invokes the in-line routine associated with the
2221abae7eeSRuslan Ermilov.Tn XDR
223eae561b3SGarrett Wollmanstream,
2241abae7eeSRuslan Ermilov.Fa xdrs .
225eae561b3SGarrett WollmanThe routine returns a pointer
226eae561b3SGarrett Wollmanto a contiguous piece of the stream's buffer;
2271abae7eeSRuslan Ermilov.Fa len
228eae561b3SGarrett Wollmanis the byte length of the desired buffer.
229eae561b3SGarrett WollmanNote: pointer is cast to
2301abae7eeSRuslan Ermilov.Vt "long *" .
2311abae7eeSRuslan Ermilov.Pp
232eae561b3SGarrett WollmanWarning:
2331abae7eeSRuslan Ermilov.Fn xdr_inline
234eae561b3SGarrett Wollmanmay return
2351abae7eeSRuslan Ermilov.Dv NULL
236eae561b3SGarrett Wollman(0)
237eae561b3SGarrett Wollmanif it cannot allocate a contiguous piece of a buffer.
238eae561b3SGarrett WollmanTherefore the behavior may vary among stream instances;
239eae561b3SGarrett Wollmanit exists for the sake of efficiency.
2401abae7eeSRuslan Ermilov.Pp
2411abae7eeSRuslan Ermilov.It Xo
2421abae7eeSRuslan Ermilov.Ft int
2431abae7eeSRuslan Ermilov.Xc
2441abae7eeSRuslan Ermilov.It Xo
2451abae7eeSRuslan Ermilov.Fn xdr_int "XDR *xdrs" "int *ip"
2461abae7eeSRuslan Ermilov.Xc
2471abae7eeSRuslan Ermilov.Pp
248eae561b3SGarrett WollmanA filter primitive that translates between C integers
249eae561b3SGarrett Wollmanand their external representations.
250eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
2511abae7eeSRuslan Ermilov.Pp
2521abae7eeSRuslan Ermilov.It Xo
2531abae7eeSRuslan Ermilov.Ft int
2541abae7eeSRuslan Ermilov.Xc
2551abae7eeSRuslan Ermilov.It Xo
2561abae7eeSRuslan Ermilov.Fn xdr_long "XDR *xdrs" "long *lp"
2571abae7eeSRuslan Ermilov.Xc
2581abae7eeSRuslan Ermilov.Pp
259eae561b3SGarrett WollmanA filter primitive that translates between C
2601abae7eeSRuslan Ermilov.Vt long
261eae561b3SGarrett Wollmanintegers and their external representations.
262eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
2631abae7eeSRuslan Ermilov.Pp
2641abae7eeSRuslan Ermilov.It Xo
2651abae7eeSRuslan Ermilov.Ft void
2661abae7eeSRuslan Ermilov.Xc
2671abae7eeSRuslan Ermilov.It Xo
2681abae7eeSRuslan Ermilov.Fn xdrmem_create "XDR *xdrs" "char *addr" "u_int size" "enum xdr_op op"
2691abae7eeSRuslan Ermilov.Xc
2701abae7eeSRuslan Ermilov.Pp
271eae561b3SGarrett WollmanThis routine initializes the
2721abae7eeSRuslan Ermilov.Tn XDR
273eae561b3SGarrett Wollmanstream object pointed to by
2741abae7eeSRuslan Ermilov.Fa xdrs .
275eae561b3SGarrett WollmanThe stream's data is written to, or read from,
276eae561b3SGarrett Wollmana chunk of memory at location
2771abae7eeSRuslan Ermilov.Fa addr
278eae561b3SGarrett Wollmanwhose length is no more than
2791abae7eeSRuslan Ermilov.Fa size
2801abae7eeSRuslan Ermilovbytes long.
2811abae7eeSRuslan ErmilovThe
2821abae7eeSRuslan Ermilov.Fa op
283eae561b3SGarrett Wollmandetermines the direction of the
2841abae7eeSRuslan Ermilov.Tn XDR
285eae561b3SGarrett Wollmanstream
286eae561b3SGarrett Wollman(either
2871abae7eeSRuslan Ermilov.Dv XDR_ENCODE ,
2881abae7eeSRuslan Ermilov.Dv XDR_DECODE ,
289eae561b3SGarrett Wollmanor
2901abae7eeSRuslan Ermilov.Dv XDR_FREE ) .
2911abae7eeSRuslan Ermilov.Pp
2921abae7eeSRuslan Ermilov.It Xo
2931abae7eeSRuslan Ermilov.Ft int
2941abae7eeSRuslan Ermilov.Xc
2951abae7eeSRuslan Ermilov.It Xo
2961abae7eeSRuslan Ermilov.Fn xdr_opaque "XDR *xdrs" "char *cp" "u_int cnt"
2971abae7eeSRuslan Ermilov.Xc
2981abae7eeSRuslan Ermilov.Pp
299eae561b3SGarrett WollmanA filter primitive that translates between fixed size opaque
300eae561b3SGarrett Wollmandata
301eae561b3SGarrett Wollmanand its external representation.
302eae561b3SGarrett WollmanThe parameter
3031abae7eeSRuslan Ermilov.Fa cp
304eae561b3SGarrett Wollmanis the address of the opaque object, and
3051abae7eeSRuslan Ermilov.Fa cnt
306eae561b3SGarrett Wollmanis its size in bytes.
307eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
3081abae7eeSRuslan Ermilov.Pp
3091abae7eeSRuslan Ermilov.It Xo
3101abae7eeSRuslan Ermilov.Ft int
3111abae7eeSRuslan Ermilov.Xc
3121abae7eeSRuslan Ermilov.It Xo
3131abae7eeSRuslan Ermilov.Fn xdr_pointer "XDR *xdrs" "char **objpp" "u_int objsize" "xdrproc_t xdrobj"
3141abae7eeSRuslan Ermilov.Xc
3151abae7eeSRuslan Ermilov.Pp
316eae561b3SGarrett WollmanLike
3171abae7eeSRuslan Ermilov.Fn xdr_reference
3181abae7eeSRuslan Ermilovexcept that it serializes
3191abae7eeSRuslan Ermilov.Dv NULL
320eae561b3SGarrett Wollmanpointers, whereas
3211abae7eeSRuslan Ermilov.Fn xdr_reference
3221abae7eeSRuslan Ermilovdoes not.
3231abae7eeSRuslan ErmilovThus,
3241abae7eeSRuslan Ermilov.Fn xdr_pointer
325eae561b3SGarrett Wollmancan represent
326eae561b3SGarrett Wollmanrecursive data structures, such as binary trees or
327eae561b3SGarrett Wollmanlinked lists.
3281abae7eeSRuslan Ermilov.Pp
3291abae7eeSRuslan Ermilov.It Xo
3301abae7eeSRuslan Ermilov.Ft void
3311abae7eeSRuslan Ermilov.Xc
3321abae7eeSRuslan Ermilov.It Xo
3331abae7eeSRuslan Ermilov.Fo xdrrec_create
3341abae7eeSRuslan Ermilov.Fa "XDR *xdrs"
3351abae7eeSRuslan Ermilov.Fa "u_int sendsize"
3361abae7eeSRuslan Ermilov.Fa "u_int recvsize"
3371abae7eeSRuslan Ermilov.Fa "char *handle"
3381abae7eeSRuslan Ermilov.Fa "int \*(lp*readit\*(rp\*(lp\*(rp"
3391abae7eeSRuslan Ermilov.Fa "int \*(lp*writeit\*(rp\*(lp\*(rp"
3401abae7eeSRuslan Ermilov.Fc
3411abae7eeSRuslan Ermilov.Xc
3421abae7eeSRuslan Ermilov.Pp
343eae561b3SGarrett WollmanThis routine initializes the
3441abae7eeSRuslan Ermilov.Tn XDR
345eae561b3SGarrett Wollmanstream object pointed to by
3461abae7eeSRuslan Ermilov.Fa xdrs .
347eae561b3SGarrett WollmanThe stream's data is written to a buffer of size
3481abae7eeSRuslan Ermilov.Fa sendsize ;
349eae561b3SGarrett Wollmana value of zero indicates the system should use a suitable
350c6ff3a1bSSheldon Hearndefault.
351c6ff3a1bSSheldon HearnThe stream's data is read from a buffer of size
3521abae7eeSRuslan Ermilov.Fa recvsize ;
353eae561b3SGarrett Wollmanit too can be set to a suitable default by passing a zero
354eae561b3SGarrett Wollmanvalue.
355eae561b3SGarrett WollmanWhen a stream's output buffer is full,
3561abae7eeSRuslan Ermilov.Fn writeit
3571abae7eeSRuslan Ermilovis called.
3581abae7eeSRuslan ErmilovSimilarly, when a stream's input buffer is empty,
3591abae7eeSRuslan Ermilov.Fn readit
3601abae7eeSRuslan Ermilovis called.
3611abae7eeSRuslan ErmilovThe behavior of these two routines is similar to
362eae561b3SGarrett Wollmanthe
363eae561b3SGarrett Wollmansystem calls
3641abae7eeSRuslan Ermilov.Xr read 2
365eae561b3SGarrett Wollmanand
3661abae7eeSRuslan Ermilov.Xr write 2 ,
367eae561b3SGarrett Wollmanexcept that
3681abae7eeSRuslan Ermilov.Fa handle
369eae561b3SGarrett Wollmanis passed to the former routines as the first parameter.
370eae561b3SGarrett WollmanNote: the
3711abae7eeSRuslan Ermilov.Tn XDR
372eae561b3SGarrett Wollmanstream's
3731abae7eeSRuslan Ermilov.Fa op
374eae561b3SGarrett Wollmanfield must be set by the caller.
3751abae7eeSRuslan Ermilov.Pp
376eae561b3SGarrett WollmanWarning: this
3771abae7eeSRuslan Ermilov.Tn XDR
378eae561b3SGarrett Wollmanstream implements an intermediate record stream.
379eae561b3SGarrett WollmanTherefore there are additional bytes in the stream
380eae561b3SGarrett Wollmanto provide record boundary information.
3811abae7eeSRuslan Ermilov.Pp
3821abae7eeSRuslan Ermilov.It Xo
3831abae7eeSRuslan Ermilov.Ft int
3841abae7eeSRuslan Ermilov.Xc
3851abae7eeSRuslan Ermilov.It Xo
3861abae7eeSRuslan Ermilov.Fn xdrrec_endofrecord "XDR *xdrs" "int sendnow"
3871abae7eeSRuslan Ermilov.Xc
3881abae7eeSRuslan Ermilov.Pp
389eae561b3SGarrett WollmanThis routine can be invoked only on
390eae561b3SGarrett Wollmanstreams created by
3911abae7eeSRuslan Ermilov.Fn xdrrec_create .
392eae561b3SGarrett WollmanThe data in the output buffer is marked as a completed
393eae561b3SGarrett Wollmanrecord,
394eae561b3SGarrett Wollmanand the output buffer is optionally written out if
3951abae7eeSRuslan Ermilov.Fa sendnow
396c6ff3a1bSSheldon Hearnis non-zero.
397c6ff3a1bSSheldon HearnThis routine returns one if it succeeds, zero
398eae561b3SGarrett Wollmanotherwise.
3991abae7eeSRuslan Ermilov.Pp
4001abae7eeSRuslan Ermilov.It Xo
4011abae7eeSRuslan Ermilov.Ft int
4021abae7eeSRuslan Ermilov.Xc
4031abae7eeSRuslan Ermilov.It Xo
4041abae7eeSRuslan Ermilov.Fn xdrrec_eof "XDR *xdrs"
4051abae7eeSRuslan Ermilov.Xc
4061abae7eeSRuslan Ermilov.Pp
407eae561b3SGarrett WollmanThis routine can be invoked only on
408eae561b3SGarrett Wollmanstreams created by
4091abae7eeSRuslan Ermilov.Fn xdrrec_create .
410eae561b3SGarrett WollmanAfter consuming the rest of the current record in the stream,
411eae561b3SGarrett Wollmanthis routine returns one if the stream has no more input,
412eae561b3SGarrett Wollmanzero otherwise.
4131abae7eeSRuslan Ermilov.Pp
4141abae7eeSRuslan Ermilov.It Xo
4151abae7eeSRuslan Ermilov.Ft int
4161abae7eeSRuslan Ermilov.Xc
4171abae7eeSRuslan Ermilov.It Xo
4181abae7eeSRuslan Ermilov.Fn xdrrec_skiprecord "XDR *xdrs"
4191abae7eeSRuslan Ermilov.Xc
4201abae7eeSRuslan Ermilov.Pp
421eae561b3SGarrett WollmanThis routine can be invoked only on
422eae561b3SGarrett Wollmanstreams created by
4231abae7eeSRuslan Ermilov.Fn xdrrec_create .
424eae561b3SGarrett WollmanIt tells the
4251abae7eeSRuslan Ermilov.Tn XDR
426eae561b3SGarrett Wollmanimplementation that the rest of the current record
427eae561b3SGarrett Wollmanin the stream's input buffer should be discarded.
428eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
4291abae7eeSRuslan Ermilov.Pp
4301abae7eeSRuslan Ermilov.It Xo
4311abae7eeSRuslan Ermilov.Ft int
4321abae7eeSRuslan Ermilov.Xc
4331abae7eeSRuslan Ermilov.It Xo
4341abae7eeSRuslan Ermilov.Fn xdr_reference "XDR *xdrs" "char **pp" "u_int size" "xdrproc_t proc"
4351abae7eeSRuslan Ermilov.Xc
4361abae7eeSRuslan Ermilov.Pp
437eae561b3SGarrett WollmanA primitive that provides pointer chasing within structures.
438eae561b3SGarrett WollmanThe parameter
4391abae7eeSRuslan Ermilov.Fa pp
440eae561b3SGarrett Wollmanis the address of the pointer;
4411abae7eeSRuslan Ermilov.Fa size
442eae561b3SGarrett Wollmanis the
4431abae7eeSRuslan Ermilov.Ic sizeof
444eae561b3SGarrett Wollmanthe structure that
4451abae7eeSRuslan Ermilov.Fa *pp
446eae561b3SGarrett Wollmanpoints to; and
4471abae7eeSRuslan Ermilov.Fa proc
448eae561b3SGarrett Wollmanis an
4491abae7eeSRuslan Ermilov.Tn XDR
450eae561b3SGarrett Wollmanprocedure that filters the structure
451eae561b3SGarrett Wollmanbetween its C form and its external representation.
452eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
4531abae7eeSRuslan Ermilov.Pp
454eae561b3SGarrett WollmanWarning: this routine does not understand
4551abae7eeSRuslan Ermilov.Dv NULL
456c6ff3a1bSSheldon Hearnpointers.
457c6ff3a1bSSheldon HearnUse
4581abae7eeSRuslan Ermilov.Fn xdr_pointer
459eae561b3SGarrett Wollmaninstead.
4601abae7eeSRuslan Ermilov.Pp
4611abae7eeSRuslan Ermilov.It Xo
4621abae7eeSRuslan Ermilov.Ft int
4631abae7eeSRuslan Ermilov.Xc
4641abae7eeSRuslan Ermilov.It Xo
4651abae7eeSRuslan Ermilov.Fn xdr_setpos "XDR *xdrs" "u_int pos"
4661abae7eeSRuslan Ermilov.Xc
4671abae7eeSRuslan Ermilov.Pp
468eae561b3SGarrett WollmanA macro that invokes the set position routine associated with
469eae561b3SGarrett Wollmanthe
4701abae7eeSRuslan Ermilov.Tn XDR
471eae561b3SGarrett Wollmanstream
4721abae7eeSRuslan Ermilov.Fa xdrs .
473eae561b3SGarrett WollmanThe parameter
4741abae7eeSRuslan Ermilov.Fa pos
475eae561b3SGarrett Wollmanis a position value obtained from
4761abae7eeSRuslan Ermilov.Fn xdr_getpos .
477eae561b3SGarrett WollmanThis routine returns one if the
4781abae7eeSRuslan Ermilov.Tn XDR
479eae561b3SGarrett Wollmanstream could be repositioned,
480eae561b3SGarrett Wollmanand zero otherwise.
4811abae7eeSRuslan Ermilov.Pp
482eae561b3SGarrett WollmanWarning: it is difficult to reposition some types of
4831abae7eeSRuslan Ermilov.Tn XDR
484eae561b3SGarrett Wollmanstreams, so this routine may fail with one
485eae561b3SGarrett Wollmantype of stream and succeed with another.
4861abae7eeSRuslan Ermilov.Pp
4871abae7eeSRuslan Ermilov.It Xo
4881abae7eeSRuslan Ermilov.Ft int
4891abae7eeSRuslan Ermilov.Xc
4901abae7eeSRuslan Ermilov.It Xo
4911abae7eeSRuslan Ermilov.Fn xdr_short "XDR *xdrs" "short *sp"
4921abae7eeSRuslan Ermilov.Xc
4931abae7eeSRuslan Ermilov.Pp
494eae561b3SGarrett WollmanA filter primitive that translates between C
4951abae7eeSRuslan Ermilov.Vt short
496eae561b3SGarrett Wollmanintegers and their external representations.
497eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
4981abae7eeSRuslan Ermilov.Pp
499c6e2c333SRuslan Ermilov.It Li "#ifdef _STDIO_H_"
500c6e2c333SRuslan Ermilov.It Li "/* XDR using stdio library */"
5011abae7eeSRuslan Ermilov.It Xo
5021abae7eeSRuslan Ermilov.Ft void
5031abae7eeSRuslan Ermilov.Xc
5041abae7eeSRuslan Ermilov.It Xo
5051abae7eeSRuslan Ermilov.Fn xdrstdio_create "XDR *xdrs" "FILE *file" "enum xdr_op op"
5061abae7eeSRuslan Ermilov.Xc
507c6e2c333SRuslan Ermilov.It Li "#endif"
5081abae7eeSRuslan Ermilov.Pp
509eae561b3SGarrett WollmanThis routine initializes the
5101abae7eeSRuslan Ermilov.Tn XDR
511eae561b3SGarrett Wollmanstream object pointed to by
5121abae7eeSRuslan Ermilov.Fa xdrs .
513eae561b3SGarrett WollmanThe
5141abae7eeSRuslan Ermilov.Tn XDR
515eae561b3SGarrett Wollmanstream data is written to, or read from, the Standard
5161abae7eeSRuslan Ermilov.Tn I/O
517eae561b3SGarrett Wollmanstream
5181abae7eeSRuslan Ermilov.Fa file .
519eae561b3SGarrett WollmanThe parameter
5201abae7eeSRuslan Ermilov.Fa op
521eae561b3SGarrett Wollmandetermines the direction of the
5221abae7eeSRuslan Ermilov.Tn XDR
523eae561b3SGarrett Wollmanstream (either
5241abae7eeSRuslan Ermilov.Dv XDR_ENCODE ,
5251abae7eeSRuslan Ermilov.Dv XDR_DECODE ,
526eae561b3SGarrett Wollmanor
5271abae7eeSRuslan Ermilov.Dv XDR_FREE ) .
5281abae7eeSRuslan Ermilov.Pp
529eae561b3SGarrett WollmanWarning: the destroy routine associated with such
5301abae7eeSRuslan Ermilov.Tn XDR
531eae561b3SGarrett Wollmanstreams calls
5321abae7eeSRuslan Ermilov.Xr fflush 3
533eae561b3SGarrett Wollmanon the
5341abae7eeSRuslan Ermilov.Fa file
535eae561b3SGarrett Wollmanstream, but never
5361abae7eeSRuslan Ermilov.Xr fclose 3 .
5371abae7eeSRuslan Ermilov.Pp
5381abae7eeSRuslan Ermilov.It Xo
5391abae7eeSRuslan Ermilov.Ft int
5401abae7eeSRuslan Ermilov.Xc
5411abae7eeSRuslan Ermilov.It Xo
5421abae7eeSRuslan Ermilov.Fn xdr_string "XDR *xdrs" "char **sp" "u_int maxsize"
5431abae7eeSRuslan Ermilov.Xc
5441abae7eeSRuslan Ermilov.Pp
545eae561b3SGarrett WollmanA filter primitive that translates between C strings and
546eae561b3SGarrett Wollmantheir
547eae561b3SGarrett Wollmancorresponding external representations.
548eae561b3SGarrett WollmanStrings cannot be longer than
5491abae7eeSRuslan Ermilov.Fa maxsize .
550eae561b3SGarrett WollmanNote:
5511abae7eeSRuslan Ermilov.Fa sp
552eae561b3SGarrett Wollmanis the address of the string's pointer.
553eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
5541abae7eeSRuslan Ermilov.Pp
5551abae7eeSRuslan Ermilov.It Xo
5561abae7eeSRuslan Ermilov.Ft int
5571abae7eeSRuslan Ermilov.Xc
5581abae7eeSRuslan Ermilov.It Xo
5591abae7eeSRuslan Ermilov.Fn xdr_u_char "XDR *xdrs" "unsigned char *ucp"
5601abae7eeSRuslan Ermilov.Xc
5611abae7eeSRuslan Ermilov.Pp
562eae561b3SGarrett WollmanA filter primitive that translates between
5631abae7eeSRuslan Ermilov.Vt unsigned
564eae561b3SGarrett WollmanC characters and their external representations.
565eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
5661abae7eeSRuslan Ermilov.Pp
5671abae7eeSRuslan Ermilov.It Xo
5681abae7eeSRuslan Ermilov.Ft int
5691abae7eeSRuslan Ermilov.Xc
5701abae7eeSRuslan Ermilov.It Xo
5711abae7eeSRuslan Ermilov.Fn xdr_u_int "XDR *xdrs" "unsigned *up"
5721abae7eeSRuslan Ermilov.Xc
5731abae7eeSRuslan Ermilov.Pp
574eae561b3SGarrett WollmanA filter primitive that translates between C
5751abae7eeSRuslan Ermilov.Vt unsigned
576eae561b3SGarrett Wollmanintegers and their external representations.
577eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
5781abae7eeSRuslan Ermilov.Pp
5791abae7eeSRuslan Ermilov.It Xo
5801abae7eeSRuslan Ermilov.Ft int
5811abae7eeSRuslan Ermilov.Xc
5821abae7eeSRuslan Ermilov.It Xo
5831abae7eeSRuslan Ermilov.Fn xdr_u_long "XDR *xdrs" "unsigned long *ulp"
5841abae7eeSRuslan Ermilov.Xc
5851abae7eeSRuslan Ermilov.Pp
586eae561b3SGarrett WollmanA filter primitive that translates between C
5871abae7eeSRuslan Ermilov.Vt "unsigned long"
588eae561b3SGarrett Wollmanintegers and their external representations.
589eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
5901abae7eeSRuslan Ermilov.Pp
5911abae7eeSRuslan Ermilov.It Xo
5921abae7eeSRuslan Ermilov.Ft int
5931abae7eeSRuslan Ermilov.Xc
5941abae7eeSRuslan Ermilov.It Xo
5951abae7eeSRuslan Ermilov.Fn xdr_u_short "XDR *xdrs" "unsigned short *usp"
5961abae7eeSRuslan Ermilov.Xc
5971abae7eeSRuslan Ermilov.Pp
598eae561b3SGarrett WollmanA filter primitive that translates between C
5991abae7eeSRuslan Ermilov.Vt "unsigned short"
600eae561b3SGarrett Wollmanintegers and their external representations.
601eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
6021abae7eeSRuslan Ermilov.Pp
6031abae7eeSRuslan Ermilov.It Xo
6041abae7eeSRuslan Ermilov.Ft int
6051abae7eeSRuslan Ermilov.Xc
6061abae7eeSRuslan Ermilov.It Xo
6071abae7eeSRuslan Ermilov.Fo xdr_union
6081abae7eeSRuslan Ermilov.Fa "XDR *xdrs"
6091abae7eeSRuslan Ermilov.Fa "int *dscmp"
6101abae7eeSRuslan Ermilov.Fa "char *unp"
6111abae7eeSRuslan Ermilov.Fa "struct xdr_discrim *choices"
6121abae7eeSRuslan Ermilov.Fa "bool_t \*(lp*defaultarm\*(rp\*(lp\*(rp"
6131abae7eeSRuslan Ermilov.Fc
6141abae7eeSRuslan Ermilov.Xc
6151abae7eeSRuslan Ermilov.Pp
616eae561b3SGarrett WollmanA filter primitive that translates between a discriminated C
6171abae7eeSRuslan Ermilov.Vt union
618c6ff3a1bSSheldon Hearnand its corresponding external representation.
619c6ff3a1bSSheldon HearnIt first
620eae561b3SGarrett Wollmantranslates the discriminant of the union located at
6211abae7eeSRuslan Ermilov.Fa dscmp .
622eae561b3SGarrett WollmanThis discriminant is always an
6231abae7eeSRuslan Ermilov.Vt enum_t .
624eae561b3SGarrett WollmanNext the union located at
6251abae7eeSRuslan Ermilov.Fa unp
6261abae7eeSRuslan Ermilovis translated.
6271abae7eeSRuslan ErmilovThe parameter
6281abae7eeSRuslan Ermilov.Fa choices
629eae561b3SGarrett Wollmanis a pointer to an array of
6301abae7eeSRuslan Ermilov.Vt xdr_discrim
631c6ff3a1bSSheldon Hearnstructures.
632c6ff3a1bSSheldon HearnEach structure contains an ordered pair of
6331abae7eeSRuslan Ermilov.Bq Va value , proc .
634eae561b3SGarrett WollmanIf the union's discriminant is equal to the associated
6351abae7eeSRuslan Ermilov.Va value ,
636eae561b3SGarrett Wollmanthen the
6371abae7eeSRuslan Ermilov.Fn proc
6381abae7eeSRuslan Ermilovis called to translate the union.
6391abae7eeSRuslan ErmilovThe end of the
6401abae7eeSRuslan Ermilov.Vt xdr_discrim
641eae561b3SGarrett Wollmanstructure array is denoted by a routine of value
6421abae7eeSRuslan Ermilov.Dv NULL .
643eae561b3SGarrett WollmanIf the discriminant is not found in the
6441abae7eeSRuslan Ermilov.Fa choices
645eae561b3SGarrett Wollmanarray, then the
6461abae7eeSRuslan Ermilov.Fn defaultarm
647eae561b3SGarrett Wollmanprocedure is called (if it is not
6481abae7eeSRuslan Ermilov.Dv NULL ) .
649eae561b3SGarrett WollmanReturns one if it succeeds, zero otherwise.
6501abae7eeSRuslan Ermilov.Pp
6511abae7eeSRuslan Ermilov.It Xo
6521abae7eeSRuslan Ermilov.Ft int
6531abae7eeSRuslan Ermilov.Xc
6541abae7eeSRuslan Ermilov.It Xo
6551abae7eeSRuslan Ermilov.Fo xdr_vector
6561abae7eeSRuslan Ermilov.Fa "XDR *xdrs"
6571abae7eeSRuslan Ermilov.Fa "char *arrp"
6581abae7eeSRuslan Ermilov.Fa "u_int size"
6591abae7eeSRuslan Ermilov.Fa "u_int elsize"
6601abae7eeSRuslan Ermilov.Fa "xdrproc_t elproc"
6611abae7eeSRuslan Ermilov.Fc
6621abae7eeSRuslan Ermilov.Xc
6631abae7eeSRuslan Ermilov.Pp
664eae561b3SGarrett WollmanA filter primitive that translates between fixed-length
665eae561b3SGarrett Wollmanarrays
6661abae7eeSRuslan Ermilovand their corresponding external representations.
6671abae7eeSRuslan ErmilovThe
668eae561b3SGarrett Wollmanparameter
6691abae7eeSRuslan Ermilov.Fa arrp
670eae561b3SGarrett Wollmanis the address of the pointer to the array, while
6711abae7eeSRuslan Ermilov.Fa size
6721abae7eeSRuslan Ermilovis the element count of the array.
6731abae7eeSRuslan ErmilovThe parameter
6741abae7eeSRuslan Ermilov.Fa elsize
675eae561b3SGarrett Wollmanis the
6761abae7eeSRuslan Ermilov.Ic sizeof
677eae561b3SGarrett Wollmaneach of the array's elements, and
6781abae7eeSRuslan Ermilov.Fa elproc
679eae561b3SGarrett Wollmanis an
6801abae7eeSRuslan Ermilov.Tn XDR
681eae561b3SGarrett Wollmanfilter that translates between
682eae561b3SGarrett Wollmanthe array elements' C form, and their external
683eae561b3SGarrett Wollmanrepresentation.
684eae561b3SGarrett WollmanThis routine returns one if it succeeds, zero otherwise.
6851abae7eeSRuslan Ermilov.Pp
6861abae7eeSRuslan Ermilov.It Xo
6871abae7eeSRuslan Ermilov.Ft int
6881abae7eeSRuslan Ermilov.Xc
6891abae7eeSRuslan Ermilov.It Xo
6901abae7eeSRuslan Ermilov.Fn xdr_void void
6911abae7eeSRuslan Ermilov.Xc
6921abae7eeSRuslan Ermilov.Pp
693eae561b3SGarrett WollmanThis routine always returns one.
694eae561b3SGarrett WollmanIt may be passed to
6951abae7eeSRuslan Ermilov.Tn RPC
696eae561b3SGarrett Wollmanroutines that require a function parameter,
697eae561b3SGarrett Wollmanwhere nothing is to be done.
6981abae7eeSRuslan Ermilov.Pp
6991abae7eeSRuslan Ermilov.It Xo
7001abae7eeSRuslan Ermilov.Ft int
7011abae7eeSRuslan Ermilov.Xc
7021abae7eeSRuslan Ermilov.It Xo
7031abae7eeSRuslan Ermilov.Fn xdr_wrapstring "XDR *xdrs" "char **sp"
7041abae7eeSRuslan Ermilov.Xc
7051abae7eeSRuslan Ermilov.Pp
706eae561b3SGarrett WollmanA primitive that calls
7071abae7eeSRuslan Ermilov.Fn xdr_string xdrs sp MAXUN.UNSIGNED ;
708eae561b3SGarrett Wollmanwhere
7091abae7eeSRuslan Ermilov.Dv MAXUN.UNSIGNED
710eae561b3SGarrett Wollmanis the maximum value of an unsigned integer.
7111abae7eeSRuslan Ermilov.Fn xdr_wrapstring
712eae561b3SGarrett Wollmanis handy because the
7131abae7eeSRuslan Ermilov.Tn RPC
714eae561b3SGarrett Wollmanpackage passes a maximum of two
7151abae7eeSRuslan Ermilov.Tn XDR
716eae561b3SGarrett Wollmanroutines as parameters, and
7171abae7eeSRuslan Ermilov.Fn xdr_string ,
718eae561b3SGarrett Wollmanone of the most frequently used primitives, requires three.
719eae561b3SGarrett WollmanReturns one if it succeeds, zero otherwise.
7201abae7eeSRuslan Ermilov.El
7211abae7eeSRuslan Ermilov.Sh SEE ALSO
7221abae7eeSRuslan Ermilov.Xr rpc 3
7231abae7eeSRuslan Ermilov.Rs
7241abae7eeSRuslan Ermilov.%T "eXternal Data Representation Standard: Protocol Specification"
7251abae7eeSRuslan Ermilov.Re
7261abae7eeSRuslan Ermilov.Rs
7271abae7eeSRuslan Ermilov.%T "eXternal Data Representation: Sun Technical Notes"
7281abae7eeSRuslan Ermilov.Re
7291abae7eeSRuslan Ermilov.Rs
7301abae7eeSRuslan Ermilov.%T "XDR: External Data Representation Standard"
7311abae7eeSRuslan Ermilov.%O RFC1014
7321abae7eeSRuslan Ermilov.%Q "Sun Microsystems, Inc., USC\-ISI"
7331abae7eeSRuslan Ermilov.Re
734