diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index 916d10ecfd..b35d1cc924 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THE SOFTWARE. */ - /* $Id: dnssec-keygen.c,v 1.2 1999/09/27 17:11:41 bwelling Exp $ */ + /* $Id: dnssec-keygen.c,v 1.3 1999/10/06 20:07:24 tale Exp $ */ #include @@ -23,9 +23,9 @@ #include #include #include -#include #include +#include #include #include #include @@ -57,8 +57,8 @@ main(int argc, char **argv) { else prog = strdup(++prog); -/* process input arguments */ - while ((ch = getopt(argc, argv, "achiuzn:s:p:D:H:R:d:Fg:"))!= EOF) { + while ((ch = isc_commandline_parse(argc, argv, + "achiuzn:s:p:D:H:R:d:Fg:")) != -1) { switch (ch) { case 'a': flags |= DNS_KEYTYPE_NOAUTH; @@ -70,8 +70,9 @@ main(int argc, char **argv) { rsa_exp=1; break; case 'g': - if (optarg != NULL && isdigit(optarg[0])) { - generator = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) { + generator = atoi(isc_commandline_argument); if (generator < 0) die("-g value is not positive"); } @@ -79,8 +80,9 @@ main(int argc, char **argv) { die("-g not followed by a number"); break; case 'p': - if (optarg != NULL && isdigit(optarg[0])) - protocol = atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + protocol = atoi(isc_commandline_argument); if (protocol < 0 || protocol > 255) die("-p value is not [0..15]"); else @@ -88,8 +90,9 @@ main(int argc, char **argv) { break; case 's': /* Default: not signatory key */ - if (optarg != NULL && isdigit(optarg[0])) { - int sign_val = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) { + int sign_val = atoi(isc_commandline_argument); if (sign_val < 0 || sign_val > 15) die("-s value is not [0..15] "); flags |= sign_val; @@ -115,8 +118,9 @@ main(int argc, char **argv) { case 'H': if (alg > 0) die("Only one alg can be specified"); - if (optarg != NULL && isdigit(optarg[0])) - size = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + size = atoi(isc_commandline_argument); else die("-H requires a size"); alg = DST_ALG_HMACMD5; @@ -124,8 +128,9 @@ main(int argc, char **argv) { case 'R': if (alg > 0) die("Only one alg can be specified"); - if (optarg != NULL && isdigit(optarg[0])) - size = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + size = atoi(isc_commandline_argument); else die("-R requires a size"); alg = DNS_KEYALG_RSA; @@ -133,8 +138,9 @@ main(int argc, char **argv) { case 'D': if (alg > 0) die("Only one alg can be specified"); - if (optarg != NULL && isdigit(optarg[0])) - size = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + size = atoi(isc_commandline_argument); else die("-D requires a size"); alg = DNS_KEYALG_DSA; @@ -142,8 +148,9 @@ main(int argc, char **argv) { case 'd': if (alg > 0) die("Only one alg can be specified"); - if (optarg != NULL && isdigit(optarg[0])) - size = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + size = atoi(isc_commandline_argument); else die("-d requires a size"); alg = DNS_KEYALG_DH; @@ -154,7 +161,7 @@ main(int argc, char **argv) { } } - if (optind == argc) + if (isc_commandline_index == argc) usage(prog); if (alg < 0) @@ -197,12 +204,12 @@ main(int argc, char **argv) { else if (size < 0) die("No key size specified"); - name = argv[optind++]; - if (argc > optind) - zonefile = argv[optind]; + name = argv[isc_commandline_index++]; + if (argc > isc_commandline_index) + zonefile = argv[isc_commandline_index]; if (name[strlen(name) - 1] != '.' && alg != DST_ALG_HMACMD5) { name = isc_mem_get(mctx, strlen(name) + 2); - sprintf(name, "%s.", argv[optind - 1]); + sprintf(name, "%s.", argv[isc_commandline_index - 1]); printf("** Added a trailing dot to the name to make it" " fully qualified **\n"); } diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 7ce52aab9f..24af5503fc 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -20,10 +20,10 @@ #include #include #include -#include /* for getopt */ #include #include +#include #include #include #include @@ -760,50 +760,52 @@ main(int argc, char *argv[]) { signer_key_t *key; isc_result_t result; - extern char *optarg; - extern int optind; - dns_result_register(); result = isc_mem_create(0, 0, &mctx); check_result(result, "isc_mem_create()"); - while ((ch = getopt(argc, argv, "s:e:c:v:o:f:h")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, "s:e:c:v:o:f:h")) + != -1) { switch (ch) { case 's': - startstr = isc_mem_strdup(mctx, optarg); + startstr = isc_mem_strdup(mctx, + isc_commandline_argument); if (startstr == NULL) check_result(ISC_R_FAILURE, "isc_mem_strdup()"); break; case 'e': - endstr = isc_mem_strdup(mctx, optarg); + endstr = isc_mem_strdup(mctx, + isc_commandline_argument); if (endstr == NULL) check_result(ISC_R_FAILURE, "isc_mem_strdup()"); break; case 'c': endp = NULL; - cycle = strtol(optarg, &endp, 0); + cycle = strtol(isc_commandline_argument, &endp, 0); if (*endp != '\0') check_result(ISC_R_FAILURE, "strtol()"); break; case 'v': endp = NULL; - verbose = strtol(optarg, &endp, 0); + verbose = strtol(isc_commandline_argument, &endp, 0); if (*endp != '\0') check_result(ISC_R_FAILURE, "strtol()"); break; case 'o': - origin = isc_mem_strdup(mctx, optarg); + origin = isc_mem_strdup(mctx, + isc_commandline_argument); if (origin == NULL) check_result(ISC_R_FAILURE, "isc_mem_strdup()"); break; case 'f': - output = isc_mem_strdup(mctx, optarg); + output = isc_mem_strdup(mctx, + isc_commandline_argument); if (output == NULL) check_result(ISC_R_FAILURE, "isc_mem_strdup()"); break; @@ -835,8 +837,8 @@ main(int argc, char *argv[]) { cycle = (end - start) / 4; } - argc -= optind; - argv += optind; + argc -= isc_commandline_index; + argv += isc_commandline_index; if (argc < 1) check_result(ISC_R_FAILURE, "No zones specified"); diff --git a/bin/tests/compress_test.c b/bin/tests/compress_test.c index d06f018bab..e74d2f3664 100644 --- a/bin/tests/compress_test.c +++ b/bin/tests/compress_test.c @@ -19,9 +19,9 @@ #include #include -#include #include +#include #include #include #include @@ -53,7 +53,7 @@ main(int argc, char *argv[]) { isc_region_t region; int c; - while ((c = getopt(argc, argv, "rv")) != -1) { + while ((c = isc_commandline_parse(argc, argv, "rv")) != -1) { switch (c) { case 'r': raw++; diff --git a/bin/tests/db_test.c b/bin/tests/db_test.c index 8bc54eb39d..5958080f2a 100644 --- a/bin/tests/db_test.c +++ b/bin/tests/db_test.c @@ -26,9 +26,9 @@ #include #include #include /* XXX Naughty. */ -#include /* XXX Naughty. */ #include +#include #include #include #include @@ -389,17 +389,18 @@ main(int argc, char *argv[]) { DNS_R_SUCCESS); strcpy(dbtype, "rbt"); - while ((ch = getopt(argc, argv, "c:d:t:z:P:Q:gpqvT")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, "c:d:t:z:P:Q:gpqvT")) + != -1) { switch (ch) { case 'c': - result = load(optarg, ".", ISC_TRUE); + result = load(isc_commandline_argument, ".", ISC_TRUE); if (result != DNS_R_SUCCESS) printf("cache load(%s) %08x: %s\n", - optarg, result, + isc_commandline_argument, result, isc_result_totext(result)); break; case 'd': - strcpy(dbtype, optarg); + strcpy(dbtype, isc_commandline_argument); break; case 'g': options |= (DNS_DBFIND_GLUEOK|DNS_DBFIND_VALIDATEGLUE); @@ -412,14 +413,14 @@ main(int argc, char *argv[]) { printnode = ISC_TRUE; break; case 'P': - pause_every = atoi(optarg); + pause_every = atoi(isc_commandline_argument); break; case 'Q': - memory_quota = atoi(optarg); + memory_quota = atoi(isc_commandline_argument); isc_mem_setquota(mctx, memory_quota); break; case 't': - type = atoi(optarg); + type = atoi(isc_commandline_argument); break; case 'T': time_lookups = ISC_TRUE; @@ -428,22 +429,23 @@ main(int argc, char *argv[]) { verbose = ISC_TRUE; break; case 'z': - origintext = strrchr(optarg, '/'); + origintext = strrchr(isc_commandline_argument, '/'); if (origintext == NULL) - origintext = optarg; + origintext = isc_commandline_argument; else origintext++; /* Skip '/'. */ - result = load(optarg, origintext, ISC_FALSE); + result = load(isc_commandline_argument, origintext, + ISC_FALSE); if (result != DNS_R_SUCCESS) printf("zone load(%s) %08x: %s\n", - optarg, result, + isc_commandline_argument, result, isc_result_totext(result)); break; } } - argc -= optind; - argv += optind; + argc -= isc_commandline_index; + argv += isc_commandline_index; if (argc != 0) printf("ignoring trailing arguments\n"); diff --git a/bin/tests/keygen.c b/bin/tests/keygen.c index 91440ce8b0..7660cedc01 100644 --- a/bin/tests/keygen.c +++ b/bin/tests/keygen.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THE SOFTWARE. */ - /* $Id: keygen.c,v 1.2 1999/09/27 17:11:41 bwelling Exp $ */ + /* $Id: keygen.c,v 1.3 1999/10/06 20:07:24 tale Exp $ */ #include @@ -23,9 +23,9 @@ #include #include #include -#include #include +#include #include #include #include @@ -57,8 +57,8 @@ main(int argc, char **argv) { else prog = strdup(++prog); -/* process input arguments */ - while ((ch = getopt(argc, argv, "achiuzn:s:p:D:H:R:d:Fg:"))!= EOF) { + while ((ch = isc_commandline_parse(argc, argv, + "achiuzn:s:p:D:H:R:d:Fg:")) != -1) { switch (ch) { case 'a': flags |= DNS_KEYTYPE_NOAUTH; @@ -70,8 +70,9 @@ main(int argc, char **argv) { rsa_exp=1; break; case 'g': - if (optarg != NULL && isdigit(optarg[0])) { - generator = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) { + generator = atoi(isc_commandline_argument); if (generator < 0) die("-g value is not positive"); } @@ -79,8 +80,9 @@ main(int argc, char **argv) { die("-g not followed by a number"); break; case 'p': - if (optarg != NULL && isdigit(optarg[0])) - protocol = atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + protocol = atoi(isc_commandline_argument); if (protocol < 0 || protocol > 255) die("-p value is not [0..15]"); else @@ -88,8 +90,9 @@ main(int argc, char **argv) { break; case 's': /* Default: not signatory key */ - if (optarg != NULL && isdigit(optarg[0])) { - int sign_val = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) { + int sign_val = atoi(isc_commandline_argument); if (sign_val < 0 || sign_val > 15) die("-s value is not [0..15] "); flags |= sign_val; @@ -115,8 +118,9 @@ main(int argc, char **argv) { case 'H': if (alg > 0) die("Only one alg can be specified"); - if (optarg != NULL && isdigit(optarg[0])) - size = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + size = atoi(isc_commandline_argument); else die("-H requires a size"); alg = DST_ALG_HMACMD5; @@ -124,8 +128,9 @@ main(int argc, char **argv) { case 'R': if (alg > 0) die("Only one alg can be specified"); - if (optarg != NULL && isdigit(optarg[0])) - size = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + size = atoi(isc_commandline_argument); else die("-R requires a size"); alg = DNS_KEYALG_RSA; @@ -133,8 +138,9 @@ main(int argc, char **argv) { case 'D': if (alg > 0) die("Only one alg can be specified"); - if (optarg != NULL && isdigit(optarg[0])) - size = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + size = atoi(isc_commandline_argument); else die("-D requires a size"); alg = DNS_KEYALG_DSA; @@ -142,8 +148,9 @@ main(int argc, char **argv) { case 'd': if (alg > 0) die("Only one alg can be specified"); - if (optarg != NULL && isdigit(optarg[0])) - size = (int) atoi(optarg); + if (isc_commandline_argument != NULL && + isdigit(isc_commandline_argument[0])) + size = atoi(isc_commandline_argument); else die("-d requires a size"); alg = DNS_KEYALG_DH; @@ -154,7 +161,7 @@ main(int argc, char **argv) { } } - if (optind == argc) + if (isc_commandline_index == argc) usage(prog); if (alg < 0) @@ -197,12 +204,12 @@ main(int argc, char **argv) { else if (size < 0) die("No key size specified"); - name = argv[optind++]; - if (argc > optind) - zonefile = argv[optind]; + name = argv[isc_commandline_index++]; + if (argc > isc_commandline_index) + zonefile = argv[isc_commandline_index]; if (name[strlen(name) - 1] != '.' && alg != DST_ALG_HMACMD5) { name = isc_mem_get(mctx, strlen(name) + 2); - sprintf(name, "%s.", argv[optind - 1]); + sprintf(name, "%s.", argv[isc_commandline_index - 1]); printf("** Added a trailing dot to the name to make it" " fully qualified **\n"); } diff --git a/bin/tests/lex_test.c b/bin/tests/lex_test.c index eb3bb84123..a8edd335a8 100644 --- a/bin/tests/lex_test.c +++ b/bin/tests/lex_test.c @@ -20,9 +20,9 @@ #include #include #include -#include #include +#include #include #include @@ -82,7 +82,7 @@ main(int argc, char *argv[]) { unsigned int options = 0; int done = 0; - while ((c = getopt(argc, argv, "qmcs")) != -1) { + while ((c = isc_commandline_parse(argc, argv, "qmcs")) != -1) { switch (c) { case 'q': quiet = 1; diff --git a/bin/tests/log_test.c b/bin/tests/log_test.c index 74ffc632df..06d7bacb00 100644 --- a/bin/tests/log_test.c +++ b/bin/tests/log_test.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: log_test.c,v 1.2 1999/09/23 23:56:35 halley Exp $ */ +/* $Id: log_test.c,v 1.3 1999/10/06 20:07:24 tale Exp $ */ /* Principal Authors: DCL */ @@ -23,7 +23,7 @@ #include #include -#include /* XXX Naughty. */ +#include #include #include #include @@ -67,16 +67,16 @@ main (int argc, char **argv) { syslog_file = SYSLOG_FILE; file_versions = FILE_VERSIONS; - while ((ch = getopt(argc, argv, "ms:r:")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, "ms:r:")) != -1) { switch (ch) { case 'm': show_final_mem = ISC_TRUE; break; case 's': - syslog_file = optarg; + syslog_file = isc_commandline_argument; break; case 'r': - file_versions = atoi(optarg); + file_versions = atoi(isc_commandline_argument); if (file_versions < 0 && file_versions != ISC_LOG_ROLLNEVER && file_versions != ISC_LOG_ROLLINFINITE) { @@ -93,8 +93,8 @@ main (int argc, char **argv) { } } - argc -= optind; - argv += optind; + argc -= isc_commandline_index; + argv += isc_commandline_index; fprintf(stderr, "==> stderr begin\n"); isc_log_opensyslog(progname, LOG_PID, LOG_DAEMON); diff --git a/bin/tests/name_test.c b/bin/tests/name_test.c index 646f0e5992..e3c2f48f00 100644 --- a/bin/tests/name_test.c +++ b/bin/tests/name_test.c @@ -21,9 +21,9 @@ #include #include #include -#include #include +#include #include #include @@ -66,7 +66,7 @@ main(int argc, char *argv[]) { isc_boolean_t inplace = ISC_FALSE; int ch; - while ((ch = getopt(argc, argv, "acdiqw")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, "acdiqw")) != -1) { switch (ch) { case 'a': check_absolute = ISC_TRUE; @@ -89,8 +89,8 @@ main(int argc, char *argv[]) { } } - argc -= optind; - argv += optind; + argc -= isc_commandline_index; + argv += isc_commandline_index; if (argc > 0) { if (strcasecmp("none", argv[0]) == 0) diff --git a/bin/tests/rbt_test.c b/bin/tests/rbt_test.c index ff4e42c1b0..fd2bd81dbb 100644 --- a/bin/tests/rbt_test.c +++ b/bin/tests/rbt_test.c @@ -19,8 +19,8 @@ #include #include #include -#include +#include #include #include @@ -271,7 +271,7 @@ main (int argc, char **argv) { else progname = *argv; - while ((ch = getopt(argc, argv, "m")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, "m")) != -1) { switch (ch) { case 'm': show_final_mem = ISC_TRUE; @@ -279,8 +279,8 @@ main (int argc, char **argv) { } } - argc -= optind; - argv += optind; + argc -= isc_commandline_index; + argv += isc_commandline_index; if (argc > 1) { printf("Usage: %s [-m]\n", progname); diff --git a/bin/tests/rdata_test.c b/bin/tests/rdata_test.c index 0eaba314b5..a83faae7a8 100644 --- a/bin/tests/rdata_test.c +++ b/bin/tests/rdata_test.c @@ -20,11 +20,12 @@ #include #include #include -#include #include +#include #include #include + #include #include #include @@ -67,7 +68,7 @@ main(int argc, char *argv[]) { int first = 1; int raw = 0; - while ((c = getopt(argc, argv, "dqswtarz")) != -1) { + while ((c = isc_commandline_parse(argc, argv, "dqswtarz")) != -1) { switch (c) { case 'd': debug = 1; diff --git a/bin/tests/res_test.c b/bin/tests/res_test.c index 08a0196bc8..f0b3ad5323 100644 --- a/bin/tests/res_test.c +++ b/bin/tests/res_test.c @@ -24,9 +24,9 @@ #include #include #include -#include /* XXX Naughty. */ #include +#include #include #include #include @@ -156,13 +156,13 @@ main(int argc, char *argv[]) { mctx = NULL; RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); - while ((ch = getopt(argc, argv, "vw:")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, "vw:")) != -1) { switch (ch) { case 'v': verbose = ISC_TRUE; break; case 'w': - workers = (unsigned int)atoi(optarg); + workers = (unsigned int)atoi(isc_commandline_argument); break; } } @@ -189,8 +189,8 @@ main(int argc, char *argv[]) { RUNTIME_CHECK(dns_tsig_init(mctx) == ISC_R_SUCCESS); - argc -= optind; - argv += optind; + argc -= isc_commandline_index; + argv += isc_commandline_index; if (argc != 0) printf("ignoring trailing arguments\n"); diff --git a/bin/tests/signer.c b/bin/tests/signer.c index 7ce52aab9f..24af5503fc 100644 --- a/bin/tests/signer.c +++ b/bin/tests/signer.c @@ -20,10 +20,10 @@ #include #include #include -#include /* for getopt */ #include #include +#include #include #include #include @@ -760,50 +760,52 @@ main(int argc, char *argv[]) { signer_key_t *key; isc_result_t result; - extern char *optarg; - extern int optind; - dns_result_register(); result = isc_mem_create(0, 0, &mctx); check_result(result, "isc_mem_create()"); - while ((ch = getopt(argc, argv, "s:e:c:v:o:f:h")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, "s:e:c:v:o:f:h")) + != -1) { switch (ch) { case 's': - startstr = isc_mem_strdup(mctx, optarg); + startstr = isc_mem_strdup(mctx, + isc_commandline_argument); if (startstr == NULL) check_result(ISC_R_FAILURE, "isc_mem_strdup()"); break; case 'e': - endstr = isc_mem_strdup(mctx, optarg); + endstr = isc_mem_strdup(mctx, + isc_commandline_argument); if (endstr == NULL) check_result(ISC_R_FAILURE, "isc_mem_strdup()"); break; case 'c': endp = NULL; - cycle = strtol(optarg, &endp, 0); + cycle = strtol(isc_commandline_argument, &endp, 0); if (*endp != '\0') check_result(ISC_R_FAILURE, "strtol()"); break; case 'v': endp = NULL; - verbose = strtol(optarg, &endp, 0); + verbose = strtol(isc_commandline_argument, &endp, 0); if (*endp != '\0') check_result(ISC_R_FAILURE, "strtol()"); break; case 'o': - origin = isc_mem_strdup(mctx, optarg); + origin = isc_mem_strdup(mctx, + isc_commandline_argument); if (origin == NULL) check_result(ISC_R_FAILURE, "isc_mem_strdup()"); break; case 'f': - output = isc_mem_strdup(mctx, optarg); + output = isc_mem_strdup(mctx, + isc_commandline_argument); if (output == NULL) check_result(ISC_R_FAILURE, "isc_mem_strdup()"); break; @@ -835,8 +837,8 @@ main(int argc, char *argv[]) { cycle = (end - start) / 4; } - argc -= optind; - argv += optind; + argc -= isc_commandline_index; + argv += isc_commandline_index; if (argc < 1) check_result(ISC_R_FAILURE, "No zones specified"); diff --git a/bin/tests/sym_test.c b/bin/tests/sym_test.c index f021d7712f..f59c3d0c32 100644 --- a/bin/tests/sym_test.c +++ b/bin/tests/sym_test.c @@ -20,9 +20,9 @@ #include #include #include -#include #include +#include #include #include #include @@ -52,7 +52,7 @@ main(int argc, char *argv[]) { isc_symexists_t exists_policy = isc_symexists_reject; isc_boolean_t case_sensitive = ISC_FALSE; - while ((c = getopt(argc, argv, "tarc")) != -1) { + while ((c = isc_commandline_parse(argc, argv, "tarc")) != -1) { switch (c) { case 't': trace = 1; diff --git a/bin/tests/zone_test.c b/bin/tests/zone_test.c index aaf245e9fc..3db87cb493 100644 --- a/bin/tests/zone_test.c +++ b/bin/tests/zone_test.c @@ -18,8 +18,8 @@ #include #include #include -#include +#include #include #include #include @@ -213,10 +213,10 @@ main(int argc, char **argv) { char *filename = NULL; char *classname = "IN"; - while ((c = getopt(argc, argv, "cdf:m:qsMS")) != EOF) { + while ((c = isc_commandline_parse(argc, argv, "cdf:m:qsMS")) != EOF) { switch (c) { case 'c': - classname = optarg; + classname = isc_commandline_argument; break; case 'd': debug++; @@ -224,12 +224,13 @@ main(int argc, char **argv) { case 'f': if (filename != NULL) usage(); - filename = optarg; + filename = isc_commandline_argument; break; case 'm': memset(&addr, 0, sizeof addr); addr.type.sin.sin_family = AF_INET; - inet_pton(AF_INET, optarg, &addr.type.sin.sin_addr); + inet_pton(AF_INET, isc_commandline_argument, + &addr.type.sin.sin_addr); addr.type.sin.sin_port = htons(53); break; case 'q': @@ -249,7 +250,7 @@ main(int argc, char **argv) { } } - if (argv[optind] == NULL) + if (argv[isc_commandline_index] == NULL) usage(); RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS); @@ -258,8 +259,8 @@ main(int argc, char **argv) { ISC_R_SUCCESS); if (filename == NULL) - filename = argv[optind]; - setup(argv[optind], filename, classname); + filename = argv[isc_commandline_index]; + setup(argv[isc_commandline_index], filename, classname); query(); destroy(); isc_taskmgr_destroy(&manager);