xref: /csrg-svn/lib/libc/net/getproto.c (revision 61150)
121378Sdist /*
2*61150Sbostic  * Copyright (c) 1983, 1993
3*61150Sbostic  *	The Regents of the University of California.  All rights reserved.
433679Sbostic  *
542626Sbostic  * %sccs.include.redist.c%
621378Sdist  */
77898Ssam 
826619Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*61150Sbostic static char sccsid[] = "@(#)getproto.c	8.1 (Berkeley) 06/04/93";
1033679Sbostic #endif /* LIBC_SCCS and not lint */
1121378Sdist 
127898Ssam #include <netdb.h>
137898Ssam 
1428280Slepreau extern int _proto_stayopen;
1528280Slepreau 
167898Ssam struct protoent *
getprotobynumber(proto)178324Ssam getprotobynumber(proto)
187898Ssam 	register int proto;
197898Ssam {
207898Ssam 	register struct protoent *p;
217898Ssam 
2228280Slepreau 	setprotoent(_proto_stayopen);
237898Ssam 	while (p = getprotoent())
247898Ssam 		if (p->p_proto == proto)
257898Ssam 			break;
2628280Slepreau 	if (!_proto_stayopen)
2728280Slepreau 		endprotoent();
287898Ssam 	return (p);
297898Ssam }
30