00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include <jf/jf_config.h>
00021
00022
00023
00024
#ifdef HAVE_STDARG_H
00025
# include <stdarg.h>
00026
#endif
00027
#ifdef HAVE_STDIO_H
00028
# include <stdio.h>
00029
#endif
00030
00031
#include <jf/jf_trace.h>
00032
00033
00034
00035 int jf_trace(
const char *fmt, ...)
00036 {
00037 va_list args;
00038
00039 va_start(args, fmt);
00040
#ifdef HAVE_VFPRINTF
00041
vfprintf(stderr, fmt, args);
00042
#else
00043
# error "vfprintf is necessary for jf_trace function!"
00044
#endif
00045
va_end(args);
00046
return 0;
00047 }
00048
00049
00050
00051 void jf_trace_hex_data(
const byte_t *data,
jf_word_t size,
00052 FILE *out_stream)
00053 {
00054
jf_word_t i;
00055
00056
for (i = 0; i < size; ++i) {
00057 fprintf(out_stream,
"%02x ", (data[i] & 0xff));
00058 }
00059 }
00060
00061
00062
00063 void jf_trace_text_data(
const byte_t *data,
jf_word_t size,
00064 FILE *out_stream)
00065 {
00066
jf_word_t i;
00067
00068
for (i = 0; i < size; ++i) {
00069
if (data[i] >= (
byte_t)
' ' && data[i] < (
byte_t)0x80)
00070 putc((
int)(data[i] & 0xff), out_stream);
00071
else
00072 putc((
int)
' ', out_stream);
00073 }
00074 }
00075
00076
00077