2006-10-22 03:03:59 -07:00
|
|
|
#include "config.h"
|
|
|
|
#include "e_precache.h"
|
|
|
|
|
|
|
|
static void *lib_evas = NULL;
|
|
|
|
static void *lib_ecore_file = NULL;
|
|
|
|
static void *lib_eet = NULL;
|
|
|
|
|
2006-10-29 03:00:32 -08:00
|
|
|
static int *e_precache_end = NULL;
|
2006-10-22 03:03:59 -07:00
|
|
|
|
|
|
|
/* internal calls */
|
|
|
|
static int log_fd = -1;
|
|
|
|
static int do_log = 0;
|
|
|
|
|
|
|
|
static void
|
|
|
|
log_open(void)
|
|
|
|
{
|
2006-10-23 06:49:06 -07:00
|
|
|
char buf[4096] = "DUMMY", *home;
|
2006-10-22 03:03:59 -07:00
|
|
|
|
|
|
|
if (log_fd != -1) return;
|
2006-10-29 03:03:47 -08:00
|
|
|
if (!e_precache_end)
|
|
|
|
{
|
2006-10-22 03:03:59 -07:00
|
|
|
#ifdef HAVE_UNSETENV
|
2006-10-29 03:03:47 -08:00
|
|
|
unsetenv("LD_PRELOAD");
|
2006-10-22 03:03:59 -07:00
|
|
|
#else
|
2006-10-29 03:03:47 -08:00
|
|
|
if (getenv("LD_PRELOAD")) putenv("LD_PRELOAD");
|
2006-10-22 03:03:59 -07:00
|
|
|
#endif
|
2006-10-29 03:03:47 -08:00
|
|
|
e_precache_end = dlsym(NULL, "e_precache_end");
|
|
|
|
}
|
|
|
|
if (!e_precache_end) return;
|
|
|
|
if (*e_precache_end) return;
|
|
|
|
|
2006-10-22 03:03:59 -07:00
|
|
|
home = getenv("HOME");
|
|
|
|
if (home)
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.e-precache", home);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "/tmp/.e-precache");
|
2006-10-29 03:00:32 -08:00
|
|
|
log_fd = open(buf, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
|
|
|
|
if (log_fd) do_log = 1;
|
2006-10-22 03:03:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
log_close(void)
|
|
|
|
{
|
2006-10-23 06:49:06 -07:00
|
|
|
if (log_fd >= 0)
|
|
|
|
{
|
|
|
|
close(log_fd);
|
|
|
|
log_fd = -1;
|
|
|
|
}
|
2006-10-22 03:03:59 -07:00
|
|
|
do_log = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
log_write(const char *type, const char *file)
|
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Hash *s_hash = NULL;
|
|
|
|
static Eina_Hash *o_hash = NULL;
|
|
|
|
static Eina_Hash *d_hash = NULL;
|
2006-10-22 03:03:59 -07:00
|
|
|
char buf[2];
|
|
|
|
|
2006-10-29 03:02:11 -08:00
|
|
|
if ((e_precache_end) && (*e_precache_end))
|
2006-10-22 03:03:59 -07:00
|
|
|
{
|
|
|
|
log_close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (type[0] == 's')
|
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
if (eina_hash_find(s_hash, file)) return;
|
|
|
|
if (!s_hash) s_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_add(s_hash, file, (void *)1);
|
2006-10-22 03:03:59 -07:00
|
|
|
}
|
|
|
|
else if (type[0] == 'o')
|
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
if (eina_hash_find(o_hash, file)) return;
|
|
|
|
if (!o_hash) o_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_add(o_hash, file, (void *)1);
|
2006-10-22 03:03:59 -07:00
|
|
|
}
|
|
|
|
else if (type[0] == 'd')
|
|
|
|
{
|
2008-12-17 07:33:43 -08:00
|
|
|
if (eina_hash_find(d_hash, file)) return;
|
|
|
|
if (!d_hash) d_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_add(d_hash, file, (void *)1);
|
|
|
|
}
|
2006-10-22 03:03:59 -07:00
|
|
|
buf[0] = type[0]; buf[1] = ' ';
|
|
|
|
write(log_fd, buf, 2);
|
|
|
|
write(log_fd, file, strlen(file));
|
|
|
|
write(log_fd, "\n", 1);
|
|
|
|
}
|
|
|
|
|
2006-10-23 06:49:06 -07:00
|
|
|
static void *
|
|
|
|
lib_func(const char *lib1, const char *lib2, const char *fname, const char *libname, void **lib)
|
|
|
|
{
|
|
|
|
void *func;
|
|
|
|
|
|
|
|
if (!*lib) *lib = dlopen(lib1, RTLD_GLOBAL | RTLD_LAZY);
|
|
|
|
if (!*lib) *lib = dlopen(lib2, RTLD_GLOBAL | RTLD_LAZY);
|
|
|
|
func = dlsym(*lib, fname);
|
|
|
|
if (!func)
|
|
|
|
{
|
|
|
|
printf("ABORT: Can't find %s() in %s or %s (%s = %p)\n",
|
|
|
|
fname, lib1, lib2, libname, *lib);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
log_open();
|
|
|
|
return func;
|
|
|
|
}
|
2006-10-22 03:03:59 -07:00
|
|
|
|
|
|
|
/* intercepts */
|
|
|
|
void
|
|
|
|
evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
|
|
|
|
{
|
|
|
|
static void (*func) (Evas_Object *obj, const char *file, const char *key) = NULL;
|
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libevas.so", "libevas.so.1",
|
|
|
|
"evas_object_image_file_set", "lib_evas", &lib_evas);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("o", file);
|
|
|
|
(*func) (obj, file, key);
|
|
|
|
}
|
|
|
|
|
2007-06-02 09:35:10 -07:00
|
|
|
long long
|
2006-10-22 03:03:59 -07:00
|
|
|
ecore_file_mod_time(const char *file)
|
|
|
|
{
|
2007-07-22 16:06:42 -07:00
|
|
|
static long long (*func) (const char *file) = NULL;
|
2006-10-22 03:03:59 -07:00
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
|
|
|
"ecore_file_mod_time", "lib_ecore_file", &lib_ecore_file);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("s", file);
|
|
|
|
return (*func) (file);
|
|
|
|
}
|
|
|
|
|
2007-06-02 09:35:10 -07:00
|
|
|
long long
|
2006-10-22 03:03:59 -07:00
|
|
|
ecore_file_size(const char *file)
|
|
|
|
{
|
|
|
|
static int (*func) (const char *file) = NULL;
|
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
|
|
|
"ecore_file_size", "lib_ecore_file", &lib_ecore_file);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("s", file);
|
|
|
|
return (*func) (file);
|
|
|
|
}
|
|
|
|
|
2010-06-10 08:12:46 -07:00
|
|
|
Eina_Bool
|
2006-10-22 03:03:59 -07:00
|
|
|
ecore_file_exists(const char *file)
|
|
|
|
{
|
|
|
|
static int (*func) (const char *file) = NULL;
|
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
|
|
|
"ecore_file_exists", "lib_ecore_file", &lib_ecore_file);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("s", file);
|
|
|
|
return (*func) (file);
|
|
|
|
}
|
|
|
|
|
2010-06-10 08:12:46 -07:00
|
|
|
Eina_Bool
|
2006-10-22 03:03:59 -07:00
|
|
|
ecore_file_is_dir(const char *file)
|
|
|
|
{
|
|
|
|
static int (*func) (const char *file) = NULL;
|
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
|
|
|
"ecore_file_is_dir", "lib_ecore_file", &lib_ecore_file);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("s", file);
|
|
|
|
return (*func) (file);
|
|
|
|
}
|
|
|
|
|
2010-06-10 08:12:46 -07:00
|
|
|
Eina_Bool
|
2006-10-22 03:03:59 -07:00
|
|
|
ecore_file_can_read(const char *file)
|
|
|
|
{
|
|
|
|
static int (*func) (const char *file) = NULL;
|
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
|
|
|
"ecore_file_can_read", "lib_ecore_file", &lib_ecore_file);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("s", file);
|
|
|
|
return (*func) (file);
|
|
|
|
}
|
|
|
|
|
2010-06-10 08:12:46 -07:00
|
|
|
Eina_Bool
|
2006-10-22 03:03:59 -07:00
|
|
|
ecore_file_can_write(const char *file)
|
|
|
|
{
|
|
|
|
static int (*func) (const char *file) = NULL;
|
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
|
|
|
"ecore_file_can_write", "lib_ecore_file", &lib_ecore_file);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("s", file);
|
|
|
|
return (*func) (file);
|
|
|
|
}
|
|
|
|
|
2010-06-10 08:12:46 -07:00
|
|
|
Eina_Bool
|
2006-10-22 03:03:59 -07:00
|
|
|
ecore_file_can_exec(const char *file)
|
|
|
|
{
|
|
|
|
static int (*func) (const char *file) = NULL;
|
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
|
|
|
"ecore_file_can_exec", "lib_ecore_file", &lib_ecore_file);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("s", file);
|
|
|
|
return (*func) (file);
|
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *
|
2006-10-22 03:03:59 -07:00
|
|
|
ecore_file_ls(const char *file)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
static Eina_List * (*func) (const char *file) = NULL;
|
2006-10-22 03:03:59 -07:00
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libecore_file.so", "libecore_file.so.1",
|
|
|
|
"ecore_file_ls", "lib_ecore_file", &lib_ecore_file);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("d", file);
|
|
|
|
return (*func) (file);
|
|
|
|
}
|
|
|
|
|
|
|
|
Eet_File *
|
|
|
|
eet_open(const char *file, Eet_File_Mode mode)
|
|
|
|
{
|
|
|
|
static Eet_File * (*func) (const char *file, Eet_File_Mode mode) = NULL;
|
|
|
|
if (!func)
|
2006-10-23 06:49:06 -07:00
|
|
|
func = lib_func("libeet.so", "libeet.so.0",
|
|
|
|
"eet_open", "lib_eet", &lib_eet);
|
2006-10-22 03:03:59 -07:00
|
|
|
if (do_log) log_write("o", file);
|
|
|
|
return (*func) (file, mode);
|
|
|
|
}
|