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