fehQlibs 26
Qlibs
Loading...
Searching...
No Matches
dns_dtda.c
Go to the documentation of this file.
1#include "stralloc.h"
2#include "dnsresolv.h"
3
11int dns_domain_todot_cat(stralloc *out,const char *d)
12{
13 char ch;
14 char ch2;
15 unsigned char ch3;
16 char buf[4];
17
18 if (!*d)
19 return stralloc_append(out,".");
20
21 for (;;) {
22 ch = *d++;
23 while (ch--) {
24 ch2 = *d++;
25 if ((ch2 >= 'A') && (ch2 <= 'Z')) ch2 += 32; // FQDN -> lowercase
26 if (((ch2 >= 'a') && (ch2 <= 'z')) ||
27 ((ch2 >= '0') && (ch2 <= '9')) ||
28 (ch2 == '-') || (ch2 == '_')) {
29 if (!stralloc_append(out,&ch2)) return DNS_MEM;
30 }
31 else { // decimal -> octal
32 ch3 = ch2;
33 buf[3] = '0' + (ch3 & 7); ch3 >>= 3;
34 buf[2] = '0' + (ch3 & 7); ch3 >>= 3;
35 buf[1] = '0' + (ch3 & 7);
36 buf[0] = '\\';
37 if (!stralloc_catb(out,buf,4)) return DNS_MEM;
38 }
39 }
40 if (!*d) return 1;
41 if (!stralloc_append(out,".")) return DNS_MEM;
42 }
43}
int dns_domain_todot_cat(stralloc *out, const char *d)
Definition: dns_dtda.c:11
#define DNS_MEM
Definition: dnsresolv.h:43
int stralloc_catb(stralloc *, const char *, unsigned int)
Definition: stralloc.c:26
int stralloc_append(stralloc *sa, const char *in)
Definition: stralloc.c:112