1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4 
5 #include "eo_parser.h"
6 #include "eolian_database.h"
7 
8 static int _eolian_init_counter = 0;
9 int _eolian_log_dom = -1;
10 Eina_Prefix *_eolian_prefix = NULL;
11 
eolian_init(void)12 EAPI int eolian_init(void)
13 {
14    const char *log_dom = "eolian";
15    if (_eolian_init_counter > 0) return ++_eolian_init_counter;
16 
17    eina_init();
18    _eolian_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_LIGHTBLUE);
19    if (_eolian_log_dom < 0)
20      {
21         EINA_LOG_ERR("Could not register log domain: %s", log_dom);
22         return EINA_FALSE;
23      }
24 
25    eina_log_timing(_eolian_log_dom,
26                    EINA_LOG_STATE_STOP,
27                    EINA_LOG_STATE_INIT);
28 
29    INF("Init");
30 
31    _eolian_prefix = eina_prefix_new(NULL, eolian_init, "EOLIAN", "eolian",
32                                     NULL, "", "", PACKAGE_DATA_DIR, "");
33    if (!_eolian_prefix)
34      {
35         ERR("Could not initialize the Eolian prefix.");
36         return EINA_FALSE;
37      }
38 
39    eo_lexer_init();
40    return ++_eolian_init_counter;
41 }
42 
eolian_shutdown(void)43 EAPI int eolian_shutdown(void)
44 {
45    if (_eolian_init_counter <= 0)
46      {
47         EINA_LOG_ERR("Init count not greater than 0 in shutdown.");
48         return 0;
49      }
50    _eolian_init_counter--;
51 
52    if (_eolian_init_counter == 0)
53      {
54         INF("Shutdown");
55         eina_log_timing(_eolian_log_dom,
56               EINA_LOG_STATE_START,
57               EINA_LOG_STATE_SHUTDOWN);
58 
59         eo_lexer_shutdown();
60         eina_prefix_free(_eolian_prefix);
61         _eolian_prefix = NULL;
62 
63         eina_log_domain_unregister(_eolian_log_dom);
64         _eolian_log_dom = -1;
65         eina_shutdown();
66      }
67 
68    return _eolian_init_counter;
69 }
70 
eolian_file_format_version_get(void)71 EAPI unsigned short eolian_file_format_version_get(void)
72 {
73    return EOLIAN_FILE_FORMAT_VERSION;
74 }
75