elput: Initial checkin of elput library
[platform/upstream/efl.git] / src / lib / elput / elput.c
1 #include "elput_private.h"
2
3 /* local variables */
4 static int _elput_init_count = 0;
5
6 /* external variables */
7 int _elput_log_dom = -1;
8
9 EAPI int
10 elput_init(void)
11 {
12    if (++_elput_init_count != 1) return _elput_init_count;
13
14    if (!eina_init()) goto eina_err;
15    if (!ecore_init()) goto ecore_err;
16    if (!ecore_event_init()) goto ecore_event_err;
17    if (!eeze_init()) goto eeze_err;
18
19    _elput_log_dom = eina_log_domain_register("elput", ELPUT_DEFAULT_LOG_COLOR);
20    if (!_elput_log_dom)
21      {
22         EINA_LOG_ERR("Could not create logging domain for Elput");
23         goto log_err;
24      }
25
26    return _elput_init_count;
27
28 log_err:
29    eeze_shutdown();
30 eeze_err:
31    ecore_event_shutdown();
32 ecore_event_err:
33    ecore_shutdown();
34 ecore_err:
35    eina_shutdown();
36 eina_err:
37    return --_elput_init_count;
38 }
39
40 EAPI int
41 elput_shutdown(void)
42 {
43    if (_elput_init_count < 1) return 0;
44    if (--_elput_init_count != 0) return _elput_init_count;
45
46    eina_log_domain_unregister(_elput_log_dom);
47    _elput_log_dom = -1;
48
49    eeze_shutdown();
50    ecore_event_shutdown();
51    ecore_shutdown();
52    eina_shutdown();
53
54    return _elput_init_count;
55 }