summaryrefslogtreecommitdiff
path: root/compat/hstrerror.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2007-06-13 18:54:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-06-16 05:48:34 (GMT)
commitfa0c87c34471286b6c261c781a45ed090135295c (patch)
tree083fd345b588cc495a7acad8b2cd07c3d516b364 /compat/hstrerror.c
parent18a936805e82d769e33ea0dd866f8fe12ef1827e (diff)
downloadgit-fa0c87c34471286b6c261c781a45ed090135295c.zip
git-fa0c87c34471286b6c261c781a45ed090135295c.tar.gz
git-fa0c87c34471286b6c261c781a45ed090135295c.tar.bz2
Add a local implementation of hstrerror for the system which do not have it
The function converts the value of h_errno (last error of name resolver library, see netdb.h). One of systems which supposedly do not have the function is SunOS. POSIX does not mandate its presence. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/hstrerror.c')
-rw-r--r--compat/hstrerror.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/compat/hstrerror.c b/compat/hstrerror.c
new file mode 100644
index 0000000..069c555
--- /dev/null
+++ b/compat/hstrerror.c
@@ -0,0 +1,21 @@
+#include <string.h>
+#include <stdio.h>
+#include <netdb.h>
+
+const char *githstrerror(int err)
+{
+ static char buffer[48];
+ switch (err)
+ {
+ case HOST_NOT_FOUND:
+ return "Authoritative answer: host not found";
+ case NO_DATA:
+ return "Valid name, no data record of requested type";
+ case NO_RECOVERY:
+ return "Non recoverable errors, FORMERR, REFUSED, NOTIMP";
+ case TRY_AGAIN:
+ return "Non-authoritative \"host not found\", or SERVERFAIL";
+ }
+ sprintf(buffer, "Name resolution error %d", err);
+ return buffer;
+}