From 552ea87f7a0e21643a7fd2ac6b571316206c6071 Mon Sep 17 00:00:00 2001 From: YI Date: Mon, 25 Dec 2023 15:30:00 +0800 Subject: [PATCH] remove dump.c --- c/dump.c | 76 -------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 c/dump.c diff --git a/c/dump.c b/c/dump.c deleted file mode 100644 index 6a30c37..0000000 --- a/c/dump.c +++ /dev/null @@ -1,76 +0,0 @@ -#define CKB_C_STDLIB_PRINTF -#include - -// Usage: -// hex_dump(desc, addr, len, perLine); -// desc: if non-NULL, printed as a description before hex dump. -// addr: the address to start dumping from. -// len: the number of bytes to dump. -// perLine: number of bytes on each output line. - -void hex_dump(const char *desc, const void *addr, const int len, int perLine) { - // Silently ignore silly per-line values. - - if (perLine < 4 || perLine > 64) - perLine = 16; - - int i; - unsigned char buff[perLine + 1]; - const unsigned char *pc = (const unsigned char *)addr; - - // Output description if given. - - if (desc != NULL) - printf("%s:\n", desc); - - // Length checks. - - if (len == 0) { - printf(" ZERO LENGTH\n"); - return; - } - if (len < 0) { - printf(" NEGATIVE LENGTH: %d\n", len); - return; - } - - // Process every byte in the data. - - for (i = 0; i < len; i++) { - // Multiple of perLine means new or first line (with line offset). - - if ((i % perLine) == 0) { - // Only print previous-line ASCII buffer for lines beyond first. - - if (i != 0) - printf(" %s\n", buff); - - // Output the offset of current line. - - printf(" %04x ", i); - } - - // Now the hex code for the specific character. - - printf(" %02x", pc[i]); - - // And buffer a printable ASCII character for later. - - if ((pc[i] < 0x20) || (pc[i] > 0x7e)) // isprint() may be better. - buff[i % perLine] = '.'; - else - buff[i % perLine] = pc[i]; - buff[(i % perLine) + 1] = '\0'; - } - - // Pad out last line if not exactly perLine characters. - - while ((i % perLine) != 0) { - printf(" "); - i++; - } - - // And print the final ASCII buffer. - - printf(" %s\n", buff); -}