1 #ifdef HAVE_CONFIG_H 2 #include "config.h" 3 #endif 4 5 #include <Ecore.h> 6 #include <Eeze.h> 7 #include <Eeze_Disk.h> 8 #include <Eeze_Sensor.h> 9 #include "eeze_udev_private.h" 10 #include "eeze_net_private.h" 11 #include "eeze_disk_private.h" 12 #include "eeze_sensor_private.h" 13 14 _udev *udev; 15 16 int _eeze_udev_log_dom = -1; 17 int _eeze_net_log_dom = -1; 18 int _eeze_sensor_log_dom = -1; 19 int _eeze_init_count = 0; 20 21 static Eeze_Version _version = { VMAJ, VMIN, VMIC, VREV }; 22 EAPI Eeze_Version *eeze_version = &_version; 23 24 EAPI int eeze_init(void)25eeze_init(void) 26 { 27 if (++_eeze_init_count != 1) 28 return _eeze_init_count; 29 30 if (!eina_init()) 31 return --_eeze_init_count; 32 33 _eeze_udev_log_dom = eina_log_domain_register("eeze_udev", EINA_COLOR_CYAN); 34 if (_eeze_udev_log_dom < 0) 35 { 36 EINA_LOG_ERR("Could not register 'eeze_udev' log domain."); 37 goto eina_fail; 38 } 39 _eeze_net_log_dom = eina_log_domain_register("eeze_net", EINA_COLOR_GREEN); 40 if (_eeze_net_log_dom < 0) 41 { 42 EINA_LOG_ERR("Could not register 'eeze_net' log domain."); 43 goto eina_net_fail; 44 } 45 46 _eeze_sensor_log_dom = eina_log_domain_register("eeze_sensor", EINA_COLOR_BLUE); 47 if (_eeze_sensor_log_dom < 0) 48 { 49 EINA_LOG_ERR("Could not register 'eeze_sensor' log domain."); 50 goto eina_sensor_fail; 51 } 52 53 if (!ecore_init()) 54 goto ecore_fail; 55 #ifdef HAVE_EEZE_MOUNT 56 if (!eeze_disk_init()) 57 goto eeze_fail; 58 #endif 59 if (!(udev = udev_new())) 60 { 61 EINA_LOG_ERR("Could not initialize udev library!"); 62 goto fail; 63 } 64 if (!eeze_net_init()) 65 { 66 EINA_LOG_ERR("Error initializing eeze_net subsystems!"); 67 goto net_fail; 68 } 69 if (!eeze_sensor_init()) 70 { 71 EINA_LOG_ERR("Error initializing eeze_sensor subsystems!"); 72 goto sensor_fail; 73 } 74 75 return _eeze_init_count; 76 77 sensor_fail: 78 eeze_net_shutdown(); 79 net_fail: 80 udev_unref(udev); 81 fail: 82 #ifdef HAVE_EEZE_MOUNT 83 eeze_disk_shutdown(); 84 eeze_fail: 85 #endif 86 ecore_shutdown(); 87 ecore_fail: 88 eina_log_domain_unregister(_eeze_sensor_log_dom); 89 _eeze_sensor_log_dom = -1; 90 eina_sensor_fail: 91 eina_log_domain_unregister(_eeze_net_log_dom); 92 _eeze_net_log_dom = -1; 93 eina_net_fail: 94 eina_log_domain_unregister(_eeze_udev_log_dom); 95 _eeze_udev_log_dom = -1; 96 eina_fail: 97 eina_shutdown(); 98 return --_eeze_init_count; 99 } 100 101 EAPI int eeze_shutdown(void)102eeze_shutdown(void) 103 { 104 if (_eeze_init_count <= 0) 105 { 106 EINA_LOG_ERR("Init count not greater than 0 in shutdown."); 107 return 0; 108 } 109 if (--_eeze_init_count != 0) 110 return _eeze_init_count; 111 112 udev_unref(udev); 113 #ifdef HAVE_EEZE_MOUNT 114 eeze_disk_shutdown(); 115 #endif 116 eeze_sensor_shutdown(); 117 eeze_net_shutdown(); 118 ecore_shutdown(); 119 eina_log_domain_unregister(_eeze_udev_log_dom); 120 _eeze_udev_log_dom = -1; 121 eina_log_domain_unregister(_eeze_net_log_dom); 122 _eeze_net_log_dom = -1; 123 eina_log_domain_unregister(_eeze_sensor_log_dom); 124 _eeze_sensor_log_dom = -1; 125 eina_shutdown(); 126 return _eeze_init_count; 127 } 128 129 EAPI void * eeze_udev_get(void)130eeze_udev_get(void) 131 { 132 return udev; 133 } 134