xref: /csrg-svn/lib/libc/net/getnetbyaddr.c (revision 33679)
121375Sdist /*
221375Sdist  * Copyright (c) 1983 Regents of the University of California.
3*33679Sbostic  * All rights reserved.
4*33679Sbostic  *
5*33679Sbostic  * Redistribution and use in source and binary forms are permitted
6*33679Sbostic  * provided that this notice is preserved and that due credit is given
7*33679Sbostic  * to the University of California at Berkeley. The name of the University
8*33679Sbostic  * may not be used to endorse or promote products derived from this
9*33679Sbostic  * software without specific prior written permission. This software
10*33679Sbostic  * is provided ``as is'' without express or implied warranty.
1121375Sdist  */
127895Ssam 
1326616Sdonn #if defined(LIBC_SCCS) && !defined(lint)
14*33679Sbostic static char sccsid[] = "@(#)getnetbyaddr.c	5.5 (Berkeley) 03/07/88";
15*33679Sbostic #endif /* LIBC_SCCS and not lint */
1621375Sdist 
177895Ssam #include <netdb.h>
187895Ssam 
1928280Slepreau extern int _net_stayopen;
2028280Slepreau 
217895Ssam struct netent *
228342Ssam getnetbyaddr(net, type)
2332296Sbostic 	register long net;
2432296Sbostic 	register int type;
257895Ssam {
267895Ssam 	register struct netent *p;
277895Ssam 
2828280Slepreau 	setnetent(_net_stayopen);
297895Ssam 	while (p = getnetent())
308342Ssam 		if (p->n_addrtype == type && p->n_net == net)
317895Ssam 			break;
3228280Slepreau 	if (!_net_stayopen)
3328280Slepreau 		endnetent();
347895Ssam 	return (p);
357895Ssam }
36