djbdnscurve6
46
djbdnscurve6
Loading...
Searching...
No Matches
djbdnscurve6-46
src
dns_dtda.c
Go to the documentation of this file.
1
#include "stralloc.h"
2
#include "
dns.h
"
3
10
11
int
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
}
buf
char buf[MSGSIZE]
Definition
axfrdns.c:318
dns.h
DNS_MEM
#define DNS_MEM
Definition
dns.h:31
dns_domain_todot_cat
int dns_domain_todot_cat(stralloc *out, const char *d)
Definition
dns_dtda.c:11
Generated on
for djbdnscurve6 by
1.14.0