Code Sync [Tizen3.0]: Merged the tizen_2.4 Spin code to tizen.org
[platform/core/connectivity/bluetooth-frwk.git] / bt-core / include / bt-core-common.h
1 /*
2  * Bluetooth-frwk
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
7  *               Girishashok Joshi <girish.joshi@samsung.com>
8  *               Chanyeol Park <chanyeol.park@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *              http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24
25 #ifndef _BT_CORE_COMMON_H_
26 #define _BT_CORE_COMMON_H_
27
28 #include <sys/types.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #undef LOG_TAG
35 #define LOG_TAG "BLUETOOTH_FRWK_CORE"
36
37 #define LOG_COLOR_RESET    "\033[0m"
38 #define LOG_COLOR_RED      "\033[31m"
39 #define LOG_COLOR_YELLOW   "\033[33m"
40 #define LOG_COLOR_GREEN         "\033[32m"
41 #define LOG_COLOR_BLUE          "\033[36m"
42 #define LOG_COLOR_PURPLE   "\033[35m"
43
44 #define BT_DBG(fmt, args...) \
45         SLOGD(fmt, ##args)
46 #define BT_INFO(fmt, args...) \
47         SLOGI(fmt, ##args)
48 #define BT_ERR(fmt, args...) \
49         SLOGE(fmt, ##args)
50
51 #define BT_INFO_C(fmt, arg...) \
52         SLOGI_IF(TRUE,  LOG_COLOR_GREEN" "fmt" "LOG_COLOR_RESET, ##arg)
53 #define BT_ERR_C(fmt, arg...) \
54         SLOGI_IF(TRUE,  LOG_COLOR_RED" "fmt" "LOG_COLOR_RESET, ##arg)
55
56 #define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
57 #define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args)
58
59 #define ret_if(expr) \
60         do { \
61                 if (expr) { \
62                         BT_ERR("(%s) return", #expr); \
63                         return; \
64                 } \
65         } while (0)
66
67 #define retv_if(expr, val) \
68         do { \
69                 if (expr) { \
70                         BT_ERR("(%s) return", #expr); \
71                         return (val); \
72                 } \
73         } while (0)
74
75 #define BT_FREE_PARAMS(IP1,IP2,IP3,IP4,OP) \
76         do { \
77                 if (IP1) \
78                         g_array_free(IP1, TRUE); \
79                 if (IP2) \
80                         g_array_free(IP2, TRUE); \
81                 if (IP3) \
82                         g_array_free(IP3, TRUE); \
83                 if (IP4) \
84                         g_array_free(IP4, TRUE); \
85                 if (OP) \
86                         g_array_free(OP, TRUE); \
87         } while (0)
88
89 #define BT_ALLOC_PARAMS(IP1,IP2,IP3,IP4,OP ) \
90         do { \
91                 IP1 = g_array_new(TRUE, TRUE, sizeof(gchar));   \
92                 IP2 = g_array_new(TRUE, TRUE, sizeof(gchar));   \
93                 IP3 = g_array_new(TRUE, TRUE, sizeof(gchar));   \
94                 IP4 = g_array_new(TRUE, TRUE, sizeof(gchar));   \
95         } while (0)
96
97 #ifdef __cplusplus
98 }
99 #endif /* __cplusplus */
100 #endif /*_BT_CORE_COMMON_H_*/
101