about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--include/netdb.h1
-rw-r--r--src/network/herror.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/include/netdb.h b/include/netdb.h
index 8a7013ad..2dd799b9 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -134,6 +134,7 @@ int *__h_errno_location(void);
 #endif
 
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+void herror(const char *);
 const char *hstrerror(int);
 int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
 int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
diff --git a/src/network/herror.c b/src/network/herror.c
new file mode 100644
index 00000000..65f25ff3
--- /dev/null
+++ b/src/network/herror.c
@@ -0,0 +1,8 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <netdb.h>
+
+void herror(const char *msg)
+{
+	fprintf(stderr, "%s%s%s", msg?msg:"", msg?": ":"", hstrerror(h_errno));
+}