| 1 |
|
| #include <stdio.h> |
| 2 |
|
| #include <stdlib.h> |
| 3 |
|
| #include <string.h> |
| 4 |
|
| |
| 5 |
|
| #include <ctype.h> |
| 6 |
|
| |
| 7 |
0 |
| static void dump_row(long count, int numinrow, int *chs) { |
| 8 |
|
| int i; |
| 9 |
|
| |
| 10 |
0 |
| printf("%08lX:", count - numinrow); |
| 11 |
|
| |
| 12 |
0 |
▶ | if (numinrow > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (numinrow > 0) { |
0 |
0 |
0 |
|
| 13 |
0 |
▶ | for (i = 0; i < numinrow; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < numinrow; i++) { |
0 |
0 |
0 |
|
| 14 |
0 |
▶ | if (i == 8) |
Branch: 1 branch
| Branch | True | False | Total |
| if (i == 8) |
0 |
0 |
0 |
|
| 15 |
0 |
| printf(" :"); |
| 16 |
0 |
| printf(" %02X", chs[i]); |
| 17 |
|
| } |
| 18 |
0 |
▶ | for (i = numinrow; i < 16; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = numinrow; i < 16; i++) { |
0 |
0 |
0 |
|
| 19 |
0 |
▶ | if (i == 8) |
Branch: 1 branch
| Branch | True | False | Total |
| if (i == 8) |
0 |
0 |
0 |
|
| 20 |
0 |
| printf(" :"); |
| 21 |
0 |
| printf(" "); |
| 22 |
|
| } |
| 23 |
0 |
| printf(" "); |
| 24 |
0 |
▶ | for (i = 0; i < numinrow; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < numinrow; i++) { |
0 |
0 |
0 |
|
| 25 |
0 |
▶ | if (isprint(chs[i])) |
Branch: 1 branch
| Branch | True | False | Total |
| if (isprint(chs[i])) |
0 |
0 |
0 |
|
| 26 |
0 |
| printf("%c", chs[i]); |
| 27 |
|
| else |
| 28 |
0 |
| printf("."); |
| 29 |
|
| } |
| 30 |
|
| } |
| 31 |
0 |
| printf("\n"); |
| 32 |
0 |
| } |
| 33 |
|
| |
| 34 |
0 |
| static int rows_eq(int *a, int *b) { |
| 35 |
|
| int i; |
| 36 |
|
| |
| 37 |
0 |
▶ | for (i=0; i<16; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i=0; i<16; i++) |
0 |
0 |
0 |
|
| 38 |
0 |
▶ | if (a[i] != b[i]) |
Branch: 1 branch
| Branch | True | False | Total |
| if (a[i] != b[i]) |
0 |
0 |
0 |
|
| 39 |
0 |
| return 0; |
| 40 |
|
| |
| 41 |
0 |
| return 1; |
| 42 |
|
| } |
| 43 |
|
| |
| 44 |
0 |
| void amqp_dump(void const *buffer, size_t len) { |
| 45 |
0 |
| unsigned char *buf = (unsigned char *) buffer; |
| 46 |
0 |
| long count = 0; |
| 47 |
0 |
| int numinrow = 0; |
| 48 |
|
| int chs[16]; |
| 49 |
|
| int oldchs[16]; |
| 50 |
0 |
| int showed_dots = 0; |
| 51 |
|
| int i; |
| 52 |
|
| |
| 53 |
0 |
▶ | for (i = 0; i < len; i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < len; i++) { |
0 |
0 |
0 |
|
| 54 |
0 |
| int ch = buf[i]; |
| 55 |
|
| |
| 56 |
0 |
▶ | if (numinrow == 16) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (numinrow == 16) { |
0 |
0 |
0 |
|
| 57 |
|
| int i; |
| 58 |
|
| |
| 59 |
0 |
▶ | if (rows_eq(oldchs, chs)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rows_eq(oldchs, chs)) { |
0 |
0 |
0 |
|
| 60 |
0 |
▶ | if (!showed_dots) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!showed_dots) { |
0 |
0 |
0 |
|
| 61 |
0 |
| showed_dots = 1; |
| 62 |
0 |
| printf(" .. .. .. .. .. .. .. .. : .. .. .. .. .. .. .. ..\n"); |
| 63 |
|
| } |
| 64 |
|
| } else { |
| 65 |
0 |
| showed_dots = 0; |
| 66 |
0 |
| dump_row(count, numinrow, chs); |
| 67 |
|
| } |
| 68 |
|
| |
| 69 |
0 |
▶ | for (i=0; i<16; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i=0; i<16; i++) |
0 |
0 |
0 |
|
| 70 |
0 |
| oldchs[i] = chs[i]; |
| 71 |
|
| |
| 72 |
0 |
| numinrow = 0; |
| 73 |
|
| } |
| 74 |
|
| |
| 75 |
0 |
| count++; |
| 76 |
0 |
| chs[numinrow++] = ch; |
| 77 |
|
| } |
| 78 |
|
| |
| 79 |
0 |
| dump_row(count, numinrow, chs); |
| 80 |
|
| |
| 81 |
0 |
▶ | if (numinrow != 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (numinrow != 0) |
0 |
0 |
0 |
|
| 82 |
0 |
| printf("%08lX:\n", count); |
| 83 |
0 |
| } |