s/qmail 4.2.29a
Next generation secure email transport
Loading...
Searching...
No Matches
dnsip.c
Go to the documentation of this file.
1#include <sys/types.h>
2#include <sys/socket.h>
3#include <unistd.h>
4#include "buffer.h"
5#include "stralloc.h"
6#include "dnsresolv.h"
7#include "ip.h"
8#include "exit.h"
9#include "fmt.h"
10#include "dns.h"
11#include "logmsg.h"
12
13#define WHO "dnsip"
14
15stralloc sa = {0};
16stralloc out = {0};
17
18int main(int argc, char **argv)
19{
20 int i;
21 char ip4str[IP4_FMT];
22 char ip6str[IP6_FMT];
23
24 if (!argv[1])
25 logmsg(WHO,100,USAGE,"dnsip fqdn");
26
27 if (!stralloc_copys(&sa,argv[1]))
28 logmsg(WHO,111,FATAL,"out of memory");
29
31 if (dns_ip6(&out,&sa) > 0) /* IPv6 first */
32 for (i = 0; i + 16 <= out.len; i += 16) {
33 if (ip6_isv4mapped(out.s + i)) continue;
34 buffer_put(buffer_1,ip6str,ip6_fmt(ip6str,out.s + i));
35 buffer_puts(buffer_1,"\n");
36 }
37
38 if (dns_ip4(&out,&sa) > 0)
39 for (i = 0; i + 4 <= out.len;i += 4) {
40 buffer_put(buffer_1,ip4str,ip4_fmt(ip4str,out.s + i));
41 buffer_puts(buffer_1,"\n");
42 }
43 buffer_putsflush(buffer_1,"");
44
45 _exit(0);
46}
int main()
Definition: chkshsgr.c:6
int stralloc_copys(stralloc *, char const *)
#define DNS_INIT
Definition: dns.h:12
stralloc out
Definition: dnsip.c:16
stralloc sa
Definition: dnsip.c:15
#define WHO
Definition: dnsip.c:13
void _exit()