You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2008/12/21 22:41:53 UTC

svn commit: r728516 [1/2] - in /httpd/httpd/trunk/modules/lua: lua_apr.c lua_apr.h lua_config.c lua_config.h lua_request.c lua_request.h lua_vmprep.c lua_vmprep.h mod_lua.c mod_lua.h

Author: pquerna
Date: Sun Dec 21 13:41:52 2008
New Revision: 728516

URL: http://svn.apache.org/viewvc?rev=728516&view=rev
Log:
Reformat mod_lua according to the HTTP Server Project C Style Guide:
  <http://httpd.apache.org/dev/styleguide.html>
No functional changes.

Modified:
    httpd/httpd/trunk/modules/lua/lua_apr.c
    httpd/httpd/trunk/modules/lua/lua_apr.h
    httpd/httpd/trunk/modules/lua/lua_config.c
    httpd/httpd/trunk/modules/lua/lua_config.h
    httpd/httpd/trunk/modules/lua/lua_request.c
    httpd/httpd/trunk/modules/lua/lua_request.h
    httpd/httpd/trunk/modules/lua/lua_vmprep.c
    httpd/httpd/trunk/modules/lua/lua_vmprep.h
    httpd/httpd/trunk/modules/lua/mod_lua.c
    httpd/httpd/trunk/modules/lua/mod_lua.h

Modified: httpd/httpd/trunk/modules/lua/lua_apr.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_apr.c?rev=728516&r1=728515&r2=728516&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_apr.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_apr.c Sun Dec 21 13:41:52 2008
@@ -32,32 +32,36 @@
 #endif
 
 
-apr_table_t* check_apr_table(lua_State* L, int index) {
+apr_table_t *check_apr_table(lua_State *L, int index)
+{
     luaL_checkudata(L, index, "Apr.Table");
-    apr_table_t* t = (apr_table_t*)lua_unboxpointer(L, index);
+    apr_table_t *t = (apr_table_t *) lua_unboxpointer(L, index);
     return t;
 }
 
 
-void apl_push_apr_table(lua_State* L, const char *name, apr_table_t *t) {
-    lua_boxpointer(L, t);    
+void apl_push_apr_table(lua_State *L, const char *name, apr_table_t *t)
+{
+    lua_boxpointer(L, t);
     luaL_getmetatable(L, "Apr.Table");
     lua_setmetatable(L, -2);
     lua_setfield(L, -2, name);
 }
 
-static int lua_table_set(lua_State* L) {
+static int lua_table_set(lua_State *L)
+{
     apr_table_t *t = check_apr_table(L, 1);
-    const char* key = luaL_checkstring(L, 2);
-    const char* val = luaL_checkstring(L, 3);
+    const char *key = luaL_checkstring(L, 2);
+    const char *val = luaL_checkstring(L, 3);
 
     apr_table_set(t, key, val);
     return 0;
 }
 
-static int lua_table_get(lua_State* L) {
+static int lua_table_get(lua_State *L)
+{
     apr_table_t *t = check_apr_table(L, 1);
-    const char* key = luaL_checkstring(L, 2);
+    const char *key = luaL_checkstring(L, 2);
     const char *val = apr_table_get(t, key);
     lua_pushstring(L, val);
     return 1;
@@ -70,7 +74,8 @@
 };
 
 
-int apr_lua_init(lua_State *L, apr_pool_t *p) {
+int apr_lua_init(lua_State *L, apr_pool_t *p)
+{
     luaL_newmetatable(L, "Apr.Table");
     luaL_openlib(L, "apr_table", lua_table_methods, 0);
     lua_pushstring(L, "__index");
@@ -82,7 +87,6 @@
     lua_pushstring(L, "set");
     lua_gettable(L, 2);
     lua_settable(L, 1);
-    
+
     return 0;
 }
-

Modified: httpd/httpd/trunk/modules/lua/lua_apr.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_apr.h?rev=728516&r1=728515&r2=728516&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_apr.h (original)
+++ httpd/httpd/trunk/modules/lua/lua_apr.h Sun Dec 21 13:41:52 2008
@@ -18,8 +18,8 @@
 #ifndef _LUA_APR_H_
 #define _LUA_APR_H_
 
-int apr_lua_init(lua_State *L, apr_pool_t *p);
-apr_table_t* check_apr_table(lua_State* L, int index);
-void apl_push_apr_table(lua_State* L, const char *name, apr_table_t *t);
+int apr_lua_init(lua_State *L, apr_pool_t * p);
+apr_table_t *check_apr_table(lua_State *L, int index);
+void apl_push_apr_table(lua_State *L, const char *name, apr_table_t *t);
 
 #endif /* !_LUA_APR_H_ */

Modified: httpd/httpd/trunk/modules/lua/lua_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_config.c?rev=728516&r1=728515&r2=728516&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_config.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_config.c Sun Dec 21 13:41:52 2008
@@ -14,41 +14,50 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 #include "lua_config.h"
 #include "lua_vmprep.h"
 
-static apl_dir_cfg* check_dir_config(lua_State* L, int index) {
+static apl_dir_cfg *check_dir_config(lua_State *L, int index)
+{
     luaL_checkudata(L, index, "Apache2.DirConfig");
-    apl_dir_cfg *cfg = (apl_dir_cfg*)lua_unboxpointer(L, index);
-    return cfg;    
+    apl_dir_cfg *cfg = (apl_dir_cfg *) lua_unboxpointer(L, index);
+    return cfg;
 }
 
-static cmd_parms* check_cmd_parms(lua_State* L, int index) {
+static cmd_parms *check_cmd_parms(lua_State *L, int index)
+{
     luaL_checkudata(L, index, "Apache2.CommandParameters");
-    cmd_parms *cmd = (cmd_parms*)lua_unboxpointer(L, index);
-    return cmd;    
+    cmd_parms *cmd = (cmd_parms *) lua_unboxpointer(L, index);
+    return cmd;
 }
 
-static int apl_toscope(const char *name) {
-    if (0 == apr_strnatcmp("once", name)) return APL_SCOPE_ONCE;
-    if (0 == apr_strnatcmp("request", name)) return APL_SCOPE_REQUEST;
-    if (0 == apr_strnatcmp("connection", name)) return APL_SCOPE_CONN;
-    if (0 == apr_strnatcmp("conn", name)) return APL_SCOPE_CONN;
-    if (0 == apr_strnatcmp("server", name)) return APL_SCOPE_SERVER;
+static int apl_toscope(const char *name)
+{
+    if (0 == apr_strnatcmp("once", name))
+        return APL_SCOPE_ONCE;
+    if (0 == apr_strnatcmp("request", name))
+        return APL_SCOPE_REQUEST;
+    if (0 == apr_strnatcmp("connection", name))
+        return APL_SCOPE_CONN;
+    if (0 == apr_strnatcmp("conn", name))
+        return APL_SCOPE_CONN;
+    if (0 == apr_strnatcmp("server", name))
+        return APL_SCOPE_SERVER;
     return APL_SCOPE_ONCE;
 }
 
-apr_status_t apl_lua_map_handler(apl_dir_cfg *cfg, 
-                                 const char *file, 
+apr_status_t apl_lua_map_handler(apl_dir_cfg *cfg,
+                                 const char *file,
                                  const char *function,
-                                 const char *pattern,
-                                 const char *scope) {
+                                 const char *pattern, const char *scope)
+{
     apr_status_t rv;
-    apl_mapped_handler_spec *handler = apr_palloc(cfg->pool, sizeof(apl_mapped_handler_spec));
+    apl_mapped_handler_spec *handler =
+        apr_palloc(cfg->pool, sizeof(apl_mapped_handler_spec));
     handler->uri_pattern = NULL;
     handler->function_name = NULL;
-    
+
     ap_regex_t *uri_pattern = apr_palloc(cfg->pool, sizeof(ap_regex_t));
     if ((rv = ap_regcomp(uri_pattern, pattern, 0)) != APR_SUCCESS) {
         return rv;
@@ -56,19 +65,22 @@
     handler->file_name = apr_pstrdup(cfg->pool, file);
     handler->uri_pattern = uri_pattern;
     handler->scope = apl_toscope(scope);
-    
+
     handler->function_name = apr_pstrdup(cfg->pool, function);
-    *(const apl_mapped_handler_spec**)apr_array_push(cfg->mapped_handlers) = handler;    
+    *(const apl_mapped_handler_spec **) apr_array_push(cfg->mapped_handlers) =
+        handler;
     return APR_SUCCESS;
 }
 
 /* Change to use apl_lua_map_handler */
-static int cfg_lua_map_handler(lua_State *L) {
+static int cfg_lua_map_handler(lua_State *L)
+{
     apl_dir_cfg *cfg = check_dir_config(L, 1);
-    apl_mapped_handler_spec *handler = apr_palloc(cfg->pool, sizeof(apl_mapped_handler_spec));
+    apl_mapped_handler_spec *handler =
+        apr_palloc(cfg->pool, sizeof(apl_mapped_handler_spec));
     handler->uri_pattern = NULL;
     handler->function_name = NULL;
-    
+
     luaL_checktype(L, 2, LUA_TTABLE);
     lua_getfield(L, 2, "file");
     if (lua_isstring(L, -1)) {
@@ -76,19 +88,20 @@
         handler->file_name = apr_pstrdup(cfg->pool, file);
     }
     lua_pop(L, 1);
-    
+
     lua_getfield(L, 2, "pattern");
     if (lua_isstring(L, -1)) {
         const char *pattern = lua_tostring(L, -1);
-        
+
         ap_regex_t *uri_pattern = apr_palloc(cfg->pool, sizeof(ap_regex_t));
         if (ap_regcomp(uri_pattern, pattern, 0) != OK) {
-            return luaL_error(L, "Unable to compile regular expression, '%s'", pattern);
+            return luaL_error(L, "Unable to compile regular expression, '%s'",
+                              pattern);
         }
         handler->uri_pattern = uri_pattern;
     }
     lua_pop(L, 1);
-    
+
     lua_getfield(L, 2, "scope");
     if (lua_isstring(L, -1)) {
         const char *scope = lua_tostring(L, -1);
@@ -98,7 +111,7 @@
         handler->scope = APL_SCOPE_ONCE;
     }
     lua_pop(L, 1);
-    
+
     lua_getfield(L, 2, "func");
     if (lua_isstring(L, -1)) {
         const char *value = lua_tostring(L, -1);
@@ -108,13 +121,15 @@
         handler->function_name = "handle";
     }
     lua_pop(L, 1);
-    
-    
-    *(const apl_mapped_handler_spec**)apr_array_push(cfg->mapped_handlers) = handler;    
+
+
+    *(const apl_mapped_handler_spec **) apr_array_push(cfg->mapped_handlers) =
+        handler;
     return 0;
 }
 
-static int cfg_directory(lua_State *L) {
+static int cfg_directory(lua_State *L)
+{
     apl_dir_cfg *cfg = check_dir_config(L, 1);
     lua_pushstring(L, cfg->dir);
     return 1;
@@ -129,69 +144,104 @@
 static const struct luaL_Reg cfg_methods[] = {
     {"match_handler", cfg_lua_map_handler},
     {"directory", cfg_directory},
-   /* {"root", cfg_root}, */
+    /* {"root", cfg_root}, */
     {NULL, NULL}
 };
 
 
 
-static int cmd_foo(lua_State *L) {
+static int cmd_foo(lua_State *L)
+{
     cmd_parms *cmd = check_cmd_parms(L, 1);
     ap_log_error(APLOG_MARK, APLOG_ERR, 0, cmd->server, "FOO!");
     return 0;
 }
 
 /* helper function for the logging functions below */
-static int cmd_log_at(lua_State* L, int level) {
+static int cmd_log_at(lua_State *L, int level)
+{
     cmd_parms *cmd = check_cmd_parms(L, 1);
     lua_Debug dbg;
-    
+
     lua_getstack(L, 1, &dbg);
     lua_getinfo(L, "Sl", &dbg);
 
-    const char* msg = luaL_checkstring(L, 2);
+    const char *msg = luaL_checkstring(L, 2);
     ap_log_error(dbg.source, dbg.currentline, level, 0, cmd->server, msg);
     return 0;
 }
 
 /* r:debug(String) and friends which use apache logging */
-static int cmd_emerg(lua_State* L)  { cmd_log_at(L, APLOG_EMERG); return 0; }
-static int cmd_alert(lua_State* L)  { cmd_log_at(L, APLOG_ALERT); return 0; }
-static int cmd_crit(lua_State* L)   { cmd_log_at(L, APLOG_CRIT); return 0; }
-static int cmd_err(lua_State* L)    { cmd_log_at(L, APLOG_ERR); return 0; }
-static int cmd_warn(lua_State* L)   { cmd_log_at(L, APLOG_WARNING); return 0; }
-static int cmd_notice(lua_State* L) { cmd_log_at(L, APLOG_NOTICE); return 0; }
-static int cmd_info(lua_State* L)   { cmd_log_at(L, APLOG_INFO); return 0; }
-static int cmd_debug(lua_State* L)  { cmd_log_at(L, APLOG_DEBUG); return 0; }
+static int cmd_emerg(lua_State *L)
+{
+    cmd_log_at(L, APLOG_EMERG);
+    return 0;
+}
+static int cmd_alert(lua_State *L)
+{
+    cmd_log_at(L, APLOG_ALERT);
+    return 0;
+}
+static int cmd_crit(lua_State *L)
+{
+    cmd_log_at(L, APLOG_CRIT);
+    return 0;
+}
+static int cmd_err(lua_State *L)
+{
+    cmd_log_at(L, APLOG_ERR);
+    return 0;
+}
+static int cmd_warn(lua_State *L)
+{
+    cmd_log_at(L, APLOG_WARNING);
+    return 0;
+}
+static int cmd_notice(lua_State *L)
+{
+    cmd_log_at(L, APLOG_NOTICE);
+    return 0;
+}
+static int cmd_info(lua_State *L)
+{
+    cmd_log_at(L, APLOG_INFO);
+    return 0;
+}
+static int cmd_debug(lua_State *L)
+{
+    cmd_log_at(L, APLOG_DEBUG);
+    return 0;
+}
 
 
-static const struct luaL_Reg cmd_methods[] = {    
+static const struct luaL_Reg cmd_methods[] = {
     {"foo", cmd_foo},
-    
-    {"debug",   cmd_debug},
-    {"info",    cmd_info},
-    {"notice",  cmd_notice},
-    {"warn",    cmd_warn},
-    {"err",     cmd_err},
-    {"crit",    cmd_crit},
-    {"alert",   cmd_alert},
-    {"emerg",   cmd_emerg},
+
+    {"debug", cmd_debug},
+    {"info", cmd_info},
+    {"notice", cmd_notice},
+    {"warn", cmd_warn},
+    {"err", cmd_err},
+    {"crit", cmd_crit},
+    {"alert", cmd_alert},
+    {"emerg", cmd_emerg},
 
     {NULL, NULL}
 };
 
-void apl_load_config_lmodule(lua_State *L) {
-    luaL_newmetatable(L, "Apache2.DirConfig"); /* [metatable] */
-    lua_pushvalue(L, -1); 
-
-    lua_setfield(L, -2, "__index"); 
-    luaL_register(L, NULL, cfg_methods); /* [metatable] */
-    
-    
+void apl_load_config_lmodule(lua_State *L)
+{
+    luaL_newmetatable(L, "Apache2.DirConfig");  /* [metatable] */
+    lua_pushvalue(L, -1);
+
+    lua_setfield(L, -2, "__index");
+    luaL_register(L, NULL, cfg_methods);        /* [metatable] */
+
+
     luaL_newmetatable(L, "Apache2.CommandParameters");
-    lua_pushvalue(L, -1); 
+    lua_pushvalue(L, -1);
+
+    lua_setfield(L, -2, "__index");
+    luaL_register(L, NULL, cmd_methods);        /* [metatable] */
 
-    lua_setfield(L, -2, "__index"); 
-    luaL_register(L, NULL, cmd_methods); /* [metatable] */
-    
 }

Modified: httpd/httpd/trunk/modules/lua/lua_config.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_config.h?rev=728516&r1=728515&r2=728516&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_config.h (original)
+++ httpd/httpd/trunk/modules/lua/lua_config.h Sun Dec 21 13:41:52 2008
@@ -14,19 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 #include "mod_lua.h"
 
 #ifndef _APL_CONFIG_H_
 #define _APL_CONFIG_H_
-                 
-APR_DECLARE(void) apl_load_config_lmodule(lua_State *L);                                                                 
 
-APR_DECLARE(apr_status_t) apl_lua_map_handler(apl_dir_cfg *cfg, 
-                                              const char *file, 
+APR_DECLARE(void) apl_load_config_lmodule(lua_State *L);
+
+APR_DECLARE(apr_status_t) apl_lua_map_handler(apl_dir_cfg *cfg,
+                                              const char *file,
                                               const char *function,
                                               const char *pattern,
                                               const char *scope);
 
 #endif /* !_APL_CONFIG_H_ */
-

Modified: httpd/httpd/trunk/modules/lua/lua_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_request.c?rev=728516&r1=728515&r2=728516&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_request.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_request.c Sun Dec 21 13:41:52 2008
@@ -19,64 +19,67 @@
 #include "util_script.h"
 #include "lua_apr.h"
 
-typedef char* (*req_field_string_f) (request_rec* r);
-typedef int (*req_field_int_f) (request_rec* r);
+typedef char *(*req_field_string_f) (request_rec * r);
+typedef int (*req_field_int_f) (request_rec * r);
 
-void rstack_dump(lua_State* L, request_rec* r, const char* msg) {
+void rstack_dump(lua_State *L, request_rec *r, const char *msg)
+{
     ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "Lua Stack Dump: [%s]", msg);
 
     int i;
     int top = lua_gettop(L);
-    for (i = 1; i<= top; i++) {
+    for (i = 1; i <= top; i++) {
         int t = lua_type(L, i);
-        switch(t) {
-            case LUA_TSTRING: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, 
+        switch (t) {
+        case LUA_TSTRING:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
                               "%d:  '%s'", i, lua_tostring(L, i));
                 break;
             }
-            case LUA_TUSERDATA: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "%d:  userdata", i);                
+        case LUA_TUSERDATA:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "%d:  userdata",
+                              i);
                 break;
             }
-            case LUA_TLIGHTUSERDATA: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "%d:  lightuserdata", i);
+        case LUA_TLIGHTUSERDATA:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
+                              "%d:  lightuserdata", i);
                 break;
             }
-            case LUA_TNIL: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, 
-                              "%d:  NIL", i);
+        case LUA_TNIL:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "%d:  NIL", i);
                 break;
             }
-            case LUA_TNONE: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, 
-                              "%d:  None", i);
+        case LUA_TNONE:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "%d:  None", i);
                 break;
             }
-            case LUA_TBOOLEAN: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, 
-                              "%d:  %s", i,  lua_toboolean(L, i) ? "true" : "false");
+        case LUA_TBOOLEAN:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
+                              "%d:  %s", i, lua_toboolean(L,
+                                                          i) ? "true" :
+                              "false");
                 break;
             }
-            case LUA_TNUMBER: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, 
+        case LUA_TNUMBER:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
                               "%d:  %g", i, lua_tonumber(L, i));
                 break;
             }
-            case LUA_TTABLE: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, 
+        case LUA_TTABLE:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
                               "%d:  <table>", i);
                 break;
             }
-            case LUA_TFUNCTION: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, 
+        case LUA_TFUNCTION:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
                               "%d:  <function>", i);
                 break;
             }
-            default: {
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, 
+        default:{
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
                               "%d:  unkown: -[%s]-", i, lua_typename(L, i));
-                break;                
+                break;
             }
         }
     }
@@ -87,275 +90,341 @@
  * userdata thingamajig and return it if it is. if it is not
  * lua will enter its error handling routine.
  */
-static request_rec* apl_check_request_rec(lua_State* L, int index) {
+static request_rec *apl_check_request_rec(lua_State *L, int index)
+{
     luaL_checkudata(L, index, "Apache2.Request");
-    request_rec* r = (request_rec*)lua_unboxpointer(L, index);
-    return r;    
+    request_rec *r = (request_rec *) lua_unboxpointer(L, index);
+    return r;
 }
 
 /* ------------------ request methods -------------------- */
 /* helper callback for req_parseargs */
-static int req_aprtable2luatable_cb(void *l, const char *key, const char *value) {
-    lua_State* L = (lua_State*)l; /* [table<s,t>, table<s,s>] */
+static int req_aprtable2luatable_cb(void *l, const char *key,
+                                    const char *value)
+{
+    lua_State *L = (lua_State *) l;     /* [table<s,t>, table<s,s>] */
     /* rstack_dump(L, RRR, "start of cb"); */
     /* L is [table<s,t>, table<s,s>] */
     /* build complex */
 
-    lua_getfield(L, -1, key); /* [VALUE, table<s,t>, table<s,s>] */
-    /* rstack_dump(L, RRR, "after getfield"); */ 
+    lua_getfield(L, -1, key);   /* [VALUE, table<s,t>, table<s,s>] */
+    /* rstack_dump(L, RRR, "after getfield"); */
     int t = lua_type(L, -1);
-    switch(t) {
-        case LUA_TNIL:
-        case LUA_TNONE: {
-            lua_pop(L, 1); /* [table<s,t>, table<s,s>] */
-            lua_newtable(L); /* [array, table<s,t>, table<s,s>] */
-            lua_pushnumber(L, 1); /* [1, array, table<s,t>, table<s,s>] */
-            lua_pushstring(L, value); /* [string, 1, array, table<s,t>, table<s,s>] */
-            lua_settable(L, -3); /* [array, table<s,t>, table<s,s>]  */
-            lua_setfield(L, -2, key); /* [table<s,t>, table<s,s>] */
+    switch (t) {
+    case LUA_TNIL:
+    case LUA_TNONE:{
+            lua_pop(L, 1);      /* [table<s,t>, table<s,s>] */
+            lua_newtable(L);    /* [array, table<s,t>, table<s,s>] */
+            lua_pushnumber(L, 1);       /* [1, array, table<s,t>, table<s,s>] */
+            lua_pushstring(L, value);   /* [string, 1, array, table<s,t>, table<s,s>] */
+            lua_settable(L, -3);        /* [array, table<s,t>, table<s,s>]  */
+            lua_setfield(L, -2, key);   /* [table<s,t>, table<s,s>] */
             break;
         }
-        case LUA_TTABLE: {
+    case LUA_TTABLE:{
             /* [array, table<s,t>, table<s,s>] */
             int size = lua_objlen(L, -1);
-            lua_pushnumber(L, size + 1); /* [#, array, table<s,t>, table<s,s>] */
-            lua_pushstring(L, value); /* [string, #, array, table<s,t>, table<s,s>] */
-            lua_settable(L, -3); /* [array, table<s,t>, table<s,s>] */
-            lua_setfield(L, -2, key); /* [table<s,t>, table<s,s>] */
+            lua_pushnumber(L, size + 1);        /* [#, array, table<s,t>, table<s,s>] */
+            lua_pushstring(L, value);   /* [string, #, array, table<s,t>, table<s,s>] */
+            lua_settable(L, -3);        /* [array, table<s,t>, table<s,s>] */
+            lua_setfield(L, -2, key);   /* [table<s,t>, table<s,s>] */
             break;
         }
     }
 
     /* L is [table<s,t>, table<s,s>] */
     /* build simple */
-    lua_getfield(L, -2, key); /* [VALUE, table<s,s>, table<s,t>] */
-    if (lua_isnoneornil(L, -1)) { /* only set if not already set */
-        lua_pop(L, 1); /* [table<s,s>, table<s,t>]] */
-        lua_pushstring(L, value); /* [string, table<s,s>, table<s,t>] */
-        lua_setfield(L, -3, key); /* [table<s,s>, table<s,t>]  */
-    } else { lua_pop(L, 1); }
+    lua_getfield(L, -2, key);   /* [VALUE, table<s,s>, table<s,t>] */
+    if (lua_isnoneornil(L, -1)) {       /* only set if not already set */
+        lua_pop(L, 1);          /* [table<s,s>, table<s,t>]] */
+        lua_pushstring(L, value);       /* [string, table<s,s>, table<s,t>] */
+        lua_setfield(L, -3, key);       /* [table<s,s>, table<s,t>]  */
+    }
+    else {
+        lua_pop(L, 1);
+    }
     return 1;
 }
 
 /* r:parseargs() returning a lua table */
-static int req_parseargs(lua_State* L) {
-    request_rec* r = apl_check_request_rec(L, 1);
+static int req_parseargs(lua_State *L)
+{
+    request_rec *r = apl_check_request_rec(L, 1);
     lua_newtable(L);
-    lua_newtable(L); /* [table, table] */
-    apr_table_t* form_table;
+    lua_newtable(L);            /* [table, table] */
+    apr_table_t *form_table;
     ap_args_to_table(r, &form_table);
-    apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL);                
-    return 2; /* [table<string, string>, table<string, array<string>>] */
+    apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL);
+    return 2;                   /* [table<string, string>, table<string, array<string>>] */
 }
 
 /* wrap ap_rputs as r:puts(String) */
-static int req_puts(lua_State* L) {    
-    request_rec* r = apl_check_request_rec(L, 1);
-    
+static int req_puts(lua_State *L)
+{
+    request_rec *r = apl_check_request_rec(L, 1);
+
     int argc = lua_gettop(L);
     int i;
-    
-    for (i=2;i<=argc;i++) {
+
+    for (i = 2; i <= argc; i++) {
         ap_rputs(luaL_checkstring(L, i), r);
     }
     return 0;
 }
 
 /* wrap ap_rwrite as r:write(String) */
-static int req_write(lua_State* L) {
-    request_rec* r = apl_check_request_rec(L, 1);
+static int req_write(lua_State *L)
+{
+    request_rec *r = apl_check_request_rec(L, 1);
     size_t n;
-    const char* buf = luaL_checklstring(L, 2, &n);
-  
-    ap_rwrite((void *)buf, n, r);
+    const char *buf = luaL_checklstring(L, 2, &n);
+
+    ap_rwrite((void *) buf, n, r);
     return 0;
 }
 
 /* r:parsebody() */
-static int req_parsebody(lua_State* L) {
-    request_rec* r = apl_check_request_rec(L, 1);
+static int req_parsebody(lua_State *L)
+{
+    request_rec *r = apl_check_request_rec(L, 1);
     lua_newtable(L);
     lua_newtable(L);
-    apr_table_t* form_table;
+    apr_table_t *form_table;
     if (ap_body_to_table(r, &form_table) == APR_SUCCESS) {
-        apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL);        
+        apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL);
     }
     return 2;
 }
 
 /* r:addoutputfilter(name|function) */
-static int req_add_output_filter(lua_State *L) {
-    request_rec* r = apl_check_request_rec(L, 1);    
+static int req_add_output_filter(lua_State *L)
+{
+    request_rec *r = apl_check_request_rec(L, 1);
     const char *name = luaL_checkstring(L, 2);
-    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "adding output filter %s", name);
+    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "adding output filter %s",
+                  name);
     ap_add_output_filter(name, L, r, r->connection);
     return 0;
 }
 
-static int req_document_root(lua_State* L) {
-  request_rec* r = apl_check_request_rec(L, 1);
-  char* doc_root = apr_pstrdup(r->pool, ap_document_root(r));
-  lua_pushstring(L, doc_root);
-  return 1;
+static int req_document_root(lua_State *L)
+{
+    request_rec *r = apl_check_request_rec(L, 1);
+    char *doc_root = apr_pstrdup(r->pool, ap_document_root(r));
+    lua_pushstring(L, doc_root);
+    return 1;
 }
 
 /* BEGIN dispatch mathods for request_rec fields */
 
-static char* req_uri_field(request_rec* r) {
+static char *req_uri_field(request_rec *r)
+{
     return r->uri;
 }
 
-static const char* req_method_field(request_rec* r) {
+static const char *req_method_field(request_rec *r)
+{
     return r->method;
 }
 
-static const char* req_hostname_field(request_rec* r) {
+static const char *req_hostname_field(request_rec *r)
+{
     return r->hostname;
 }
 
-static const char* req_args_field(request_rec* r) {
+static const char *req_args_field(request_rec *r)
+{
     return r->args;
 }
 
-static const char* req_path_info_field(request_rec* r) {
+static const char *req_path_info_field(request_rec *r)
+{
     return r->path_info;
 }
 
-static const char* req_canonical_filename_field(request_rec* r) {
+static const char *req_canonical_filename_field(request_rec *r)
+{
     return r->canonical_filename;
 }
 
-static const char* req_filename_field(request_rec* r) {
+static const char *req_filename_field(request_rec *r)
+{
     return r->filename;
 }
 
-static const char* req_user_field(request_rec* r) {
+static const char *req_user_field(request_rec *r)
+{
     return r->user;
 }
 
-static const char* req_unparsed_uri_field(request_rec* r) {
+static const char *req_unparsed_uri_field(request_rec *r)
+{
     return r->unparsed_uri;
 }
 
-static const char* req_ap_auth_type_field(request_rec* r) {
+static const char *req_ap_auth_type_field(request_rec *r)
+{
     return r->ap_auth_type;
 }
 
-static const char* req_content_encoding_field(request_rec* r) {
+static const char *req_content_encoding_field(request_rec *r)
+{
     return r->content_encoding;
 }
 
-static const char* req_content_type_field(request_rec* r) {
+static const char *req_content_type_field(request_rec *r)
+{
     return r->content_type;
 }
 
-static const char* req_range_field(request_rec* r) {
+static const char *req_range_field(request_rec *r)
+{
     return r->range;
 }
 
-static const char* req_protocol_field(request_rec* r) {
+static const char *req_protocol_field(request_rec *r)
+{
     return r->protocol;
 }
 
-static const char* req_the_request_field(request_rec* r) {
+static const char *req_the_request_field(request_rec *r)
+{
     return r->the_request;
 }
 
-static int req_status_field(request_rec* r) {
+static int req_status_field(request_rec *r)
+{
     return r->status;
 }
 
-static int req_assbackwards_field(request_rec* r) {
+static int req_assbackwards_field(request_rec *r)
+{
     return r->assbackwards;
 }
 
 /* END dispatch mathods for request_rec fields */
 
-static int req_dispatch(lua_State* L) {
-    request_rec* r = apl_check_request_rec(L, 1);
+static int req_dispatch(lua_State *L)
+{
+    request_rec *r = apl_check_request_rec(L, 1);
     const char *name = luaL_checkstring(L, 2);
     lua_pop(L, 2);
- 
+
     lua_getfield(L, LUA_REGISTRYINDEX, "Apache2.Request.dispatch");
-    apr_hash_t* dispatch = lua_touserdata(L, 1);
+    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);
+
+    req_fun_t *rft = apr_hash_get(dispatch, name, APR_HASH_KEY_STRING);
     if (rft) {
-        switch(rft->type) {
-            case APL_REQ_FUNTYPE_TABLE: {
-                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, 
-                              "request_rec->dispatching %s -> apr table (NOT IMPLEMENTED YET)", name);
+        switch (rft->type) {
+        case APL_REQ_FUNTYPE_TABLE:{
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                              "request_rec->dispatching %s -> apr table (NOT IMPLEMENTED YET)",
+                              name);
                 return 0;
             }
-            
-            case APL_REQ_FUNTYPE_LUACFUN: {
-                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, 
-                              "request_rec->dispatching %s -> lua_CFunction", name);
+
+        case APL_REQ_FUNTYPE_LUACFUN:{
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                              "request_rec->dispatching %s -> lua_CFunction",
+                              name);
                 lua_CFunction func = rft->fun;
-                lua_pushcfunction(L, func);      
-                return 1;                
+                lua_pushcfunction(L, func);
+                return 1;
             }
-            case APL_REQ_FUNTYPE_STRING: {
-                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, 
+        case APL_REQ_FUNTYPE_STRING:{
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                               "request_rec->dispatching %s -> string", name);
                 req_field_string_f func = rft->fun;
-                char* rs = (*func)(r);
+                char *rs = (*func) (r);
                 lua_pushstring(L, rs);
-                return 1;                
+                return 1;
             }
-            case APL_REQ_FUNTYPE_INT: {
-                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, 
+        case APL_REQ_FUNTYPE_INT:{
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                               "request_rec->dispatching %s -> int", name);
                 req_field_int_f func = rft->fun;
-                int rs = (*func)(r);
+                int rs = (*func) (r);
                 lua_pushnumber(L, rs);
-                return 1;                
+                return 1;
             }
-            case APL_REQ_FUNTYPE_BOOLEAN: {
-                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, 
+        case APL_REQ_FUNTYPE_BOOLEAN:{
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                               "request_rec->dispatching %s -> boolean", name);
                 req_field_int_f func = rft->fun;
-                int rs = (*func)(r);
+                int rs = (*func) (r);
                 lua_pushboolean(L, rs);
-                return 1;                
+                return 1;
             }
         }
     }
-    
-    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, 
-                  "nothing for %s", name);  
+
+    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "nothing for %s", name);
     return 0;
 }
 
 /* helper function for the logging functions below */
-static int req_log_at(lua_State* L, int level) {
-    request_rec* r = apl_check_request_rec(L, 1);
+static int req_log_at(lua_State *L, int level)
+{
+    request_rec *r = apl_check_request_rec(L, 1);
     lua_Debug dbg;
-    
+
     lua_getstack(L, 1, &dbg);
     lua_getinfo(L, "Sl", &dbg);
 
-    const char* msg = luaL_checkstring(L, 2);
+    const char *msg = luaL_checkstring(L, 2);
     ap_log_rerror(dbg.source, dbg.currentline, level, 0, r, msg);
     return 0;
 }
 
 /* r:debug(String) and friends which use apache logging */
-static int req_emerg(lua_State* L)  { req_log_at(L, APLOG_EMERG); return 0; }
-static int req_alert(lua_State* L)  { req_log_at(L, APLOG_ALERT); return 0; }
-static int req_crit(lua_State* L)   { req_log_at(L, APLOG_CRIT); return 0; }
-static int req_err(lua_State* L)    { req_log_at(L, APLOG_ERR); return 0; }
-static int req_warn(lua_State* L)   { req_log_at(L, APLOG_WARNING); return 0; }
-static int req_notice(lua_State* L) { req_log_at(L, APLOG_NOTICE); return 0; }
-static int req_info(lua_State* L)   { req_log_at(L, APLOG_INFO); return 0; }
-static int req_debug(lua_State* L)  { req_log_at(L, APLOG_DEBUG); return 0; }
+static int req_emerg(lua_State *L)
+{
+    req_log_at(L, APLOG_EMERG);
+    return 0;
+}
+static int req_alert(lua_State *L)
+{
+    req_log_at(L, APLOG_ALERT);
+    return 0;
+}
+static int req_crit(lua_State *L)
+{
+    req_log_at(L, APLOG_CRIT);
+    return 0;
+}
+static int req_err(lua_State *L)
+{
+    req_log_at(L, APLOG_ERR);
+    return 0;
+}
+static int req_warn(lua_State *L)
+{
+    req_log_at(L, APLOG_WARNING);
+    return 0;
+}
+static int req_notice(lua_State *L)
+{
+    req_log_at(L, APLOG_NOTICE);
+    return 0;
+}
+static int req_info(lua_State *L)
+{
+    req_log_at(L, APLOG_INFO);
+    return 0;
+}
+static int req_debug(lua_State *L)
+{
+    req_log_at(L, APLOG_DEBUG);
+    return 0;
+}
 
 /* handle r.status = 201 */
-static int req_newindex(lua_State* L) {
-    /* request_rec* r = lua_touserdata(L, lua_upvalueindex(1)); */ 
+static int req_newindex(lua_State *L)
+{
+    /* request_rec* r = lua_touserdata(L, lua_upvalueindex(1)); */
     /* const char* key = luaL_checkstring(L, -2); */
-    request_rec* r = apl_check_request_rec(L, 1);
+    request_rec *r = apl_check_request_rec(L, 1);
     rstack_dump(L, r, "req_newindex");
     const char *key = luaL_checkstring(L, 2);
     rstack_dump(L, r, "req_newindex");
@@ -368,9 +437,9 @@
         lua_pop(L, 1);
         return 0;
     }
-    
+
     if (0 == apr_strnatcmp("content_type", key)) {
-        const char* value = luaL_checkstring(L, 3);
+        const char *value = luaL_checkstring(L, 3);
         r->content_type = apr_pstrdup(r->pool, value);
         luaL_getmetatable(L, "Apache2.Request");
         lua_pushstring(L, value);
@@ -378,9 +447,9 @@
         lua_pop(L, 1);
         return 0;
     }
-    
+
     if (0 == apr_strnatcmp("filename", key)) {
-        const char* value = luaL_checkstring(L, 3);
+        const char *value = luaL_checkstring(L, 3);
         r->filename = apr_pstrdup(r->pool, value);
         luaL_getmetatable(L, "Apache2.Request");
         lua_pushstring(L, value);
@@ -390,7 +459,7 @@
     }
 
     if (0 == apr_strnatcmp("uri", key)) {
-        const char* value = luaL_checkstring(L, 3);
+        const char *value = luaL_checkstring(L, 3);
         r->uri = apr_pstrdup(r->pool, value);
         luaL_getmetatable(L, "Apache2.Request");
         lua_pushstring(L, value);
@@ -398,8 +467,11 @@
         lua_pop(L, 1);
         return 0;
     }
-    
-    lua_pushstring(L, apr_psprintf(r->pool, "Property [%s] may not be set on a request_rec", key));
+
+    lua_pushstring(L,
+                   apr_psprintf(r->pool,
+                                "Property [%s] may not be set on a request_rec",
+                                key));
     lua_error(L);
     return 0;
 }
@@ -422,110 +494,116 @@
 };
 
 
-static req_fun_t* makefun(void* fun, int type, apr_pool_t* pool) {
-    req_fun_t* rft = apr_palloc(pool, sizeof(req_fun_t));
+static req_fun_t *makefun(void *fun, int type, apr_pool_t *pool)
+{
+    req_fun_t *rft = apr_palloc(pool, sizeof(req_fun_t));
     rft->fun = fun;
     rft->type = type;
     return rft;
 }
 
-void apl_load_request_lmodule(lua_State *L, apr_pool_t *p) {
-    
-    apr_hash_t* dispatch = apr_hash_make(p);
-    
-    apr_hash_set(dispatch, "puts", APR_HASH_KEY_STRING, 
+void apl_load_request_lmodule(lua_State *L, apr_pool_t *p)
+{
+
+    apr_hash_t *dispatch = apr_hash_make(p);
+
+    apr_hash_set(dispatch, "puts", APR_HASH_KEY_STRING,
                  makefun(&req_puts, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "write", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "write", APR_HASH_KEY_STRING,
                  makefun(&req_write, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "document_root", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "document_root", APR_HASH_KEY_STRING,
                  makefun(&req_document_root, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "parseargs", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "parseargs", APR_HASH_KEY_STRING,
                  makefun(&req_parseargs, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "parsebody", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "parsebody", APR_HASH_KEY_STRING,
                  makefun(&req_parsebody, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "debug", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "debug", APR_HASH_KEY_STRING,
                  makefun(&req_debug, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "info", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "info", APR_HASH_KEY_STRING,
                  makefun(&req_info, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "notice", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "notice", APR_HASH_KEY_STRING,
                  makefun(&req_notice, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "warn", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "warn", APR_HASH_KEY_STRING,
                  makefun(req_warn, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "err", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "err", APR_HASH_KEY_STRING,
                  makefun(&req_err, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "crit", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "crit", APR_HASH_KEY_STRING,
                  makefun(&req_crit, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "alert", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "alert", APR_HASH_KEY_STRING,
                  makefun(&req_alert, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "emerg", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "emerg", APR_HASH_KEY_STRING,
                  makefun(&req_emerg, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "add_output_filter", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "add_output_filter", APR_HASH_KEY_STRING,
                  makefun(&req_add_output_filter, APL_REQ_FUNTYPE_LUACFUN, p));
-    apr_hash_set(dispatch, "assbackwards", APR_HASH_KEY_STRING, 
-                 makefun(&req_assbackwards_field, APL_REQ_FUNTYPE_BOOLEAN, p));
-    apr_hash_set(dispatch, "status", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "assbackwards", APR_HASH_KEY_STRING,
+                 makefun(&req_assbackwards_field, APL_REQ_FUNTYPE_BOOLEAN,
+                         p));
+    apr_hash_set(dispatch, "status", APR_HASH_KEY_STRING,
                  makefun(&req_status_field, APL_REQ_FUNTYPE_INT, p));
-    apr_hash_set(dispatch, "protocol", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "protocol", APR_HASH_KEY_STRING,
                  makefun(&req_protocol_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "range", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "range", APR_HASH_KEY_STRING,
                  makefun(&req_range_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "content_type", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "content_type", APR_HASH_KEY_STRING,
                  makefun(&req_content_type_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "content_encoding", APR_HASH_KEY_STRING, 
-                 makefun(&req_content_encoding_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "ap_auth_type", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "content_encoding", APR_HASH_KEY_STRING,
+                 makefun(&req_content_encoding_field, APL_REQ_FUNTYPE_STRING,
+                         p));
+    apr_hash_set(dispatch, "ap_auth_type", APR_HASH_KEY_STRING,
                  makefun(&req_ap_auth_type_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "unparsed_uri", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "unparsed_uri", APR_HASH_KEY_STRING,
                  makefun(&req_unparsed_uri_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "user", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "user", APR_HASH_KEY_STRING,
                  makefun(&req_user_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "filename", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "filename", APR_HASH_KEY_STRING,
                  makefun(&req_filename_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "canonical_filename", APR_HASH_KEY_STRING, 
-                 makefun(&req_canonical_filename_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "path_info", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "canonical_filename", APR_HASH_KEY_STRING,
+                 makefun(&req_canonical_filename_field,
+                         APL_REQ_FUNTYPE_STRING, p));
+    apr_hash_set(dispatch, "path_info", APR_HASH_KEY_STRING,
                  makefun(&req_path_info_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "args", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "args", APR_HASH_KEY_STRING,
                  makefun(&req_args_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "hostname", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "hostname", APR_HASH_KEY_STRING,
                  makefun(&req_hostname_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "uri", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "uri", APR_HASH_KEY_STRING,
                  makefun(&req_uri_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "the_request", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "the_request", APR_HASH_KEY_STRING,
                  makefun(&req_the_request_field, APL_REQ_FUNTYPE_STRING, p));
-    apr_hash_set(dispatch, "method", APR_HASH_KEY_STRING, 
+    apr_hash_set(dispatch, "method", APR_HASH_KEY_STRING,
                  makefun(&req_method_field, APL_REQ_FUNTYPE_STRING, p));
-    
+
     lua_pushlightuserdata(L, dispatch);
     lua_setfield(L, LUA_REGISTRYINDEX, "Apache2.Request.dispatch");
-    
-    luaL_newmetatable(L, "Apache2.Request"); /* [metatable] */
-    lua_pushvalue(L, -1); 
 
-    lua_setfield(L, -2, "__index"); 
-    luaL_register(L, NULL, request_methods); /* [metatable] */
+    luaL_newmetatable(L, "Apache2.Request");    /* [metatable] */
+    lua_pushvalue(L, -1);
+
+    lua_setfield(L, -2, "__index");
+    luaL_register(L, NULL, request_methods);    /* [metatable] */
 
     lua_pop(L, 2);
 
     luaL_newmetatable(L, "Apache2.Connection"); /* [metatable] */
-    lua_pushvalue(L, -1); 
+    lua_pushvalue(L, -1);
 
-    lua_setfield(L, -2, "__index"); 
+    lua_setfield(L, -2, "__index");
     luaL_register(L, NULL, connection_methods); /* [metatable] */
 
     lua_pop(L, 2);
 
-    luaL_newmetatable(L, "Apache2.Server"); /* [metatable] */
-    lua_pushvalue(L, -1); 
+    luaL_newmetatable(L, "Apache2.Server");     /* [metatable] */
+    lua_pushvalue(L, -1);
 
-    lua_setfield(L, -2, "__index"); 
-    luaL_register(L, NULL, server_methods); /* [metatable] */
+    lua_setfield(L, -2, "__index");
+    luaL_register(L, NULL, server_methods);     /* [metatable] */
 
     lua_pop(L, 2);
 
 }
 
-void apl_push_connection(lua_State* L, conn_rec* c) {  
+void apl_push_connection(lua_State *L, conn_rec *c)
+{
     lua_boxpointer(L, c);
     luaL_getmetatable(L, "Apache2.Connection");
     lua_setmetatable(L, -2);
@@ -534,27 +612,28 @@
     apl_push_apr_table(L, "notes", c->notes);
 
     lua_pushstring(L, c->remote_ip);
-    lua_setfield(L, -2, "remote_ip");    
+    lua_setfield(L, -2, "remote_ip");
 
     lua_pop(L, 1);
 }
 
 
-void apl_push_server(lua_State* L, server_rec* s) {  
+void apl_push_server(lua_State *L, server_rec *s)
+{
     lua_boxpointer(L, s);
     luaL_getmetatable(L, "Apache2.Server");
     lua_setmetatable(L, -2);
     luaL_getmetatable(L, "Apache2.Server");
 
     lua_pushstring(L, s->server_hostname);
-    lua_setfield(L, -2, "server_hostname");    
+    lua_setfield(L, -2, "server_hostname");
 
     lua_pop(L, 1);
 }
 
-void apl_push_request(lua_State* L, request_rec* r) {  
+void apl_push_request(lua_State *L, request_rec *r)
+{
     lua_boxpointer(L, r);
     luaL_getmetatable(L, "Apache2.Request");
     lua_setmetatable(L, -2);
 }
-

Modified: httpd/httpd/trunk/modules/lua/lua_request.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_request.h?rev=728516&r1=728515&r2=728516&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_request.h (original)
+++ httpd/httpd/trunk/modules/lua/lua_request.h Sun Dec 21 13:41:52 2008
@@ -18,7 +18,7 @@
 #ifndef _LUA_REQUEST_H_
 #define _LUA_REQUEST_H_
 
-APR_DECLARE(void) apl_push_request(lua_State* L, request_rec* r);
+APR_DECLARE(void) apl_push_request(lua_State *L, request_rec *r);
 APR_DECLARE(void) apl_load_request_lmodule(lua_State *L, apr_pool_t *p);
 
 #define APL_REQ_FUNTYPE_STRING      1
@@ -27,11 +27,11 @@
 #define APL_REQ_FUNTYPE_LUACFUN     4
 #define APL_REQ_FUNTYPE_BOOLEAN     5
 
-typedef struct {
+typedef struct
+{
     void *fun;
     int type;
 } req_fun_t;
 
 
 #endif /* !_LUA_REQUEST_H_ */
-

Modified: httpd/httpd/trunk/modules/lua/lua_vmprep.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_vmprep.c?rev=728516&r1=728515&r2=728516&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_vmprep.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_vmprep.c Sun Dec 21 13:41:52 2008
@@ -23,66 +23,66 @@
 
 /* forward dec'l from this file */
 
-static void pstack_dump(lua_State* L, apr_pool_t* r, int level, const char* msg) {
+static void pstack_dump(lua_State *L, apr_pool_t *r, int level,
+                        const char *msg)
+{
     ap_log_perror(APLOG_MARK, level, 0, r, "Lua Stack Dump: [%s]", msg);
 
     int i;
     int top = lua_gettop(L);
-    for (i = 1; i<= top; i++) {
+    for (i = 1; i <= top; i++) {
         int t = lua_type(L, i);
-        switch(t) {
-            case LUA_TSTRING: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
+        switch (t) {
+        case LUA_TSTRING:{
+                ap_log_perror(APLOG_MARK, level, 0, r,
                               "%d:  '%s'", i, lua_tostring(L, i));
                 break;
             }
-            case LUA_TUSERDATA: {
-                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  userdata", i);                
+        case LUA_TUSERDATA:{
+                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  userdata", i);
                 break;
             }
-            case LUA_TLIGHTUSERDATA: {
-                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  lightuserdata", i);
+        case LUA_TLIGHTUSERDATA:{
+                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  lightuserdata",
+                              i);
                 break;
             }
-            case LUA_TNIL: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
-                              "%d:  NIL", i);
+        case LUA_TNIL:{
+                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  NIL", i);
                 break;
             }
-            case LUA_TNONE: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
-                              "%d:  None", i);
+        case LUA_TNONE:{
+                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  None", i);
                 break;
             }
-            case LUA_TBOOLEAN: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
-                              "%d:  %s", i,  lua_toboolean(L, i) ? "true" : "false");
+        case LUA_TBOOLEAN:{
+                ap_log_perror(APLOG_MARK, level, 0, r,
+                              "%d:  %s", i, lua_toboolean(L,
+                                                          i) ? "true" :
+                              "false");
                 break;
             }
-            case LUA_TNUMBER: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
+        case LUA_TNUMBER:{
+                ap_log_perror(APLOG_MARK, level, 0, r,
                               "%d:  %g", i, lua_tonumber(L, i));
                 break;
             }
-            case LUA_TTABLE: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
-                              "%d:  <table>", i);
+        case LUA_TTABLE:{
+                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  <table>", i);
                 break;
             }
-            case LUA_TTHREAD: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
-                              "%d:  <thread>", i);
+        case LUA_TTHREAD:{
+                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  <thread>", i);
                 break;
             }
-            case LUA_TFUNCTION: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
-                              "%d:  <function>", i);
+        case LUA_TFUNCTION:{
+                ap_log_perror(APLOG_MARK, level, 0, r, "%d:  <function>", i);
                 break;
             }
-            default: {
-                ap_log_perror(APLOG_MARK, level, 0, r, 
+        default:{
+                ap_log_perror(APLOG_MARK, level, 0, r,
                               "%d:  unkown: [%s]", i, lua_typename(L, i));
-                break;                
+                break;
             }
         }
     }
@@ -92,13 +92,14 @@
 
 /* BEGIN apache lmodule  */
 
-void apl_load_apache2_lmodule(lua_State *L) {
+void apl_load_apache2_lmodule(lua_State *L)
+{
     lua_getglobal(L, "package");
     lua_getfield(L, -1, "loaded");
-    lua_newtable(L);    
+    lua_newtable(L);
     lua_setfield(L, -2, "apache2");
     lua_setglobal(L, "apache2");
-    lua_pop(L, 1); /* empty stack */
+    lua_pop(L, 1);              /* empty stack */
 
     lua_getglobal(L, "apache2");
     lua_pushinteger(L, OK);
@@ -109,187 +110,186 @@
 
     lua_pushinteger(L, DONE);
     lua_setfield(L, -2, "DONE");
-   
+
     lua_pushstring(L, ap_get_server_banner());
     lua_setfield(L, -2, "version");
 
     lua_pushinteger(L, HTTP_MOVED_TEMPORARILY);
     lua_setfield(L, -2, "HTTP_MOVED_TEMPORARILY");
-    
+
     /*
-    lua_pushinteger(L, HTTP_CONTINUE);
-    lua_setfield(L, -2, "HTTP_CONTINUE");
-    lua_pushinteger(L, HTTP_SWITCHING_PROTOCOLS);
-    lua_setfield(L, -2, "HTTP_SWITCHING_PROTOCOLS");
-    lua_pushinteger(L, HTTP_PROCESSING);
-    lua_setfield(L, -2, "HTTP_PROCESSING");
-    lua_pushinteger(L, HTTP_OK);
-    lua_setfield(L, -2, "HTTP_OK");
-    lua_pushinteger(L, HTTP_CREATED);
-    lua_setfield(L, -2, "HTTP_CREATED");
-    lua_pushinteger(L, HTTP_ACCEPTED);
-    lua_setfield(L, -2, "HTTP_ACCEPTED");
-    lua_pushinteger(L, HTTP_NON_AUTHORITATIVE);
-    lua_setfield(L, -2, "HTTP_NON_AUTHORITATIVE");
-    lua_pushinteger(L, HTTP_NO_CONTENT);
-    lua_setfield(L, -2, "HTTP_NO_CONTENT");
-    lua_pushinteger(L, HTTP_RESET_CONTENT);
-    lua_setfield(L, -2, "HTTP_RESET_CONTENT");
-    lua_pushinteger(L, HTTP_PARTIAL_CONTENT);
-    lua_setfield(L, -2, "HTTP_PARTIAL_CONTENT");
-    lua_pushinteger(L, HTTP_MULTI_STATUS);
-    lua_setfield(L, -2, "HTTP_MULTI_STATUS");
-    lua_pushinteger(L, HTTP_MULTIPLE_CHOICES);
-    lua_setfield(L, -2, "HTTP_MULTIPLE_CHOICES");
-    lua_pushinteger(L, HTTP_MOVED_PERMANENTLY);
-    lua_setfield(L, -2, "HTTP_MOVED_PERMANENTLY");
-    lua_pushinteger(L, HTTP_SEE_OTHER);
-    lua_setfield(L, -2, "HTTP_SEE_OTHER");
-    lua_pushinteger(L, HTTP_NOT_MODIFIED);
-    lua_setfield(L, -2, "HTTP_NOT_MODIFIED");
-    lua_pushinteger(L, HTTP_USE_PROXY);
-    lua_setfield(L, -2, "HTTP_USE_PROXY");
-    lua_pushinteger(L, HTTP_TEMPORARY_REDIRECT);
-    lua_setfield(L, -2, "HTTP_TEMPORARY_REDIRECT");
-    lua_pushinteger(L, HTTP_BAD_REQUEST);
-    lua_setfield(L, -2, "HTTP_BAD_REQUEST");
-    lua_pushinteger(L, HTTP_UNAUTHORIZED);
-    lua_setfield(L, -2, "HTTP_UNAUTHORIZED");
-    lua_pushinteger(L, HTTP_PAYMENT_REQUIRED);
-    lua_setfield(L, -2, "HTTP_PAYMENT_REQUIRED");
-    lua_pushinteger(L, HTTP_FORBIDDEN);
-    lua_setfield(L, -2, "HTTP_FORBIDDEN");
-    lua_pushinteger(L, HTTP_NOT_FOUND);
-    lua_setfield(L, -2, "HTTP_NOT_FOUND");
-    lua_pushinteger(L, HTTP_METHOD_NOT_ALLOWED);
-    lua_setfield(L, -2, "HTTP_METHOD_NOT_ALLOWED");
-    lua_pushinteger(L, HTTP_NOT_ACCEPTABLE);
-    lua_setfield(L, -2, "HTTP_NOT_ACCEPTABLE");
-    lua_pushinteger(L, HTTP_PROXY_AUTHENTICATION_REQUIRED);
-    lua_setfield(L, -2, "HTTP_PROXY_AUTHENTICATION_REQUIRED");
-    lua_pushinteger(L, HTTP_REQUEST_TIME_OUT);
-    lua_setfield(L, -2, "HTTP_REQUEST_TIME_OUT");
-    lua_pushinteger(L, HTTP_CONFLICT);
-    lua_setfield(L, -2, "HTTP_CONFLICT");
-    lua_pushinteger(L, HTTP_GONE);
-    lua_setfield(L, -2, "HTTP_GONE");
-    lua_pushinteger(L, HTTP_LENGTH_REQUIRED);
-    lua_setfield(L, -2, "HTTP_LENGTH_REQUIRED");
-    lua_pushinteger(L, HTTP_PRECONDITION_FAILED);
-    lua_setfield(L, -2, "HTTP_PRECONDITION_FAILED");
-    lua_pushinteger(L, HTTP_REQUEST_ENTITY_TOO_LARGE);
-    lua_setfield(L, -2, "HTTP_REQUEST_ENTITY_TOO_LARGE");
-    lua_pushinteger(L, HTTP_REQUEST_URI_TOO_LARGE);
-    lua_setfield(L, -2, "HTTP_REQUEST_URI_TOO_LARGE");
-    lua_pushinteger(L, HTTP_UNSUPPORTED_MEDIA_TYPE);
-    lua_setfield(L, -2, "HTTP_UNSUPPORTED_MEDIA_TYPE");
-    lua_pushinteger(L, HTTP_RANGE_NOT_SATISFIABLE);
-    lua_setfield(L, -2, "HTTP_RANGE_NOT_SATISFIABLE");
-    lua_pushinteger(L, HTTP_EXPECTATION_FAILED);
-    lua_setfield(L, -2, "HTTP_EXPECTATION_FAILED");
-    lua_pushinteger(L, HTTP_UNPROCESSABLE_ENTITY);
-    lua_setfield(L, -2, "HTTP_UNPROCESSABLE_ENTITY");
-    lua_pushinteger(L, HTTP_LOCKED);
-    lua_setfield(L, -2, "HTTP_LOCKED");
-    lua_pushinteger(L, HTTP_FAILED_DEPENDENCY);
-    lua_setfield(L, -2, "HTTP_FAILED_DEPENDENCY");
-    lua_pushinteger(L, HTTP_UPGRADE_REQUIRED);
-    lua_setfield(L, -2, "HTTP_UPGRADE_REQUIRED");
-    lua_pushinteger(L, HTTP_INTERNAL_SERVER_ERROR);
-    lua_setfield(L, -2, "HTTP_INTERNAL_SERVER_ERROR");
-    lua_pushinteger(L, HTTP_NOT_IMPLEMENTED);
-    lua_setfield(L, -2, "HTTP_NOT_IMPLEMENTED");
-    lua_pushinteger(L, HTTP_BAD_GATEWAY);
-    lua_setfield(L, -2, "HTTP_BAD_GATEWAY");
-    lua_pushinteger(L, HTTP_SERVICE_UNAVAILABLE);
-    lua_setfield(L, -2, "HTTP_SERVICE_UNAVAILABLE");
-    lua_pushinteger(L, HTTP_GATEWAY_TIME_OUT);
-    lua_setfield(L, -2, "HTTP_GATEWAY_TIME_OUT");
-    lua_pushinteger(L, HTTP_VERSION_NOT_SUPPORTED);
-    lua_setfield(L, -2, "HTTP_VERSION_NOT_SUPPORTED");
-    lua_pushinteger(L, HTTP_VARIANT_ALSO_VARIES);
-    lua_setfield(L, -2, "HTTP_VARIANT_ALSO_VARIES");
-    lua_pushinteger(L, HTTP_INSUFFICIENT_STORAGE);
-    lua_setfield(L, -2, "HTTP_INSUFFICIENT_STORAGE");
-    lua_pushinteger(L, HTTP_NOT_EXTENDED);
-    lua_setfield(L, -2, "HTTP_NOT_EXTENDED");
-    */
-} 
+       lua_pushinteger(L, HTTP_CONTINUE);
+       lua_setfield(L, -2, "HTTP_CONTINUE");
+       lua_pushinteger(L, HTTP_SWITCHING_PROTOCOLS);
+       lua_setfield(L, -2, "HTTP_SWITCHING_PROTOCOLS");
+       lua_pushinteger(L, HTTP_PROCESSING);
+       lua_setfield(L, -2, "HTTP_PROCESSING");
+       lua_pushinteger(L, HTTP_OK);
+       lua_setfield(L, -2, "HTTP_OK");
+       lua_pushinteger(L, HTTP_CREATED);
+       lua_setfield(L, -2, "HTTP_CREATED");
+       lua_pushinteger(L, HTTP_ACCEPTED);
+       lua_setfield(L, -2, "HTTP_ACCEPTED");
+       lua_pushinteger(L, HTTP_NON_AUTHORITATIVE);
+       lua_setfield(L, -2, "HTTP_NON_AUTHORITATIVE");
+       lua_pushinteger(L, HTTP_NO_CONTENT);
+       lua_setfield(L, -2, "HTTP_NO_CONTENT");
+       lua_pushinteger(L, HTTP_RESET_CONTENT);
+       lua_setfield(L, -2, "HTTP_RESET_CONTENT");
+       lua_pushinteger(L, HTTP_PARTIAL_CONTENT);
+       lua_setfield(L, -2, "HTTP_PARTIAL_CONTENT");
+       lua_pushinteger(L, HTTP_MULTI_STATUS);
+       lua_setfield(L, -2, "HTTP_MULTI_STATUS");
+       lua_pushinteger(L, HTTP_MULTIPLE_CHOICES);
+       lua_setfield(L, -2, "HTTP_MULTIPLE_CHOICES");
+       lua_pushinteger(L, HTTP_MOVED_PERMANENTLY);
+       lua_setfield(L, -2, "HTTP_MOVED_PERMANENTLY");
+       lua_pushinteger(L, HTTP_SEE_OTHER);
+       lua_setfield(L, -2, "HTTP_SEE_OTHER");
+       lua_pushinteger(L, HTTP_NOT_MODIFIED);
+       lua_setfield(L, -2, "HTTP_NOT_MODIFIED");
+       lua_pushinteger(L, HTTP_USE_PROXY);
+       lua_setfield(L, -2, "HTTP_USE_PROXY");
+       lua_pushinteger(L, HTTP_TEMPORARY_REDIRECT);
+       lua_setfield(L, -2, "HTTP_TEMPORARY_REDIRECT");
+       lua_pushinteger(L, HTTP_BAD_REQUEST);
+       lua_setfield(L, -2, "HTTP_BAD_REQUEST");
+       lua_pushinteger(L, HTTP_UNAUTHORIZED);
+       lua_setfield(L, -2, "HTTP_UNAUTHORIZED");
+       lua_pushinteger(L, HTTP_PAYMENT_REQUIRED);
+       lua_setfield(L, -2, "HTTP_PAYMENT_REQUIRED");
+       lua_pushinteger(L, HTTP_FORBIDDEN);
+       lua_setfield(L, -2, "HTTP_FORBIDDEN");
+       lua_pushinteger(L, HTTP_NOT_FOUND);
+       lua_setfield(L, -2, "HTTP_NOT_FOUND");
+       lua_pushinteger(L, HTTP_METHOD_NOT_ALLOWED);
+       lua_setfield(L, -2, "HTTP_METHOD_NOT_ALLOWED");
+       lua_pushinteger(L, HTTP_NOT_ACCEPTABLE);
+       lua_setfield(L, -2, "HTTP_NOT_ACCEPTABLE");
+       lua_pushinteger(L, HTTP_PROXY_AUTHENTICATION_REQUIRED);
+       lua_setfield(L, -2, "HTTP_PROXY_AUTHENTICATION_REQUIRED");
+       lua_pushinteger(L, HTTP_REQUEST_TIME_OUT);
+       lua_setfield(L, -2, "HTTP_REQUEST_TIME_OUT");
+       lua_pushinteger(L, HTTP_CONFLICT);
+       lua_setfield(L, -2, "HTTP_CONFLICT");
+       lua_pushinteger(L, HTTP_GONE);
+       lua_setfield(L, -2, "HTTP_GONE");
+       lua_pushinteger(L, HTTP_LENGTH_REQUIRED);
+       lua_setfield(L, -2, "HTTP_LENGTH_REQUIRED");
+       lua_pushinteger(L, HTTP_PRECONDITION_FAILED);
+       lua_setfield(L, -2, "HTTP_PRECONDITION_FAILED");
+       lua_pushinteger(L, HTTP_REQUEST_ENTITY_TOO_LARGE);
+       lua_setfield(L, -2, "HTTP_REQUEST_ENTITY_TOO_LARGE");
+       lua_pushinteger(L, HTTP_REQUEST_URI_TOO_LARGE);
+       lua_setfield(L, -2, "HTTP_REQUEST_URI_TOO_LARGE");
+       lua_pushinteger(L, HTTP_UNSUPPORTED_MEDIA_TYPE);
+       lua_setfield(L, -2, "HTTP_UNSUPPORTED_MEDIA_TYPE");
+       lua_pushinteger(L, HTTP_RANGE_NOT_SATISFIABLE);
+       lua_setfield(L, -2, "HTTP_RANGE_NOT_SATISFIABLE");
+       lua_pushinteger(L, HTTP_EXPECTATION_FAILED);
+       lua_setfield(L, -2, "HTTP_EXPECTATION_FAILED");
+       lua_pushinteger(L, HTTP_UNPROCESSABLE_ENTITY);
+       lua_setfield(L, -2, "HTTP_UNPROCESSABLE_ENTITY");
+       lua_pushinteger(L, HTTP_LOCKED);
+       lua_setfield(L, -2, "HTTP_LOCKED");
+       lua_pushinteger(L, HTTP_FAILED_DEPENDENCY);
+       lua_setfield(L, -2, "HTTP_FAILED_DEPENDENCY");
+       lua_pushinteger(L, HTTP_UPGRADE_REQUIRED);
+       lua_setfield(L, -2, "HTTP_UPGRADE_REQUIRED");
+       lua_pushinteger(L, HTTP_INTERNAL_SERVER_ERROR);
+       lua_setfield(L, -2, "HTTP_INTERNAL_SERVER_ERROR");
+       lua_pushinteger(L, HTTP_NOT_IMPLEMENTED);
+       lua_setfield(L, -2, "HTTP_NOT_IMPLEMENTED");
+       lua_pushinteger(L, HTTP_BAD_GATEWAY);
+       lua_setfield(L, -2, "HTTP_BAD_GATEWAY");
+       lua_pushinteger(L, HTTP_SERVICE_UNAVAILABLE);
+       lua_setfield(L, -2, "HTTP_SERVICE_UNAVAILABLE");
+       lua_pushinteger(L, HTTP_GATEWAY_TIME_OUT);
+       lua_setfield(L, -2, "HTTP_GATEWAY_TIME_OUT");
+       lua_pushinteger(L, HTTP_VERSION_NOT_SUPPORTED);
+       lua_setfield(L, -2, "HTTP_VERSION_NOT_SUPPORTED");
+       lua_pushinteger(L, HTTP_VARIANT_ALSO_VARIES);
+       lua_setfield(L, -2, "HTTP_VARIANT_ALSO_VARIES");
+       lua_pushinteger(L, HTTP_INSUFFICIENT_STORAGE);
+       lua_setfield(L, -2, "HTTP_INSUFFICIENT_STORAGE");
+       lua_pushinteger(L, HTTP_NOT_EXTENDED);
+       lua_setfield(L, -2, "HTTP_NOT_EXTENDED");
+     */
+}
 
 /* END apache2 lmodule */
 
 /*  END library functions */
 
 /* callback for cleaning up a lua vm when pool is closed */
-static apr_status_t cleanup_lua(void *l) {
-  lua_close((lua_State*) l);
-  return APR_SUCCESS;
+static apr_status_t cleanup_lua(void *l)
+{
+    lua_close((lua_State *) l);
+    return APR_SUCCESS;
 }
 
-static void munge_path(lua_State *L, 
+static void munge_path(lua_State *L,
                        const char *field,
-                       const char *sub_pat, 
+                       const char *sub_pat,
                        const char *rep_pat,
-                       apr_pool_t *pool, 
-                       apr_array_header_t *paths, 
-                       const char *file) {
-  lua_getglobal(L, "package");
-  lua_getfield(L, -1, field);
-  const char* current = lua_tostring(L, -1);
-  const char* parent_dir = ap_make_dirstr_parent(pool, file);
-  const char* pattern = apr_pstrcat(pool, parent_dir, sub_pat, NULL);
-  luaL_gsub(L, current, rep_pat, pattern);
-  lua_setfield(L, -3, field);
-  lua_getfield(L, -2, field);
-  const char* modified = lua_tostring(L, -1);
-  lua_pop(L, 2);
-  
-  char * part = apr_pstrdup(pool, modified);
-  int i;
-  for (i = 0; i < paths->nelts; i++) {
-    const char *new_path = ((const char**)paths->elts)[i];
-    part = apr_pstrcat(pool, part, ";", new_path, NULL);
-  }
-  lua_pushstring(L, part);
-  lua_setfield(L, -2, field);
-  lua_pop(L, 1); /* pop "package" off the stack     */
+                       apr_pool_t *pool,
+                       apr_array_header_t *paths, const char *file)
+{
+    lua_getglobal(L, "package");
+    lua_getfield(L, -1, field);
+    const char *current = lua_tostring(L, -1);
+    const char *parent_dir = ap_make_dirstr_parent(pool, file);
+    const char *pattern = apr_pstrcat(pool, parent_dir, sub_pat, NULL);
+    luaL_gsub(L, current, rep_pat, pattern);
+    lua_setfield(L, -3, field);
+    lua_getfield(L, -2, field);
+    const char *modified = lua_tostring(L, -1);
+    lua_pop(L, 2);
+
+    char *part = apr_pstrdup(pool, modified);
+    int i;
+    for (i = 0; i < paths->nelts; i++) {
+        const char *new_path = ((const char **) paths->elts)[i];
+        part = apr_pstrcat(pool, part, ";", new_path, NULL);
+    }
+    lua_pushstring(L, part);
+    lua_setfield(L, -2, field);
+    lua_pop(L, 1);              /* pop "package" off the stack     */
 }
 
-lua_State* apl_get_lua_state(apr_pool_t* lifecycle_pool, 
-                            char* file, 
-                            apr_array_header_t* package_paths, 
-                            apr_array_header_t* package_cpaths,
-                            apl_lua_state_open_callback cb,
-                            void* btn) {
-    
-    lua_State* L;
-    ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, lifecycle_pool, "obtaining lua_State");
-    if (!apr_pool_userdata_get((void**)&L, file, lifecycle_pool)) {
-        ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, lifecycle_pool, "creating lua_State with file %s", file);
+lua_State *apl_get_lua_state(apr_pool_t *lifecycle_pool,
+                             char *file,
+                             apr_array_header_t *package_paths,
+                             apr_array_header_t *package_cpaths,
+                             apl_lua_state_open_callback cb, void *btn)
+{
+
+    lua_State *L;
+    ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, lifecycle_pool,
+                  "obtaining lua_State");
+    if (!apr_pool_userdata_get((void **) &L, file, lifecycle_pool)) {
+        ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, lifecycle_pool,
+                      "creating lua_State with file %s", file);
         /* not available, so create */
-        L =  luaL_newstate();
-        luaL_openlibs(L);        
-        if (package_paths) 
-            munge_path(L, "path", "?.lua", "./?.lua", lifecycle_pool, package_paths, file);
-        if (package_cpaths) 
-            munge_path(L, "cpath", "?.so", "./?.so", lifecycle_pool, package_cpaths, file);
-        
+        L = luaL_newstate();
+        luaL_openlibs(L);
+        if (package_paths)
+            munge_path(L, "path", "?.lua", "./?.lua", lifecycle_pool,
+                       package_paths, file);
+        if (package_cpaths)
+            munge_path(L, "cpath", "?.so", "./?.so", lifecycle_pool,
+                       package_cpaths, file);
+
         if (cb) {
             cb(L, lifecycle_pool, btn);
         }
-        
+
         luaL_loadfile(L, file);
         lua_pcall(L, 0, LUA_MULTRET, 0);
         apr_pool_userdata_set(L, file, &cleanup_lua, lifecycle_pool);
-        
+
         lua_pushlightuserdata(L, lifecycle_pool);
-        lua_setfield(L, LUA_REGISTRYINDEX, "Apache2.Wombat.pool");  
+        lua_setfield(L, LUA_REGISTRYINDEX, "Apache2.Wombat.pool");
     }
     return L;
 }
-
-
-
-
-
-

Modified: httpd/httpd/trunk/modules/lua/lua_vmprep.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_vmprep.h?rev=728516&r1=728515&r2=728516&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_vmprep.h (original)
+++ httpd/httpd/trunk/modules/lua/lua_vmprep.h Sun Dec 21 13:41:52 2008
@@ -45,22 +45,23 @@
 
 /**
  * Specification for a lua virtual machine
- */ 
-typedef struct {
+ */
+typedef struct
+{
 
     /* NEED TO ADD ADDITIONAL PACKAGE PATHS AS PART OF SPEC INSTEAD OF DIR CONFIG */
-    apr_array_header_t* package_paths;
-    apr_array_header_t* package_cpaths;
-    
+    apr_array_header_t *package_paths;
+    apr_array_header_t *package_cpaths;
+
     /* name of base file to load in the vm */
-    char *file;             
+    char *file;
 
     /* APL_CODE_CACHE_STAT | APL_CODE_CACHE_FOREVER | APL_CODE_CACHE_NEVER */
     int code_cache_style;
 
     /* APL_SCOPE_ONCE | APL_SCOPE_REQUEST | APL_SCOPE_CONN | APL_SCOPE_SERVER */
     int scope;
-    
+
     /* pool to use for lifecycle if APL_SCOPE_ONCE is set, otherwise unused */
     apr_pool_t *pool;
 
@@ -68,7 +69,8 @@
     apr_size_t bytecode_len;
 } apl_vm_spec;
 
-typedef struct {
+typedef struct
+{
     int code_cache_style;
     char *function_name;
     char *file_name;
@@ -78,17 +80,18 @@
     apr_size_t bytecode_len;
 } apl_mapped_handler_spec;
 
-typedef struct {
+typedef struct
+{
     apr_pool_t *pool;
     apr_hash_t *compiled_files;
-    apr_thread_rwlock_t* compiled_files_lock;
+    apr_thread_rwlock_t *compiled_files_lock;
 } apl_code_cache;
 
 /* remove and make static once out of mod_wombat.c */
-void apl_openlibs(lua_State* L);
+void apl_openlibs(lua_State *L);
 
 /* remove and make static once out of mod_wombat.c */
-void apl_registerlib(lua_State* L, char* name, lua_CFunction f);
+void apl_registerlib(lua_State *L, char *name, lua_CFunction f);
 
 /**
  * Fake out addition of the "apache2" module
@@ -108,7 +111,8 @@
 /* returns NULL if the spec requires a request scope or conn scope */
 /* lua_State* apl_sgetvm(server_rec *r, apl_vm_spec *spec); */
 
-typedef void (*apl_lua_state_open_callback) (lua_State* L, apr_pool_t* p, void* ctx);
+typedef void (*apl_lua_state_open_callback) (lua_State *L, apr_pool_t *p,
+                                             void *ctx);
 
 /*
  * alternate means of getting lua_State (preferred eventually)
@@ -122,14 +126,12 @@
  * @cb callback for vm initialization called *before* the file is opened
  * @ctx a baton passed to cb
  */
-lua_State* apl_get_lua_state(apr_pool_t* lifecycle_pool, 
-                             char* file, 
-                             apr_array_header_t* package_paths, 
-                             apr_array_header_t* package_cpaths,
-                             apl_lua_state_open_callback cb,
-                             void* btn);
-                             
-                             
+lua_State *apl_get_lua_state(apr_pool_t *lifecycle_pool,
+                             char *file,
+                             apr_array_header_t *package_paths,
+                             apr_array_header_t *package_cpaths,
+                             apl_lua_state_open_callback cb, void *btn);
+
 
-#endif
 
+#endif