]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/tools/assert_macro.h
Backport from BEE
[bacula/bacula] / bacula / src / tools / assert_macro.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from many
7    others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    Bacula® is a registered trademark of Kern Sibbald.
15 */
16 /**
17  * Assertion definitions
18  *
19  */
20
21
22 #ifndef _ASSERT_MACRO_H
23 #define _ASSERT_MACRO_H 1
24
25 /* Assertions definitions */
26
27 /* check valid pointer if not return */
28 #ifndef ASSERT_NVAL_RET
29 #define ASSERT_NVAL_RET(value) \
30    if ( ! value ){ \
31       return; \
32    }
33 #endif
34
35 /* check an error if true return */
36 #ifndef ASSERT_VAL_RET
37 #define ASSERT_VAL_RET(value) \
38    if ( value ){ \
39       return; \
40    }
41 #endif
42
43 /* check valid pointer with Null return */
44 #ifndef ASSERT_NVAL_RET_NULL
45 #define ASSERT_NVAL_RET_NULL(value) \
46    if ( ! value ) \
47    { \
48       return NULL; \
49    }
50 #endif
51
52 /* if value then Null return */
53 #ifndef ASSERT_VAL_RET_NULL
54 #define ASSERT_VAL_RET_NULL(value) \
55    if ( value ) \
56    { \
57       return NULL; \
58    }
59 #endif
60
61 /* check valid pointer with int/err return */
62 #ifndef ASSERT_NVAL_RET_ONE
63 #define ASSERT_NVAL_RET_ONE(value) \
64    if ( ! value ) \
65    { \
66       return 1; \
67    }
68 #endif
69
70 /* check valid pointer with int/err return */
71 #ifndef ASSERT_NVAL_RET_NONE
72 #define ASSERT_NVAL_RET_NONE(value) \
73    if ( ! value ) \
74    { \
75       return -1; \
76    }
77 #endif
78
79 /* check error if not exit with error */
80 #ifndef ASSERT_NVAL_EXIT_ONE
81 #define ASSERT_NVAL_EXIT_ONE(value) \
82    if ( ! value ){ \
83       exit ( 1 ); \
84    }
85 #endif
86
87 /* check error if not exit with error */
88 #ifndef ASSERT_NVAL_EXIT_E
89 #define ASSERT_NVAL_EXIT_E(value,ev) \
90    if ( ! value ){ \
91       exit ( ev ); \
92    }
93 #endif
94
95 /* check error if not return zero */
96 #ifndef ASSERT_NVAL_RET_ZERO
97 #define ASSERT_NVAL_RET_ZERO(value) \
98    if ( ! value ){ \
99       return 0; \
100    }
101 #endif
102
103 /* check error if not return value */
104 #ifndef ASSERT_NVAL_RET_V
105 #define ASSERT_NVAL_RET_V(value,rv) \
106    if ( ! value ){ \
107       return rv; \
108    }
109 #endif
110
111 /* checks error value then int/err return */
112 #ifndef ASSERT_VAL_RET_ONE
113 #define ASSERT_VAL_RET_ONE(value) \
114    if ( value ) \
115    { \
116       return 1; \
117    }
118 #endif
119
120 /* checks error value then int/err return */
121 #ifndef ASSERT_VAL_RET_NONE
122 #define ASSERT_VAL_RET_NONE(value) \
123    if ( value ) \
124    { \
125       return -1; \
126    }
127 #endif
128
129 /* checks error value then exit one */
130 #ifndef ASSERT_VAL_EXIT_ONE
131 #define ASSERT_VAL_EXIT_ONE(value) \
132    if ( value ) \
133    { \
134       exit (1); \
135    }
136 #endif
137
138 /* check error if not return zero */
139 #ifndef ASSERT_VAL_RET_ZERO
140 #define ASSERT_VAL_RET_ZERO(value) \
141    if ( value ){ \
142       return 0; \
143    }
144 #endif
145
146 /* check error if not return value */
147 #ifndef ASSERT_VAL_RET_V
148 #define ASSERT_VAL_RET_V(value,rv) \
149    if ( value ){ \
150       return rv; \
151    }
152 #endif
153
154 #endif /* _ASSERT_MACRO_H */