121380Sdist /* 221380Sdist * Copyright (c) 1983 Regents of the University of California. 321380Sdist * All rights reserved. The Berkeley software License Agreement 421380Sdist * specifies the terms and conditions for redistribution. 521380Sdist */ 67900Ssam 726621Sdonn #if defined(LIBC_SCCS) && !defined(lint) 8*28280Slepreau static char sccsid[] = "@(#)getprotoname.c 5.3 (Berkeley) 05/19/86"; 926621Sdonn #endif LIBC_SCCS and not lint 1021380Sdist 117900Ssam #include <netdb.h> 127900Ssam 13*28280Slepreau extern int _proto_stayopen; 14*28280Slepreau 157900Ssam struct protoent * 168324Ssam getprotobyname(name) 177900Ssam register char *name; 187900Ssam { 197900Ssam register struct protoent *p; 207900Ssam register char **cp; 217900Ssam 22*28280Slepreau setprotoent(_proto_stayopen); 237900Ssam while (p = getprotoent()) { 247900Ssam if (strcmp(p->p_name, name) == 0) 257900Ssam break; 267900Ssam for (cp = p->p_aliases; *cp != 0; cp++) 277900Ssam if (strcmp(*cp, name) == 0) 287900Ssam goto found; 297900Ssam } 307900Ssam found: 31*28280Slepreau if (!_proto_stayopen) 32*28280Slepreau endprotoent(); 337900Ssam return (p); 347900Ssam } 35