2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 22:45:39 +00:00

fix text region typing

This commit is contained in:
Bob Halley
1999-01-02 21:20:03 +00:00
parent 903b7c030e
commit 8afa9d1fcb
6 changed files with 28 additions and 21 deletions

View File

@@ -50,7 +50,8 @@ main(int argc, char *argv[]) {
unsigned int tbytes; unsigned int tbytes;
dns_result_t result; dns_result_t result;
dns_name_t name, oname, compname; 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; dns_name_t *origin, *comp;
isc_boolean_t downcase = ISC_FALSE; isc_boolean_t downcase = ISC_FALSE;
@@ -61,7 +62,7 @@ main(int argc, char *argv[]) {
if (strcasecmp("none", argv[0]) == 0) if (strcasecmp("none", argv[0]) == 0)
origin = NULL; origin = NULL;
else { else {
source.base = (unsigned char *)argv[0]; source.base = argv[0];
source.length = strlen(argv[0]); source.length = strlen(argv[0]);
target.base = o; target.base = o;
target.length = 255; target.length = 255;
@@ -83,7 +84,7 @@ main(int argc, char *argv[]) {
if (strcasecmp("none", argv[0]) == 0) if (strcasecmp("none", argv[0]) == 0)
comp = NULL; comp = NULL;
else { else {
source.base = (unsigned char *)argv[1]; source.base = argv[1];
source.length = strlen(argv[1]); source.length = strlen(argv[1]);
target.base = c; target.base = c;
target.length = 255; target.length = 255;
@@ -102,7 +103,7 @@ main(int argc, char *argv[]) {
comp = NULL; comp = NULL;
while (gets(s) != NULL) { while (gets(s) != NULL) {
source.base = (unsigned char *)s; source.base = s;
source.length = strlen(s); source.length = strlen(s);
target.base = b; target.base = b;
target.length = 255; target.length = 255;
@@ -120,9 +121,9 @@ main(int argc, char *argv[]) {
printf("%s\n", dns_result_totext(result)); printf("%s\n", dns_result_totext(result));
if (result == 0) { if (result == 0) {
target.base = (unsigned char *)s; ttarget.base = s;
target.length = 1000; ttarget.length = sizeof s;
result = dns_name_totext(&name, 0, &target, &tbytes); result = dns_name_totext(&name, 0, &ttarget, &tbytes);
if (result == DNS_R_SUCCESS) { if (result == DNS_R_SUCCESS) {
printf("%.*s\n", (int)tbytes, s); printf("%.*s\n", (int)tbytes, s);
#ifndef QUIET #ifndef QUIET

View File

@@ -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_result_t dns_name_fromtext(dns_name_t *name,
dns_region_t *source, dns_textregion_t *source,
dns_name_t *origin, dns_name_t *origin,
dns_boolean_t downcase, dns_boolean_t downcase,
dns_region_t *target); dns_region_t *target);
@@ -459,7 +459,10 @@ dns_result_t dns_name_fromtext(dns_name_t *name,
* *
* Requires: * Requires:
* *
* 'source' and 'target' are valid regions. * 'source' is a valid text region.
*
* 'target' is a valid region.
*
* 'name' is a valid name. * 'name' is a valid name.
* *
* Ensures: * 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_result_t dns_name_totext(dns_name_t *name,
dns_boolean_t omit_final_dot, 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'. * 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: * Requires:
* 'name' is a valid name * 'name' is a valid name
* *
* 'target' is a valid buffer * 'target' is a valid text region
* *
* dns_name_countlabels(name) > 0 * dns_name_countlabels(name) > 0
* *

View File

@@ -21,14 +21,14 @@
#include <dns/types.h> #include <dns/types.h>
dns_result_t dns_rdataclass_fromtext(dns_rdataclass_t *class, 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. * Convert the text 'source' refers to into a DNS class.
* *
* Requires: * Requires:
* 'class' is a valid pointer. * 'class' is a valid pointer.
* *
* 'region' is a valid region. * 'source' is a valid text region.
* *
* Returns: * Returns:
* DNS_R_SUCCESS on success * 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_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'. * Put a textual representation of class 'class' into 'target'.
* *
* Requires: * Requires:
* 'class' is a valid pointer. * 'class' is a valid pointer.
* *
* 'region' is a valid region. * 'target' is a valid text region.
* *
* Ensures: * Ensures:
* If the result is success: * If the result is success:

View File

@@ -21,14 +21,14 @@
#include <dns/types.h> #include <dns/types.h>
dns_result_t dns_rdatatype_fromtext(dns_rdatatype_t *type, 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. * Convert the text 'source' refers to into a DNS rdata type.
* *
* Requires: * Requires:
* 'type' is a valid pointer. * 'type' is a valid pointer.
* *
* 'region' is a valid region. * 'source' is a valid text region.
* *
* Returns: * Returns:
* DNS_R_SUCCESS on success * 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_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); unsigned int *bytesp);
/* /*
* Put a textual representation of type 'type' into 'target'. * 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: * Requires:
* 'type' is a valid pointer. * 'type' is a valid pointer.
* *
* 'region' is a valid region. * 'target' is a valid text region.
* *
* Ensures: * Ensures:
* If the result is success: * If the result is success:

View File

@@ -34,6 +34,7 @@
typedef isc_boolean_t dns_boolean_t; typedef isc_boolean_t dns_boolean_t;
typedef isc_region_t dns_region_t; typedef isc_region_t dns_region_t;
typedef isc_textregion_t dns_textregion_t;
typedef dns_region_t dns_label_t; typedef dns_region_t dns_label_t;
typedef struct dns_name dns_name_t; typedef struct dns_name dns_name_t;
typedef struct dns_lex dns_lex_t; typedef struct dns_lex dns_lex_t;

View File

@@ -504,7 +504,7 @@ dns_name_toregion(dns_name_t *name, dns_region_t *r) {
dns_result_t 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_name_t *origin, dns_boolean_t downcase,
dns_region_t *target) dns_region_t *target)
{ {
@@ -956,7 +956,7 @@ dns_name_fromtext(dns_name_t *name, dns_region_t *source,
dns_result_t dns_result_t
dns_name_totext(dns_name_t *name, dns_boolean_t omit_final_dot, 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; unsigned char *ndata;
char *tdata; char *tdata;