Updated: fixed command line parsing
This commit is contained in:
parent
569dd8832e
commit
62a2ee9db3
2 changed files with 6 additions and 6 deletions
BIN
serpent
Executable file
BIN
serpent
Executable file
Binary file not shown.
12
serpent.c
12
serpent.c
|
@ -78,25 +78,25 @@ int main (int argc, char **argv) {
|
||||||
/* Command line parsing */
|
/* Command line parsing */
|
||||||
int option;
|
int option;
|
||||||
|
|
||||||
static const char* short_options = "chv";
|
static const char* shortOptions = "chv";
|
||||||
static struct option long_options[] = {
|
static struct option longOptions[] = {
|
||||||
{"show-controls", no_argument, NULL, 'c'},
|
{"show-controls", no_argument, NULL, 'c'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((option = getopt_long (argc, argv, short_options, long_options, NULL)) != -1) {
|
while ((option = getopt_long (argc, argv, shortOptions, longOptions, NULL)) != -1) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 'c':
|
case 'c':
|
||||||
argControls();
|
argControls();
|
||||||
break;
|
return 0;
|
||||||
case 'h':
|
case 'h':
|
||||||
argHelp();
|
argHelp();
|
||||||
break;
|
return 0;
|
||||||
case 'v':
|
case 'v':
|
||||||
argVersion();
|
argVersion();
|
||||||
break;
|
return 0;
|
||||||
case '?':
|
case '?':
|
||||||
fprintf(stderr, "Use '-h, --help' for help.\n");
|
fprintf(stderr, "Use '-h, --help' for help.\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue