summaryrefslogtreecommitdiff
path: root/src/lib/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-10 11:42:09 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:19 +0100
commit5f6109bc4776084b093662215146f7c16247d62f (patch)
treeab763e63c97a31f5d621e102f64ee865a5edcb69 /src/lib/elua
parentc1cfcc35b91c59980861caa96abfb374b8a7efcb (diff)
elua: new API elua_state_dirs_fill + utilize
Diffstat (limited to '')
-rw-r--r--src/lib/elua/Elua.h1
-rw-r--r--src/lib/elua/elua.c38
2 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/elua/Elua.h b/src/lib/elua/Elua.h
index b72ada52c7..a05b82433c 100644
--- a/src/lib/elua/Elua.h
+++ b/src/lib/elua/Elua.h
@@ -72,6 +72,7 @@ EAPI void elua_state_free(Elua_State *es);
72 72
73EAPI void elua_state_dirs_set(Elua_State *es, const char *core, 73EAPI void elua_state_dirs_set(Elua_State *es, const char *core,
74 const char *mods, const char *apps); 74 const char *mods, const char *apps);
75EAPI void elua_state_dirs_fill(Elua_State *es, Eina_Bool ignore_env);
75 76
76EAPI Eina_Stringshare *elua_state_core_dir_get(const Elua_State *es); 77EAPI Eina_Stringshare *elua_state_core_dir_get(const Elua_State *es);
77EAPI Eina_Stringshare *elua_state_mod_dir_get(const Elua_State *es); 78EAPI Eina_Stringshare *elua_state_mod_dir_get(const Elua_State *es);
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index 3ab2448427..ae5da0e012 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -109,6 +109,44 @@ elua_state_dirs_set(Elua_State *es, const char *core, const char *mods,
109 if (apps) es->appsdir = eina_stringshare_add(apps); 109 if (apps) es->appsdir = eina_stringshare_add(apps);
110} 110}
111 111
112EAPI void
113elua_state_dirs_fill(Elua_State *es, Eina_Bool ignore_env)
114{
115 const char *coredir = NULL, *moddir = NULL, *appsdir = NULL;
116 char coredirbuf[PATH_MAX], moddirbuf[PATH_MAX], appsdirbuf[PATH_MAX];
117 EINA_SAFETY_ON_NULL_RETURN(es);
118 if (!(coredir = es->coredir))
119 {
120 if (ignore_env || !(coredir = getenv("ELUA_CORE_DIR")) || !coredir[0])
121 {
122 coredir = coredirbuf;
123 snprintf(coredirbuf, sizeof(coredirbuf), "%s/core",
124 eina_prefix_data_get(_elua_pfx));
125 }
126 if (coredir) es->coredir = eina_stringshare_add(coredir);
127 }
128 if (!(moddir = es->moddir))
129 {
130 if (ignore_env || !(moddir = getenv("ELUA_MODULES_DIR")) || !moddir[0])
131 {
132 moddir = moddirbuf;
133 snprintf(moddirbuf, sizeof(moddirbuf), "%s/modules",
134 eina_prefix_data_get(_elua_pfx));
135 }
136 if (moddir) es->moddir = eina_stringshare_add(moddir);
137 }
138 if (!(appsdir = es->appsdir))
139 {
140 if (ignore_env || !(appsdir = getenv("ELUA_APPS_DIR")) || !appsdir[0])
141 {
142 appsdir = appsdirbuf;
143 snprintf(appsdirbuf, sizeof(appsdirbuf), "%s/apps",
144 eina_prefix_data_get(_elua_pfx));
145 }
146 if (appsdir) es->appsdir = eina_stringshare_add(appsdir);
147 }
148}
149
112EAPI Eina_Stringshare * 150EAPI Eina_Stringshare *
113elua_state_core_dir_get(const Elua_State *es) 151elua_state_core_dir_get(const Elua_State *es)
114{ 152{