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