7 #define DEFAULT_GROUPING 0x01
8 #define DEFAULT_BASE 16
15 int base
= DEFAULT_BASE
, un_flag
= FALSE
, iso_flag
= FALSE
, endian
= 1;
16 int group_by
= DEFAULT_GROUPING
;
26 register long address
;
30 progname
= *argv
++; --argc
;
39 ** -iso iso character set.
40 ** -big-endian Big Endian
41 ** -little-endian Little Endian
42 ** -un || -de from hexl format to binary.
43 ** -- End switch list.
44 ** <filename> dump filename
45 ** - (as filename == stdin)
48 while (*argv
&& *argv
[0] == '-' && (*argv
)[1])
51 if (!strcmp (*argv
, "--"))
56 else if (!strcmp (*argv
, "-un") || !strcmp (*argv
, "-de"))
61 else if (!strcmp (*argv
, "-hex"))
66 else if (!strcmp (*argv
, "-iso"))
71 else if (!strcmp (*argv
, "-oct"))
76 else if (!strcmp (*argv
, "-big-endian"))
81 else if (!strcmp (*argv
, "-little-endian"))
86 else if (!strcmp (*argv
, "-group-by-8-bits"))
91 else if (!strcmp (*argv
, "-group-by-16-bits"))
96 else if (!strcmp (*argv
, "-group-by-32-bits"))
101 else if (!strcmp (*argv
, "-group-by-64-bits"))
109 fprintf (stderr
, "%s: invalid switch: \"%s\".\n", progname
,
121 char *filename
= *argv
++;
123 if (!strcmp (filename
, "-"))
125 else if ((fp
= fopen (filename
, "r")) == NULL
)
137 (stdout
)->_flag
&= ~_IOTEXT
; /* print binary */
138 _setmode (fileno (stdout
), O_BINARY
);
142 register int i
, c
, d
;
144 #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
146 fread (buf
, 1, 10, fp
); /* skip 10 bytes */
148 for (i
=0; i
< 16; ++i
)
150 if ((c
= getc (fp
)) == ' ' || c
== EOF
)
154 c
= hexchar (c
) * 0x10 + hexchar (d
);
157 if ((i
&group_by
) == group_by
)
163 while ((c
= getc (fp
)) != '\n' && c
!= EOF
)
174 fread (buf
, 1, 18, fp
); /* skip 18 bytes */
181 (fp
)->_flag
&= ~_IOTEXT
; /* read binary */
182 _setmode (fileno (fp
), O_BINARY
);
191 for (i
=0; i
< 16; ++i
)
193 if ((c
= getc (fp
)) == EOF
)
204 printf ("%08x: ", address
);
208 (c
< 0x20 || (c
>= 0x7F && c
< 0xa0)) ? '.' :c
;
210 string
[i
+1] = (c
< 0x20 || c
>= 0x7F) ? '.' : c
;
215 if ((i
&group_by
) == group_by
)
233 } while (*argv
!= NULL
);
240 fprintf (stderr
, "usage: %s [-de] [-iso]\n", progname
);