| 121 | } |
| 122 | |
| 123 | static void hexdump(FILE *f, uint8_t *p, int len) |
| 124 | { |
| 125 | char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; |
| 126 | const int sz = 8 * 1024; |
| 127 | char buf[sz + 1]; |
| 128 | buf[sz] = 0; |
| 129 | int counter = 0; |
| 130 | for (int i = 0; i < len; i++) { |
| 131 | uint8_t byte = *p; |
| 132 | ++p; |
| 133 | buf[counter++] = hex[byte >> 4]; |
| 134 | buf[counter++] = hex[byte & 0x0f]; |
| 135 | if (counter == sz) { |
| 136 | fprintf(f, "%s", buf); |
| 137 | counter = 0; |
| 138 | } |
| 139 | } |
| 140 | if (counter) { |
| 141 | buf[counter] = 0; |
| 142 | fprintf(f, "%s", buf); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | void dumpstring(FILE *f, char *s, int quotes, int quote_quotes) |
| 147 | { |