2 static char sfs_clnt_id[] = "@(#)pmap_prot2.c 2.1 97/10/23";
4 /* @(#)pmap_prot2.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[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
57 * Protocol for the local binder service, or pmap.
59 * Copyright (C) 1984, Sun Microsystems, Inc.
62 #include "rpc/types.h"
64 #include "rpc/pmap_prot.h"
68 * What is going on with linked lists? (!)
69 * First recall the link list declaration from pmap_prot.h:
72 * struct pmap pml_map;
73 * struct pmaplist *pml_map;
76 * Compare that declaration with a corresponding xdr declaration that
77 * is (a) pointer-less, and (b) recursive:
79 * typedef union switch (bool_t) {
86 * case FALSE: struct {};
89 * Notice that the xdr declaration has no nxt pointer while
90 * the C declaration has no bool_t variable. The bool_t can be
91 * interpreted as ``more data follows me''; if FALSE then nothing
92 * follows this bool_t; if TRUE then the bool_t is followed by
93 * an actual struct pmap, and then (recursively) by the
94 * xdr union, pamplist_t.
96 * This could be implemented via the xdr_union primitive, though this
97 * would cause a one recursive call per element in the list. Rather than do
98 * that we can ``unwind'' the recursion
99 * into a while loop and do the union arms in-place.
101 * The head of the list is what the C programmer wishes to past around
102 * the net, yet is the data that the pointer points to which is interesting;
103 * this sounds like a job for xdr_reference!
108 struct pmaplist **rp)
111 * more_elements is pre-computed in case the direction is
112 * XDR_ENCODE or XDR_FREE. more_elements is overwritten by
113 * xdr_bool when the direction is XDR_DECODE.
115 bool_t more_elements;
116 register int freeing = (xdrs->x_op == XDR_FREE);
117 register struct pmaplist **next;
121 more_elements = (bool_t)(*rp != NULL);
122 if (! xdr_bool(xdrs, &more_elements))
125 return (TRUE); /* we are done */
127 * the unfortunate side effect of non-recursion is that in
128 * the case of freeing we must remember the next object
129 * before we free the current object ...
132 next = &((*rp)->pml_next);
133 if (! xdr_reference(xdrs, (void **)rp,
134 (uint_t)sizeof(struct pmaplist), xdr_pmap))
136 rp = (freeing) ? next : &((*rp)->pml_next);