-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
37 lines (34 loc) · 694 Bytes
/
utils.c
File metadata and controls
37 lines (34 loc) · 694 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
34
35
36
37
#include "utils.h"
void print_buffer(uint8_t* buf, ssize_t Size)
{
ssize_t i = 0;
while (i < Size) {
printf("%02x ", buf[i]);
i++;
if (!(i%16)) {
printf(" | ");
for (int j=16; j>0; j--)
if ((buf[i-j] >= 0x20) && (buf[i-j] < 0x7E))
printf("%c", buf[i-j]);
else
printf(".");
printf("\n");
}
}
if (i%16) {
for (int j=0; j<=15; j++) {
if ((i+j)%16)
printf(" ");
else
break;
}
printf(" | ");
for (int j=(i%16); j>0; j--) {
if ((buf[i-j] >= 0x20) && (buf[i-j] < 0x7E))
printf("%c", buf[i-j]);
else
printf(".");
}
}
printf("\n");
}