djbdnscurve6
38
djbdnscurve6
djbdnscurve6-38
src
dns_dtda.c
Go to the documentation of this file.
1
#include "stralloc.h"
2
#include "
dns.h
"
3
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:301
dns.h
DNS_MEM
#define DNS_MEM
Definition:
dns.h:21
dns_domain_todot_cat
int dns_domain_todot_cat(stralloc *out, const char *d)
Definition:
dns_dtda.c:11
out
void out(const char *s, unsigned int len)
Definition:
generic-conf.c:54
d
void d(const char *home, const char *subdir, int uid, int gid, int mode)
Generated on Tue Aug 3 2021 23:28:56 for djbdnscurve6 by
1.9.1