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_cache.h"
|
2015-06-24 03:24:21 -07:00
|
|
|
#include "efreetd_ipc.h"
|
2012-10-20 21:53:23 -07:00
|
|
|
|
|
|
|
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-10-15 21:38:40 -07:00
|
|
|
char path[PATH_MAX];
|
2013-06-21 01:32:18 -07:00
|
|
|
FILE *log;
|
2013-10-22 03:54:22 -07:00
|
|
|
int fd;
|
2013-10-15 21:38:40 -07:00
|
|
|
mode_t um;
|
2013-06-21 01:32:18 -07:00
|
|
|
|
2013-12-27 17:22:23 -08:00
|
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
|
|
|
setpriority(PRIO_PROCESS, 0, 19);
|
|
|
|
#elif _WIN32
|
|
|
|
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
|
|
|
|
#endif
|
|
|
|
|
2013-10-15 21:38:40 -07:00
|
|
|
strcpy(path, "/tmp/efreetd_XXXXXX");
|
2013-12-27 17:22:23 -08:00
|
|
|
um = umask(S_IRWXG | S_IRWXO);
|
2013-10-22 03:54:22 -07:00
|
|
|
fd = mkstemp(path);
|
2013-10-15 21:38:40 -07:00
|
|
|
umask(um);
|
2013-10-22 03:54:22 -07:00
|
|
|
if (fd < 0)
|
2013-10-15 21:38:40 -07:00
|
|
|
{
|
2013-10-22 03:54:22 -07:00
|
|
|
perror("mkstemp");
|
2013-10-15 21:38:40 -07:00
|
|
|
return 1;
|
2013-08-07 01:02:05 -07:00
|
|
|
}
|
2013-10-22 03:54:22 -07:00
|
|
|
log = fdopen(fd, "wb");
|
2013-10-15 21:38:40 -07:00
|
|
|
if (!log) return 1;
|
2013-08-07 01:02:05 -07:00
|
|
|
|
2013-10-15 21:38:40 -07:00
|
|
|
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;
|
|
|
|
}
|
2013-12-27 17:22:23 -08:00
|
|
|
|
2012-10-20 21:53:23 -07:00
|
|
|
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;
|
2015-06-24 03:24:21 -07:00
|
|
|
if (!ipc_init()) goto ipc_error;
|
2012-10-20 21:53:23 -07:00
|
|
|
if (!cache_init()) goto cache_error;
|
|
|
|
|
|
|
|
ecore_main_loop_begin();
|
|
|
|
|
|
|
|
cache_shutdown();
|
2015-06-24 03:24:21 -07:00
|
|
|
ipc_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:
|
2015-06-24 03:24:21 -07:00
|
|
|
ipc_shutdown();
|
|
|
|
ipc_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:
|
2013-12-27 17:22:23 -08: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;
|
|
|
|
}
|