From 8afa9d1fcbf58f514e59a94f626e57d3f928f67d Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Sat, 2 Jan 1999 21:20:03 +0000 Subject: [PATCH] fix text region typing --- bin/tests/name_test.c | 15 ++++++++------- lib/dns/include/dns/name.h | 11 +++++++---- lib/dns/include/dns/rdataclass.h | 9 +++++---- lib/dns/include/dns/rdatatype.h | 9 +++++---- lib/dns/include/dns/types.h | 1 + lib/dns/name.c | 4 ++-- 6 files changed, 28 insertions(+), 21 deletions(-) diff --git a/bin/tests/name_test.c b/bin/tests/name_test.c index 97e46b62df..a34c9ac918 100644 --- a/bin/tests/name_test.c +++ b/bin/tests/name_test.c @@ -50,7 +50,8 @@ main(int argc, char *argv[]) { unsigned int tbytes; dns_result_t result; dns_name_t name, oname, compname; - isc_region_t source, target, r; + dns_textregion_t source, ttarget; + dns_region_t target, r; dns_name_t *origin, *comp; isc_boolean_t downcase = ISC_FALSE; @@ -61,7 +62,7 @@ main(int argc, char *argv[]) { if (strcasecmp("none", argv[0]) == 0) origin = NULL; else { - source.base = (unsigned char *)argv[0]; + source.base = argv[0]; source.length = strlen(argv[0]); target.base = o; target.length = 255; @@ -83,7 +84,7 @@ main(int argc, char *argv[]) { if (strcasecmp("none", argv[0]) == 0) comp = NULL; else { - source.base = (unsigned char *)argv[1]; + source.base = argv[1]; source.length = strlen(argv[1]); target.base = c; target.length = 255; @@ -102,7 +103,7 @@ main(int argc, char *argv[]) { comp = NULL; while (gets(s) != NULL) { - source.base = (unsigned char *)s; + source.base = s; source.length = strlen(s); target.base = b; target.length = 255; @@ -120,9 +121,9 @@ main(int argc, char *argv[]) { printf("%s\n", dns_result_totext(result)); if (result == 0) { - target.base = (unsigned char *)s; - target.length = 1000; - result = dns_name_totext(&name, 0, &target, &tbytes); + ttarget.base = s; + ttarget.length = sizeof s; + result = dns_name_totext(&name, 0, &ttarget, &tbytes); if (result == DNS_R_SUCCESS) { printf("%.*s\n", (int)tbytes, s); #ifndef QUIET diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index eee051a0f8..4e8f6f8266 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -441,7 +441,7 @@ dns_result_t dns_name_towire(dns_name_t *name, */ dns_result_t dns_name_fromtext(dns_name_t *name, - dns_region_t *source, + dns_textregion_t *source, dns_name_t *origin, dns_boolean_t downcase, dns_region_t *target); @@ -459,7 +459,10 @@ dns_result_t dns_name_fromtext(dns_name_t *name, * * Requires: * - * 'source' and 'target' are valid regions. + * 'source' is a valid text region. + * + * 'target' is a valid region. + * * 'name' is a valid name. * * Ensures: @@ -486,7 +489,7 @@ dns_result_t dns_name_fromtext(dns_name_t *name, dns_result_t dns_name_totext(dns_name_t *name, dns_boolean_t omit_final_dot, - dns_region_t *target, unsigned int *bytesp); + dns_textregion_t *target, unsigned int *bytesp); /* * Convert 'name' into text format, storing the result in 'target'. * @@ -497,7 +500,7 @@ dns_result_t dns_name_totext(dns_name_t *name, * Requires: * 'name' is a valid name * - * 'target' is a valid buffer + * 'target' is a valid text region * * dns_name_countlabels(name) > 0 * diff --git a/lib/dns/include/dns/rdataclass.h b/lib/dns/include/dns/rdataclass.h index b14348e699..0b29f38e88 100644 --- a/lib/dns/include/dns/rdataclass.h +++ b/lib/dns/include/dns/rdataclass.h @@ -21,14 +21,14 @@ #include dns_result_t dns_rdataclass_fromtext(dns_rdataclass_t *class, - dns_region_t *source); + dns_textregion_t *source); /* * Convert the text 'source' refers to into a DNS class. * * Requires: * 'class' is a valid pointer. * - * 'region' is a valid region. + * 'source' is a valid text region. * * Returns: * DNS_R_SUCCESS on success @@ -37,14 +37,15 @@ dns_result_t dns_rdataclass_fromtext(dns_rdataclass_t *class, */ dns_result_t dns_rdataclass_totext(dns_rdataclass_t class, - dns_region_t *target, unsigned int *bytesp); + dns_textregion_t *target, + unsigned int *bytesp); /* * Put a textual representation of class 'class' into 'target'. * * Requires: * 'class' is a valid pointer. * - * 'region' is a valid region. + * 'target' is a valid text region. * * Ensures: * If the result is success: diff --git a/lib/dns/include/dns/rdatatype.h b/lib/dns/include/dns/rdatatype.h index c63d3e1769..615e41f30d 100644 --- a/lib/dns/include/dns/rdatatype.h +++ b/lib/dns/include/dns/rdatatype.h @@ -21,14 +21,14 @@ #include dns_result_t dns_rdatatype_fromtext(dns_rdatatype_t *type, - dns_region_t *source); + dns_textregion_t *source); /* * Convert the text 'source' refers to into a DNS rdata type. * * Requires: * 'type' is a valid pointer. * - * 'region' is a valid region. + * 'source' is a valid text region. * * Returns: * DNS_R_SUCCESS on success @@ -36,7 +36,8 @@ dns_result_t dns_rdatatype_fromtext(dns_rdatatype_t *type, * DNS_R_NOTIMPLEMENTED type is known, but not implemented */ -dns_result_t dns_rdatatype_totext(dns_rdatatype_t type, dns_region_t *target, +dns_result_t dns_rdatatype_totext(dns_rdatatype_t type, + dns_textregion_t *target, unsigned int *bytesp); /* * Put a textual representation of type 'type' into 'target'. @@ -44,7 +45,7 @@ dns_result_t dns_rdatatype_totext(dns_rdatatype_t type, dns_region_t *target, * Requires: * 'type' is a valid pointer. * - * 'region' is a valid region. + * 'target' is a valid text region. * * Ensures: * If the result is success: diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index a5978a7516..9fe868c69f 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -34,6 +34,7 @@ typedef isc_boolean_t dns_boolean_t; typedef isc_region_t dns_region_t; +typedef isc_textregion_t dns_textregion_t; typedef dns_region_t dns_label_t; typedef struct dns_name dns_name_t; typedef struct dns_lex dns_lex_t; diff --git a/lib/dns/name.c b/lib/dns/name.c index c440892378..ec0188b3c1 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -504,7 +504,7 @@ dns_name_toregion(dns_name_t *name, dns_region_t *r) { dns_result_t -dns_name_fromtext(dns_name_t *name, dns_region_t *source, +dns_name_fromtext(dns_name_t *name, dns_textregion_t *source, dns_name_t *origin, dns_boolean_t downcase, dns_region_t *target) { @@ -956,7 +956,7 @@ dns_name_fromtext(dns_name_t *name, dns_region_t *source, dns_result_t dns_name_totext(dns_name_t *name, dns_boolean_t omit_final_dot, - dns_region_t *target, unsigned int *bytesp) + dns_textregion_t *target, unsigned int *bytesp) { unsigned char *ndata; char *tdata;