2 static char sfs_xdr_reference_id[] = "@(#)xdr_reference.c 2.1 97/10/23";
4 /* @(#)xdr_reference.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_reference.c 1.11 87/08/11 SMI";
56 * xdr_reference.c, Generic XDR routines impelmentation.
58 * Copyright (C) 1987, Sun Microsystems, Inc.
60 * These are the "non-trivial" xdr primitives used to serialize and de-serialize
61 * "pointers". See xdr.h for more info on the interface to xdr.
68 #include "rpc/types.h"
71 #define LASTUNSIGNED ((uint_t)0-1)
74 * XDR an indirect pointer
75 * xdr_reference is for recursively translating a structure that is
76 * referenced by a pointer inside the structure that is currently being
77 * translated. pp references a pointer to storage. If *pp is null
78 * the necessary storage is allocated.
79 * size is the sizeof the referneced structure.
80 * proc is the routine to handle the referenced structure.
85 void **pp, /* the pointer to work on */
86 uint_t size, /* size of the object pointed to */
87 xdrproc_t proc) /* xdr routine to handle the object */
98 *pp = loc = (void *) mem_alloc(size);
100 (void) fprintf(stderr,
101 "xdr_reference: out of memory\n");
104 memset(loc, '\0', (int)size);
108 stat = (*proc)(xdrs, loc, LASTUNSIGNED);
110 if (xdrs->x_op == XDR_FREE) {
121 * XDR a pointer to a possibly recursive data structure. This
122 * differs with xdr_reference in that it can serialize/deserialiaze
125 * What's sent is actually a union:
127 * union object_pointer switch (boolean b) {
128 * case TRUE: object_data data;
129 * case FALSE: void nothing;
132 * > objpp: Pointer to the pointer to the object.
133 * > obj_size: size of the object.
134 * > xdr_obj: routine to XDR an object.
147 more_data = (*objpp != NULL);
148 if (! xdr_bool(xdrs,&more_data)) {
155 return (xdr_reference(xdrs,objpp,obj_size,xdr_obj));