Commit 8afa9d1f authored by Bob Halley's avatar Bob Halley
Browse files

fix text region typing

parent 903b7c03
......@@ -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
......
......@@ -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
*
......
......@@ -21,14 +21,14 @@
#include <dns/types.h>
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:
......
......@@ -21,14 +21,14 @@
#include <dns/types.h>
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:
......
......@@ -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;
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment