diff options
Diffstat (limited to 'src/utils.c')
| -rw-r--r-- | src/utils.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/utils.c b/src/utils.c index ceb1f5d..fb98471 100644 --- a/src/utils.c +++ b/src/utils.c | |||
| @@ -56,11 +56,35 @@ void log_debug_msg(const char *format, ...) | |||
| 56 | inline void log_debug_buffer(const char *data, const int length) | 56 | inline void log_debug_buffer(const char *data, const int length) |
| 57 | { | 57 | { |
| 58 | #ifndef STRIP_DEBUG_CODE | 58 | #ifndef STRIP_DEBUG_CODE |
| 59 | int i; | ||
| 60 | int j; | ||
| 61 | unsigned char c; | ||
| 59 | 62 | ||
| 60 | /* run the real fprintf */ | 63 | if (toto_debug) { |
| 61 | if (toto_debug) | 64 | for (i = 0; i < length; i += 16) { |
| 62 | fwrite(data, 1, length, stderr); | 65 | fprintf(stderr, "%04x: ", i); |
| 63 | 66 | for (j = 0; j < 16; j++) { | |
| 67 | if (i + j >= length) { | ||
| 68 | fprintf(stderr, " "); | ||
| 69 | continue; | ||
| 70 | } | ||
| 71 | fprintf(stderr, "%02hhx ", *(data + i + j)); | ||
| 72 | } | ||
| 73 | fprintf(stderr, " | "); | ||
| 74 | for (j = 0; j < 16; j++) { | ||
| 75 | if (i + j >= length) | ||
| 76 | break; | ||
| 77 | c = *(data + i + j); | ||
| 78 | if ((c < 32) || (c > 127)) { | ||
| 79 | fprintf(stderr, "."); | ||
| 80 | continue; | ||
| 81 | } | ||
| 82 | fprintf(stderr, "%c", c); | ||
| 83 | } | ||
| 84 | fprintf(stderr, "\n"); | ||
| 85 | } | ||
| 86 | fprintf(stderr, "\n"); | ||
| 87 | } | ||
| 64 | #endif | 88 | #endif |
| 65 | } | 89 | } |
| 66 | 90 | ||
