Implementing an XDR Data Stream

You can create and implement XDR data streams. The following example shows the abstract data types (XDR handle) required for you to implement your own XDR streams. They contain operations applied to the stream (an operation vector for the particular implementation) and two private fields for using that implementation.

enum xdr_op  { XDR_ENCODE=0, XDR_DECODE=1, XDR_FREE=2 };
typedef struct xdr {
        enum xdr_op  x_op;
        struct xdr_ops {
               bool_t  (*x_getlong)(struct xdr *, long *);
               bool_t  (*x_putlong)(struct xdr *, long *);
               bool_t  (*x_getbytes)(struct xdr *, caddr_t, u_int);
        /* get some bytes from " */
               bool_t  (*x_putbytes)(struct xdr *, caddr_t, u_int);
        /* put some bytes to " */
               u_int   (*x_getpostn)(struct xdr *);
               bool_t  (*x_setpostn)(struct xdr *,u_int);
               long *  (*x_inline)(struct xdr *,u_int);
               void    (*x_destroy)(struct xdr *);
        } *x_ops;
        caddr_t         x_public;
        caddr_t         x_private;
        caddr_t         x_base;
        int             x_handy;
} XDR;

The following parameters are pointers to XDR stream manipulation routines:

Parameter

x _ getlong x _ putlong x _ getbytes x _ putbytes x _ getpostn x _ setpostn x _ inline x _ destroy x _ ops

The following fields are specific to a stream's implementation:

Field

x _ public x _ private x _ base x _ handy


[Back: Manipulating an XDR Data Stream]
[Next: Destroying an XDR Data Stream]