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