forked from gregkh/ndas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlsp_debug.c
More file actions
70 lines (64 loc) · 1.35 KB
/
lsp_debug.c
File metadata and controls
70 lines (64 loc) · 1.35 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "lsp_type.h"
#ifdef LSPIMP_DEBUG_UMODE
#include <stdio.h>
#include <ctype.h>
#include <stdarg.h>
#include "lsp_debug.h"
void
lsp_call
lsp_debug(const char* format, ...)
{
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}
void
lsp_call
lsp_debug_payload(const char* header, const void* buf, size_t len)
{
static const size_t col = 16;
static const size_t delimit = 512;
size_t i, j;
printf("=====================================================\n");
if (header)
{
printf(" %s (%d,0x%02X bytes)\n", header, len, len);
printf("-----------------------------------------------------\n");
}
if (len == 0)
{
return;
}
printf(" ");
for (i = 0; i < col; ++i)
{
printf("%02X ", i);
}
printf("\n");
for (i = 0; i < len; i += col)
{
if ((i%delimit) == 0)
{
printf("-----------------------------------------------------\n");
}
printf("%04X: ", i);
for (j = 0; j < col && (i + j < len); ++j)
{
printf("%02X ", ((unsigned char*)buf)[i+j]);
}
for (; j < col; ++j)
{
printf(" ");
}
for (j = 0; j < col && (i + j < len); ++j)
{
unsigned char c = ((unsigned char*)buf)[i+j];
if (!isprint(c)) c = '.';
printf("%c", c);
}
printf("\n");
}
printf("-----------------------------------------------------\n");
}
#endif