xref: /csrg-svn/lib/libc/net/getnetbyname.c (revision 26617)
121376Sdist /*
221376Sdist  * Copyright (c) 1983 Regents of the University of California.
321376Sdist  * All rights reserved.  The Berkeley software License Agreement
421376Sdist  * specifies the terms and conditions for redistribution.
521376Sdist  */
67897Ssam 
7*26617Sdonn #if defined(LIBC_SCCS) && !defined(lint)
8*26617Sdonn static char sccsid[] = "@(#)getnetbyname.c	5.2 (Berkeley) 03/09/86";
9*26617Sdonn #endif LIBC_SCCS and not lint
1021376Sdist 
117897Ssam #include <netdb.h>
127897Ssam 
137897Ssam struct netent *
148324Ssam getnetbyname(name)
157897Ssam 	register char *name;
167897Ssam {
177897Ssam 	register struct netent *p;
187897Ssam 	register char **cp;
197897Ssam 
207897Ssam 	setnetent(0);
217897Ssam 	while (p = getnetent()) {
227897Ssam 		if (strcmp(p->n_name, name) == 0)
237897Ssam 			break;
247897Ssam 		for (cp = p->n_aliases; *cp != 0; cp++)
257897Ssam 			if (strcmp(*cp, name) == 0)
267897Ssam 				goto found;
277897Ssam 	}
287897Ssam found:
297897Ssam 	endnetent();
307897Ssam 	return (p);
317897Ssam }
32