static int mtev_lua_http_request_cookie(lua_State *L) { int has_arg; CCALL_NARGS(L, 0); has_arg = (lua_gettop(L) == 2); if(lua_gettop(L) > 2) luaL_error(L, "invalid arguments to mtev_http_request:cookie()"); lua_getglobal(L, "mtev"); lua_getfield(L, -1, "extras"); lua_remove(L, -2); /* pop mtev */ lua_getfield(L, -1, "decode_cookie"); lua_remove(L, -2); /* pop extras */ lua_pushvalue(L, 1); if(has_arg) lua_pushvalue(L, 2); lua_call(L, has_arg ? 2 : 1, 1); return 1; }
static int mtev_lua_http_set_cookie(lua_State *L) { int i, n; CCALL_NARGS(L, 0); n = lua_gettop(L); if(n < 3 || n > 4) luaL_error(L, "invalid arguments to mtev_http_session:set_cookie()"); lua_getglobal(L, "mtev"); lua_getfield(L, -1, "extras"); lua_remove(L, -2); /* pop mtev */ lua_getfield(L, -1, "set_cookie"); lua_remove(L, -2); /* pop extras */ lua_pushvalue(L, 1); for(i = 2; i <= n; i++) lua_pushvalue(L, i); lua_call(L, n, 0); return 0; }
static int noit_lua_http_request_form(lua_State *L) { int has_arg; CCALL_NARGS(L, 0); has_arg = (lua_gettop(L) == 2); if(lua_gettop(L) > 2) luaL_error(L, "invalid arguments to noit_http_request:form()"); lua_getglobal(L, "noit"); lua_getfield(L, -1, "extras"); lua_remove(L, -2); /* pop noit */ lua_getfield(L, -1, "decode_form"); lua_remove(L, -2); /* pop extras */ lua_pushvalue(L, 1); if(has_arg) lua_pushvalue(L, 2); lua_call(L, has_arg ? 2 : 1, 1); return 1; }