xref: /csrg-svn/lib/libc/net/getnetbyaddr.c (revision 32296)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #if defined(LIBC_SCCS) && !defined(lint)
8 static char sccsid[] = "@(#)getnetbyaddr.c	5.4 (Berkeley) 09/30/87";
9 #endif LIBC_SCCS and not lint
10 
11 #include <netdb.h>
12 
13 extern int _net_stayopen;
14 
15 struct netent *
16 getnetbyaddr(net, type)
17 	register long net;
18 	register int type;
19 {
20 	register struct netent *p;
21 
22 	setnetent(_net_stayopen);
23 	while (p = getnetent())
24 		if (p->n_addrtype == type && p->n_net == net)
25 			break;
26 	if (!_net_stayopen)
27 		endnetent();
28 	return (p);
29 }
30