From 2192b4497348ccab94ca6f3f779cec399c72a8ef Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 22 Jan 1999 01:27:30 +0000 Subject: [PATCH] HINFO and TXT now handle quoted strings. --- bin/tests/rdata_test.c | 19 ++++++++++++++++++- lib/dns/rdata.c | 7 ++++++- lib/dns/rdata/generic/hinfo_13.c | 4 ++-- lib/dns/rdata/generic/hinfo_13.h | 4 ++-- lib/dns/rdata/generic/txt_16.c | 7 ++++--- lib/dns/rdata/generic/txt_16.h | 7 ++++--- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/bin/tests/rdata_test.c b/bin/tests/rdata_test.c index beb920e7bf..c9148a45f8 100644 --- a/bin/tests/rdata_test.c +++ b/bin/tests/rdata_test.c @@ -65,8 +65,9 @@ main(int argc, char *argv[]) { int debug = 0; isc_region_t region; int first = 1; + int raw = 0; - while ((c = getopt(argc, argv, "dqswtaz")) != -1) { + while ((c = getopt(argc, argv, "dqswtarz")) != -1) { switch (c) { case 'd': debug = 1; @@ -91,6 +92,9 @@ main(int argc, char *argv[]) { case 'z': zero = 1; break; + case 'r': + raw = 1; + break; } } @@ -178,6 +182,19 @@ main(int argc, char *argv[]) { fflush(stdout); continue; } + if (raw) { + unsigned int i; + for (i = 0 ; i < rdata.length ; /* */ ) { + fprintf(stdout, "%02x", rdata.data[i]); + if ((++i % 20) == 0) + fputs("\n", stdout); + else + if (i == rdata.length) + fputs("\n", stdout); + else + fputs(" ", stdout); + } + } /* Convert to wire and back? */ if (wire) { diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 3d5ac81c78..ef9744cc3c 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: rdata.c,v 1.11 1999/01/22 01:21:02 explorer Exp $ */ + /* $Id: rdata.c,v 1.12 1999/01/22 01:27:29 marka Exp $ */ #include @@ -607,6 +607,8 @@ gettoken(isc_lex_t *lexer, isc_token_t *token, isc_tokentype_t expect, isc_boolean_t eol) { unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; + if (expect == isc_tokentype_qstring) + options |= ISC_LEXOPT_QSTRING; if (expect == isc_tokentype_number) options |= ISC_LEXOPT_NUMBER; if (isc_lex_gettoken(lexer, options, token) != ISC_R_SUCCESS) @@ -614,6 +616,9 @@ gettoken(isc_lex_t *lexer, isc_token_t *token, isc_tokentype_t expect, if (eol && ((token->type == isc_tokentype_eol) || (token->type == isc_tokentype_eof))) return (DNS_R_SUCCESS); + if (token->type == isc_tokentype_string && + expect == isc_tokentype_qstring) + return (DNS_R_SUCCESS); if (token->type != expect) { isc_lex_ungettoken(lexer, token); if (token->type == isc_tokentype_eol || diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index b4eae087f8..ba79ee0cb3 100644 --- a/lib/dns/rdata/generic/hinfo_13.c +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: hinfo_13.c,v 1.6 1999/01/22 00:36:55 marka Exp $ */ + /* $Id: hinfo_13.c,v 1.7 1999/01/22 01:27:30 marka Exp $ */ #ifndef RDATA_GENERIC_HINFO_13_H #define RDATA_GENERIC_HINFO_13_H @@ -34,7 +34,7 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, downcase = downcase; /*unused*/ for (i = 0; i < 2 ; i++) { - RETERR(gettoken(lexer, &token, isc_tokentype_string, + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE)); RETERR(txt_fromtext(&token.value.as_textregion, target)); } diff --git a/lib/dns/rdata/generic/hinfo_13.h b/lib/dns/rdata/generic/hinfo_13.h index a3a07a827d..84fed057c3 100644 --- a/lib/dns/rdata/generic/hinfo_13.h +++ b/lib/dns/rdata/generic/hinfo_13.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: hinfo_13.h,v 1.6 1999/01/22 00:36:55 marka Exp $ */ + /* $Id: hinfo_13.h,v 1.7 1999/01/22 01:27:30 marka Exp $ */ #ifndef RDATA_GENERIC_HINFO_13_H #define RDATA_GENERIC_HINFO_13_H @@ -34,7 +34,7 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, downcase = downcase; /*unused*/ for (i = 0; i < 2 ; i++) { - RETERR(gettoken(lexer, &token, isc_tokentype_string, + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_FALSE)); RETERR(txt_fromtext(&token.value.as_textregion, target)); } diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index 64edccec46..782b8964bd 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: txt_16.c,v 1.6 1999/01/22 00:36:58 marka Exp $ */ + /* $Id: txt_16.c,v 1.7 1999/01/22 01:27:30 marka Exp $ */ #ifndef RDATA_GENERIC_TXT_16_H #define RDATA_GENERIC_TXT_16_H @@ -33,9 +33,10 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, downcase = downcase; /*unused*/ while (1) { - RETERR(gettoken(lexer, &token, isc_tokentype_string, + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_TRUE)); - if (token.type != isc_tokentype_string) + if (token.type != isc_tokentype_qstring && + token.type != isc_tokentype_string) break; RETERR(txt_fromtext(&token.value.as_textregion, target)); } diff --git a/lib/dns/rdata/generic/txt_16.h b/lib/dns/rdata/generic/txt_16.h index 7a62ef85de..352c0beb03 100644 --- a/lib/dns/rdata/generic/txt_16.h +++ b/lib/dns/rdata/generic/txt_16.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: txt_16.h,v 1.6 1999/01/22 00:36:58 marka Exp $ */ + /* $Id: txt_16.h,v 1.7 1999/01/22 01:27:30 marka Exp $ */ #ifndef RDATA_GENERIC_TXT_16_H #define RDATA_GENERIC_TXT_16_H @@ -33,9 +33,10 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, downcase = downcase; /*unused*/ while (1) { - RETERR(gettoken(lexer, &token, isc_tokentype_string, + RETERR(gettoken(lexer, &token, isc_tokentype_qstring, ISC_TRUE)); - if (token.type != isc_tokentype_string) + if (token.type != isc_tokentype_qstring && + token.type != isc_tokentype_string) break; RETERR(txt_fromtext(&token.value.as_textregion, target)); }