mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-03 22:08:25 -04:00
use isc_commandline_parse instead of getopt
This commit is contained in:
parent
626100a123
commit
6a759e3869
14 changed files with 144 additions and 122 deletions
|
|
@ -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 <config.h>
|
||||
|
||||
|
|
@ -23,9 +23,9 @@
|
|||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/mem.h>
|
||||
#include <dns/keyvalues.h>
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h> /* for getopt */
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/error.h>
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <dns/compress.h>
|
||||
#include <dns/name.h>
|
||||
|
|
@ -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++;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h> /* XXX Naughty. */
|
||||
#include <unistd.h> /* XXX Naughty. */
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/region.h>
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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 <config.h>
|
||||
|
||||
|
|
@ -23,9 +23,9 @@
|
|||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/mem.h>
|
||||
#include <dns/keyvalues.h>
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/lex.h>
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <unistd.h> /* XXX Naughty. */
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/log.h>
|
||||
#include <isc/result.h>
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/region.h>
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/boolean.h>
|
||||
|
||||
#include <dns/rbt.h>
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/lex.h>
|
||||
|
||||
#include <dns/rdata.h>
|
||||
#include <dns/compress.h>
|
||||
#include <dns/rdataclass.h>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h> /* XXX Naughty. */
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/timer.h>
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h> /* for getopt */
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/error.h>
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/symtab.h>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/app.h>
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue