diff options
author | Elliott Hughes <enh@google.com> | 2018-03-12 10:02:08 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-03-12 14:18:46 -0500 |
commit | 30e23c72a12fa3a95d25b15cf9a0517dae07db8b (patch) | |
tree | 3506c20fbd74f7a897db313f0614b2ba9015ae7d /toys | |
parent | f71f8485efbed0ecdd213c4e6d0c9403aa1fcd79 (diff) | |
download | toybox-30e23c72a12fa3a95d25b15cf9a0517dae07db8b.tar.gz |
Add xxd -o.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/other/xxd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/toys/other/xxd.c b/toys/other/xxd.c index edc5772c..6203d7aa 100644 --- a/toys/other/xxd.c +++ b/toys/other/xxd.c @@ -10,13 +10,13 @@ * xxd -p "plain" output: * "4c696e75782076657273696f6e20342e392e302d342d616d643634202864" -USE_XXD(NEWTOY(xxd, ">1c#l#g#<1=2iprs#[!rs]", TOYFLAG_USR|TOYFLAG_BIN)) +USE_XXD(NEWTOY(xxd, ">1c#l#o#g#<1=2iprs#[!rs]", TOYFLAG_USR|TOYFLAG_BIN)) config XXD bool "xxd" default y help - usage: xxd [-c n] [-g n] [-i] [-l n] [-p] [-r] [-s n] [file] + usage: xxd [-c n] [-g n] [-i] [-l n] [-o n] [-p] [-r] [-s n] [file] Hexdump a file to stdout. If no file is listed, copy from stdin. Filename "-" is a synonym for stdin. @@ -25,6 +25,7 @@ config XXD -g n Group bytes by adding a ' ' every n bytes (default 2) -i Include file output format (comma-separated hex byte literals) -l n Limit of n bytes before stopping (default is no limit) + -o n Add n to display offset -p Plain hexdump (30 bytes/line, no grouping) -r Reverse operation: turn a hexdump into a binary file -s n Skip to offset n @@ -36,6 +37,7 @@ config XXD GLOBALS( long s; long g; + long o; long l; long c; ) @@ -54,7 +56,7 @@ static void do_xxd(int fd, char *name) while (0<(len = readall(fd, toybuf, (limit && limit-pos<TT.c)?limit-pos:TT.c))) { - if (!(toys.optflags&FLAG_p)) printf("%08llx: ", pos); + if (!(toys.optflags&FLAG_p)) printf("%08llx: ", TT.o + pos); pos += len; space = 2*TT.c+TT.c/TT.g+1; |