#include <rpc/rpc.h>
static bool_t xdrmem_getlong (XDR *, long *);
-static bool_t xdrmem_putlong (XDR *, long *);
+static bool_t xdrmem_putlong (XDR *, const long *);
static bool_t xdrmem_getbytes (XDR *, caddr_t, u_int);
-static bool_t xdrmem_putbytes (XDR *, caddr_t, u_int);
-static u_int xdrmem_getpos (XDR *);
+static bool_t xdrmem_putbytes (XDR *, const char *, u_int);
+static u_int xdrmem_getpos (const XDR *);
static bool_t xdrmem_setpos (XDR *, u_int);
static long *xdrmem_inline (XDR *, int);
static void xdrmem_destroy (XDR *);
void
xdrmem_create (xdrs, addr, size, op)
XDR *xdrs;
- caddr_t addr;
+ const caddr_t addr;
u_int size;
enum xdr_op op;
{
xdrs->x_op = op;
- xdrs->x_ops = &xdrmem_ops;
+ /* We have to add the const since the `struct xdr_ops' in `struct XDR'
+ is not `const'. */
+ xdrs->x_ops = (struct xdr_ops *) &xdrmem_ops;
xdrs->x_private = xdrs->x_base = addr;
xdrs->x_handy = size;
}
+/*
+ * Nothing needs to be done for the memory case. The argument is clearly
+ * const.
+ */
+
static void
xdrmem_destroy (XDR *xdrs)
{
}
+/*
+ * Gets the next word from the memory referenced by xdrs and places it
+ * in the long pointed to by lp. It then increments the private word to
+ * point at the next element. Neither object pointed to is const
+ */
static bool_t
xdrmem_getlong (xdrs, lp)
XDR *xdrs;
return TRUE;
}
+/*
+ * Puts the long pointed to by lp in the memory referenced by xdrs. It
+ * then increments the private word to point at the next element. The
+ * long pointed at is const
+ */
static bool_t
xdrmem_putlong (xdrs, lp)
XDR *xdrs;
- long *lp;
+ const long *lp;
{
if ((xdrs->x_handy -= 4) < 0)
return TRUE;
}
+/*
+ * Gets an unaligned number of bytes from the xdrs structure and writes them
+ * to the address passed in addr. Be very careful when calling this routine
+ * as it could leave the xdrs pointing to an unaligned structure which is not
+ * a good idea. None of the things pointed to are const.
+ */
static bool_t
xdrmem_getbytes (xdrs, addr, len)
XDR *xdrs;
return TRUE;
}
+/*
+ * The complementary function to the above. The same warnings apply about
+ * unaligned data. The source address is const.
+ */
static bool_t
xdrmem_putbytes (xdrs, addr, len)
XDR *xdrs;
- caddr_t addr;
+ const char *addr;
u_int len;
{
return TRUE;
}
+/*
+ * Not sure what this one does. But it clearly doesn't modify the contents
+ * of xdrs. **FIXME** does this not assume u_int == u_long?
+ */
static u_int
xdrmem_getpos (xdrs)
- XDR *xdrs;
+ const XDR *xdrs;
{
return (u_long) xdrs->x_private - (u_long) xdrs->x_base;
}
+/*
+ * xdrs modified
+ */
static bool_t
xdrmem_setpos (xdrs, pos)
XDR *xdrs;
return TRUE;
}
+/*
+ * xdrs modified
+ */
static long *
xdrmem_inline (xdrs, len)
XDR *xdrs;