diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-09-04 01:20:33 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-09-04 01:20:33 +0200 |
commit | 671966ae7bb69fc04952a8accaa52fae5e77d8bb (patch) | |
tree | b3678ab9e73b9de72787e5ab701328b86c1ab761 /options.c | |
parent | b44aef17d76c7781e1ff5958e29fe5f2b006cb09 (diff) |
Added command-line options and daemonizer.
Diffstat (limited to 'options.c')
-rw-r--r-- | options.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/options.c b/options.c new file mode 100644 index 0000000..ee237aa --- /dev/null +++ b/options.c @@ -0,0 +1,24 @@ +#include "options.h" +#include "conf.h" + +#include <glib.h> + +#include <stdlib.h> + +void options_parse(int argc, char **argv, struct options *options) { + GError *error = NULL; + GOptionContext *context; + GOptionEntry entries[] = { + {"daemonize", 'd', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &options->daemonize, NULL, NULL}, + {NULL}, + }; + + context = g_option_context_new(NULL); + g_option_context_set_summary(context, "audist daemon"); + g_option_context_add_main_entries(context, entries, NULL); + if(g_option_context_parse(context, &argc, &argv, &error) == FALSE) { + g_warning(error->message); + g_error_free(error); + exit(1); + } +} |