Added configuration test for hstrerror().

This commit is contained in:
hjp 2001-07-03 20:53:17 +00:00
parent 8a1a8732e0
commit 20692a6976
6 changed files with 38 additions and 1 deletions

View File

@ -10,4 +10,11 @@ clean:
distclean: clean
rm -f *.d
cfg/%:
$(MAKE) -C cfg all
gethostbyname: gethostbyname.o hstrerror.o
hstrerror.o: cfg/have_hstrerror.h
-include *.d

4
dns/cfg/GNUmakefile Normal file
View File

@ -0,0 +1,4 @@
all: have_hstrerror.h
%.h: %.sh
CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' sh $^ > $@

11
dns/cfg/have_hstrerror.sh Normal file
View File

@ -0,0 +1,11 @@
cat > has_hstrerror_$$.c <<EOF
#include <netdb.h>
int main(void) { hstrerror(0); }
EOF
if $CC $CFLAGS has_hstrerror_$$.c $LDFLAGS -o has_hstrerror_$$
then
echo '#define HAVE_HSTRERROR 1'
else
echo '#define HAVE_HSTRERROR 0'
fi
rm has_hstrerror_$$.c has_hstrerror_$$

View File

@ -1,5 +1,8 @@
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include "hstrerror.h"
char *cmnd;
@ -36,7 +39,7 @@ int main(int argc, char **argv) {
}
for (a = he->h_addr_list; *a; a++) {
int j;
printf("\tAddress: ");
printf("\tAddress: ");
for (j = 0; j < he->h_length; j++) {
printf("%s%d", j ? "." : "", (unsigned char)(*a)[j]);
}

11
dns/hstrerror.c Normal file
View File

@ -0,0 +1,11 @@
#include "cfg/have_hstrerror.h"
#include "hstrerror.h"
#if (!HAVE_HSTRERROR)
const char *hstrerror(int err) {
static char errstr[80];
snprintf(errstr, sizeof(errstr), "resolver error %d", err);
return errstr;
}
#endif

1
dns/hstrerror.h Normal file
View File

@ -0,0 +1 @@
const char * hstrerror(int err);