1998-12-12 20:48:14 +00:00
|
|
|
/*
|
2016-06-27 14:56:38 +10:00
|
|
|
* Copyright (C) 1998-2001, 2003-2005, 2007, 2009, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
1998-12-12 20:48:14 +00:00
|
|
|
*/
|
1998-12-04 02:27:01 +00:00
|
|
|
|
2009-09-02 23:48:03 +00:00
|
|
|
/* $Id: name_test.c,v 1.43 2009/09/02 23:48:01 tbox Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
1998-12-12 19:25:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
1998-12-04 02:27:01 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
1999-10-06 20:07:25 +00:00
|
|
|
#include <isc/commandline.h>
|
2015-05-23 14:21:51 +02:00
|
|
|
#include <isc/print.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/string.h>
|
2000-04-28 02:12:16 +00:00
|
|
|
#include <isc/util.h>
|
1998-12-04 02:27:01 +00:00
|
|
|
|
1999-03-08 18:55:58 +00:00
|
|
|
#include <dns/fixedname.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/result.h>
|
1998-12-04 02:27:01 +00:00
|
|
|
|
|
|
|
static void
|
1998-12-13 23:45:21 +00:00
|
|
|
print_wirename(isc_region_t *name) {
|
1998-12-04 02:27:01 +00:00
|
|
|
unsigned char *ccurr, *cend;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-03-11 00:45:03 +00:00
|
|
|
if (name->length == 0) {
|
|
|
|
printf("<empty wire name>\n");
|
|
|
|
return;
|
|
|
|
}
|
1998-12-04 02:27:01 +00:00
|
|
|
ccurr = name->base;
|
|
|
|
cend = ccurr + name->length;
|
|
|
|
while (ccurr != cend)
|
|
|
|
printf("%02x ", *ccurr++);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2000-02-25 01:05:53 +00:00
|
|
|
static void
|
|
|
|
print_name(dns_name_t *name) {
|
|
|
|
isc_result_t result;
|
|
|
|
isc_buffer_t source;
|
|
|
|
isc_region_t r;
|
|
|
|
char s[1000];
|
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, s, sizeof(s));
|
2000-02-25 01:05:53 +00:00
|
|
|
if (dns_name_countlabels(name) > 0)
|
|
|
|
result = dns_name_totext(name, ISC_FALSE, &source);
|
|
|
|
else
|
2000-04-06 22:03:35 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_usedregion(&source, &r);
|
2000-02-25 01:05:53 +00:00
|
|
|
if (r.length > 0)
|
|
|
|
printf("%.*s\n", (int)r.length, r.base);
|
|
|
|
else
|
|
|
|
printf("<empty text name>\n");
|
|
|
|
} else
|
|
|
|
printf("error: %s\n", dns_result_totext(result));
|
|
|
|
}
|
|
|
|
|
1998-12-04 02:27:01 +00:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[]) {
|
|
|
|
char s[1000];
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-08-26 21:08:13 +00:00
|
|
|
dns_fixedname_t wname, wname2, oname, compname, downname;
|
1999-03-08 18:55:58 +00:00
|
|
|
isc_buffer_t source;
|
1999-01-06 05:42:42 +00:00
|
|
|
isc_region_t r;
|
2016-12-31 14:30:50 +11:00
|
|
|
dns_name_t *name, *comp, *down;
|
|
|
|
const dns_name_t *origin;
|
2009-09-01 00:22:28 +00:00
|
|
|
unsigned int downcase = 0;
|
1999-01-06 05:42:42 +00:00
|
|
|
size_t len;
|
1999-01-09 01:21:11 +00:00
|
|
|
isc_boolean_t quiet = ISC_FALSE;
|
1999-03-11 00:45:03 +00:00
|
|
|
isc_boolean_t concatenate = ISC_FALSE;
|
|
|
|
isc_boolean_t got_name = ISC_FALSE;
|
|
|
|
isc_boolean_t check_absolute = ISC_FALSE;
|
1999-08-12 07:52:09 +00:00
|
|
|
isc_boolean_t check_wildcard = ISC_FALSE;
|
1999-08-26 21:08:13 +00:00
|
|
|
isc_boolean_t test_downcase = ISC_FALSE;
|
|
|
|
isc_boolean_t inplace = ISC_FALSE;
|
2000-02-25 01:05:53 +00:00
|
|
|
isc_boolean_t want_split = ISC_FALSE;
|
2003-10-25 00:31:12 +00:00
|
|
|
unsigned int labels, split_label = 0;
|
2000-02-25 01:05:53 +00:00
|
|
|
dns_fixedname_t fprefix, fsuffix;
|
|
|
|
dns_name_t *prefix, *suffix;
|
1999-01-09 01:21:11 +00:00
|
|
|
int ch;
|
1998-12-04 02:27:01 +00:00
|
|
|
|
2000-02-25 01:05:53 +00:00
|
|
|
while ((ch = isc_commandline_parse(argc, argv, "acdiqs:w")) != -1) {
|
1999-01-09 01:21:11 +00:00
|
|
|
switch (ch) {
|
1999-03-11 00:45:03 +00:00
|
|
|
case 'a':
|
|
|
|
check_absolute = ISC_TRUE;
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
concatenate = ISC_TRUE;
|
|
|
|
break;
|
1999-08-26 21:08:13 +00:00
|
|
|
case 'd':
|
|
|
|
test_downcase = ISC_TRUE;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
inplace = ISC_TRUE;
|
|
|
|
break;
|
1999-01-09 01:21:11 +00:00
|
|
|
case 'q':
|
|
|
|
quiet = ISC_TRUE;
|
|
|
|
break;
|
2000-02-25 01:05:53 +00:00
|
|
|
case 's':
|
|
|
|
want_split = ISC_TRUE;
|
2003-10-25 00:31:12 +00:00
|
|
|
split_label = atoi(isc_commandline_argument);
|
2000-02-25 01:05:53 +00:00
|
|
|
break;
|
1999-08-12 07:52:09 +00:00
|
|
|
case 'w':
|
|
|
|
check_wildcard = ISC_TRUE;
|
|
|
|
break;
|
1999-01-09 01:21:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-06 20:07:25 +00:00
|
|
|
argc -= isc_commandline_index;
|
|
|
|
argv += isc_commandline_index;
|
1998-12-04 02:27:01 +00:00
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
if (strcasecmp("none", argv[0]) == 0)
|
|
|
|
origin = NULL;
|
|
|
|
else {
|
1999-01-06 05:42:42 +00:00
|
|
|
len = strlen(argv[0]);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, argv[0], len);
|
1999-01-06 05:42:42 +00:00
|
|
|
isc_buffer_add(&source, len);
|
1999-03-08 18:55:58 +00:00
|
|
|
dns_fixedname_init(&oname);
|
2016-12-31 14:30:50 +11:00
|
|
|
result = dns_name_fromtext(&oname.name, &source,
|
2009-09-01 00:22:28 +00:00
|
|
|
dns_rootname, 0, NULL);
|
1998-12-04 02:27:01 +00:00
|
|
|
if (result != 0) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"dns_name_fromtext() failed: %d\n",
|
|
|
|
result);
|
|
|
|
exit(1);
|
|
|
|
}
|
2016-12-31 14:30:50 +11:00
|
|
|
origin = &oname.name;
|
1998-12-04 02:27:01 +00:00
|
|
|
}
|
1999-03-11 00:45:03 +00:00
|
|
|
} else if (concatenate)
|
|
|
|
origin = NULL;
|
|
|
|
else
|
1998-12-04 02:27:01 +00:00
|
|
|
origin = dns_rootname;
|
|
|
|
|
1999-05-18 22:06:27 +00:00
|
|
|
if (argc >= 1) {
|
2000-11-22 00:14:55 +00:00
|
|
|
if (strcasecmp("none", argv[1]) == 0)
|
1998-12-04 02:27:01 +00:00
|
|
|
comp = NULL;
|
|
|
|
else {
|
2000-11-22 00:14:55 +00:00
|
|
|
len = strlen(argv[1]);
|
|
|
|
isc_buffer_init(&source, argv[1], len);
|
1999-01-06 05:42:42 +00:00
|
|
|
isc_buffer_add(&source, len);
|
1999-03-08 18:55:58 +00:00
|
|
|
dns_fixedname_init(&compname);
|
|
|
|
comp = &compname.name;
|
2009-09-01 00:22:28 +00:00
|
|
|
result = dns_name_fromtext(comp, &source, origin,
|
|
|
|
0, NULL);
|
1998-12-04 02:27:01 +00:00
|
|
|
if (result != 0) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"dns_name_fromtext() failed: %d\n",
|
|
|
|
result);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
comp = NULL;
|
|
|
|
|
1999-03-08 18:55:58 +00:00
|
|
|
dns_fixedname_init(&wname);
|
1999-04-27 00:05:33 +00:00
|
|
|
name = dns_fixedname_name(&wname);
|
1999-03-11 00:45:03 +00:00
|
|
|
dns_fixedname_init(&wname2);
|
2001-11-27 01:56:32 +00:00
|
|
|
while (fgets(s, sizeof(s), stdin) != NULL) {
|
1999-01-06 05:42:42 +00:00
|
|
|
len = strlen(s);
|
2005-03-16 22:22:31 +00:00
|
|
|
if (len > 0U && s[len - 1] == '\n') {
|
1999-04-27 00:05:33 +00:00
|
|
|
s[len - 1] = '\0';
|
|
|
|
len--;
|
|
|
|
}
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, s, len);
|
1999-01-06 05:42:42 +00:00
|
|
|
isc_buffer_add(&source, len);
|
1999-03-11 00:45:03 +00:00
|
|
|
|
2005-03-16 22:22:31 +00:00
|
|
|
if (len > 0U)
|
1999-03-11 00:45:03 +00:00
|
|
|
result = dns_name_fromtext(name, &source, origin,
|
|
|
|
downcase, NULL);
|
|
|
|
else {
|
1999-04-27 00:05:33 +00:00
|
|
|
if (name == dns_fixedname_name(&wname))
|
1999-03-11 00:45:03 +00:00
|
|
|
dns_fixedname_init(&wname);
|
|
|
|
else
|
|
|
|
dns_fixedname_init(&wname2);
|
2000-04-06 22:03:35 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
1999-03-11 00:45:03 +00:00
|
|
|
}
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1998-12-04 02:27:01 +00:00
|
|
|
printf("%s\n", dns_result_totext(result));
|
1999-04-27 00:05:33 +00:00
|
|
|
if (name == dns_fixedname_name(&wname))
|
|
|
|
dns_fixedname_init(&wname);
|
|
|
|
else
|
|
|
|
dns_fixedname_init(&wname2);
|
|
|
|
continue;
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-04-27 00:05:33 +00:00
|
|
|
if (check_absolute && dns_name_countlabels(name) > 0) {
|
|
|
|
if (dns_name_isabsolute(name))
|
|
|
|
printf("absolute\n");
|
|
|
|
else
|
|
|
|
printf("relative\n");
|
|
|
|
}
|
1999-08-12 07:52:09 +00:00
|
|
|
if (check_wildcard && dns_name_countlabels(name) > 0) {
|
|
|
|
if (dns_name_iswildcard(name))
|
|
|
|
printf("wildcard\n");
|
|
|
|
else
|
|
|
|
printf("not wildcard\n");
|
|
|
|
}
|
1999-04-27 00:05:33 +00:00
|
|
|
dns_name_toregion(name, &r);
|
|
|
|
if (!quiet) {
|
|
|
|
print_wirename(&r);
|
|
|
|
printf("%u labels, %u bytes.\n",
|
|
|
|
dns_name_countlabels(name), r.length);
|
|
|
|
}
|
1998-12-04 02:27:01 +00:00
|
|
|
|
1999-04-27 00:05:33 +00:00
|
|
|
if (concatenate) {
|
|
|
|
if (got_name) {
|
|
|
|
printf("Concatenating.\n");
|
|
|
|
result = dns_name_concatenate(&wname.name,
|
1999-03-11 00:45:03 +00:00
|
|
|
&wname2.name,
|
|
|
|
&wname2.name,
|
|
|
|
NULL);
|
1999-04-27 00:05:33 +00:00
|
|
|
name = &wname2.name;
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
1999-04-27 00:05:33 +00:00
|
|
|
if (check_absolute &&
|
1999-03-11 00:45:03 +00:00
|
|
|
dns_name_countlabels(name) > 0) {
|
1999-04-27 00:05:33 +00:00
|
|
|
if (dns_name_isabsolute(name))
|
|
|
|
printf("absolute\n");
|
|
|
|
else
|
|
|
|
printf("relative\n");
|
|
|
|
}
|
1999-08-12 07:52:09 +00:00
|
|
|
if (check_wildcard &&
|
|
|
|
dns_name_countlabels(name) > 0) {
|
|
|
|
if (dns_name_iswildcard(name))
|
|
|
|
printf("wildcard\n");
|
|
|
|
else
|
|
|
|
printf("not "
|
|
|
|
"wildcard\n");
|
|
|
|
}
|
1999-04-27 00:05:33 +00:00
|
|
|
dns_name_toregion(name, &r);
|
|
|
|
if (!quiet) {
|
|
|
|
print_wirename(&r);
|
|
|
|
printf("%u labels, "
|
|
|
|
"%u bytes.\n",
|
1999-03-11 00:45:03 +00:00
|
|
|
dns_name_countlabels(name),
|
1999-04-27 00:05:33 +00:00
|
|
|
r.length);
|
|
|
|
}
|
1999-03-11 00:45:03 +00:00
|
|
|
} else
|
1999-04-27 00:05:33 +00:00
|
|
|
printf("%s\n",
|
|
|
|
dns_result_totext(result));
|
|
|
|
got_name = ISC_FALSE;
|
1998-12-04 02:27:01 +00:00
|
|
|
} else
|
1999-04-27 00:05:33 +00:00
|
|
|
got_name = ISC_TRUE;
|
1998-12-04 02:27:01 +00:00
|
|
|
}
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, s, sizeof(s));
|
1999-04-27 00:05:33 +00:00
|
|
|
if (dns_name_countlabels(name) > 0)
|
|
|
|
result = dns_name_totext(name, ISC_FALSE, &source);
|
|
|
|
else
|
2000-04-06 22:03:35 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_usedregion(&source, &r);
|
1999-04-27 00:05:33 +00:00
|
|
|
if (r.length > 0)
|
|
|
|
printf("%.*s\n", (int)r.length, r.base);
|
|
|
|
else
|
|
|
|
printf("<empty text name>\n");
|
|
|
|
if (!quiet) {
|
|
|
|
printf("%u bytes.\n", source.used);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
printf("%s\n", dns_result_totext(result));
|
1998-12-04 02:27:01 +00:00
|
|
|
|
1999-08-26 21:08:13 +00:00
|
|
|
if (test_downcase) {
|
|
|
|
if (inplace) {
|
|
|
|
down = name;
|
|
|
|
} else {
|
|
|
|
dns_fixedname_init(&downname);
|
|
|
|
down = dns_fixedname_name(&downname);
|
|
|
|
}
|
|
|
|
result = dns_name_downcase(name, down, NULL);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
if (!quiet) {
|
|
|
|
dns_name_toregion(down, &r);
|
|
|
|
print_wirename(&r);
|
|
|
|
printf("%u labels, %u bytes.\n",
|
|
|
|
dns_name_countlabels(down),
|
|
|
|
r.length);
|
|
|
|
}
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, s, sizeof(s));
|
2000-02-25 01:05:53 +00:00
|
|
|
print_name(down);
|
1999-08-26 21:08:13 +00:00
|
|
|
}
|
|
|
|
|
1999-03-11 00:45:03 +00:00
|
|
|
if (comp != NULL && dns_name_countlabels(name) > 0) {
|
1999-02-16 08:19:18 +00:00
|
|
|
int order;
|
2003-10-25 00:31:12 +00:00
|
|
|
unsigned int nlabels;
|
1999-02-16 08:19:18 +00:00
|
|
|
dns_namereln_t namereln;
|
1998-12-04 02:27:01 +00:00
|
|
|
|
1999-03-08 18:55:58 +00:00
|
|
|
namereln = dns_name_fullcompare(name, comp, &order,
|
2003-10-25 00:31:12 +00:00
|
|
|
&nlabels);
|
1999-01-09 01:21:11 +00:00
|
|
|
if (!quiet) {
|
1999-02-16 08:19:18 +00:00
|
|
|
if (order < 0)
|
|
|
|
printf("<");
|
|
|
|
else if (order > 0)
|
|
|
|
printf(">");
|
1999-01-09 01:21:11 +00:00
|
|
|
else
|
1999-02-16 08:19:18 +00:00
|
|
|
printf("=");
|
|
|
|
switch (namereln) {
|
|
|
|
case dns_namereln_contains:
|
|
|
|
printf(", contains");
|
|
|
|
break;
|
|
|
|
case dns_namereln_subdomain:
|
|
|
|
printf(", subdomain");
|
|
|
|
break;
|
|
|
|
case dns_namereln_commonancestor:
|
|
|
|
printf(", common ancestor");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (namereln != dns_namereln_none &&
|
|
|
|
namereln != dns_namereln_equal)
|
2004-04-13 03:31:14 +00:00
|
|
|
printf(", nlabels = %u", nlabels);
|
1999-02-16 08:19:18 +00:00
|
|
|
printf("\n");
|
1999-01-09 01:21:11 +00:00
|
|
|
}
|
1999-05-18 22:06:27 +00:00
|
|
|
printf("dns_name_equal() returns %s\n",
|
|
|
|
dns_name_equal(name, comp) ? "TRUE" : "FALSE");
|
1999-01-09 00:34:18 +00:00
|
|
|
}
|
1999-03-11 00:45:03 +00:00
|
|
|
|
2003-10-25 00:31:12 +00:00
|
|
|
labels = dns_name_countlabels(name);
|
|
|
|
if (want_split && split_label < labels) {
|
2000-02-25 01:05:53 +00:00
|
|
|
dns_fixedname_init(&fprefix);
|
|
|
|
prefix = dns_fixedname_name(&fprefix);
|
|
|
|
dns_fixedname_init(&fsuffix);
|
|
|
|
suffix = dns_fixedname_name(&fsuffix);
|
2003-10-25 00:31:12 +00:00
|
|
|
printf("splitting at label %u: ", split_label);
|
|
|
|
dns_name_split(name, split_label, prefix, suffix);
|
|
|
|
printf("\n prefix = ");
|
|
|
|
print_name(prefix);
|
|
|
|
printf(" suffix = ");
|
|
|
|
print_name(suffix);
|
2000-02-25 01:05:53 +00:00
|
|
|
}
|
|
|
|
|
1999-03-11 00:45:03 +00:00
|
|
|
if (concatenate) {
|
|
|
|
if (got_name)
|
|
|
|
name = &wname2.name;
|
|
|
|
else
|
|
|
|
name = &wname.name;
|
|
|
|
}
|
1998-12-04 02:27:01 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1998-12-04 02:27:01 +00:00
|
|
|
return (0);
|
|
|
|
}
|