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

Added dns_name_downcase

This commit is contained in:
Brian Wellington
1999-08-20 17:01:06 +00:00
parent 6ee1fca9b2
commit e22d03eb45
2 changed files with 57 additions and 0 deletions

View File

@@ -789,6 +789,16 @@ dns_result_t dns_name_totext(dns_name_t *name,
* DNS_R_NOSPACE
*/
void
dns_name_downcase(dns_name_t *name);
/*
* Convert all uppercase letters in name to lowercase.
*
* Requires:
*
* 'name' is a valid name that is not read-only.
*/
dns_result_t dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix,
dns_name_t *name, isc_buffer_t *target);
/*

View File

@@ -1724,6 +1724,53 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
return (DNS_R_SUCCESS);
}
void
dns_name_downcase(dns_name_t *name) {
unsigned char *ndata;
unsigned int nlen, count, bytes, labels;
REQUIRE(VALID_NAME(name));
REQUIRE((name->attributes & DNS_NAMEATTR_READONLY) == 0);
ndata = name->ndata;
nlen = name->length;
labels = name->labels;
while (labels > 0 && nlen > 0) {
labels--;
count = *ndata++;
nlen--;
if (count < 64) {
INSIST(nlen >= count);
while (count > 0) {
*ndata = maptolower[(*ndata)];
ndata++;
nlen--;
count--;
}
} else if (count == DNS_LABELTYPE_BITSTRING) {
INSIST(nlen > 0);
count = *ndata++;
if (count == 0)
count = 256;
nlen--;
bytes = count / 8;
if (count % 8 != 0)
bytes++;
INSIST(nlen >= bytes);
/* Skip this label */
nlen -= bytes;
ndata += bytes;
} else {
FATAL_ERROR(__FILE__, __LINE__,
"Unexpected label type %02x", count);
/* Does not return. */
}
}
}
static void
set_offsets(dns_name_t *name, unsigned char *offsets, isc_boolean_t set_labels,
isc_boolean_t set_length, isc_boolean_t set_absolute)