Mercurial > libpst
annotate src/define.h @ 59:7d5c637aaafb
General cleanup and code fixes.
Use autoscan to cleanup our autoconf system.
Use autoconf to detect when we need to use our XGetopt files and other header files.
Decode BCC field.
Fix missing LE32_CPU byte swapping for FILETIME types.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 14 Feb 2008 14:55:32 -0800 |
parents | f66078abed38 |
children | cfd6175f9334 |
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 | |
48 | 11 #include "version.h" |
16 | 12 |
13 #ifndef DEFINEH_H | |
14 #define DEFINEH_H | |
15 | |
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 | |
27 | |
28 //number of items to save in memory between writes | |
29 #define DEBUG_MAX_ITEMS 0 | |
30 | |
36 | 31 #define DEBUG_FILE_NO 1 |
32 #define DEBUG_INDEX_NO 2 | |
33 #define DEBUG_EMAIL_NO 3 | |
34 #define DEBUG_WARN_NO 4 | |
35 #define DEBUG_READ_NO 5 | |
36 #define DEBUG_INFO_NO 6 | |
37 #define DEBUG_MAIN_NO 7 | |
38 #define DEBUG_DECRYPT_NO 8 | |
39 #define DEBUG_FUNCENT_NO 9 | |
40 #define DEBUG_FUNCRET_NO 10 | |
16 | 41 #define DEBUG_HEXDUMP_NO 11 |
42 | |
43 #include <stdio.h> | |
44 #include <stdlib.h> | |
45 #include <stdarg.h> | |
59
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
46 #include <time.h> |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
47 #include <string.h> |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
48 #include <ctype.h> |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
49 #include <limits.h> |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
50 #include <wchar.h> |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
51 #include <signal.h> |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
52 #include <errno.h> |
16 | 53 |
59
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
54 #ifdef HAVE_UNISTD_H |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
55 #include <unistd.h> |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
56 #else |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
57 #include "XGetopt.h" |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
58 #ifdef HAVE_DIRECT_H |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
59 #include <direct.h> // win32 |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
60 #define chdir _chdir |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
61 #define int32_t __int32 |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
62 #endif |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
63 |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
64 #ifdef HAVE_WINDOWS_H |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
65 #include <windows.h> // win32 |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
66 #endif |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
67 #endif |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
68 |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
69 #ifdef HAVE_SYS_STAT_H |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
70 # include <sys/stat.h> //mkdir |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
71 #endif |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
72 |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
73 // for reading of directory and clearing in function mk_seperate_dir |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
74 #ifdef HAVE_SYS_TYPES_H |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
75 # include <sys/types.h> |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
76 #endif |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
77 |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
78 #ifdef HAVE_DIRENT_H |
7d5c637aaafb
General cleanup and code fixes.
Carl Byington <carl@five-ten-sg.com>
parents:
48
diff
changeset
|
79 # include <dirent.h> |
16 | 80 #endif |
81 | |
82 | |
46 | 83 void pst_debug(char *fmt, ...); |
84 void pst_debug_hexdumper(FILE* out, unsigned char* buf, size_t size, int col, int delta); | |
85 void pst_debug_hexprint(char *data, int size); | |
16 | 86 |
46 | 87 void pst_debug_init(char *fname); |
88 void pst_debug_msg_info (int line, char *file, int type); | |
89 void pst_debug_msg_text(char* fmt, ...); | |
90 void pst_debug_hexdump(unsigned char *x, size_t y, int cols, int delta); | |
91 void pst_debug_func(char *function); | |
92 void pst_debug_func_ret(); | |
93 void pst_debug_close(void); | |
94 void pst_debug_write(); | |
16 | 95 |
96 void * xmalloc(size_t size); | |
97 | |
46 | 98 #define MESSAGEPRINT(x,y) {pst_debug_msg_info(__LINE__,__FILE__,y);\ |
99 pst_debug_msg_text x;} | |
16 | 100 |
101 #define LOGSTOP() {MESSAGESTOP();DEBUGSTOP();} | |
102 | |
103 #define DIE(x) {\ | |
104 MESSAGEPRINT(x, 0);\ | |
105 printf x;\ | |
106 exit(EXIT_FAILURE);\ | |
107 } | |
108 #define WARN(x) {\ | |
109 MESSAGEPRINT(x, 0);\ | |
110 printf x;\ | |
111 } | |
112 | |
113 #ifdef DEBUGPRINT | |
46 | 114 #define DEBUG_PRINT(x) pst_debug x; |
16 | 115 #else |
116 #define DEBUG_PRINT(x) {} | |
117 #endif | |
118 | |
119 #ifdef DEBUG_MODE_GEN | |
120 #define DEBUG(x) {DEBUG_PRINT(x);} | |
121 #else | |
122 #define DEBUG(x) {} | |
123 #endif | |
124 | |
125 #ifdef DEBUG_MODE_INDEX | |
126 #define DEBUG_INDEX(x) MESSAGEPRINT(x, DEBUG_INDEX_NO); | |
127 #else | |
128 #define DEBUG_INDEX(x) {} | |
129 #endif | |
130 | |
131 #ifdef DEBUG_MODE_EMAIL | |
132 #define DEBUG_EMAIL(x) MESSAGEPRINT(x, DEBUG_EMAIL_NO); | |
46 | 133 #define DEBUG_EMAIL_HEXPRINT(x,y) {pst_debug_msg_info(__LINE__, __FILE__, 11);\ |
134 pst_debug_hexdump(x, y, 0x10, 0);} | |
16 | 135 #else |
136 #define DEBUG_EMAIL(x) {} | |
137 #define DEBUG_EMAIL_HEXPRINT(x,y) {} | |
138 #endif | |
139 | |
140 #ifdef DEBUG_MODE_WARN | |
141 #define DEBUG_WARN(x) MESSAGEPRINT(x, DEBUG_WARN_NO); | |
142 #else | |
143 #define DEBUG_WARN(x) {} | |
144 #endif | |
145 | |
146 #ifdef DEBUG_MODE_READ | |
147 #define DEBUG_READ(x) MESSAGEPRINT(x, DEBUG_READ_NO); | |
148 #else | |
149 #define DEBUG_READ(x) {} | |
150 #endif | |
151 | |
152 #ifdef DEBUG_MODE_INFO | |
153 #define DEBUG_INFO(x) MESSAGEPRINT(x, DEBUG_INFO_NO); | |
154 #else | |
155 #define DEBUG_INFO(x) {} | |
156 #endif | |
157 | |
158 #ifdef DEBUG_MODE_MAIN | |
159 #define DEBUG_MAIN(x) MESSAGEPRINT(x, DEBUG_MAIN_NO); | |
160 #else | |
161 #define DEBUG_MAIN(x) {} | |
162 #endif | |
163 | |
164 #ifdef DEBUG_MODE_CODE | |
165 #define DEBUG_CODE(x) {x} | |
166 #else | |
167 #define DEBUG_CODE(x) {} | |
168 #endif | |
169 | |
170 #ifdef DEBUG_MODE_DECRYPT | |
171 #define DEBUG_DECRYPT(x) MESSAGEPRINT(x, DEBUG_DECRYPT_NO); | |
172 #else | |
173 #define DEBUG_DECRYPT(x) {} | |
174 #endif | |
175 | |
176 #ifdef DEBUG_MODE_HEXDUMP | |
177 #define DEBUG_HEXDUMP(x, s)\ | |
46 | 178 {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\ |
179 pst_debug_hexdump(x, s, 0x10, 0);} | |
16 | 180 #define DEBUG_HEXDUMPC(x, s, c)\ |
46 | 181 {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\ |
182 pst_debug_hexdump(x, s, c, 0);} | |
16 | 183 #else |
184 #define DEBUG_HEXDUMP(x, s) {} | |
185 #define DEBUG_HEXDUMPC(x, s, c) {} | |
186 #endif | |
187 | |
46 | 188 #define DEBUG_FILE(x) {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_FILE_NO);\ |
189 pst_debug_msg_text x;} | |
16 | 190 |
191 #ifdef DEBUG_MODE_FUNC | |
36 | 192 # define DEBUG_ENT(x) \ |
193 { \ | |
46 | 194 pst_debug_func(x); \ |
36 | 195 MESSAGEPRINT(("Entering function\n"),DEBUG_FUNCENT_NO); \ |
196 } | |
197 # define DEBUG_RET() \ | |
198 { \ | |
199 MESSAGEPRINT(("Leaving function\n"),DEBUG_FUNCRET_NO); \ | |
46 | 200 pst_debug_func_ret(); \ |
36 | 201 } |
16 | 202 #else |
203 # define DEBUG_ENT(x) {} | |
204 # define DEBUG_RET() {} | |
205 #endif | |
206 | |
46 | 207 #define DEBUG_INIT(fname) {pst_debug_init(fname);} |
208 #define DEBUG_CLOSE() {pst_debug_close();} | |
209 #define DEBUG_REGISTER_CLOSE() {if(atexit(pst_debug_close)!=0) fprintf(stderr, "Error registering atexit function\n");} | |
16 | 210 |
211 #define RET_DERROR(res, ret_val, x)\ | |
212 if (res) { DIE(x);} | |
213 | |
214 #define RET_ERROR(res, ret_val)\ | |
215 if (res) {return ret_val;} | |
216 | |
217 #define DEBUG_VERSION 1 | |
46 | 218 struct pst_debug_file_rec_m { |
16 | 219 unsigned short int funcname; |
220 unsigned short int filename; | |
221 unsigned short int text; | |
222 unsigned short int end; | |
223 unsigned int line; | |
224 unsigned int type; | |
225 }; | |
226 | |
46 | 227 struct pst_debug_file_rec_l { |
16 | 228 unsigned int funcname; |
229 unsigned int filename; | |
230 unsigned int text; | |
231 unsigned int end; | |
232 unsigned int line; | |
233 unsigned int type; | |
234 }; | |
235 | |
236 #endif //DEFINEH_H |