xref: /csrg-svn/lib/libc/net/getnetbyname.c (revision 61150)
121376Sdist /*
2*61150Sbostic  * Copyright (c) 1983, 1993
3*61150Sbostic  *	The Regents of the University of California.  All rights reserved.
433679Sbostic  *
542625Sbostic  * %sccs.include.redist.c%
621376Sdist  */
77897Ssam 
826617Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*61150Sbostic static char sccsid[] = "@(#)getnetbyname.c	8.1 (Berkeley) 06/04/93";
1033679Sbostic #endif /* LIBC_SCCS and not lint */
1121376Sdist 
127897Ssam #include <netdb.h>
1346604Sbostic #include <string.h>
147897Ssam 
1528280Slepreau extern int _net_stayopen;
1628280Slepreau 
177897Ssam struct netent *
getnetbyname(name)188324Ssam getnetbyname(name)
1946604Sbostic 	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