wok view busybox/stuff/busybox-1.7.3-hexdump.u @ rev 2129

get-wifi-firmware: b43-firmware version 4.150.10.5
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Feb 01 19:02:11 2009 +0100 (2009-02-01)
parents
children
line source
1 --- busybox-1.7.3/util-linux/hexdump.c
2 +++ busybox-1.7.3/util-linux/hexdump.c
3 @@ -45,7 +45,7 @@
5 static const char add_first[] ALIGN1 = "\"%07.7_Ax\n\"";
7 -static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:v";
8 +static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:vR";
10 static const struct suffix_mult suffixes[] = {
11 { "b", 512 },
12 @@ -59,6 +59,8 @@
13 {
14 const char *p;
15 int ch;
16 + FILE *fp;
17 + smallint rdump = 0;
19 bb_dump_vflag = FIRST;
20 bb_dump_length = -1;
21 @@ -70,7 +72,7 @@
22 if ((p - hexdump_opts) < 5) {
23 bb_dump_add(add_first);
24 bb_dump_add(add_strings[(int)(p - hexdump_opts)]);
25 - } else if (ch == 'C') {
26 + } if (ch == 'C') {
27 bb_dump_add("\"%08.8_Ax\n\"");
28 bb_dump_add("\"%08.8_ax \" 8/1 \"%02x \" \" \" 8/1 \"%02x \" ");
29 bb_dump_add("\" |\" 16/1 \"%_p\" \"|\\n\"");
30 @@ -90,6 +92,9 @@
31 } /* else */
32 if (ch == 'v') {
33 bb_dump_vflag = ALL;
34 + } /* else */
35 + if (ch == 'R') {
36 + rdump = 1;
37 }
38 }
39 }
40 @@ -101,5 +106,36 @@
42 argv += optind;
44 - return bb_dump_dump(argv);
45 + if (!rdump) {
46 + return bb_dump_dump(argv);
47 + }
48 +
49 + /* -R: reverse of 'hexdump -Cv' */
50 + fp = stdin;
51 + if (!*argv) {
52 + argv--;
53 + goto jump_in;
54 + }
55 +
56 + do {
57 + char *buf;
58 + fp = xfopen(*argv, "r");
59 + jump_in:
60 + while ((buf = xmalloc_getline(fp)) != NULL) {
61 + p = buf;
62 + while (1) {
63 + /* skip address or previous byte */
64 + while (isxdigit(*p)) p++;
65 + while (*p == ' ') p++;
66 + /* '|' char will break the line */
67 + if (!isxdigit(*p) || sscanf(p, "%x ", &ch) != 1)
68 + break;
69 + putchar(ch);
70 + }
71 + free(buf);
72 + }
73 + fclose(fp);
74 + } while (*++argv);
75 +
76 + fflush_stdout_and_exit(EXIT_SUCCESS);
77 }