| 415 | } |
| 416 | |
| 417 | void hexDump2(char* desc, void* addr, int len) { |
| 418 | int i; |
| 419 | unsigned char buff[17]; |
| 420 | unsigned char* pc = (unsigned char*)addr; |
| 421 | |
| 422 | // Output description if given. |
| 423 | if (desc != NULL) |
| 424 | printf("%s:\n", desc); |
| 425 | |
| 426 | if (len == 0) { |
| 427 | printf(" ZERO LENGTH\n"); |
| 428 | return; |
| 429 | } |
| 430 | if (len < 0) { |
| 431 | printf(" NEGATIVE LENGTH: %i\n", len); |
| 432 | return; |
| 433 | } |
| 434 | |
| 435 | // Process every byte in the data. |
| 436 | for (i = 0; i < len; i++) { |
| 437 | // Multiple of 16 means new line (with line offset). |
| 438 | |
| 439 | if ((i % 16) == 0) { |
| 440 | // Just don't print ASCII for the zeroth line. |
| 441 | if (i != 0) |
| 442 | printf(" %s\n", buff); |
| 443 | |
| 444 | // Output the offset. |
| 445 | printf(" %04x ", i); |
| 446 | } |
| 447 | |
| 448 | // Now the hex code for the specific character. |
| 449 | printf(" %02x", pc[i]); |
| 450 | |
| 451 | // And store a printable ASCII character for later. |
| 452 | if ((pc[i] < 0x20) || (pc[i] > 0x7e)) |
| 453 | buff[i % 16] = '.'; |
| 454 | else |
| 455 | buff[i % 16] = pc[i]; |
| 456 | buff[(i % 16) + 1] = '\0'; |
| 457 | } |
| 458 | |
| 459 | // Pad out last line if not exactly 16 characters. |
| 460 | while ((i % 16) != 0) { |
| 461 | printf(" "); |
| 462 | i++; |
| 463 | } |
| 464 | |
| 465 | // And print the final ASCII bit. |
| 466 | printf(" %s\n", buff); |
| 467 | } |
| 468 | |
| 469 | |
| 470 | int findBase64Negotiate(char* buffer, int buffer_len, byte* outbuffer, int* outbuffer_len) { |