summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getprotoname.c
diff options
context:
space:
mode:
authormillert <>2004-10-25 03:09:01 +0000
committermillert <>2004-10-25 03:09:01 +0000
commit42489d4b990a8793c837811c34a869ec16d055ba (patch)
tree36483a751887031181b8128f629bde9b388ecac4 /src/lib/libc/net/getprotoname.c
parenteae90a29f226809527585d7ba688d0af8627db58 (diff)
downloadopenbsd-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/getprotoname.c')
-rw-r--r--src/lib/libc/net/getprotoname.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/libc/net/getprotoname.c b/src/lib/libc/net/getprotoname.c
index 429304e7a1..f257bf4a71 100644
--- a/src/lib/libc/net/getprotoname.c
+++ b/src/lib/libc/net/getprotoname.c
@@ -28,25 +28,25 @@
28 */ 28 */
29 29
30#if defined(LIBC_SCCS) && !defined(lint) 30#if defined(LIBC_SCCS) && !defined(lint)
31static char rcsid[] = "$OpenBSD: getprotoname.c,v 1.5 2004/10/17 20:24:23 millert Exp $"; 31static char rcsid[] = "$OpenBSD: getprotoname.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#include <string.h> 36#include <string.h>
37 37
38struct protoent * 38int
39getprotobyname_r(const char *name, struct protoent *pe, 39getprotobyname_r(const char *name, struct protoent *pe,
40 struct protoent_data *pd) 40 struct protoent_data *pd)
41{ 41{
42 struct protoent *p;
43 char **cp; 42 char **cp;
43 int error;
44 44
45 setprotoent_r(pd->stayopen, pd); 45 setprotoent_r(pd->stayopen, pd);
46 while ((p = getprotoent_r(pe, pd))) { 46 while ((error = getprotoent_r(pe, pd)) == 0) {
47 if (strcmp(p->p_name, name) == 0) 47 if (strcmp(pe->p_name, name) == 0)
48 break; 48 break;
49 for (cp = p->p_aliases; *cp != 0; cp++) 49 for (cp = pe->p_aliases; *cp != 0; cp++)
50 if (strcmp(*cp, name) == 0) 50 if (strcmp(*cp, name) == 0)
51 goto found; 51 goto found;
52 } 52 }
@@ -55,7 +55,7 @@ found:
55 fclose(pd->fp); 55 fclose(pd->fp);
56 pd->fp = NULL; 56 pd->fp = NULL;
57 } 57 }
58 return (p); 58 return (error);
59} 59}
60 60
61struct protoent * 61struct protoent *
@@ -64,5 +64,7 @@ getprotobyname(const char *name)
64 extern struct protoent_data _protoent_data; 64 extern struct protoent_data _protoent_data;
65 static struct protoent proto; 65 static struct protoent proto;
66 66
67 return getprotobyname_r(name, &proto, &_protoent_data); 67 if (getprotobyname_r(name, &proto, &_protoent_data) != 0)
68 return (NULL);
69 return (&proto);
68} 70}