httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Corsix <cor...@www.corsix.org>
Subject Re: On future mod_wombat improvements
Date Sun, 04 May 2008 14:43:36 GMT
One new bit of apr "glue" to complement apr_table.get and
apr_table.set : apr_table.foreach

Index: apr_lua.c
===================================================================
--- apr_lua.c	(revision 653202)
+++ apr_lua.c	(working copy)
@@ -46,9 +46,30 @@
     return 1;
 }

+static APR_DECLARE_NONSTD(int) lua_table_foreach_iterator(void* rec,
const char* key, const char* value) {
+    int status;
+    lua_State *L = (lua_State*)rec;
+    lua_pushvalue(L, 2);
+    lua_pushstring(L, key);
+    lua_pushstring(L, value);
+    lua_call(L, 2, 1);
+    status = lua_toboolean(L, 3);
+    lua_pop(L, 1);
+    return status;
+}
+
+static int lua_table_foreach(lua_State* L) {
+    apr_table_t *t = check_apr_table(L, 1);
+    luaL_checktype(L, 2, LUA_TFUNCTION);
+    lua_settop(L, 2);
+    lua_pushboolean(L, apr_table_do(lua_table_foreach_iterator,
(void*)L, t, NULL));
+    return 1;
+}
+
 static const luaL_reg lua_table_methods[] = {
     {"set", lua_table_set},
     {"get", lua_table_get},
+    {"foreach", lua_table_foreach},
     {0, 0}
 };

2008/4/30 Akins, Brian <Brian.Akins@turner.com>:
> On 4/29/08 3:52 PM, "Maxime Petazzoni" <maxime.petazzoni@bulix.org> wrote:
>  > So, feel free to jump in and write down some
>  > ideas!
>
>  Some "short term" ideas:
>
>  -Interface/API to allow other modules to run Lua code:
>  wombat_init(/some/lua/file), wombat_run(some_lua "handle) or something
>  similar.  Mod_wombat could/should (?) use this interface internally.
>
>  -Allow <Lua hook>some lua code for this hook</Lua> in config.
>
>  -Do Lua binding in another module(s) (mod_headers, mod_expires, and mod_mime
>  look like they may be fairly easy).
>
>  -More Lua "glue" with httpd/apr as well as apreq.
>
>  -Other modules can hook into "initialization" hooks.  Ie, wombat_loadlibs
>  and push_request become hooks.  There was a version I did that did this.
>
>  Some longer term ideas:
>
>  -Lua bindings to most core modules where it makes sense.
>
>  -Ability to write "full" modules in Lua.
>
>  -mod_lsp (don't laugh, we are contemplating working on this...)
>
>
>  I have several itches that must be scratched in Lua/httpd.  I am willing to
>  help as my time permits.  I have a real project coming up that will
>  "require" some Lua integration, so I may as well base that on mod_wombat.
>
>  --
>  Brian Akins
>  Chief Operations Engineer
>  Turner Digital Media Technologies
>
>

Mime
View raw message