xref: /csrg-svn/lib/libc/net/getnetbyaddr.c (revision 42625)
121375Sdist /*
221375Sdist  * Copyright (c) 1983 Regents of the University of California.
333679Sbostic  * All rights reserved.
433679Sbostic  *
5*42625Sbostic  * %sccs.include.redist.c%
621375Sdist  */
77895Ssam 
826616Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*42625Sbostic static char sccsid[] = "@(#)getnetbyaddr.c	5.7 (Berkeley) 06/01/90";
1033679Sbostic #endif /* LIBC_SCCS and not lint */
1121375Sdist 
127895Ssam #include <netdb.h>
137895Ssam 
1428280Slepreau extern int _net_stayopen;
1528280Slepreau 
167895Ssam struct netent *
178342Ssam getnetbyaddr(net, type)
1832296Sbostic 	register long net;
1932296Sbostic 	register int type;
207895Ssam {
217895Ssam 	register struct netent *p;
227895Ssam 
2328280Slepreau 	setnetent(_net_stayopen);
247895Ssam 	while (p = getnetent())
258342Ssam 		if (p->n_addrtype == type && p->n_net == net)
267895Ssam 			break;
2728280Slepreau 	if (!_net_stayopen)
2828280Slepreau 		endnetent();
297895Ssam 	return (p);
307895Ssam }
31