mirror of git://git.sysmocom.de/ofono
Add command line option for printing version number
This commit is contained in:
parent
e8d18946b9
commit
e433ddc100
14
src/main.c
14
src/main.c
|
@ -93,15 +93,18 @@ static void system_bus_disconnected(DBusConnection *conn, void *user_data)
|
||||||
g_main_loop_quit(event_loop);
|
g_main_loop_quit(event_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean option_detach = TRUE;
|
|
||||||
static gboolean option_debug = FALSE;
|
static gboolean option_debug = FALSE;
|
||||||
|
static gboolean option_detach = TRUE;
|
||||||
|
static gboolean option_version = FALSE;
|
||||||
|
|
||||||
static GOptionEntry options[] = {
|
static GOptionEntry options[] = {
|
||||||
|
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug,
|
||||||
|
"Enable debug information output" },
|
||||||
{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
|
{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
|
||||||
G_OPTION_ARG_NONE, &option_detach,
|
G_OPTION_ARG_NONE, &option_detach,
|
||||||
"Don't run as daemon in background" },
|
"Don't run as daemon in background" },
|
||||||
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug,
|
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
|
||||||
"Enable debug information output" },
|
"Show version information and exit" },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -161,6 +164,11 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
g_option_context_free(context);
|
g_option_context_free(context);
|
||||||
|
|
||||||
|
if (option_version == TRUE) {
|
||||||
|
printf("%s\n", VERSION);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (option_detach == TRUE) {
|
if (option_detach == TRUE) {
|
||||||
if (daemon(0, 0)) {
|
if (daemon(0, 0)) {
|
||||||
perror("Can't start daemon");
|
perror("Can't start daemon");
|
||||||
|
|
Loading…
Reference in New Issue