Improved help. Moving to 0.2.
#include <stdio.h>
#include <stdarg.h>
#include "main.h"
const int should_dump = 0;
void dump_line(const char *msg, ...)
{
va_list v;
FILE *f;
if (!should_dump) return;
va_start(v, msg);
f = fopen("/tmp/dump.txt", "a");
if (f == 0) return;
vfprintf(f, msg, v);
fclose(f);
}
void hex_dump(const char *head, const unsigned char *data, int len)
{
int i;
FILE *f;
if (!should_dump) return;
f = fopen("/tmp/dump.txt", "a");
if (f == 0) return;
fprintf(f, "%s: ", head);
for(i=0;i<len; ++i)
{
int c;
if (i > 0)
fprintf(f," ");
c = data[i];
if (c >= 32 && c <= 127)
fprintf(f, "'%c'", c);
else
fprintf(f, "%2x", c);
}
fputc('\n', f);
fclose(f);
}