2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Make -t and -c change command line parsing so that unprefixed class and types

are treated as hosts.
This commit is contained in:
Michael Sawyer
2000-10-02 16:16:50 +00:00
parent aea4345be8
commit a5e89a4493

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: dig.c,v 1.107 2000/09/30 00:09:57 mws Exp $ */ /* $Id: dig.c,v 1.108 2000/10/02 16:16:50 mws Exp $ */
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
@@ -847,7 +847,8 @@ plus_option(char *option, isc_boolean_t is_batchfile,
* ISC_TRUE returned if value was used * ISC_TRUE returned if value was used
*/ */
static isc_boolean_t static isc_boolean_t
dash_option(char *option, char *next, dig_lookup_t **lookup) dash_option(char *option, char *next, dig_lookup_t **lookup,
isc_boolean_t *open_type_class)
{ {
char cmd, *value, *ptr; char cmd, *value, *ptr;
isc_result_t result; isc_result_t result;
@@ -891,6 +892,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup)
specified_source = ISC_TRUE; specified_source = ISC_TRUE;
return (value_from_next); return (value_from_next);
case 'c': case 'c':
*open_type_class = ISC_FALSE;
tr.base = value; tr.base = value;
tr.length = strlen(value); tr.length = strlen(value);
result = dns_rdataclass_fromtext(&rdclass, result = dns_rdataclass_fromtext(&rdclass,
@@ -912,6 +914,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup)
port = atoi(value); port = atoi(value);
return (value_from_next); return (value_from_next);
case 't': case 't':
*open_type_class = ISC_FALSE;
if (strncasecmp(value, "ixfr=", 5) == 0) { if (strncasecmp(value, "ixfr=", 5) == 0) {
(*lookup)->rdtype = dns_rdatatype_ixfr; (*lookup)->rdtype = dns_rdatatype_ixfr;
(*lookup)->ixfr_serial = (*lookup)->ixfr_serial =
@@ -1013,6 +1016,7 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
dig_lookup_t *lookup = NULL; dig_lookup_t *lookup = NULL;
dns_rdatatype_t rdtype; dns_rdatatype_t rdtype;
dns_rdataclass_t rdclass; dns_rdataclass_t rdclass;
isc_boolean_t open_type_class = ISC_TRUE;
char batchline[MXNAME]; char batchline[MXNAME];
int bargc; int bargc;
char *bargv[16]; char *bargv[16];
@@ -1093,13 +1097,13 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
} else if (rv[0][0] == '-') { } else if (rv[0][0] == '-') {
if (rc <= 1) { if (rc <= 1) {
if (dash_option(&rv[0][1], NULL, if (dash_option(&rv[0][1], NULL,
&lookup)) { &lookup, &open_type_class)) {
rc--; rc--;
rv++; rv++;
} }
} else { } else {
if (dash_option(&rv[0][1], rv[1], if (dash_option(&rv[0][1], rv[1],
&lookup)) { &lookup, &open_type_class)) {
rc--; rc--;
rv++; rv++;
} }
@@ -1108,26 +1112,28 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
/* /*
* Anything which isn't an option * Anything which isn't an option
*/ */
tr.base = rv[0]; if (open_type_class) {
tr.length = strlen(rv[0]); tr.base = rv[0];
if (strncmp(rv[0], "ixfr=", 5) == 0) { tr.length = strlen(rv[0]);
lookup->rdtype = dns_rdatatype_ixfr; if (strncmp(rv[0], "ixfr=", 5) == 0) {
lookup->ixfr_serial = lookup->rdtype = dns_rdatatype_ixfr;
atoi(&rv[0][5]); lookup->ixfr_serial =
continue; atoi(&rv[0][5]);
} continue;
result = dns_rdatatype_fromtext(&rdtype, }
(isc_textregion_t *)&tr); result = dns_rdatatype_fromtext(&rdtype,
if ((result == ISC_R_SUCCESS) && (isc_textregion_t *)&tr);
(rdtype != dns_rdatatype_ixfr)) { if ((result == ISC_R_SUCCESS) &&
lookup->rdtype = rdtype; (rdtype != dns_rdatatype_ixfr)) {
continue; lookup->rdtype = rdtype;
} continue;
result = dns_rdataclass_fromtext(&rdclass, }
(isc_textregion_t *)&tr); result = dns_rdataclass_fromtext(&rdclass,
if (result == ISC_R_SUCCESS) { (isc_textregion_t *)&tr);
lookup->rdclass = rdclass; if (result == ISC_R_SUCCESS) {
continue; lookup->rdclass = rdclass;
continue;
}
} }
if (!config_only) { if (!config_only) {
lookup = clone_lookup(default_lookup, lookup = clone_lookup(default_lookup,