annotate lib-src/hexl.c @ 15008:aca392dc5b0f

[DJGPP v2]: Include io.h. (main) [DJGPP v2]: Switch standard streams to binary with setmode.
author Richard M. Stallman <rms@gnu.org>
date Fri, 12 Apr 1996 16:02:38 +0000
parents dd3b83e4ceb0
children 2a4f0129d30d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 #include <stdio.h>
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 #include <ctype.h>
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
3 #ifdef MSDOS
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
4 #include <fcntl.h>
15008
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
5 #if __DJGPP__ >= 2
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
6 #include <io.h>
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
7 #endif
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
8 #endif
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 #define DEFAULT_GROUPING 0x01
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 #define DEFAULT_BASE 16
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 #undef TRUE
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 #undef FALSE
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 #define TRUE (1)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 #define FALSE (0)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 int group_by = DEFAULT_GROUPING;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 char *progname;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 8026
diff changeset
22 void usage();
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 8026
diff changeset
23
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 8026
diff changeset
24 int
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
25 main (argc, argv)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
26 int argc;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
27 char *argv[];
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
29 register long address;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
30 char string[18];
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
31 FILE *fp;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
33 progname = *argv++; --argc;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
35 /*
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
36 ** -hex hex dump
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
37 ** -oct Octal dump
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
38 ** -group-by-8-bits
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
39 ** -group-by-16-bits
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
40 ** -group-by-32-bits
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
41 ** -group-by-64-bits
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
42 ** -iso iso character set.
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
43 ** -big-endian Big Endian
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
44 ** -little-endian Little Endian
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
45 ** -un || -de from hexl format to binary.
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
46 ** -- End switch list.
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
47 ** <filename> dump filename
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
48 ** - (as filename == stdin)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
49 */
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
51 while (*argv && *argv[0] == '-' && (*argv)[1])
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
53 /* A switch! */
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
54 if (!strcmp (*argv, "--"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
56 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
57 break;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
58 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
59 else if (!strcmp (*argv, "-un") || !strcmp (*argv, "-de"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
61 un_flag = TRUE;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
62 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
63 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
64 else if (!strcmp (*argv, "-hex"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
66 base = 16;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
67 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
68 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
69 else if (!strcmp (*argv, "-iso"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
71 iso_flag = TRUE;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
72 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
73 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
74 else if (!strcmp (*argv, "-oct"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
76 base = 8;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
77 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
78 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
79 else if (!strcmp (*argv, "-big-endian"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
81 endian = 1;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
82 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
83 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
84 else if (!strcmp (*argv, "-little-endian"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
86 endian = 0;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
87 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
88 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
89 else if (!strcmp (*argv, "-group-by-8-bits"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
91 group_by = 0x00;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
92 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
93 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
94 else if (!strcmp (*argv, "-group-by-16-bits"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
96 group_by = 0x01;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
97 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
98 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
99 else if (!strcmp (*argv, "-group-by-32-bits"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
101 group_by = 0x03;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
102 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
103 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
104 else if (!strcmp (*argv, "-group-by-64-bits"))
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
106 group_by = 0x07;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
107 endian = 0;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
108 --argc; argv++;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
109 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
110 else
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
112 fprintf (stderr, "%s: invalid switch: \"%s\".\n", progname,
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
113 *argv);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
114 usage ();
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
118 do
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
120 if (*argv == NULL)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
121 fp = stdin;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
122 else
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
124 char *filename = *argv++;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
126 if (!strcmp (filename, "-"))
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
127 fp = stdin;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
128 else if ((fp = fopen (filename, "r")) == NULL)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
129 {
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
130 perror (filename);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
131 continue;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
132 }
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
135 if (un_flag)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
137 char buf[18];
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
139 #ifdef MSDOS
15008
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
140 #if __DJGPP__ >= 2
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
141 setmode (fileno (stdout), O_BINARY);
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
142 #else
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
143 (stdout)->_flag &= ~_IOTEXT; /* print binary */
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
144 _setmode (fileno (stdout), O_BINARY);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
145 #endif
15008
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
146 #endif
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
147 for (;;)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
149 register int i, c, d;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
151 #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
153 fread (buf, 1, 10, fp); /* skip 10 bytes */
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
154
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
155 for (i=0; i < 16; ++i)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
157 if ((c = getc (fp)) == ' ' || c == EOF)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
158 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
160 d = getc (fp);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
161 c = hexchar (c) * 0x10 + hexchar (d);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
162 putchar (c);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
164 if ((i&group_by) == group_by)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
165 getc (fp);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
168 if (c == ' ')
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
170 while ((c = getc (fp)) != '\n' && c != EOF)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
171 ;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
173 if (c == EOF)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
174 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 }
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
176 else
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
178 if (i < 16)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
179 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
181 fread (buf, 1, 18, fp); /* skip 18 bytes */
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 }
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
185 else
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
187 #ifdef MSDOS
15008
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
188 #if __DJGPP__ >= 2
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
189 setmode (fileno (stdout), O_BINARY);
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
190 #else
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
191 (fp)->_flag &= ~_IOTEXT; /* read binary */
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
192 _setmode (fileno (fp), O_BINARY);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
193 #endif
15008
aca392dc5b0f [DJGPP v2]: Include io.h.
Richard M. Stallman <rms@gnu.org>
parents: 9491
diff changeset
194 #endif
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
195 address = 0;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
196 string[0] = ' ';
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
197 string[17] = '\0';
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
198 for (;;)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
200 register int i, c;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
202 for (i=0; i < 16; ++i)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
203 {
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
204 if ((c = getc (fp)) == EOF)
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
206 if (!i)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
207 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
209 fputs (" ", stdout);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
210 string[i+1] = '\0';
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
211 }
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
212 else
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
213 {
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
214 if (!i)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
215 printf ("%08x: ", address);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
217 if (iso_flag)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
218 string[i+1] =
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
219 (c < 0x20 || (c >= 0x7F && c < 0xa0)) ? '.' :c;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
220 else
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
221 string[i+1] = (c < 0x20 || c >= 0x7F) ? '.' : c;
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
222
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
223 printf ("%02x", c);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
226 if ((i&group_by) == group_by)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
227 putchar (' ');
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
230 if (i)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
231 puts (string);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
233 if (c == EOF)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
234 break;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
236 address += 0x10;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
241 if (fp != stdin)
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
242 fclose (fp);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 } while (*argv != NULL);
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
245 return 0;
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 8026
diff changeset
248 void
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
249 usage ()
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 {
5445
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
251 fprintf (stderr, "usage: %s [-de] [-iso]\n", progname);
44e193cc8f49 Fix up whitespace. Get rid of spurious casts to void.
Richard M. Stallman <rms@gnu.org>
parents: 26
diff changeset
252 exit (1);
26
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 }