Add "--version" to all executables to print compile-time version info
Change-Id: I9ae504ff95beeefb9e90e02a576861351ea9e143
This commit is contained in:
parent
3f9663215f
commit
cd7fcd717c
|
@ -243,6 +243,7 @@ static void printf_help()
|
|||
{
|
||||
printf(
|
||||
" -h --help Print this help message\n"
|
||||
" -V --version Print the version of the program\n"
|
||||
" -i --server-host A.B.C.D remsim-server IP address (default: 127.0.0.1)\n"
|
||||
" -p --server-port <1-65535> remsim-server TCP port (default: 9998)\n"
|
||||
" -b --bank-id <1-65535> Bank Identifier of this SIM bank (default: 1)\n"
|
||||
|
@ -263,6 +264,7 @@ void handle_options(int argc, char **argv)
|
|||
int option_index = 0, c;
|
||||
static const struct option long_options[] = {
|
||||
{ "help", 0, 0, 'h' },
|
||||
{ "version", 0, 0, 'V' },
|
||||
{ "server-host", 1, 0, 'i' },
|
||||
{ "server-port", 1, 0, 'p' },
|
||||
{ "bank-id", 1, 0, 'b' },
|
||||
|
@ -273,7 +275,7 @@ void handle_options(int argc, char **argv)
|
|||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "hi:o:b:n:N:I:P:", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "hVi:o:b:n:N:I:P:", long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
|
@ -282,6 +284,10 @@ void handle_options(int argc, char **argv)
|
|||
printf_help();
|
||||
exit(0);
|
||||
break;
|
||||
case 'V':
|
||||
printf("osmo-remsim-bankd version %s\n", VERSION);
|
||||
exit(0);
|
||||
break;
|
||||
case 'i':
|
||||
g_bankd->srvc.server_host = optarg;
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <getopt.h>
|
||||
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include <osmocom/core/utils.h>
|
||||
|
@ -25,6 +28,49 @@ static void handle_sig_usr1(int signal)
|
|||
talloc_report_full(g_tall_ctx, stderr);
|
||||
}
|
||||
|
||||
static void print_help()
|
||||
{
|
||||
printf( " Some useful help...\n"
|
||||
" -h --help This text\n"
|
||||
" -V --version Print version of the program\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void handle_options(int argc, char **argv)
|
||||
{
|
||||
while (1) {
|
||||
int option_index = 0, c;
|
||||
static struct option long_options[] = {
|
||||
{ "help", 0, 0, 'h' },
|
||||
{ "version", 0, 0, 'V' },
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "hV", long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'h':
|
||||
print_help();
|
||||
exit(0);
|
||||
break;
|
||||
case 'V':
|
||||
printf("osmo-resmim-server version %s\n", VERSION);
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
/* ignore */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > optind) {
|
||||
fprintf(stderr, "Unsupported extra positional arguments in command line\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
void *talloc_rest_ctx;
|
||||
|
@ -37,6 +83,8 @@ int main(int argc, char **argv)
|
|||
|
||||
osmo_init_logging2(g_tall_ctx, &log_info);
|
||||
|
||||
handle_options(argc, argv);
|
||||
|
||||
g_rps = rspro_server_create(g_tall_ctx, "0.0.0.0", 9998);
|
||||
if (!g_rps)
|
||||
exit(1);
|
||||
|
|
|
@ -696,6 +696,7 @@ static void print_help(void)
|
|||
"\t-c\t--client-id <0-65535>\n"
|
||||
"\t-n\t--client-slot <0-65535>\n"
|
||||
"\t-h\t--help\n"
|
||||
"\t-v\t--version\n"
|
||||
"\t-i\t--gsmtap-ip\tA.B.C.D\n"
|
||||
"\t-k\t--keep-running\n"
|
||||
"\t-V\t--usb-vendor\tVENDOR_ID\n"
|
||||
|
@ -716,6 +717,7 @@ static const struct option opts[] = {
|
|||
{ "client-id", 1, 0, 'c' },
|
||||
{ "client-slot", 1, 0, 'n' },
|
||||
{ "help", 0, 0, 'h' },
|
||||
{ "version", 0, 0, 'v' },
|
||||
{ "gsmtap-ip", 1, 0, 'i' },
|
||||
{ "keep-running", 0, 0, 'k' },
|
||||
{ "usb-vendor", 1, 0, 'V' },
|
||||
|
@ -751,7 +753,7 @@ int main(int argc, char **argv)
|
|||
while (1) {
|
||||
int option_index = 0;
|
||||
|
||||
c = getopt_long(argc, argv, "s:p:c:n:hi:kV:P:C:I:S:A:H:a:", opts, &option_index);
|
||||
c = getopt_long(argc, argv, "s:p:c:n:hvi:kV:P:C:I:S:A:H:a:", opts, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
|
@ -771,6 +773,10 @@ int main(int argc, char **argv)
|
|||
print_help();
|
||||
exit(0);
|
||||
break;
|
||||
case 'v':
|
||||
printf("osmo-remsim-client version %s\n", VERSION);
|
||||
exit(0);
|
||||
break;
|
||||
case 'i':
|
||||
gsmtap_host = optarg;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue