xref: /csrg-svn/lib/libc/net/getnetbyaddr.c (revision 32296)
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*32296Sbostic static char sccsid[] = "@(#)getnetbyaddr.c	5.4 (Berkeley) 09/30/87";
926616Sdonn #endif LIBC_SCCS and not lint
1021375Sdist 
117895Ssam #include <netdb.h>
127895Ssam 
1328280Slepreau extern int _net_stayopen;
1428280Slepreau 
157895Ssam struct netent *
168342Ssam getnetbyaddr(net, type)
17*32296Sbostic 	register long net;
18*32296Sbostic 	register int type;
197895Ssam {
207895Ssam 	register struct netent *p;
217895Ssam 
2228280Slepreau 	setnetent(_net_stayopen);
237895Ssam 	while (p = getnetent())
248342Ssam 		if (p->n_addrtype == type && p->n_net == net)
257895Ssam 			break;
2628280Slepreau 	if (!_net_stayopen)
2728280Slepreau 		endnetent();
287895Ssam 	return (p);
297895Ssam }
30