update from Donn -- fixes for pcc
[unix-history] / usr / src / lib / libc / net / getnetbyname.c
CommitLineData
8ea4199d
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
6b2f9dd0
KB
3 * All rights reserved.
4 *
269a7923 5 * %sccs.include.redist.c%
8ea4199d
DF
6 */
7
2ce81398 8#if defined(LIBC_SCCS) && !defined(lint)
24fac7d8 9static char sccsid[] = "@(#)getnetbyname.c 5.7 (Berkeley) %G%";
6b2f9dd0 10#endif /* LIBC_SCCS and not lint */
d32c3507
SL
11
12#include <netdb.h>
24fac7d8 13#include <string.h>
d32c3507 14
5442f2c7
JL
15extern int _net_stayopen;
16
d32c3507 17struct netent *
5e649950 18getnetbyname(name)
24fac7d8 19 register const char *name;
d32c3507
SL
20{
21 register struct netent *p;
22 register char **cp;
23
5442f2c7 24 setnetent(_net_stayopen);
d32c3507
SL
25 while (p = getnetent()) {
26 if (strcmp(p->n_name, name) == 0)
27 break;
28 for (cp = p->n_aliases; *cp != 0; cp++)
29 if (strcmp(*cp, name) == 0)
30 goto found;
31 }
32found:
5442f2c7
JL
33 if (!_net_stayopen)
34 endnetent();
d32c3507
SL
35 return (p);
36}