Add --version cmdline option

Related: OS#3577
Change-Id: Ibdda54acddde0ac03e202286736d56b6fa51a365
This commit is contained in:
Oliver Smith 2018-10-16 17:02:26 +02:00
parent f0c2b31df9
commit d9c059e92a
1 changed files with 7 additions and 1 deletions

View File

@ -81,6 +81,7 @@ static void print_help(void)
printf("OsmoSIPcon: MNCC to SIP bridge\n"); printf("OsmoSIPcon: MNCC to SIP bridge\n");
printf(" -h --help\tthis text\n"); printf(" -h --help\tthis text\n");
printf(" -c --config-file NAME\tThe config file to use [%s]\n", config_file); printf(" -c --config-file NAME\tThe config file to use [%s]\n", config_file);
printf(" -V --version\tPrint the version number\n");
} }
static void handle_options(int argc, char **argv) static void handle_options(int argc, char **argv)
@ -90,10 +91,11 @@ static void handle_options(int argc, char **argv)
static struct option long_options[] = { static struct option long_options[] = {
{"help", 0, 0, 'h'}, {"help", 0, 0, 'h'},
{"config-file", 1, 0, 'c'}, {"config-file", 1, 0, 'c'},
{"version", 0, 0, 'V' },
{NULL, 0, 0, 0} {NULL, 0, 0, 0}
}; };
c = getopt_long(argc, argv, "hc:", c = getopt_long(argc, argv, "hc:V",
long_options, &option_index); long_options, &option_index);
if (c == -1) if (c == -1)
break; break;
@ -105,6 +107,10 @@ static void handle_options(int argc, char **argv)
case 'c': case 'c':
config_file = optarg; config_file = optarg;
break; break;
case 'V':
print_version(1);
exit(EXIT_SUCCESS);
break;
} }
} }
} }