2014-02-12 12:56:20 -08:00
|
|
|
#ifdef HAVE_CONFIG
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Edi.h"
|
|
|
|
|
|
|
|
#include "edi_private.h"
|
|
|
|
|
|
|
|
static int _edi_init = 0;
|
|
|
|
int _edi_lib_log_dom = -1;
|
2014-04-27 09:36:20 -07:00
|
|
|
static const char *_edi_project_path;
|
2014-02-12 12:56:20 -08:00
|
|
|
|
|
|
|
EAPI int
|
|
|
|
edi_init(void)
|
|
|
|
{
|
|
|
|
_edi_init++;
|
|
|
|
if (_edi_init > 1) return _edi_init;
|
|
|
|
|
|
|
|
eina_init();
|
|
|
|
|
|
|
|
_edi_lib_log_dom = eina_log_domain_register("edi", EINA_COLOR_CYAN);
|
|
|
|
if (_edi_lib_log_dom < 0)
|
|
|
|
{
|
2014-02-15 16:31:10 -08:00
|
|
|
EINA_LOG_ERR("Edi can not create its log domain.");
|
|
|
|
goto shutdown_eina;
|
2014-02-12 12:56:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Put here your initialization logic of your library
|
|
|
|
|
|
|
|
eina_log_timing(_edi_lib_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
|
|
|
|
|
|
|
|
return _edi_init;
|
|
|
|
|
2014-02-12 15:02:09 -08:00
|
|
|
shutdown_eina:
|
2014-02-12 12:56:20 -08:00
|
|
|
eina_shutdown();
|
|
|
|
_edi_init--;
|
|
|
|
|
|
|
|
return _edi_init;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
edi_shutdown(void)
|
|
|
|
{
|
|
|
|
_edi_init--;
|
|
|
|
if (_edi_init != 0) return _edi_init;
|
|
|
|
|
|
|
|
eina_log_timing(_edi_lib_log_dom,
|
2014-02-15 16:31:10 -08:00
|
|
|
EINA_LOG_STATE_START,
|
|
|
|
EINA_LOG_STATE_SHUTDOWN);
|
2014-02-12 12:56:20 -08:00
|
|
|
|
|
|
|
// Put here your shutdown logic
|
|
|
|
|
|
|
|
eina_log_domain_unregister(_edi_lib_log_dom);
|
|
|
|
_edi_lib_log_dom = -1;
|
|
|
|
|
|
|
|
eina_shutdown();
|
|
|
|
|
|
|
|
return _edi_init;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2014-04-27 09:36:20 -07:00
|
|
|
edi_project_set(const char *path)
|
2014-02-12 12:56:20 -08:00
|
|
|
{
|
2014-04-27 10:43:15 -07:00
|
|
|
if (_edi_project_path)
|
|
|
|
eina_stringshare_del(_edi_project_path);
|
|
|
|
|
|
|
|
_edi_project_path = eina_stringshare_add(path);
|
2014-04-27 09:36:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
edi_project_get()
|
|
|
|
{
|
|
|
|
return _edi_project_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
edi_project_file_path_get(const char *file)
|
|
|
|
{
|
2014-05-19 11:19:12 -07:00
|
|
|
char *path;
|
2014-04-27 09:36:20 -07:00
|
|
|
int len;
|
|
|
|
|
|
|
|
len = strlen(file) + strlen(edi_project_get()) + 2;
|
|
|
|
path = malloc(sizeof(char) * len);
|
|
|
|
snprintf(path, len, "%s/%s", edi_project_get(), file);
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
edi_project_file_exists(const char *file)
|
|
|
|
{
|
|
|
|
const char *path;
|
|
|
|
Eina_Bool exists;
|
|
|
|
|
|
|
|
path = edi_project_file_path_get(file);
|
|
|
|
exists = ecore_file_exists(path);
|
|
|
|
|
2014-05-19 11:19:12 -07:00
|
|
|
free((void *)path);
|
2014-04-27 09:36:20 -07:00
|
|
|
return exists;
|
2014-02-12 12:56:20 -08:00
|
|
|
}
|