1. Changed license year
[apps/home/mobileprint.git] / mobileprint / smsc / include / smsc_debug.h
1 /*
2 *  Mobileprint
3 *
4 * Copyright 2013  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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
20 #ifndef _SMSC_DEBUG_H_INCLUDED_
21 #define _SMSC_DEBUG_H_INCLUDED_
22
23 //#define SMSC_DEBUG_SILENT
24 #ifdef SMSC_DEBUG_SILENT
25 #define SMSC_DEBUG
26 #define SMSC_TRACE_BEGIN
27 #define SMSC_TRACE_END
28 #else /* !SMSC_DEBUG_SILENT */
29
30 /*#define SMSC_DEBUG_STANDALONE*/
31 #ifdef SMSC_DEBUG_STANDALONE
32
33 /* standalone debugging */
34 #include <stdio.h>
35 #define SMSC_DEBUG(fmt, arg...)         do { \
36                 printf("DEBUG: %s: " fmt "\n", __FUNCTION__, ##arg); } while (0)
37 #define SMSC_TRACE_BEGIN        SMSC_DEBUG("TRACE: %s enter", __FUNCTION__)
38 #define SMSC_TRACE_END          SMSC_DEBUG("TRACE: %s leave", __FUNCTION__)
39
40 #define SMSC_IF_FREE_MEM(mem) \
41         do { \
42                 if(mem) { \
43                         free(mem); \
44                         mem = NULL; \
45                 } \
46         } while (0)
47 #define SMSC_RET_IF(expr, fmt, args...) \
48         do { \
49                 if(expr) { \
50                         PTS_PRT("[%s] Return, message "fmt, #expr, ##args );\
51                         return; \
52                 } \
53         } while (0)
54 #define SMSC_RETV_IF(expr, val, fmt, args...) \
55         do { \
56                 if(expr) { \
57                         PTS_PRT("[%s] Return value, message "fmt, #expr, ##args );\
58                         return (val); \
59                 } \
60         } while (0)
61
62 #else /* !SMSC_DEBUG_STANDALONE */
63
64 #include <pts_debug.h>
65 #define SMSC_DEBUG(fmt, arg...)         PTS_DEBUG(fmt, ##arg)
66 #define SMSC_TRACE_BEGIN                PTS_TRACE_BEGIN
67 #define SMSC_TRACE_END                  PTS_TRACE_END
68
69 #define SMSC_IF_FREE_MEM                PTS_IF_FREE_MEM
70 #define SMSC_RET_IF                     PTS_RET_IF
71 #define SMSC_RETV_IF                    PTS_RETV_IF
72
73 #endif /* SMSC_DEBUG_STANDALONE */
74 #endif /* SMSC_DEBUG_SILENT */
75
76
77 #endif /* _SMSC_DEBUG_H_INCLUDED_ */
78