diff options
author | Rob Landley <rob@landley.net> | 2015-07-03 15:19:07 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-07-03 15:19:07 -0500 |
commit | 6b6daecc7c87746aa0f38a298aecd2c38ee60520 (patch) | |
tree | 9db0ee6d2b39ae9ebbe4ce513d370d4a3ad02b9c /toys/pending | |
parent | 9933273c5b7b6e0471d9195e8c2facb795b795ae (diff) | |
download | toybox-6b6daecc7c87746aa0f38a298aecd2c38ee60520.tar.gz |
Promote xxd to other.
Diffstat (limited to 'toys/pending')
-rw-r--r-- | toys/pending/xxd.c | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/toys/pending/xxd.c b/toys/pending/xxd.c deleted file mode 100644 index dee8c316..00000000 --- a/toys/pending/xxd.c +++ /dev/null @@ -1,65 +0,0 @@ -/* xxd.c - hexdump. - * - * Copyright 2015 The Android Open Source Project - * - * No obvious standard, output looks like: - * 0000000: 4c69 6e75 7820 7665 7273 696f 6e20 332e Linux version 3. - * - * TODO: support for reversing a hexdump back into the original data. - * TODO: -s seek - -USE_XXD(NEWTOY(xxd, ">1c#<1>4096=16l#g#<1=2", TOYFLAG_USR|TOYFLAG_BIN)) - -config XXD - bool "xxd" - default n - help - usage: xxd [-c n] [-g n] [-l n] [file] - - Hexdump a file to stdout. If no file is listed, copy from stdin. - Filename "-" is a synonym for stdin. - - -c n Show n bytes per line (default 16). - -g n Group bytes by adding a ' ' every n bytes (default 2). - -l n Limit of n bytes before stopping (default is no limit). -*/ - -#define FOR_xxd -#include "toys.h" - -GLOBALS( - long g; - long l; - long c; -) - -static void do_xxd(int fd, char *name) -{ - long long pos = 0; - int i, len, space; - - while (0<(len = readall(fd, toybuf, (TT.l && TT.l-pos<TT.c)?TT.l-pos:TT.c))) { - printf("%08llx: ", pos); - pos += len; - space = 2*TT.c+TT.c/TT.g+1; - - for (i=0; i<len;) { - space -= printf("%02x", toybuf[i]); - if (!(++i%TT.g)) { - putchar(' '); - space--; - } - } - - printf("%*s", space, ""); - for (i=0; i<len; i++) - putchar((toybuf[i]>=' ' && toybuf[i]<='~') ? toybuf[i] : '.'); - putchar('\n'); - } - if (len<0) perror_exit("read"); -} - -void xxd_main(void) -{ - loopfiles(toys.optargs, do_xxd); -} |