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 7*26622Sdonn #if defined(LIBC_SCCS) && !defined(lint) 8*26622Sdonn static char sccsid[] = "@(#)getservbyname.c 5.2 (Berkeley) 03/09/86"; 9*26622Sdonn #endif LIBC_SCCS and not lint 1021381Sdist 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