diff --git a/dns/GNUmakefile b/dns/GNUmakefile index 7041ff3..d9ffb12 100644 --- a/dns/GNUmakefile +++ b/dns/GNUmakefile @@ -1,8 +1,12 @@ include GNUmakevars include GNUmakerules -all: gethostbyname -install: $(BINDIR)/gethostbyname +all: gethostbyname fqdn +install: \ + $(BINDIR)/gethostbyname \ + $(BINDIR)/axfr \ + $(BINDIR)/fqdn \ + clean: rm -f *.bak *.o core gethostbyname @@ -15,6 +19,14 @@ cfg/%: gethostbyname: gethostbyname.o hstrerror.o +fqdn: fqdn.o hstrerror.o + hstrerror.o: cfg/have_hstrerror.h +axfr: + +%: %.pl + cp $< $@ + chmod +x $@ + -include *.d diff --git a/dns/fqdn.c b/dns/fqdn.c new file mode 100644 index 0000000..c12494b --- /dev/null +++ b/dns/fqdn.c @@ -0,0 +1,37 @@ +#include +#include +#include + +#include "hstrerror.h" + +char *cmnd; + +void usage(void) { + fprintf(stderr, "Usage: %s [hostname ...]\n", cmnd); + exit(1); +} + +int main(int argc, char **argv) { + int i; + int rc = 0; + + cmnd = argv[0]; + + if (argc < 2) { + usage(); + } + + for (i = 1; i < argc; i++) { + struct hostent *he = gethostbyname(argv[i]); + + if (!he) { + fprintf(stderr, "%s: cannot resolve %s: %s\n", + argv[0], argv[i], hstrerror(h_errno)); + rc++; + continue; + } + + printf("%s\n", he->h_name); + } + return rc; +}