#include "apr.h"
#include "apr_tables.h"
-#include "lua.h"
-#include "lauxlib.h"
-#include "lualib.h"
+#include "mod_lua.h"
#include "lua_apr.h"
/**
}
-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");
};
-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);
#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_ */
#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;
}
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;
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;
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;
}*/
{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);
#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_ */
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);
* 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");
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);
/* 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;
/* 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);
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) {
/* 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);
/* 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);
}
{
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);
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;
}
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);
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);
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);
}
-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);
}
-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");
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");
* 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
/* 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");
#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;
*/
const char *bytecode;
apr_size_t bytecode_len;
-} apl_vm_spec;
+} ap_lua_vm_spec;
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);
/*
* @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);
#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)
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)
*/
static int lua_handler(request_rec *r)
{
- apl_dir_cfg *dcfg;
+ ap_lua_dir_cfg *dcfg;
if (strcmp(r->handler, "lua-script")) {
return DECLINED;
}
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;
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,
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);
}
/**
* 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,
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);
{
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;
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,
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");
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.
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;
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;
}
const char *line)
{
const char *function;
- apl_mapped_handler_spec *spec;
+ ap_lua_mapped_handler_spec *spec;
if (line && line[0] == '>') {
function = NULL;
}
}
- spec = apr_pcalloc(cmd->pool, sizeof(apl_mapped_handler_spec));
+ spec = apr_pcalloc(cmd->pool, sizeof(ap_lua_mapped_handler_spec));
{
cr_ctx ctx;
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;
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;
}
{
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,
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);
}
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);
}
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;
}
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;
}
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",
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;
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);
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);
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);
static int lua_request_hook(lua_State *L, request_rec *r)
{
- apl_push_request(L, r);
+ ap_lua_push_request(L, r);
return OK;
}
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);
}
#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"
#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
{
/* 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_ */