]>
Commit | Line | Data |
---|---|---|
c6b24b3b | 1 | /* |
da23017d NS |
2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
dfc130f3 | 4 | * |
da23017d NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
c6b24b3b | 7 | * published by the Free Software Foundation. |
dfc130f3 | 8 | * |
da23017d NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
dfc130f3 | 13 | * |
da23017d NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
c6b24b3b NS |
17 | */ |
18 | ||
6b803e5a | 19 | #include "libxfs.h" |
c6b24b3b NS |
20 | #include <ctype.h> |
21 | #include "block.h" | |
22 | #include "bmap.h" | |
23 | #include "command.h" | |
c6b24b3b NS |
24 | #include "type.h" |
25 | #include "faddr.h" | |
26 | #include "fprint.h" | |
27 | #include "field.h" | |
28 | #include "inode.h" | |
29 | #include "io.h" | |
30 | #include "output.h" | |
4ca431fc | 31 | #include "init.h" |
c6b24b3b NS |
32 | |
33 | static void print_rawtext(void *data, int len); | |
34 | ||
35 | void | |
36 | print_text( | |
dfc130f3 RC |
37 | const field_t *fields, |
38 | int argc, | |
39 | char **argv) | |
c6b24b3b | 40 | { |
dfc130f3 | 41 | print_rawtext(iocur_top->data, iocur_top->len); |
c6b24b3b NS |
42 | } |
43 | ||
44 | static void | |
45 | print_rawtext( | |
dfc130f3 RC |
46 | void *data, |
47 | int len) | |
c6b24b3b | 48 | { |
dfc130f3 RC |
49 | int i; |
50 | int j; | |
51 | int lastaddr; | |
52 | int offchars; | |
53 | unsigned char *p; | |
c6b24b3b | 54 | |
dfc130f3 RC |
55 | lastaddr = (len - 1) & ~(16 - 1); |
56 | if (lastaddr < 0x10) | |
57 | offchars = 1; | |
58 | else if (lastaddr < 0x100) | |
59 | offchars = 2; | |
60 | else if (lastaddr < 0x1000) | |
61 | offchars = 3; | |
62 | else | |
63 | offchars = 4; | |
c6b24b3b | 64 | |
dfc130f3 RC |
65 | for (i = 0, p = data; i < len; i += 16) { |
66 | unsigned char *s = p; | |
c6b24b3b | 67 | |
dfc130f3 | 68 | dbprintf("%-0*.*x: ", offchars, offchars, i); |
c6b24b3b | 69 | |
dfc130f3 RC |
70 | for (j = 0; j < 16 && i + j < len; j++, p++) { |
71 | dbprintf("%02x ", *p); | |
72 | } | |
c6b24b3b | 73 | |
dfc130f3 | 74 | dbprintf(" "); |
c6b24b3b | 75 | |
dfc130f3 RC |
76 | for (j = 0; j < 16 && i + j < len; j++, s++) { |
77 | if (isalnum(*s)) | |
78 | dbprintf("%c", *s); | |
79 | else | |
80 | dbprintf(".", *s); | |
81 | } | |
c6b24b3b | 82 | |
dfc130f3 RC |
83 | dbprintf("\n"); |
84 | } | |
c6b24b3b | 85 | } |