121381Sdist /* 221381Sdist * Copyright (c) 1983 Regents of the University of California. 321381Sdist * All rights reserved. The Berkeley software License Agreement 421381Sdist * specifies the terms and conditions for redistribution. 521381Sdist */ 67902Ssam 726622Sdonn #if defined(LIBC_SCCS) && !defined(lint) 8*28280Slepreau static char sccsid[] = "@(#)getservbyname.c 5.3 (Berkeley) 05/19/86"; 926622Sdonn #endif LIBC_SCCS and not lint 1021381Sdist 117902Ssam #include <netdb.h> 127902Ssam 13*28280Slepreau extern int _serv_stayopen; 14*28280Slepreau 157902Ssam struct servent * 168324Ssam getservbyname(name, proto) 177902Ssam char *name, *proto; 187902Ssam { 197902Ssam register struct servent *p; 207902Ssam register char **cp; 217902Ssam 22*28280Slepreau setservent(_serv_stayopen); 237902Ssam while (p = getservent()) { 247902Ssam if (strcmp(name, p->s_name) == 0) 257902Ssam goto gotname; 267902Ssam for (cp = p->s_aliases; *cp; cp++) 277902Ssam if (strcmp(name, *cp) == 0) 287902Ssam goto gotname; 297902Ssam continue; 307902Ssam gotname: 317902Ssam if (proto == 0 || strcmp(p->s_proto, proto) == 0) 327902Ssam break; 337902Ssam } 34*28280Slepreau if (!_serv_stayopen) 35*28280Slepreau endservent(); 367902Ssam return (p); 377902Ssam } 38