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

Function lua_ap_expr

modules/lua/lua_request.c:1127–1162  ·  view source on GitHub ↗

* lua_ap_expr; r:expr(string) - Evaluates an expr statement. */

Source from the content-addressed store, hash-verified

1125 * lua_ap_expr; r:expr(string) - Evaluates an expr statement.
1126 */
1127static int lua_ap_expr(lua_State *L)
1128{
1129 request_rec *r;
1130 int x = 0;
1131 const char *expr,
1132 *err;
1133 ap_expr_info_t res;
1134
1135 luaL_checktype(L, 1, LUA_TUSERDATA);
1136 luaL_checktype(L, 2, LUA_TSTRING);
1137 r = ap_lua_check_request_rec(L, 1);
1138 expr = lua_tostring(L, 2);
1139
1140
1141 res.filename = NULL;
1142 res.flags = 0;
1143 res.line_number = 0;
1144 res.module_index = APLOG_MODULE_INDEX;
1145
1146 err = ap_expr_parse(r->pool, r->pool, &res, expr, NULL);
1147 if (!err) {
1148 x = ap_expr_exec(r, &res, &err);
1149 lua_pushboolean(L, x);
1150 if (x < 0) {
1151 lua_pushstring(L, err);
1152 return 2;
1153 }
1154 return 1;
1155 } else {
1156 lua_pushboolean(L, 0);
1157 lua_pushstring(L, err);
1158 return 2;
1159 }
1160 lua_pushboolean(L, 0);
1161 return 1;
1162}
1163
1164
1165/*

Callers

nothing calls this directly

Calls 3

ap_expr_parseFunction · 0.85
ap_expr_execFunction · 0.85
ap_lua_check_request_recFunction · 0.70

Tested by

no test coverage detected