]> git.ipfire.org Git - collecty.git/commitdiff
args: Add function to check if any sources have been added
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Jun 2026 14:29:40 +0000 (14:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Jun 2026 14:29:40 +0000 (14:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/args.c
src/daemon/args.h

index 363361aee861438b1a90a170acce7998f8e9d6d3..5b5d852485380b3e0515a5824fff5353eace3abf 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "args.h"
 #include "ctx.h"
+#include "string.h"
 
 struct td_args {
        td_ctx* ctx;
@@ -146,3 +147,12 @@ int td_args_dump(td_args* self) {
 
        return 0;
 }
+
+int td_args_has_sources(td_args* self) {
+       for (int i = 0; i < self->argc; i++) {
+               if (td_string_startswith(self->argv[i], "DEF:"))
+                       return 1;
+       }
+
+       return 0;
+}
index 816cd431f60c159dab15f3102f286bfe089898e9..c5293978f0a29ba5a8062dabdc28c542c4fcc636 100644 (file)
@@ -40,4 +40,6 @@ int td_args_pushv(td_args* self, const char* args[]);
 
 int td_args_dump(td_args* self);
 
+int td_args_has_sources(td_args* self);
+
 #endif /* TELEMETRY_ARGS_H */