summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXANTRONIX Development2023-09-13 00:09:23 -0400
committerXANTRONIX Development2023-09-13 00:09:23 -0400
commit5bc8a00f02156102e3ac613fb89931262b8b5b45 (patch)
treee4995ca8af5bfa8f5b3fe24e33ac24afd5cb85c9
parent7b71a6dfc1bd5628b429c62eeb9353b449313a73 (diff)
downloadzxdump-5bc8a00f02156102e3ac613fb89931262b8b5b45.tar.gz
zxdump-5bc8a00f02156102e3ac613fb89931262b8b5b45.tar.bz2
zxdump-5bc8a00f02156102e3ac613fb89931262b8b5b45.zip
Slight reorganisation
-rw-r--r--main.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/main.c b/main.c
index 0e3da6d..42a12bc 100644
--- a/main.c
+++ b/main.c
@@ -9,15 +9,10 @@
#include <endian.h>
#include <errno.h>
-#define ZX_DUMP_STRIDE_LINE 16
-#define ZX_DUMP_STRIDE_GROUP 2
-#define ZX_DUMP_CHARSET_LEN 64
-
-#define ZX_DUMP_FLAGS_NONE 0
-#define ZX_DUMP_FLAGS_BASIC (1 << 0)
+#define ZX_CHARSET_LEN 64
#define ZX_CHAR_LOW(c) \
- (c <= ZX_DUMP_CHARSET_LEN)
+ (c <= ZX_CHARSET_LEN)
#define ZX_CHAR_INVERSE_START 0x80
#define ZX_CHAR_INVERSE_END 0xbf
@@ -56,7 +51,7 @@ typedef struct _zx_basic_line {
#define ZX_BASIC_STATE_SIZE 116
#define ZX_BASIC_LINE_LAST 0x7676
-static uint32_t zx_charset[ZX_DUMP_CHARSET_LEN] = {
+static uint32_t zx_charset[ZX_CHARSET_LEN] = {
0x0020, 0x2598, 0x259d, 0x2580, 0x2596, 0x258c, 0x259e, 0x259b,
0x2592, '.', '.', '"', 0x00a3, '$', ':', '?',
'(', ')', '>', '<', '=', '+', '-', '*',
@@ -134,6 +129,9 @@ error_io:
return -1;
}
+#define ZX_HEXDUMP_STRIDE_LINE 16
+#define ZX_HEXDUMP_STRIDE_GROUP 2
+
static ssize_t hexdump_line(off_t offset, void *buf, size_t len, int tty) {
size_t i;
@@ -142,7 +140,7 @@ static ssize_t hexdump_line(off_t offset, void *buf, size_t len, int tty) {
}
for (i=0; i<len; i++) {
- if (i > 0 && (i % ZX_DUMP_STRIDE_GROUP) == 0) {
+ if (i > 0 && (i % ZX_HEXDUMP_STRIDE_GROUP) == 0) {
if (putchar(' ') < 0) {
goto error_io;
}
@@ -209,9 +207,9 @@ static ssize_t zx_dump_hex(int fd) {
break;
}
- for (i=0; i<len; i+=ZX_DUMP_STRIDE_LINE) {
+ for (i=0; i<len; i+=ZX_HEXDUMP_STRIDE_LINE) {
size_t left = len - i,
- linesz = left < ZX_DUMP_STRIDE_LINE? left: ZX_DUMP_STRIDE_LINE;
+ linesz = left < ZX_HEXDUMP_STRIDE_LINE? left: ZX_HEXDUMP_STRIDE_LINE;
if (hexdump_line(offset, buf, linesz, tty) < 0) {
goto error_hexdump_line;
@@ -347,6 +345,9 @@ static void usage(const char *prog, char *message, ...) {
exit(1);
}
+#define ZX_DUMP_FLAGS_NONE 0
+#define ZX_DUMP_FLAGS_BASIC (1 << 0)
+
int main(int argc, char **argv) {
int fd,
flags = ZX_DUMP_FLAGS_NONE,