comparison src/define.h @ 46:b2a7f2e0926a

more fixes for 64 bit format
author carl
date Sat, 12 Jan 2008 15:20:53 -0800
parents f6db1f060a95
children f66078abed38
comparison
equal deleted inserted replaced
45:b961bcdadd0e 46:b2a7f2e0926a
49 #include <netinet/in.h> 49 #include <netinet/in.h>
50 #include <unistd.h> 50 #include <unistd.h>
51 #endif 51 #endif
52 52
53 53
54 void _pst_debug(char *fmt, ...); 54 void pst_debug(char *fmt, ...);
55 void _pst_debug_hexdump(FILE* out, unsigned char* buf, size_t size, int col, int delta); 55 void pst_debug_hexdumper(FILE* out, unsigned char* buf, size_t size, int col, int delta);
56 void _pst_debug_hexprint(char *data, int size); 56 void pst_debug_hexprint(char *data, int size);
57 57
58 void _debug_init(char *fname); 58 void pst_debug_init(char *fname);
59 void _debug_msg_info (int line, char *file, int type); 59 void pst_debug_msg_info (int line, char *file, int type);
60 void _debug_msg_text(char* fmt, ...); 60 void pst_debug_msg_text(char* fmt, ...);
61 void _debug_hexdump(unsigned char *x, int y, int cols, int delta); 61 void pst_debug_hexdump(unsigned char *x, size_t y, int cols, int delta);
62 void _debug_func(char *function); 62 void pst_debug_func(char *function);
63 void _debug_func_ret(); 63 void pst_debug_func_ret();
64 void _debug_close(void); 64 void pst_debug_close(void);
65 void _debug_write(); 65 void pst_debug_write();
66 66
67 void * xmalloc(size_t size); 67 void * xmalloc(size_t size);
68 68
69 #define MESSAGEPRINT(x,y) {_debug_msg_info(__LINE__,__FILE__,y);\ 69 #define MESSAGEPRINT(x,y) {pst_debug_msg_info(__LINE__,__FILE__,y);\
70 _debug_msg_text x;} 70 pst_debug_msg_text x;}
71 71
72 #define LOGSTOP() {MESSAGESTOP();DEBUGSTOP();} 72 #define LOGSTOP() {MESSAGESTOP();DEBUGSTOP();}
73 73
74 #define DIE(x) {\ 74 #define DIE(x) {\
75 MESSAGEPRINT(x, 0);\ 75 MESSAGEPRINT(x, 0);\
80 MESSAGEPRINT(x, 0);\ 80 MESSAGEPRINT(x, 0);\
81 printf x;\ 81 printf x;\
82 } 82 }
83 83
84 #ifdef DEBUGPRINT 84 #ifdef DEBUGPRINT
85 #define DEBUG_PRINT(x) _pst_debug x; 85 #define DEBUG_PRINT(x) pst_debug x;
86 #else 86 #else
87 #define DEBUG_PRINT(x) {} 87 #define DEBUG_PRINT(x) {}
88 #endif 88 #endif
89 89
90 #ifdef DEBUG_MODE_GEN 90 #ifdef DEBUG_MODE_GEN
99 #define DEBUG_INDEX(x) {} 99 #define DEBUG_INDEX(x) {}
100 #endif 100 #endif
101 101
102 #ifdef DEBUG_MODE_EMAIL 102 #ifdef DEBUG_MODE_EMAIL
103 #define DEBUG_EMAIL(x) MESSAGEPRINT(x, DEBUG_EMAIL_NO); 103 #define DEBUG_EMAIL(x) MESSAGEPRINT(x, DEBUG_EMAIL_NO);
104 #define DEBUG_EMAIL_HEXPRINT(x,y) {_debug_msg_info(__LINE__, __FILE__, 11);\ 104 #define DEBUG_EMAIL_HEXPRINT(x,y) {pst_debug_msg_info(__LINE__, __FILE__, 11);\
105 _debug_hexdump(x, y, 0x10, 0);} 105 pst_debug_hexdump(x, y, 0x10, 0);}
106 #else 106 #else
107 #define DEBUG_EMAIL(x) {} 107 #define DEBUG_EMAIL(x) {}
108 #define DEBUG_EMAIL_HEXPRINT(x,y) {} 108 #define DEBUG_EMAIL_HEXPRINT(x,y) {}
109 #endif 109 #endif
110 110
144 #define DEBUG_DECRYPT(x) {} 144 #define DEBUG_DECRYPT(x) {}
145 #endif 145 #endif
146 146
147 #ifdef DEBUG_MODE_HEXDUMP 147 #ifdef DEBUG_MODE_HEXDUMP
148 #define DEBUG_HEXDUMP(x, s)\ 148 #define DEBUG_HEXDUMP(x, s)\
149 {_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\ 149 {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\
150 _debug_hexdump(x, s, 0x10, 0);} 150 pst_debug_hexdump(x, s, 0x10, 0);}
151 #define DEBUG_HEXDUMPC(x, s, c)\ 151 #define DEBUG_HEXDUMPC(x, s, c)\
152 {_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\ 152 {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_HEXDUMP_NO);\
153 _debug_hexdump(x, s, c, 0);} 153 pst_debug_hexdump(x, s, c, 0);}
154 #else 154 #else
155 #define DEBUG_HEXDUMP(x, s) {} 155 #define DEBUG_HEXDUMP(x, s) {}
156 #define DEBUG_HEXDUMPC(x, s, c) {} 156 #define DEBUG_HEXDUMPC(x, s, c) {}
157 #endif 157 #endif
158 158
159 #define DEBUG_FILE(x) {_debug_msg_info(__LINE__, __FILE__, DEBUG_FILE_NO);\ 159 #define DEBUG_FILE(x) {pst_debug_msg_info(__LINE__, __FILE__, DEBUG_FILE_NO);\
160 _debug_msg_text x;} 160 pst_debug_msg_text x;}
161 161
162 #ifdef DEBUG_MODE_FUNC 162 #ifdef DEBUG_MODE_FUNC
163 # define DEBUG_ENT(x) \ 163 # define DEBUG_ENT(x) \
164 { \ 164 { \
165 _debug_func(x); \ 165 pst_debug_func(x); \
166 MESSAGEPRINT(("Entering function\n"),DEBUG_FUNCENT_NO); \ 166 MESSAGEPRINT(("Entering function\n"),DEBUG_FUNCENT_NO); \
167 } 167 }
168 # define DEBUG_RET() \ 168 # define DEBUG_RET() \
169 { \ 169 { \
170 MESSAGEPRINT(("Leaving function\n"),DEBUG_FUNCRET_NO); \ 170 MESSAGEPRINT(("Leaving function\n"),DEBUG_FUNCRET_NO); \
171 _debug_func_ret(); \ 171 pst_debug_func_ret(); \
172 } 172 }
173 #else 173 #else
174 # define DEBUG_ENT(x) {} 174 # define DEBUG_ENT(x) {}
175 # define DEBUG_RET() {} 175 # define DEBUG_RET() {}
176 #endif 176 #endif
177 177
178 #define DEBUG_INIT(fname) {_debug_init(fname);} 178 #define DEBUG_INIT(fname) {pst_debug_init(fname);}
179 #define DEBUG_CLOSE() {_debug_close();} 179 #define DEBUG_CLOSE() {pst_debug_close();}
180 #define DEBUG_REGISTER_CLOSE() {if(atexit(_debug_close)!=0) fprintf(stderr, "Error registering atexit function\n");} 180 #define DEBUG_REGISTER_CLOSE() {if(atexit(pst_debug_close)!=0) fprintf(stderr, "Error registering atexit function\n");}
181 181
182 #define RET_DERROR(res, ret_val, x)\ 182 #define RET_DERROR(res, ret_val, x)\
183 if (res) { DIE(x);} 183 if (res) { DIE(x);}
184 184
185 #define RET_ERROR(res, ret_val)\ 185 #define RET_ERROR(res, ret_val)\
186 if (res) {return ret_val;} 186 if (res) {return ret_val;}
187 187
188 #define DEBUG_VERSION 1 188 #define DEBUG_VERSION 1
189 struct _debug_file_rec_m { 189 struct pst_debug_file_rec_m {
190 unsigned short int funcname; 190 unsigned short int funcname;
191 unsigned short int filename; 191 unsigned short int filename;
192 unsigned short int text; 192 unsigned short int text;
193 unsigned short int end; 193 unsigned short int end;
194 unsigned int line; 194 unsigned int line;
195 unsigned int type; 195 unsigned int type;
196 }; 196 };
197 197
198 struct _debug_file_rec_l { 198 struct pst_debug_file_rec_l {
199 unsigned int funcname; 199 unsigned int funcname;
200 unsigned int filename; 200 unsigned int filename;
201 unsigned int text; 201 unsigned int text;
202 unsigned int end; 202 unsigned int end;
203 unsigned int line; 203 unsigned int line;