4 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef __CAL_INTERNAL_H__
20 #define __CAL_INTERNAL_H__
24 #include <system_info.h>
26 #define SAFE_STRDUP(src) (src) ? strdup((char *)src) : NULL
30 #define LOG_TAG "CALENDAR_SVC"
33 #define COLOR_RED "\033[0;31m"
34 #define COLOR_GREEN "\033[0;32m"
35 #define COLOR_BROWN "\033[0;33m"
36 #define COLOR_BLUE "\033[0;34m"
37 #define COLOR_PURPLE "\033[0;35m"
38 #define COLOR_CYAN "\033[0;36m"
39 #define COLOR_END "\033[0;m"
41 #if defined(CAL_IPC_SERVER)
42 #define IPC_ROLE COLOR_BLUE "[SERVER]" COLOR_END
43 #elif defined(CAL_IPC_CLIENT)
44 #define IPC_ROLE COLOR_BROWN "[CLIENT]" COLOR_END
46 #define IPC_ROLE COLOR_GREEN "[LIB]" COLOR_END
50 #define INFO(fmt, arg...) SLOGI(IPC_ROLE fmt, ##arg)
51 #define ERR(fmt, arg...) SLOGE(IPC_ROLE fmt, ##arg)
52 #define DBG(fmt, arg...) SLOGD(IPC_ROLE fmt, ##arg)
53 #define WARN(fmt, arg...) SLOGD(IPC_ROLE fmt, ##arg)
54 #define VERBOSE(fmt, arg...) SLOGV(IPC_ROLE fmt, ##arg)
55 #else /* CAL_DEBUGGING */
56 #define INFO(fmt, arg...)
57 #define ERR(fmt, arg...)
58 #define DBG(fmt, arg...)
59 #define WARN(fmt, arg...)
60 #define VERBOSE(fmt, arg...)
61 #endif /* CAL_DEBUGGING */
63 #define SEC_INFO(fmt, arg...) SECURE_LOGI(fmt, ##arg)
64 #define SEC_ERR(fmt, arg...) SECURE_LOGE(fmt, ##arg)
65 #define SEC_DBG(fmt, arg...) SECURE_LOGD(fmt, ##arg)
66 #define SECURE(fmt, arg...) SECURE_LOGD(fmt, ##arg)
68 #define CAL_FN_CALL() DBG(">>>>>>>> called")
69 #define CAL_FN_END() DBG("<<<<<<<< ended")
70 #define CAL_DBG(fmt, arg...) DBG(fmt, ##arg)
71 #define CAL_WARN(fmt, arg...) WARN(fmt, ##arg)
72 #define CAL_ERR(fmt, arg...) ERR(fmt, ##arg)
73 #define CAL_INFO(fmt, arg...) INFO(fmt, ##arg)
74 #define CAL_VERBOSE(fmt, arg...) VERBOSE(fmt, ##arg)
76 #define WARN_IF(expr, fmt, arg...) do { \
81 #define RET_IF(expr) do { \
87 #define RETV_IF(expr, val) do { \
93 #define RETM_IF(expr, fmt, arg...) do { \
99 #define RETVM_IF(expr, val, fmt, arg...) do { \
105 #define BREAK_IF(expr, fmt, arg...) do { \
112 #define CAL_START_TIMESTAMP struct timeval timeval_s = {0}; \
113 struct timeval timeval_e = {0}; \
114 struct timeval timeval_d = {0}; \
115 DBG(COLOR_PURPLE ">>>>>" COLOR_END); \
116 gettimeofday(&timeval_s, NULL);
118 #define CAL_PRINT_TIMESTAMP gettimeofday(&timeval_e, NULL); \
119 timersub(&timeval_e, &timeval_s, &timeval_d); \
120 timeval_s = timeval_e; \
121 DBG(COLOR_PURPLE "<<<<< (%03d.%03dsec)" COLOR_END, (int)(timeval_d.tv_sec % 1000), (int)(timeval_d.tv_usec/1000));
125 #define CAL_PROFILE_GET_TIME() (clock() / (CLOCKS_PER_SEC / 1000));
126 #define CAL_PROFILE_PRINT(starttime, endtime) ERR("%ld ~ %ld : %ld(%d sec) msec", starttime, endtime, endtime-starttime, (endtime-starttime)/1000);
128 #define CAL_PROFILE_GET_TIME(input_time) 0
129 #define CAL_PROFILE_PRINT(starttime, endtime)
132 #define CAL_FREE(ptr) \
140 /* Thread-local storage */
141 #if defined(CAL_IPC_SERVER)
143 #elif defined(CAL_IPC_CLIENT)
145 #else /* CAL_NATIVE */
149 #define CALENDAR_FEATURE "http://tizen.org/feature/calendar"
150 #if defined(CAL_IPC_CLIENT)
151 #define CHECK_CALENDAR_SUPPORTED(feature_name) \
153 bool is_supported = false; \
154 if (!system_info_get_platform_bool(feature_name, &is_supported)) { \
155 if (is_supported == false) { \
156 LOGE("[%s] feature is disabled", feature_name); \
157 return CALENDAR_ERROR_NOT_SUPPORTED; \
160 LOGE("Error - Feature getting from System Info"); \
161 return CALENDAR_ERROR_SYSTEM; \
165 #define CHECK_CALENDAR_SUPPORTED(feature_name)
168 #endif /* __CAL_INTERNAL_H__ */