xref: /original-bsd/lib/libc/net/getproto.c (revision 237fdba6)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)getproto.c	5.6 (Berkeley) 06/01/90";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <netdb.h>
13 
14 extern int _proto_stayopen;
15 
16 struct protoent *
17 getprotobynumber(proto)
18 	register int proto;
19 {
20 	register struct protoent *p;
21 
22 	setprotoent(_proto_stayopen);
23 	while (p = getprotoent())
24 		if (p->p_proto == proto)
25 			break;
26 	if (!_proto_stayopen)
27 		endprotoent();
28 	return (p);
29 }
30