1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)getnetbyname.c 5.7 (Berkeley) 02/24/91"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <netdb.h> 13 #include <string.h> 14 15 extern int _net_stayopen; 16 17 struct netent * 18 getnetbyname(name) 19 register const char *name; 20 { 21 register struct netent *p; 22 register char **cp; 23 24 setnetent(_net_stayopen); 25 while (p = getnetent()) { 26 if (strcmp(p->n_name, name) == 0) 27 break; 28 for (cp = p->n_aliases; *cp != 0; cp++) 29 if (strcmp(*cp, name) == 0) 30 goto found; 31 } 32 found: 33 if (!_net_stayopen) 34 endnetent(); 35 return (p); 36 } 37