Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define COLS 16
- static void hexdump(const char *buf, size_t length)
- {
- bool star = false;
- size_t i, j;
- for (i = 0; i < length; i += COLS, buf += COLS) {
- if (i && !memcmp(buf, buf - COLS, COLS)) {
- if (!star)
- printk(KERN_CONT "*\n");
- star = true;
- continue;
- }
- star = false;
- printk("%px ", buf + i);
- for (j = 0; j < COLS; j++) {
- printk(KERN_CONT "%02hhx ", buf[j]);
- if ((j & (COLS / 2 - 1)) == COLS / 2 - 1)
- printk(KERN_CONT " ");
- }
- printk(KERN_CONT "|");
- for (j = 0; j < COLS; j++) {
- int c = buf[j];
- printk(KERN_CONT "%c", c >= ' ' && c <= '~' ? c : '.');
- }
- printk(KERN_CONT "|\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement