Added fqdn command.
This commit is contained in:
parent
53bae2019f
commit
b9699494bb
|
@ -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
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue