(一) 应用层调试打印
#if 1
#define isprint(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))
static inline void br_dump_raw (const unsigned char *buf, unsigned len)
{
int i;
char lbuf [80];
int lbix = 0;
/*
1 2 3 4 5 6 7
01234567890123456789012345678901234567890123456789012345678901234567890123
280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................
*/
memset(lbuf, ' ', 79);
lbuf [79] = 0;
for (i = 0; i < len; i++) {
if ((i & 15) == 0) {
if (lbix) {
lbuf[53]=' ';
lbuf[54]=' ';
lbuf[55]=' ';
lbuf[73]='\0';
printf ("%s\n", lbuf);
}
memset(lbuf, ' ', 79);
lbuf [79] = 0;
sprintf (lbuf, "%03x:", i);
lbix = 4;
} else if ((i & 7) == 0)
lbuf [lbix++] = ' ';
if(isprint(buf[i])) {
lbuf[56+(i%16)]=buf[i];
} else {
lbuf[56+(i%16)]='.';
}
sprintf (&lbuf [lbix], " %02x", buf [i]);
lbix += 3;
lbuf[lbix]=' ';
}
lbuf[53]=' ';
lbuf[54]=' ';
lbuf[55]=' ';
lbuf[73]='\0';
printf ("%s\n", lbuf);
}
#endif
(二) 内核调试打印