summaryrefslogtreecommitdiff
path: root/src/dnscname.c
blob: 17265d399188845036420cd1f1629ddf4a258b39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <unistd.h>

#include "buffer.h"
#include "dnsresolv.h"
#include "exit.h"
#include "logmsg.h"
#include "stralloc.h"

#include "dns.h"

#define WHO "dnscname"

stralloc sa = {0};
stralloc out = {0};

int main(int argc, char **argv)
{
  int r;

  if (!argv[1]) logmsg(WHO, 100, USAGE, "dnscname fqdn");

  if (!stralloc_copys(&sa, argv[1])) logmsg(WHO, 111, FATAL, "out of memory");

  DNS_INIT
  if ((r = dns_cname(&out, &sa)) < 0) _exit(1);
  if (r > 0) {
    buffer_putflush(buffer_1, out.s, out.len);
    buffer_putsflush(buffer_1, "\n");
  }

  _exit(0);
}