2012-10-20 21:53:23 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2013-06-21 01:32:18 -07:00
|
|
|
#include <stdlib.h>
|
2013-07-11 02:22:38 -07:00
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
2013-06-20 04:53:54 -07:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/resource.h>
|
2013-07-09 01:04:58 -07:00
|
|
|
#endif
|
2013-06-20 04:53:54 -07:00
|
|
|
|
2012-10-20 21:53:23 -07:00
|
|
|
#include <Ecore.h>
|
2012-11-01 18:46:31 -07:00
|
|
|
#include <Ecore_File.h>
|
2012-10-20 21:53:23 -07:00
|
|
|
|
|
|
|
#include "efreetd.h"
|
|
|
|
#include "efreetd_dbus.h"
|
|
|
|
#include "efreetd_cache.h"
|
|
|
|
|
|
|
|
int efreetd_log_dom = -1;
|
|
|
|
|
2012-11-02 13:12:41 -07:00
|
|
|
void
|
|
|
|
quit(void)
|
|
|
|
{
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
}
|
|
|
|
|
2012-10-20 21:53:23 -07:00
|
|
|
int
|
2013-01-04 09:42:23 -08:00
|
|
|
main(int argc, char *argv[])
|
2012-10-20 21:53:23 -07:00
|
|
|
{
|
2013-06-21 01:32:18 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
char *path;
|
|
|
|
FILE *log;
|
|
|
|
|
|
|
|
strcpy(buf, "/tmp/efreetd_XXXXXX");
|
|
|
|
path = mktemp(buf);
|
|
|
|
if (!path) return 1;
|
2013-08-07 01:02:05 -07:00
|
|
|
if (chmod(path, 0700) < 0)
|
|
|
|
{
|
|
|
|
perror("chmod");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-06-21 01:32:18 -07:00
|
|
|
log = fopen(path, "wb");
|
2013-08-07 01:02:05 -07:00
|
|
|
if (!log) return 1;
|
|
|
|
|
|
|
|
if (!eina_init()) return 1;
|
2013-06-21 01:32:18 -07:00
|
|
|
eina_log_print_cb_set(eina_log_print_cb_file, log);
|
|
|
|
|
2012-10-20 21:53:23 -07:00
|
|
|
efreetd_log_dom = eina_log_domain_register("efreetd", EFREETD_DEFAULT_LOG_COLOR);
|
|
|
|
if (efreetd_log_dom < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Efreet: Could not create a log domain for efreetd.");
|
|
|
|
goto ecore_error;
|
|
|
|
}
|
|
|
|
if (!ecore_init()) goto ecore_error;
|
2013-01-04 09:42:23 -08:00
|
|
|
ecore_app_args_set(argc, (const char **)argv);
|
2012-11-01 18:46:31 -07:00
|
|
|
if (!ecore_file_init()) goto ecore_file_error;
|
2012-10-20 21:53:23 -07:00
|
|
|
|
|
|
|
if (!dbus_init()) goto dbus_error;
|
|
|
|
if (!cache_init()) goto cache_error;
|
|
|
|
|
2013-07-11 02:22:38 -07:00
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
2013-06-20 04:53:54 -07:00
|
|
|
setpriority(PRIO_PROCESS, 0, 19);
|
2013-07-11 12:10:51 -07:00
|
|
|
#elif _WIN32
|
|
|
|
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
|
2013-07-09 01:04:58 -07:00
|
|
|
#endif
|
|
|
|
|
2012-10-20 21:53:23 -07:00
|
|
|
ecore_main_loop_begin();
|
|
|
|
|
|
|
|
cache_shutdown();
|
|
|
|
dbus_shutdown();
|
2012-11-01 18:46:31 -07:00
|
|
|
ecore_file_shutdown();
|
2012-10-20 21:53:23 -07:00
|
|
|
ecore_shutdown();
|
|
|
|
eina_log_domain_unregister(efreetd_log_dom);
|
|
|
|
efreetd_log_dom = -1;
|
|
|
|
eina_shutdown();
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cache_error:
|
|
|
|
dbus_shutdown();
|
|
|
|
dbus_error:
|
2012-11-01 18:46:31 -07:00
|
|
|
ecore_file_shutdown();
|
|
|
|
ecore_file_error:
|
2012-10-20 21:53:23 -07:00
|
|
|
ecore_shutdown();
|
|
|
|
ecore_error:
|
2012-11-01 18:46:44 -07:00
|
|
|
if (efreetd_log_dom >= 0)
|
|
|
|
eina_log_domain_unregister(efreetd_log_dom);
|
2012-10-20 21:53:23 -07:00
|
|
|
efreetd_log_dom = -1;
|
|
|
|
eina_shutdown();
|
|
|
|
return 1;
|
|
|
|
}
|