1d7ce700605e1af0e455e31ec11f19ff21d26b525darylm/* 2d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * Copyright (c) 1983, 1993 3d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * The Regents of the University of California. All rights reserved. 4d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * 5d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * Redistribution and use in source and binary forms, with or without 6d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * modification, are permitted provided that the following conditions 7d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * are met: 8d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * 1. Redistributions of source code must retain the above copyright 9d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * notice, this list of conditions and the following disclaimer. 10d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * 2. Redistributions in binary form must reproduce the above copyright 11d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * notice, this list of conditions and the following disclaimer in the 12d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * documentation and/or other materials provided with the distribution. 13d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * 3. All advertising materials mentioning features or use of this software 14d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * must display the following acknowledgement: 15d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * This product includes software developed by the University of 16d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * California, Berkeley and its contributors. 17d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * 4. Neither the name of the University nor the names of its contributors 18d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * may be used to endorse or promote products derived from this software 19d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * without specific prior written permission. 20d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * 21d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31d7ce700605e1af0e455e31ec11f19ff21d26b525darylm * SUCH DAMAGE. 32d7ce700605e1af0e455e31ec11f19ff21d26b525darylm */ 33d7ce700605e1af0e455e31ec11f19ff21d26b525darylm 34d7ce700605e1af0e455e31ec11f19ff21d26b525darylm#if defined(LIBC_SCCS) && !defined(lint) 35d7ce700605e1af0e455e31ec11f19ff21d26b525darylmstatic char sccsid[] = "@(#)getproto.c 8.1 (Berkeley) 6/4/93"; 36d7ce700605e1af0e455e31ec11f19ff21d26b525darylm#endif /* LIBC_SCCS and not lint */ 37d7ce700605e1af0e455e31ec11f19ff21d26b525darylm 38d7ce700605e1af0e455e31ec11f19ff21d26b525darylm#include <netdb.h> 39d7ce700605e1af0e455e31ec11f19ff21d26b525darylm 40d7ce700605e1af0e455e31ec11f19ff21d26b525darylmextern int _proto_stayopen; 41d7ce700605e1af0e455e31ec11f19ff21d26b525darylm 42d7ce700605e1af0e455e31ec11f19ff21d26b525darylmstruct protoent * 43d7ce700605e1af0e455e31ec11f19ff21d26b525darylmgetprotobynumber(register int proto) 44d7ce700605e1af0e455e31ec11f19ff21d26b525darylm{ 45d7ce700605e1af0e455e31ec11f19ff21d26b525darylm register struct protoent *p; 46d7ce700605e1af0e455e31ec11f19ff21d26b525darylm 47d7ce700605e1af0e455e31ec11f19ff21d26b525darylm setprotoent(_proto_stayopen); 48d7ce700605e1af0e455e31ec11f19ff21d26b525darylm while ( NULL != (p = getprotoent()) ) 49d7ce700605e1af0e455e31ec11f19ff21d26b525darylm if (p->p_proto == proto) 50d7ce700605e1af0e455e31ec11f19ff21d26b525darylm break; 51d7ce700605e1af0e455e31ec11f19ff21d26b525darylm if (!_proto_stayopen) 52d7ce700605e1af0e455e31ec11f19ff21d26b525darylm endprotoent(); 53d7ce700605e1af0e455e31ec11f19ff21d26b525darylm return (p); 54d7ce700605e1af0e455e31ec11f19ff21d26b525darylm} 55