/*
* Remove \DDD constructs from the input. See RFC 1035, section 5.1.
+ * dest is alloced in this function!
*/
-size_t zoctet(char *text);
+size_t ldns_unquote(char *text, char **dest);
#endif /* _PARSE_H_ */
}
}
-/* should text be writeable? Or should we return a new
- * string??
- */
size_t
-zoctet(char *text)
+ldns_unquote(char *text, char **dest)
{
/*
* s follows the string, p lags behind and rebuilds
- * the new string
+ * the new string.
+ * Assumes: the new string will be <= old string
*/
- char *s;
+ char *s;
char *p;
- for (s = p = text; *s; ++s, ++p) {
+ *dest = strdup(text);
+
+ for (s = p = *dest; *s; ++s, ++p) {
assert(p <= s);
if (s[0] != '\\') {
/* Ordinary character. */
s += 3;
*p = val;
} else {
- printf("text escape \\DDD overflow");
- /* kuch, another printf... */
+ printf("text escape \\DDD overflow\n");
+ /* TODO, another printf... */
*p = *++s;
}
} else if (s[1] != '\0') {
--p;
}
}
- *p = '\0';
- return p - text;
+ *p = '\0';
+ return (size_t)((p - *dest));
}
ldns_rr_type rr_type;
ldns_buffer *rr_buf;
ldns_buffer *rd_buf;
+ char *unquoted;
char *owner;
char *ttl;
char *clas;
char *rd;
ldns_rdf *r;
+ size_t unquoted_len;
uint16_t r_cnt;
uint16_t r_min;
uint16_t r_max;
new = ldns_rr_new();
+ unquoted_len = ldns_unquote((char *)str, &unquoted);
+ printf("unq: [%s]\n", unquoted);
+ printf("unq: [%d] %d\n", strlen(unquoted), unquoted_len);
owner = XMALLOC(char, MAX_DOMAINLEN + 1);
ttl = XMALLOC(char, 21);
rd = XMALLOC(char, MAX_RDFLEN);
r_cnt = 0;
- ldns_buffer_new_frm_data(rr_buf, str, strlen(str));
+ ldns_buffer_new_frm_data(rr_buf, unquoted, unquoted_len);
/* split the rr in its parts -1 signal trouble */
if (ldns_bget_token(rr_buf, owner, "\t ", MAX_DOMAINLEN) == -1) {
rr = ldns_rr_new_frm_str("a.miek.nl. 1800 IN MX 10 www.atoom.net");
ldns_rr_print(stdout, rr);
printf("\n");
+
+ rr = ldns_rr_new_frm_str("a.miek.nl. 1800 IN MX 10 w\065.atoom.net");
+ ldns_rr_print(stdout, rr);
+ printf("\n");
+
+ rr = ldns_rr_new_frm_str("a.miek.nl. 1800 IN MX 10 w\65.atoom.net");
+ ldns_rr_print(stdout, rr);
+ printf("\n");
/* miss formed */
rr = ldns_rr_new_frm_str("a.miek.nl. 1800 IN MX 10");