MCPcopy Create free account
hub / github.com/apache/httpd / cfg_lua_map_handler

Function cfg_lua_map_handler

modules/lua/lua_config.c:82–135  ·  view source on GitHub ↗

Change to use ap_lua_map_handler */

Source from the content-addressed store, hash-verified

80
81/* Change to use ap_lua_map_handler */
82static int cfg_lua_map_handler(lua_State *L)
83{
84 ap_lua_dir_cfg *cfg = check_dir_config(L, 1);
85 ap_lua_mapped_handler_spec *handler =
86 apr_pcalloc(cfg->pool, sizeof(ap_lua_mapped_handler_spec));
87 handler->uri_pattern = NULL;
88 handler->function_name = NULL;
89
90 luaL_checktype(L, 2, LUA_TTABLE);
91 lua_getfield(L, 2, "file");
92 if (lua_isstring(L, -1)) {
93 const char *file = lua_tostring(L, -1);
94 handler->file_name = apr_pstrdup(cfg->pool, file);
95 }
96 lua_pop(L, 1);
97
98 lua_getfield(L, 2, "pattern");
99 if (lua_isstring(L, -1)) {
100 const char *pattern = lua_tostring(L, -1);
101
102 ap_regex_t *uri_pattern = apr_palloc(cfg->pool, sizeof(ap_regex_t));
103 if (ap_regcomp(uri_pattern, pattern, 0) != OK) {
104 return luaL_error(L, "Unable to compile regular expression, '%s'",
105 pattern);
106 }
107 handler->uri_pattern = uri_pattern;
108 }
109 lua_pop(L, 1);
110
111 lua_getfield(L, 2, "scope");
112 if (lua_isstring(L, -1)) {
113 const char *scope = lua_tostring(L, -1);
114 handler->scope = apl_toscope(scope);
115 }
116 else {
117 handler->scope = AP_LUA_SCOPE_ONCE;
118 }
119 lua_pop(L, 1);
120
121 lua_getfield(L, 2, "func");
122 if (lua_isstring(L, -1)) {
123 const char *value = lua_tostring(L, -1);
124 handler->function_name = apr_pstrdup(cfg->pool, value);
125 }
126 else {
127 handler->function_name = "handle";
128 }
129 lua_pop(L, 1);
130
131
132 *(const ap_lua_mapped_handler_spec **) apr_array_push(cfg->mapped_handlers) =
133 handler;
134 return 0;
135}
136
137static int cfg_directory(lua_State *L)
138{

Callers

nothing calls this directly

Calls 3

check_dir_configFunction · 0.85
ap_regcompFunction · 0.85
apl_toscopeFunction · 0.85

Tested by

no test coverage detected