tizen_2.0_build
[framework/pim/calendar-service.git] / include / cals-internal.h
1 /*
2  * Calendar Service
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19 #ifndef __CALENDAR_SVC_INTERNAL_H__
20 #define __CALENDAR_SVC_INTERNAL_H__
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <alarm.h>
25
26 #define EVENT_UPDATE "calendar_event_update"
27 #define CALENDARBOOK_UPDATE "calendar_book_update"
28 #define TASK_UPDATE "task_update"
29
30 #ifndef API
31 #define API __attribute__ ((visibility("default")))
32 #endif
33
34 #define SAFE_STRDUP(src) (src)?strdup((char *)src):NULL
35
36 #define CALS_DEBUGGING
37
38 #define LOG_TAG "CALENDAR_SVC"
39 #include <dlog.h>
40 #define DLOG(prio, fmt, arg...) \
41   do { SLOG(prio, LOG_TAG, fmt, ##arg); } while(0);
42 #define INFO(fmt, arg...) SLOGI(fmt, ##arg)
43 #define WARN(fmt, arg...) SLOGW("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg)
44 #define ERR(fmt, arg...) SLOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg)
45 #define DBG(fmt, arg...) SLOGD("%s:" fmt, __FUNCTION__, ##arg)
46
47 //#define CALS_DEBUGGING
48 #ifdef CALS_DEBUGGING
49 #define CALS_FN_CALL DBG(">>>>>>>>%s called", __FUNCTION__)
50 #define CALS_FN_END DBG("<<<<<<<<%s ended", __FUNCTION__)
51 #define CALS_DBG(fmt, arg...) DBG("%d " fmt, __LINE__, ##arg)
52 #else /* CALS_DEBUGGING */
53 #define CALS_FN_CALL
54 #define CALS_FN_END
55 #define CALS_DBG(fmt, arg...)
56 #endif /* CALS_DEBUGGING */
57
58
59 #define TMDUMP(_X_)\
60 {\
61         ERR("tm(%d/%d/%d %d:%d)",(_X_).tm_year+1900,(_X_).tm_mon+1,(_X_).tm_mday,(_X_).tm_hour,(_X_).tm_min);\
62 }
63
64 #define warn_if(expr, fmt, arg...) do { \
65         if (expr) { \
66                 WARN(fmt, ##arg); \
67         } \
68 } while (0)
69 #define ret_if(expr) do { \
70         if (expr) { \
71                 ERR("(%s)", #expr); \
72                 return; \
73         } \
74 } while (0)
75 #define retv_if(expr, val) do { \
76         if (expr) { \
77                 ERR("(%s)", #expr); \
78                 return (val); \
79         } \
80 } while (0)
81 #define retm_if(expr, fmt, arg...) do { \
82         if (expr) { \
83                 ERR(fmt, ##arg); \
84                 return; \
85         } \
86 } while (0)
87 #define retvm_if(expr, val, fmt, arg...) do { \
88         if (expr) { \
89                 ERR(fmt, ##arg); \
90                 return (val); \
91         } \
92 } while (0)
93
94 #define retex_if(expr, val, fmt, arg...) do { \
95           if(expr) { \
96                  ERR(fmt, ##arg); \
97                  val; \
98                  goto CATCH; \
99           } \
100         } while (0);
101
102 #define CAL_PROFILE
103 #ifdef CAL_PROFILE
104 #define CAL_PROFILE_GET_TIME() (clock() / (CLOCKS_PER_SEC / 1000));
105 #define CAL_PROFILE_PRINT(starttime,endtime) ERR("%ld ~ %ld : %ld(%d sec) msec",starttime,endtime,endtime-starttime,(endtime-starttime)/1000);
106 #else
107 #define CAL_PROFILE_GET_TIME(input_time) 0
108 #define CAL_PROFILE_PRINT(starttime,endtime)
109 #endif
110
111 #define CAL_FREE(ptr) \
112  do { \
113   free(ptr); \
114   ptr = NULL; \
115  }while(0);
116
117 #endif /* __CALENDAR_SVC_INTERNAL_H__ */
118