Mercurial > libpst
annotate src/define.h @ 40:be6d5329cc01 stable-0-5-11
fix unitialized variable
author | carl |
---|---|
date | Fri, 24 Aug 2007 18:57:59 -0700 |
parents | 6fe121a971c9 |
children | f6db1f060a95 |
rev | line source |
---|---|
16 | 1 /*** |
2 * define.h | |
3 * Part of the LibPST project | |
4 * Written by David Smith | |
5 * dave.s@earthcorp.com | |
6 */ | |
7 | |
31 | 8 #ifdef HAVE_CONFIG_H |
9 #include "config.h" | |
10 #endif | |
16 | 11 |
12 #ifndef DEFINEH_H | |
13 #define DEFINEH_H | |
14 | |
33
12cac756bc05
enable -d option, but if not specified, don't generate a debug file
carl
parents:
31
diff
changeset
|
15 // #ifdef DEBUG_ALL |
16 | 16 #define DEBUG_MODE_GEN |
17 #define DEBUGPRINT | |
18 #define DEBUG_MODE_WARN | |
19 #define DEBUG_MODE_READ | |
20 #define DEBUG_MODE_EMAIL | |
21 #define DEBUG_MODE_MAIN | |
22 #define DEBUG_MODE_INDEX | |
23 #define DEBUG_MODE_CODE | |
24 #define DEBUG_MODE_INFO | |
25 #define DEBUG_MODE_HEXDUMP | |
26 #define DEBUG_MODE_FUNC | |
33
12cac756bc05
enable -d option, but if not specified, don't generate a debug file
carl
parents:
31
diff
changeset
|
27 // #endif |
16 | 28 |
29 //number of items to save in memory between writes | |
30 #define DEBUG_MAX_ITEMS 0 | |
31 | |
36 | 32 #define DEBUG_FILE_NO 1 |
33 #define DEBUG_INDEX_NO 2 | |
34 #define DEBUG_EMAIL_NO 3 | |
35 #define DEBUG_WARN_NO 4 | |
36 #define DEBUG_READ_NO 5 | |
37 #define DEBUG_INFO_NO 6 | |
38 #define DEBUG_MAIN_NO 7 | |
39 #define DEBUG_DECRYPT_NO 8 | |
40 #define DEBUG_FUNCENT_NO 9 | |
41 #define DEBUG_FUNCRET_NO 10 | |
16 | 42 #define DEBUG_HEXDUMP_NO 11 |
43 | |
44 //variable number of arguments to this macro. will expand them into | |
45 // ## args, then exit with status of 1 | |
46 #include <stdio.h> | |
47 #include <stdlib.h> | |
48 #include <stdarg.h> | |
49 | |
50 #ifdef __LINUX__ | |
51 #include <netinet/in.h> | |
52 #include <unistd.h> | |
53 #endif | |
54 | |
55 | |
56 void _pst_debug(char *fmt, ...); | |
34
07177825c91b
fix signed/unsigned to allow very small pst files with only leaf nodes
carl
parents:
33
diff
changeset
|
57 void _pst_debug_hexdump(FILE* out, unsigned char* buf, size_t size, int col, int delta); |
16 | 58 void _pst_debug_hexprint(char *data, int size); |
59 | |
60 void _debug_init(char *fname); | |
61 void _debug_msg_info (int line, char *file, int type); | |
62 void _debug_msg_text(char* fmt, ...); | |
34
07177825c91b
fix signed/unsigned to allow very small pst files with only leaf nodes
carl
parents:
33
diff
changeset
|
63 void _debug_hexdump(unsigned char *x, int y, int cols, int delta); |
16 | 64 void _debug_func(char *function); |
65 void _debug_func_ret(); | |
66 void _debug_close(void); | |
67 void _debug_write(); | |
68 | |
69 void * xmalloc(size_t size); | |
70 | |
71 #define MESSAGEPRINT(x,y) {_debug_msg_info(__LINE__,__FILE__,y);\ | |
72 _debug_msg_text x;} | |
73 | |
74 #define LOGSTOP() {MESSAGESTOP();DEBUGSTOP();} | |
75 | |
76 #define DIE(x) {\ | |
77 MESSAGEPRINT(x, 0);\ | |
78 printf x;\ | |
79 exit(EXIT_FAILURE);\ | |
80 } | |
81 #define WARN(x) {\ | |
82 MESSAGEPRINT(x, 0);\ | |
83 printf x;\ | |
84 } | |
85 | |
86 #ifdef DEBUGPRINT | |
87 #define DEBUG_PRINT(x) _pst_debug x; | |
88 #else | |
89 #define DEBUG_PRINT(x) {} | |
90 #endif | |
91 | |
92 #ifdef DEBUG_MODE_GEN | |
93 #define DEBUG(x) {DEBUG_PRINT(x);} | |
94 #else | |
95 #define DEBUG(x) {} | |
96 #endif | |
97 | |
98 #ifdef DEBUG_MODE_INDEX | |
99 #define DEBUG_INDEX(x) MESSAGEPRINT(x, DEBUG_INDEX_NO); | |
100 #else | |
101 #define DEBUG_INDEX(x) {} | |
102 #endif | |
103 | |
104 #ifdef DEBUG_MODE_EMAIL | |
105 #define DEBUG_EMAIL(x) MESSAGEPRINT(x, DEBUG_EMAIL_NO); | |
106 #define DEBUG_EMAIL_HEXPRINT(x,y) {_debug_msg_info(__LINE__, __FILE__, 11);\ | |
34
07177825c91b
fix signed/unsigned to allow very small pst files with only leaf nodes
carl
parents:
33
diff
changeset
|
107 _debug_hexdump(x, y, 0x10, 0);} |
16 | 108 #else |
109 #define DEBUG_EMAIL(x) {} | |
110 #define DEBUG_EMAIL_HEXPRINT(x,y) {} | |
111 #endif | |
112 | |
113 #ifdef DEBUG_MODE_WARN | |
114 #define DEBUG_WARN(x) MESSAGEPRINT(x, DEBUG_WARN_NO); | |
115 #else | |
116 #define DEBUG_WARN(x) {} | |
117 #endif | |
118 | |
119 #ifdef DEBUG_MODE_READ | |
120 #define DEBUG_READ(x) MESSAGEPRINT(x, DEBUG_READ_NO); | |
121 #else | |
122 #define DEBUG_READ(x) {} | |
123 #endif | |
124 | |
125 #ifdef DEBUG_MODE_INFO | |
126 #define DEBUG_INFO(x) MESSAGEPRINT(x, DEBUG_INFO_NO); | |
127 #else | |
128 #define DEBUG_INFO(x) {} | |
129 #endif | |
130 | |
131 #ifdef DEBUG_MODE_MAIN | |
132 #define DEBUG_MAIN(x) MESSAGEPRINT(x, DEBUG_MAIN_NO); | |
133 #else | |
134 #define DEBUG_MAIN(x) {} | |
135 #endif | |
136 | |
137 #ifdef DEBUG_MODE_CODE | |
138 #define DEBUG_CODE(x) {x} | |
139 #else | |
140 #define DEBUG_CODE(x) {} | |
141 #endif | |
142 | |
143 #ifdef DEBUG_MODE_DECRYPT | |
144 #define DEBUG_DECRYPT(x) MESSAGEPRINT(x, DEBUG_DECRYPT_NO); | |
145 #else | |
146 #define DEBUG_DECRYPT(x) {} | |
147 #endif | |
148 | |
149 #ifdef DEBUG_MODE_HEXDUMP | |
150 #define DEBUG_HEXDUMP(x, s)\ | |
151 {_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\ | |
34
07177825c91b
fix signed/unsigned to allow very small pst files with only leaf nodes
carl
parents:
33
diff
changeset
|
152 _debug_hexdump(x, s, 0x10, 0);} |
16 | 153 #define DEBUG_HEXDUMPC(x, s, c)\ |
154 {_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\ | |
34
07177825c91b
fix signed/unsigned to allow very small pst files with only leaf nodes
carl
parents:
33
diff
changeset
|
155 _debug_hexdump(x, s, c, 0);} |
16 | 156 #else |
157 #define DEBUG_HEXDUMP(x, s) {} | |
158 #define DEBUG_HEXDUMPC(x, s, c) {} | |
159 #endif | |
160 | |
161 #define DEBUG_FILE(x) {_debug_msg_info(__LINE__, __FILE__, DEBUG_FILE_NO);\ | |
162 _debug_msg_text x;} | |
163 | |
164 #ifdef DEBUG_MODE_FUNC | |
36 | 165 # define DEBUG_ENT(x) \ |
166 { \ | |
167 _debug_func(x); \ | |
168 MESSAGEPRINT(("Entering function\n"),DEBUG_FUNCENT_NO); \ | |
169 } | |
170 # define DEBUG_RET() \ | |
171 { \ | |
172 MESSAGEPRINT(("Leaving function\n"),DEBUG_FUNCRET_NO); \ | |
173 _debug_func_ret(); \ | |
174 } | |
16 | 175 #else |
176 # define DEBUG_ENT(x) {} | |
177 # define DEBUG_RET() {} | |
178 #endif | |
179 | |
180 #define DEBUG_INIT(fname) {_debug_init(fname);} | |
181 #define DEBUG_CLOSE() {_debug_close();} | |
182 #define DEBUG_REGISTER_CLOSE() {if(atexit(_debug_close)!=0) fprintf(stderr, "Error registering atexit function\n");} | |
183 | |
184 #define RET_DERROR(res, ret_val, x)\ | |
185 if (res) { DIE(x);} | |
186 | |
187 #define RET_ERROR(res, ret_val)\ | |
188 if (res) {return ret_val;} | |
189 | |
190 #define DEBUG_VERSION 1 | |
191 struct _debug_file_rec_m { | |
192 unsigned short int funcname; | |
193 unsigned short int filename; | |
194 unsigned short int text; | |
195 unsigned short int end; | |
196 unsigned int line; | |
197 unsigned int type; | |
198 }; | |
199 | |
200 struct _debug_file_rec_l { | |
201 unsigned int funcname; | |
202 unsigned int filename; | |
203 unsigned int text; | |
204 unsigned int end; | |
205 unsigned int line; | |
206 unsigned int type; | |
207 }; | |
208 | |
209 #endif //DEFINEH_H |