annotate src/debug.c @ 395:fbe51207b963

changes to build on centos 6
author Carl Byington <carl@five-ten-sg.com>
date Sun, 12 Jan 2020 14:10:17 -0800
parents 7a91e30826d8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48
f66078abed38 more fixes for 64 bit format
carl
parents: 46
diff changeset
1 #include "define.h"
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
2
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
3
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
4 struct pst_debug_func {
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
5 char * name;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
6 struct pst_debug_func *next;
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
7 };
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
8
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
9
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
10 #define NUM_COL 32
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
11 #define MAX_DEPTH 32
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
12
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
13 static struct pst_debug_func *func_head = NULL;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
14 static int func_depth = 0;
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
15 static int pst_debuglevel = 0;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
16 static char indent[MAX_DEPTH*4+1];
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
17 static FILE *debug_fp = NULL;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
18 #ifdef HAVE_SEMAPHORE_H
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
19 static sem_t* debug_mutex = NULL;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
20 #endif
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
21
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
22
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
23 void pst_debug_setlevel(int level)
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
24 {
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
25 pst_debuglevel = level;
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
26 }
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
27
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
28 void pst_debug_lock()
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
29 {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
30 #ifdef HAVE_SEMAPHORE_H
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
31 if (debug_mutex) sem_wait(debug_mutex);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
32 #endif
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
33 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
34
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
35
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
36 void pst_debug_unlock()
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
37 {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
38 #ifdef HAVE_SEMAPHORE_H
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
39 if (debug_mutex) sem_post(debug_mutex);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
40 #endif
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
41 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
42
176
ac6e22c8a9cf build separate libpst, libpst-libs, libpst-devel rpms.
Carl Byington <carl@five-ten-sg.com>
parents: 172
diff changeset
43
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
44 void pst_debug_init(const char* fname, void* output_mutex) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
45 #ifdef HAVE_SEMAPHORE_H
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
46 debug_mutex = (sem_t*)output_mutex;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
47 #endif
260
156cf548c764 adding more debug code
Carl Byington <carl@five-ten-sg.com>
parents: 202
diff changeset
48 memset(indent, ' ', MAX_DEPTH*4);
156cf548c764 adding more debug code
Carl Byington <carl@five-ten-sg.com>
parents: 202
diff changeset
49 indent[MAX_DEPTH*4] = '\0';
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
50 if (debug_fp) pst_debug_close();
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
51 if (!fname) return;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
52 if ((debug_fp = fopen(fname, "wb")) == NULL) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
53 fprintf(stderr, "Opening of file %s failed\n", fname);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
54 exit(1);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
55 }
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
56 }
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
57
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
58
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
59 void pst_debug_func(int level, const char* function) {
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
60 if (pst_debuglevel > level) return;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
61 struct pst_debug_func *func_ptr = pst_malloc (sizeof(struct pst_debug_func));
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
62 func_ptr->name = strdup(function);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
63 func_ptr->next = func_head;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
64 func_head = func_ptr;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
65 func_depth++;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
66 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
67
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
68
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
69 void pst_debug_func_ret(int level) {
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
70 if (pst_debuglevel > level) return;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
71 //remove the head item
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
72 struct pst_debug_func *func_ptr = func_head;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
73 if (func_head) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
74 func_head = func_head->next;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
75 free(func_ptr->name);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
76 free(func_ptr);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
77 func_depth--;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
78 } else {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
79 DIE(("function list is empty!\n"));
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
80 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
81 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
82
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
83
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
84 static void pst_debug_info(int level, int line, const char* file);
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
85 static void pst_debug_info(int level, int line, const char* file) {
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
86 if (pst_debuglevel > level) return;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
87 int le = (func_depth > MAX_DEPTH) ? MAX_DEPTH : func_depth;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
88 if (le > 0) le--;
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
89 char *func = (func_head ? func_head->name : "No Function");
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
90 pst_debug_lock();
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
91 fprintf(debug_fp, "%06d %.*s%s %s(%d) ", getpid(), le*4, indent, func, file, line);
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
92 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
93
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
94
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
95 void pst_debug(int level, int line, const char* file, const char *fmt, ...) {
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
96 if (pst_debuglevel > level) return;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
97 if (debug_fp) {
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
98 pst_debug_info(level, line, file);
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
99 va_list ap;
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
100 va_start(ap,fmt);
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
101 vfprintf(debug_fp, fmt, ap);
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
102 va_end(ap);
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
103 fflush(debug_fp);
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
104 pst_debug_unlock();
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
105 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
106 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
107
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
108
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
109 void pst_debug_hexdump(int level, int line, const char *file, const char *buf, size_t size, int cols, int delta) {
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
110 if (pst_debuglevel > level) return;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
111 if (debug_fp) {
350
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
112 pst_debug_info(level, line, file);
7a91e30826d8 Hans Liss - debug level output
Carl Byington <carl@five-ten-sg.com>
parents: 289
diff changeset
113 pst_debug_hexdumper(debug_fp, buf, size, cols, delta);
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
114 pst_debug_unlock();
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
115 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
116 }
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
117
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
118
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
119 void pst_debug_hexdumper(FILE *out, const char *buf, size_t size, int cols, int delta) {
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
120 int le = (func_depth > MAX_DEPTH) ? MAX_DEPTH : func_depth;
70
b12f4e50e2e8 Patch from Joachim Metz <joachim.metz@gmail.com> for 64 bit compile.
Carl Byington <carl@five-ten-sg.com>
parents: 48
diff changeset
121 size_t off = 0, toff;
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
122 int count = 0;
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
123
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
124 if (!out) return; // no file
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
125
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
126 if (cols == -1) cols = NUM_COL;
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
127 fprintf(out, "\n");
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
128 while (off < size) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
129 fprintf(out, "%06d %.*s%06"PRIx64"\t:", getpid(), le*4, indent, (int64_t)(off+delta));
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
130 toff = off;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
131 while (count < cols && off < size) {
73
3cb02cb1e6cd Patch from Robert Simpson to fix doubly-linked list in the cache_ptr code, and allow arrays of unicode strings (without converting them).
Carl Byington <carl@five-ten-sg.com>
parents: 70
diff changeset
132 fprintf(out, "%02hhx ", (unsigned char)buf[off]);
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
133 off++; count++;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
134 }
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
135 off = toff;
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
136 while (count < cols) {
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
137 // only happens at end of block to pad the text over to the text column
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
138 fprintf(out, " ");
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
139 count++;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
140 }
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
141 count = 0;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
142 fprintf(out, ":");
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
143 while (count < cols && off < size) {
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
144 fprintf(out, "%c", isgraph(buf[off])?buf[off]:'.');
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
145 off++; count ++;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
146 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
147
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
148 fprintf(out, "\n");
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
149 count=0;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
150 }
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
151
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
152 fprintf(out, "\n");
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
153 fflush(out);
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
154 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
155
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
156
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
157 void pst_debug_close(void) {
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
158 while (func_head) {
202
2f38c4ce606f remove readpstlog, switch to plain ascii debug log files
Carl Byington <carl@five-ten-sg.com>
parents: 176
diff changeset
159 struct pst_debug_func *func_ptr = func_head;
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
160 func_head = func_head->next;
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
161 free(func_ptr->name);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
162 free(func_ptr);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
163 }
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
164 if (debug_fp) fclose(debug_fp);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
165 debug_fp = NULL;
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
166 }
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
167
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
168
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
169 void *pst_malloc(size_t size) {
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
170 void *mem = malloc(size);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
171 if (!mem) {
172
6954d315aaa8 move version-info into main configure.in, and set it properly.
Carl Byington <carl@five-ten-sg.com>
parents: 129
diff changeset
172 fprintf(stderr, "pst_malloc: Out Of memory [req: %ld]\n", (long)size);
46
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
173 exit(1);
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
174 }
b2a7f2e0926a more fixes for 64 bit format
carl
parents: 43
diff changeset
175 return mem;
33
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
176 }
12cac756bc05 enable -d option, but if not specified, don't generate a debug file
carl
parents: 31
diff changeset
177
289
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
178
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
179 void *pst_realloc(void *ptr, size_t size) {
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
180 void *mem = realloc(ptr, size);
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
181 if (!mem) {
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
182 fprintf(stderr, "pst_realloc: Out Of memory [req: %ld]\n", (long)size);
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
183 exit(1);
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
184 }
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
185 return mem;
cc8ee701f190 pst_block_offset elements are unsigned; consistent usage of pst_malloc and pst_realloc
Carl Byington <carl@five-ten-sg.com>
parents: 260
diff changeset
186 }