Skip to content
/ git Public
forked from git/git

Commit

Permalink
Add a local implementation of hstrerror for the system which do not h…
Browse files Browse the repository at this point in the history
…ave 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>
  • Loading branch information
raalkml authored and gitster committed Jun 16, 2007
1 parent 18a9368 commit fa0c87c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ ifeq ($(uname_S),SunOS)
NEEDS_NSL = YesPlease
SHELL_PATH = /bin/bash
NO_STRCASESTR = YesPlease
NO_HSTRERROR = YesPlease
ifeq ($(uname_R),5.8)
NEEDS_LIBICONV = YesPlease
NO_UNSETENV = YesPlease
Expand Down Expand Up @@ -654,6 +655,10 @@ endif
ifdef NO_PERL_MAKEMAKER
export NO_PERL_MAKEMAKER
endif
ifdef NO_HSTRERROR
COMPAT_CFLAGS += -DNO_HSTRERROR
COMPAT_OBJS += compat/hstrerror.o
endif

ifeq ($(TCLTK_PATH),)
NO_TCLTK=NoThanks
Expand Down
21 changes: 21 additions & 0 deletions compat/hstrerror.c
Original file line number Diff line number Diff line change
@@ -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;
}
5 changes: 5 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ extern size_t gitstrlcpy(char *, const char *, size_t);
extern uintmax_t gitstrtoumax(const char *, char **, int);
#endif

#ifdef NO_HSTRERROR
#define hstrerror githstrerror
extern const char *githstrerror(int herror);
#endif

extern void release_pack_memory(size_t, int);

static inline char* xstrdup(const char *str)
Expand Down

0 comments on commit fa0c87c

Please sign in to comment.