Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ xdr_short(3N) — DG/UX 4.30

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

rpc(3N)



     xdr(3N)                    DG/UX 4.30                     xdr(3N)



     NAME
          xdr_array, xdr_bool, xdr_bytes, xdr_char, xdr_destroy,
          xdr_double, xdr_int, xdr_long, xdrmem_create, xdr_opaque,
          xdr_pointer, xdrrec_create, xdrrec_endofrecord, xdrrec_eof,
          xdrrec_skiprecord, xdr_reference, xdr_setpos, xdr_short,
          xdrstdio_create, xdr_string, xdr_u_char, xdr_u_int,
          xdr_u_long, xdr_u_short, xdr_union, xdr_vector, xdr_void,
          xdr_wrapstring - library routines for external data
          representation

     SYNOPSIS AND DESCRIPTION
          The XDR library has filter routines for strings (null-
          terminated arrays of bytes), structures, unions, arrays, and
          the basic C language data types. These routines, allow C
          programmers to describe arbitrary data structures in a
          machine-independent fashion.

          XDR routines a are direction-independent; that is the same
          routines are called to serialize data to, or deserialize
          data from, an XDR stream. XDR streams are created by the use
          of the xdr*_create() functions, and then the pointer to
          these streams are passed to many of the other XDR functions.

          Data for remote procedure calls are transmitted using these
          routines.

          #include <rpc/rpc.h>



          xdrarray(xdrs, arrp, sizep, maxsize, elsize, elproc)
          XDR *xdrs;
          char **arrp;
          uint *sizep, maxsize, elsize;
          xdrproct elproc;

               A filter primitive that translates between variable-
               length arrays and their corresponding external
               representations. The parameter arrp is the address of
               the pointer to the array, while sizep is the address of
               the element count of the array; this element count
               cannot exceed maxsize.  The parameter elsize is the
               sizeof each of the array's elements, and elproc is an
               XDR filter that translates between the array elements'
               C form, and their external representation.  This
               routine returns one if it succeeds, zero otherwise.

          xdrbool(xdrs, bp)
          XDR *xdrs;
          boolt *bp;

               A filter primitive that translates between booleans (C



     Licensed material--property of copyright holder(s)         Page 1





     xdr(3N)                    DG/UX 4.30                     xdr(3N)



               integers) and their external representations. When
               encoding data, this filter produces values of either
               one or zero.  This routine returns one if it succeeds,
               zero otherwise.

          xdrbytes(xdrs, sp, sizep, maxsize)
          XDR *xdrs;
          char **sp;
          uint *sizep, maxsize;

               A filter primitive that translates between counted byte
               strings and their external representations.  The
               parameter sp is the address of the string pointer. The
               length of the string is located at address sizep;
               strings cannot be longer than maxsize.  This routine
               returns one if it succeeds, zero otherwise.

          xdrchar(xdrs, cp)
          XDR *xdrs;
          char *cp;

               A filter primitive that translates between C characters
               and their external representations.  This routine
               returns one if it succeeds, zero otherwise.  Note:
               encoded characters are not packed, and occupy 4 bytes
               each. For arrays of characters, it is worthwhile to
               consider xdrbytes(), xdropaque() or xdrstring().

          void
          xdrdestroy(xdrs)
          XDR *xdrs;

               A macro that invokes the destroy routine associated
               with the XDR stream, xdrs.  Destruction usually
               involves freeing private data structures associated
               with the stream.  Using xdrs after invoking
               xdrdestroy() is undefined.

          xdrdouble(xdrs, dp)
          XDR *xdrs;
          double *dp;

               A filter primitive that translates between C double
               precision numbers and their external representations.
               This routine returns one if it succeeds, zero
               otherwise.

          xdrenum(xdrs, ep)
          XDR *xdrs;
          enumt *ep;

               A filter primitive that translates between C enums



     Licensed material--property of copyright holder(s)         Page 2





     xdr(3N)                    DG/UX 4.30                     xdr(3N)



               (actually integers) and their external representations.
               This routine returns one if it succeeds, zero
               otherwise.

          xdrfloat(xdrs, fp)
          XDR *xdrs;
          float *fp;

               A filter primitive that translates between C floats and
               their external representations.  This routine returns
               one if it succeeds, zero otherwise.

          void
          xdrfree(proc, objp)
          xdrproct proc;
          char *objp;

               Generic freeing routine. The first argument is the XDR
               routine for the object being freed. The second argument
               is a pointer to the object itself. Note: the pointer
               passed to this routine is not freed, but what it points
               to is freed (recursively).

          uint
          xdrgetpos(xdrs)
          XDR *xdrs;

               A macro that invokes the get-position routine
               associated with the XDR stream, xdrs.  The routine
               returns an unsigned integer, which indicates the
               position of the XDR byte stream.  A desirable feature
               of XDR streams is that simple arithmetic works with
               this number, although the XDR stream instances need not
               guarantee this.

          long *
          xdrinline(xdrs, len)
          XDR *xdrs;
          int len;

               A macro that invokes the in-line routine associated
               with the XDR stream, xdrs.  The routine returns a
               pointer to a contiguous piece of the stream's buffer;
               len is the byte length of the desired buffer.  Note:
               pointer is cast to long *.

               Warning:  xdrinline() may return 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.

          xdrint(xdrs, ip)



     Licensed material--property of copyright holder(s)         Page 3





     xdr(3N)                    DG/UX 4.30                     xdr(3N)



          XDR *xdrs;
          int *ip;

               A filter primitive that translates between C integers
               and their external representations.  This routine
               returns one if it succeeds, zero otherwise.

          xdrlong(xdrs, lp)
          XDR *xdrs;
          long *lp;

               A filter primitive that translates between C long
               integers and their external representations.  This
               routine returns one if it succeeds, zero otherwise.

          void
          xdrmemcreate(xdrs, addr, size, op)
          XDR *xdrs;
          char *addr;
          uint size;
          enum xdrop op;

               This routine initializes the XDR stream object pointed
               to by xdrs.  The stream's data is written to, or read
               from, a chunk of memory at location addr whose length
               is no more than size bytes long.  The op determines the
               direction of the XDR stream (either XDRENCODE,
               XDRDECODE, or XDRFREE).

          xdropaque(xdrs, cp, cnt)
          XDR *xdrs;
          char *cp;
          uint cnt;

               A filter primitive that translates between fixed size
               opaque data and its external representation.  The
               parameter cp is the address of the opaque object, and
               cnt is its size in bytes.  This routine returns one if
               it succeeds, zero otherwise.

          xdrpointer(xdrs, objpp, objsize, xdrobj)
          XDR *xdrs;
          char **objpp;
          uint objsize;
          xdrproct xdrobj;

               Like xdrreference() except that it serializes NULL
               pointers, whereas xdrreference() does not.  Thus,
               xdrpointer() can represent recursive data structures,
               such as binary trees or linked lists.

          void



     Licensed material--property of copyright holder(s)         Page 4





     xdr(3N)                    DG/UX 4.30                     xdr(3N)



          xdrreccreate(xdrs, sendsize, recvsize, handle, readit, writeit)
          XDR *xdrs;
          uint sendsize, recvsize;
          char *handle;
          int (*readit) (), (*writeit) ();

               This routine initializes the XDR stream object pointed
               to by xdrs.  The stream's data is written to a buffer
               of size sendsize; a value of zero indicates the system
               should use a suitable default. The stream's data is
               read from a buffer of size recvsize; it too can be set
               to a suitable default by passing a zero value.  When a
               stream's output buffer is full, writeit is called.
               Similarly, when a stream's input buffer is empty,
               readit is called.  The behavior of these two routines
               is similar to the system calls read and write, except
               that handle is passed to the former routines as the
               first parameter.  Note: the XDR stream's op field must
               be set by the caller.

               Warning: this XDR stream implements an intermediate
               record stream.  Therefore there are additional bytes in
               the stream to provide record boundary information.

          xdrrecendofrecord(xdrs, sendnow)
          XDR *xdrs;
          int sendnow;

               This routine can be invoked only on streams created by
               xdrreccreate().  The data in the output buffer is
               marked as a completed record, and the output buffer is
               optionally written out if sendnow is non-zero. This
               routine returns one if it succeeds, zero otherwise.

          xdrreceof(xdrs)
          XDR *xdrs;
          int empty;

               This routine can be invoked only on streams created by
               xdrreccreate().  After consuming the rest of the
               current record in the stream, this routine returns one
               if the stream has no more input, zero otherwise.

          xdrrecskiprecord(xdrs)
          XDR *xdrs;

               This routine can be invoked only on streams created by
               xdrreccreate().  It tells the XDR implementation that
               the rest of the current record in the stream's input
               buffer should be discarded.  This routine returns one
               if it succeeds, zero otherwise.




     Licensed material--property of copyright holder(s)         Page 5





     xdr(3N)                    DG/UX 4.30                     xdr(3N)



          xdrreference(xdrs, pp, size, proc)
          XDR *xdrs;
          char **pp;
          uint size;
          xdrproct proc;

               A primitive that provides pointer chasing within
               structures.  The parameter pp is the address of the
               pointer; size is the sizeof the structure that *pp
               points to; and proc is an XDR procedure that filters
               the structure between its C form and its external
               representation.  This routine returns one if it
               succeeds, zero otherwise.

               Warning: this routine does not understand NULL
               pointers. Use xdrpointer() instead.

          xdrsetpos(xdrs, pos)
          XDR *xdrs;
          uint pos;

               A macro that invokes the set position routine
               associated with the XDR stream xdrs.  The parameter pos
               is a position value obtained from xdrgetpos().  This
               routine returns one if the XDR stream could be
               repositioned, and zero otherwise.

               Warning: it is difficult to reposition some types of
               XDR streams, so this routine may fail with one type of
               stream and succeed with another.

          xdrshort(xdrs, sp)
          XDR *xdrs;
          short *sp;

               A filter primitive that translates between C short
               integers and their external representations.  This
               routine returns one if it succeeds, zero otherwise.

          void
          xdrstdiocreate(xdrs, file, op)
          XDR *xdrs;
          FILE *file;
          enum xdrop op;

               This routine initializes the XDR stream object pointed
               to by xdrs.  The XDR stream data is written to, or read
               from, the Standard I/O stream file.  The parameter op
               determines the direction of the XDR stream (either
               XDRENCODE, XDRDECODE, or XDRFREE).

               Warning: the destroy routine associated with such XDR



     Licensed material--property of copyright holder(s)         Page 6





     xdr(3N)                    DG/UX 4.30                     xdr(3N)



               streams calls fflush() on the file stream, but never
               fclose().

          xdrstring(xdrs, sp, maxsize)
          XDR
          *xdrs;
          char **sp;
          uint maxsize;

               A filter primitive that translates between C strings
               and their corresponding external representations.
               Strings cannot be longer than maxsize.  Note: sp is the
               address of the string's pointer.  This routine returns
               one if it succeeds, zero otherwise.

          xdruchar(xdrs, ucp)
          XDR *xdrs;
          unsigned char *ucp;

               A filter primitive that translates between unsigned C
               characters and their external representations.  This
               routine returns one if it succeeds, zero otherwise.

          xdruint(xdrs, up)
          XDR *xdrs;
          unsigned *up;

               A filter primitive that translates between C unsigned
               integers and their external representations.  This
               routine returns one if it succeeds, zero otherwise.

          xdrulong(xdrs, ulp)
          XDR *xdrs;
          unsigned long *ulp;

               A filter primitive that translates between C unsigned
               long integers and their external representations.  This
               routine returns one if it succeeds, zero otherwise.

          xdrushort(xdrs, usp)
          XDR *xdrs;
          unsigned short *usp;

               A filter primitive that translates between C unsigned
               short integers and their external representations.
               This routine returns one if it succeeds, zero
               otherwise.

          xdrunion(xdrs, dscmp, unp, choices, dfault)
          XDR *xdrs;
          int *dscmp;
          char *unp;



     Licensed material--property of copyright holder(s)         Page 7





     xdr(3N)                    DG/UX 4.30                     xdr(3N)



          struct xdrdiscrim *choices;
          boolt (*defaultarm) ();  /* may equal NULL */

               A filter primitive that translates between a
               discriminated C union and its corresponding external
               representation. It first translates the discriminant of
               the union located at dscmp.  This discriminant is
               always an enumt.  Next the union located at unp is
               translated.  The parameter choices is a pointer to an
               array of xdrdiscrim() structures. Each structure
               contains an ordered pair of [value,proc].  If the
               union's discriminant is equal to the associated value,
               then the proc is called to translate the union.  The
               end of the xdrdiscrim() structure array is denoted by
               a routine of value NULL.  If the discriminant is not
               found in the choices array, then the defaultarm
               procedure is called (if it is not NULL).  Returns one
               if it succeeds, zero otherwise.

          xdrvector(xdrs, arrp, size, elsize, elproc)
          XDR *xdrs;
          char *arrp;
          uint size, elsize;
          xdrproct elproc;

               A filter primitive that translates between fixed-length
               arrays and their corresponding external
               representations.  The parameter arrp is the address of
               the pointer to the array, while size is is the element
               count of the array.  The parameter elsize is the sizeof
               each of the array's elements, and elproc is an XDR
               filter that translates between the array elements' C
               form, and their external representation.  This routine
               returns one if it succeeds, zero otherwise.

          xdrvoid()

               This routine always returns one.  It may be passed to
               RPC routines that require a function parameter, where
               nothing is to be done.

          xdrwrapstring(xdrs, sp)
          XDR *xdrs;
          char **sp;

               A primitive that calls xdrstring(xdrs, sp,
               MAX.UNSIGNED");" where MAX.UNSIGNED is the maximum
               value of an unsigned integer.  xdrwrapstring() is
               handy because the RPC package passes a maximum of two
               XDR routines as parameters, and xdrstring(), one of
               the most frequently used primitives, requires three.
               Returns one if it succeeds, zero otherwise.



     Licensed material--property of copyright holder(s)         Page 8





     xdr(3N)                    DG/UX 4.30                     xdr(3N)



     SEE ALSO
          rpc(3N).





















































     Licensed material--property of copyright holder(s)         Page 9



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026