static Eina_Bool dont_use_xkb_cache = EINA_FALSE;
static Eina_Bool use_cache_keymap = EINA_FALSE;
+/* default XKB values from enviroment variables */
+static char *_env_e_default_xkb_rules = NULL;
+static char *_env_e_default_xkb_model = NULL;
+static char *_env_e_default_xkb_layout = NULL;
+static char *_env_e_default_xkb_variant = NULL;
+static char *_env_e_default_xkb_opts = NULL;
+
static void
_e_comp_wl_input_update_seat_caps(struct wl_client *wc)
{
_e_comp_wl_input_keymap_fd_get(off_t size)
{
int fd = 0, blen = 0, len = 0;
- const char *path;
+ char *path;
char tmp[PATH_MAX] = {0, };
long flags;
blen = sizeof(tmp) - 20;
- if (!(path = getenv("XDG_RUNTIME_DIR"))) return -1;
+ path = e_util_env_get("XDG_RUNTIME_DIR");
+ if (!path) return -1;
len = strlen(path);
if (len < blen)
{
strncpy(tmp, path, len + 1);
strncat(tmp, "/e-wl-keymap-XXXXXX", 19);
+ E_FREE(path);
}
else
{
+ E_FREE(path);
return -1;
}
E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = ecore_event_type_new();
+ /* get string values from environment variables */
+ _env_e_default_xkb_rules = e_util_env_get("E_DEFAULT_XKB_RULES" );
+ _env_e_default_xkb_model = e_util_env_get("E_DEFAULT_XKB_MODEL" );
+ _env_e_default_xkb_layout = e_util_env_get("E_DEFAULT_XKB_LAYOUT" );
+ _env_e_default_xkb_variant = e_util_env_get("E_DEFAULT_XKB_VARIANT");
+ _env_e_default_xkb_opts = e_util_env_get("E_DEFAULT_XKB_OPTIONS");
+
return EINA_TRUE;
}
{
struct wl_resource *res;
+ /* free environment variable string */
+ E_FREE(_env_e_default_xkb_rules );
+ E_FREE(_env_e_default_xkb_model );
+ E_FREE(_env_e_default_xkb_layout );
+ E_FREE(_env_e_default_xkb_variant);
+ E_FREE(_env_e_default_xkb_opts );
+
/* destroy pointer resources */
EINA_LIST_FREE(e_comp_wl->ptr.resources, res)
wl_resource_destroy(res);
E_API const char*
e_comp_wl_input_keymap_default_rules_get(void)
{
- const char *rules;
if (e_config->xkb.default_rmlvo.rules)
return e_config->xkb.default_rmlvo.rules;
- else
- {
- rules = getenv("E_DEFAULT_XKB_RULES");
- if (rules) return rules;
- else return "evdev";
- }
+
+ if (_env_e_default_xkb_rules)
+ return _env_e_default_xkb_rules;
+
+ return "evdev";
}
E_API const char*
e_comp_wl_input_keymap_default_model_get(void)
{
- const char *model;
if (e_config->xkb.default_rmlvo.model)
return e_config->xkb.default_rmlvo.model;
- else
- {
- model = getenv("E_DEFAULT_XKB_MODEL");
- if (model) return model;
- else return "pc105";
- }
+
+ if (_env_e_default_xkb_model)
+ return _env_e_default_xkb_model;
+
+ return "pc105";
}
E_API const char*
e_comp_wl_input_keymap_default_layout_get(void)
{
- const char *layout;
if (e_config->xkb.default_rmlvo.layout)
return e_config->xkb.default_rmlvo.layout;
- else
- {
- layout = getenv("E_DEFAULT_XKB_LAYOUT");
- if (layout) return layout;
- else return "us";
- }
+
+ if (_env_e_default_xkb_layout)
+ return _env_e_default_xkb_layout;
+
+ return "us";
}
E_API const char*
e_comp_wl_input_keymap_default_variant_get(void)
{
- const char *variant;
if (e_config->xkb.default_rmlvo.variant)
return e_config->xkb.default_rmlvo.variant;
- else
- {
- variant = getenv("E_DEFAULT_XKB_VARIANT");
- if (variant) return variant;
- else return NULL;
- }
+
+ if (_env_e_default_xkb_variant)
+ return _env_e_default_xkb_variant;
+
+ return NULL;
}
E_API const char*
e_comp_wl_input_keymap_default_options_get(void)
{
- const char *options;
if (e_config->xkb.default_rmlvo.options)
return e_config->xkb.default_rmlvo.options;
- else
- {
- options = getenv("E_DEFAULT_XKB_OPTIONS");
- if (options) return options;
- else return NULL;
- }
+
+ if (_env_e_default_xkb_opts)
+ return _env_e_default_xkb_opts;
+
+ return NULL;
}
E_API void
E_Client *ec;
char name[1024];
char dest_dir[1024];
- const char *dest_path, *run_dir, *dupname, *dupdir;
+ const char *dest_path, *dupname, *dupdir;
+ char *run_dir;
if (!(td = data)) return;
if (!ec) return;
if (ecore_thread_check(th)) return;
- if (!(run_dir = getenv("XDG_RUNTIME_DIR")))
- return;
+ run_dir = e_util_env_get("XDG_RUNTIME_DIR");
+ if (!run_dir) return;
snprintf(dest_dir, sizeof(dest_dir), "%s/.e-img", run_dir);
+ E_FREE(run_dir);
+
if (!ecore_file_exists(dest_dir))
ecore_file_mkdir(dest_dir);
dupdir = strdup(dest_dir);
_e_comp_wl_remote_surface_dummy_fd_get(void)
{
int fd = 0, blen = 0, len = 0;
- const char *path;
+ char *path;
char tmp[PATH_MAX];
blen = sizeof(tmp) - 1;
- if (!(path = getenv("XDG_RUNTIME_DIR")))
- return -1;
+ path = e_util_env_get("XDG_RUNTIME_DIR");
+ if (!path) return -1;
len = strlen(path);
if (len < blen)
{
strncpy(tmp, path, len + 1);
strncat(tmp, "/enlightenment_rsm_dummy_fdXXXXXX", 34);
+ E_FREE(path);
}
else
- return -1;
+ {
+ E_FREE(path);
+ return -1;
+ }
if ((fd = mkstemp(tmp)) < 0)
return -1;
if (getenv("E_CONF_RO")) e_config_save_block_set(1);
/* if environment var set - use this profile name */
- _e_config_profile = eina_stringshare_add(getenv("E_CONF_PROFILE"));
+ char *s = e_util_env_get("E_CONF_PROFILE");
+ if (s)
+ {
+ _e_config_profile = eina_stringshare_add(s);
+ E_FREE(s);
+ }
_e_config_edd_init(EINA_FALSE);
static Eina_Bool
_e_info_server_dbus_init(void *data EINA_UNUSED)
{
+ char *s = NULL;
+
if (e_info_server.conn) return ECORE_CALLBACK_CANCEL;
if (!e_info_server.conn)
E_EVENT_INFO_ROTATION_MESSAGE = ecore_event_type_new();
e_info_protocol_init();
- e_info_server_protocol_rule_path_init(getenv("E_INFO_RULE_FILE"));
- e_info_server_protocol_trace_path_init(getenv("E_INFO_TRACE_FILE"));
+
+ s = e_util_env_get("E_INFO_RULE_FILE");
+ e_info_server_protocol_rule_path_init(s);
+ E_FREE(s);
+
+ s = e_util_env_get("E_INFO_TRACE_FILE");
+ e_info_server_protocol_trace_path_init(s);
+ E_FREE(s);
+
e_main_hook_call(E_MAIN_HOOK_E_INFO_READY);
return ECORE_CALLBACK_CANCEL;
}
/* set libinput log priority */
- if ((env = getenv(E_INPUT_ENV_LIBINPUT_LOG_DISABLE)) && (atoi(env) == 1))
+ env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
+ if ((env) && (atoi(env) == 1))
libinput_log_set_handler(input->libinput, NULL);
- else if ((env = getenv(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG)) && (atoi(env) == 1))
- libinput_log_set_handler(input->libinput, e_input_device_libinput_log_handler);
+ else
+ {
+ env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
+ if ((env) && (atoi(env) == 1))
+ libinput_log_set_handler(input->libinput,
+ e_input_device_libinput_log_handler);
+ }
+ E_FREE(env);
libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
struct libinput_device *device;
int devices_num = 0;
char *env;
- Eina_Stringshare *path;
/* check for valid device */
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
- if ((env = getenv("PATH_DEVICES_NUM")))
- devices_num = atoi(env);
+ env = e_util_env_get("PATH_DEVICES_NUM");
+ if (env)
+ {
+ devices_num = atoi(env);
+ E_FREE(env);
+ }
+
if (devices_num <= 0 || devices_num >= INT_MAX)
{
return EINA_TRUE;
}
/* set libinput log priority */
- if ((env = getenv(E_INPUT_ENV_LIBINPUT_LOG_DISABLE)) && (atoi(env) == 1))
+ env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_DISABLE);
+ if ((env) && (atoi(env) == 1))
libinput_log_set_handler(input->libinput, NULL);
- else if ((env = getenv(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG)) && (atoi(env) == 1))
- libinput_log_set_handler(input->libinput, e_input_device_libinput_log_handler);
+ else
+ {
+ env = e_util_env_get(E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG);
+ if ((env) && (atoi(env) == 1))
+ libinput_log_set_handler(input->libinput,
+ e_input_device_libinput_log_handler);
+ }
+ E_FREE(env);
libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
{
char buf[1024] = "PATH_DEVICE_";
eina_convert_itoa(i + 1, buf + 12);
- env = getenv(buf);
+ env = e_util_env_get(buf);
if (env)
{
- path = eina_stringshare_add(env);
- device = libinput_path_add_device(input->libinput, path);
+ device = libinput_path_add_device(input->libinput, env);
if (!device)
- ERR("Failed to initialized device %s", path);
+ ERR("Failed to initialized device %s", env);
else
- INF("libinput_path created input device %s", path);
+ INF("libinput_path created input device %s", env);
+ E_FREE(env);
}
}
static void
_xdg_data_dirs_augment(void)
{
- const char *s;
+ char *s;
const char *p = e_prefix_get();
char newpath[4096], buf[4096];
if (!p) return;
- s = getenv("XDG_DATA_DIRS");
+ s = e_util_env_get("XDG_DATA_DIRS");
if (s)
{
Eina_Bool pfxdata, pfx;
s);
e_util_env_set("XDG_DATA_DIRS", buf);
}
+ E_FREE(s);
}
else
{
e_util_env_set("XDG_DATA_DIRS", buf);
}
- s = getenv("XDG_CONFIG_DIRS");
+ s = e_util_env_get("XDG_CONFIG_DIRS");
snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
if (s)
{
snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
e_util_env_set("XDG_CONFIG_DIRS", buf);
}
+ E_FREE(s);
}
else
{
e_util_env_set("XDG_CONFIG_DIRS", buf);
}
- if (!getenv("XDG_RUNTIME_DIR"))
+ s = e_util_env_get("XDG_RUNTIME_DIR");
+ if (s)
+ E_FREE(s);
+ else
{
const char *dir;
}
/* set menu prefix so we get our e menu */
- if (!getenv("XDG_MENU_PREFIX"))
- {
- e_util_env_set("XDG_MENU_PREFIX", "e-");
- }
+ s = e_util_env_get("XDG_MENU_PREFIX");
+ if (s)
+ E_FREE(s);
+ else
+ e_util_env_set("XDG_MENU_PREFIX", "e-");
}
static Eina_Bool
{
Eina_Bool safe_mode = EINA_FALSE;
double t = 0.0, tstart = 0.0;
- char *s = NULL, buff[32];
+ char *s = NULL, *s1 = NULL, buff[32];
struct sigaction action;
#ifdef __linux__
/* Wayland shm sets up a sigbus handler for catching invalid shm region */
/* access. If we setup our sigbus handler here, then the wl-shm sigbus */
/* handler will not function properly */
- if (!getenv("NOTIFY_SOCKET"))
+ s = e_util_env_get("NOTIFY_SOCKET");
+ if (s)
+ E_FREE(s);
+ else
{
TSB("Signal Trap");
action.sa_sigaction = e_sigseg_act;
}
t = ecore_time_unix_get();
- s = getenv("E_START_TIME");
- if ((s) && (!getenv("E_RESTART_OK")))
+ s = e_util_env_get("E_START_TIME");
+ if (s)
{
- tstart = atof(s);
- if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
+ s1 = e_util_env_get("E_RESTART_OK");
+ if (s1)
+ E_FREE(s1); /* do nothing... */
+ else
+ {
+ /* enable safe mode
+ * 1. E_RESTART_OK is not defined.
+ * 2. the diff time between this and previous start is less than 5 seconds.
+ */
+ tstart = atof(s);
+ if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
+ }
+ E_FREE(s);
}
+
+ /* save start time to environment variable to calculate
+ * diff time at the next restart
+ */
tstart = t;
snprintf(buff, sizeof(buff), "%1.1f", tstart);
e_util_env_set("E_START_TIME", buff);
- if (getenv("E_START_MTRACK"))
- e_util_env_set("MTRACK", NULL);
+ s = e_util_env_get("E_START_MTRACK");
+ if (s)
+ {
+ e_util_env_set("MTRACK", NULL);
+ E_FREE(s);
+ }
TSB("Eina Init");
if (!eina_init())
{
/*** Initialize E Subsystems We Need ***/
+ TSB("E User Init");
+ if (!e_user_init())
+ {
+ e_error_message_show(_("Enlightenment cannot set up user home path\n"));
+ goto failed;
+ }
+ TSE("E User Init Done");
+ _e_main_shutdown_push(e_user_shutdown);
+
TSB("E Directories Init");
/* setup directories we will be using for configurations storage etc. */
if (!_e_main_dirs_init())
if (restart)
{
e_util_env_set("E_RESTART_OK", "1");
- if (getenv("E_START_MTRACK"))
- e_util_env_set("MTRACK", "track");
+ s = e_util_env_get("E_START_MTRACK");
+ if (s)
+ {
+ e_util_env_set("MTRACK", "track");
+ E_FREE(s);
+ }
ecore_app_restart();
}
{
int i = 0;
char buf[PATH_MAX];
- const char *dir;
+ char *dir;
printf("E: Begin Shutdown Procedure!\n");
if (_idle_after) ecore_idle_enterer_del(_idle_after);
_idle_after = NULL;
- dir = getenv("XDG_RUNTIME_DIR");
+ dir = e_util_env_get("XDG_RUNTIME_DIR");
if (dir)
{
char buf_env[PATH_MAX];
snprintf(buf_env, sizeof(buf_env), "%s", dir);
snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
+ E_FREE(dir);
}
for (i = (_e_main_lvl - 1); i >= 0; i--)
(*_e_main_shutdown_func[i])();
if (!mod_src_path)
{
- const char *src_path = getenv("E_MODULE_SRC_PATH");
+ char *src_path = e_util_env_get("E_MODULE_SRC_PATH");
if (src_path)
{
char buf_p[PATH_MAX];
snprintf(buf_p, sizeof(buf_p), "%s", src_path);
mod_src_path = eina_stringshare_add((const char*)buf_p);
+ E_FREE(src_path);
}
}
if (!mod_src_path)
{
- const char *src_path = getenv("E_MODULE_SRC_PATH");
+ char *src_path = e_util_env_get("E_MODULE_SRC_PATH");
if (src_path)
{
char buf_p[PATH_MAX];
snprintf(buf_p, sizeof(buf_p), "%s", src_path);
mod_src_path = eina_stringshare_add((const char*)buf_p);
+ E_FREE(src_path);
}
}
if (mod_src_path)
e_obj_hash_check = EINA_FALSE;
- val = getenv("E_OBJECT_HASH_CHECK");
- if ((val) && (!strcmp(val, "1")))
+ val = e_util_env_get("E_OBJECT_HASH_CHECK");
+ if (!val) return;
+ if (!strcmp(val, "1"))
{
e_obj_hash_check = EINA_TRUE;
e_obj_hash = eina_hash_pointer_new(NULL);
}
+
+ E_FREE(val);
}
E_API void
#include "e.h"
-static const char *_e_user_homedir = NULL;
+static char *_e_user_homedir = NULL;
static size_t _e_user_homedir_len = 0;
/* externally accessible functions */
-E_API const char *
-e_user_homedir_get(void)
+EINTERN int
+e_user_init(void)
{
char *d;
- if (_e_user_homedir)
- return _e_user_homedir;
-
- _e_user_homedir = d = getenv("HOME");
+ /* e_user_shutdown will free for the d string */
+ _e_user_homedir = d = e_util_env_get("HOME");
if (!_e_user_homedir)
{
_e_user_homedir = "/tmp";
_e_user_homedir_len = sizeof("/tmp") - 1;
- return _e_user_homedir;
+ return 1;
}
_e_user_homedir_len = strlen(_e_user_homedir);
_e_user_homedir_len--;
d[_e_user_homedir_len] = '\0';
}
+
+ return 1;
+}
+
+EINTERN int
+e_user_shutdown(void)
+{
+ E_FREE(_e_user_homedir);
+ _e_user_homedir_len = 0;
+ return 1;
+}
+
+E_API const char *
+e_user_homedir_get(void)
+{
return _e_user_homedir;
}
if (!dir[0])
{
- char *d;
-
- if ((d = getenv("E_HOME")))
+ char *d = e_util_env_get("E_HOME");
+ if (d)
{
snprintf(dir, sizeof(dir), "%s/e", d);
_e_user_dir_len = strlen(dir);
+ E_FREE(d);
}
else
{
#ifdef DOXDG
- if ((d = getenv("XDG_CONFIG_HOME")))
+ d = e_util_env_get("XDG_CONFIG_HOME");
+ if (d)
{
snprintf(dir, sizeof(dir), "%s/e", d);
_e_user_dir_len = strlen(dir);
+ E_FREE(d);
}
else
#endif
#ifndef E_USER_H
#define E_USER_H
+EINTERN int e_user_init(void);
+EINTERN int e_user_shutdown(void);
+
E_API const char *e_user_homedir_get(void);
E_API size_t e_user_homedir_concat_len(char *dst, size_t size, const char *path, size_t path_len);
E_API size_t e_user_homedir_concat(char *dst, size_t size, const char *path);