{ NULL },
};
-// The database path
-static const char* path = NULL;
+static struct config {
+ // Database Path
+ const char* path;
-// Collect all sources that should be enabled
-static char** sources = NULL;
+ // All sources that should be enabled
+ char** sources;
-static const char* user = DAEMON_USER;
+ // Daemon User
+ const char* user;
+} config = {
+ .user = DAEMON_USER,
+};
static error_t parse(int key, char* arg, struct argp_state* state) {
td_ctx* ctx = state->input;
break;
case OPT_PATH:
- path = arg;
+ config.path = arg;
break;
case OPT_SOURCE:
- return td_strings_append(&sources, arg);
+ return td_strings_append(&config.sources, arg);
case OPT_USER:
- user = arg;
+ config.user = arg;
break;
default:
goto ERROR;
// Drop privileges
- r = td_priv_drop_privileges(ctx, user);
+ r = td_priv_drop_privileges(ctx, config.user);
if (r < 0)
goto ERROR;
// Create a daemon
- r = td_daemon_create(&daemon, ctx, path, sources);
+ r = td_daemon_create(&daemon, ctx, config.path, config.sources);
if (r < 0) {
ERROR(ctx, "Failed to initialize the daemon: %s\n", strerror(-r));
goto ERROR;