int status;
};
-const luaL_reg cutillib[] =
-{
- { "init_module", elua_module_init },
- { "popenv" , elua_io_popen },
- { NULL , NULL }
-};
-
static void
elua_print_help(const char *pname, FILE *stream)
{
hasexec = EINA_FALSE;
Eina_List *largs = NULL;
const char *coredir = NULL, *moddir = NULL, *appsdir = NULL;
- char modfile[PATH_MAX];
char *data = NULL;
int ch;
elua_state_dirs_set(es, coredir, moddir, appsdir);
elua_state_dirs_fill(es, noenv);
- coredir = elua_state_core_dir_get(es);
- moddir = elua_state_mod_dir_get(es);
- appsdir = elua_state_apps_dir_get(es);
-
- if (!coredir || !moddir || !appsdir)
- {
- ERR("could not set one or more script directories");
- goto error;
- }
-
- snprintf(modfile, sizeof(modfile), "%s/module.lua", coredir);
- if (elua_report_error(es, elua_state_prog_name_get(es),
- elua_io_loadfile(es, modfile)))
- goto error;
- lua_pushcfunction(L, elua_module_system_init);
- lua_createtable(L, 0, 0);
- luaL_register(L, NULL, cutillib);
- lua_call(L, 2, 0);
-
- if (!elua_state_setup_i18n(es))
+ if (!elua_state_setup_modules(es) || !elua_state_setup_i18n(es))
goto error;
elua_io_register(es);
EINA_SAFETY_ON_NULL_RETURN_VAL(es, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE);
snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir);
- if (elua_report_error(es, elua_state_prog_name_get(es),
- elua_io_loadfile(es, buf)))
+ if (elua_report_error(es, es->progname, elua_io_loadfile(es, buf)))
return EINA_FALSE;
lua_createtable(es->luastate, 0, 0);
luaL_register(es->luastate, NULL, gettextlib);
return EINA_TRUE;
}
+const luaL_reg _elua_cutillib[] =
+{
+ { "init_module", elua_module_init },
+ { "popenv" , elua_io_popen },
+ { NULL , NULL }
+};
+
+EAPI Eina_Bool
+elua_state_setup_modules(const Elua_State *es)
+{
+ char buf[PATH_MAX];
+ EINA_SAFETY_ON_NULL_RETURN_VAL(es, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE);
+ snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir);
+ if (elua_report_error(es, es->progname, elua_io_loadfile(es, buf)))
+ return EINA_FALSE;
+ lua_pushcfunction(es->luastate, elua_module_system_init);
+ lua_createtable(es->luastate, 0, 0);
+ luaL_register(es->luastate, NULL, _elua_cutillib);
+ lua_call(es->luastate, 2, 0);
+ return EINA_TRUE;
+}
+
EAPI int
elua_module_init(lua_State *L)
{