-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug.c
More file actions
33 lines (29 loc) · 804 Bytes
/
debug.c
File metadata and controls
33 lines (29 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include "debug.h"
void printbuffer(unsigned char* buffer, size_t len)
{
size_t offset;
size_t i;
for(offset = 0; offset < len; offset+=8)
{
printf("%04X: ", (unsigned int)offset);
for(i = 0; i < 8 && i+offset < len; i++)
{
printf("%02X ", (unsigned int)buffer[i+offset]);
}
for(i = 0; i < 8 && i+offset < len; i++)
{
if((unsigned int)buffer[i+offset] < 0x20 ||
(unsigned int)buffer[i+offset] > 0x7E)
{
printf(".");
}
else
{
printf("%c", buffer[i+offset]);
}
}
printf("\n");
}
}
/* vim: set tabstop=4 shiftwidth=4 expandtab: */