]> git.ipfire.org Git - zone-sync.git/commitdiff
main: Add a path where to store the zones
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 11 May 2026 10:57:18 +0000 (10:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 11 May 2026 10:57:18 +0000 (10:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
main.c

diff --git a/main.c b/main.c
index 0a4e274e99cf8e333356676afcf536f2892231d9..f210601372b6bc7d7da58a1da4c8bceb8f93e467 100644 (file)
--- a/main.c
+++ b/main.c
 #include <isc/mem.h>
 #include <isc/netmgr.h>
 
+#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 = {