return APR_SUCCESS;
}
+/*
+ munge_path(L,
+ "path",
+ "?.lua",
+ "./?.lua",
+ lifecycle_pool,
+ spec->package_paths,
+ spec->file);
+*/
+/**
+ * field -> "path" or "cpath"
+ * sub_pat -> "?.lua"
+ * rep_pat -> "./?.lua"
+ * pool -> lifecycle pool for allocations
+ * paths -> things to add
+ * file -> ???
+ */
static void munge_path(lua_State *L,
const char *field,
const char *sub_pat,
lua_getglobal(L, "package");
lua_getfield(L, -1, field);
+
current = lua_tostring(L, -1);
+
parent_dir = ap_make_dirstr_parent(pool, file);
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);
modified = lua_tostring(L, -1);
+
+
lua_pop(L, 2);
- part = apr_pstrcat(pool, modified, apr_array_pstrcat(pool, paths, ';'),
+ part = apr_pstrcat(pool, modified, ";", apr_array_pstrcat(pool, paths, ';'),
NULL);
+
lua_pushstring(L, part);
lua_setfield(L, -2, field);
lua_pop(L, 1); /* pop "package" off the stack */
#endif
luaL_openlibs(L);
if (spec->package_paths) {
- munge_path(L, "path", "?.lua", "./?.lua", lifecycle_pool,
- spec->package_paths, spec->file);
+ munge_path(L,
+ "path", "?.lua", "./?.lua",
+ lifecycle_pool,
+ spec->package_paths,
+ spec->file);
}
if (spec->package_cpaths) {
munge_path(L, "cpath", "?.so", "./?.so", lifecycle_pool,
-static const char *register_package_helper(cmd_parms *cmd, const char *arg,
+static const char *register_package_helper(cmd_parms *cmd,
+ const char *arg,
apr_array_header_t *dir_array)
{
apr_status_t rv;
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,
- APR_FILEPATH_NOTRELATIVE, cmd->pool);
+ rv = apr_filepath_merge(&fixed_filename,
+ server_cfg->root_path,
+ arg,
+ APR_FILEPATH_NOTRELATIVE,
+ cmd->pool);
+
if (rv != APR_SUCCESS) {
return apr_psprintf(cmd->pool,
"Unable to build full path to file, %s", arg);