diff --git a/epicardium/modules/config.c b/epicardium/modules/config.c index 5be76cd97a3c3758efd5d5108165a2aa738f0b7a..2c41f814eeaef4410315aba930c47f74db16533b 100644 --- a/epicardium/modules/config.c +++ b/epicardium/modules/config.c @@ -30,9 +30,21 @@ struct config_option { }; static struct config_option s_options[_EpicOptionCount] = { - [OptionExecuteElf] = { .name = "execute_elf", - .type = OptionType_Boolean, - .value = { .boolean = false } }, +/* clang-format off */ + #define INIT_Boolean(v) { .boolean = (v) } + #define INIT_Int(v) { .integer = (v) } + #define INIT_Float(v) { .floating_point = (v) } + #define INIT_String(v) { .string = (v) } + #define INIT_(tp, v) INIT_ ## tp (v) + #define INIT(tp, v) INIT_ (tp, v) + + #define CARD10_SETTING(identifier, spelling, tp, default_value) \ + [Option ## identifier] = { .name = (spelling), \ + .type = OptionType_ ## tp, \ + .value = INIT(tp, (default_value)) }, + + #include "modules/config.def" + /* clang-format on */ }; static struct config_option *findOption(const char *key) diff --git a/epicardium/modules/config.def b/epicardium/modules/config.def new file mode 100644 index 0000000000000000000000000000000000000000..455aaedd8d61f821c1d08ee99bb45c3a61d983ba --- /dev/null +++ b/epicardium/modules/config.def @@ -0,0 +1,11 @@ +#ifndef CARD10_SETTING +# define CARD10_SETTING(identifier, spelling, type, default_value) +#endif + +CARD10_SETTING(ExecuteElf, "execute_elf", Boolean, false) +//CARD10_SETTING(Nick, "nick", String, "an0n") +//CARD10_SETTING(Timeout, "timeout", Integer, 123) +//CARD10_SETTING(Dampening, "dampening", Float, 420) + + +#undef CARD10_SETTING diff --git a/epicardium/modules/config.h b/epicardium/modules/config.h index cfde8b163bfc761ebd9aac9111e7be2b6de7a5ea..b72b08a5205bf9344bc3e3d805423dc826f30ccc 100644 --- a/epicardium/modules/config.h +++ b/epicardium/modules/config.h @@ -4,7 +4,8 @@ #include <stdbool.h> enum EpicConfigOption { - OptionExecuteElf, + #define CARD10_SETTING(identifier, spelling, type, default_value) Option ## identifier, + #include "modules/config.def" _EpicOptionCount };