1*21381Sdist /* 2*21381Sdist * Copyright (c) 1983 Regents of the University of California. 3*21381Sdist * All rights reserved. The Berkeley software License Agreement 4*21381Sdist * specifies the terms and conditions for redistribution. 5*21381Sdist */ 67902Ssam 7*21381Sdist #ifndef lint 8*21381Sdist static char sccsid[] = "@(#)getservbyname.c 5.1 (Berkeley) 05/30/85"; 9*21381Sdist #endif not lint 10*21381Sdist 117902Ssam #include <netdb.h> 127902Ssam 137902Ssam struct servent * 148324Ssam getservbyname(name, proto) 157902Ssam char *name, *proto; 167902Ssam { 177902Ssam register struct servent *p; 187902Ssam register char **cp; 197902Ssam 207902Ssam setservent(0); 217902Ssam while (p = getservent()) { 227902Ssam if (strcmp(name, p->s_name) == 0) 237902Ssam goto gotname; 247902Ssam for (cp = p->s_aliases; *cp; cp++) 257902Ssam if (strcmp(name, *cp) == 0) 267902Ssam goto gotname; 277902Ssam continue; 287902Ssam gotname: 297902Ssam if (proto == 0 || strcmp(p->s_proto, proto) == 0) 307902Ssam break; 317902Ssam } 327902Ssam endservent(); 337902Ssam return (p); 347902Ssam } 35