]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings: Rewrite and add missing SETTING_DEFINE_STRUCT_* macros
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 13:53:26 +0000 (16:53 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 18 Mar 2021 08:35:02 +0000 (08:35 +0000)
These hadn't been used anywhere.

src/config/test-config-parser.c
src/lib-settings/settings-parser.h
src/lib-settings/test-settings-parser.c

index d54a5643e1664ba5328b694d7fb973f6e7093b8d..baf91a1d45488320c569c70e9751ae3db87ef85d 100644 (file)
@@ -30,18 +30,18 @@ struct test_settings {
 };
 
 static const struct setting_define test_settings_defs[] = {
-       SETTING_DEFINE_STRUCT_STR(key, test_settings),
-       SETTING_DEFINE_STRUCT_STR(key2, test_settings),
-       SETTING_DEFINE_STRUCT_STR(key3, test_settings),
-       SETTING_DEFINE_STRUCT_STR(key4, test_settings),
-       SETTING_DEFINE_STRUCT_STR(key5, test_settings),
-       SETTING_DEFINE_STRUCT_STR(pop3_deleted_flag, test_settings),
-       SETTING_DEFINE_STRUCT_STR(env_key, test_settings),
-       SETTING_DEFINE_STRUCT_STR(env_key2, test_settings),
-       SETTING_DEFINE_STRUCT_STR(env_key3, test_settings),
-       SETTING_DEFINE_STRUCT_STR(env_key4, test_settings),
-       SETTING_DEFINE_STRUCT_STR(env_key5, test_settings),
-       SETTING_DEFINE_STRUCT_STR(protocols, test_settings),
+       SETTING_DEFINE_STRUCT_STR("key", key, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("key2", key2, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("key3", key3, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("key4", key4, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("key5", key5, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("pop3_deleted_flag", pop3_deleted_flag, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("env_key", env_key, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("env_key2", env_key2, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("env_key3", env_key3, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("env_key4", env_key4, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("env_key5", env_key5, struct test_settings),
+       SETTING_DEFINE_STRUCT_STR("protocols", protocols, struct test_settings),
        SETTING_DEFINE_LIST_END
 };
 
index 2c23290ddb7bd748c2d3e5c5c5e01eeb67701b1c..b66d32a0d1336ae93681eb93f7c77a9fdd7d067a 100644 (file)
@@ -46,34 +46,31 @@ struct setting_define {
        const struct setting_parser_info *list_info;
 };
 
-#define SETTING_DEFINE_STRUCT_BOOL(name, struct_name) \
-       { SET_BOOL + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \
-               ((struct struct_name *)0)->name, bool), \
-         #name, offsetof(struct struct_name, name), NULL }
-#define SETTING_DEFINE_STRUCT_UINT(name, struct_name) \
-       { SET_UINT + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \
-               ((struct struct_name *)0)->name, unsigned int), \
-         #name, offsetof(struct struct_name, name), NULL }
-#define SETTING_DEFINE_STRUCT_SIZE(name, struct_name) \
-       { SET_SIZE + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \
-               ((struct struct_name *)0)->name, uoff_t), \
-         #name, offsetof(struct struct_name, name), NULL }
-#define SETTING_DEFINE_STRUCT_TIME(name, struct_name) \
-       { SET_TIME + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \
-               ((struct struct_name *)0)->name, unsigned int), \
-         #name, offsetof(struct struct_name, name), NULL }
-#define SETTING_DEFINE_STRUCT_TIME_MSECS(name, struct_name) \
-       { SET_TIME_MSECS + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \
-               ((struct struct_name *)0)->name, unsigned int), \
-         #name, offsetof(struct struct_name, name), NULL }
-#define SETTING_DEFINE_STRUCT_STR(name, struct_name) \
-       { SET_STR + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \
-               ((struct struct_name *)0)->name, const char *), \
-         #name, offsetof(struct struct_name, name), NULL }
-#define SETTING_DEFINE_STRUCT_IN_PORT(name, struct_name) \
-       { SET_IN_PORT + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \
-               ((struct struct_name *)0)->name, in_port_t), \
-         #name, offsetof(struct struct_name, name), NULL }
+#define SETTING_DEFINE_STRUCT_TYPE(_enum_type, _c_type, _key, _name, _struct_name) \
+       { .type = (_enum_type) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \
+               ((_struct_name *)0)->_name, _c_type), \
+         .key = _key, .offset = offsetof(_struct_name, _name) }
+
+#define SETTING_DEFINE_STRUCT_BOOL(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_BOOL, bool, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_UINT(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_UINT, unsigned int, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_UINT_OCT(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_UINT_OCT, unsigned int, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_TIME(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_TIME, unsigned int, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_TIME_MSECS(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_TIME_MSECS, unsigned int, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_SIZE(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_SIZE, uoff_t, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_IN_PORT(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_IN_PORT, in_port_t, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_STR(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_STR, const char *, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_STR_VARS(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_STR_VARS, const char *, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_ENUM(key, name, struct_name) \
+       SETTING_DEFINE_STRUCT_TYPE(SET_ENUM, const char *, key, name, struct_name)
 
 struct setting_parser_info {
        const char *module_name;
index 76f9be32798b13753d87514f59eb361bbe04bd96..c5a47dd6169aab81559b98572bb676f6e0cf2047 100644 (file)
@@ -249,16 +249,16 @@ static void test_settings_parser_get(void)
                ARRAY_INIT,
        };
        const struct setting_define defs[] = {
-               SETTING_DEFINE_STRUCT_BOOL(bool_true, test_settings),
-               SETTING_DEFINE_STRUCT_BOOL(bool_false, test_settings),
-               SETTING_DEFINE_STRUCT_UINT(uint, test_settings),
+               SETTING_DEFINE_STRUCT_BOOL("bool_true", bool_true, struct test_settings),
+               SETTING_DEFINE_STRUCT_BOOL("bool_false", bool_false, struct test_settings),
+               SETTING_DEFINE_STRUCT_UINT("uint", uint, struct test_settings),
                { .type = SET_UINT_OCT, "uint_oct",
                  offsetof(struct test_settings, uint_oct), NULL },
-               SETTING_DEFINE_STRUCT_TIME(secs, test_settings),
-               SETTING_DEFINE_STRUCT_TIME_MSECS(msecs, test_settings),
-               SETTING_DEFINE_STRUCT_SIZE(size, test_settings),
-               SETTING_DEFINE_STRUCT_IN_PORT(port, test_settings),
-               SETTING_DEFINE_STRUCT_STR(str, test_settings),
+               SETTING_DEFINE_STRUCT_TIME("secs", secs, struct test_settings),
+               SETTING_DEFINE_STRUCT_TIME_MSECS("msecs", msecs, struct test_settings),
+               SETTING_DEFINE_STRUCT_SIZE("size", size, struct test_settings),
+               SETTING_DEFINE_STRUCT_IN_PORT("port", port, struct test_settings),
+               SETTING_DEFINE_STRUCT_STR("str", str, struct test_settings),
                { .type = SET_STR_VARS, "expand_str",
                  offsetof(struct test_settings, expand_str), NULL },
                { .type = SET_STRLIST, "strlist",