summaryrefslogtreecommitdiff
path: root/ucspi-tcp-0.88/dns_dtda.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-06-01 23:07:51 -0700
committerJohn Denker <jsd@av8n.com>2012-06-02 17:30:23 -0700
commit0d0f7a0e7c32842edff533246a1f8523306f9ab0 (patch)
tree43dbb2fffaa8d490731969f39f5d20832523bd5d /ucspi-tcp-0.88/dns_dtda.c
parent94c58d7f8cabd9b1ff4c33c57a6ff76cdf3f955e (diff)
as downloaded : ucspi-tcp
Diffstat (limited to 'ucspi-tcp-0.88/dns_dtda.c')
-rw-r--r--ucspi-tcp-0.88/dns_dtda.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/ucspi-tcp-0.88/dns_dtda.c b/ucspi-tcp-0.88/dns_dtda.c
new file mode 100644
index 0000000..00b41a1
--- /dev/null
+++ b/ucspi-tcp-0.88/dns_dtda.c
@@ -0,0 +1,35 @@
+#include "stralloc.h"
+#include "dns.h"
+
+int dns_domain_todot_cat(stralloc *out,char *d)
+{
+ char ch;
+ char ch2;
+ unsigned char ch3;
+ char buf[4];
+
+ if (!*d)
+ return stralloc_append(out,".");
+
+ for (;;) {
+ ch = *d++;
+ while (ch--) {
+ ch2 = *d++;
+ if ((ch2 >= 'A') && (ch2 <= 'Z'))
+ ch2 += 32;
+ if (((ch2 >= 'a') && (ch2 <= 'z')) || ((ch2 >= '0') && (ch2 <= '9')) || (ch2 == '-') || (ch2 == '_')) {
+ if (!stralloc_append(out,&ch2)) return 0;
+ }
+ else {
+ ch3 = ch2;
+ buf[3] = '0' + (ch3 & 7); ch3 >>= 3;
+ buf[2] = '0' + (ch3 & 7); ch3 >>= 3;
+ buf[1] = '0' + (ch3 & 7);
+ buf[0] = '\\';
+ if (!stralloc_catb(out,buf,4)) return 0;
+ }
+ }
+ if (!*d) return 1;
+ if (!stralloc_append(out,".")) return 0;
+ }
+}