Mercurial > libpst
annotate src/define.h @ 66:32f771bc9c1c
remove redundant requires from the spec file
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 26 Feb 2008 17:36:57 -0800 |
parents | cfd6175f9334 |
children | 3cb02cb1e6cd |
rev | line source |
---|---|
16 | 1 /*** |
2 * define.h | |
3 * Part of the LibPST project | |
4 * Written by David Smith | |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
5 * dave.s@earthcorp.com |
16 | 6 */ |
7 | |
31 | 8 #ifdef HAVE_CONFIG_H |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
9 #include "config.h" |
31 | 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 | |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
31 #define DEBUG_FILE_NO 1 |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
32 #define DEBUG_INDEX_NO 2 |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
33 #define DEBUG_EMAIL_NO 3 |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
34 #define DEBUG_WARN_NO 4 |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
35 #define DEBUG_READ_NO 5 |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
36 #define DEBUG_INFO_NO 6 |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
37 #define DEBUG_MAIN_NO 7 |
36 | 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);\ |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
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);\ |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
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);\ |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
189 pst_debug_msg_text x;} |
16 | 190 |
191 #ifdef DEBUG_MODE_FUNC | |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
192 # define DEBUG_ENT(x) \ |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
193 { \ |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
194 pst_debug_func(x); \ |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
195 MESSAGEPRINT(("Entering function %s\n",x),DEBUG_FUNCENT_NO); \ |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
196 } |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
197 # define DEBUG_RET() \ |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
198 { \ |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
199 MESSAGEPRINT(("Leaving function\n"),DEBUG_FUNCRET_NO); \ |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
200 pst_debug_func_ret(); \ |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
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)\ | |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
212 if (res) { DIE(x);} |
16 | 213 |
214 #define RET_ERROR(res, ret_val)\ | |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
215 if (res) {return ret_val;} |
16 | 216 |
217 #define DEBUG_VERSION 1 | |
46 | 218 struct pst_debug_file_rec_m { |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
219 unsigned short int funcname; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
220 unsigned short int filename; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
221 unsigned short int text; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
222 unsigned short int end; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
223 unsigned int line; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
224 unsigned int type; |
16 | 225 }; |
226 | |
46 | 227 struct pst_debug_file_rec_l { |
63
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
228 unsigned int funcname; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
229 unsigned int filename; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
230 unsigned int text; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
231 unsigned int end; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
232 unsigned int line; |
cfd6175f9334
Start work on pst2dii to convert to Summation dii load file format.
Carl Byington <carl@five-ten-sg.com>
parents:
59
diff
changeset
|
233 unsigned int type; |
16 | 234 }; |
235 | |
236 #endif //DEFINEH_H |