You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
331 lines
8.0 KiB
331 lines
8.0 KiB
13 years ago
|
#include "Efreet.h"
|
||
12 years ago
|
#include <Ecore_File.h>
|
||
13 years ago
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
12 years ago
|
int
|
||
|
ef_cb_efreet_data_home(void)
|
||
|
{
|
||
|
const char *tmp;
|
||
|
int ret = 1;
|
||
|
|
||
|
efreet_shutdown();
|
||
|
setenv("XDG_DATA_HOME", "/var/tmp", 1);
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_data_home_get();
|
||
|
if (strcmp(tmp, "/var/tmp"))
|
||
|
{
|
||
|
printf("efreet_data_home_get() returned incorrect "
|
||
|
"value (%s) on XDG_DATA_HOME=/var/tmp\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
/* reset efreet here so we can set a new home dir */
|
||
|
efreet_shutdown();
|
||
|
unsetenv("XDG_DATA_HOME");
|
||
|
setenv("HOME", "/home/tmp", 1);
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_data_home_get();
|
||
|
if (strcmp(tmp, "/home/tmp/.local/share"))
|
||
|
{
|
||
|
printf("efreet_data_home_get() returned incorrect "
|
||
|
"value (%s) on blank XDG_DATA_HOME\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
/* reset efreet here so we can set a new home dir */
|
||
|
efreet_shutdown();
|
||
|
unsetenv("XDG_DATA_HOME");
|
||
|
unsetenv("HOME");
|
||
|
#ifdef _WIN32
|
||
|
unsetenv("USERPROFILE");
|
||
|
#endif
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_data_home_get();
|
||
|
if (strcmp(tmp, "/tmp/.local/share"))
|
||
|
{
|
||
|
printf("efreet_data_home_get() returned incorrect "
|
||
|
"value (%s) on blank XDG_DATA_HOME and blank HOME\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
13 years ago
|
int
|
||
|
ef_cb_efreet_config_home(void)
|
||
|
{
|
||
|
const char *tmp;
|
||
|
int ret = 1;
|
||
|
|
||
|
efreet_shutdown();
|
||
|
setenv("XDG_CONFIG_HOME", "/var/tmp", 1);
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_config_home_get();
|
||
|
if (strcmp(tmp, "/var/tmp"))
|
||
|
{
|
||
|
printf("efreet_config_home_get() returned incorrect "
|
||
|
"value (%s) on XDG_CONFIG_HOME=/var/tmp\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
/* reset efreet here so we can set a new home dir */
|
||
|
efreet_shutdown();
|
||
|
unsetenv("XDG_CONFIG_HOME");
|
||
|
setenv("HOME", "/home/tmp", 1);
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_config_home_get();
|
||
|
if (strcmp(tmp, "/home/tmp/.config"))
|
||
|
{
|
||
|
printf("efreet_config_home_get() returned incorrect "
|
||
|
"value (%s) on blank XDG_CONFIG_HOME\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
/* reset efreet here so we can set a new home dir */
|
||
|
efreet_shutdown();
|
||
|
unsetenv("XDG_CONFIG_HOME");
|
||
|
unsetenv("HOME");
|
||
|
#ifdef _WIN32
|
||
|
unsetenv("USERPROFILE");
|
||
|
#endif
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_config_home_get();
|
||
|
if (strcmp(tmp, "/tmp/.config"))
|
||
|
{
|
||
|
printf("efreet_config_home_get() returned incorrect "
|
||
|
"value (%s) on blank XDG_CONFIG_HOME and blank HOME\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
int
|
||
|
ef_cb_efreet_cache_home(void)
|
||
|
{
|
||
|
const char *tmp;
|
||
|
int ret = 1;
|
||
|
|
||
|
efreet_shutdown();
|
||
|
setenv("XDG_CACHE_HOME", "/var/tmp", 1);
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_cache_home_get();
|
||
|
if (strcmp(tmp, "/var/tmp"))
|
||
|
{
|
||
|
printf("efreet_cache_home_get() returned incorrect "
|
||
|
"value (%s) on XDG_CACHE_HOME=/var/tmp\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
/* reset efreet here so we can set a new home dir */
|
||
|
efreet_shutdown();
|
||
|
unsetenv("XDG_CACHE_HOME");
|
||
|
setenv("HOME", "/home/tmp", 1);
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_cache_home_get();
|
||
|
if (strcmp(tmp, "/home/tmp/.cache"))
|
||
|
{
|
||
|
printf("efreet_cache_home_get() returned incorrect "
|
||
|
"value (%s) on blank XDG_CACHE_HOME\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
/* reset efreet here so we can set a new home dir */
|
||
|
efreet_shutdown();
|
||
|
unsetenv("XDG_CACHE_HOME");
|
||
|
unsetenv("HOME");
|
||
|
#ifdef _WIN32
|
||
|
unsetenv("USERPROFILE");
|
||
|
#endif
|
||
|
efreet_init();
|
||
|
|
||
|
tmp = efreet_cache_home_get();
|
||
|
if (strcmp(tmp, "/tmp/.cache"))
|
||
|
{
|
||
|
printf("efreet_cache_home_get() returned incorrect "
|
||
|
"value (%s) on blank XDG_CACHE_HOME and blank HOME\n", tmp);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
int
|
||
|
ef_cb_efreet_data_dirs(void)
|
||
|
{
|
||
|
Eina_List *tmp, *l;
|
||
12 years ago
|
int ret = 1;
|
||
|
unsigned int i;
|
||
|
unsigned int ok;
|
||
13 years ago
|
char dirs[128], *val;
|
||
|
char *vals[] = {"/var/tmp/a", "/tmp/b", "/usr/local/share", "/etc", NULL};
|
||
|
char *def_vals[] = {PACKAGE_DATA_DIR, "/usr/share", "/usr/local/share", NULL};
|
||
|
|
||
|
dirs[0] = '\0';
|
||
|
for (i = 0; vals[i]; i++)
|
||
|
{
|
||
|
if (i > 0) strcat(dirs, ":");
|
||
|
strcat(dirs, vals[i]);
|
||
|
}
|
||
|
|
||
|
efreet_shutdown();
|
||
|
setenv("XDG_DATA_DIRS", dirs, 1);
|
||
|
efreet_init();
|
||
|
|
||
12 years ago
|
ok = 0;
|
||
13 years ago
|
tmp = efreet_data_dirs_get();
|
||
12 years ago
|
for (i = 0; vals[i]; i++)
|
||
13 years ago
|
{
|
||
12 years ago
|
char *found;
|
||
|
|
||
|
found = eina_list_search_unsorted(tmp, EINA_COMPARE_CB(strcmp), vals[i]);
|
||
|
if (!ecore_file_exists(vals[i]) && found)
|
||
13 years ago
|
{
|
||
12 years ago
|
printf("efreet_data_dirs_get() includes non-existing dir (%s) when "
|
||
|
"%s set\n", vals[i], dirs);
|
||
13 years ago
|
ret = 0;
|
||
12 years ago
|
continue;
|
||
13 years ago
|
}
|
||
12 years ago
|
if (ecore_file_exists(vals[i]) && !found)
|
||
13 years ago
|
{
|
||
12 years ago
|
printf("efreet_data_dirs_get() is missing dir (%s) when "
|
||
|
"%s set\n", vals[i], dirs);
|
||
13 years ago
|
ret = 0;
|
||
12 years ago
|
continue;
|
||
13 years ago
|
}
|
||
12 years ago
|
if (ecore_file_exists(vals[i]) && found)
|
||
|
ok++;
|
||
|
}
|
||
|
if (eina_list_count(tmp) != ok)
|
||
|
{
|
||
|
printf("efreet_data_dirs_get() returned more values then it "
|
||
|
"should have given %s as input\n", dirs);
|
||
|
ret = 0;
|
||
13 years ago
|
}
|
||
|
|
||
|
efreet_shutdown();
|
||
|
unsetenv("XDG_DATA_DIRS");
|
||
|
efreet_init();
|
||
|
|
||
|
i = 0;
|
||
|
tmp = efreet_data_dirs_get();
|
||
|
if (eina_list_count(tmp) != 3)
|
||
|
{
|
||
|
printf("efreet_data_dirs_get() nodes is differnet from expected default\n");
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
EINA_LIST_FOREACH(tmp, l, val)
|
||
|
{
|
||
|
if (!def_vals[i])
|
||
|
{
|
||
|
printf("efreet_data_dirs_get() returned more values then it "
|
||
|
"should have given %s as input\n", dirs);
|
||
|
ret = 0;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (strcmp(val, def_vals[i]))
|
||
|
{
|
||
|
printf("efreet_data_dirs_get() returned incorrect value (%s) when "
|
||
|
"XDG_DATA_DIRS= is set %s\n", val, def_vals[i]);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
i++;
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
int
|
||
|
ef_cb_efreet_config_dirs(void)
|
||
|
{
|
||
|
Eina_List *tmp, *l;
|
||
12 years ago
|
int ret = 1;
|
||
|
unsigned int i;
|
||
|
unsigned int ok;
|
||
13 years ago
|
char dirs[128], *val;
|
||
|
char *vals[] = {"/var/tmp/a", "/tmp/b", "/usr/local/share", "/etc", NULL};
|
||
|
char *def_vals[] = {"/etc/xdg", NULL};
|
||
|
|
||
|
dirs[0] = '\0';
|
||
|
|
||
|
for (i = 0; vals[i]; i++)
|
||
|
{
|
||
|
if (i > 0) strcat(dirs, ":");
|
||
|
strcat(dirs, vals[i]);
|
||
|
}
|
||
|
|
||
|
efreet_shutdown();
|
||
|
setenv("XDG_CONFIG_DIRS", dirs, 1);
|
||
|
efreet_init();
|
||
|
|
||
12 years ago
|
ok = 0;
|
||
13 years ago
|
tmp = efreet_config_dirs_get();
|
||
12 years ago
|
for (i = 0; vals[i]; i++)
|
||
13 years ago
|
{
|
||
12 years ago
|
char *found;
|
||
|
|
||
|
found = eina_list_search_unsorted(tmp, EINA_COMPARE_CB(strcmp), vals[i]);
|
||
|
if (!ecore_file_exists(vals[i]) && found)
|
||
13 years ago
|
{
|
||
12 years ago
|
printf("efreet_data_dirs_get() includes non-existing dir (%s) when "
|
||
|
"%s set\n", vals[i], dirs);
|
||
13 years ago
|
ret = 0;
|
||
12 years ago
|
continue;
|
||
13 years ago
|
}
|
||
12 years ago
|
if (ecore_file_exists(vals[i]) && !found)
|
||
13 years ago
|
{
|
||
12 years ago
|
printf("efreet_data_dirs_get() is missing dir (%s) when "
|
||
|
"%s set\n", vals[i], dirs);
|
||
13 years ago
|
ret = 0;
|
||
12 years ago
|
continue;
|
||
13 years ago
|
}
|
||
12 years ago
|
if (ecore_file_exists(vals[i]) && found)
|
||
|
ok++;
|
||
|
}
|
||
|
if (eina_list_count(tmp) != ok)
|
||
|
{
|
||
|
printf("efreet_data_dirs_get() returned more values then it "
|
||
|
"should have given %s as input\n", dirs);
|
||
|
ret = 0;
|
||
13 years ago
|
}
|
||
|
|
||
|
efreet_shutdown();
|
||
|
unsetenv("XDG_CONFIG_DIRS");
|
||
|
efreet_init();
|
||
|
|
||
|
i = 0;
|
||
|
tmp = efreet_config_dirs_get();
|
||
|
EINA_LIST_FOREACH(tmp, l, val)
|
||
|
{
|
||
|
if (!def_vals[i])
|
||
|
{
|
||
|
printf("efreet_config_dirs_get() returned more values then it "
|
||
|
"should have given %s as input\n", dirs);
|
||
|
ret = 0;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (strcmp(val, def_vals[i]))
|
||
|
{
|
||
|
printf("efreet_config_dirs_get() returned incorrect value (%s) when "
|
||
|
"XDG_CONFIG_DIRS= is set\n", val);
|
||
|
ret = 0;
|
||
|
}
|
||
|
|
||
|
i++;
|
||
|
}
|
||
|
return ret;
|
||
|
}
|