2 static char sfs_xdr_mem_id[] = "@(#)xdr_mem.c 2.1 97/10/23";
4 /* @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC */
6 * Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
8 * Standard Performance Evaluation Corporation (SPEC)
9 * 6585 Merchant Place, Suite 100
12 * This product contains benchmarks acquired from several sources who
13 * understand and agree with SPEC's goal of creating fair and objective
14 * benchmarks to measure computer performance.
16 * This copyright notice is placed here only to protect SPEC in the
17 * event the source is misused in any manner that is contrary to the
18 * spirit, the goals and the intent of SPEC.
20 * The source code is provided to the user or company under the license
21 * agreement for the SPEC Benchmark Suite for this product.
24 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
25 * unrestricted use provided that this legend is included on all tape
26 * media and as a part of the software program in whole or part. Users
27 * may copy or modify Sun RPC without charge, but are not authorized
28 * to license or distribute it to anyone else except as part of a product or
29 * program developed by the user.
31 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
32 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
33 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
35 * Sun RPC is provided with no support and without any obligation on the
36 * part of Sun Microsystems, Inc. to assist in its use, correction,
37 * modification or enhancement.
39 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
40 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
41 * OR ANY PART THEREOF.
43 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
44 * or profits or other special, indirect and consequential damages, even if
45 * Sun has been advised of the possibility of such damages.
47 * Sun Microsystems, Inc.
49 * Mountain View, California 94043
51 #if !defined(lint) && defined(SCCSIDS)
52 static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
56 * xdr_mem.h, XDR implementation using memory buffers.
58 * Copyright (C) 1984, Sun Microsystems, Inc.
60 * If you have some data to be interpreted as external data representation
61 * or to be converted to external data representation in a memory buffer,
62 * then this is the package for you.
67 #include "rpc/types.h"
69 #include "rpc/osdep.h"
71 static bool_t xdrmem_getlong(XDR *, int32_t *);
72 static bool_t xdrmem_putlong(XDR *, int32_t *);
73 static bool_t xdrmem_getbytes(XDR *, void *, uint_t);
74 static bool_t xdrmem_putbytes(XDR *, void *, uint_t);
75 static uint_t xdrmem_getpos(XDR *);
76 static bool_t xdrmem_setpos(XDR *, uint_t);
77 static int32_t *xdrmem_inline(XDR *, uint_t);
78 static void xdrmem_destroy(XDR *);
80 static struct xdr_ops xdrmem_ops = {
92 * The procedure xdrmem_create initializes a stream descriptor for a
104 xdrs->x_ops = &xdrmem_ops;
105 xdrs->x_private = xdrs->x_base = addr;
106 xdrs->x_handy = size;
111 xdrmem_destroy(XDR *xdrs)
121 if ((xdrs->x_handy -= sizeof(int32_t)) < 0)
123 *lp = (int32_t)ntohl((uint32_t)(*((int32_t *)(xdrs->x_private))));
124 xdrs->x_private += sizeof(int32_t);
134 if ((xdrs->x_handy -= sizeof(int32_t)) < 0)
136 *(int32_t *)xdrs->x_private = (int32_t)htonl((uint32_t)(*lp));
137 xdrs->x_private += sizeof(int32_t);
148 if ((xdrs->x_handy -= len) < 0)
150 memmove(addr, xdrs->x_private, len);
151 xdrs->x_private += len;
162 if ((xdrs->x_handy -= len) < 0)
164 memmove(xdrs->x_private, addr, len);
165 xdrs->x_private += len;
174 return ((uint_t)xdrs->x_private - (uint_t)xdrs->x_base);
182 char * newaddr = xdrs->x_base + pos;
183 char * lastaddr = xdrs->x_private + xdrs->x_handy;
185 if ((int32_t)newaddr > (int32_t)lastaddr)
187 xdrs->x_private = newaddr;
188 xdrs->x_handy = (int)lastaddr - (int)newaddr;
199 if (xdrs->x_handy >= len) {
200 xdrs->x_handy -= len;
201 buf = (int32_t *) xdrs->x_private;
202 xdrs->x_private += len;