]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/text.c
Update copyright/license notices to match SGI legal prefered boilerplate.
[thirdparty/xfsprogs-dev.git] / db / text.c
1 /*
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
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
7 * published by the Free Software Foundation.
8 *
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.
13 *
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
17 */
18
19 #include <xfs/libxfs.h>
20 #include <ctype.h>
21 #include "block.h"
22 #include "bmap.h"
23 #include "command.h"
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"
31 #include "init.h"
32
33 static void print_rawtext(void *data, int len);
34
35 void
36 print_text(
37 const field_t *fields,
38 int argc,
39 char **argv)
40 {
41 print_rawtext(iocur_top->data, iocur_top->len);
42 }
43
44 static void
45 print_rawtext(
46 void *data,
47 int len)
48 {
49 int i;
50 int j;
51 int lastaddr;
52 int offchars;
53 unsigned char *p;
54
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;
64
65 for (i = 0, p = data; i < len; i += 16) {
66 unsigned char *s = p;
67
68 dbprintf("%-0*.*x: ", offchars, offchars, i);
69
70 for (j = 0; j < 16 && i + j < len; j++, p++) {
71 dbprintf("%02x ", *p);
72 }
73
74 dbprintf(" ");
75
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 }
82
83 dbprintf("\n");
84 }
85 }