Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int req_dispatch(lua_State* L) {
- request_rec* r = check_request_rec(L, 1);
- const char *name = luaL_checkstring(L, 2);
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "dispatching %s", name);
- lua_pop(L, 2);
- lua_getfield(L, LUA_REGISTRYINDEX, "Apache2.Request.dispatch");
- apr_hash_t* dispatch = lua_touserdata(L, 1);
- lua_pop(L, 1);
- req_fun_t* rft = apr_hash_get(dispatch, name, APR_HASH_KEY_STRING);
- if (rft) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "rft -> %d, type -> %d", (int)rft, rft->type);
- switch(rft->type) {
- case APW_REQ_FUNTYPE_LUACFUN: {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "%s -> lua_CFunction", name);
- lua_CFunction func = rft->fun;
- lua_pushcfunction(L, func);
- return 1;
- }
- case APW_REQ_FUNTYPE_STRING: {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "%s -> string", name);
- req_field_string_f func = rft->fun;
- char* rs = (*func)(r);
- lua_pushstring(L, rs);
- return 1;
- }
- case APW_REQ_FUNTYPE_INT: {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "%s -> int", name);
- req_field_int_f func = rft->fun;
- int rs = (*func)(r);
- lua_pushnumber(L, rs);
- return 1;
- }
- case APW_REQ_FUNTYPE_BOOLEAN: {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "%s -> boolean", name);
- req_field_int_f func = rft->fun;
- int rs = (*func)(r);
- lua_pushboolean(L, rs);
- return 1;
- }
- }
- }
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "nothing for %s", name);
- return 0;
- }
Add Comment
Please, Sign In to add comment