]> git.ipfire.org Git - collecty.git/commitdiff
args: Add function to add multiple pre-formatted arguments at once
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Oct 2025 09:35:57 +0000 (09:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Oct 2025 09:35:57 +0000 (09:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/args.c
src/daemon/args.h

index 6a4cda1e9232487de5bba44cc2b98bb6040a4ebc..1319b97e7464f2c7bc46d13ea45510f2e35cf451 100644 (file)
@@ -123,6 +123,22 @@ ERROR:
        return -errno;
 }
 
+int collecty_args_pushv(collecty_args* self, const char* args[]) {
+       int r;
+
+       // Check inputs
+       if (!args)
+               return -EINVAL;
+
+       for (unsigned int i = 0; args[i]; i++) {
+               r = collecty_args_push(self, "%s", args[i]);
+               if (r < 0)
+                       return r;
+       }
+
+       return 0;
+}
+
 int collecty_args_dump(collecty_args* self) {
        for (int i = 0; i < self->argc; i++) {
                DEBUG(self->ctx, "argv[%d]: %s\n", i, self->argv[i]);
index e8c2ca807832bbb5afebc4e405ec1048ede9002c..67b19543d8c6d3902f2154fda39f7248752ebbd1 100644 (file)
@@ -36,6 +36,8 @@ int collecty_args_argc(collecty_args* self);
 int collecty_args_push(collecty_args* self, const char* format, ...)
        __attribute__((format(printf, 2, 3)));
 
+int collecty_args_pushv(collecty_args* self, const char* args[]);
+
 int collecty_args_dump(collecty_args* self);
 
 #endif /* COLLECTY_ARGS_H */