1 /*********************************************************************
2 * RPC for the Windows NT Operating System
3 * 1993 by Martin F. Gergeleit
4 * Users may use, copy or modify Sun RPC for the Windows NT Operating
5 * System according to the Sun copyright below.
7 * RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
8 * WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
9 * USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
10 *********************************************************************/
12 /* @(#)getrpcent.c 2.2 88/07/29 4.0 RPCSRC */
13 #if !defined(lint) && defined(SCCSIDS)
14 static char sccsid[] = "@(#)getrpcent.c 1.9 87/08/11 Copyr 1984 Sun Micro";
18 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
19 * unrestricted use provided that this legend is included on all tape
20 * media and as a part of the software program in whole or part. Users
21 * may copy or modify Sun RPC without charge, but are not authorized
22 * to license or distribute it to anyone else except as part of a product or
23 * program developed by the user.
25 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
26 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
29 * Sun RPC is provided with no support and without any obligation on the
30 * part of Sun Microsystems, Inc. to assist in its use, correction,
31 * modification or enhancement.
33 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
34 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
35 * OR ANY PART THEREOF.
37 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
38 * or profits or other special, indirect and consequential damages, even if
39 * Sun has been advised of the possibility of such damages.
41 * Sun Microsystems, Inc.
43 * Mountain View, California 94043
47 * Copyright (c) 1985 by Sun Microsystems, Inc.
51 #include <sys/types.h>
55 #include <sys/socket.h>
67 char *rpc_aliases[MAXALIASES];
71 } *rpcdata, *_rpcdata();
73 static struct rpcent *interpret();
74 struct hostent *gethostent();
76 #define index(str,ch) strchr(str,ch)
83 static char RPCDB[1024];
85 static char RPCDB[] = "/etc/rpc";
88 static struct rpcdata *
91 register struct rpcdata *d = rpcdata;
96 if ((RPCDB[0] == '\0') && (str = getenv("SystemRoot"))) {
98 strcat(RPCDB, "\\system32\\drivers\\etc\\rpc");
103 d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata));
110 getrpcbynumber(number)
113 register struct rpcdata *d = _rpcdata();
114 register struct rpcent *p;
116 char adrstr[16], *val = NULL;
122 while (p = getrpcent()) {
123 if (p->r_number == number)
138 while(rpc = getrpcent()) {
139 if (strcmp(rpc->r_name, name) == 0)
141 for (rp = rpc->r_aliases; *rp != NULL; rp++) {
142 if (strcmp(*rp, name) == 0)
153 register struct rpcdata *d = _rpcdata();
158 d->rpcf = fopen(RPCDB, "r");
169 register struct rpcdata *d = _rpcdata();
173 if (d->current && !d->stayopen) {
177 if (d->rpcf && !d->stayopen) {
188 char *key = NULL, *val = NULL;
190 register struct rpcdata *d = _rpcdata();
194 if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
196 if (fgets(d->line, BUFSIZ, d->rpcf) == NULL)
198 return interpret(d->line, strlen(d->line));
201 static struct rpcent *
205 register struct rpcdata *d = _rpcdata();
207 register char *cp, **q;
211 strncpy(d->line, val, len);
215 return (getrpcent());
221 return (getrpcent());
229 return (getrpcent());
232 /* THIS STUFF IS INTERNET SPECIFIC */
233 d->rpc.r_name = d->line;
234 while (*cp == ' ' || *cp == '\t')
236 d->rpc.r_number = atoi(cp);
237 q = d->rpc.r_aliases = d->rpc_aliases;
248 if (*cp == ' ' || *cp == '\t') {
252 if (q < &(d->rpc_aliases[MAXALIASES - 1]))