Explorar o código

implement legacy function herror

based on patch by Timo Teräs; greatly simplified to use fprintf.
Rich Felker %!s(int64=11) %!d(string=hai) anos
pai
achega
18144af297
Modificáronse 2 ficheiros con 9 adicións e 0 borrados
  1. 1 0
      include/netdb.h
  2. 8 0
      src/network/herror.c

+ 1 - 0
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 *);

+ 8 - 0
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));
+}