diff options
author | millert <> | 2004-10-25 03:09:01 +0000 |
---|---|---|
committer | millert <> | 2004-10-25 03:09:01 +0000 |
commit | 42489d4b990a8793c837811c34a869ec16d055ba (patch) | |
tree | 36483a751887031181b8128f629bde9b388ecac4 /src/lib/libc/net/getproto.c | |
parent | eae90a29f226809527585d7ba688d0af8627db58 (diff) | |
download | openbsd-42489d4b990a8793c837811c34a869ec16d055ba.tar.gz openbsd-42489d4b990a8793c837811c34a869ec16d055ba.tar.bz2 openbsd-42489d4b990a8793c837811c34a869ec16d055ba.zip |
Change return value of reentrant getproto* and getserv* to match the
IBM/Digital API.
Diffstat (limited to 'src/lib/libc/net/getproto.c')
-rw-r--r-- | src/lib/libc/net/getproto.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/libc/net/getproto.c b/src/lib/libc/net/getproto.c index 3f05a93cce..16d840394c 100644 --- a/src/lib/libc/net/getproto.c +++ b/src/lib/libc/net/getproto.c | |||
@@ -28,26 +28,26 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) |
31 | static char rcsid[] = "$OpenBSD: getproto.c,v 1.5 2004/10/17 20:24:23 millert Exp $"; | 31 | static char rcsid[] = "$OpenBSD: getproto.c,v 1.6 2004/10/25 03:09:01 millert Exp $"; |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ |
33 | 33 | ||
34 | #include <netdb.h> | 34 | #include <netdb.h> |
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | struct protoent * | 37 | int |
38 | getprotobynumber_r(int num, struct protoent *pe, struct protoent_data *pd) | 38 | getprotobynumber_r(int num, struct protoent *pe, struct protoent_data *pd) |
39 | { | 39 | { |
40 | struct protoent *p; | 40 | int error; |
41 | 41 | ||
42 | setprotoent_r(pd->stayopen, pd); | 42 | setprotoent_r(pd->stayopen, pd); |
43 | while ((p = getprotoent_r(pe, pd))) | 43 | while ((error = getprotoent_r(pe, pd)) == 0) |
44 | if (p->p_proto == num) | 44 | if (pe->p_proto == num) |
45 | break; | 45 | break; |
46 | if (!pd->stayopen && pd->fp != NULL) { | 46 | if (!pd->stayopen && pd->fp != NULL) { |
47 | (void)fclose(pd->fp); | 47 | (void)fclose(pd->fp); |
48 | pd->fp = NULL; | 48 | pd->fp = NULL; |
49 | } | 49 | } |
50 | return (p); | 50 | return (error); |
51 | } | 51 | } |
52 | 52 | ||
53 | struct protoent * | 53 | struct protoent * |
@@ -56,5 +56,7 @@ getprotobynumber(int num) | |||
56 | extern struct protoent_data _protoent_data; | 56 | extern struct protoent_data _protoent_data; |
57 | static struct protoent proto; | 57 | static struct protoent proto; |
58 | 58 | ||
59 | return getprotobynumber_r(num, &proto, &_protoent_data); | 59 | if (getprotobynumber_r(num, &proto, &_protoent_data) != 0) |
60 | return (NULL); | ||
61 | return (&proto); | ||
60 | } | 62 | } |