#if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
#endif
#include <gssrpc/types.h>
#include <gssrpc/xdr.h>
#include "dyn.h"
static bool_t xdralloc_putlong(XDR *, long *);
static bool_t xdralloc_putbytes(XDR *, caddr_t, unsigned int);
static unsigned int xdralloc_getpos(XDR *);
static rpc_inline_t * xdralloc_inline(XDR *, int);
static void xdralloc_destroy(XDR *);
static bool_t xdralloc_notsup_getlong(XDR *, long *);
static bool_t xdralloc_notsup_getbytes(XDR *, caddr_t, unsigned int);
static bool_t xdralloc_notsup_setpos(XDR *, unsigned int);
static struct xdr_ops xdralloc_ops = {
xdralloc_notsup_getlong,
xdralloc_putlong,
xdralloc_notsup_getbytes,
xdralloc_putbytes,
xdralloc_getpos,
xdralloc_notsup_setpos,
xdralloc_inline,
xdralloc_destroy,
};
void xdralloc_create(XDR *xdrs, enum xdr_op op)
{
xdrs->x_op = op;
xdrs->x_ops = &xdralloc_ops;
xdrs->x_private = (caddr_t) DynCreate(sizeof(char), -4);
}
caddr_t xdralloc_getdata(XDR *xdrs)
{
return (caddr_t) DynGet((DynObject) xdrs->x_private, 0);
}
void xdralloc_release(XDR *xdrs)
{
DynRelease((DynObject) xdrs->x_private);
}
static void xdralloc_destroy(XDR *xdrs)
{
DynDestroy((DynObject) xdrs->x_private);
}
static bool_t xdralloc_notsup_getlong(
register XDR *xdrs,
long *lp)
{
return FALSE;
}
static bool_t xdralloc_putlong(
register XDR *xdrs,
long *lp)
{
int l = htonl((uint32_t) *lp);
if (DynInsert((DynObject) xdrs->x_private,
DynSize((DynObject) xdrs->x_private), &l,
sizeof(int)) != DYN_OK)
return FALSE;
return (TRUE);
}
static bool_t xdralloc_notsup_getbytes(
register XDR *xdrs,
caddr_t addr,
register unsigned int len)
{
return FALSE;
}
static bool_t xdralloc_putbytes(
register XDR *xdrs,
caddr_t addr,
register unsigned int len)
{
if (DynInsert((DynObject) xdrs->x_private,
DynSize((DynObject) xdrs->x_private),
addr, (int) len) != DYN_OK)
return FALSE;
return TRUE;
}
static unsigned int xdralloc_getpos(XDR *xdrs)
{
return DynSize((DynObject) xdrs->x_private);
}
static bool_t xdralloc_notsup_setpos(
register XDR *xdrs,
unsigned int lp)
{
return FALSE;
}
static rpc_inline_t *xdralloc_inline(
register XDR *xdrs,
int len)
{
return (rpc_inline_t *) 0;
}