xref: /csrg-svn/lib/libc/net/getproto.c (revision 33679)
121378Sdist /*
221378Sdist  * 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.
1121378Sdist  */
127898Ssam 
1326619Sdonn #if defined(LIBC_SCCS) && !defined(lint)
14*33679Sbostic static char sccsid[] = "@(#)getproto.c	5.4 (Berkeley) 03/07/88";
15*33679Sbostic #endif /* LIBC_SCCS and not lint */
1621378Sdist 
177898Ssam #include <netdb.h>
187898Ssam 
1928280Slepreau extern int _proto_stayopen;
2028280Slepreau 
217898Ssam struct protoent *
228324Ssam getprotobynumber(proto)
237898Ssam 	register int proto;
247898Ssam {
257898Ssam 	register struct protoent *p;
267898Ssam 
2728280Slepreau 	setprotoent(_proto_stayopen);
287898Ssam 	while (p = getprotoent())
297898Ssam 		if (p->p_proto == proto)
307898Ssam 			break;
3128280Slepreau 	if (!_proto_stayopen)
3228280Slepreau 		endprotoent();
337898Ssam 	return (p);
347898Ssam }
35