From a82870384c3295b0a6f235c2041f8f127cbd9c5f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 27 Sep 2025 14:47:59 +0000 Subject: [PATCH] modules: Create a dummy function for modules to submit data Signed-off-by: Michael Tremer --- src/daemon/module.c | 30 ++++++++++++++++++++++++++++++ src/daemon/module.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/src/daemon/module.c b/src/daemon/module.c index f5d0e71..bba4f8b 100644 --- a/src/daemon/module.c +++ b/src/daemon/module.c @@ -19,6 +19,7 @@ #############################################################################*/ #include +#include #include #include @@ -209,3 +210,32 @@ collecty_module* collecty_module_unref(collecty_module* self) { const char* collecty_module_name(collecty_module* self) { return self->methods->name; } + +/* + Called when a module has some data to submit +*/ +int collecty_module_submit(collecty_module* self, + const char* object, const char* format, ...) { + char* value = NULL; + va_list args; + int r; + + // Format the arguments + va_start(args, format); + r = vasprintf(&value, format, args); + va_end(args); + + // Handle errors + if (r < 0) + return -errno; + + DEBUG(self->ctx, "%s(%s) submitted: %s\n", + collecty_module_name(self), (object) ? object : "", value); + + // TODO + + if (value) + free(value); + + return 0; +} diff --git a/src/daemon/module.h b/src/daemon/module.h index fc5db7c..d856e81 100644 --- a/src/daemon/module.h +++ b/src/daemon/module.h @@ -44,4 +44,7 @@ collecty_module* collecty_module_unref(collecty_module* self); const char* collecty_module_name(collecty_module* self); +int collecty_module_submit(collecty_module* self, const char* object, + const char* format, ...) __attribute__((format(printf, 3, 4))); + #endif /* COLLECTY_MODULE_H */ -- 2.47.3