From: Michael Tremer Date: Thu, 2 Oct 2025 09:35:57 +0000 (+0000) Subject: args: Add function to add multiple pre-formatted arguments at once X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c6f93dc3c275992d6e9317b6e05a57c02c2eaf1d;p=collecty.git args: Add function to add multiple pre-formatted arguments at once Signed-off-by: Michael Tremer --- diff --git a/src/daemon/args.c b/src/daemon/args.c index 6a4cda1..1319b97 100644 --- a/src/daemon/args.c +++ b/src/daemon/args.c @@ -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]); diff --git a/src/daemon/args.h b/src/daemon/args.h index e8c2ca8..67b1954 100644 --- a/src/daemon/args.h +++ b/src/daemon/args.h @@ -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 */