summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getprotoname.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2004-10-25 03:09:01 +0000
committermillert <millert@openbsd.org>2004-10-25 03:09:01 +0000
commite3a1e9bf34eea155696e6eec761a1bf8eceb7daa (patch)
treee76d39ea6eed374cd8878ce3f6e3544b6a4c9806 /lib/libc/net/getprotoname.c
parentregen (diff)
downloadwireguard-openbsd-e3a1e9bf34eea155696e6eec761a1bf8eceb7daa.tar.xz
wireguard-openbsd-e3a1e9bf34eea155696e6eec761a1bf8eceb7daa.zip
Change return value of reentrant getproto* and getserv* to match the
IBM/Digital API.
Diffstat (limited to 'lib/libc/net/getprotoname.c')
-rw-r--r--lib/libc/net/getprotoname.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/libc/net/getprotoname.c b/lib/libc/net/getprotoname.c
index 429304e7a1c..f257bf4a71f 100644
--- a/lib/libc/net/getprotoname.c
+++ b/lib/libc/net/getprotoname.c
@@ -28,25 +28,25 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getprotoname.c,v 1.5 2004/10/17 20:24:23 millert Exp $";
+static char rcsid[] = "$OpenBSD: getprotoname.c,v 1.6 2004/10/25 03:09:01 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <netdb.h>
#include <stdio.h>
#include <string.h>
-struct protoent *
+int
getprotobyname_r(const char *name, struct protoent *pe,
struct protoent_data *pd)
{
- struct protoent *p;
char **cp;
+ int error;
setprotoent_r(pd->stayopen, pd);
- while ((p = getprotoent_r(pe, pd))) {
- if (strcmp(p->p_name, name) == 0)
+ while ((error = getprotoent_r(pe, pd)) == 0) {
+ if (strcmp(pe->p_name, name) == 0)
break;
- for (cp = p->p_aliases; *cp != 0; cp++)
+ for (cp = pe->p_aliases; *cp != 0; cp++)
if (strcmp(*cp, name) == 0)
goto found;
}
@@ -55,7 +55,7 @@ found:
fclose(pd->fp);
pd->fp = NULL;
}
- return (p);
+ return (error);
}
struct protoent *
@@ -64,5 +64,7 @@ getprotobyname(const char *name)
extern struct protoent_data _protoent_data;
static struct protoent proto;
- return getprotobyname_r(name, &proto, &_protoent_data);
+ if (getprotobyname_r(name, &proto, &_protoent_data) != 0)
+ return (NULL);
+ return (&proto);
}