annotate lib-src/hexl.c @ 1302:538cc0cd6d83

* textprop.c: Conditionalize all functions on "USE_TEXT_PROPERTIES".
author Joseph Arceneaux <jla@gnu.org>
date Fri, 02 Oct 1992 20:05:45 +0000
parents 7c9f757a985a
children 44e193cc8f49
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>
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 #define DEFAULT_GROUPING 0x01
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 #define DEFAULT_BASE 16
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 #undef TRUE
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 #undef FALSE
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 #define TRUE (1)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 #define FALSE (0)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 extern void exit(), perror();
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 int group_by = DEFAULT_GROUPING;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 char *progname;
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 main(argc, argv)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 int argc;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 char *argv[];
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 register long address;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 char string[18];
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 FILE *fp;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 progname = *argv++; --argc;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 /*
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ** -hex hex dump
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ** -oct Octal dump
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ** -group-by-8-bits
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ** -group-by-16-bits
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ** -group-by-32-bits
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ** -group-by-64-bits
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ** -iso iso character set.
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ** -big-endian Big Endian
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ** -little-endian Little Endian
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ** -un || -de from hexl format to binary.
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 ** -- End switch list.
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 ** <filename> dump filename
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 ** - (as filename == stdin)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 */
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 while (*argv && *argv[0] == '-' && (*argv)[1])
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 /* A switch! */
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 if (!strcmp(*argv, "--"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 break;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 } else if (!strcmp(*argv, "-un") || !strcmp(*argv, "-de"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 un_flag = TRUE;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 } else if (!strcmp(*argv, "-hex"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 base = 16;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 } else if (!strcmp(*argv, "-iso"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 iso_flag = TRUE;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 } else if (!strcmp(*argv, "-oct"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 base = 8;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 } else if (!strcmp(*argv, "-big-endian"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 endian = 1;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 } else if (!strcmp(*argv, "-little-endian"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 endian = 0;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 } else if (!strcmp(*argv, "-group-by-8-bits"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 group_by = 0x00;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 } else if (!strcmp(*argv, "-group-by-16-bits"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 group_by = 0x01;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 } else if (!strcmp(*argv, "-group-by-32-bits"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 group_by = 0x03;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 } else if (!strcmp(*argv, "-group-by-64-bits"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 group_by = 0x07;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 endian = 0;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 --argc; argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 } else
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (void) fprintf(stderr, "%s: invalid switch: \"%s\".\n", progname,
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 *argv);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 usage();
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 do
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 if (*argv == NULL)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 fp = stdin;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 else
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 char *filename = *argv++;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 if (!strcmp(filename, "-"))
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 fp = stdin;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 else
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 if ((fp = fopen(filename, "r")) == NULL)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 perror(filename);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 continue;
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
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 if (un_flag)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 char buf[18];
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 for (;;)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 register int i, c, d;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 #define hexchar(x) (isdigit(x) ? x - '0' : x - 'a' + 10)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 (void) fread(buf, 1, 10, fp); /* skip 10 bytes */
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 for (i=0; i < 16; ++i)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 if ((c = getc(fp)) == ' ' || c == EOF)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 break;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 d = getc(fp);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 c = hexchar(c) * 0x10 + hexchar(d);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (void) putchar(c);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 if ((i&group_by) == group_by)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (void) getc(fp);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 if (c == ' ')
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 while ((c = getc(fp)) != '\n' && c != EOF)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 ;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 if (c == EOF)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 break;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 else
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 if (i < 16)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 break;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (void) fread(buf, 1, 18, fp); /* skip 18 bytes */
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 else
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 address = 0;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 string[0] = ' ';
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 string[17] = '\0';
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 for (;;)
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 register int i, c;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 for (i=0; i < 16; ++i)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 if ((c = getc(fp)) == EOF)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 if (!i)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 break;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (void) fputs(" ", stdout);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 string[i+1] = '\0';
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 else
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 if (!i)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (void) printf("%08x: ", address);
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 if (iso_flag)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 string[i+1] =
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 (c < 0x20 || (c >= 0x7F && c < 0xa0)) ? '.' :c;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 else
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 string[i+1] = (c < 0x20 || c >= 0x7F) ? '.' : c;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (void) printf("%02x", c);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 if ((i&group_by) == group_by)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (void) putchar(' ');
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 if (i)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (void) puts(string);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 if (c == EOF)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 break;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 address += 0x10;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 if (fp != stdin)
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (void) close(fp);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 } while (*argv != NULL);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 return 0;
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 }
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 usage()
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 {
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (void) fprintf(stderr, "usage: %s [-de] [-iso]\n", progname);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 exit(1);
7c9f757a985a entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 }