};
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
};
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;
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",