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>
Alex Riesen committed
Jun 13, 2007 at 20:54 UTC
fa0c87c34471286b6c261c781a45ed090135295c
3 files changed
+31
Makefile
+5
@@ -410,6 +410,7 @@ ifeq ($(uname_S),SunOS)
410
NEEDS_NSL = YesPlease
411
SHELL_PATH = /bin/bash
412
NO_STRCASESTR = YesPlease
413
+ NO_HSTRERROR = YesPlease
414
ifeq ($(uname_R),5.8)
415
NEEDS_LIBICONV = YesPlease
416
NO_UNSETENV = YesPlease
@@ -654,6 +655,10 @@ endif
655
ifdef NO_PERL_MAKEMAKER
656
export NO_PERL_MAKEMAKER
657
endif
658
+ifdef NO_HSTRERROR
659
+ COMPAT_CFLAGS += -DNO_HSTRERROR
660
+ COMPAT_OBJS += compat/hstrerror.o
661
+endif
662
663
ifeq ($(TCLTK_PATH),)
664
NO_TCLTK=NoThanks
compat/hstrerror.c
new
+21
@@ -0,0 +1,21 @@
1
+#include <string.h>
2
+#include <stdio.h>
3
+#include <netdb.h>
4
+
5
+const char *githstrerror(int err)
6
+{
7
+ static char buffer[48];
8
+ switch (err)
9
+ {
10
+ case HOST_NOT_FOUND:
11
+ return "Authoritative answer: host not found";
12
+ case NO_DATA:
13
+ return "Valid name, no data record of requested type";
14
+ case NO_RECOVERY:
15
+ return "Non recoverable errors, FORMERR, REFUSED, NOTIMP";
16
+ case TRY_AGAIN:
17
+ return "Non-authoritative \"host not found\", or SERVERFAIL";
18
+ }
19
+ sprintf(buffer, "Name resolution error %d", err);
20
+ return buffer;
21
+}
git-compat-util.h
+5
@@ -167,6 +167,11 @@ extern size_t gitstrlcpy(char *, const char *, size_t);
167
extern uintmax_t gitstrtoumax(const char *, char **, int);
168
#endif
169
170
+#ifdef NO_HSTRERROR
171
+#define hstrerror githstrerror
172
+extern const char *githstrerror(int herror);
173
+#endif
174
+
175
extern void release_pack_memory(size_t, int);
176
177
static inline char* xstrdup(const char *str)