xref: /original-bsd/lib/libc/net/getproto.c (revision ee2c7323)
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)getproto.c	8.1 (Berkeley) 06/04/93";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <netdb.h>
13 
14 extern int _proto_stayopen;
15 
16 struct protoent *
getprotobynumber(proto)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