diff options
author | PA4WDH | 2023-05-20 17:17:43 +0200 |
---|---|---|
committer | PA4WDH | 2023-05-20 17:17:43 +0200 |
commit | 15d9095122c0d4f9a4dab05fb0e84d84c624e1b4 (patch) | |
tree | c6edcc0b2efe1dc68577d57de9de74ae4bf8cdd4 /debug.c | |
parent | Initial commit, POC shell script (diff) | |
download | cputemp2maxfreq-15d9095122c0d4f9a4dab05fb0e84d84c624e1b4.tar.gz cputemp2maxfreq-15d9095122c0d4f9a4dab05fb0e84d84c624e1b4.tar.bz2 cputemp2maxfreq-15d9095122c0d4f9a4dab05fb0e84d84c624e1b4.zip |
Translate POC to C code0.1
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 71 |
1 files changed, 71 insertions, 0 deletions
@@ -0,0 +1,71 @@ +#include "debug.h" + +#ifdef NEED_DEBUG_HELPER +#include <stdio.h> +#include <time.h> +#include <sys/time.h> + +void debug_print_time() +{ + struct timeval debug_tv; + struct tm *debug_tm; + char debug_buffer[10]; + + gettimeofday(&debug_tv,NULL); + debug_tm=localtime(&debug_tv.tv_sec); + strftime(debug_buffer,10, "%T",debug_tm); + fprintf(stderr,"%s.%06d: ",debug_buffer,(int)debug_tv.tv_usec); +} + +#endif + +#ifdef NEED_HEXDUMP_HELPER +#include <stdio.h> + +void hexdump(unsigned char *data,int len) +{ + int count; + int count2; + int max; + + for(count=0;count<len;count+=16) + { +#ifdef SET_DEBUG_PRINT_PREFIX + fprintf(stderr,"%s",SET_DEBUG_PRINT_PREFIX); +#endif + fprintf(stderr,"%04x ",count); + + max=count+16; + if (max>len) max=len; + + for(count2=count;count2<max;count2++) + { + if (count2%8==0) fprintf(stderr," "); + fprintf(stderr,"%02x ",data[count2]); + } + + if (max<count+16) + { + for(count2=max;count2<count+16;count2++) + { + if (count2%8==0) fprintf(stderr," "); + fprintf(stderr," "); + } + } + fprintf(stderr," "); + + for(count2=count;count2<max;count2++) + { + if (count2%8==0) fprintf(stderr," "); + if ((data[count2]>=32) && (data[count2]<127)) + { + fprintf(stderr,"%c",data[count2]); + } else { + fprintf(stderr,"."); + } + } + + fprintf(stderr,"\n"); + } +} +#endif |