summaryrefslogtreecommitdiff
path: root/package/sash/src/hexdump.c
diff options
context:
space:
mode:
authormirabilos <tg@mirbsd.org>2017-11-18 12:37:08 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2017-11-19 09:09:27 +0100
commit69229e524cde4412eb111180f15e073cc00366d9 (patch)
treebbe1a9e2f1157ca23b233fcf2d73a8c1f229d4a6 /package/sash/src/hexdump.c
parentd68e2217231db1a738374dbff846a5612be621a0 (diff)
clean up sash
Signed-off-by: mirabilos <tg@mirbsd.org>
Diffstat (limited to 'package/sash/src/hexdump.c')
-rw-r--r--package/sash/src/hexdump.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/package/sash/src/hexdump.c b/package/sash/src/hexdump.c
index f12f62494..8b271981a 100644
--- a/package/sash/src/hexdump.c
+++ b/package/sash/src/hexdump.c
@@ -32,13 +32,13 @@ do_hexdump(argc, argv)
char *name = 0;
unsigned long pos = 0;
char *myname = argv[0];
-
+
if ( (argc > 2) && !strcmp(argv[1],"-s") ) {
pos = strtoul(argv[2], 0, 0);
argc -= 2;
argv += 2;
}
-
+
if (argc <= 1) {
fprintf(stderr, "No filename provided\n");
return;
@@ -54,15 +54,15 @@ do_hexdump(argc, argv)
if (pos)
fseek(fp, pos, SEEK_SET);
-
+
c = 0;
-
+
text[16] = 0;
-
+
while(!feof(fp)) {
-
+
strcmp(text, " ");
-
+
while (c < (pos & 0xf)) {
if (c == 0)
printf("%4X:", pos & 0xfffffff0);
@@ -70,35 +70,35 @@ do_hexdump(argc, argv)
text[c] = ' ';
c++;
}
-
+
{
int p = 0;
count = fread(buf, 1, 128 - (pos % 16), fp);
-
+
if (count <= 0)
break;
while (p < count) {
c = (pos & 0xf);
-
+
if (c == 0)
printf("%4X:", pos & 0xfffffff0);
-
+
if ((buf[p] < 32) || (buf[p]>126))
text[c] = '.';
else
text[c] = buf[p];
-
+
printf( (c==15) ? " %02.2X" : (c == 8) ? "-%02.2X" : " %02.2X", buf[p]);
-
+
if (c == 15)
printf(" %s\n", text);
-
+
pos++;
p++;
}
}
-
+
if (c = (pos & 0x0f)) {
while (c < 16) {
@@ -106,16 +106,16 @@ do_hexdump(argc, argv)
text[c] = ' ';
c++;
}
-
+
printf(" %s\n", text);
}
-
+
if (feof(fp))
break;
-
+
printf("--more--");
fflush(stdout);
-
+
fgets(buf, 80, stdin);
if (toupper(buf[0]) == 'Q')
break;
@@ -124,4 +124,3 @@ do_hexdump(argc, argv)
if (fp != stdin)
fclose(fp);
}
-