/* hex_dump.h -- simple hex dump routine * * Copyright (C) 2002 convergence GmbH * Johannes Stezenbach * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "hex_dump.h" void hex_dump(uint8_t data[], int bytes) { int i, j; uint8_t c; for (i = 0; i < bytes; i++) { if (!(i % 8) && i) printf(" "); if (!(i % 16) && i) { printf(" "); for (j = 0; j < 16; j++) { c = data[i+j-16]; if ((c < 0x20) || (c >= 0x7f)) c = '.'; printf("%c", c); } printf("\n"); } printf("%.2x ", data[i]); } j = (bytes % 16); j = (j != 0 ? j : 16); for (i = j; i < 16; i++) { if (!(i % 8) && i) printf(" "); printf(" "); } printf(" "); for (i = bytes - j; i < bytes; i++) { c = data[i]; if ((c < 0x20) || (c >= 0x7f)) c = '.'; printf("%c", c); } printf("\n"); } p;id=dada84092749891541a003d43da4229314e81632'>refslogtreecommitdiffstats
blob: c0cc96e4d5b2d879fd1bf6ea6c5224fb7180e4b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90