xref: /csrg-svn/lib/libc/net/getnetbyaddr.c (revision 28280)
121375Sdist /*
221375Sdist  * Copyright (c) 1983 Regents of the University of California.
321375Sdist  * All rights reserved.  The Berkeley software License Agreement
421375Sdist  * specifies the terms and conditions for redistribution.
521375Sdist  */
67895Ssam 
726616Sdonn #if defined(LIBC_SCCS) && !defined(lint)
8*28280Slepreau static char sccsid[] = "@(#)getnetbyaddr.c	5.3 (Berkeley) 05/19/86";
926616Sdonn #endif LIBC_SCCS and not lint
1021375Sdist 
117895Ssam #include <netdb.h>
127895Ssam 
13*28280Slepreau extern int _net_stayopen;
14*28280Slepreau 
157895Ssam struct netent *
168342Ssam getnetbyaddr(net, type)
178342Ssam 	register int net, type;
187895Ssam {
197895Ssam 	register struct netent *p;
207895Ssam 
21*28280Slepreau 	setnetent(_net_stayopen);
227895Ssam 	while (p = getnetent())
238342Ssam 		if (p->n_addrtype == type && p->n_net == net)
247895Ssam 			break;
25*28280Slepreau 	if (!_net_stayopen)
26*28280Slepreau 		endnetent();
277895Ssam 	return (p);
287895Ssam }
29