Commit | Line | Data |
---|---|---|
8ea4199d DF |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
2ce81398 | 7 | #if defined(LIBC_SCCS) && !defined(lint) |
5442f2c7 | 8 | static char sccsid[] = "@(#)getprotoname.c 5.3 (Berkeley) %G%"; |
2ce81398 | 9 | #endif LIBC_SCCS and not lint |
723e6dff SL |
10 | |
11 | #include <netdb.h> | |
12 | ||
5442f2c7 JL |
13 | extern int _proto_stayopen; |
14 | ||
723e6dff | 15 | struct protoent * |
5e649950 | 16 | getprotobyname(name) |
723e6dff SL |
17 | register char *name; |
18 | { | |
19 | register struct protoent *p; | |
20 | register char **cp; | |
21 | ||
5442f2c7 | 22 | setprotoent(_proto_stayopen); |
723e6dff SL |
23 | while (p = getprotoent()) { |
24 | if (strcmp(p->p_name, name) == 0) | |
25 | break; | |
26 | for (cp = p->p_aliases; *cp != 0; cp++) | |
27 | if (strcmp(*cp, name) == 0) | |
28 | goto found; | |
29 | } | |
30 | found: | |
5442f2c7 JL |
31 | if (!_proto_stayopen) |
32 | endprotoent(); | |
723e6dff SL |
33 | return (p); |
34 | } |