URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [librpc/] [src/] [xdr/] [xdr.3] - Rev 1771
Go to most recent revision | Compare with Previous | Blame | View Log
.\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI.\" $FreeBSD: src/lib/libc/xdr/xdr.3,v 1.8 2000/03/02 09:14:05 sheldonh Exp $.\".TH XDR 3 "16 February 1988".SH NAMExdr \- library routines for external data representation.SH SYNOPSIS AND DESCRIPTION.LPThese routines allow C programmers to describearbitrary data structures in a machine-independent fashion.Data for remote procedure calls are transmitted using theseroutines..LP.ft B.nf.sp .5xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc)\s-1XDR\s0 *xdrs;char **arrp;u_int *sizep, maxsize, elsize;xdrproc_t elproc;.fi.ft R.IPA filter primitive that translates between variable-lengtharraysand their corresponding external representations.Theparameter.I arrpis the address of the pointer to the array, while.I sizepis the address of the element count of the array;this element count cannot exceed.IR maxsize .The parameter.I elsizeis the.I sizeofeach of the array's elements, and.I elprocis an.SM XDRfilter that translates betweenthe array elements' C form, and their externalrepresentation.This routine returns one if it succeeds, zero otherwise..br.if t .ne 8.LP.ft B.nf.sp .5xdr_bool(xdrs, bp)\s-1XDR\s0 *xdrs;bool_t *bp;.fi.ft R.IPA filter primitive that translates between booleans (Cintegers)and their external representations.When encoding data, thisfilter produces values of either one or zero.This routine returns one if it succeeds, zero otherwise..br.if t .ne 10.LP.ft B.nf.sp .5xdr_bytes(xdrs, sp, sizep, maxsize)\s-1XDR\s0 *xdrs;char **sp;u_int *sizep, maxsize;.fi.ft R.IPA filter primitive that translates between counted bytestrings and their external representations.The parameter.I spis the address of the string pointer.The length of thestring is located at address.IR sizep ;strings cannot be longer than.IR maxsize .This routine returns one if it succeeds, zero otherwise..br.if t .ne 7.LP.ft B.nf.sp .5xdr_char(xdrs, cp)\s-1XDR\s0 *xdrs;char *cp;.fi.ft R.IPA filter primitive that translates between C charactersand their external representations.This routine returns one if it succeeds, zero otherwise.Note: encoded characters are not packed, and occupy 4 byteseach.For arrays of characters, it is worthwhile toconsider.BR xdr_bytes(\|) ,.B xdr_opaque(\|)or.BR xdr_string(\|) ..br.if t .ne 8.LP.ft B.nf.sp .5voidxdr_destroy(xdrs)\s-1XDR\s0 *xdrs;.fi.ft R.IPA macro that invokes the destroy routine associated with the.SM XDRstream,.IR xdrs .Destruction usually involves freeing private data structuresassociated with the stream. Using.I xdrsafter invoking.B xdr_destroy(\|)is undefined..br.if t .ne 7.LP.ft B.nf.sp .5xdr_double(xdrs, dp)\s-1XDR\s0 *xdrs;double *dp;.fi.ft R.IPA filter primitive that translates between C.B doubleprecision numbers and their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 7.LP.ft B.nf.sp .5xdr_enum(xdrs, ep)\s-1XDR\s0 *xdrs;enum_t *ep;.fi.ft R.IPA filter primitive that translates between C.BR enum s(actually integers) and their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 8.LP.ft B.nf.sp .5xdr_float(xdrs, fp)\s-1XDR\s0 *xdrs;float *fp;.fi.ft R.IPA filter primitive that translates between C.BR float sand their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 9.LP.ft B.nf.sp .5voidxdr_free(proc, objp)xdrproc_t proc;char *objp;.fi.ft R.IPGeneric freeing routine.The first argument is the.SM XDRroutine for the object being freed.The second argumentis a pointer to the object itself.Note: the pointer passedto this routine is.I notfreed, but what it points to.I isfreed (recursively)..br.if t .ne 8.LP.ft B.nf.sp .5u_intxdr_getpos(xdrs)\s-1XDR\s0 *xdrs;.fi.ft R.IPA macro that invokes the get-position routineassociated with the.SM XDRstream,.IR xdrs .The routine returns an unsigned integer,which indicates the position of the.SM XDRbyte stream.A desirable feature of.SM XDRstreams is that simple arithmetic works with this number,although the.SM XDRstream instances need not guarantee this..br.if t .ne 4.LP.ft B.nf.sp .5.brlong *xdr_inline(xdrs, len)\s-1XDR\s0 *xdrs;int len;.fi.ft R.IPA macro that invokes the in-line routine associated with the.SM XDRstream,.IR xdrs .The routine returns a pointerto a contiguous piece of the stream's buffer;.I lenis the byte length of the desired buffer.Note: pointer is cast to.BR "long *" ..IPWarning:.B xdr_inline(\|)may return.SM NULL(0)if it cannot allocate a contiguous piece of a buffer.Therefore the behavior may vary among stream instances;it exists for the sake of efficiency..br.if t .ne 7.LP.ft B.nf.sp .5xdr_int(xdrs, ip)\s-1XDR\s0 *xdrs;int *ip;.fi.ft R.IPA filter primitive that translates between C integersand their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 7.LP.ft B.nf.sp .5xdr_long(xdrs, lp)\s-1XDR\s0 *xdrs;long *lp;.fi.ft R.IPA filter primitive that translates between C.B longintegers and their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 12.LP.ft B.nf.sp .5voidxdrmem_create(xdrs, addr, size, op)\s-1XDR\s0 *xdrs;char *addr;u_int size;enum xdr_op op;.fi.ft R.IPThis routine initializes the.SM XDRstream object pointed to by.IR xdrs .The stream's data is written to, or read from,a chunk of memory at location.I addrwhose length is no more than.I sizebytes long. The.I opdetermines the direction of the.SM XDRstream(either.BR \s-1XDR_ENCODE\s0 ,.BR \s-1XDR_DECODE\s0 ,or.BR \s-1XDR_FREE\s0 )..br.if t .ne 10.LP.ft B.nf.sp .5xdr_opaque(xdrs, cp, cnt)\s-1XDR\s0 *xdrs;char *cp;u_int cnt;.fi.ft R.IPA filter primitive that translates between fixed size opaquedataand its external representation.The parameter.I cpis the address of the opaque object, and.I cntis its size in bytes.This routine returns one if it succeeds, zero otherwise..br.if t .ne 10.LP.ft B.nf.sp .5xdr_pointer(xdrs, objpp, objsize, xdrobj)\s-1XDR\s0 *xdrs;char **objpp;u_int objsize;xdrproc_t xdrobj;.fi.ft R.IPLike.B xdr_reference(\|)execpt that it serializes.SM NULLpointers, whereas.B xdr_reference(\|)does not. Thus,.B xdr_pointer(\|)can representrecursive data structures, such as binary trees orlinked lists..br.if t .ne 15.LP.ft B.nf.sp .5voidxdrrec_create(xdrs, sendsize, recvsize, handle, readit, writeit)\s-1XDR\s0 *xdrs;u_int sendsize, recvsize;char *handle;int (*readit) (\|), (*writeit) (\|);.fi.ft R.IPThis routine initializes the.SM XDRstream object pointed to by.IR xdrs .The stream's data is written to a buffer of size.IR sendsize ;a value of zero indicates the system should use a suitabledefault.The stream's data is read from a buffer of size.IR recvsize ;it too can be set to a suitable default by passing a zerovalue.When a stream's output buffer is full,.I writeitis called. Similarly, when a stream's input buffer is empty,.I readitis called. The behavior of these two routines is similar tothesystem calls.B readand.BR write ,except that.I handleis passed to the former routines as the first parameter.Note: the.SM XDRstream's.I opfield must be set by the caller..IPWarning: this.SM XDRstream implements an intermediate record stream.Therefore there are additional bytes in the streamto provide record boundary information..br.if t .ne 9.LP.ft B.nf.sp .5xdrrec_endofrecord(xdrs, sendnow)\s-1XDR\s0 *xdrs;int sendnow;.fi.ft R.IPThis routine can be invoked only onstreams created by.BR xdrrec_create(\|) .The data in the output buffer is marked as a completedrecord,and the output buffer is optionally written out if.I sendnowis non-zero.This routine returns one if it succeeds, zerootherwise..br.if t .ne 8.LP.ft B.nf.sp .5xdrrec_eof(xdrs)\s-1XDR\s0 *xdrs;int empty;.fi.ft R.IPThis routine can be invoked only onstreams created by.BR xdrrec_create(\|) .After consuming the rest of the current record in the stream,this routine returns one if the stream has no more input,zero otherwise..br.if t .ne 3.LP.ft B.nf.sp .5xdrrec_skiprecord(xdrs)\s-1XDR\s0 *xdrs;.fi.ft R.IPThis routine can be invoked only onstreams created by.BR xdrrec_create(\|) .It tells the.SM XDRimplementation that the rest of the current recordin the stream's input buffer should be discarded.This routine returns one if it succeeds, zero otherwise..br.if t .ne 11.LP.ft B.nf.sp .5xdr_reference(xdrs, pp, size, proc)\s-1XDR\s0 *xdrs;char **pp;u_int size;xdrproc_t proc;.fi.ft R.IPA primitive that provides pointer chasing within structures.The parameter.I ppis the address of the pointer;.I sizeis the.I sizeofthe structure that.I *pppoints to; and.I procis an.SM XDRprocedure that filters the structurebetween its C form and its external representation.This routine returns one if it succeeds, zero otherwise..IPWarning: this routine does not understand.SM NULLpointers.Use.B xdr_pointer(\|)instead..br.if t .ne 10.LP.ft B.nf.sp .5xdr_setpos(xdrs, pos)\s-1XDR\s0 *xdrs;u_int pos;.fi.ft R.IPA macro that invokes the set position routine associated withthe.SM XDRstream.IR xdrs .The parameter.I posis a position value obtained from.BR xdr_getpos(\|) .This routine returns one if the.SM XDRstream could be repositioned,and zero otherwise..IPWarning: it is difficult to reposition some types of.SM XDRstreams, so this routine may fail with onetype of stream and succeed with another..br.if t .ne 8.LP.ft B.nf.sp .5xdr_short(xdrs, sp)\s-1XDR\s0 *xdrs;short *sp;.fi.ft R.IPA filter primitive that translates between C.B shortintegers and their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 10.LP.ft B.nf.sp .5voidxdrstdio_create(xdrs, file, op)\s-1XDR\s0 *xdrs;\s-1FILE\s0 *file;enum xdr_op op;.fi.ft R.IPThis routine initializes the.SM XDRstream object pointed to by.IR xdrs .The.SM XDRstream data is written to, or read from, the Standard.B I/Ostream.IR file .The parameter.I opdetermines the direction of the.SM XDRstream (either.BR \s-1XDR_ENCODE\s0 ,.BR \s-1XDR_DECODE\s0 ,or.BR \s-1XDR_FREE\s0 )..IPWarning: the destroy routine associated with such.SM XDRstreams calls.B fflush(\|)on the.I filestream, but never.BR fclose(\|) ..br.if t .ne 9.LP.ft B.nf.sp .5xdr_string(xdrs, sp, maxsize)\s-1XDR\s0*xdrs;char **sp;u_int maxsize;.fi.ft R.IPA filter primitive that translates between C strings andtheircorresponding external representations.Strings cannot be longer than.IR maxsize .Note:.I spis the address of the string's pointer.This routine returns one if it succeeds, zero otherwise..br.if t .ne 8.LP.ft B.nf.sp .5xdr_u_char(xdrs, ucp)\s-1XDR\s0 *xdrs;unsigned char *ucp;.fi.ft R.IPA filter primitive that translates between.B unsignedC characters and their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 9.LP.ft B.nf.sp .5xdr_u_int(xdrs, up)\s-1XDR\s0 *xdrs;unsigned *up;.fi.ft R.IPA filter primitive that translates between C.B unsignedintegers and their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 7.LP.ft B.nf.sp .5xdr_u_long(xdrs, ulp)\s-1XDR\s0 *xdrs;unsigned long *ulp;.fi.ft R.IPA filter primitive that translates between C.B "unsigned long"integers and their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 7.LP.ft B.nf.sp .5xdr_u_short(xdrs, usp)\s-1XDR\s0 *xdrs;unsigned short *usp;.fi.ft R.IPA filter primitive that translates between C.B "unsigned short"integers and their external representations.This routine returns one if it succeeds, zero otherwise..br.if t .ne 16.LP.ft B.nf.sp .5xdr_union(xdrs, dscmp, unp, choices, dfault)\s-1XDR\s0 *xdrs;int *dscmp;char *unp;struct xdr_discrim *choices;bool_t (*defaultarm) (\|); /* may equal \s-1NULL\s0 */.fi.ft R.IPA filter primitive that translates between a discriminated C.B unionand its corresponding external representation.It firsttranslates the discriminant of the union located at.IR dscmp .This discriminant is always an.BR enum_t .Next the union located at.I unpis translated. The parameter.I choicesis a pointer to an array of.B xdr_discrim(\|)structures.Each structure contains an ordered pair of.RI [ value , proc ].If the union's discriminant is equal to the associated.IR value ,then the.I procis called to translate the union. The end of the.B xdr_discrim(\|)structure array is denoted by a routine of value.SM NULL\s0.If the discriminant is not found in the.I choicesarray, then the.I defaultarmprocedure is called (if it is not.SM NULL\s0).Returns one if it succeeds, zero otherwise..br.if t .ne 6.LP.ft B.nf.sp .5xdr_vector(xdrs, arrp, size, elsize, elproc)\s-1XDR\s0 *xdrs;char *arrp;u_int size, elsize;xdrproc_t elproc;.fi.ft R.IPA filter primitive that translates between fixed-lengtharraysand their corresponding external representations. Theparameter.I arrpis the address of the pointer to the array, while.I sizeis the element count of the array. The parameter.I elsizeis the.I sizeofeach of the array's elements, and.I elprocis an.SM XDRfilter that translates betweenthe array elements' C form, and their externalrepresentation.This routine returns one if it succeeds, zero otherwise..br.if t .ne 5.LP.ft B.nf.sp .5xdr_void(\|).fi.ft R.IPThis routine always returns one.It may be passed to.SM RPCroutines that require a function parameter,where nothing is to be done..br.if t .ne 10.LP.ft B.nf.sp .5xdr_wrapstring(xdrs, sp)\s-1XDR\s0 *xdrs;char **sp;.fi.ft R.IPA primitive that calls.B "xdr_string(xdrs, sp,\s-1MAXUN.UNSIGNED\s0 );"where.B.SM MAXUN.UNSIGNEDis the maximum value of an unsigned integer..B xdr_wrapstring(\|)is handy because the.SM RPCpackage passes a maximum of two.SM XDRroutines as parameters, and.BR xdr_string(\|) ,one of the most frequently used primitives, requires three.Returns one if it succeeds, zero otherwise..SH SEE ALSO.BR rpc (3).LPThe following manuals:.RS.ft IeXternal Data Representation Standard: Protocol Specification.breXternal Data Representation: Sun Technical Notes.ft R.br.IR "\s-1XDR\s0: External Data Representation Standard" ,.SM RFC1014, Sun Microsystems, Inc.,.SM USC-ISI\s0.
Go to most recent revision | Compare with Previous | Blame | View Log
