wrap putenv... (and for remote_main just strudup - if we leak it doesnt

matter - it will not run for long :) )


SVN revision: 14195
This commit is contained in:
Carsten Haitzler 2005-04-14 09:09:22 +00:00
parent 0671d90de4
commit 72eb2e9bc9
6 changed files with 43 additions and 12 deletions

View File

@ -20,6 +20,9 @@ AM_ENABLE_SHARED
AM_PROG_LIBTOOL
AC_C___ATTRIBUTE__
AC_CHECK_FUNCS(setenv)
AC_CHECK_FUNCS(unsetenv)
MODULE_ARCH="$target_os-$target_cpu"
AC_SUBST(MODULE_ARCH)
AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")

View File

@ -66,8 +66,7 @@ e_intl_language_set(const char *lang)
if (!lang) lang = getenv("LANG");
if (!lang) lang = "en";
_e_intl_language = strdup(lang);
snprintf(buf, sizeof(buf), "LANG=%s", _e_intl_language);
putenv(buf);
e_util_env_set("LANG", _e_intl_language);
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALE_DIR);
textdomain(PACKAGE);

View File

@ -80,7 +80,7 @@ main(int argc, char **argv)
printf("after restart!!!\n");
after_restart = 1;
}
putenv("RESTART=1");
e_util_env_set("RESTART", "1");
e_intl_init();
@ -91,8 +91,7 @@ main(int argc, char **argv)
{
i++;
snprintf(buf, sizeof(buf), "DISPLAY=%s", argv[i]);
putenv(buf);
e_util_env_set("DISPLAY", argv[i]);
}
else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
{
@ -132,16 +131,16 @@ main(int argc, char **argv)
p = strrchr(s, ':');
if (!p)
{
snprintf(buf, sizeof(buf), "DISPLAY=%s:0.0", s);
putenv(buf);
snprintf(buf, sizeof(buf), "%s:0.0", s);
e_util_env_set("DISPLAY", buf);
}
else
{
p = strrchr(p, '.');
if (!p)
{
snprintf(buf, sizeof(buf), "DISPLAY=%s.0", s);
putenv(buf);
snprintf(buf, sizeof(buf), "%s.0", s);
e_util_env_set("DISPLAY", buf);
}
}
}

View File

@ -86,7 +86,7 @@ main(int argc, char **argv)
if (!p)
{
snprintf(buf, sizeof(buf), "DISPLAY=%s:0.0", s);
putenv(buf);
putenv(strdup(buf));
}
else
{
@ -94,7 +94,7 @@ main(int argc, char **argv)
if (!p)
{
snprintf(buf, sizeof(buf), "DISPLAY=%s.0", s);
putenv(buf);
putenv(strdup(buf));
}
}
}

View File

@ -49,6 +49,35 @@ e_util_wakeup(void)
_e_util_dummy_timer = ecore_timer_add(0.0, _e_util_wakeup_cb, NULL);
}
void
e_util_env_set(const char *var, const char *val)
{
char buf[4096];
if (val)
{
#ifdef HAVE_SETENV
setenv(var, val, 1);
#else
char buf[8192];
snprintf(buf, sizeof(buf), "%s=%s", var, val);
if (getenv(var))
putenv(buf);
else
putenv(strdup(buf));
#endif
}
else
{
#ifdef HAVE_UNSETENV
unsetenv(var);
#else
if (getenv(var)) putenv(var);
#endif
}
}
/* local subsystem functions */
static void
_e_util_container_fake_mouse_up_cb(void *data)

View File

@ -9,6 +9,7 @@
EAPI void e_util_container_fake_mouse_up_later(E_Container *con, int button);
EAPI void e_util_container_fake_mouse_up_all_later(E_Container *con);
EAPI void e_util_wakeup(void);
EAPI void e_util_env_set(const char *var, const char *val);
#endif
#endif