1 /* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 06/04/93"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <netdb.h> 13 #include <string.h> 14 15 extern int _proto_stayopen; 16 17 struct protoent * 18 getprotobyname(name) 19 register const char *name; 20 { 21 register struct protoent *p; 22 register char **cp; 23 24 setprotoent(_proto_stayopen); 25 while (p = getprotoent()) { 26 if (strcmp(p->p_name, name) == 0) 27 break; 28 for (cp = p->p_aliases; *cp != 0; cp++) 29 if (strcmp(*cp, name) == 0) 30 goto found; 31 } 32 found: 33 if (!_proto_stayopen) 34 endprotoent(); 35 return (p); 36 } 37