1 /* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler,
3 * Jorge Luis Zapata Muga,
5 * Gustavo Sverzut Barbieri
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library;
20 * if not, see <http://www.gnu.org/licenses/>.
28 #include "eina_config.h"
29 #include "eina_private.h"
30 #include "eina_unicode.h"
32 #include "eina_share_common.h"
34 /* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
35 #include "eina_safety_checks.h"
36 #include "eina_binshare.h"
38 /*============================================================================*
40 *============================================================================*/
49 #define CRITICAL(...) EINA_LOG_DOM_CRIT(_eina_share_binshare_log_dom, __VA_ARGS__)
54 #define ERR(...) EINA_LOG_DOM_ERR(_eina_share_binshare_log_dom, __VA_ARGS__)
59 #define DBG(...) EINA_LOG_DOM_DBG(_eina_share_binshare_log_dom, __VA_ARGS__)
61 static int _eina_share_binshare_log_dom = -1;
63 /* The actual share */
64 static Eina_Share *binshare_share;
65 static const char EINA_MAGIC_BINSHARE_NODE_STR[] = "Eina Binshare Node";
71 /*============================================================================*
73 *============================================================================*/
77 * @brief Initialize the share_common module.
79 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
81 * This function sets up the share_common module of Eina. It is called by
87 eina_binshare_init(void)
91 if (_eina_share_binshare_log_dom < 0)
93 _eina_share_binshare_log_dom = eina_log_domain_register
94 ("eina_binshare", EINA_LOG_COLOR_DEFAULT);
96 if (_eina_share_binshare_log_dom < 0)
98 EINA_LOG_ERR("Could not register log domain: eina_binshare");
103 ret = eina_share_common_init(&binshare_share,
104 EINA_MAGIC_BINSHARE_NODE,
105 EINA_MAGIC_BINSHARE_NODE_STR);
109 eina_log_domain_unregister(_eina_share_binshare_log_dom);
110 _eina_share_binshare_log_dom = -1;
118 * @brief Shut down the share_common module.
120 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
122 * This function shuts down the share_common module set up by
123 * eina_share_common_init(). It is called by eina_shutdown().
125 * @see eina_shutdown()
128 eina_binshare_shutdown(void)
131 ret = eina_share_common_shutdown(&binshare_share);
133 if (_eina_share_binshare_log_dom > 0)
135 eina_log_domain_unregister(_eina_share_binshare_log_dom);
136 _eina_share_binshare_log_dom = -1;
143 /*============================================================================*
145 *============================================================================*/
148 eina_binshare_del(const void *obj)
153 if (!eina_share_common_del(binshare_share, obj))
154 CRITICAL("EEEK trying to del non-shared binshare %p", obj);
158 eina_binshare_add_length(const void *obj, unsigned int olen)
160 return eina_share_common_add_length(binshare_share,
162 (olen) * sizeof(char),
167 eina_binshare_ref(const void *obj)
169 return eina_share_common_ref(binshare_share, obj);
173 eina_binshare_length(const void *obj)
175 return eina_share_common_length(binshare_share, obj);
179 eina_binshare_dump(void)
181 eina_share_common_dump(binshare_share, NULL, 0);