121381Sdist /* 221381Sdist * Copyright (c) 1983 Regents of the University of California. 333679Sbostic * All rights reserved. 433679Sbostic * 5*42626Sbostic * %sccs.include.redist.c% 621381Sdist */ 77902Ssam 826622Sdonn #if defined(LIBC_SCCS) && !defined(lint) 9*42626Sbostic static char sccsid[] = "@(#)getservbyname.c 5.6 (Berkeley) 06/01/90"; 1033679Sbostic #endif /* LIBC_SCCS and not lint */ 1121381Sdist 127902Ssam #include <netdb.h> 137902Ssam 1428280Slepreau extern int _serv_stayopen; 1528280Slepreau 167902Ssam struct servent * 178324Ssam getservbyname(name, proto) 187902Ssam char *name, *proto; 197902Ssam { 207902Ssam register struct servent *p; 217902Ssam register char **cp; 227902Ssam 2328280Slepreau setservent(_serv_stayopen); 247902Ssam while (p = getservent()) { 257902Ssam if (strcmp(name, p->s_name) == 0) 267902Ssam goto gotname; 277902Ssam for (cp = p->s_aliases; *cp; cp++) 287902Ssam if (strcmp(name, *cp) == 0) 297902Ssam goto gotname; 307902Ssam continue; 317902Ssam gotname: 327902Ssam if (proto == 0 || strcmp(p->s_proto, proto) == 0) 337902Ssam break; 347902Ssam } 3528280Slepreau if (!_serv_stayopen) 3628280Slepreau endservent(); 377902Ssam return (p); 387902Ssam } 39