ucspi-ssl  0.99e
TLS encryption for IPv6 communication
dns_dtda.c
Go to the documentation of this file.
1 #include "stralloc.h"
2 #include "dns.h"
3 
4 int dns_domain_todot_cat(stralloc *out,const char *d)
5 {
6  char ch;
7  char ch2;
8  unsigned char ch3;
9  char buf[4];
10 
11  if (!*d)
12  return stralloc_append(out,".");
13 
14  for (;;) {
15  ch = *d++;
16  while (ch--) {
17  ch2 = *d++;
18  if ((ch2 >= 'A') && (ch2 <= 'Z'))
19  ch2 += 32;
20  if (((ch2 >= 'a') && (ch2 <= 'z')) || ((ch2 >= '0') && (ch2 <= '9')) || (ch2 == '-') || (ch2 == '_')) {
21  if (!stralloc_append(out,&ch2)) return 0;
22  }
23  else {
24  ch3 = ch2;
25  buf[3] = '0' + (ch3 & 7); ch3 >>= 3;
26  buf[2] = '0' + (ch3 & 7); ch3 >>= 3;
27  buf[1] = '0' + (ch3 & 7);
28  buf[0] = '\\';
29  if (!stralloc_catb(out,buf,4)) return 0;
30  }
31  }
32  if (!*d) return 1;
33  if (!stralloc_append(out,".")) return 0;
34  }
35 }
char buf[SSL_NAME_LEN]
Definition: sslhandle.c:125
int stralloc_append(stralloc *, const char *)
int dns_domain_todot_cat(stralloc *out, const char *d)
Definition: dns_dtda.c:4
int stralloc_catb(stralloc *, const char *, unsigned int)
Definition: stralloc_catb.c:6