diff options
Diffstat (limited to 'dnsmxip.c')
| -rw-r--r-- | dnsmxip.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/dnsmxip.c b/dnsmxip.c new file mode 100644 index 0000000..6d8e137 --- /dev/null +++ b/dnsmxip.c | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #include "substdio.h" | ||
| 2 | #include "subfd.h" | ||
| 3 | #include "stralloc.h" | ||
| 4 | #include "fmt.h" | ||
| 5 | #include "dns.h" | ||
| 6 | #include "dnsdoe.h" | ||
| 7 | #include "ip.h" | ||
| 8 | #include "ipalloc.h" | ||
| 9 | #include "now.h" | ||
| 10 | #include "exit.h" | ||
| 11 | |||
| 12 | char temp[IPFMT + FMT_ULONG]; | ||
| 13 | |||
| 14 | stralloc sa = {0}; | ||
| 15 | ipalloc ia = {0}; | ||
| 16 | |||
| 17 | void main(argc,argv) | ||
| 18 | int argc; | ||
| 19 | char **argv; | ||
| 20 | { | ||
| 21 | int j; | ||
| 22 | unsigned long r; | ||
| 23 | |||
| 24 | if (!argv[1]) _exit(100); | ||
| 25 | |||
| 26 | if (!stralloc_copys(&sa,argv[1])) | ||
| 27 | { substdio_putsflush(subfderr,"out of memory\n"); _exit(111); } | ||
| 28 | |||
| 29 | r = now() + getpid(); | ||
| 30 | dns_init(0); | ||
| 31 | dnsdoe(dns_mxip(&ia,&sa,r)); | ||
| 32 | for (j = 0;j < ia.len;++j) | ||
| 33 | { | ||
| 34 | substdio_put(subfdout,temp,ip_fmt(temp,&ia.ix[j].ip)); | ||
| 35 | substdio_puts(subfdout," "); | ||
| 36 | substdio_put(subfdout,temp,fmt_ulong(temp,(unsigned long) ia.ix[j].pref)); | ||
| 37 | substdio_putsflush(subfdout,"\n"); | ||
| 38 | } | ||
| 39 | _exit(0); | ||
| 40 | } | ||
