aboutsummaryrefslogtreecommitdiff
path: root/util-linux/hexdump.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/hexdump.c')
-rw-r--r--util-linux/hexdump.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c
index 4a7f641db..25f771201 100644
--- a/util-linux/hexdump.c
+++ b/util-linux/hexdump.c
@@ -41,19 +41,21 @@
41//usage: "[-bcCdefnosvx" IF_FEATURE_HEXDUMP_REVERSE("R") "] [FILE]..." 41//usage: "[-bcCdefnosvx" IF_FEATURE_HEXDUMP_REVERSE("R") "] [FILE]..."
42//usage:#define hexdump_full_usage "\n\n" 42//usage:#define hexdump_full_usage "\n\n"
43//usage: "Display FILEs (or stdin) in a user specified format\n" 43//usage: "Display FILEs (or stdin) in a user specified format\n"
44//usage: "\n -b One-byte octal display" 44//usage: "\n -b 1-byte octal display"
45//usage: "\n -c One-byte character display" 45//usage: "\n -c 1-byte character display"
46//usage: "\n -C Canonical hex+ASCII, 16 bytes per line" 46//usage: "\n -d 2-byte decimal display"
47//usage: "\n -d Two-byte decimal display" 47//usage: "\n -o 2-byte octal display"
48//usage: "\n -e FORMAT_STRING" 48//usage: "\n -x 2-byte hex display"
49//usage: "\n -C hex+ASCII 16 bytes per line"
50//usage: "\n -v Show all (no dup folding)"
51//usage: "\n -e FORMAT_STR Example: '16/1 \"%02x|\"\"\\n\"'"
49//usage: "\n -f FORMAT_FILE" 52//usage: "\n -f FORMAT_FILE"
50//usage: "\n -n LENGTH Interpret only LENGTH bytes of input" 53// exactly the same help text lines in hexdump and xxd:
51//usage: "\n -o Two-byte octal display" 54//usage: "\n -n LENGTH Show only first LENGTH bytes"
52//usage: "\n -s OFFSET Skip OFFSET bytes" 55//usage: "\n -s OFFSET Skip OFFSET bytes"
53//usage: "\n -v Display all input data"
54//usage: "\n -x Two-byte hexadecimal display"
55//usage: IF_FEATURE_HEXDUMP_REVERSE( 56//usage: IF_FEATURE_HEXDUMP_REVERSE(
56//usage: "\n -R Reverse of 'hexdump -Cv'") 57//usage: "\n -R Reverse of 'hexdump -Cv'")
58// TODO: NONCOMPAT!!! move -R to xxd -r
57//usage: 59//usage:
58//usage:#define hd_trivial_usage 60//usage:#define hd_trivial_usage
59//usage: "FILE..." 61//usage: "FILE..."
@@ -83,11 +85,11 @@ static void bb_dump_addfile(dumper_t *dumper, char *name)
83} 85}
84 86
85static const char *const add_strings[] = { 87static const char *const add_strings[] = {
86 "\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"", /* b */ 88 "\"%07.7_ax \"16/1 \"%03o \"\"\n\"", /* b */
87 "\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"", /* c */ 89 "\"%07.7_ax \"16/1 \"%3_c \"\"\n\"", /* c */
88 "\"%07.7_ax \" 8/2 \" %05u \" \"\\n\"", /* d */ 90 "\"%07.7_ax \"8/2 \" %05u \"\"\n\"", /* d */
89 "\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"", /* o */ 91 "\"%07.7_ax \"8/2 \" %06o \"\"\n\"", /* o */
90 "\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"", /* x */ 92 "\"%07.7_ax \"8/2 \" %04x \"\"\n\"", /* x */
91}; 93};
92 94
93static const char add_first[] ALIGN1 = "\"%07.7_Ax\n\""; 95static const char add_first[] ALIGN1 = "\"%07.7_Ax\n\"";
@@ -125,9 +127,11 @@ int hexdump_main(int argc, char **argv)
125 /* Save a little bit of space below by omitting the 'else's. */ 127 /* Save a little bit of space below by omitting the 'else's. */
126 if (ch == 'C') { 128 if (ch == 'C') {
127 hd_applet: 129 hd_applet:
128 bb_dump_add(dumper, "\"%08.8_Ax\n\""); 130 bb_dump_add(dumper, "\"%08.8_Ax\n\""); // final address line after dump
129 bb_dump_add(dumper, "\"%08.8_ax \" 8/1 \"%02x \" \" \" 8/1 \"%02x \" "); 131 //------------------- "address " 8 * "xx " " " 8 * "xx "
130 bb_dump_add(dumper, "\" |\" 16/1 \"%_p\" \"|\\n\""); 132 bb_dump_add(dumper, "\"%08.8_ax \"8/1 \"%02x \"\" \"8/1 \"%02x \"");
133 //------------------- " |ASCII...........|\n"
134 bb_dump_add(dumper, "\" |\"16/1 \"%_p\"\"|\n\"");
131 } 135 }
132 if (ch == 'e') { 136 if (ch == 'e') {
133 bb_dump_add(dumper, optarg); 137 bb_dump_add(dumper, optarg);
@@ -158,7 +162,7 @@ int hexdump_main(int argc, char **argv)
158 162
159 if (!dumper->fshead) { 163 if (!dumper->fshead) {
160 bb_dump_add(dumper, add_first); 164 bb_dump_add(dumper, add_first);
161 bb_dump_add(dumper, "\"%07.7_ax \" 8/2 \"%04x \" \"\\n\""); 165 bb_dump_add(dumper, "\"%07.7_ax \"8/2 \"%04x \"\"\n\"");
162 } 166 }
163 167
164 argv += optind; 168 argv += optind;