aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-14 04:40:37 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-14 04:40:37 -0500
commit072544c2f6072d4fabc8db354cbd128388caa243 (patch)
tree0222bf18f5118e535c916eb4c4548cef5ba3a5a5
parent56fd406b636f29e4178c888ac62337b9c792f3dd (diff)
downloaduxd-072544c2f6072d4fabc8db354cbd128388caa243.tar.gz
document options in man page, implement -o.
-rw-r--r--uxd.136
-rw-r--r--uxd.c6
-rw-r--r--uxd.rst30
3 files changed, 65 insertions, 7 deletions
diff --git a/uxd.1 b/uxd.1
index 171929e..cbfad7e 100644
--- a/uxd.1
+++ b/uxd.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "UXD" 1 "2024-12-13" "0.1.0" "Urchlay's Utilities"
+.TH "UXD" 1 "2024-12-14" "0.1.0" "Urchlay's Utilities"
.SH NAME
uxd \- UTF-8 hex dumper
.SH SYNOPSIS
@@ -51,8 +51,38 @@ terminal. It\(aqs assumed that the terminal supports ANSI\-style color and
UTF\-8. See \fBTERMINAL SUPPORT\fP below. If you want to pipe the output
to a pager, try \fBless \-R\fP\&.
.SH OPTIONS
-.sp
-There are no options yet.
+.INDENT 0.0
+.TP
+.B \-r
+Highlight multi\-byte sequences in reverse video, in the hex output.
+.TP
+.B \-m
+Monochrome mode. Uses underline, bold, reverse video instead of color.
+Use this if you have trouble distinguishing the colors, or if they
+look too much like angry fruit salad.
+NOT IMPLEMENTED YET.
+.TP
+.BI \-o \ offset
+Add this amount to the hex offsets (left column). May be negative,
+if you can think of a reason to want it to be. Can be given in
+decimal, hex (with \fI0x\fP prefix), or octal (with \fI0\fP prefix).
+.TP
+.BI \-s \ position
+Seek in input before starting to dump. Positive \fIposition\fP means
+seek from the start of the input. Negative \fIposition\fP only works
+on files (not standard input); it means seek backward from EOF.
+NOT IMPLEMENTED YET.
+.TP
+.B \-u
+Use uppercase hex digits A\-F. Default is lowercase.
+NOT IMPLEMENTED YET.
+.TP
+.B \-h\fP,\fB \-\-help
+Print built\-in usage message and exit.
+.TP
+.B \-v\fP,\fB \-\-version
+Print version number and exit.
+.UNINDENT
.SH OUTPUT FORMAT
.sp
The output is designed to fit in an 80\-column terminal.
diff --git a/uxd.c b/uxd.c
index f58c24e..3f9d363 100644
--- a/uxd.c
+++ b/uxd.c
@@ -128,10 +128,10 @@ void parse_options(int argc, char **argv) {
case 'm':
mono = 1; break;
case 'o':
- display_offset = atoi(optarg);
+ display_offset = strtol(optarg, NULL, 0);
break;
case 's':
- seekpos = atoi(optarg);
+ seekpos = strtol(optarg, NULL, 0);
break;
case 'u':
uppercase = 1; break;
@@ -227,7 +227,7 @@ void append_left(unsigned char byte, int dash, int fgcolor, int bgcolor) {
char tmpbuf[100];
if(!dump_column)
- sprintf(left_buf, "%04x: ", filepos);
+ sprintf(left_buf, "%04x: ", filepos + display_offset);
append_color(left_buf, fgcolor, bgcolor);
sprintf(tmpbuf, "%02x", byte);
diff --git a/uxd.rst b/uxd.rst
index 48c6af3..e466adb 100644
--- a/uxd.rst
+++ b/uxd.rst
@@ -42,7 +42,35 @@ to a pager, try **less -R**.
OPTIONS
=======
-There are no options yet.
+-r
+ Highlight multi-byte sequences in reverse video, in the hex output.
+
+-m
+ Monochrome mode. Uses underline, bold, reverse video instead of color.
+ Use this if you have trouble distinguishing the colors, or if they
+ look too much like angry fruit salad.
+ NOT IMPLEMENTED YET.
+
+-o offset
+ Add this amount to the hex offsets (left column). May be negative,
+ if you can think of a reason to want it to be. Can be given in
+ decimal, hex (with *0x* prefix), or octal (with *0* prefix).
+
+-s position
+ Seek in input before starting to dump. Positive *position* means
+ seek from the start of the input. Negative *position* only works
+ on files (not standard input); it means seek backward from EOF.
+ NOT IMPLEMENTED YET.
+
+-u
+ Use uppercase hex digits A-F. Default is lowercase.
+ NOT IMPLEMENTED YET.
+
+-h, --help
+ Print built-in usage message and exit.
+
+-v, --version
+ Print version number and exit.
OUTPUT FORMAT
=============