2 static char sfs_getrpcent_id[] = "@(#)getrpcent.c 2.1 97/10/23";
4 /* @(#)getrpcent.c 2.2 88/07/29 4.0 RPCSRC */
5 #if !defined(lint) && defined(SCCSIDS)
6 static char sccsid[] = "@(#)getrpcent.c 1.9 87/08/11 Copyr 1984 Sun Micro";
9 * Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
10 * All rights reserved.
11 * Standard Performance Evaluation Corporation (SPEC)
12 * 6585 Merchant Place, Suite 100
15 * This product contains benchmarks acquired from several sources who
16 * understand and agree with SPEC's goal of creating fair and objective
17 * benchmarks to measure computer performance.
19 * This copyright notice is placed here only to protect SPEC in the
20 * event the source is misused in any manner that is contrary to the
21 * spirit, the goals and the intent of SPEC.
23 * The source code is provided to the user or company under the license
24 * agreement for the SPEC Benchmark Suite for this product.
28 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
29 * unrestricted use provided that this legend is included on all tape
30 * media and as a part of the software program in whole or part. Users
31 * may copy or modify Sun RPC without charge, but are not authorized
32 * to license or distribute it to anyone else except as part of a product or
33 * program developed by the user.
35 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
36 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
37 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
39 * Sun RPC is provided with no support and without any obligation on the
40 * part of Sun Microsystems, Inc. to assist in its use, correction,
41 * modification or enhancement.
43 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
44 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
45 * OR ANY PART THEREOF.
47 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
48 * or profits or other special, indirect and consequential damages, even if
49 * Sun has been advised of the possibility of such damages.
51 * Sun Microsystems, Inc.
53 * Mountain View, California 94043
57 * Copyright (c) 1985 by Sun Microsystems, Inc.
63 #include <sys/types.h>
65 #include "rpc/netdb.h"
66 #include "rpc/osdep.h"
77 char *rpc_aliases[MAXALIASES];
83 extern void setrpcent(int);
84 extern void endrpcent(void);
85 static struct rpcent *interpret(char *, int);
87 static char RPCDB[] = "/etc/rpc";
89 static struct rpcdata *
92 register struct rpcdata *d = rpcdata;
95 d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata));
105 register struct rpcdata *d = _rpcdata();
106 register struct rpcent *p;
111 while ((p = getrpcent()) != NULL) {
112 if (p->r_number == number)
127 while((rpc = getrpcent()) != NULL) {
128 if (strcmp(rpc->r_name, name) == 0)
130 for (rp = rpc->r_aliases; *rp != NULL; rp++) {
131 if (strcmp(*rp, name) == 0)
143 register struct rpcdata *d = _rpcdata();
148 d->rpcf = fopen(RPCDB, "r");
160 register struct rpcdata *d = _rpcdata();
164 if (d->current && !d->stayopen) {
168 if (d->rpcf && !d->stayopen) {
177 register struct rpcdata *d = _rpcdata();
181 if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
183 if (fgets(d->line, BUFSIZ, d->rpcf) == NULL)
185 return (interpret(d->line, strlen(d->line)));
188 static struct rpcent *
193 register struct rpcdata *d = _rpcdata();
195 register char *cp, **q;
199 strncpy(d->line, val, len);
203 return (getrpcent());
206 cp = strchr(p, '\n');
208 return (getrpcent());
213 cp = strchr(p, '\t');
215 return (getrpcent());
218 /* THIS STUFF IS INTERNET SPECIFIC */
219 d->rpc.r_name = d->line;
220 while (*cp == ' ' || *cp == '\t')
222 d->rpc.r_number = atoi(cp);
223 q = d->rpc.r_aliases = d->rpc_aliases;
228 cp = strchr(p, '\t');
233 if (*cp == ' ' || *cp == '\t') {
237 if (q < &(d->rpc_aliases[MAXALIASES - 1]))
243 cp = strchr(p, '\t');