helper function for walking config trees */
| 2617 | |
| 2618 | /* helper function for walking config trees */ |
| 2619 | static void read_cfg_tree(lua_State *L, request_rec *r, ap_directive_t *rcfg) { |
| 2620 | int x = 0; |
| 2621 | const char* value; |
| 2622 | ap_directive_t *cfg; |
| 2623 | lua_newtable(L); |
| 2624 | |
| 2625 | for (cfg = rcfg; cfg; cfg = cfg->next) { |
| 2626 | x++; |
| 2627 | lua_pushnumber(L, x); |
| 2628 | lua_newtable(L); |
| 2629 | value = apr_psprintf(r->pool, "%s %s", cfg->directive, cfg->args); |
| 2630 | lua_pushstring(L, "directive"); |
| 2631 | lua_pushstring(L, value); |
| 2632 | lua_settable(L, -3); |
| 2633 | lua_pushstring(L, "file"); |
| 2634 | lua_pushstring(L, cfg->filename); |
| 2635 | lua_settable(L, -3); |
| 2636 | lua_pushstring(L, "line"); |
| 2637 | lua_pushnumber(L, cfg->line_num); |
| 2638 | lua_settable(L, -3); |
| 2639 | if (cfg->first_child) { |
| 2640 | lua_pushstring(L, "children"); |
| 2641 | read_cfg_tree(L, r, cfg->first_child); |
| 2642 | lua_settable(L, -3); |
| 2643 | } |
| 2644 | lua_settable(L, -3); |
| 2645 | } |
| 2646 | } |
| 2647 | |
| 2648 | static int lua_ap_get_config(lua_State *L) { |
| 2649 | request_rec *r = ap_lua_check_request_rec(L, 1); |
no outgoing calls
no test coverage detected