121380Sdist /* 221380Sdist * 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. 1121380Sdist */ 127900Ssam 1326621Sdonn #if defined(LIBC_SCCS) && !defined(lint) 14*33679Sbostic static char sccsid[] = "@(#)getprotoname.c 5.4 (Berkeley) 03/07/88"; 15*33679Sbostic #endif /* LIBC_SCCS and not lint */ 1621380Sdist 177900Ssam #include <netdb.h> 187900Ssam 1928280Slepreau extern int _proto_stayopen; 2028280Slepreau 217900Ssam struct protoent * 228324Ssam getprotobyname(name) 237900Ssam register char *name; 247900Ssam { 257900Ssam register struct protoent *p; 267900Ssam register char **cp; 277900Ssam 2828280Slepreau setprotoent(_proto_stayopen); 297900Ssam while (p = getprotoent()) { 307900Ssam if (strcmp(p->p_name, name) == 0) 317900Ssam break; 327900Ssam for (cp = p->p_aliases; *cp != 0; cp++) 337900Ssam if (strcmp(*cp, name) == 0) 347900Ssam goto found; 357900Ssam } 367900Ssam found: 3728280Slepreau if (!_proto_stayopen) 3828280Slepreau endprotoent(); 397900Ssam return (p); 407900Ssam } 41