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