121376Sdist /* 221376Sdist * Copyright (c) 1983 Regents of the University of California. 3*33679Sbostic * All rights reserved. 4*33679Sbostic * 5*33679Sbostic * Redistribution and use in source and binary forms are permitted 6*33679Sbostic * provided that this notice is preserved and that due credit is given 7*33679Sbostic * to the University of California at Berkeley. The name of the University 8*33679Sbostic * may not be used to endorse or promote products derived from this 9*33679Sbostic * software without specific prior written permission. This software 10*33679Sbostic * is provided ``as is'' without express or implied warranty. 1121376Sdist */ 127897Ssam 1326617Sdonn #if defined(LIBC_SCCS) && !defined(lint) 14*33679Sbostic static char sccsid[] = "@(#)getnetbyname.c 5.4 (Berkeley) 03/07/88"; 15*33679Sbostic #endif /* LIBC_SCCS and not lint */ 1621376Sdist 177897Ssam #include <netdb.h> 187897Ssam 1928280Slepreau extern int _net_stayopen; 2028280Slepreau 217897Ssam struct netent * 228324Ssam getnetbyname(name) 237897Ssam register char *name; 247897Ssam { 257897Ssam register struct netent *p; 267897Ssam register char **cp; 277897Ssam 2828280Slepreau setnetent(_net_stayopen); 297897Ssam while (p = getnetent()) { 307897Ssam if (strcmp(p->n_name, name) == 0) 317897Ssam break; 327897Ssam for (cp = p->n_aliases; *cp != 0; cp++) 337897Ssam if (strcmp(*cp, name) == 0) 347897Ssam goto found; 357897Ssam } 367897Ssam found: 3728280Slepreau if (!_net_stayopen) 3828280Slepreau endnetent(); 397897Ssam return (p); 407897Ssam } 41