/* hexd.c: a hex-dumper for muLinux ------------------------------------ -code : encode in hex + ascii -decode: decode only hex rows. User can edit them. */ /* * Copyright (C) 1999 * Michele Andreoli, andreoli@pisoft.it - Public domain. */ #include #include #define USAGE "hex code/decode: (C) by M. Andreoli 1999\n\ Usage hex [-h|-help] [-c|-code] [-d|-decode] (read/write from stdin/stdout)\n" #define R 17 #define COUNTER 6 /* functions */ /* * code() */ int code() { unsigned char buf[R]; int j=0,i=0,n,c; while (1) { /* read the buffer */ n=read(0, buf, R); if (n <= 0) break; /* finish */ /* row number */ fprintf(stdout,"%0*d: ",COUNTER,i); /* write the buffer in HEX */ for (j=0; j