xref: /csrg-svn/lib/libc/net/getnetbyname.c (revision 46604)
121376Sdist /*
221376Sdist  * Copyright (c) 1983 Regents of the University of California.
333679Sbostic  * All rights reserved.
433679Sbostic  *
542625Sbostic  * %sccs.include.redist.c%
621376Sdist  */
77897Ssam 
826617Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*46604Sbostic static char sccsid[] = "@(#)getnetbyname.c	5.7 (Berkeley) 02/24/91";
1033679Sbostic #endif /* LIBC_SCCS and not lint */
1121376Sdist 
127897Ssam #include <netdb.h>
13*46604Sbostic #include <string.h>
147897Ssam 
1528280Slepreau extern int _net_stayopen;
1628280Slepreau 
177897Ssam struct netent *
188324Ssam getnetbyname(name)
19*46604Sbostic 	register const char *name;
207897Ssam {
217897Ssam 	register struct netent *p;
227897Ssam 	register char **cp;
237897Ssam 
2428280Slepreau 	setnetent(_net_stayopen);
257897Ssam 	while (p = getnetent()) {
267897Ssam 		if (strcmp(p->n_name, name) == 0)
277897Ssam 			break;
287897Ssam 		for (cp = p->n_aliases; *cp != 0; cp++)
297897Ssam 			if (strcmp(*cp, name) == 0)
307897Ssam 				goto found;
317897Ssam 	}
327897Ssam found:
3328280Slepreau 	if (!_net_stayopen)
3428280Slepreau 		endnetent();
357897Ssam 	return (p);
367897Ssam }
37