summaryrefslogtreecommitdiffstats
path: root/src/modules/custom
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/modules/custom
Add the files
Diffstat (limited to 'src/modules/custom')
-rw-r--r--src/modules/custom/custom.c45
-rw-r--r--src/modules/custom/custom.h11
-rw-r--r--src/modules/custom/option.h9
3 files changed, 65 insertions, 0 deletions
diff --git a/src/modules/custom/custom.c b/src/modules/custom/custom.c
new file mode 100644
index 0000000..054f370
--- /dev/null
+++ b/src/modules/custom/custom.c
@@ -0,0 +1,45 @@
+#include "common/printing.h"
+#include "common/jsonconfig.h"
+#include "common/textModifier.h"
+#include "common/strutil.h"
+#include "modules/custom/custom.h"
+
+bool ffPrintCustom(FFCustomOptions* options) {
+ ffPrintFormat(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, 0, ((FFformatarg[]) {}));
+ return true;
+}
+
+void ffGenerateCustomJsonConfig(FFCustomOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
+ ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
+}
+
+void ffParseCustomJsonObject(FFCustomOptions* options, yyjson_val* module) {
+ yyjson_val *key, *val;
+ size_t idx, max;
+ yyjson_obj_foreach (module, idx, max, key, val) {
+ if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) {
+ continue;
+ }
+
+ ffPrintError(FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
+ }
+}
+
+void ffInitCustomOptions(FFCustomOptions* options) {
+ ffOptionInitModuleArg(&options->moduleArgs, "");
+ ffStrbufSetStatic(&options->moduleArgs.key, " ");
+}
+
+void ffDestroyCustomOptions(FFCustomOptions* options) {
+ ffOptionDestroyModuleArg(&options->moduleArgs);
+}
+
+FFModuleBaseInfo ffCustomModuleInfo = {
+ .name = FF_CUSTOM_MODULE_NAME,
+ .description = "Print a custom string, with or without key",
+ .initOptions = (void*) ffInitCustomOptions,
+ .destroyOptions = (void*) ffDestroyCustomOptions,
+ .parseJsonObject = (void*) ffParseCustomJsonObject,
+ .printModule = (void*) ffPrintCustom,
+ .generateJsonConfig = (void*) ffGenerateCustomJsonConfig,
+};
diff --git a/src/modules/custom/custom.h b/src/modules/custom/custom.h
new file mode 100644
index 0000000..628a621
--- /dev/null
+++ b/src/modules/custom/custom.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "option.h"
+
+#define FF_CUSTOM_MODULE_NAME "Custom"
+
+bool ffPrintCustom(FFCustomOptions* options);
+void ffInitCustomOptions(FFCustomOptions* options);
+void ffDestroyCustomOptions(FFCustomOptions* options);
+
+extern FFModuleBaseInfo ffCustomModuleInfo;
diff --git a/src/modules/custom/option.h b/src/modules/custom/option.h
new file mode 100644
index 0000000..2a7e5e4
--- /dev/null
+++ b/src/modules/custom/option.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "common/option.h"
+
+typedef struct FFCustomOptions {
+ FFModuleArgs moduleArgs;
+} FFCustomOptions;
+
+static_assert(sizeof(FFCustomOptions) <= FF_OPTION_MAX_SIZE, "FFCustomOptions size exceeds maximum allowed size");