Lines Matching refs:L

36 static const char * load_file(lua_State *L, void *data, size_t *size) {  in load_file()  argument
39 UNUSED(L); in load_file()
48 static int lua_to_c_get_string(lua_State *L, const char *varname, buffer *b) { in lua_to_c_get_string() argument
51 lua_pushstring(L, varname); in lua_to_c_get_string()
53 curelem = lua_gettop(L); in lua_to_c_get_string()
54 lua_gettable(L, LUA_GLOBALSINDEX); in lua_to_c_get_string()
57 if (!lua_isstring(L, curelem)) { in lua_to_c_get_string()
58 lua_settop(L, curelem - 1); in lua_to_c_get_string()
63 buffer_copy_string(b, lua_tostring(L, curelem)); in lua_to_c_get_string()
65 lua_pop(L, 1); in lua_to_c_get_string()
67 assert(curelem - 1 == lua_gettop(L)); in lua_to_c_get_string()
72 static int lua_to_c_is_table(lua_State *L, const char *varname) { in lua_to_c_is_table() argument
75 lua_pushstring(L, varname); in lua_to_c_is_table()
77 curelem = lua_gettop(L); in lua_to_c_is_table()
78 lua_gettable(L, LUA_GLOBALSINDEX); in lua_to_c_is_table()
81 if (!lua_istable(L, curelem)) { in lua_to_c_is_table()
82 lua_settop(L, curelem - 1); in lua_to_c_is_table()
87 lua_settop(L, curelem - 1); in lua_to_c_is_table()
89 assert(curelem - 1 == lua_gettop(L)); in lua_to_c_is_table()
94 static int c_to_lua_push(lua_State *L, int tbl, const char *key, size_t key_len, const char *val, s… in c_to_lua_push() argument
95 lua_pushlstring(L, key, key_len); in c_to_lua_push()
96 lua_pushlstring(L, val, val_len); in c_to_lua_push()
97 lua_settable(L, tbl); in c_to_lua_push()
103 static int cache_export_get_params(lua_State *L, int tbl, buffer *qrystr) { in cache_export_get_params() argument
131 c_to_lua_push(L, tbl, in cache_export_get_params()
209 lua_State *L; in cache_parse_lua() local
219 L = luaL_newstate(); in cache_parse_lua()
220 luaL_openlibs(L); in cache_parse_lua()
223 lua_register(L, "md5", f_crypto_md5); in cache_parse_lua()
224 lua_register(L, "file_mtime", f_file_mtime); in cache_parse_lua()
225 lua_register(L, "file_isreg", f_file_isreg); in cache_parse_lua()
226 lua_register(L, "file_isdir", f_file_isreg); in cache_parse_lua()
227 lua_register(L, "dir_files", f_dir_files); in cache_parse_lua()
230 lua_pushliteral(L, "memcache_get_long"); in cache_parse_lua()
231 lua_pushlightuserdata(L, p->conf.mc); in cache_parse_lua()
232 lua_pushcclosure(L, f_memcache_get_long, 1); in cache_parse_lua()
233 lua_settable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
235 lua_pushliteral(L, "memcache_get_string"); in cache_parse_lua()
236 lua_pushlightuserdata(L, p->conf.mc); in cache_parse_lua()
237 lua_pushcclosure(L, f_memcache_get_string, 1); in cache_parse_lua()
238 lua_settable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
240 lua_pushliteral(L, "memcache_exists"); in cache_parse_lua()
241 lua_pushlightuserdata(L, p->conf.mc); in cache_parse_lua()
242 lua_pushcclosure(L, f_memcache_exists, 1); in cache_parse_lua()
243 lua_settable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
246 lua_pushliteral(L, "request"); in cache_parse_lua()
247 lua_newtable(L); in cache_parse_lua()
248 lua_settable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
250 lua_pushliteral(L, "request"); in cache_parse_lua()
251 header_tbl = lua_gettop(L); in cache_parse_lua()
252 lua_gettable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
254 c_to_lua_push(L, header_tbl, CONST_STR_LEN("REQUEST_URI"), CONST_BUF_LEN(con->request.orig_uri)); in cache_parse_lua()
255 c_to_lua_push(L, header_tbl, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path)); in cache_parse_lua()
256 c_to_lua_push(L, header_tbl, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(con->physical.path)); in cache_parse_lua()
257 …c_to_lua_push(L, header_tbl, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root)… in cache_parse_lua()
259 c_to_lua_push(L, header_tbl, CONST_STR_LEN("PATH_INFO"), CONST_BUF_LEN(con->request.pathinfo)); in cache_parse_lua()
262 c_to_lua_push(L, header_tbl, CONST_STR_LEN("CWD"), CONST_BUF_LEN(p->basedir)); in cache_parse_lua()
263 c_to_lua_push(L, header_tbl, CONST_STR_LEN("BASEURL"), CONST_BUF_LEN(p->baseurl)); in cache_parse_lua()
266 lua_pushliteral(L, "get"); in cache_parse_lua()
267 lua_newtable(L); in cache_parse_lua()
268 lua_settable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
270 lua_pushliteral(L, "get"); in cache_parse_lua()
271 header_tbl = lua_gettop(L); in cache_parse_lua()
272 lua_gettable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
275 cache_export_get_params(L, header_tbl, b); in cache_parse_lua()
279 lua_pushliteral(L, "CACHE_HIT"); in cache_parse_lua()
280 lua_pushnumber(L, 0); in cache_parse_lua()
281 lua_settable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
283 lua_pushliteral(L, "CACHE_MISS"); in cache_parse_lua()
284 lua_pushnumber(L, 1); in cache_parse_lua()
285 lua_settable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
288 if (lua_load(L, load_file, &rm, fn->ptr) || lua_pcall(L,0,1,0)) { in cache_parse_lua()
290 lua_tostring(L,-1)); in cache_parse_lua()
296 ret = (int)lua_tonumber(L, -1); in cache_parse_lua()
297 lua_pop(L, 1); in cache_parse_lua()
300 lua_to_c_get_string(L, "trigger_handler", p->trigger_handler); in cache_parse_lua()
302 if (0 == lua_to_c_get_string(L, "output_contenttype", b)) { in cache_parse_lua()
312 if (!lua_to_c_is_table(L, "output_include")) { in cache_parse_lua()
320 lua_pushstring(L, "output_include"); in cache_parse_lua()
322 curelem = lua_gettop(L); in cache_parse_lua()
323 lua_gettable(L, LUA_GLOBALSINDEX); in cache_parse_lua()
334 lua_pushnil(L); /* first key */ in cache_parse_lua()
335 while (lua_next(L, curelem) != 0) { in cache_parse_lua()
339 if (lua_isstring(L, -1)) { in cache_parse_lua()
340 const char *s = lua_tostring(L, -1); in cache_parse_lua()
345 buffer_append_string(b, lua_tostring(L, -1)); in cache_parse_lua()
347 buffer_copy_string(b, lua_tostring(L, -1)); in cache_parse_lua()
388 lua_pop(L, 1); /* removes value'; keeps key' for next iteration */ in cache_parse_lua()
391 lua_settop(L, curelem - 1); in cache_parse_lua()
447 lua_close(L); in cache_parse_lua()