summaryrefslogtreecommitdiff
path: root/hexdump.py
diff options
context:
space:
mode:
authoritsme <itsme@xs4all.nl>2021-07-09 02:08:22 +0200
committeritsme <itsme@xs4all.nl>2021-07-09 02:08:22 +0200
commit2a9e53566d873b226d1523adcb80f78c14b4d773 (patch)
treeee374fcf8b441e75bad32f3d659bb75c36f55d48 /hexdump.py
parent8bcb2e9f570d3ee4a84884e5907b03e37a0b8389 (diff)
added support for compressed records. kodump now supports a --width option.
Diffstat (limited to 'hexdump.py')
-rw-r--r--hexdump.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/hexdump.py b/hexdump.py
index cbba3c9..984a19f 100644
--- a/hexdump.py
+++ b/hexdump.py
@@ -26,9 +26,17 @@ def aschr(b):
26 return "." 26 return "."
27def asasc(line): 27def asasc(line):
28 return "".join(aschr(_) for _ in line) 28 return "".join(aschr(_) for _ in line)
29def hexdump(ofs, data): 29def hexdump(ofs, data, args):
30 for o in range(0, len(data), 16): 30 w = args.width
31 print("%08x: %-47s %s" % (o+ofs, ashex(data[o:o+16]), asasc(data[o:o+16]))) 31 if args.ascdump:
32 fmt = "%08x: %s"
33 else:
34 fmt = "%%08x: %%-%ds %%s" % (3*w-1)
35 for o in range(0, len(data), w):
36 if args.ascdump:
37 print(fmt % (o+ofs, asasc(data[o:o+w])))
38 else:
39 print(fmt % (o+ofs, ashex(data[o:o+w]), asasc(data[o:o+w])))
32 40
33def tohex(data): 41def tohex(data):
34 return b2a_hex(data).decode('ascii') 42 return b2a_hex(data).decode('ascii')