home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / util / unix / macutil2.sha / macutil / hexbin / crc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  757 b   |  45 lines

  1. /* crc.c; do crc calculation. */
  2.  
  3. #include <stdio.h>
  4. #include "hexbin.h"
  5. #include "crc.h"
  6. #include "../util/masks.h"
  7. #include "globals.h"
  8.  
  9. extern void exit();
  10.  
  11. unsigned long crc;
  12.  
  13. #ifdef HQX
  14. void comp_q_crc(c)
  15. register unsigned int c;
  16. {
  17.     unsigned char cc = c;
  18.  
  19.     crc = binhex_updcrc(crc, &cc, 1);
  20. }
  21.  
  22. void comp_q_crc_n(s, e)
  23. register unsigned char *s, *e;
  24. {
  25.     crc = binhex_updcrc(crc, s, e - s);
  26. }
  27. #endif /* HQX */
  28.  
  29. void verify_crc(calc_crc, file_crc)
  30. unsigned long calc_crc, file_crc;
  31. {
  32.     calc_crc &= WORDMASK;
  33.     file_crc &= WORDMASK;
  34.  
  35.     if(calc_crc != file_crc) {
  36.         (void)fprintf(stderr, "CRC mismatch: got 0x%04lx, need 0x%04lx\n",
  37.         file_crc, calc_crc);
  38. #ifdef SCAN
  39.     do_error("hexbin: CRC error");
  40. #endif /* SCAN */
  41.     exit(1);
  42.     }
  43. }
  44.  
  45.