change when arguments are converted to lower case

pull/74/head
Levi Rak 2017-08-17 14:04:50 -06:00
parent aa581dd18a
commit baa74cf4b8
3 changed files with 14 additions and 25 deletions

View File

@ -79,7 +79,7 @@ static struct option long_options[] = {
{"noout", no_argument, 0, NOOUT }, {"noout", no_argument, 0, NOOUT },
{"text", no_argument, 0, TEXT_OUT }, {"text", no_argument, 0, TEXT_OUT },
{"silent", no_argument, 0, SILENT }, {"silent", no_argument, 0, SILENT },
{"output", no_argument, 0, OUTPUT }, {"output", required_argument, 0, OUTPUT },
{"help", no_argument, 0, HELP }, {"help", no_argument, 0, HELP },
{"h", no_argument, 0, HELP }, {"h", no_argument, 0, HELP },
{"v", no_argument, 0, 'v' }, {"v", no_argument, 0, 'v' },

View File

@ -67,7 +67,7 @@ int wolfCLU_benchSetup(int argc, char** argv)
/* acceptable option check */ /* acceptable option check */
int optionCheck = 0; int optionCheck = 0;
ret = wolfCLU_checkForArg("-h", 2, argc, argv); ret = wolfCLU_checkForArg("-help", 5, argc, argv);
if (ret > 0) { if (ret > 0) {
wolfCLU_benchHelp(); wolfCLU_benchHelp();
return 0; return 0;
@ -103,8 +103,8 @@ int wolfCLU_benchSetup(int argc, char** argv)
} }
if (optionCheck != 1) { if (optionCheck != 1) {
/* help checking */
wolfCLU_help(); wolfCLU_help();
ret = 0;
} }
else { else {
/* benchmarking function */ /* benchmarking function */

View File

@ -45,24 +45,6 @@ int main(int argc, char** argv)
wolfCLU_help(); wolfCLU_help();
} }
/* Set ignore variables for -in and -out files */
ret = wolfCLU_checkForArg("-in", 3, argc, argv);
if (ret > 0) {
ignoreIn = ret + 1;
}
ret = wolfCLU_checkForArg("-out", 4, argc, argv);
if (ret > 0) {
ignoreOut = ret + 1;
}
/* flexibility: allow users to input any CAPS or lower case, we will do all
* processing on lower case only. except where ignored */
for (i = 0; i < argc; i++) {
if (i != ignoreIn && i != ignoreOut) {
convert_to_lower(argv[i], (int) XSTRLEN(argv[i]));
}
}
while ((option = getopt_long_only(argc, argv,"", while ((option = getopt_long_only(argc, argv,"",
long_options, &long_index )) != -1) { long_options, &long_index )) != -1) {
@ -76,8 +58,8 @@ int main(int argc, char** argv)
case X509: case X509:
case REQUEST: case REQUEST:
case GEN_KEY: case GEN_KEY:
if (!flag) flag = option; if (!flag) flag = option;
break;
/* /*
* Ignore the following arguments for now. They will be handled by * Ignore the following arguments for now. They will be handled by
@ -85,8 +67,6 @@ int main(int argc, char** argv)
* Hash Setup) * Hash Setup)
*/ */
case INFILE: /* File passed in by user */
case OUTFILE: /* Output file */
case PASSWORD: /* Password */ case PASSWORD: /* Password */
case KEY: /* Key if used must be in hex */ case KEY: /* Key if used must be in hex */
case IV: /* IV if used must be in hex */ case IV: /* IV if used must be in hex */
@ -101,8 +81,17 @@ int main(int argc, char** argv)
case NOOUT: case NOOUT:
case TEXT_OUT: case TEXT_OUT:
case SILENT: case SILENT:
/* The cases above have their arguments converted to lower case */
if (optarg) convert_to_lower(optarg, (int)XSTRLEN(optarg));
/* The cases below won't have their argument's molested */
case INFILE: /* File passed in by user */
case OUTFILE: /* Output file */
/* do nothing. */ /* do nothing. */
break;
break; /* note: this is the first break in the block */
/* /*
* End of ignored arguments * End of ignored arguments