diff --git a/doc/internals/filters.txt b/doc/internals/filters.txt index 61a01553f..09090e556 100644 --- a/doc/internals/filters.txt +++ b/doc/internals/filters.txt @@ -353,13 +353,7 @@ line: { NULL, NULL, NULL }, } }; - - __attribute__((constructor)) - static void - __my_filter_init(void) - { - flt_register_keywords(&flt_kws); - } + INITCALL1(STG_REGISTER, flt_register_keywords, &flt_kws); Then you must define the internal configuration your filter will use. For diff --git a/src/51d.c b/src/51d.c index e092c5ba8..d53796488 100644 --- a/src/51d.c +++ b/src/51d.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -667,25 +668,28 @@ static struct cfg_kw_list _51dcfg_kws = {{ }, { { 0, NULL, NULL }, }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &_51dcfg_kws); + /* Note: must not be declared as its list will be overwritten */ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { "51d.all", _51d_fetch, ARG5(1,STR,STR,STR,STR,STR), _51d_fetch_check, SMP_T_STR, SMP_USE_HRQHV }, { NULL, NULL, 0, 0, 0 }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords); + /* Note: must not be declared as its list will be overwritten */ static struct sample_conv_kw_list conv_kws = {ILH, { { "51d.single", _51d_conv, ARG5(1,STR,STR,STR,STR,STR), _51d_conv_check, SMP_T_STR, SMP_T_STR }, { NULL, NULL, 0, 0, 0 }, }}; +INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws); + __attribute__((constructor)) static void __51d_init(void) { /* register sample fetch and conversion keywords */ - sample_register_fetches(&sample_fetch_keywords); - sample_register_convs(&conv_kws); - cfg_register_keywords(&_51dcfg_kws); hap_register_build_opts("Built with 51Degrees support.", 0); hap_register_post_check(init_51degrees); hap_register_post_deinit(deinit_51degrees); diff --git a/src/acl.c b/src/acl.c index a9cf7a15e..b598088ad 100644 --- a/src/acl.c +++ b/src/acl.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -1352,12 +1353,7 @@ static struct acl_kw_list acl_kws = {ILH, { { /* END */ }, }}; -__attribute__((constructor)) -static void __acl_init(void) -{ - acl_register_keywords(&acl_kws); -} - +INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws); /* * Local variables: diff --git a/src/activity.c b/src/activity.c index 9460a8a7e..4a807c8e4 100644 --- a/src/activity.c +++ b/src/activity.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -116,6 +117,8 @@ static struct cfg_kw_list cfg_kws = {ILH, { { 0, NULL, NULL } }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + /* register cli keywords */ static struct cli_kw_list cli_kws = {{ },{ { { "show", "profiling", NULL }, "show profiling : show CPU profiling options", NULL, cli_io_handler_show_profiling, NULL }, @@ -123,9 +126,4 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; -__attribute__((constructor)) -static void __activity_init(void) -{ - cfg_register_keywords(&cfg_kws); - cli_register_kw(&cli_kws); -} +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); diff --git a/src/backend.c b/src/backend.c index e55d87c34..5aaa46d61 100644 --- a/src/backend.c +++ b/src/backend.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -2073,12 +2074,15 @@ static struct sample_fetch_kw_list smp_kws = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws); + /* Note: must not be declared as its list will be overwritten */ static struct sample_conv_kw_list sample_conv_kws = {ILH, { { "nbsrv", sample_conv_nbsrv, 0, NULL, SMP_T_STR, SMP_T_SINT }, { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws); /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted. @@ -2087,14 +2091,7 @@ static struct acl_kw_list acl_kws = {ILH, { { /* END */ }, }}; - -__attribute__((constructor)) -static void __backend_init(void) -{ - sample_register_fetches(&smp_kws); - sample_register_convs(&sample_conv_kws); - acl_register_keywords(&acl_kws); -} +INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws); /* * Local variables: diff --git a/src/cache.c b/src/cache.c index 21574339d..acab99da0 100644 --- a/src/cache.c +++ b/src/cache.c @@ -34,6 +34,7 @@ #include #include +#include /* flt_cache_store */ @@ -1184,6 +1185,7 @@ static struct cli_kw_list cli_kws = {{},{ {{},} }}; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); static struct action_kw_list http_res_actions = { .kw = { @@ -1192,6 +1194,8 @@ static struct action_kw_list http_res_actions = { } }; +INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions); + static struct action_kw_list http_req_actions = { .kw = { { "cache-use", parse_cache_use }, @@ -1199,6 +1203,8 @@ static struct action_kw_list http_req_actions = { } }; +INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions); + struct applet http_cache_applet = { .obj_type = OBJ_TYPE_APPLET, .name = "", /* used for logging */ @@ -1211,9 +1217,5 @@ static void __cache_init(void) { cfg_register_section("cache", cfg_parse_cache, cfg_post_parse_section_cache); cfg_register_postparser("cache", cfg_cache_postparser); - cli_register_kw(&cli_kws); - http_res_keywords_register(&http_res_actions); - http_req_keywords_register(&http_req_actions); pool_head_cache_st = create_pool("cache_st", sizeof(struct cache_st), MEM_F_SHARED); } - diff --git a/src/cli.c b/src/cli.c index 3f438621a..b8b233509 100644 --- a/src/cli.c +++ b/src/cli.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -2449,11 +2450,15 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); + static struct cfg_kw_list cfg_kws = {ILH, { { CFG_GLOBAL, "stats", stats_parse_global }, { 0, NULL, NULL }, }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + static struct bind_kw_list bind_kws = { "STAT", { }, { { "level", bind_parse_level, 1 }, /* set the unix socket admin level */ { "expose-fd", bind_parse_expose_fd, 1 }, /* set the unix socket expose fd rights */ @@ -2461,13 +2466,7 @@ static struct bind_kw_list bind_kws = { "STAT", { }, { { NULL, NULL, 0 }, }}; -__attribute__((constructor)) -static void __dumpstats_module_init(void) -{ - cfg_register_keywords(&cfg_kws); - cli_register_kw(&cli_kws); - bind_register_keywords(&bind_kws); -} +INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws); /* * Local variables: diff --git a/src/compression.c b/src/compression.c index d3e6f2816..b725e3130 100644 --- a/src/compression.c +++ b/src/compression.c @@ -28,8 +28,9 @@ #include #include -#include #include +#include +#include #include #include @@ -699,6 +700,8 @@ static struct cfg_kw_list cfg_kws = {ILH, { { 0, NULL, NULL } }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + __attribute__((constructor)) static void __comp_fetch_init(void) { @@ -735,5 +738,4 @@ static void __comp_fetch_init(void) memprintf(&ptr, "%s none", ptr); hap_register_build_opts(ptr, 1); - cfg_register_keywords(&cfg_kws); } diff --git a/src/connection.c b/src/connection.c index 502277290..621477557 100644 --- a/src/connection.c +++ b/src/connection.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -1314,9 +1315,4 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { /* END */ }, }}; - -__attribute__((constructor)) -static void __connection_init(void) -{ - sample_register_fetches(&sample_fetch_keywords); -} +INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords); diff --git a/src/da.c b/src/da.c index 990267a3c..c1c07e397 100644 --- a/src/da.c +++ b/src/da.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -376,25 +377,28 @@ static struct cfg_kw_list dacfg_kws = {{ }, { { 0, NULL, NULL }, }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &dacfg_kws); + /* Note: must not be declared as its list will be overwritten */ static struct sample_fetch_kw_list fetch_kws = {ILH, { { "da-csv-fetch", da_haproxy_fetch, ARG12(1,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_USE_HRQHV }, { NULL, NULL, 0, 0, 0 }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &fetch_kws); + /* Note: must not be declared as its list will be overwritten */ static struct sample_conv_kw_list conv_kws = {ILH, { { "da-csv-conv", da_haproxy_conv, ARG12(1,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_T_STR }, { NULL, NULL, 0, 0, 0 }, }}; +INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws); + __attribute__((constructor)) static void __da_init(void) { /* register sample fetch and format conversion keywords */ - sample_register_fetches(&fetch_kws); - sample_register_convs(&conv_kws); - cfg_register_keywords(&dacfg_kws); hap_register_build_opts("Built with DeviceAtlas support.", 0); hap_register_post_check(init_deviceatlas); hap_register_post_deinit(deinit_deviceatlas); diff --git a/src/dns.c b/src/dns.c index 5bce18b03..2dfbdd587 100644 --- a/src/dns.c +++ b/src/dns.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -2050,6 +2051,7 @@ static struct cli_kw_list cli_kws = {{ }, { } }; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); __attribute__((constructor)) static void __dns_init(void) @@ -2059,6 +2061,4 @@ static void __dns_init(void) cfg_register_postparser("dns runtime resolver", dns_finalize_config); hap_register_post_deinit(dns_deinit); - - cli_register_kw(&cli_kws); } diff --git a/src/filters.c b/src/filters.c index bdc106a6e..edce60380 100644 --- a/src/filters.c +++ b/src/filters.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1189,12 +1190,13 @@ static struct cfg_kw_list cfg_kws = {ILH, { } }; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + __attribute__((constructor)) static void __filters_init(void) { pool_head_filter = create_pool("filter", sizeof(struct filter), MEM_F_SHARED); - cfg_register_keywords(&cfg_kws); hap_register_post_check(flt_init_all); hap_register_per_thread_init(flt_init_all_per_thread); hap_register_per_thread_deinit(flt_deinit_all_per_thread); diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index b4f093c2a..e0cee75b4 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -993,6 +994,8 @@ static struct cfg_kw_list cfg_kws = {ILH, { } }; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + /* Declare the filter parser for "compression" keyword */ static struct flt_kw_list filter_kws = { "COMP", { }, { { "compression", parse_http_comp_flt, NULL }, @@ -1000,6 +1003,8 @@ static struct flt_kw_list filter_kws = { "COMP", { }, { } }; +INITCALL1(STG_REGISTER, flt_register_keywords, &filter_kws); + /* Note: must not be declared as its list will be overwritten */ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { "res.comp", smp_fetch_res_comp, 0, NULL, SMP_T_BOOL, SMP_USE_HRSHP }, @@ -1008,12 +1013,11 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { } }; +INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords); + __attribute__((constructor)) static void __flt_http_comp_init(void) { - cfg_register_keywords(&cfg_kws); - flt_register_keywords(&filter_kws); - sample_register_fetches(&sample_fetch_keywords); pool_head_comp_state = create_pool("comp_state", sizeof(struct comp_state), MEM_F_SHARED); } diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 02bc3d2e7..aa9d8750f 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -16,9 +16,10 @@ #include #include #include +#include +#include #include #include -#include #include #include @@ -4641,37 +4642,44 @@ static struct flt_kw_list flt_kws = { "SPOE", { }, { } }; +INITCALL1(STG_REGISTER, flt_register_keywords, &flt_kws); + /* Delcate the action parser for "spoe-action" keyword */ static struct action_kw_list tcp_req_action_kws = { { }, { { "send-spoe-group", parse_send_spoe_group }, { /* END */ }, } }; + +INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_action_kws); + static struct action_kw_list tcp_res_action_kws = { { }, { { "send-spoe-group", parse_send_spoe_group }, { /* END */ }, } }; + +INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_action_kws); + static struct action_kw_list http_req_action_kws = { { }, { { "send-spoe-group", parse_send_spoe_group }, { /* END */ }, } }; + +INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_action_kws); + static struct action_kw_list http_res_action_kws = { { }, { { "send-spoe-group", parse_send_spoe_group }, { /* END */ }, } }; +INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_action_kws); + __attribute__((constructor)) static void __spoe_init(void) { - flt_register_keywords(&flt_kws); - tcp_req_cont_keywords_register(&tcp_req_action_kws); - tcp_res_cont_keywords_register(&tcp_res_action_kws); - http_req_keywords_register(&http_req_action_kws); - http_res_keywords_register(&http_res_action_kws); - pool_head_spoe_ctx = create_pool("spoe_ctx", sizeof(struct spoe_context), MEM_F_SHARED); pool_head_spoe_appctx = create_pool("spoe_appctx", sizeof(struct spoe_appctx), MEM_F_SHARED); } diff --git a/src/flt_trace.c b/src/flt_trace.c index 6b65fe938..d5a4d93e4 100644 --- a/src/flt_trace.c +++ b/src/flt_trace.c @@ -12,10 +12,11 @@ #include +#include +#include #include #include #include -#include #include #include @@ -628,9 +629,4 @@ static struct flt_kw_list flt_kws = { "TRACE", { }, { } }; -__attribute__((constructor)) -static void -__flt_trace_init(void) -{ - flt_register_keywords(&flt_kws); -} +INITCALL1(STG_REGISTER, flt_register_keywords, &flt_kws); diff --git a/src/frontend.c b/src/frontend.c index 65c696601..716725746 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -263,6 +264,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws); /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted. @@ -271,14 +273,7 @@ static struct acl_kw_list acl_kws = {ILH, { { /* END */ }, }}; - -__attribute__((constructor)) -static void __frontend_init(void) -{ - sample_register_fetches(&smp_kws); - acl_register_keywords(&acl_kws); -} - +INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws); /* * Local variables: diff --git a/src/hlua.c b/src/hlua.c index c354af89c..d34aa798d 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -26,8 +26,9 @@ #include #include -#include #include +#include +#include #include #include @@ -7520,6 +7521,8 @@ static struct cfg_kw_list cfg_kws = {{ },{ { 0, NULL, NULL }, }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + static int hlua_check_config() { struct proxy *px; @@ -7672,9 +7675,6 @@ void hlua_init(void) /* Initialise struct hlua and com signals pool */ pool_head_hlua = create_pool("hlua", sizeof(struct hlua), MEM_F_SHARED); - /* Register configuration keywords. */ - cfg_register_keywords(&cfg_kws); - /* Init main lua stack. */ gL.Mref = LUA_REFNIL; gL.flags = 0; diff --git a/src/http_acl.c b/src/http_acl.c index 7864df89f..edd3be579 100644 --- a/src/http_acl.c +++ b/src/http_acl.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -180,11 +181,7 @@ static struct acl_kw_list acl_kws = {ILH, { { /* END */ }, }}; -__attribute__((constructor)) -static void __http_acl_init(void) -{ - acl_register_keywords(&acl_kws); -} +INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws); /* * Local variables: diff --git a/src/http_act.c b/src/http_act.c index 8ca6ba482..37cf4350a 100644 --- a/src/http_act.c +++ b/src/http_act.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -586,6 +587,8 @@ static struct action_kw_list http_req_actions = { } }; +INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions); + static struct action_kw_list http_res_actions = { .kw = { { "capture", parse_http_res_capture }, @@ -594,12 +597,7 @@ static struct action_kw_list http_res_actions = { } }; -__attribute__((constructor)) -static void __http_act_init(void) -{ - http_req_keywords_register(&http_req_actions); - http_res_keywords_register(&http_res_actions); -} +INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions); /* * Local variables: diff --git a/src/http_conv.c b/src/http_conv.c index c6cfdab39..93b748c2f 100644 --- a/src/http_conv.c +++ b/src/http_conv.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -335,11 +336,7 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, { { NULL, NULL, 0, 0, 0 }, }}; -__attribute__((constructor)) -static void __http_conv_init(void) -{ - sample_register_convs(&sample_conv_kws); -} +INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws); /* * Local variables: diff --git a/src/http_fetch.c b/src/http_fetch.c index 56c6a2bf9..389050959 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -2851,12 +2852,7 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { /* END */ }, }}; - -__attribute__((constructor)) -static void __http_fetch_init(void) -{ - sample_register_fetches(&sample_fetch_keywords); -} +INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords); /* * Local variables: diff --git a/src/listener.c b/src/listener.c index a730b1832..2a38cfd2b 100644 --- a/src/listener.c +++ b/src/listener.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -1013,6 +1014,8 @@ static struct sample_fetch_kw_list smp_kws = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws); + /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted. */ @@ -1020,6 +1023,8 @@ static struct acl_kw_list acl_kws = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws); + /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted, doing so helps * all code contributors. @@ -1040,12 +1045,11 @@ static struct bind_kw_list bind_kws = { "ALL", { }, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws); + __attribute__((constructor)) static void __listener_init(void) { - sample_register_fetches(&smp_kws); - acl_register_keywords(&acl_kws); - bind_register_keywords(&bind_kws); HA_SPIN_INIT(&lq_lock); } diff --git a/src/log.c b/src/log.c index 3db3c0d9e..5c6b8dfa9 100644 --- a/src/log.c +++ b/src/log.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -2806,12 +2807,13 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); + __attribute__((constructor)) static void __log_init(void) { hap_register_per_thread_init(init_log_buffers_per_thread); hap_register_per_thread_deinit(deinit_log_buffers_per_thread); - cli_register_kw(&cli_kws); } /* * Local variables: diff --git a/src/map.c b/src/map.c index 7eb9e3647..bfdb73d21 100644 --- a/src/map.c +++ b/src/map.c @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -1106,6 +1107,7 @@ static struct cli_kw_list cli_kws = {{ },{ { { NULL }, NULL, NULL, NULL } }}; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); /* Note: must not be declared as its list will be overwritten * @@ -1159,10 +1161,4 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, { { /* END */ }, }}; -__attribute__((constructor)) -static void __map_init(void) -{ - /* register format conversion keywords */ - sample_register_convs(&sample_conv_kws); - cli_register_kw(&cli_kws); -} +INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws); diff --git a/src/memory.c b/src/memory.c index 17ac1d1f3..1554243f0 100644 --- a/src/memory.c +++ b/src/memory.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -526,11 +527,7 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; -__attribute__((constructor)) -static void __memory_init(void) -{ - cli_register_kw(&cli_kws); -} +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); /* * Local variables: diff --git a/src/mux_h1.c b/src/mux_h1.c index 2e28d369e..c9bfaa392 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -11,6 +11,7 @@ */ #include #include +#include #include #include @@ -1823,6 +1824,8 @@ const struct mux_ops mux_h1_ops = { static struct mux_proto_list mux_proto_htx = { .token = IST(""), .mode = PROTO_MODE_HTX, .side = PROTO_SIDE_BOTH, .mux = &mux_h1_ops }; +INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_htx); + static void __h1_deinit(void) { pool_destroy(pool_head_h1c); @@ -1832,7 +1835,6 @@ static void __h1_deinit(void) __attribute__((constructor)) static void __h1_init(void) { - register_mux_proto(&mux_proto_htx); hap_register_post_deinit(__h1_deinit); pool_head_h1c = create_pool("h1c", sizeof(struct h1c), MEM_F_SHARED); pool_head_h1s = create_pool("h1s", sizeof(struct h1s), MEM_F_SHARED); diff --git a/src/mux_h2.c b/src/mux_h2.c index 0407e3808..c3cd1e12d 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -3832,6 +3833,8 @@ const struct mux_ops h2_ops = { static struct mux_proto_list mux_proto_h2 = { .token = IST("h2"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_FE, .mux = &h2_ops }; +INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_h2); + /* config keyword parsers */ static struct cfg_kw_list cfg_kws = {ILH, { { CFG_GLOBAL, "tune.h2.header-table-size", h2_parse_header_table_size }, @@ -3840,6 +3843,8 @@ static struct cfg_kw_list cfg_kws = {ILH, { { 0, NULL, NULL } }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + static void __h2_deinit(void) { pool_destroy(pool_head_h2s); @@ -3849,8 +3854,6 @@ static void __h2_deinit(void) __attribute__((constructor)) static void __h2_init(void) { - register_mux_proto(&mux_proto_h2); - cfg_register_keywords(&cfg_kws); hap_register_post_deinit(__h2_deinit); pool_head_h2c = create_pool("h2c", sizeof(struct h2c), MEM_F_SHARED); pool_head_h2s = create_pool("h2s", sizeof(struct h2s), MEM_F_SHARED); diff --git a/src/mux_pt.c b/src/mux_pt.c index a974ec302..8e9c651fd 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -316,10 +317,11 @@ const struct mux_ops mux_pt_ops = { static struct mux_proto_list mux_proto_pt = { .token = IST(""), .mode = PROTO_MODE_ANY, .side = PROTO_SIDE_BOTH, .mux = &mux_pt_ops }; +INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_pt); + __attribute__((constructor)) static void __mux_pt_init(void) { - register_mux_proto(&mux_proto_pt); pool_head_pt_ctx = create_pool("mux_pt", sizeof(struct mux_pt_ctx), MEM_F_SHARED); } diff --git a/src/payload.c b/src/payload.c index 054168a51..14191a7e2 100644 --- a/src/payload.c +++ b/src/payload.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -1151,6 +1152,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws); /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted. @@ -1166,13 +1168,7 @@ static struct acl_kw_list acl_kws = {ILH, { { /* END */ }, }}; - -__attribute__((constructor)) -static void __payload_init(void) -{ - sample_register_fetches(&smp_kws); - acl_register_keywords(&acl_kws); -} +INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws); /* * Local variables: diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index ba82c5ea5..ef0e72563 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -74,6 +75,8 @@ static struct protocol proto_sockpair = { .nb_listeners = 0, }; +INITCALL1(STG_REGISTER, protocol_register, &proto_sockpair); + /* Add to the list of sockpair listeners (port is ignored). The * listener's state is automatically updated from LI_INIT to LI_ASSIGNED. * The number of listeners for the protocol is updated. @@ -389,12 +392,6 @@ int recv_fd_uxst(int sock) return recv_fd; } -__attribute__((constructor)) -static void __uxst_protocol_init(void) -{ - protocol_register(&proto_sockpair); -} - /* * Local variables: * c-indent-level: 8 diff --git a/src/proto_tcp.c b/src/proto_tcp.c index c7951c55a..26926680f 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,8 @@ static struct protocol proto_tcpv4 = { .nb_listeners = 0, }; +INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv4); + /* Note: must not be declared as its list will be overwritten */ static struct protocol proto_tcpv6 = { .name = "tcpv6", @@ -113,6 +116,8 @@ static struct protocol proto_tcpv6 = { .nb_listeners = 0, }; +INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv6); + /* Default TCP parameters, got by opening a temporary TCP socket. */ #ifdef TCP_MAXSEG static THREAD_LOCAL int default_tcp_maxseg = -1; @@ -1913,6 +1918,8 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords); + /************************************************************************/ /* All supported bind keywords must be declared here. */ /************************************************************************/ @@ -1960,6 +1967,8 @@ static struct bind_kw_list bind_kws = { "TCP", { }, { { NULL, NULL, 0 }, }}; +INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws); + static struct srv_kw_list srv_kws = { "TCP", { }, { #ifdef TCP_USER_TIMEOUT { "tcp-ut", srv_parse_tcp_ut, 1, 1 }, /* set TCP user timeout on server */ @@ -1967,6 +1976,8 @@ static struct srv_kw_list srv_kws = { "TCP", { }, { { NULL, NULL, 0 }, }}; +INITCALL1(STG_REGISTER, srv_register_keywords, &srv_kws); + static struct action_kw_list tcp_req_conn_actions = {ILH, { { "silent-drop", tcp_parse_silent_drop }, { "set-src", tcp_parse_set_src_dst }, @@ -1976,6 +1987,8 @@ static struct action_kw_list tcp_req_conn_actions = {ILH, { { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_conn_keywords_register, &tcp_req_conn_actions); + static struct action_kw_list tcp_req_sess_actions = {ILH, { { "silent-drop", tcp_parse_silent_drop }, { "set-src", tcp_parse_set_src_dst }, @@ -1985,16 +1998,22 @@ static struct action_kw_list tcp_req_sess_actions = {ILH, { { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_req_sess_actions); + static struct action_kw_list tcp_req_cont_actions = {ILH, { { "silent-drop", tcp_parse_silent_drop }, { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_cont_actions); + static struct action_kw_list tcp_res_cont_actions = {ILH, { { "silent-drop", tcp_parse_silent_drop }, { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_cont_actions); + static struct action_kw_list http_req_actions = {ILH, { { "silent-drop", tcp_parse_silent_drop }, { "set-src", tcp_parse_set_src_dst }, @@ -2004,28 +2023,18 @@ static struct action_kw_list http_req_actions = {ILH, { { /* END */ } }}; +INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions); + static struct action_kw_list http_res_actions = {ILH, { { "silent-drop", tcp_parse_silent_drop }, { /* END */ } }}; +INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions); __attribute__((constructor)) static void __tcp_protocol_init(void) { - protocol_register(&proto_tcpv4); - protocol_register(&proto_tcpv6); - sample_register_fetches(&sample_fetch_keywords); - bind_register_keywords(&bind_kws); - srv_register_keywords(&srv_kws); - tcp_req_conn_keywords_register(&tcp_req_conn_actions); - tcp_req_sess_keywords_register(&tcp_req_sess_actions); - tcp_req_cont_keywords_register(&tcp_req_cont_actions); - tcp_res_cont_keywords_register(&tcp_res_cont_actions); - http_req_keywords_register(&http_req_actions); - http_res_keywords_register(&http_res_actions); - - hap_register_build_opts("Built with transparent proxy support using:" #if defined(IP_TRANSPARENT) " IP_TRANSPARENT" diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 149ba8e32..878a10db5 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -77,6 +78,8 @@ static struct protocol proto_unix = { .nb_listeners = 0, }; +INITCALL1(STG_REGISTER, protocol_register, &proto_unix); + /******************************** * 1) low-level socket functions ********************************/ @@ -720,17 +723,7 @@ static struct bind_kw_list bind_kws = { "UNIX", { }, { { NULL, NULL, 0 }, }}; -/******************************** - * 4) high-level functions - ********************************/ - -__attribute__((constructor)) -static void __uxst_protocol_init(void) -{ - protocol_register(&proto_unix); - bind_register_keywords(&bind_kws); -} - +INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws); /* * Local variables: diff --git a/src/proxy.c b/src/proxy.c index 76d84a24f..f8d22b633 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -1497,6 +1498,8 @@ static struct cfg_kw_list cfg_kws = {ILH, { { 0, NULL, NULL }, }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + /* Expects to find a frontend named and returns it, otherwise displays various * adequate error messages and returns NULL. This function is designed to be used by * functions requiring a frontend on the CLI. @@ -2229,12 +2232,7 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; -__attribute__((constructor)) -static void __proxy_module_init(void) -{ - cfg_register_keywords(&cfg_kws); - cli_register_kw(&cli_kws); -} +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); /* * Local variables: diff --git a/src/queue.c b/src/queue.c index a5f129d50..fa02b4adb 100644 --- a/src/queue.c +++ b/src/queue.c @@ -70,6 +70,7 @@ */ #include +#include #include #include #include @@ -601,12 +602,16 @@ static struct action_kw_list tcp_cont_kws = {ILH, { { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_cont_kws); + static struct action_kw_list http_req_kws = {ILH, { { "set-priority-class", parse_set_priority_class }, { "set-priority-offset", parse_set_priority_offset }, { /* END */ } }}; +INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_kws); + static int smp_fetch_priority_class(const struct arg *args, struct sample *smp, const char *kw, void *private) { @@ -638,13 +643,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, { { /* END */}, }}; -__attribute__((constructor)) -static void __queue_init(void) -{ - tcp_req_cont_keywords_register(&tcp_cont_kws); - http_req_keywords_register(&http_req_kws); - sample_register_fetches(&smp_kws); -} +INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws); /* * Local variables: diff --git a/src/sample.c b/src/sample.c index 8ca454064..134ff76f5 100644 --- a/src/sample.c +++ b/src/sample.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -3089,6 +3090,8 @@ static struct sample_fetch_kw_list smp_kws = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws); + /* Note: must not be declared as its list will be overwritten */ static struct sample_conv_kw_list sample_conv_kws = {ILH, { #ifdef DEBUG_EXPR @@ -3139,10 +3142,4 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, { { NULL, NULL, 0, 0, 0 }, }}; -__attribute__((constructor)) -static void __sample_init(void) -{ - /* register sample fetch and format conversion keywords */ - sample_register_fetches(&smp_kws); - sample_register_convs(&sample_conv_kws); -} +INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws); diff --git a/src/server.c b/src/server.c index 0cf5ecaf5..eb2bc6e9c 100644 --- a/src/server.c +++ b/src/server.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -1221,11 +1222,7 @@ static struct srv_kw_list srv_kws = { "ALL", { }, { { NULL, NULL, 0 }, }}; -__attribute__((constructor)) -static void __listener_init(void) -{ - srv_register_keywords(&srv_kws); -} +INITCALL1(STG_REGISTER, srv_register_keywords, &srv_kws); /* Recomputes the server's eweight based on its state, uweight, the current time, * and the proxy's algorihtm. To be used after updating sv->uweight. The warmup @@ -4700,11 +4697,7 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; -__attribute__((constructor)) -static void __server_init(void) -{ - cli_register_kw(&cli_kws); -} +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); /* * This function applies server's status changes, it is diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 4fb984f27..174ed1f95 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -8927,6 +8928,7 @@ static struct cli_kw_list cli_kws = {{ },{ { { NULL }, NULL, NULL, NULL } }}; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted. @@ -9010,6 +9012,8 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { NULL, NULL, 0, 0, 0 }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords); + /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted. */ @@ -9019,6 +9023,8 @@ static struct acl_kw_list acl_kws = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws); + /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted, doing so helps * all code contributors. @@ -9045,6 +9051,8 @@ static struct ssl_bind_kw ssl_bind_kws[] = { { NULL, NULL, 0 }, }; +/* no initcall for ssl_bind_kws, these ones are parsed in the parser loop */ + static struct bind_kw_list bind_kws = { "SSL", { }, { { "allow-0rtt", bind_parse_allow_0rtt, 0 }, /* Allow 0RTT */ { "alpn", bind_parse_alpn, 1 }, /* set ALPN supported protocols */ @@ -9086,6 +9094,8 @@ static struct bind_kw_list bind_kws = { "SSL", { }, { { NULL, NULL, 0 }, }}; +INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws); + /* Note: must not be declared as its list will be overwritten. * Please take care of keeping this list alphabetically sorted, doing so helps * all code contributors. @@ -9135,6 +9145,8 @@ static struct srv_kw_list srv_kws = { "SSL", { }, { { NULL, NULL, 0, 0 }, }}; +INITCALL1(STG_REGISTER, srv_register_keywords, &srv_kws); + static struct cfg_kw_list cfg_kws = {ILH, { { CFG_GLOBAL, "ca-base", ssl_parse_global_ca_crt_base }, { CFG_GLOBAL, "crt-base", ssl_parse_global_ca_crt_base }, @@ -9166,6 +9178,8 @@ static struct cfg_kw_list cfg_kws = {ILH, { { 0, NULL, NULL }, }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + /* transport-layer operations for SSL sockets */ static struct xprt_ops ssl_sock = { .snd_buf = ssl_sock_from_buf, @@ -9217,6 +9231,8 @@ static struct action_kw_list http_req_actions = {ILH, { { /* END */ } }}; +INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions); + #if (OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined OPENSSL_NO_TLSEXT && !defined OPENSSL_IS_BORINGSSL && !defined LIBRESSL_VERSION_NUMBER) static void ssl_sock_sctl_free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, int idx, long argl, void *argp) @@ -9265,12 +9281,6 @@ static void __ssl_sock_init(void) ssl_app_data_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL); ssl_capture_ptr_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, ssl_sock_capture_free_func); ssl_pkey_info_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL); - sample_register_fetches(&sample_fetch_keywords); - acl_register_keywords(&acl_kws); - bind_register_keywords(&bind_kws); - srv_register_keywords(&srv_kws); - cfg_register_keywords(&cfg_kws); - cli_register_kw(&cli_kws); #ifndef OPENSSL_NO_ENGINE ENGINE_load_builtin_engines(); hap_register_post_check(ssl_check_async_engine_count); @@ -9330,8 +9340,6 @@ static void __ssl_sock_init(void) #endif /* Load SSL string for the verbose & debug mode. */ ERR_load_SSL_strings(); - - http_req_keywords_register(&http_req_actions); } #ifndef OPENSSL_NO_ENGINE diff --git a/src/stats.c b/src/stats.c index 9b0800edd..d0544a336 100644 --- a/src/stats.c +++ b/src/stats.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -3965,6 +3966,8 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); + struct applet http_stats_applet = { .obj_type = OBJ_TYPE_APPLET, .name = "", /* used for logging */ @@ -3972,12 +3975,6 @@ struct applet http_stats_applet = { .release = NULL, }; -__attribute__((constructor)) -static void __stat_init(void) -{ - cli_register_kw(&cli_kws); -} - /* * Local variables: * c-indent-level: 8 diff --git a/src/stick_table.c b/src/stick_table.c index 6bddc90c4..e24ef65b6 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -3626,6 +3627,7 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); static struct action_kw_list tcp_conn_kws = { { }, { { "sc-inc-gpc0", parse_inc_gpc0, 1 }, @@ -3634,6 +3636,8 @@ static struct action_kw_list tcp_conn_kws = { { }, { { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_conn_keywords_register, &tcp_conn_kws); + static struct action_kw_list tcp_sess_kws = { { }, { { "sc-inc-gpc0", parse_inc_gpc0, 1 }, { "sc-inc-gpc1", parse_inc_gpc1, 1 }, @@ -3641,6 +3645,8 @@ static struct action_kw_list tcp_sess_kws = { { }, { { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_sess_kws); + static struct action_kw_list tcp_req_kws = { { }, { { "sc-inc-gpc0", parse_inc_gpc0, 1 }, { "sc-inc-gpc1", parse_inc_gpc1, 1 }, @@ -3648,6 +3654,8 @@ static struct action_kw_list tcp_req_kws = { { }, { { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_kws); + static struct action_kw_list tcp_res_kws = { { }, { { "sc-inc-gpc0", parse_inc_gpc0, 1 }, { "sc-inc-gpc1", parse_inc_gpc1, 1 }, @@ -3655,6 +3663,8 @@ static struct action_kw_list tcp_res_kws = { { }, { { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_kws); + static struct action_kw_list http_req_kws = { { }, { { "sc-inc-gpc0", parse_inc_gpc0, 1 }, { "sc-inc-gpc1", parse_inc_gpc1, 1 }, @@ -3662,6 +3672,8 @@ static struct action_kw_list http_req_kws = { { }, { { /* END */ } }}; +INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_kws); + static struct action_kw_list http_res_kws = { { }, { { "sc-inc-gpc0", parse_inc_gpc0, 1 }, { "sc-inc-gpc1", parse_inc_gpc1, 1 }, @@ -3669,6 +3681,8 @@ static struct action_kw_list http_res_kws = { { }, { { /* END */ } }}; +INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_kws); + ///* Note: must not be declared as its list will be overwritten. // * Please take care of keeping this list alphabetically sorted. // */ @@ -3805,6 +3819,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &smp_fetch_keywords); /* Note: must not be declared as its list will be overwritten */ static struct sample_conv_kw_list sample_conv_kws = {ILH, { @@ -3832,19 +3847,4 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, { { /* END */ }, }}; -__attribute__((constructor)) -static void __stick_table_init(void) -{ - /* register som action keywords. */ - tcp_req_conn_keywords_register(&tcp_conn_kws); - tcp_req_sess_keywords_register(&tcp_sess_kws); - tcp_req_cont_keywords_register(&tcp_req_kws); - tcp_res_cont_keywords_register(&tcp_res_kws); - http_req_keywords_register(&http_req_kws); - http_res_keywords_register(&http_res_kws); - - /* register sample fetch and format conversion keywords */ - sample_register_fetches(&smp_fetch_keywords); - sample_register_convs(&sample_conv_kws); - cli_register_kw(&cli_kws); -} +INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws); diff --git a/src/stream.c b/src/stream.c index eda2aed11..31146d27f 100644 --- a/src/stream.c +++ b/src/stream.c @@ -18,8 +18,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -3411,24 +3412,22 @@ static struct cli_kw_list cli_kws = {{ },{ {{},} }}; +INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); + /* main configuration keyword registration. */ static struct action_kw_list stream_tcp_keywords = { ILH, { { "use-service", stream_parse_use_service }, { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &stream_tcp_keywords); + static struct action_kw_list stream_http_keywords = { ILH, { { "use-service", stream_parse_use_service }, { /* END */ } }}; -__attribute__((constructor)) -static void __stream_init(void) -{ - tcp_req_cont_keywords_register(&stream_tcp_keywords); - http_req_keywords_register(&stream_http_keywords); - cli_register_kw(&cli_kws); -} +INITCALL1(STG_REGISTER, http_req_keywords_register, &stream_http_keywords); /* * Local variables: diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 564b1eaa4..602749c49 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -1191,12 +1192,7 @@ static struct cfg_kw_list cfg_kws = {ILH, { { 0, NULL, NULL }, }}; - -__attribute__((constructor)) -static void __tcp_protocol_init(void) -{ - cfg_register_keywords(&cfg_kws); -} +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); /* * Local variables: diff --git a/src/vars.c b/src/vars.c index 8f757f9bd..e44a78600 100644 --- a/src/vars.c +++ b/src/vars.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -861,42 +862,56 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords); + static struct sample_conv_kw_list sample_conv_kws = {ILH, { { "set-var", smp_conv_store, ARG1(1,STR), conv_check_var, SMP_T_ANY, SMP_T_ANY }, { "unset-var", smp_conv_clear, ARG1(1,STR), conv_check_var, SMP_T_ANY, SMP_T_ANY }, { /* END */ }, }}; +INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws); + static struct action_kw_list tcp_req_sess_kws = { { }, { { "set-var", parse_store, 1 }, { "unset-var", parse_store, 1 }, { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_req_sess_kws); + static struct action_kw_list tcp_req_cont_kws = { { }, { { "set-var", parse_store, 1 }, { "unset-var", parse_store, 1 }, { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_cont_kws); + static struct action_kw_list tcp_res_kws = { { }, { { "set-var", parse_store, 1 }, { "unset-var", parse_store, 1 }, { /* END */ } }}; +INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_kws); + static struct action_kw_list http_req_kws = { { }, { { "set-var", parse_store, 1 }, { "unset-var", parse_store, 1 }, { /* END */ } }}; +INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_kws); + static struct action_kw_list http_res_kws = { { }, { { "set-var", parse_store, 1 }, { "unset-var", parse_store, 1 }, { /* END */ } }}; +INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_kws); + static struct cfg_kw_list cfg_kws = {{ },{ { CFG_GLOBAL, "tune.vars.global-max-size", vars_max_size_global }, { CFG_GLOBAL, "tune.vars.proc-max-size", vars_max_size_proc }, @@ -906,19 +921,12 @@ static struct cfg_kw_list cfg_kws = {{ },{ { /* END */ } }}; +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + __attribute__((constructor)) static void __vars_init(void) { var_pool = create_pool("vars", sizeof(struct var), MEM_F_SHARED); - sample_register_fetches(&sample_fetch_keywords); - sample_register_convs(&sample_conv_kws); - tcp_req_sess_keywords_register(&tcp_req_sess_kws); - tcp_req_cont_keywords_register(&tcp_req_cont_kws); - tcp_res_cont_keywords_register(&tcp_res_kws); - http_req_keywords_register(&http_req_kws); - http_res_keywords_register(&http_res_kws); - cfg_register_keywords(&cfg_kws); - HA_RWLOCK_INIT(&var_names_rwlock); } diff --git a/src/wurfl.c b/src/wurfl.c index f7ac9b665..eb1fb472d 100644 --- a/src/wurfl.c +++ b/src/wurfl.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -669,6 +670,8 @@ static struct cfg_kw_list wurflcfg_kws = {{ }, { } }; +INITCALL1(STG_REGISTER, cfg_register_keywords, &wurflcfg_kws); + /* Note: must not be declared as its list will be overwritten */ static struct sample_fetch_kw_list fetch_kws = {ILH, { { "wurfl-get-all", ha_wurfl_get_all, 0, NULL, SMP_T_STR, SMP_USE_HRQHV }, @@ -677,19 +680,20 @@ static struct sample_fetch_kw_list fetch_kws = {ILH, { } }; +INITCALL1(STG_REGISTER, sample_register_fetches, &fetch_kws); + /* Note: must not be declared as its list will be overwritten */ static struct sample_conv_kw_list conv_kws = {ILH, { { NULL, NULL, 0, 0, 0 }, } }; +INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws); + __attribute__((constructor)) static void __wurfl_init(void) { /* register sample fetch and format conversion keywords */ - sample_register_fetches(&fetch_kws); - sample_register_convs(&conv_kws); - cfg_register_keywords(&wurflcfg_kws); hap_register_build_opts("Built with WURFL support.", 0); hap_register_post_check(ha_wurfl_init); hap_register_post_deinit(ha_wurfl_deinit);