From: Michael Tremer Date: Mon, 11 May 2026 10:57:18 +0000 (+0000) Subject: main: Add a path where to store the zones X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07dae299418b64b368b289cdef09736c8ad08359;p=zone-sync.git main: Add a path where to store the zones Signed-off-by: Michael Tremer --- diff --git a/main.c b/main.c index 0a4e274..f210601 100644 --- a/main.c +++ b/main.c @@ -28,9 +28,14 @@ #include #include +#define DEFAULT_PATH "/tmp" + typedef struct ctx { int log_level; + // Path + const char* path; + // Zones const char** zones; unsigned int num_zones; @@ -107,10 +112,12 @@ static const char* args_doc = "TODO"; enum { OPT_DEBUG = 1, + OPT_PATH = 2, }; static struct argp_option options[] = { { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 }, + { "path", OPT_PATH, "PATH", 1, "Path where to store the zones", 0 }, { NULL }, }; @@ -123,6 +130,10 @@ static error_t parse(int key, char* arg, struct argp_state* state) { ctx->log_level = LOG_DEBUG; break; + case OPT_PATH: + ctx->path = arg; + break; + case ARGP_KEY_ARG: zones = reallocarray(ctx->zones, ctx->num_zones + 1, sizeof(*ctx->zones)); if (!zones) { @@ -161,7 +172,9 @@ int main(int argc, char* argv[]) { int r; // Create the context - ctx_t ctx = {}; + ctx_t ctx = { + .path = DEFAULT_PATH, + }; // Setup the command line parser struct argp parser = {