From 287ddfc25ee60955e2bfc8ba8193309747639f4f Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 5 Aug 2023 11:14:51 -0700 Subject: til_builtins: add "none" builtin Sometimes nested modules are optional, in those cases I've usually been using the "none" module name to indicate this and the ad-hoc setup stuff can easily bypass module setup on that. This commit is a step towards having a "none" builtin that provides a til_module_t.setup() which succeeds but only produces a NULL res_setup when asked to finalize. So if callers just handle a successful finalize case that writes NULL at res_setup equivalent to "disabled", this all Just Works. Currently that's not an expected thing, but future commits will bring everything else on the same page. For callers who want to require the module and not offer "none", they can just put "none" in the explicit exclusions list passed to til_module_setup_full(). --- src/til_builtins.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/til_builtins.c') diff --git a/src/til_builtins.c b/src/til_builtins.c index 7a36d23..a73cf30 100644 --- a/src/til_builtins.c +++ b/src/til_builtins.c @@ -165,3 +165,25 @@ static int _ref_setup(const til_settings_t *settings, til_setting_t **res_settin return 0; } + + +/* "none" built-in module */ +static int _none_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); + + +til_module_t _none_module = { + .setup = _none_setup, + .name = "none", + .description = "Disabled (built-in)", + .author = "built-in", + .flags = TIL_MODULE_BUILTIN, +}; + + +static int _none_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) +{ + if (res_setup) + *res_setup = NULL; + + return 0; +} -- cgit v1.2.1