comparison src/debug.c @ 43:f6db1f060a95

start on outlook 2003 64 bit format
author carl
date Sun, 06 Jan 2008 14:47:06 -0800
parents ddfb25318812
children b2a7f2e0926a
comparison
equal deleted inserted replaced
42:7a97f50c39c5 43:f6db1f060a95
244 244
245 void _debug_write() { 245 void _debug_write() {
246 size_t size, ptr, funcname, filename, text, end; 246 size_t size, ptr, funcname, filename, text, end;
247 char *buf = NULL, rec_type; 247 char *buf = NULL, rec_type;
248 if (!debug_fp) return; // no file 248 if (!debug_fp) return; // no file
249 long index_pos = ftell (debug_fp), file_pos = index_pos; 249 off_t index_pos = ftell (debug_fp);
250 off_t file_pos = index_pos;
250 // add 2. One for the pointer to the next index, 251 // add 2. One for the pointer to the next index,
251 // one for the count of this index 252 // one for the count of this index
252 int index_size = ((curr_items+2) * sizeof(int)); 253 int index_size = ((curr_items+2) * sizeof(off_t));
253 int *index; 254 off_t *index;
254 int index_ptr = 0; 255 int index_ptr = 0;
255 struct _debug_file_rec_m mfile_rec; 256 struct _debug_file_rec_m mfile_rec;
256 struct _debug_file_rec_l lfile_rec; 257 struct _debug_file_rec_l lfile_rec;
257 258
258 if (curr_items == 0) return; // no items to write. 259 if (curr_items == 0) return; // no items to write.
327 328
328 void _debug_write_msg(struct _debug_item *item, char *fmt, va_list *ap, int size) { 329 void _debug_write_msg(struct _debug_item *item, char *fmt, va_list *ap, int size) {
329 struct _debug_file_rec_l lfile_rec; 330 struct _debug_file_rec_l lfile_rec;
330 struct _debug_file_rec_m mfile_rec; 331 struct _debug_file_rec_m mfile_rec;
331 unsigned char rec_type; 332 unsigned char rec_type;
332 int index_size = 3 * sizeof(int); 333 int index_size = 3 * sizeof(off_t);
333 int index[3]; 334 off_t index[3];
334 int index_pos, file_pos; 335 off_t index_pos, file_pos;
335 char zero='\0'; 336 char zero='\0';
336 unsigned int end; 337 unsigned int end;
337 if (!debug_fp) return; // no file 338 if (!debug_fp) return; // no file
338 index[0] = 1; //only one item in this index 339 index[0] = 1; //only one item in this index
339 index_pos = ftell(debug_fp); 340 index_pos = ftell(debug_fp);
385 386
386 387
387 void _debug_write_hex(struct _debug_item *item, unsigned char *buf, int size, int col) { 388 void _debug_write_hex(struct _debug_item *item, unsigned char *buf, int size, int col) {
388 struct _debug_file_rec_l lfile_rec; 389 struct _debug_file_rec_l lfile_rec;
389 unsigned char rec_type; 390 unsigned char rec_type;
390 int index_size = 3 * sizeof(int); 391 int index_size = 3 * sizeof(off_t);
391 int index_pos, file_pos, index[3]; 392 off_t index_pos, file_pos, index[3];
392 char zero='\0'; 393 char zero='\0';
393 if (!debug_fp) return; // no file 394 if (!debug_fp) return; // no file
394 index[0] = 1; // only one item in this index run 395 index[0] = 1; // only one item in this index run
395 index[1] = 0; // valgrind, avoid writing uninitialized data 396 index[1] = 0; // valgrind, avoid writing uninitialized data
396 index[2] = 0; // "" 397 index[2] = 0; // ""
413 fwrite(item->function, strlen(item->function)+1, 1, debug_fp); 414 fwrite(item->function, strlen(item->function)+1, 1, debug_fp);
414 fwrite(item->file, strlen(item->file)+1, 1, debug_fp); 415 fwrite(item->file, strlen(item->file)+1, 1, debug_fp);
415 416
416 _pst_debug_hexdump(debug_fp, buf, size, col, 0); 417 _pst_debug_hexdump(debug_fp, buf, size, col, 0);
417 fwrite(&zero, 1, 1, debug_fp); 418 fwrite(&zero, 1, 1, debug_fp);
418 lfile_rec.end = ftell(debug_fp)-file_pos; 419 lfile_rec.end = ftell(debug_fp) - file_pos;
419 420
420 index[2] = ftell(debug_fp); 421 index[2] = ftell(debug_fp);
421 fseek(debug_fp, index_pos, SEEK_SET); 422 fseek(debug_fp, index_pos, SEEK_SET);
422 fwrite(index, index_size, 1, debug_fp); 423 fwrite(index, index_size, 1, debug_fp);
423 fwrite(&rec_type, 1, sizeof(char), debug_fp); 424 fwrite(&rec_type, 1, sizeof(char), debug_fp);