| 1242 | static vector<uchar> hexbin; |
| 1243 | |
| 1244 | void hexbinwrite(stream *f, void *data, int len, bool ascii = true) // write block of binary data as hex values with up to 24 bytes per line |
| 1245 | { |
| 1246 | string asc; |
| 1247 | uchar *s = (uchar *) data; |
| 1248 | while(len > 0) |
| 1249 | { |
| 1250 | int chunk = min(len, 24); |
| 1251 | f->printf("hexbinchunk"); |
| 1252 | loopi(chunk) |
| 1253 | { |
| 1254 | asc[i] = isalnum(*s) ? *s : '.'; asc[i + 1] = '\0'; |
| 1255 | f->printf(" %02x", int(*s++)); |
| 1256 | } |
| 1257 | if(ascii) f->printf(" // %s\n", asc); |
| 1258 | else f->printf("\n"); |
| 1259 | len -= chunk; |
| 1260 | } |
| 1261 | } |
| 1262 | |
| 1263 | COMMANDF(hexbinchunk, "v", (char **args, int numargs) // read up to 24 bytes from the command's arguments to the hexbin buffer |
| 1264 | { |