From deaaf94332abbfdb3aff53675546acfed16e5eb6 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 22 Jan 1999 00:36:59 +0000 Subject: [PATCH] dns_rdata_compare checked for RFC 1035 types converted frometext* to use gettoken() converted: result = foo(); if (result != DNS_R_SUCCESS) return (result); to RETERR(foo()); --- bin/tests/rdata_test.c | 23 ++++++ lib/dns/rdata.c | 8 +- lib/dns/rdata/generic/cname_5.c | 14 +--- lib/dns/rdata/generic/cname_5.h | 14 +--- lib/dns/rdata/generic/hinfo_13.c | 54 +++----------- lib/dns/rdata/generic/hinfo_13.h | 54 +++----------- lib/dns/rdata/generic/mb_7.c | 13 +--- lib/dns/rdata/generic/mb_7.h | 13 +--- lib/dns/rdata/generic/md_3.c | 15 +--- lib/dns/rdata/generic/md_3.h | 15 +--- lib/dns/rdata/generic/mf_4.c | 13 +--- lib/dns/rdata/generic/mf_4.h | 13 +--- lib/dns/rdata/generic/mg_8.c | 13 +--- lib/dns/rdata/generic/mg_8.h | 13 +--- lib/dns/rdata/generic/minfo_14.c | 83 ++++++--------------- lib/dns/rdata/generic/minfo_14.h | 83 ++++++--------------- lib/dns/rdata/generic/mr_9.c | 13 +--- lib/dns/rdata/generic/mr_9.h | 13 +--- lib/dns/rdata/generic/mx_15.c | 45 ++---------- lib/dns/rdata/generic/mx_15.h | 45 ++---------- lib/dns/rdata/generic/ns_2.c | 13 +--- lib/dns/rdata/generic/ns_2.h | 13 +--- lib/dns/rdata/generic/ptr_12.c | 13 +--- lib/dns/rdata/generic/ptr_12.h | 13 +--- lib/dns/rdata/generic/soa_6.c | 121 ++++++++----------------------- lib/dns/rdata/generic/soa_6.h | 121 ++++++++----------------------- lib/dns/rdata/generic/txt_16.c | 48 ++++-------- lib/dns/rdata/generic/txt_16.h | 48 ++++-------- lib/dns/rdata/in_1/a_1.c | 13 +--- lib/dns/rdata/in_1/a_1.h | 13 +--- lib/dns/rdata/in_1/wks_11.c | 48 ++++-------- lib/dns/rdata/in_1/wks_11.h | 48 ++++-------- 32 files changed, 264 insertions(+), 805 deletions(-) diff --git a/bin/tests/rdata_test.c b/bin/tests/rdata_test.c index d4be244352..beb920e7bf 100644 --- a/bin/tests/rdata_test.c +++ b/bin/tests/rdata_test.c @@ -45,6 +45,7 @@ main(int argc, char *argv[]) { unsigned int options = 0; unsigned int parens = 0; dns_rdatatype_t type; + dns_rdatatype_t lasttype = 0; char outbuf[16*1024]; char inbuf[16*1024]; char wirebuf[16*1024]; @@ -52,6 +53,7 @@ main(int argc, char *argv[]) { isc_buffer_t tbuf; isc_buffer_t wbuf; dns_rdata_t rdata; + dns_rdata_t last; int need_eol = 0; int wire = 0; dns_compress_t cctx; @@ -61,6 +63,8 @@ main(int argc, char *argv[]) { int len; int zero = 0; int debug = 0; + isc_region_t region; + int first = 1; while ((c = getopt(argc, argv, "dqswtaz")) != -1) { switch (c) { @@ -107,6 +111,7 @@ main(int argc, char *argv[]) { RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS); + dns_rdata_init(&last); while ((result = isc_lex_gettoken(lex, options | ISC_LEXOPT_NUMBER, &token)) == ISC_R_SUCCESS) { if (debug) fprintf(stdout, "token.type = %d\n", token.type); @@ -219,6 +224,24 @@ main(int argc, char *argv[]) { fprintf(stdout, "\"%.*s\"\n", (int)tbuf.used, (char*)tbuf.base); fflush(stdout); + if (lasttype == type) { + fprintf(stdout, "dns_rdata_compare = %d\n", + dns_rdata_compare(&rdata, &last)); + + } + if (!first) { + free(last.data); + } + dns_rdata_init(&last); + region.base = malloc(region.length = rdata.length); + if (region.base) { + memcpy(region.base, rdata.data, rdata.length); + dns_rdata_fromregion(&last, 1, type, ®ion); + lasttype = type; + first = 0; + } else + first = 1; + } if (result != ISC_R_EOF) printf("Result: %s\n", isc_result_totext(result)); diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index b75d947bf4..3d7caf328c 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: rdata.c,v 1.8 1999/01/21 06:02:13 marka Exp $ */ + /* $Id: rdata.c,v 1.9 1999/01/22 00:36:54 marka Exp $ */ #include #include @@ -28,6 +28,12 @@ #include #include +#define RETERR(x) { \ + dns_result_t __r = (x); \ + if (__r != DNS_R_SUCCESS) \ + return (__r); \ + } + static dns_result_t txt_totext(isc_region_t *source, isc_buffer_t *target); static dns_result_t txt_fromtext(isc_textregion_t *source, isc_buffer_t *target); diff --git a/lib/dns/rdata/generic/cname_5.c b/lib/dns/rdata/generic/cname_5.c index 50b5dd24ad..478284ae6f 100644 --- a/lib/dns/rdata/generic/cname_5.c +++ b/lib/dns/rdata/generic/cname_5.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: cname_5.c,v 1.4 1999/01/20 05:20:19 marka Exp $ */ + /* $Id: cname_5.c,v 1.5 1999/01/22 00:36:55 marka Exp $ */ #ifndef RDATA_GENERIC_CNAME_5_H #define RDATA_GENERIC_CNAME_5_H @@ -27,21 +27,11 @@ fromtext_cname(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 5); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/cname_5.h b/lib/dns/rdata/generic/cname_5.h index 2a3b23bba4..cc075175f8 100644 --- a/lib/dns/rdata/generic/cname_5.h +++ b/lib/dns/rdata/generic/cname_5.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: cname_5.h,v 1.4 1999/01/20 05:20:19 marka Exp $ */ + /* $Id: cname_5.h,v 1.5 1999/01/22 00:36:55 marka Exp $ */ #ifndef RDATA_GENERIC_CNAME_5_H #define RDATA_GENERIC_CNAME_5_H @@ -27,21 +27,11 @@ fromtext_cname(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 5); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index 20ef187842..b4eae087f8 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.5 1999/01/20 05:20:20 marka Exp $ */ + /* $Id: hinfo_13.c,v 1.6 1999/01/22 00:36:55 marka Exp $ */ #ifndef RDATA_GENERIC_HINFO_13_H #define RDATA_GENERIC_HINFO_13_H @@ -25,8 +25,7 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - dns_result_t result; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; + int i; REQUIRE(type == 13); @@ -34,60 +33,32 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); + for (i = 0; i < 2 ; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + RETERR(txt_fromtext(&token.value.as_textregion, target)); } - - result = txt_fromtext(&token.value.as_textregion, target); - if (result != DNS_R_SUCCESS) - return (result); - - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } - return (txt_fromtext(&token.value.as_textregion, target)); + return (DNS_R_SUCCESS); } static dns_result_t totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; - dns_result_t result; REQUIRE(rdata->type == 13); origin = origin; /*unused*/ dns_rdata_toregion(rdata, ®ion); - - result = txt_totext(®ion, target); - if (result != DNS_R_SUCCESS) - return (result); - - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - - result = txt_totext(®ion, target); - return (DNS_R_SUCCESS); + RETERR(txt_totext(®ion, target)); + RETERR(str_totext(" ", target)); + return (txt_totext(®ion, target)); } static dns_result_t fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target) { - dns_result_t result; REQUIRE(type == 13); @@ -95,10 +66,7 @@ fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, class = class; /* unused */ downcase = downcase; /* unused */ - result = txt_fromwire(source, target); - if (result != DNS_R_SUCCESS) - return (result); - + RETERR(txt_fromwire(source, target)); return (txt_fromwire(source, target)); } diff --git a/lib/dns/rdata/generic/hinfo_13.h b/lib/dns/rdata/generic/hinfo_13.h index 3d819afabe..a3a07a827d 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.5 1999/01/20 05:20:20 marka Exp $ */ + /* $Id: hinfo_13.h,v 1.6 1999/01/22 00:36:55 marka Exp $ */ #ifndef RDATA_GENERIC_HINFO_13_H #define RDATA_GENERIC_HINFO_13_H @@ -25,8 +25,7 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - dns_result_t result; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; + int i; REQUIRE(type == 13); @@ -34,60 +33,32 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); + for (i = 0; i < 2 ; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + RETERR(txt_fromtext(&token.value.as_textregion, target)); } - - result = txt_fromtext(&token.value.as_textregion, target); - if (result != DNS_R_SUCCESS) - return (result); - - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } - return (txt_fromtext(&token.value.as_textregion, target)); + return (DNS_R_SUCCESS); } static dns_result_t totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; - dns_result_t result; REQUIRE(rdata->type == 13); origin = origin; /*unused*/ dns_rdata_toregion(rdata, ®ion); - - result = txt_totext(®ion, target); - if (result != DNS_R_SUCCESS) - return (result); - - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - - result = txt_totext(®ion, target); - return (DNS_R_SUCCESS); + RETERR(txt_totext(®ion, target)); + RETERR(str_totext(" ", target)); + return (txt_totext(®ion, target)); } static dns_result_t fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target) { - dns_result_t result; REQUIRE(type == 13); @@ -95,10 +66,7 @@ fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, class = class; /* unused */ downcase = downcase; /* unused */ - result = txt_fromwire(source, target); - if (result != DNS_R_SUCCESS) - return (result); - + RETERR(txt_fromwire(source, target)); return (txt_fromwire(source, target)); } diff --git a/lib/dns/rdata/generic/mb_7.c b/lib/dns/rdata/generic/mb_7.c index 3b60818369..7d907ebb36 100644 --- a/lib/dns/rdata/generic/mb_7.c +++ b/lib/dns/rdata/generic/mb_7.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mb_7.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ + /* $Id: mb_7.c,v 1.5 1999/01/22 00:36:55 marka Exp $ */ #ifndef RDATA_GENERIC_MB_7_H #define RDATA_GENERIC_MB_7_H @@ -27,21 +27,12 @@ fromtext_mb(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 7); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/mb_7.h b/lib/dns/rdata/generic/mb_7.h index 0bb0189139..4c23583e17 100644 --- a/lib/dns/rdata/generic/mb_7.h +++ b/lib/dns/rdata/generic/mb_7.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mb_7.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ + /* $Id: mb_7.h,v 1.5 1999/01/22 00:36:55 marka Exp $ */ #ifndef RDATA_GENERIC_MB_7_H #define RDATA_GENERIC_MB_7_H @@ -27,21 +27,12 @@ fromtext_mb(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 7); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/md_3.c b/lib/dns/rdata/generic/md_3.c index eb6298bfa6..ab5d936ce0 100644 --- a/lib/dns/rdata/generic/md_3.c +++ b/lib/dns/rdata/generic/md_3.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: md_3.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ + /* $Id: md_3.c,v 1.5 1999/01/22 00:36:55 marka Exp $ */ #ifndef RDATA_GENERIC_MD_3_H #define RDATA_GENERIC_MD_3_H @@ -25,25 +25,14 @@ fromtext_md(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - isc_result_t result; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 3); class = class; /*unused*/ - result = isc_lex_gettoken(lexer, options, &token); - if (result != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/md_3.h b/lib/dns/rdata/generic/md_3.h index 5db3922d90..9307bc3e71 100644 --- a/lib/dns/rdata/generic/md_3.h +++ b/lib/dns/rdata/generic/md_3.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: md_3.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ + /* $Id: md_3.h,v 1.5 1999/01/22 00:36:55 marka Exp $ */ #ifndef RDATA_GENERIC_MD_3_H #define RDATA_GENERIC_MD_3_H @@ -25,25 +25,14 @@ fromtext_md(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - isc_result_t result; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 3); class = class; /*unused*/ - result = isc_lex_gettoken(lexer, options, &token); - if (result != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/mf_4.c b/lib/dns/rdata/generic/mf_4.c index ca5974e58b..86a69deea0 100644 --- a/lib/dns/rdata/generic/mf_4.c +++ b/lib/dns/rdata/generic/mf_4.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mf_4.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ + /* $Id: mf_4.c,v 1.5 1999/01/22 00:36:56 marka Exp $ */ #ifndef RDATA_GENERIC_MF_4_H #define RDATA_GENERIC_MF_4_H @@ -27,21 +27,12 @@ fromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 4); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/mf_4.h b/lib/dns/rdata/generic/mf_4.h index 7d50002a00..01fd69f196 100644 --- a/lib/dns/rdata/generic/mf_4.h +++ b/lib/dns/rdata/generic/mf_4.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mf_4.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ + /* $Id: mf_4.h,v 1.5 1999/01/22 00:36:56 marka Exp $ */ #ifndef RDATA_GENERIC_MF_4_H #define RDATA_GENERIC_MF_4_H @@ -27,21 +27,12 @@ fromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 4); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/mg_8.c b/lib/dns/rdata/generic/mg_8.c index 32fa90222a..5655045063 100644 --- a/lib/dns/rdata/generic/mg_8.c +++ b/lib/dns/rdata/generic/mg_8.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mg_8.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ + /* $Id: mg_8.c,v 1.5 1999/01/22 00:36:56 marka Exp $ */ #ifndef RDATA_GENERIC_MG_8_H #define RDATA_GENERIC_MG_8_H @@ -27,21 +27,12 @@ fromtext_mg(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 8); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/mg_8.h b/lib/dns/rdata/generic/mg_8.h index cedaa29381..de09bcc626 100644 --- a/lib/dns/rdata/generic/mg_8.h +++ b/lib/dns/rdata/generic/mg_8.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mg_8.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ + /* $Id: mg_8.h,v 1.5 1999/01/22 00:36:56 marka Exp $ */ #ifndef RDATA_GENERIC_MG_8_H #define RDATA_GENERIC_MG_8_H @@ -27,21 +27,12 @@ fromtext_mg(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 8); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c index 31e28047db..f569ab595c 100644 --- a/lib/dns/rdata/generic/minfo_14.c +++ b/lib/dns/rdata/generic/minfo_14.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: minfo_14.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ + /* $Id: minfo_14.c,v 1.5 1999/01/22 00:36:56 marka Exp $ */ #ifndef RDATA_GENERIC_MINFO_14_H #define RDATA_GENERIC_MINFO_14_H @@ -25,48 +25,25 @@ fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - dns_result_t result; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; + int i; REQUIRE(type == 14); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); + for (i = 0; i < 2 ; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + RETERR(dns_name_fromtext(&name, &buffer, origin, + downcase, target)); } - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region, - ISC_BUFFERTYPE_TEXT); - origin = (origin != NULL) ? origin : dns_rootname; - result = dns_name_fromtext(&name, &buffer, origin, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } - if (token.type != isc_tokentype_string) - return (DNS_R_UNEXPECTED); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region, - ISC_BUFFERTYPE_TEXT); - origin = (origin != NULL) ? origin : dns_rootname; - return (dns_name_fromtext(&name, &buffer, origin, downcase, target)); + return (DNS_R_SUCCESS); } static dns_result_t @@ -75,7 +52,6 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t rmail; dns_name_t email; dns_name_t prefix; - dns_result_t result; isc_boolean_t sub; REQUIRE(rdata->type == 14); @@ -94,20 +70,12 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { sub = name_prefix(&rmail, origin, &prefix); - result = dns_name_totext(&prefix, sub, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_totext(&prefix, sub, target)); - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); sub = name_prefix(&email, origin, &prefix); - result = dns_name_totext(&prefix, sub, target); - if (result != DNS_R_SUCCESS) - return (result); - - return (DNS_R_SUCCESS); + return (dns_name_totext(&prefix, sub, target)); } static dns_result_t @@ -116,7 +84,6 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t rmail; dns_name_t email; - dns_result_t result; REQUIRE(type == 14); @@ -125,10 +92,7 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type, dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); - result = dns_name_fromwire(&rmail, source, dctx, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - + RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target)); return (dns_name_fromwire(&email, source, dctx, downcase, target)); } @@ -137,7 +101,6 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t region; dns_name_t rmail; dns_name_t email; - dns_result_t result; REQUIRE(rdata->type == 14); @@ -149,16 +112,12 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_fromregion(&rmail, ®ion); isc_region_consume(®ion, rmail.length); - result = dns_name_towire(&rmail, cctx, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_towire(&rmail, cctx, target)); dns_name_fromregion(&rmail, ®ion); isc_region_consume(®ion, rmail.length); - result = dns_name_towire(&rmail, cctx, target); - - return (DNS_R_SUCCESS); + return (dns_name_towire(&rmail, cctx, target)); } static int @@ -177,7 +136,7 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { dns_name_init(&name2, NULL); dns_rdata_toregion(rdata1, ®ion1); - dns_rdata_toregion(rdata2, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); dns_name_fromregion(&name1, ®ion1); dns_name_fromregion(&name2, ®ion2); @@ -186,8 +145,8 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { if (result != 0) return (result); - isc_region_consume(®ion1, name1.length); - isc_region_consume(®ion2, name2.length); + isc_region_consume(®ion1, name_length(&name1)); + isc_region_consume(®ion2, name_length(&name2)); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); diff --git a/lib/dns/rdata/generic/minfo_14.h b/lib/dns/rdata/generic/minfo_14.h index 95022dd702..6914c920e3 100644 --- a/lib/dns/rdata/generic/minfo_14.h +++ b/lib/dns/rdata/generic/minfo_14.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: minfo_14.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ + /* $Id: minfo_14.h,v 1.5 1999/01/22 00:36:56 marka Exp $ */ #ifndef RDATA_GENERIC_MINFO_14_H #define RDATA_GENERIC_MINFO_14_H @@ -25,48 +25,25 @@ fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - dns_result_t result; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; + int i; REQUIRE(type == 14); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); + for (i = 0; i < 2 ; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + RETERR(dns_name_fromtext(&name, &buffer, origin, + downcase, target)); } - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region, - ISC_BUFFERTYPE_TEXT); - origin = (origin != NULL) ? origin : dns_rootname; - result = dns_name_fromtext(&name, &buffer, origin, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } - if (token.type != isc_tokentype_string) - return (DNS_R_UNEXPECTED); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region, - ISC_BUFFERTYPE_TEXT); - origin = (origin != NULL) ? origin : dns_rootname; - return (dns_name_fromtext(&name, &buffer, origin, downcase, target)); + return (DNS_R_SUCCESS); } static dns_result_t @@ -75,7 +52,6 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t rmail; dns_name_t email; dns_name_t prefix; - dns_result_t result; isc_boolean_t sub; REQUIRE(rdata->type == 14); @@ -94,20 +70,12 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { sub = name_prefix(&rmail, origin, &prefix); - result = dns_name_totext(&prefix, sub, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_totext(&prefix, sub, target)); - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); sub = name_prefix(&email, origin, &prefix); - result = dns_name_totext(&prefix, sub, target); - if (result != DNS_R_SUCCESS) - return (result); - - return (DNS_R_SUCCESS); + return (dns_name_totext(&prefix, sub, target)); } static dns_result_t @@ -116,7 +84,6 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t rmail; dns_name_t email; - dns_result_t result; REQUIRE(type == 14); @@ -125,10 +92,7 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type, dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); - result = dns_name_fromwire(&rmail, source, dctx, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - + RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target)); return (dns_name_fromwire(&email, source, dctx, downcase, target)); } @@ -137,7 +101,6 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t region; dns_name_t rmail; dns_name_t email; - dns_result_t result; REQUIRE(rdata->type == 14); @@ -149,16 +112,12 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_fromregion(&rmail, ®ion); isc_region_consume(®ion, rmail.length); - result = dns_name_towire(&rmail, cctx, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_towire(&rmail, cctx, target)); dns_name_fromregion(&rmail, ®ion); isc_region_consume(®ion, rmail.length); - result = dns_name_towire(&rmail, cctx, target); - - return (DNS_R_SUCCESS); + return (dns_name_towire(&rmail, cctx, target)); } static int @@ -177,7 +136,7 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { dns_name_init(&name2, NULL); dns_rdata_toregion(rdata1, ®ion1); - dns_rdata_toregion(rdata2, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); dns_name_fromregion(&name1, ®ion1); dns_name_fromregion(&name2, ®ion2); @@ -186,8 +145,8 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { if (result != 0) return (result); - isc_region_consume(®ion1, name1.length); - isc_region_consume(®ion2, name2.length); + isc_region_consume(®ion1, name_length(&name1)); + isc_region_consume(®ion2, name_length(&name2)); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); diff --git a/lib/dns/rdata/generic/mr_9.c b/lib/dns/rdata/generic/mr_9.c index 8227793410..801ea62b44 100644 --- a/lib/dns/rdata/generic/mr_9.c +++ b/lib/dns/rdata/generic/mr_9.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mr_9.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ + /* $Id: mr_9.c,v 1.5 1999/01/22 00:36:57 marka Exp $ */ #ifndef RDATA_GENERIC_MR_9_H #define RDATA_GENERIC_MR_9_H @@ -27,21 +27,12 @@ fromtext_mr(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 9); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/mr_9.h b/lib/dns/rdata/generic/mr_9.h index 8dd68cc5bf..ca9a6df985 100644 --- a/lib/dns/rdata/generic/mr_9.h +++ b/lib/dns/rdata/generic/mr_9.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mr_9.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ + /* $Id: mr_9.h,v 1.5 1999/01/22 00:36:57 marka Exp $ */ #ifndef RDATA_GENERIC_MR_9_H #define RDATA_GENERIC_MR_9_H @@ -27,21 +27,12 @@ fromtext_mr(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 9); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index c0dff1e646..63bb74edd0 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mx_15.c,v 1.7 1999/01/21 06:02:14 marka Exp $ */ + /* $Id: mx_15.c,v 1.8 1999/01/22 00:36:57 marka Exp $ */ #ifndef RDATA_GENERIC_MX_15_H #define RDATA_GENERIC_MX_15_H @@ -27,38 +27,16 @@ fromtext_mx(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - dns_result_t result; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 15); class = class; /*unused*/ - options |= ISC_LEXOPT_NUMBER; - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_number) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); - result = uint16_tobuffer(token.value.as_ulong, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); - options &= ~ISC_LEXOPT_NUMBER; - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -73,7 +51,6 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t name; dns_name_t prefix; isc_boolean_t sub; - dns_result_t result; char buf[sizeof "64000"]; unsigned short num; @@ -86,14 +63,8 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { num = uint16_fromregion(®ion); isc_region_consume(®ion, 2); sprintf(buf, "%u", num); - result = str_totext(buf, target); - if (result != DNS_R_SUCCESS) - return (result); - - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); dns_name_fromregion(&name, ®ion); sub = name_prefix(&name, origin, &prefix); return(dns_name_totext(&prefix, sub, target)); @@ -128,7 +99,6 @@ static dns_result_t towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - dns_result_t result; isc_region_t tr; REQUIRE(rdata->type == 15); @@ -144,8 +114,7 @@ towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_init(&name, NULL); dns_name_fromregion(&name, ®ion); - result = dns_name_towire(&name, cctx, target); - return (result); + return (dns_name_towire(&name, cctx, target)); } static int diff --git a/lib/dns/rdata/generic/mx_15.h b/lib/dns/rdata/generic/mx_15.h index cb7f6fa91e..d1cfdd8f42 100644 --- a/lib/dns/rdata/generic/mx_15.h +++ b/lib/dns/rdata/generic/mx_15.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mx_15.h,v 1.7 1999/01/21 06:02:14 marka Exp $ */ + /* $Id: mx_15.h,v 1.8 1999/01/22 00:36:57 marka Exp $ */ #ifndef RDATA_GENERIC_MX_15_H #define RDATA_GENERIC_MX_15_H @@ -27,38 +27,16 @@ fromtext_mx(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - dns_result_t result; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 15); class = class; /*unused*/ - options |= ISC_LEXOPT_NUMBER; - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_number) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); - result = uint16_tobuffer(token.value.as_ulong, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(uint16_tobuffer(token.value.as_ulong, target)); - options &= ~ISC_LEXOPT_NUMBER; - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -73,7 +51,6 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t name; dns_name_t prefix; isc_boolean_t sub; - dns_result_t result; char buf[sizeof "64000"]; unsigned short num; @@ -86,14 +63,8 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { num = uint16_fromregion(®ion); isc_region_consume(®ion, 2); sprintf(buf, "%u", num); - result = str_totext(buf, target); - if (result != DNS_R_SUCCESS) - return (result); - - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - + RETERR(str_totext(buf, target)); + RETERR(str_totext(" ", target)); dns_name_fromregion(&name, ®ion); sub = name_prefix(&name, origin, &prefix); return(dns_name_totext(&prefix, sub, target)); @@ -128,7 +99,6 @@ static dns_result_t towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - dns_result_t result; isc_region_t tr; REQUIRE(rdata->type == 15); @@ -144,8 +114,7 @@ towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_init(&name, NULL); dns_name_fromregion(&name, ®ion); - result = dns_name_towire(&name, cctx, target); - return (result); + return (dns_name_towire(&name, cctx, target)); } static int diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index fecba0912d..7b969aa9f0 100644 --- a/lib/dns/rdata/generic/ns_2.c +++ b/lib/dns/rdata/generic/ns_2.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: ns_2.c,v 1.4 1999/01/20 05:20:22 marka Exp $ */ + /* $Id: ns_2.c,v 1.5 1999/01/22 00:36:57 marka Exp $ */ #ifndef RDATA_GENERIC_NS_2_H #define RDATA_GENERIC_NS_2_H @@ -27,21 +27,12 @@ fromtext_ns(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 2); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token,isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/ns_2.h b/lib/dns/rdata/generic/ns_2.h index 56ace09e08..e1afb269ed 100644 --- a/lib/dns/rdata/generic/ns_2.h +++ b/lib/dns/rdata/generic/ns_2.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: ns_2.h,v 1.4 1999/01/20 05:20:22 marka Exp $ */ + /* $Id: ns_2.h,v 1.5 1999/01/22 00:36:57 marka Exp $ */ #ifndef RDATA_GENERIC_NS_2_H #define RDATA_GENERIC_NS_2_H @@ -27,21 +27,12 @@ fromtext_ns(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 2); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token,isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c index 1993feb1d7..97ba5296ec 100644 --- a/lib/dns/rdata/generic/ptr_12.c +++ b/lib/dns/rdata/generic/ptr_12.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: ptr_12.c,v 1.4 1999/01/20 05:20:23 marka Exp $ */ + /* $Id: ptr_12.c,v 1.5 1999/01/22 00:36:58 marka Exp $ */ #ifndef RDATA_GENERIC_PTR_12_H #define RDATA_GENERIC_PTR_12_H @@ -27,21 +27,12 @@ fromtext_ptr(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 12); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/ptr_12.h b/lib/dns/rdata/generic/ptr_12.h index 8278e003f7..27cf29752a 100644 --- a/lib/dns/rdata/generic/ptr_12.h +++ b/lib/dns/rdata/generic/ptr_12.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: ptr_12.h,v 1.4 1999/01/20 05:20:23 marka Exp $ */ + /* $Id: ptr_12.h,v 1.5 1999/01/22 00:36:58 marka Exp $ */ #ifndef RDATA_GENERIC_PTR_12_H #define RDATA_GENERIC_PTR_12_H @@ -27,21 +27,12 @@ fromtext_ptr(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 12); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index 3ef8696e87..9085f2c487 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: soa_6.c,v 1.7 1999/01/21 06:02:14 marka Exp $ */ + /* $Id: soa_6.c,v 1.8 1999/01/22 00:36:58 marka Exp $ */ #ifndef RDATA_GENERIC_SOA_6_H #define RDATA_GENERIC_SOA_6_H @@ -27,65 +27,28 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - dns_result_t result; int i; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 6); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); + for (i = 0 ; i < 2 ; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + RETERR(dns_name_fromtext(&name, &buffer, origin, + downcase, target)); } - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region, - ISC_BUFFERTYPE_TEXT); - origin = (origin != NULL) ? origin : dns_rootname; - result = dns_name_fromtext(&name, &buffer, origin, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region, - ISC_BUFFERTYPE_TEXT); - origin = (origin != NULL) ? origin : dns_rootname; - result = dns_name_fromtext(&name, &buffer, origin, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - - options |= ISC_LEXOPT_NUMBER; for (i = 0; i < 5; i++) { - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_number) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } - - result = uint32_tobuffer(token.value.as_ulong, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(gettoken(lexer, &token, isc_tokentype_number, + ISC_FALSE)); + RETERR(uint32_tobuffer(token.value.as_ulong, target)); } return (DNS_R_SUCCESS); } @@ -96,7 +59,6 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t mname; dns_name_t rname; dns_name_t prefix; - dns_result_t result; isc_boolean_t sub; int i; @@ -115,33 +77,23 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_consume(&dregion, name_length(&rname)); sub = name_prefix(&mname, origin, &prefix); - result = dns_name_totext(&prefix, sub, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_totext(&prefix, sub, target)); - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); sub = name_prefix(&rname, origin, &prefix); - result = dns_name_totext(&prefix, sub, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_totext(&prefix, sub, target)); for (i = 0; i < 5 ; i++) { char buf[sizeof "2147483647"]; unsigned long num; - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); num = uint32_fromregion(&dregion); isc_region_consume(&dregion, 4); sprintf(buf, "%lu", num); - result = str_totext(buf, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(buf, target)); } return (DNS_R_SUCCESS); } @@ -152,7 +104,6 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t mname; dns_name_t rname; - dns_result_t result; isc_region_t sregion; isc_region_t tregion; @@ -163,13 +114,8 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type, dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); - result = dns_name_fromwire(&mname, source, dctx, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - - result = dns_name_fromwire(&rname, source, dctx, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_fromwire(&mname, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&rname, source, dctx, downcase, target)); isc_buffer_active(source, &sregion); isc_buffer_available(target, &tregion); @@ -191,7 +137,6 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t tregion; dns_name_t mname; dns_name_t rname; - dns_result_t result; REQUIRE(rdata->type == 6); @@ -201,15 +146,11 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_rdata_toregion(rdata, &sregion); dns_name_fromregion(&mname, &sregion); isc_region_consume(&sregion, name_length(&mname)); - result = dns_name_towire(&mname, cctx, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_towire(&mname, cctx, target)); dns_name_fromregion(&rname, &sregion); isc_region_consume(&sregion, name_length(&rname)); - result = dns_name_towire(&rname, cctx, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_towire(&rname, cctx, target)); isc_buffer_available(target, &tregion); if (tregion.length < 20) @@ -236,7 +177,7 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { dns_name_init(&name2, NULL); dns_rdata_toregion(rdata1, ®ion1); - dns_rdata_toregion(rdata2, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); dns_name_fromregion(&name1, ®ion1); dns_name_fromregion(&name2, ®ion2); @@ -245,8 +186,8 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { if (result != 0) return (result); - isc_region_consume(®ion1, name1.length); - isc_region_consume(®ion2, name2.length); + isc_region_consume(®ion1, name_length(&name1)); + isc_region_consume(®ion2, name_length(&name2)); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -258,14 +199,10 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { if (result != 0) return (result); - isc_region_consume(®ion1, name1.length); - isc_region_consume(®ion2, name2.length); + isc_region_consume(®ion1, name_length(&name1)); + isc_region_consume(®ion2, name_length(&name2)); - result = memcmp(region1.base, region2.base, 12); - if (result != 0) - return ((result < 0) ? -1 : 1); - - return (0); + return (compare_region(®ion1, ®ion2)); } static dns_result_t diff --git a/lib/dns/rdata/generic/soa_6.h b/lib/dns/rdata/generic/soa_6.h index fce614c8e7..1bcbc249e1 100644 --- a/lib/dns/rdata/generic/soa_6.h +++ b/lib/dns/rdata/generic/soa_6.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: soa_6.h,v 1.7 1999/01/21 06:02:14 marka Exp $ */ + /* $Id: soa_6.h,v 1.8 1999/01/22 00:36:58 marka Exp $ */ #ifndef RDATA_GENERIC_SOA_6_H #define RDATA_GENERIC_SOA_6_H @@ -27,65 +27,28 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; - dns_result_t result; int i; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 6); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); + for (i = 0 ; i < 2 ; i++) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_FALSE)); + + dns_name_init(&name, NULL); + buffer_fromregion(&buffer, &token.value.as_region, + ISC_BUFFERTYPE_TEXT); + origin = (origin != NULL) ? origin : dns_rootname; + RETERR(dns_name_fromtext(&name, &buffer, origin, + downcase, target)); } - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region, - ISC_BUFFERTYPE_TEXT); - origin = (origin != NULL) ? origin : dns_rootname; - result = dns_name_fromtext(&name, &buffer, origin, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region, - ISC_BUFFERTYPE_TEXT); - origin = (origin != NULL) ? origin : dns_rootname; - result = dns_name_fromtext(&name, &buffer, origin, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - - options |= ISC_LEXOPT_NUMBER; for (i = 0; i < 5; i++) { - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_number) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } - - result = uint32_tobuffer(token.value.as_ulong, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(gettoken(lexer, &token, isc_tokentype_number, + ISC_FALSE)); + RETERR(uint32_tobuffer(token.value.as_ulong, target)); } return (DNS_R_SUCCESS); } @@ -96,7 +59,6 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t mname; dns_name_t rname; dns_name_t prefix; - dns_result_t result; isc_boolean_t sub; int i; @@ -115,33 +77,23 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_consume(&dregion, name_length(&rname)); sub = name_prefix(&mname, origin, &prefix); - result = dns_name_totext(&prefix, sub, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_totext(&prefix, sub, target)); - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); sub = name_prefix(&rname, origin, &prefix); - result = dns_name_totext(&prefix, sub, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_totext(&prefix, sub, target)); for (i = 0; i < 5 ; i++) { char buf[sizeof "2147483647"]; unsigned long num; - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); num = uint32_fromregion(&dregion); isc_region_consume(&dregion, 4); sprintf(buf, "%lu", num); - result = str_totext(buf, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(buf, target)); } return (DNS_R_SUCCESS); } @@ -152,7 +104,6 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t mname; dns_name_t rname; - dns_result_t result; isc_region_t sregion; isc_region_t tregion; @@ -163,13 +114,8 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type, dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); - result = dns_name_fromwire(&mname, source, dctx, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); - - result = dns_name_fromwire(&rname, source, dctx, downcase, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_fromwire(&mname, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&rname, source, dctx, downcase, target)); isc_buffer_active(source, &sregion); isc_buffer_available(target, &tregion); @@ -191,7 +137,6 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t tregion; dns_name_t mname; dns_name_t rname; - dns_result_t result; REQUIRE(rdata->type == 6); @@ -201,15 +146,11 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_rdata_toregion(rdata, &sregion); dns_name_fromregion(&mname, &sregion); isc_region_consume(&sregion, name_length(&mname)); - result = dns_name_towire(&mname, cctx, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_towire(&mname, cctx, target)); dns_name_fromregion(&rname, &sregion); isc_region_consume(&sregion, name_length(&rname)); - result = dns_name_towire(&rname, cctx, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(dns_name_towire(&rname, cctx, target)); isc_buffer_available(target, &tregion); if (tregion.length < 20) @@ -236,7 +177,7 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { dns_name_init(&name2, NULL); dns_rdata_toregion(rdata1, ®ion1); - dns_rdata_toregion(rdata2, ®ion1); + dns_rdata_toregion(rdata2, ®ion2); dns_name_fromregion(&name1, ®ion1); dns_name_fromregion(&name2, ®ion2); @@ -245,8 +186,8 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { if (result != 0) return (result); - isc_region_consume(®ion1, name1.length); - isc_region_consume(®ion2, name2.length); + isc_region_consume(®ion1, name_length(&name1)); + isc_region_consume(®ion2, name_length(&name2)); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -258,14 +199,10 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { if (result != 0) return (result); - isc_region_consume(®ion1, name1.length); - isc_region_consume(®ion2, name2.length); + isc_region_consume(®ion1, name_length(&name1)); + isc_region_consume(®ion2, name_length(&name2)); - result = memcmp(region1.base, region2.base, 12); - if (result != 0) - return ((result < 0) ? -1 : 1); - - return (0); + return (compare_region(®ion1, ®ion2)); } static dns_result_t diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index e84a1a55e7..64edccec46 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.5 1999/01/20 05:20:24 marka Exp $ */ + /* $Id: txt_16.c,v 1.6 1999/01/22 00:36:58 marka Exp $ */ #ifndef RDATA_GENERIC_TXT_16_H #define RDATA_GENERIC_TXT_16_H @@ -25,8 +25,6 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - dns_result_t result; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 16); @@ -34,14 +32,12 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - while (token.type == isc_tokentype_string) { - result = txt_fromtext(&token.value.as_textregion, target); - if (result != DNS_R_SUCCESS) - return (result); - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); + while (1) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_TRUE)); + if (token.type != isc_tokentype_string) + break; + RETERR(txt_fromtext(&token.value.as_textregion, target)); } /* Let upper layer handle eol/eof. */ isc_lex_ungettoken(lexer, &token); @@ -51,7 +47,6 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, static dns_result_t totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; - dns_result_t result; REQUIRE(rdata->type == 16); @@ -60,14 +55,9 @@ totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_rdata_toregion(rdata, ®ion); while (region.length) { - result = txt_totext(®ion, target); - if (result != DNS_R_SUCCESS) - return (result); - if (region.length) { - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - } + RETERR(txt_totext(®ion, target)); + if (region.length) + RETERR(str_totext(" ", target)); } return (DNS_R_SUCCESS); @@ -112,22 +102,16 @@ towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { static int compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { - int l; - int result; + isc_region_t r1; + isc_region_t r2; REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->class == rdata2->class); - REQUIRE(rdata1->class == 16); + REQUIRE(rdata1->type == 16); - l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; - result = memcmp(rdata1->data, rdata2->data, l); - - if (result != 0) - result = (result < 0) ? -1 : 1; - else if (rdata1->length != rdata2->length) - result = (rdata1->length < rdata2->length) ? -1 : 1; - - return (result); + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); } static dns_result_t diff --git a/lib/dns/rdata/generic/txt_16.h b/lib/dns/rdata/generic/txt_16.h index 02ae74207b..7a62ef85de 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.5 1999/01/20 05:20:24 marka Exp $ */ + /* $Id: txt_16.h,v 1.6 1999/01/22 00:36:58 marka Exp $ */ #ifndef RDATA_GENERIC_TXT_16_H #define RDATA_GENERIC_TXT_16_H @@ -25,8 +25,6 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - dns_result_t result; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 16); @@ -34,14 +32,12 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - while (token.type == isc_tokentype_string) { - result = txt_fromtext(&token.value.as_textregion, target); - if (result != DNS_R_SUCCESS) - return (result); - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); + while (1) { + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_TRUE)); + if (token.type != isc_tokentype_string) + break; + RETERR(txt_fromtext(&token.value.as_textregion, target)); } /* Let upper layer handle eol/eof. */ isc_lex_ungettoken(lexer, &token); @@ -51,7 +47,6 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, static dns_result_t totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; - dns_result_t result; REQUIRE(rdata->type == 16); @@ -60,14 +55,9 @@ totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_rdata_toregion(rdata, ®ion); while (region.length) { - result = txt_totext(®ion, target); - if (result != DNS_R_SUCCESS) - return (result); - if (region.length) { - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - } + RETERR(txt_totext(®ion, target)); + if (region.length) + RETERR(str_totext(" ", target)); } return (DNS_R_SUCCESS); @@ -112,22 +102,16 @@ towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { static int compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { - int l; - int result; + isc_region_t r1; + isc_region_t r2; REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->class == rdata2->class); - REQUIRE(rdata1->class == 16); + REQUIRE(rdata1->type == 16); - l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; - result = memcmp(rdata1->data, rdata2->data, l); - - if (result != 0) - result = (result < 0) ? -1 : 1; - else if (rdata1->length != rdata2->length) - result = (rdata1->length < rdata2->length) ? -1 : 1; - - return (result); + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (compare_region(&r1, &r2)); } static dns_result_t diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index e8d425b089..de4f153d10 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: a_1.c,v 1.5 1999/01/20 05:20:24 marka Exp $ */ + /* $Id: a_1.c,v 1.6 1999/01/22 00:36:58 marka Exp $ */ #ifndef RDATA_IN_1_A_1_H #define RDATA_IN_1_A_1_H @@ -33,7 +33,6 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; struct in_addr addr; isc_region_t region; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 1); REQUIRE(class == 1); @@ -41,15 +40,7 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type, origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); if (inet_aton(token.value.as_pointer , &addr) != 1) return (DNS_R_UNEXPECTED); diff --git a/lib/dns/rdata/in_1/a_1.h b/lib/dns/rdata/in_1/a_1.h index 102f15cf05..1f7f93b0fd 100644 --- a/lib/dns/rdata/in_1/a_1.h +++ b/lib/dns/rdata/in_1/a_1.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: a_1.h,v 1.5 1999/01/20 05:20:24 marka Exp $ */ + /* $Id: a_1.h,v 1.6 1999/01/22 00:36:58 marka Exp $ */ #ifndef RDATA_IN_1_A_1_H #define RDATA_IN_1_A_1_H @@ -33,7 +33,6 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; struct in_addr addr; isc_region_t region; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; REQUIRE(type == 1); REQUIRE(class == 1); @@ -41,15 +40,7 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type, origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) - return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) { - isc_lex_ungettoken(lexer, &token); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) - return(DNS_R_UNEXPECTEDEND); - return (DNS_R_UNEXPECTED); - } + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); if (inet_aton(token.value.as_pointer , &addr) != 1) return (DNS_R_UNEXPECTED); diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 2a0112d311..97b63c0518 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: wks_11.c,v 1.1 1999/01/21 06:02:15 marka Exp $ */ + /* $Id: wks_11.c,v 1.2 1999/01/22 00:36:59 marka Exp $ */ #ifndef RDATA_IN_1_WKS_11_H #define RDATA_IN_1_WKS_11_H @@ -36,14 +36,13 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - dns_result_t result; isc_region_t region; struct in_addr addr; struct protoent *pe; struct servent *se; char *e; long proto; - unsigned char bm[8*1024]; + unsigned char bm[8*1024]; /* 64k bits */ long port; long maxport = -1; char *ps = NULL; @@ -56,9 +55,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, downcase = downcase; /*unused*/ /* IPv4 dotted quad */ - result = gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); isc_buffer_available(target, ®ion); if (inet_aton(token.value.as_pointer , &addr) != 1) @@ -69,9 +66,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_add(target, 4); /* protocol */ - result = gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); proto = strtol(token.value.as_pointer, &e, 10); if (*e == '\0') @@ -88,16 +83,13 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, else if (proto == IPPROTO_UDP) ps = "udp"; - result = uint16_tobuffer(proto, target); + RETERR(uint16_tobuffer(proto, target)); memset(bm, 0, sizeof bm); while (1) { - result = gettoken(lexer, &token, isc_tokentype_string, - ISC_TRUE); - if (result != DNS_R_SUCCESS) - return (result); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_TRUE)); + if (token.type != isc_tokentype_string) break; port = strtol(token.value.as_pointer, &e, 10); if (*e == '\0') @@ -124,7 +116,6 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t tr; unsigned short proto; char buf[sizeof "65535"]; - dns_result_t result; unsigned int i, j; REQUIRE(rdata->type == 11); @@ -140,30 +131,21 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { proto = uint16_fromregion(&sr); sprintf(buf, "%u", proto); - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - result = str_totext(buf, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); + RETERR(str_totext(buf, target)); isc_region_consume(&sr, 2); - result = str_totext(" (", target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" (", target)); + for (i = 0 ; i < sr.length ; i++) { if (sr.base[i] != 0) for (j = 0; j < 8; j++) if ((sr.base[i] & (0x80>>j)) != 0) { sprintf(buf, "%u", i * 8 + j); - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - result = str_totext(buf, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); + RETERR(str_totext(buf, target)); } } - result = str_totext(" )", target); + RETERR(str_totext(" )", target)); return (DNS_R_SUCCESS); } diff --git a/lib/dns/rdata/in_1/wks_11.h b/lib/dns/rdata/in_1/wks_11.h index a8b0868c85..312607a2a9 100644 --- a/lib/dns/rdata/in_1/wks_11.h +++ b/lib/dns/rdata/in_1/wks_11.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: wks_11.h,v 1.1 1999/01/21 06:02:15 marka Exp $ */ + /* $Id: wks_11.h,v 1.2 1999/01/22 00:36:59 marka Exp $ */ #ifndef RDATA_IN_1_WKS_11_H #define RDATA_IN_1_WKS_11_H @@ -36,14 +36,13 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - dns_result_t result; isc_region_t region; struct in_addr addr; struct protoent *pe; struct servent *se; char *e; long proto; - unsigned char bm[8*1024]; + unsigned char bm[8*1024]; /* 64k bits */ long port; long maxport = -1; char *ps = NULL; @@ -56,9 +55,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, downcase = downcase; /*unused*/ /* IPv4 dotted quad */ - result = gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); isc_buffer_available(target, ®ion); if (inet_aton(token.value.as_pointer , &addr) != 1) @@ -69,9 +66,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_add(target, 4); /* protocol */ - result = gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); proto = strtol(token.value.as_pointer, &e, 10); if (*e == '\0') @@ -88,16 +83,13 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, else if (proto == IPPROTO_UDP) ps = "udp"; - result = uint16_tobuffer(proto, target); + RETERR(uint16_tobuffer(proto, target)); memset(bm, 0, sizeof bm); while (1) { - result = gettoken(lexer, &token, isc_tokentype_string, - ISC_TRUE); - if (result != DNS_R_SUCCESS) - return (result); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) + RETERR(gettoken(lexer, &token, isc_tokentype_string, + ISC_TRUE)); + if (token.type != isc_tokentype_string) break; port = strtol(token.value.as_pointer, &e, 10); if (*e == '\0') @@ -124,7 +116,6 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t tr; unsigned short proto; char buf[sizeof "65535"]; - dns_result_t result; unsigned int i, j; REQUIRE(rdata->type == 11); @@ -140,30 +131,21 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { proto = uint16_fromregion(&sr); sprintf(buf, "%u", proto); - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - result = str_totext(buf, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); + RETERR(str_totext(buf, target)); isc_region_consume(&sr, 2); - result = str_totext(" (", target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" (", target)); + for (i = 0 ; i < sr.length ; i++) { if (sr.base[i] != 0) for (j = 0; j < 8; j++) if ((sr.base[i] & (0x80>>j)) != 0) { sprintf(buf, "%u", i * 8 + j); - result = str_totext(" ", target); - if (result != DNS_R_SUCCESS) - return (result); - result = str_totext(buf, target); - if (result != DNS_R_SUCCESS) - return (result); + RETERR(str_totext(" ", target)); + RETERR(str_totext(buf, target)); } } - result = str_totext(" )", target); + RETERR(str_totext(" )", target)); return (DNS_R_SUCCESS); }