Skip to content

Commit

Permalink
New hex program
Browse files Browse the repository at this point in the history
  • Loading branch information
nealey committed Aug 9, 2017
1 parent 0c37c73 commit 5dd38fb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Usually, a program expects input on stdin,
and produces output on stdout.
Flags are sparse by design.

Fluffy source code is purposefully spartan and easy to audit.
Forks are encouraged,
please let me know if you make one.


How To Build
------------
Expand Down Expand Up @@ -114,6 +118,15 @@ Removes duplicate frames from input,
writing to output.


### hex: hex-encode input

The opposite of `unhex`.

The following is the equivalent of `cat`:

hex | unhex


### printfesc: printf escape input

Reads octets,
Expand Down
22 changes: 22 additions & 0 deletions hex.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>

int
main(int argc, char *argv[])
{
size_t count;

for (count = 0; ; count += 1) {
int c = getchar();

if (EOF == c) {
break;
}
printf("%02x ", c);
if (7 == count % 8) {
putchar(' ');
}
}
putchar('\n');

return 0;
}

0 comments on commit 5dd38fb

Please sign in to comment.