00001
00014 #include "contributors.h"
00015 #include "global.h"
00016 #include "mbuffer.h"
00017
00018
00019 #if TRACE
00020
00027 void dectracebitcnt(int count)
00028 {
00029 p_Dec->bitcounter -= count;
00030 }
00031
00039 void tracebits(
00040 const char *trace_str,
00041 int len,
00042 int info,
00043 int value1)
00044 {
00045 int i, chars;
00046
00047
00048 if(len>=64)
00049 {
00050 snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work");
00051 error (errortext, 600);
00052 }
00053
00054 putc('@', p_Dec->p_trace);
00055 chars = fprintf(p_Dec->p_trace, "%i", p_Dec->bitcounter);
00056 while(chars++ < 5)
00057 putc(' ',p_Dec->p_trace);
00058
00059 chars += fprintf(p_Dec->p_trace, " %s", trace_str);
00060 while(chars++ < 55)
00061 putc(' ',p_Dec->p_trace);
00062
00063
00064 if(len<15)
00065 {
00066 for(i=0 ; i<15-len ; i++)
00067 fputc(' ', p_Dec->p_trace);
00068 }
00069
00070
00071 for(i=0 ; i<len/2 ; i++)
00072 {
00073 fputc('0', p_Dec->p_trace);
00074 }
00075
00076 fprintf(p_Dec->p_trace, "1");
00077
00078
00079 for(i=0 ; i<len/2 ; i++)
00080 {
00081 if (0x01 & ( info >> ((len/2-i)-1)))
00082 fputc('1', p_Dec->p_trace);
00083 else
00084 fputc('0', p_Dec->p_trace);
00085 }
00086
00087 fprintf(p_Dec->p_trace, " (%3d) \n", value1);
00088 p_Dec->bitcounter += len;
00089
00090 fflush (p_Dec->p_trace);
00091 }
00092
00099 void tracebits2(
00100 const char *trace_str,
00101 int len,
00102 int info)
00103 {
00104
00105 int i, chars;
00106
00107
00108 if(len>=64)
00109 {
00110 snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work");
00111 error (errortext, 600);
00112 }
00113
00114 putc('@', p_Dec->p_trace);
00115 chars = fprintf(p_Dec->p_trace, "%i", p_Dec->bitcounter);
00116
00117 while(chars++ < 5)
00118 putc(' ',p_Dec->p_trace);
00119
00120 chars += fprintf(p_Dec->p_trace, " %s", trace_str);
00121
00122 while(chars++ < 55)
00123 putc(' ',p_Dec->p_trace);
00124
00125
00126 if(len < 15)
00127 {
00128 for(i = 0; i < 15 - len; i++)
00129 fputc(' ', p_Dec->p_trace);
00130 }
00131
00132 p_Dec->bitcounter += len;
00133 while (len >= 32)
00134 {
00135 for(i = 0; i < 8; i++)
00136 {
00137 fputc('0', p_Dec->p_trace);
00138 }
00139 len -= 8;
00140 }
00141
00142
00143 for(i=0 ; i<len ; i++)
00144 {
00145 if (0x01 & ( info >> (len-i-1)))
00146 fputc('1', p_Dec->p_trace);
00147 else
00148 fputc('0', p_Dec->p_trace);
00149 }
00150
00151 fprintf(p_Dec->p_trace, " (%3d) \n", info);
00152
00153 fflush (p_Dec->p_trace);
00154 }
00155 #endif
00156