From: Michael Tremer Date: Thu, 4 Jun 2026 14:59:19 +0000 (+0000) Subject: daemon: main: Group any arguments into a new struct X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=6473190ceb0a90970bb2dc369b01d2ace1075884;p=telemetry.git daemon: main: Group any arguments into a new struct Signed-off-by: Michael Tremer --- diff --git a/src/daemon/main.c b/src/daemon/main.c index 09d1514..34169cc 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -49,13 +49,18 @@ static struct argp_option options[] = { { 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; @@ -70,14 +75,14 @@ static error_t parse(int key, char* arg, struct argp_state* state) { 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: @@ -109,12 +114,12 @@ int main(int argc, char* argv[]) { 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;