summaryrefslogtreecommitdiff
path: root/options.c
blob: 2c8daa472092c56d7bbbed5b260661bcc13229de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#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},
		{"kill", 'k', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &options->kill, 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);
	}
}