#include <common/compat.h>
#include <common/config.h>
+#include <common/initcall.h>
#include <common/mini-clist.h>
#include <proto/log.h>
return 0;
}
+/* simplified way to define a section parser */
+#define REGISTER_CONFIG_SECTION(name, parse, post) \
+ INITCALL3(STG_REGISTER, cfg_register_section, (name), (parse), (post))
+
+#define REGISTER_CONFIG_POSTPARSER(name, parser) \
+ INITCALL2(STG_REGISTER, cfg_register_postparser, (name), (parser))
+
#endif /* _COMMON_CFGPARSE_H */
/*
__attribute__((constructor))
static void __cache_init(void)
{
- cfg_register_section("cache", cfg_parse_cache, cfg_post_parse_section_cache);
- cfg_register_postparser("cache", cfg_cache_postparser);
pool_head_cache_st = create_pool("cache_st", sizeof(struct cache_st), MEM_F_SHARED);
}
+
+/* config parsers for this section */
+REGISTER_CONFIG_SECTION("cache", cfg_parse_cache, cfg_post_parse_section_cache);
+REGISTER_CONFIG_POSTPARSER("cache", cfg_cache_postparser);
}
}
-__attribute__((constructor))
-static void cfgparse_init(void)
-{
- /* Register internal sections */
- cfg_register_section("listen", cfg_parse_listen, NULL);
- cfg_register_section("frontend", cfg_parse_listen, NULL);
- cfg_register_section("backend", cfg_parse_listen, NULL);
- cfg_register_section("defaults", cfg_parse_listen, NULL);
- cfg_register_section("global", cfg_parse_global, NULL);
- cfg_register_section("userlist", cfg_parse_users, NULL);
- cfg_register_section("peers", cfg_parse_peers, NULL);
- cfg_register_section("mailers", cfg_parse_mailers, NULL);
- cfg_register_section("namespace_list", cfg_parse_netns, NULL);
- cfg_register_section("resolvers", cfg_parse_resolvers, NULL);
-}
+/* these are the config sections handled by default */
+REGISTER_CONFIG_SECTION("listen", cfg_parse_listen, NULL);
+REGISTER_CONFIG_SECTION("frontend", cfg_parse_listen, NULL);
+REGISTER_CONFIG_SECTION("backend", cfg_parse_listen, NULL);
+REGISTER_CONFIG_SECTION("defaults", cfg_parse_listen, NULL);
+REGISTER_CONFIG_SECTION("global", cfg_parse_global, NULL);
+REGISTER_CONFIG_SECTION("userlist", cfg_parse_users, NULL);
+REGISTER_CONFIG_SECTION("peers", cfg_parse_peers, NULL);
+REGISTER_CONFIG_SECTION("mailers", cfg_parse_mailers, NULL);
+REGISTER_CONFIG_SECTION("namespace_list", cfg_parse_netns, NULL);
+REGISTER_CONFIG_SECTION("resolvers", cfg_parse_resolvers, NULL);
/*
* Local variables:
{
dns_answer_item_pool = create_pool("dns_answer_item", sizeof(struct dns_answer_item), MEM_F_SHARED);
dns_resolution_pool = create_pool("dns_resolution", sizeof(struct dns_resolution), MEM_F_SHARED);
-
- cfg_register_postparser("dns runtime resolver", dns_finalize_config);
}
REGISTER_POST_DEINIT(dns_deinit);
+REGISTER_CONFIG_POSTPARSER("dns runtime resolver", dns_finalize_config);
RESET_SAFE_LJMP(gL.T);
}
-__attribute__((constructor))
-static void __hlua_init(void)
-{
- cfg_register_postparser("hlua", hlua_check_config);
-}
-
static void hlua_register_build_options(void)
{
char *ptr = NULL;
}
INITCALL0(STG_REGISTER, hlua_register_build_options);
+REGISTER_CONFIG_POSTPARSER("hlua", hlua_check_config);