apply FSL(Flora Software License)
[apps/home/memo.git] / extend / gravel.h
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   * 
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   * 
8   *     http://www.tizenopensource.org/license
9   * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17 #ifndef __GRAVEL_H__
18 #define __GRAVEL_H__
19
20 #include <dlog.h>
21
22 /* use prefix 'P' means print */
23 #define PTAG LOGD("[%s : %d]\n", __FILE__, __LINE__)
24 #define PLOG(fmt, arg...) LOGD(" ## "fmt, ##arg)
25 #define PFUNC_ENTER LOGD("ENTER : %s\n", __func__)
26 #define PFUNC_LEAVE LOGD("LEAVE : %s\n", __func__)
27
28 #define ARRAY_SIZE(array) \
29         ((int)(sizeof(array) / sizeof(array[0])))
30
31 #define STR_EQUAL(str1, str2) \
32         (strcmp(str1, str2) == 0)
33
34 #define SSTRLEN(str)\
35         (str == NULL ? 0 : strlen(str))\
36
37 #define sncat(to, size, from) \
38         strncat(to, from, size-strlen(to)-1)
39
40 #define sncatprintf(s, size, fmt, args...) \
41         snprintf(s+strlen(s), size-strlen(s), fmt, ##args)
42
43 #define SMALLOC(Type)\
44         (Type *)calloc(1, sizeof(Type))\
45
46 #define SFREE(var)\
47         if (var != NULL) {\
48                 free(var);\
49                 var = NULL;\
50         } \
51
52 #define RETIF(condition)\
53         if (condition) return
54
55 #define RETVIF(condition, val)\
56         if (condition) return val
57
58 #endif                          /* __GRAVEL_H__ */