Prettier dumper
authorviric@mandarina
Sun, 07 Oct 2007 22:16:21 +0200
changeset 68 560d86d7dfc1
parent 67 d7405e4f12e1
child 69 c107ac7b3d29
Prettier dumper
dump.c
--- a/dump.c	Sun Oct 07 21:59:12 2007 +0200
+++ b/dump.c	Sun Oct 07 22:16:21 2007 +0200
@@ -9,7 +9,7 @@
 
 #include "main.h"
 
-const int should_dump = 0;
+const int should_dump = 1;
 
 void dump_line(const char *msg, ...)
 {
@@ -36,18 +36,16 @@
     f = fopen("/tmp/dump.txt", "a");
     if (f == 0) return;
 
-    fprintf(f, "%s (%i): ", head, len);
+    fprintf(f, "%s (%i): \"", head, len);
     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);
+            fprintf(f, "%c", c);
         else
-            fprintf(f, "%2x", c);
+            fprintf(f, "\\x%02x", c);
     }
-    fputc('\n', f);
+    fprintf(f, "\"\n");
     fclose(f);
 }