]> granicus.if.org Git - apache/commitdiff
fix symbol space and exports
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 25 Mar 2009 20:09:08 +0000 (20:09 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 25 Mar 2009 20:09:08 +0000 (20:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@758428 13f79535-47bb-0310-9956-ffa450edef68

modules/lua/lua_apr.c
modules/lua/lua_apr.h
modules/lua/lua_config.c
modules/lua/lua_config.h
modules/lua/lua_request.c
modules/lua/lua_request.h
modules/lua/lua_vmprep.c
modules/lua/lua_vmprep.h
modules/lua/mod_lua.c
modules/lua/mod_lua.h

index fb514ebc05a1d4b4923aeed51b65c142dfe30cb1..bcd5c59754a89f3e232451dba6f3d3cf3808d9a4 100644 (file)
@@ -17,9 +17,7 @@
 #include "apr.h"
 #include "apr_tables.h"
 
-#include "lua.h"
-#include "lauxlib.h"
-#include "lualib.h"
+#include "mod_lua.h"
 #include "lua_apr.h"
 
 /**
@@ -41,7 +39,7 @@ apr_table_t *check_apr_table(lua_State *L, int index)
 }
 
 
-void apl_push_apr_table(lua_State *L, apr_table_t *t)
+AP_LUA_DECLARE(void) ap_lua_push_apr_table(lua_State *L, apr_table_t *t)
 {
     lua_boxpointer(L, t);
     luaL_getmetatable(L, "Apr.Table");
@@ -74,7 +72,7 @@ static const luaL_reg lua_table_methods[] = {
 };
 
 
-int apr_lua_init(lua_State *L, apr_pool_t *p)
+AP_LUA_DECLARE(int) ap_lua_init(lua_State *L, apr_pool_t *p)
 {
     luaL_newmetatable(L, "Apr.Table");
     luaL_openlib(L, "apr_table", lua_table_methods, 0);
index be4fa10540be426f3dff903ba7ebbf8283bbaf47..c66cdde9e808e82c75eaeaba49b7d9ea08f0b882 100644 (file)
@@ -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, apr_table_t *t);
+AP_LUA_DECLARE(int) ap_lua_init(lua_State *L, apr_pool_t * p);
+AP_LUA_DECLARE(apr_table_t*) ap_lua_check_apr_table(lua_State *L, int index);
+AP_LUA_DECLARE(void) ap_lua_push_apr_table(lua_State *L, apr_table_t *t);
 
 #endif /* !_LUA_APR_H_ */
index 62e6757ad7375aeb171ad8f4c58241dcb6f9bbf9..3beaf91e8aedbd4e48cae61b1a11f7a6ecf2dbcf 100644 (file)
 #include "lua_config.h"
 #include "lua_vmprep.h"
 
-static apl_dir_cfg *check_dir_config(lua_State *L, int index)
+static ap_lua_dir_cfg *check_dir_config(lua_State *L, int index)
 {
-    apl_dir_cfg *cfg;
+    ap_lua_dir_cfg *cfg;
     luaL_checkudata(L, index, "Apache2.DirConfig");
-    cfg = (apl_dir_cfg *) lua_unboxpointer(L, index);
+    cfg = (ap_lua_dir_cfg *) lua_unboxpointer(L, index);
     return cfg;
 }
 
@@ -49,15 +49,16 @@ static int apl_toscope(const char *name)
     return APL_SCOPE_ONCE;
 }
 
-apr_status_t apl_lua_map_handler(apl_dir_cfg *cfg,
-                                 const char *file,
-                                 const char *function,
-                                 const char *pattern, const char *scope)
+AP_LUA_DECLARE(apr_status_t) ap_lua_map_handler(ap_lua_dir_cfg *cfg,
+                                                 const char *file,
+                                                 const char *function,
+                                                 const char *pattern,
+                                                 const char *scope)
 {
     ap_regex_t *uri_pattern;
     apr_status_t rv;
-    apl_mapped_handler_spec *handler =
-        apr_palloc(cfg->pool, sizeof(apl_mapped_handler_spec));
+    ap_lua_mapped_handler_spec *handler =
+        apr_palloc(cfg->pool, sizeof(ap_lua_mapped_handler_spec));
     handler->uri_pattern = NULL;
     handler->function_name = NULL;
 
@@ -70,17 +71,17 @@ apr_status_t apl_lua_map_handler(apl_dir_cfg *cfg,
     handler->scope = apl_toscope(scope);
 
     handler->function_name = apr_pstrdup(cfg->pool, function);
-    *(const apl_mapped_handler_spec **) apr_array_push(cfg->mapped_handlers) =
+    *(const ap_lua_mapped_handler_spec **) apr_array_push(cfg->mapped_handlers) =
         handler;
     return APR_SUCCESS;
 }
 
-/* Change to use apl_lua_map_handler */
+/* Change to use ap_lua_map_handler */
 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));
+    ap_lua_dir_cfg *cfg = check_dir_config(L, 1);
+    ap_lua_mapped_handler_spec *handler =
+        apr_palloc(cfg->pool, sizeof(ap_lua_mapped_handler_spec));
     handler->uri_pattern = NULL;
     handler->function_name = NULL;
 
@@ -126,20 +127,20 @@ static int cfg_lua_map_handler(lua_State *L)
     lua_pop(L, 1);
 
 
-    *(const apl_mapped_handler_spec **) apr_array_push(cfg->mapped_handlers) =
+    *(const ap_lua_mapped_handler_spec **) apr_array_push(cfg->mapped_handlers) =
         handler;
     return 0;
 }
 
 static int cfg_directory(lua_State *L)
 {
-    apl_dir_cfg *cfg = check_dir_config(L, 1);
+    ap_lua_dir_cfg *cfg = check_dir_config(L, 1);
     lua_pushstring(L, cfg->dir);
     return 1;
 }
 
 /*static int cfg_root(lua_State *L) {
-    apl_dir_cfg *cfg = check_dir_config(L, 1);
+    ap_lua_dir_cfg *cfg = check_dir_config(L, 1);
     lua_pushstring(L, cfg->root_path);
     return 1;
 }*/
@@ -233,7 +234,7 @@ static const struct luaL_Reg cmd_methods[] = {
     {NULL, NULL}
 };
 
-void apl_load_config_lmodule(lua_State *L)
+AP_LUA_DECLARE(void) ap_lua_load_config_lmodule(lua_State *L)
 {
     luaL_newmetatable(L, "Apache2.DirConfig");  /* [metatable] */
     lua_pushvalue(L, -1);
index 8f8761ee961c02b51bbdb51038575bfe544ca07e..d2689da1aaee41b9df6656afb2371c7e7af8e9f3 100644 (file)
 #ifndef _APL_CONFIG_H_
 #define _APL_CONFIG_H_
 
-APR_DECLARE(void) apl_load_config_lmodule(lua_State *L);
+AP_LUA_DECLARE(void) ap_lua_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);
+AP_LUA_DECLARE(apr_status_t) ap_lua_map_handler(ap_lua_dir_cfg *cfg,
+                                                const char *file,
+                                                const char *function,
+                                                const char *pattern,
+                                                const char *scope);
 
 #endif /* !_APL_CONFIG_H_ */
index 4c96c49c44f83643aae83be94568e708249f096e..75fe7151ad2f14e5856ddf0abc2aa304e297522c 100644 (file)
@@ -23,7 +23,7 @@ typedef char *(*req_field_string_f) (request_rec * r);
 typedef int (*req_field_int_f) (request_rec * r);
 typedef apr_table_t *(*req_field_apr_table_f) (request_rec * r);
 
-void apl_rstack_dump(lua_State *L, request_rec *r, const char *msg)
+void ap_lua_rstack_dump(lua_State *L, request_rec *r, const char *msg)
 {
     int i;
     int top = lua_gettop(L);
@@ -92,7 +92,7 @@ void apl_rstack_dump(lua_State *L, request_rec *r, const char *msg)
  * 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 *ap_lua_check_request_rec(lua_State *L, int index)
 {
     request_rec *r;
     luaL_checkudata(L, index, "Apache2.Request");
@@ -154,7 +154,7 @@ static int req_aprtable2luatable_cb(void *l, const char *key,
 static int req_parseargs(lua_State *L)
 {
     apr_table_t *form_table;
-    request_rec *r = apl_check_request_rec(L, 1);
+    request_rec *r = ap_lua_check_request_rec(L, 1);
     lua_newtable(L);
     lua_newtable(L);            /* [table, table] */
     ap_args_to_table(r, &form_table);
@@ -165,7 +165,7 @@ static int req_parseargs(lua_State *L)
 /* wrap ap_rputs as r:puts(String) */
 static int req_puts(lua_State *L)
 {
-    request_rec *r = apl_check_request_rec(L, 1);
+    request_rec *r = ap_lua_check_request_rec(L, 1);
 
     int argc = lua_gettop(L);
     int i;
@@ -179,7 +179,7 @@ static int req_puts(lua_State *L)
 /* wrap ap_rwrite as r:write(String) */
 static int req_write(lua_State *L)
 {
-    request_rec *r = apl_check_request_rec(L, 1);
+    request_rec *r = ap_lua_check_request_rec(L, 1);
     size_t n;
     const char *buf = luaL_checklstring(L, 2, &n);
 
@@ -191,7 +191,7 @@ static int req_write(lua_State *L)
 static int req_parsebody(lua_State *L)
 {
     apr_table_t *form_table;
-    request_rec *r = apl_check_request_rec(L, 1);
+    request_rec *r = ap_lua_check_request_rec(L, 1);
     lua_newtable(L);
     lua_newtable(L);
     if (ap_body_to_table(r, &form_table) == APR_SUCCESS) {
@@ -203,7 +203,7 @@ static int req_parsebody(lua_State *L)
 /* r:addoutputfilter(name|function) */
 static int req_add_output_filter(lua_State *L)
 {
-    request_rec *r = apl_check_request_rec(L, 1);
+    request_rec *r = ap_lua_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);
@@ -214,7 +214,7 @@ static int req_add_output_filter(lua_State *L)
 /* BEGIN dispatch mathods for request_rec fields */
 
 /* not really a field, but we treat it like one */
-static char *req_document_root(request_rec *r)
+static const char *req_document_root(request_rec *r)
 {
     return ap_document_root(r);
 }
@@ -321,7 +321,7 @@ static int req_dispatch(lua_State *L)
 {
     apr_hash_t *dispatch;
     req_fun_t *rft;
-    request_rec *r = apl_check_request_rec(L, 1);
+    request_rec *r = ap_lua_check_request_rec(L, 1);
     const char *name = luaL_checkstring(L, 2);
     lua_pop(L, 2);
 
@@ -333,13 +333,13 @@ static int req_dispatch(lua_State *L)
     if (rft) {
         switch (rft->type) {
         case APL_REQ_FUNTYPE_TABLE:{
+                apr_table_t *rs;
                 req_field_apr_table_f func = rft->fun;
                 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                               "request_rec->dispatching %s -> apr table",
                               name);
-                apr_table_t *rs;
                 rs = (*func)(r);
-                apl_push_apr_table(L, rs);          
+                ap_lua_push_apr_table(L, rs);          
                 return 1;
             }
 
@@ -389,7 +389,7 @@ static int req_dispatch(lua_State *L)
 static int req_log_at(lua_State *L, int level)
 {
     const char *msg;
-    request_rec *r = apl_check_request_rec(L, 1);
+    request_rec *r = ap_lua_check_request_rec(L, 1);
     lua_Debug dbg;
 
     lua_getstack(L, 1, &dbg);
@@ -448,7 +448,7 @@ static int req_newindex(lua_State *L)
     const char *key;
     /* 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 = ap_lua_check_request_rec(L, 1);
     key = luaL_checkstring(L, 2);
     if (0 == apr_strnatcmp("status", key)) {
         int code = luaL_checkinteger(L, 3);
@@ -508,7 +508,7 @@ static req_fun_t *makefun(void *fun, int type, apr_pool_t *pool)
     return rft;
 }
 
-void apl_load_request_lmodule(lua_State *L, apr_pool_t *p)
+AP_LUA_DECLARE(void) ap_lua_load_request_lmodule(lua_State *L, apr_pool_t *p)
 {
 
     apr_hash_t *dispatch = apr_hash_make(p);
@@ -614,14 +614,14 @@ void apl_load_request_lmodule(lua_State *L, apr_pool_t *p)
 
 }
 
-void apl_push_connection(lua_State *L, conn_rec *c)
+void ap_lua_push_connection(lua_State *L, conn_rec *c)
 {
     lua_boxpointer(L, c);
     luaL_getmetatable(L, "Apache2.Connection");
     lua_setmetatable(L, -2);
     luaL_getmetatable(L, "Apache2.Connection");
 
-    apl_push_apr_table(L, c->notes);
+    ap_lua_push_apr_table(L, c->notes);
     lua_setfield(L, -2, "notes");
 
     lua_pushstring(L, c->remote_ip);
@@ -631,7 +631,7 @@ void apl_push_connection(lua_State *L, conn_rec *c)
 }
 
 
-void apl_push_server(lua_State *L, server_rec *s)
+void ap_lua_push_server(lua_State *L, server_rec *s)
 {
     lua_boxpointer(L, s);
     luaL_getmetatable(L, "Apache2.Server");
@@ -644,7 +644,7 @@ void apl_push_server(lua_State *L, server_rec *s)
     lua_pop(L, 1);
 }
 
-void apl_push_request(lua_State *L, request_rec *r)
+AP_LUA_DECLARE(void) ap_lua_push_request(lua_State *L, request_rec *r)
 {
     lua_boxpointer(L, r);
     luaL_getmetatable(L, "Apache2.Request");
index beed41fc98d54737893caab44304a75f8dbf7fd6..d11ecea138b5c3b19cfd1021f6cbb5dbf4b05d36 100644 (file)
  * limitations under the License.
  */
 
+#include "mod_lua.h"
+
 #ifndef _LUA_REQUEST_H_
 #define _LUA_REQUEST_H_
 
-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);
+AP_LUA_DECLARE(void) ap_lua_push_request(lua_State *L, request_rec *r);
+AP_LUA_DECLARE(void) ap_lua_load_request_lmodule(lua_State *L, apr_pool_t *p);
 
 #define APL_REQ_FUNTYPE_STRING      1
 #define APL_REQ_FUNTYPE_INT         2
index 1d139a5be07a042949da73642de531cfeaa04a8c..8e4c3196505b925df135ce8905630d112c8da219 100644 (file)
@@ -95,7 +95,7 @@ static void pstack_dump(lua_State *L, apr_pool_t *r, int level,
 
 /* BEGIN apache lmodule  */
 
-void apl_load_apache2_lmodule(lua_State *L)
+AP_LUA_DECLARE(void) ap_lua_load_apache2_lmodule(lua_State *L)
 {
     lua_getglobal(L, "package");
     lua_getfield(L, -1, "loaded");
@@ -286,11 +286,12 @@ static int loadjitmodule(lua_State *L, apr_pool_t *lifecycle_pool) {
 
 #endif
 
-lua_State *apl_get_lua_state(apr_pool_t *lifecycle_pool,
-                             apl_vm_spec *spec,
-                             apr_array_header_t *package_paths,
-                             apr_array_header_t *package_cpaths,
-                             apl_lua_state_open_callback cb, void *btn)
+AP_LUA_DECLARE(lua_State*)ap_lua_get_lua_state(apr_pool_t *lifecycle_pool,
+                                               ap_lua_vm_spec *spec,
+                                               apr_array_header_t *package_paths,
+                                               apr_array_header_t *package_cpaths,
+                                               ap_lua_state_open_callback cb,
+                                               void *btn)
 {
 
     lua_State *L;
index a0c37259bcb3a3c20e083a8cba85aebda7108359..995ff2db0251a38ee6a92575b2fb4fb12ea4d6f9 100644 (file)
@@ -71,7 +71,7 @@ typedef struct
      */
     const char *bytecode;
     apr_size_t bytecode_len;
-} apl_vm_spec;
+} ap_lua_vm_spec;
 
 typedef struct
 {
@@ -82,40 +82,40 @@ typedef struct
     ap_regex_t *uri_pattern;
     const char *bytecode;
     apr_size_t bytecode_len;
-} apl_mapped_handler_spec;
+} ap_lua_mapped_handler_spec;
 
 typedef struct
 {
     apr_pool_t *pool;
     apr_hash_t *compiled_files;
     apr_thread_rwlock_t *compiled_files_lock;
-} apl_code_cache;
+} ap_lua_code_cache;
 
 /* remove and make static once out of mod_wombat.c */
-void apl_openlibs(lua_State *L);
+AP_LUA_DECLARE(void) ap_lua_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);
+AP_LUA_DECLARE(void) ap_lua_registerlib(lua_State *L, char *name, lua_CFunction f);
 
 /**
  * Fake out addition of the "apache2" module
  */
-void apl_load_apache2_lmodule(lua_State *L);
+AP_LUA_DECLARE(void) ap_lua_load_apache2_lmodule(lua_State *L);
 
 /**
- * the apl_?getvm family of functions is used to create and/or obtain
+ * the ap_lua_?getvm family of functions is used to create and/or obtain
  * a handle to a lua state. If there is not an extant vm matching the
  * spec then a new one is created.
  */
-/* lua_State* apl_rgetvm(request_rec *r, apl_vm_spec *spec); */
+/* lua_State* ap_lua_rgetvm(request_rec *r, ap_lua_vm_spec *spec); */
 
 /* returns NULL if the spec requires a request scope */
-/* lua_State* apl_cgetvm(conn_rec *r, apl_vm_spec *spec);*/
+/* lua_State* ap_lua_cgetvm(conn_rec *r, ap_lua_vm_spec *spec);*/
 
 /* returns NULL if the spec requires a request scope or conn scope */
-/* lua_State* apl_sgetvm(server_rec *r, apl_vm_spec *spec); */
+/* lua_State* ap_lua_sgetvm(server_rec *r, ap_lua_vm_spec *spec); */
 
-typedef void (*apl_lua_state_open_callback) (lua_State *L, apr_pool_t *p,
+typedef void (*ap_lua_state_open_callback) (lua_State *L, apr_pool_t *p,
                                              void *ctx);
 
 /*
@@ -130,11 +130,12 @@ typedef void (*apl_lua_state_open_callback) (lua_State *L, apr_pool_t *p,
  * @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,
-                             apl_vm_spec *spec,
-                             apr_array_header_t *package_paths,
-                             apr_array_header_t *package_cpaths,
-                             apl_lua_state_open_callback cb, void *btn);
+AP_LUA_DECLARE(lua_State*) ap_lua_get_lua_state(apr_pool_t *lifecycle_pool,
+                                                ap_lua_vm_spec *spec,
+                                                apr_array_header_t *package_paths,
+                                                apr_array_header_t *package_cpaths,
+                                                ap_lua_state_open_callback cb, 
+                                                void *btn);
 
 
 
index 638455faa75b527f55007ac8beba3e48699c01e7..73fd9e0bfc5071bb04d5977618d53b01f872867c 100644 (file)
 #include "lua_apr.h"
 #include "lua_config.h"
 
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(apl, AP_LUA, int, lua_open,
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap_lua, AP_LUA, int, lua_open,
                                     (lua_State *L, apr_pool_t *p),
                                     (L, p), OK, DECLINED)
 
-APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(apl, AP_LUA, int, lua_request,
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap_lua, AP_LUA, int, lua_request,
                                     (lua_State *L, request_rec *r),
                                     (L, r), OK, DECLINED)
 
@@ -55,10 +55,10 @@ static void report_lua_error(lua_State *L, request_rec *r)
 
 static void lua_open_callback(lua_State *L, apr_pool_t *p, void *ctx)
 {
-    apr_lua_init(L, p);
-    apl_load_apache2_lmodule(L);
-    apl_load_request_lmodule(L, p);
-    apl_load_config_lmodule(L);
+    ap_lua_init(L, p);
+    ap_lua_load_apache2_lmodule(L);
+    ap_lua_load_request_lmodule(L, p);
+    ap_lua_load_config_lmodule(L);
 }
 
 static int lua_open_hook(lua_State *L, apr_pool_t *p)
@@ -99,7 +99,7 @@ static apr_status_t luahood(ap_filter_t *f, apr_bucket_brigade *bb) {
  */
 static int lua_handler(request_rec *r)
 {
-    apl_dir_cfg *dcfg;
+    ap_lua_dir_cfg *dcfg;
     if (strcmp(r->handler, "lua-script")) {
         return DECLINED;
     }
@@ -110,16 +110,16 @@ static int lua_handler(request_rec *r)
 
     if (!r->header_only) {
         lua_State *L;
-        const apl_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
+        const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
                                                       &lua_module);
-        apl_request_cfg *rcfg =
+        ap_lua_request_cfg *rcfg =
             ap_get_module_config(r->request_config, &lua_module);
         mapped_request_details *d = rcfg->mapped_request_details;
-        apl_vm_spec *spec = NULL;
+        ap_lua_vm_spec *spec = NULL;
 
         if (!d) {
             d = apr_palloc(r->pool, sizeof(mapped_request_details));
-            spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
+            spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
             spec->scope = dcfg->vm_scope;
             spec->pool = r->pool;
             spec->file = r->filename;
@@ -131,7 +131,7 @@ static int lua_handler(request_rec *r)
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                       "request details scope:%u, cache:%u", d->spec->scope,
                       d->spec->code_cache_style);
-        L = apl_get_lua_state(r->pool,
+        L = ap_lua_get_lua_state(r->pool,
                               d->spec,
                               cfg->package_paths,
                               cfg->package_cpaths,
@@ -144,7 +144,7 @@ static int lua_handler(request_rec *r)
             ap_rputs("Unable to compile VM, see logs", r);
         }
         lua_getglobal(L, d->function_name);
-        apl_run_lua_request(L, r);
+        ap_lua_run_lua_request(L, r);
         if (lua_pcall(L, 1, 0, 0)) {
             report_lua_error(L, r);
         }
@@ -157,19 +157,19 @@ static int lua_handler(request_rec *r)
 /**
  * Like mod_alias except for lua handler fun :-) 
  */
-static int apl_alias_munger(request_rec *r)
+static int lua_alias_munger(request_rec *r)
 {
-    apl_vm_spec *spec;
-    apl_request_cfg *rcfg = ap_get_module_config(r->request_config,
+    ap_lua_vm_spec *spec;
+    ap_lua_request_cfg *rcfg = ap_get_module_config(r->request_config,
                                                  &lua_module);
-    const apl_dir_cfg *cfg =
+    const ap_lua_dir_cfg *cfg =
         ap_get_module_config(r->per_dir_config, &lua_module);
     int i;
     ap_regmatch_t matches[AP_MAX_REG_MATCH];
 
     for (i = 0; i < cfg->mapped_handlers->nelts; i++) {
-        const apl_mapped_handler_spec *cnd =
-            ((const apl_mapped_handler_spec **) cfg->mapped_handlers->elts)[i];
+        const ap_lua_mapped_handler_spec *cnd =
+            ((const ap_lua_mapped_handler_spec **) cfg->mapped_handlers->elts)[i];
 
         if (OK ==
             ap_regexec(cnd->uri_pattern, r->uri, AP_MAX_REG_MATCH, matches,
@@ -177,7 +177,7 @@ static int apl_alias_munger(request_rec *r)
             mapped_request_details *d;
             r->handler = "lua-script";
 
-            spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
+            spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
             spec->file =
                 ap_pregsub(r->pool, cnd->file_name, r->uri, AP_MAX_REG_MATCH,
                            matches);
@@ -213,24 +213,24 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name)
 {
     int rc;
     lua_State *L;
-    apl_vm_spec *spec;
-    apl_server_cfg *server_cfg = ap_get_module_config(r->server->module_config,
+    ap_lua_vm_spec *spec;
+    ap_lua_server_cfg *server_cfg = ap_get_module_config(r->server->module_config,
                                                       &lua_module);
-    const apl_dir_cfg *cfg =
-        (apl_dir_cfg *) ap_get_module_config(r->per_dir_config,
+    const ap_lua_dir_cfg *cfg =
+        (ap_lua_dir_cfg *) ap_get_module_config(r->per_dir_config,
                                              &lua_module);
     apr_array_header_t *hook_specs =
         apr_hash_get(cfg->hooks, name, APR_HASH_KEY_STRING);
     if (hook_specs) {
         int i;
         for (i = 0; i < hook_specs->nelts; i++) {
-            apl_mapped_handler_spec *hook_spec =
-                ((apl_mapped_handler_spec **) hook_specs->elts)[i];
+            ap_lua_mapped_handler_spec *hook_spec =
+                ((ap_lua_mapped_handler_spec **) hook_specs->elts)[i];
 
             if (hook_spec == NULL) {
                 continue;
             }
-            spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
+            spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
 
             spec->file = hook_spec->file_name;
             spec->code_cache_style = hook_spec->code_cache_style;
@@ -241,7 +241,7 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name)
 
             apr_filepath_merge(&spec->file, server_cfg->root_path,
                                spec->file, APR_FILEPATH_NOTRELATIVE, r->pool);
-            L = apl_get_lua_state(r->pool,
+            L = ap_lua_get_lua_state(r->pool,
                                   spec,
                                   cfg->package_paths,
                                   cfg->package_cpaths,
@@ -266,11 +266,11 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name)
                     return HTTP_INTERNAL_SERVER_ERROR;
                 }
 
-                apl_run_lua_request(L, r);
+                ap_lua_run_lua_request(L, r);
             }
             else {
                 int t;
-                apl_run_lua_request(L, r);
+                ap_lua_run_lua_request(L, r);
 
                 t = lua_gettop(L);
                 lua_setglobal(L, "r");
@@ -385,7 +385,7 @@ static int ldump_writer(lua_State *L, const void *b, size_t size, void *B)
 typedef struct hack_section_baton
 {
     const char *name;
-    apl_mapped_handler_spec *spec;
+    ap_lua_mapped_handler_spec *spec;
 } hack_section_baton;
 
 /* You can be unhappy now.
@@ -401,7 +401,7 @@ typedef struct hack_section_baton
 static const char *hack_section_handler(cmd_parms *cmd, void *_cfg,
                                         const char *arg)
 {
-    apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
+    ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
     ap_directive_t *directive = cmd->directive;
     hack_section_baton *baton = directive->data;
 
@@ -409,14 +409,14 @@ static const char *hack_section_handler(cmd_parms *cmd, void *_cfg,
         apr_hash_get(cfg->hooks, baton->name, APR_HASH_KEY_STRING);
     if (!hook_specs) {
         hook_specs =
-            apr_array_make(cmd->pool, 2, sizeof(apl_mapped_handler_spec *));
+            apr_array_make(cmd->pool, 2, sizeof(ap_lua_mapped_handler_spec *));
         apr_hash_set(cfg->hooks, apr_pstrdup(cmd->pool, baton->name),
                      APR_HASH_KEY_STRING, hook_specs);
     }
 
     baton->spec->scope = cfg->vm_scope;
 
-    *(apl_mapped_handler_spec **) apr_array_push(hook_specs) = baton->spec;
+    *(ap_lua_mapped_handler_spec **) apr_array_push(hook_specs) = baton->spec;
 
     return NULL;
 }
@@ -427,7 +427,7 @@ static const char *register_named_block_function_hook(const char *name,
                                                       const char *line)
 {
     const char *function;
-    apl_mapped_handler_spec *spec;
+    ap_lua_mapped_handler_spec *spec;
 
     if (line && line[0] == '>') {
         function = NULL;
@@ -446,7 +446,7 @@ static const char *register_named_block_function_hook(const char *name,
         }
     }
 
-    spec = apr_pcalloc(cmd->pool, sizeof(apl_mapped_handler_spec));
+    spec = apr_pcalloc(cmd->pool, sizeof(ap_lua_mapped_handler_spec));
 
     {
         cr_ctx ctx;
@@ -529,19 +529,19 @@ static const char *register_named_file_function_hook(const char *name,
                                                      const char *file,
                                                      const char *function)
 {
-    apl_mapped_handler_spec *spec;
-    apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
+    ap_lua_mapped_handler_spec *spec;
+    ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
 
     apr_array_header_t *hook_specs =
         apr_hash_get(cfg->hooks, name, APR_HASH_KEY_STRING);
     if (!hook_specs) {
         hook_specs =
-            apr_array_make(cmd->pool, 2, sizeof(apl_mapped_handler_spec *));
+            apr_array_make(cmd->pool, 2, sizeof(ap_lua_mapped_handler_spec *));
         apr_hash_set(cfg->hooks, apr_pstrdup(cmd->pool, name),
                      APR_HASH_KEY_STRING, hook_specs);
     }
 
-    spec = apr_pcalloc(cmd->pool, sizeof(apl_mapped_handler_spec));
+    spec = apr_pcalloc(cmd->pool, sizeof(ap_lua_mapped_handler_spec));
     spec->file_name = apr_pstrdup(cmd->pool, file);
     spec->function_name = apr_pstrdup(cmd->pool, function);
     spec->scope = cfg->vm_scope;
@@ -552,7 +552,7 @@ static const char *register_named_file_function_hook(const char *name,
        char *file_name;
        int scope;
      */
-    *(apl_mapped_handler_spec **) apr_array_push(hook_specs) = spec;
+    *(ap_lua_mapped_handler_spec **) apr_array_push(hook_specs) = spec;
     return NULL;
 }
 
@@ -729,7 +729,7 @@ static const char *register_package_helper(cmd_parms *cmd, const char *arg,
 {
     apr_status_t rv;
 
-    apl_server_cfg *server_cfg =
+    ap_lua_server_cfg *server_cfg =
         ap_get_module_config(cmd->server->module_config, &lua_module);
     char *fixed_filename;
     rv = apr_filepath_merge(&fixed_filename, server_cfg->root_path, arg,
@@ -751,7 +751,7 @@ static const char *register_package_helper(cmd_parms *cmd, const char *arg,
 static const char *register_package_dir(cmd_parms *cmd, void *_cfg,
                                         const char *arg)
 {
-    apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
+    ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
 
     return register_package_helper(cmd, arg, cfg->package_paths);
 }
@@ -763,7 +763,7 @@ static const char *register_package_dir(cmd_parms *cmd, void *_cfg,
 static const char *register_package_cdir(cmd_parms *cmd, void *_cfg,
                                          const char *arg)
 {
-    apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
+    ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
 
     return register_package_helper(cmd, arg, cfg->package_cpaths);
 }
@@ -775,7 +775,7 @@ static const char *register_package_cdir(cmd_parms *cmd, void *_cfg,
 static const char *register_code_cache(cmd_parms *cmd, void *_cfg,
                                        const char *arg)
 {
-    apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
+    ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
     if (apr_strnatcmp("stat", arg) == 0) {
         cfg->code_cache_style = APL_CODE_CACHE_STAT;
     }
@@ -797,7 +797,7 @@ static const char *register_lua_scope(cmd_parms *cmd, void *_cfg,
                                       const char *scope, const char *min,
                                       const char *max)
 {
-    apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
+    ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
     if (apr_strnatcmp("once", scope) == 0) {
         cfg->vm_scope = APL_SCOPE_ONCE;
     }
@@ -831,11 +831,11 @@ static const char *lua_map_handler(cmd_parms *cmd, void *_cfg,
                                    const char *path, const char *file,
                                    const char *function)
 {
-    apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
+    ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
     apr_status_t rv;
     const char *function_name;
     function_name = function ? function : "handle";
-    rv = apl_lua_map_handler(cfg, file, function_name, path, "once");
+    rv = ap_lua_map_handler(cfg, file, function_name, path, "once");
     if (rv != APR_SUCCESS) {
         return apr_psprintf(cmd->pool,
                             "Unable to configure a lua handler for path '%s', handler %s#%s",
@@ -847,8 +847,8 @@ static const char *lua_map_handler(cmd_parms *cmd, void *_cfg,
 static const char *register_lua_root(cmd_parms *cmd, void *_cfg,
                                      const char *root)
 {
-    /* apl_dir_cfg* cfg = (apl_dir_cfg*)_cfg; */
-    apl_server_cfg *cfg =
+    /* ap_lua_dir_cfg* cfg = (ap_lua_dir_cfg*)_cfg; */
+    ap_lua_server_cfg *cfg =
         ap_get_module_config(cmd->server->module_config, &lua_module);
 
     cfg->root_path = root;
@@ -956,11 +956,11 @@ command_rec lua_commands[] = {
 
 static void *create_dir_config(apr_pool_t *p, char *dir)
 {
-    apl_dir_cfg *cfg = apr_pcalloc(p, sizeof(apl_dir_cfg));
+    ap_lua_dir_cfg *cfg = apr_pcalloc(p, sizeof(ap_lua_dir_cfg));
     cfg->package_paths = apr_array_make(p, 2, sizeof(char *));
     cfg->package_cpaths = apr_array_make(p, 2, sizeof(char *));
     cfg->mapped_handlers =
-        apr_array_make(p, 1, sizeof(apl_mapped_handler_spec *));
+        apr_array_make(p, 1, sizeof(ap_lua_mapped_handler_spec *));
     cfg->code_cache_style = APL_CODE_CACHE_STAT;
     cfg->pool = p;
     cfg->hooks = apr_hash_make(p);
@@ -971,7 +971,7 @@ static void *create_dir_config(apr_pool_t *p, char *dir)
 
 static int create_request_config(request_rec *r)
 {
-    apl_request_cfg *cfg = apr_palloc(r->pool, sizeof(apl_request_cfg));
+    ap_lua_request_cfg *cfg = apr_palloc(r->pool, sizeof(ap_lua_request_cfg));
     cfg->mapped_request_details = NULL;
     cfg->request_scoped_vms = apr_hash_make(r->pool);
     ap_set_module_config(r->request_config, &lua_module, cfg);
@@ -981,8 +981,8 @@ static int create_request_config(request_rec *r)
 static void *create_server_config(apr_pool_t *p, server_rec *s)
 {
 
-    apl_server_cfg *cfg = apr_pcalloc(p, sizeof(apl_server_cfg));
-    cfg->code_cache = apr_pcalloc(p, sizeof(apl_code_cache));
+    ap_lua_server_cfg *cfg = apr_pcalloc(p, sizeof(ap_lua_server_cfg));
+    cfg->code_cache = apr_pcalloc(p, sizeof(ap_lua_code_cache));
     apr_thread_rwlock_create(&cfg->code_cache->compiled_files_lock, p);
     cfg->code_cache->compiled_files = apr_hash_make(p);
     cfg->vm_reslists = apr_hash_make(p);
@@ -995,7 +995,7 @@ static void *create_server_config(apr_pool_t *p, server_rec *s)
 
 static int lua_request_hook(lua_State *L, request_rec *r)
 {
-    apl_push_request(L, r);
+    ap_lua_push_request(L, r);
     return OK;
 }
 
@@ -1025,12 +1025,12 @@ static void lua_register_hooks(apr_pool_t *p)
     ap_hook_quick_handler(lua_quick_harness, NULL, NULL, APR_HOOK_FIRST);
 
     /* ap_hook_translate_name(lua_alias_munger, NULL, NULL, APR_HOOK_MIDDLE); */
-    ap_hook_translate_name(apl_alias_munger, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_hook_translate_name(lua_alias_munger, NULL, NULL, APR_HOOK_MIDDLE);
 
-    APR_OPTIONAL_HOOK(apl, lua_open, lua_open_hook, NULL, NULL,
+    APR_OPTIONAL_HOOK(ap_lua, lua_open, lua_open_hook, NULL, NULL,
                       APR_HOOK_REALLY_FIRST);
 
-    APR_OPTIONAL_HOOK(apl, lua_request, lua_request_hook, NULL, NULL,
+    APR_OPTIONAL_HOOK(ap_lua, lua_request, lua_request_hook, NULL, NULL,
                       APR_HOOK_REALLY_FIRST);
 }
 
index 14e004c115e07781e3f42cb45b31cb5a6cceb734..ca89c379044a98118a4a2025db2299e1dc6c3f31 100644 (file)
 #include "lauxlib.h"
 #include "lualib.h"
 
+/* Create a set of AP_LUA_DECLARE(type), AP_LUA_DECLARE_NONSTD(type) and 
+ * AP_LUA_DECLARE_DATA with appropriate export and import tags for the platform
+ */
+#if !defined(WIN32)
+#define AP_LUA_DECLARE(type)            type
+#define AP_LUA_DECLARE_NONSTD(type)     type
+#define AP_LUA_DECLARE_DATA
+#elif defined(AP_LUA_DECLARE_STATIC)
+#define AP_LUA_DECLARE(type)            type __stdcall
+#define AP_LUA_DECLARE_NONSTD(type)     type
+#define AP_LUA_DECLARE_DATA
+#elif defined(AP_LUA_DECLARE_EXPORT)
+#define AP_LUA_DECLARE(type)            __declspec(dllexport) type __stdcall
+#define AP_LUA_DECLARE_NONSTD(type)     __declspec(dllexport) type
+#define AP_LUA_DECLARE_DATA             __declspec(dllexport)
+#else
+#define AP_LUA_DECLARE(type)            __declspec(dllimport) type __stdcall
+#define AP_LUA_DECLARE_NONSTD(type)     __declspec(dllimport) type
+#define AP_LUA_DECLARE_DATA             __declspec(dllimport)
+#endif
+
+
 #include "lua_request.h"
 #include "lua_vmprep.h"
 
@@ -57,7 +79,7 @@
 #define lua_unboxpointer(L,i)  (*(void **)(lua_touserdata(L, i)))
 #endif
 
-void apl_rstack_dump(lua_State *L, request_rec *r, const char *msg);
+void ap_lua_rstack_dump(lua_State *L, request_rec *r, const char *msg);
 
 typedef struct
 {
@@ -88,60 +110,42 @@ typedef struct
 
     /* the actual directory being configured */
     char *dir;
-} apl_dir_cfg;
+} ap_lua_dir_cfg;
 
 typedef struct
 {
-    apl_code_cache *code_cache;
+    ap_lua_code_cache *code_cache;
     apr_hash_t *vm_reslists;
     apr_thread_rwlock_t *vm_reslists_lock;
 
     /* value of the LuaRoot directive */
     const char *root_path;
-} apl_server_cfg;
+} ap_lua_server_cfg;
 
 typedef struct
 {
     char *function_name;
-    apl_vm_spec *spec;
+    ap_lua_vm_spec *spec;
 } mapped_request_details;
 
 typedef struct
 {
     mapped_request_details *mapped_request_details;
     apr_hash_t *request_scoped_vms;
-} apl_request_cfg;
+} ap_lua_request_cfg;
 
 typedef struct
 {
     lua_State *L;
     char *function;
-} apl_filter_ctx;
+} ap_lua_filter_ctx;
 
 extern module AP_MODULE_DECLARE_DATA lua_module;
 
-#if !defined(WIN32)
-#define AP_LUA_DECLARE(type)            type
-#define AP_LUA_DECLARE_NONSTD(type)     type
-#define AP_LUA_DECLARE_DATA
-#elif defined(LUA_DECLARE_STATIC)
-#define AP_LUA_DECLARE(type)            type __stdcall
-#define AP_LUA_DECLARE_NONSTD(type)     type
-#define AP_LUA_DECLARE_DATA
-#elif defined(LUA_DECLARE_EXPORT)
-#define AP_LUA_DECLARE(type)            __declspec(dllexport) type __stdcall
-#define AP_LUA_DECLARE_NONSTD(type)     __declspec(dllexport) type
-#define AP_LUA_DECLARE_DATA             __declspec(dllexport)
-#else
-#define AP_LUA_DECLARE(type)            __declspec(dllimport) type __stdcall
-#define AP_LUA_DECLARE_NONSTD(type)     __declspec(dllimport) type
-#define AP_LUA_DECLARE_DATA             __declspec(dllimport)
-#endif
-
-APR_DECLARE_EXTERNAL_HOOK(apl, AP_LUA, int, lua_open,
+APR_DECLARE_EXTERNAL_HOOK(ap_lua, AP_LUA, int, lua_open,
                           (lua_State *L, apr_pool_t *p));
 
-APR_DECLARE_EXTERNAL_HOOK(apl, AP_LUA, int, lua_request,
+APR_DECLARE_EXTERNAL_HOOK(ap_lua, AP_LUA, int, lua_request,
                           (lua_State *L, request_rec *r));
 
 #endif /* !_MOD_LUA_H_ */