diff options
author | Daniel Kolesa <d.kolesa@samsung.com> | 2015-04-10 11:42:09 +0100 |
---|---|---|
committer | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2015-05-06 15:05:19 +0100 |
commit | 5f6109bc4776084b093662215146f7c16247d62f (patch) | |
tree | ab763e63c97a31f5d621e102f64ee865a5edcb69 /src/bin/elua | |
parent | c1cfcc35b91c59980861caa96abfb374b8a7efcb (diff) | |
download | efl-5f6109bc4776084b093662215146f7c16247d62f.tar.gz |
elua: new API elua_state_dirs_fill + utilize
Diffstat (limited to 'src/bin/elua')
-rw-r--r-- | src/bin/elua/main.c | 87 |
1 files changed, 36 insertions, 51 deletions
diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c index 38cf5cea67..ed83b7027b 100644 --- a/src/bin/elua/main.c +++ b/src/bin/elua/main.c @@ -288,8 +288,7 @@ elua_main(lua_State *L) hasexec = EINA_FALSE; Eina_List *largs = NULL, *l = NULL; Arg_Data *data = NULL; - char *coredir = NULL, *moddir = NULL, *appsdir = NULL; - char coredirbuf[PATH_MAX], moddirbuf[PATH_MAX], appsdirbuf[PATH_MAX]; + const char *coredir = NULL, *moddir = NULL, *appsdir = NULL; char modfile[PATH_MAX]; int ch; @@ -306,29 +305,31 @@ elua_main(lua_State *L) { switch (ch) { - case 'h': - elua_print_help(elua_progname, stdout); - return 0; - case 'C': - coredir = optarg; + case 'h': + elua_print_help(elua_progname, stdout); + return 0; + case 'C': + coredir = optarg; + break; + case 'M': + moddir = optarg; + break; + case 'A': + appsdir = optarg; + break; + case 'e': + case 'l': + case 'I': + { + Arg_Data *v = malloc(sizeof(Arg_Data)); + v->type = (ch == 'e') ? ARG_CODE : ((ch == 'l') + ? ARG_LIBRARY : ARG_LIBDIR); + v->value = optarg; + largs = eina_list_append(largs, v); break; - case 'M': - moddir = optarg; - break; - case 'A': - appsdir = optarg; - break; - case 'e': - case 'l': - case 'I': - { - Arg_Data *v = malloc(sizeof(Arg_Data)); - v->type = (ch == 'e') ? ARG_CODE : ((ch == 'l') - ? ARG_LIBRARY : ARG_LIBDIR); - v->value = optarg; - largs = eina_list_append(largs, v); - break; - } + } + case 'E': + noenv = EINA_TRUE; } } @@ -347,36 +348,20 @@ elua_main(lua_State *L) return 0; } - if (!coredir) - { - if (noenv || !(coredir = getenv("ELUA_CORE_DIR")) || !coredir[0]) - { - coredir = coredirbuf; - snprintf(coredirbuf, sizeof(coredirbuf), "%s/core", - eina_prefix_data_get(elua_prefix)); - } - } - if (!moddir) - { - if (noenv || !(moddir = getenv("ELUA_MODULES_DIR")) || !moddir[0]) - { - moddir = moddirbuf; - snprintf(moddirbuf, sizeof(moddirbuf), "%s/modules", - eina_prefix_data_get(elua_prefix)); - } - } - if (!appsdir) + 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) { - if (noenv || !(appsdir = getenv("ELUA_APPS_DIR")) || !appsdir[0]) - { - appsdir = appsdirbuf; - snprintf(appsdirbuf, sizeof(appsdirbuf), "%s/apps", - eina_prefix_data_get(elua_prefix)); - } + ERR("could not set one or more script directories"); + m->status = 1; + return 0; } - elua_state_dirs_set(es, coredir, moddir, appsdir); - snprintf(modfile, sizeof(modfile), "%s/module.lua", coredir); if (elua_report_error(es, elua_progname, elua_io_loadfile(es, modfile))) { |