/* * hexify.c * * read a binary file, produce a text (7 bit wide ASCII) file * * decus c version, presumed unix compliant, but not compatible */ /* * 02feb85 pf allow for zero-length records: give a blank line in * hex file. useful for t2b output records. * * bug: the output always begins with a superflous '\n' */ #include extern int $$ferr; #include #define BUFSIZ 1024 char buf[BUFSIZ]; /* some machines have small stacks */ main(argc,argv) int argc; char **argv; BEGIN int fd; /* handle of input file */ int howlong; /* length of input buffer in chars */ register char *p; /* scan input buffer */ register int test; /* used to put '\n' after 32 %02x outputs */ register char *nd; /* end of buffer scan */ fd = fopen(argv[1],"ur"); WHILE (TRUE) DO howlong = fget(buf,BUFSIZ,fd); IF (ferror(fd)) THEN error("read fail $$ferr=%oo",$$ferr); FI IF (feof(fd)) THEN break; FI nd = buf+howlong; FOR (p=buf; p