home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 110_01 / bin2hex.c < prev    next >
C/C++ Source or Header  |  1984-03-03  |  1KB  |  54 lines

  1. /*
  2.     Binary to HEX-ASCII utility
  3.  
  4.     Makes a binary file into a HEX file, 32 bytes/block with
  5.     proper sumcheck byte at the end. The starting address for the
  6.     HEX file is settable; the input is assumed to be contiguous
  7.     locations. Some garbage may be included at the end of the
  8.     HEX file since the program does not recognize 0x1A as an
  9.     end-of-file code in the binary input.
  10.  
  11.     Called with:
  12.         bin2hex [<binary file 1> [<bin. file 2>...]]
  13.  
  14.     Nothing special required, but if you have NSECTS
  15.     set larger than 1 you may want to include the
  16.     modified "getc" for better end-of-file indication.
  17.  
  18. written by:
  19.     Robert Pasky
  20.     36 Wiswall Rd
  21.     Newton Centre, MA 01259
  22. */
  23.  
  24. #include "bdscio.h"
  25.  
  26. #define CTRLQ 0x11    /* quit key: control-q */
  27.  
  28. int i, j, fd;
  29. int addr,sad;
  30. char fnbuf[30], *fname;        /* filename buffer & ptr */
  31. char onbuf[30], *oname;        /* output filename buf & ptr */
  32. char ibuf[BUFSIZ];    /* buffered input buffer */
  33. char obuf[BUFSIZ];    /* buffered output */
  34. char hextab[16];
  35. char kybdbuf[20];
  36. char sumcheck;
  37.  
  38. main(argc,argv)
  39. char **argv;
  40. {
  41.     strcpy(hextab,"0123456789ABCDEF");
  42.  
  43.     while (1)
  44.     {
  45.         oname = onbuf;
  46.         if (argc-1)
  47.          {
  48.             fname = *++argv;
  49.             argc--;
  50.          }
  51.         else
  52.          {
  53.             printf ("\nEnter binary file name: ");
  54.             if (!*(fname = get