add osmo-mgw --vty-ref-xml: dump VTY ref XML to stdout
Add only a long option to not clutter the cmdline namespace. To add a long option without a short letter is slightly complex: use the 'flag' and 'val' mechanism as in 'man 3 getopt' to write an option index to long_option. Depends: Ic74bbdb6dc5ea05f03c791cc70184861e39cd492 (libosmocore) Change-Id: Ia988ea1c3f5169bdb4d21f2f05933665711cfcbf
This commit is contained in:
parent
13fae78b32
commit
f5531845bc
|
@ -98,18 +98,21 @@ static void print_help()
|
||||||
printf(" -s --disable-color\n");
|
printf(" -s --disable-color\n");
|
||||||
printf(" -D --daemonize Fork the process into a background daemon\n");
|
printf(" -D --daemonize Fork the process into a background daemon\n");
|
||||||
printf(" -V --version Print the version number\n");
|
printf(" -V --version Print the version number\n");
|
||||||
|
printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_options(int argc, char **argv)
|
static void handle_options(int argc, char **argv)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0, c;
|
int option_index = 0, c;
|
||||||
|
static int long_option = 0;
|
||||||
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'},
|
||||||
{"daemonize", 0, 0, 'D'},
|
{"daemonize", 0, 0, 'D'},
|
||||||
{"version", 0, 0, 'V'},
|
{"version", 0, 0, 'V'},
|
||||||
{"disable-color", 0, 0, 's'},
|
{"disable-color", 0, 0, 's'},
|
||||||
|
{"vty-ref-xml", 0, &long_option, 1},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,6 +126,15 @@ static void handle_options(int argc, char **argv)
|
||||||
print_help();
|
print_help();
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
|
case 0:
|
||||||
|
switch (long_option) {
|
||||||
|
case 1:
|
||||||
|
vty_dump_xml_ref(stdout);
|
||||||
|
exit(0);
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "error parsing cmdline options\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
case 'c':
|
case 'c':
|
||||||
config_file = talloc_strdup(tall_bsc_ctx, optarg);
|
config_file = talloc_strdup(tall_bsc_ctx, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue