From 90e303b114e56db5809fdd19805243457fa43cd9 Mon Sep 17 00:00:00 2001 From: Olafur Gudmundsson Date: Sat, 5 Jan 2002 07:05:28 +0000 Subject: [PATCH] Adding function isc_region_compare and using in instead of compare_region in lib/dns --- CHANGES | 3 +++ lib/dns/rdata.c | 21 ++------------------- lib/dns/rdata/any_255/tsig_250.c | 4 ++-- lib/dns/rdata/generic/cert_37.c | 4 ++-- lib/dns/rdata/generic/gpos_27.c | 4 ++-- lib/dns/rdata/generic/hinfo_13.c | 4 ++-- lib/dns/rdata/generic/isdn_20.c | 4 ++-- lib/dns/rdata/generic/key_25.c | 4 ++-- lib/dns/rdata/generic/loc_29.c | 4 ++-- lib/dns/rdata/generic/null_10.c | 4 ++-- lib/dns/rdata/generic/nxt_30.c | 4 ++-- lib/dns/rdata/generic/opt_41.c | 4 ++-- lib/dns/rdata/generic/proforma.c | 4 ++-- lib/dns/rdata/generic/sig_24.c | 6 +++--- lib/dns/rdata/generic/soa_6.c | 4 ++-- lib/dns/rdata/generic/tkey_249.c | 4 ++-- lib/dns/rdata/generic/txt_16.c | 4 ++-- lib/dns/rdata/generic/unspec_103.c | 4 ++-- lib/dns/rdata/generic/x25_19.c | 4 ++-- lib/dns/rdata/in_1/a_1.c | 4 ++-- lib/dns/rdata/in_1/aaaa_28.c | 4 ++-- lib/dns/rdata/in_1/nsap_22.c | 4 ++-- lib/dns/rdata/in_1/wks_11.c | 4 ++-- lib/isc/buffer.c | 19 ++++++++++++++++++- lib/isc/include/isc/buffer.h | 16 +++++++++++++++- 25 files changed, 81 insertions(+), 64 deletions(-) diff --git a/CHANGES b/CHANGES index 21776243b0..1c6b95a877 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1171. [func] Added function isc_region_compare(), updated files in + lib/dns to use this function instead of local one. + 1170. [bug] Don't attempt to print the token when a I/O error occurs when parsing named.conf. [RT #2275] diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 4569f1751a..d058538016 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.c,v 1.156 2001/11/30 01:02:09 gson Exp $ */ +/* $Id: rdata.c,v 1.157 2002/01/05 07:05:05 ogud Exp $ */ #include #include @@ -152,9 +152,6 @@ uint8_fromregion(isc_region_t *region); static isc_result_t mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length); -static int -compare_region(isc_region_t *r1, isc_region_t *r2); - static int hexvalue(char value); @@ -449,7 +446,7 @@ dns_rdata_compare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - result = compare_region(&r1, &r2); + result = isc_region_compare(&r1, &r2); } return (result); } @@ -1625,20 +1622,6 @@ mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) { return (ISC_R_SUCCESS); } -static int -compare_region(isc_region_t *r1, isc_region_t *r2) { - unsigned int l; - int result; - - l = (r1->length < r2->length) ? r1->length : r2->length; - - if ((result = memcmp(r1->base, r2->base, l)) != 0) - return ((result < 0) ? -1 : 1); - else - return ((r1->length == r2->length) ? 0 : - (r1->length < r2->length) ? -1 : 1); -} - static int hexvalue(char value) { char *s; diff --git a/lib/dns/rdata/any_255/tsig_250.c b/lib/dns/rdata/any_255/tsig_250.c index 0ba9a60e91..d041ba435f 100644 --- a/lib/dns/rdata/any_255/tsig_250.c +++ b/lib/dns/rdata/any_255/tsig_250.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tsig_250.c,v 1.53 2001/11/27 01:55:32 gson Exp $ */ +/* $Id: tsig_250.c,v 1.54 2002/01/05 07:05:06 ogud Exp $ */ /* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */ @@ -350,7 +350,7 @@ compare_any_tsig(ARGS_COMPARE) { return (order); isc_region_consume(&r1, name_length(&name1)); isc_region_consume(&r2, name_length(&name2)); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/cert_37.c b/lib/dns/rdata/generic/cert_37.c index b98d494655..1aea535e86 100644 --- a/lib/dns/rdata/generic/cert_37.c +++ b/lib/dns/rdata/generic/cert_37.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cert_37.c,v 1.41 2001/11/27 01:55:35 gson Exp $ */ +/* $Id: cert_37.c,v 1.42 2002/01/05 07:05:07 ogud Exp $ */ /* Reviewed: Wed Mar 15 21:14:32 EST 2000 by tale */ @@ -161,7 +161,7 @@ compare_cert(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/gpos_27.c b/lib/dns/rdata/generic/gpos_27.c index 47851bbdc0..90bb16dc95 100644 --- a/lib/dns/rdata/generic/gpos_27.c +++ b/lib/dns/rdata/generic/gpos_27.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: gpos_27.c,v 1.33 2001/11/27 00:55:58 gson Exp $ */ +/* $Id: gpos_27.c,v 1.34 2002/01/05 07:05:08 ogud Exp $ */ /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */ @@ -109,7 +109,7 @@ compare_gpos(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index a8ca82051c..cd57697aa3 100644 --- a/lib/dns/rdata/generic/hinfo_13.c +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: hinfo_13.c,v 1.38 2001/11/27 00:56:00 gson Exp $ */ +/* $Id: hinfo_13.c,v 1.39 2002/01/05 07:05:10 ogud Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -101,7 +101,7 @@ compare_hinfo(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/isdn_20.c b/lib/dns/rdata/generic/isdn_20.c index f56ea00589..68879734fd 100644 --- a/lib/dns/rdata/generic/isdn_20.c +++ b/lib/dns/rdata/generic/isdn_20.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: isdn_20.c,v 1.30 2001/07/16 03:06:08 marka Exp $ */ +/* $Id: isdn_20.c,v 1.31 2002/01/05 07:05:11 ogud Exp $ */ /* Reviewed: Wed Mar 15 16:53:11 PST 2000 by bwelling */ @@ -110,7 +110,7 @@ compare_isdn(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/key_25.c b/lib/dns/rdata/generic/key_25.c index 9bcb186fb2..2c01ffd235 100644 --- a/lib/dns/rdata/generic/key_25.c +++ b/lib/dns/rdata/generic/key_25.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: key_25.c,v 1.42 2001/11/27 01:55:36 gson Exp $ */ +/* $Id: key_25.c,v 1.43 2002/01/05 07:05:12 ogud Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -176,7 +176,7 @@ compare_key(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 3f7391f1e5..43d6126963 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: loc_29.c,v 1.31 2001/11/27 00:56:01 gson Exp $ */ +/* $Id: loc_29.c,v 1.32 2002/01/05 07:05:13 ogud Exp $ */ /* Reviewed: Wed Mar 15 18:13:09 PST 2000 by explorer */ @@ -619,7 +619,7 @@ compare_loc(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/null_10.c b/lib/dns/rdata/generic/null_10.c index e7bec0c8f6..f349ef8889 100644 --- a/lib/dns/rdata/generic/null_10.c +++ b/lib/dns/rdata/generic/null_10.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: null_10.c,v 1.36 2001/09/10 23:47:25 marka Exp $ */ +/* $Id: null_10.c,v 1.37 2002/01/05 07:05:14 ogud Exp $ */ /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */ @@ -86,7 +86,7 @@ compare_null(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/nxt_30.c b/lib/dns/rdata/generic/nxt_30.c index 7660f8b574..9cc0da3e62 100644 --- a/lib/dns/rdata/generic/nxt_30.c +++ b/lib/dns/rdata/generic/nxt_30.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nxt_30.c,v 1.51 2001/11/27 01:55:38 gson Exp $ */ +/* $Id: nxt_30.c,v 1.52 2002/01/05 07:05:15 ogud Exp $ */ /* reviewed: Wed Mar 15 18:21:15 PST 2000 by brister */ @@ -193,7 +193,7 @@ compare_nxt(ARGS_COMPARE) { if (order != 0) return (order); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index c2d7a75209..8cc650d358 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: opt_41.c,v 1.25 2001/07/16 03:06:24 marka Exp $ */ +/* $Id: opt_41.c,v 1.26 2002/01/05 07:05:16 ogud Exp $ */ /* Reviewed: Thu Mar 16 14:06:44 PST 2000 by gson */ @@ -154,7 +154,7 @@ compare_opt(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/proforma.c b/lib/dns/rdata/generic/proforma.c index 2239356d8f..d831d63691 100644 --- a/lib/dns/rdata/generic/proforma.c +++ b/lib/dns/rdata/generic/proforma.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: proforma.c,v 1.30 2001/01/09 21:54:35 bwelling Exp $ */ +/* $Id: proforma.c,v 1.31 2002/01/05 07:05:17 ogud Exp $ */ #ifndef RDATA_GENERIC_#_#_C #define RDATA_GENERIC_#_#_C @@ -84,7 +84,7 @@ compare_#(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/sig_24.c b/lib/dns/rdata/generic/sig_24.c index 0b20e7f733..0bc9c324c0 100644 --- a/lib/dns/rdata/generic/sig_24.c +++ b/lib/dns/rdata/generic/sig_24.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sig_24.c,v 1.55 2001/11/27 01:55:40 gson Exp $ */ +/* $Id: sig_24.c,v 1.56 2002/01/05 07:05:18 ogud Exp $ */ /* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */ @@ -335,7 +335,7 @@ compare_sig(ARGS_COMPARE) { INSIST(r2.length > 18); r1.length = 18; r2.length = 18; - order = compare_region(&r1, &r2); + order = isc_region_compare(&r1, &r2); if (order != 0) return (order); @@ -354,7 +354,7 @@ compare_sig(ARGS_COMPARE) { isc_region_consume(&r1, name_length(&name1)); isc_region_consume(&r2, name_length(&name2)); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index f2efe00ad8..217ccadbcd 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: soa_6.c,v 1.55 2001/11/27 01:55:42 gson Exp $ */ +/* $Id: soa_6.c,v 1.56 2002/01/05 07:05:19 ogud Exp $ */ /* Reviewed: Thu Mar 16 15:18:32 PST 2000 by explorer */ @@ -255,7 +255,7 @@ compare_soa(ARGS_COMPARE) { isc_region_consume(®ion1, name_length(&name1)); isc_region_consume(®ion2, name_length(&name2)); - return (compare_region(®ion1, ®ion2)); + return (isc_region_compare(®ion1, ®ion2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/tkey_249.c b/lib/dns/rdata/generic/tkey_249.c index 424789914f..59dca1c411 100644 --- a/lib/dns/rdata/generic/tkey_249.c +++ b/lib/dns/rdata/generic/tkey_249.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tkey_249.c,v 1.49 2001/11/27 01:55:43 gson Exp $ */ +/* $Id: tkey_249.c,v 1.50 2002/01/05 07:05:20 ogud Exp $ */ /* * Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley. @@ -340,7 +340,7 @@ compare_tkey(ARGS_COMPARE) { return (order); isc_region_consume(&r1, name_length(&name1)); isc_region_consume(&r2, name_length(&name2)); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index 989f176306..3883a98932 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: txt_16.c,v 1.37 2001/07/16 03:06:33 marka Exp $ */ +/* $Id: txt_16.c,v 1.38 2002/01/05 07:05:21 ogud Exp $ */ /* Reviewed: Thu Mar 16 15:40:00 PST 2000 by bwelling */ @@ -119,7 +119,7 @@ compare_txt(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/unspec_103.c b/lib/dns/rdata/generic/unspec_103.c index 5db419a22d..5a2e6e538b 100644 --- a/lib/dns/rdata/generic/unspec_103.c +++ b/lib/dns/rdata/generic/unspec_103.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: unspec_103.c,v 1.29 2001/09/10 23:47:26 marka Exp $ */ +/* $Id: unspec_103.c,v 1.30 2002/01/05 07:05:22 ogud Exp $ */ #ifndef RDATA_GENERIC_UNSPEC_103_C #define RDATA_GENERIC_UNSPEC_103_C @@ -83,7 +83,7 @@ compare_unspec(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/x25_19.c b/lib/dns/rdata/generic/x25_19.c index 272c5695df..2e7c7fcb94 100644 --- a/lib/dns/rdata/generic/x25_19.c +++ b/lib/dns/rdata/generic/x25_19.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: x25_19.c,v 1.31 2001/07/16 03:06:36 marka Exp $ */ +/* $Id: x25_19.c,v 1.32 2002/01/05 07:05:24 ogud Exp $ */ /* Reviewed: Thu Mar 16 16:15:57 PST 2000 by bwelling */ @@ -103,7 +103,7 @@ compare_x25(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index e731e586eb..3b65ecaece 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a_1.c,v 1.46 2001/07/16 03:06:40 marka Exp $ */ +/* $Id: a_1.c,v 1.47 2002/01/05 07:05:25 ogud Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -127,7 +127,7 @@ compare_in_a(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/aaaa_28.c b/lib/dns/rdata/in_1/aaaa_28.c index d6089f3c98..e871c41d81 100644 --- a/lib/dns/rdata/in_1/aaaa_28.c +++ b/lib/dns/rdata/in_1/aaaa_28.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: aaaa_28.c,v 1.36 2001/07/16 03:06:41 marka Exp $ */ +/* $Id: aaaa_28.c,v 1.37 2002/01/05 07:05:26 ogud Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -128,7 +128,7 @@ compare_in_aaaa(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/nsap_22.c b/lib/dns/rdata/in_1/nsap_22.c index c5e39c9103..0478b783fb 100644 --- a/lib/dns/rdata/in_1/nsap_22.c +++ b/lib/dns/rdata/in_1/nsap_22.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsap_22.c,v 1.34 2001/11/27 01:55:48 gson Exp $ */ +/* $Id: nsap_22.c,v 1.35 2002/01/05 07:05:27 ogud Exp $ */ /* Reviewed: Fri Mar 17 10:41:07 PST 2000 by gson */ @@ -141,7 +141,7 @@ compare_in_nsap(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 64c7c2682e..d87cc0ee47 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: wks_11.c,v 1.46 2001/11/27 01:55:51 gson Exp $ */ +/* $Id: wks_11.c,v 1.47 2002/01/05 07:05:28 ogud Exp $ */ /* Reviewed: Fri Mar 17 15:01:49 PST 2000 by explorer */ @@ -229,7 +229,7 @@ compare_in_wks(ARGS_COMPARE) { dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); - return (compare_region(&r1, &r2)); + return (isc_region_compare(&r1, &r2)); } static inline isc_result_t diff --git a/lib/isc/buffer.c b/lib/isc/buffer.c index 743b1be0bb..05aba4ce43 100644 --- a/lib/isc/buffer.c +++ b/lib/isc/buffer.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: buffer.c,v 1.36 2001/01/09 21:55:56 bwelling Exp $ */ +/* $Id: buffer.c,v 1.37 2002/01/05 07:05:02 ogud Exp $ */ #include @@ -367,6 +367,23 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) { return (ISC_R_SUCCESS); } +int +isc_region_compare(isc_region_t *r1, isc_region_t *r2) { + unsigned int l; + int result; + + REQUIRE(r1 != NULL); + REQUIRE(r2 != NULL); + + l = (r1->length < r2->length) ? r1->length : r2->length; + + if ((result = memcmp(r1->base, r2->base, l)) != 0) + return ((result < 0) ? -1 : 1); + else + return ((r1->length == r2->length) ? 0 : + (r1->length < r2->length) ? -1 : 1); +} + isc_result_t isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer, unsigned int length) diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index a3527a47e4..45f2cde1fa 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: buffer.h,v 1.39 2001/02/07 01:36:12 bwelling Exp $ */ +/* $Id: buffer.h,v 1.40 2002/01/05 07:05:04 ogud Exp $ */ #ifndef ISC_BUFFER_H #define ISC_BUFFER_H 1 @@ -570,6 +570,20 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r); * ISC_R_NOSPACE The available region of 'b' is not * big enough. */ +int +isc_region_compare(isc_region_t *r1, isc_region_t *r2); +/* + * Compares the contents of two regions + * + * Requires: + * 'r1' is a valid region + * 'r2' is a valid region + * + * Returns: + * < 0 if r1 is lexicographicly less than r2 + * = 0 if r1 is lexicographicly identical to r2 + * > 0 if r1 is lexicographicly greater than r2 + */ ISC_LANG_ENDDECLS