home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / zoo / part01 / addbfcrc.c next >
Encoding:
C/C++ Source or Header  |  1987-08-16  |  863 b   |  38 lines

  1. #ifndef LINT
  2. static char sccsid[]="@(#) addbfcrc.c 1.2 87/05/03 16:00:26";
  3. #endif /* LINT */
  4.  
  5. #include "options.h"
  6. /*
  7. addbfcrc() accepts a buffer address and a count and adds the CRC for
  8. all bytes in the buffer to the global variable crccode using
  9. CRC-16.
  10.  
  11. CRC computation algorithm taken from source code for ARC 5.12, which
  12. in turn took it from an article by David Schwaderer in the April 1985
  13. issue of PC Tech Journal.
  14.  
  15. I claim no copyright over the contents of this file.
  16.  
  17.                                     -- Rahul Dhesi 1986/12/31
  18.  
  19. */
  20.  
  21. extern unsigned int crccode;
  22. extern unsigned crctab[];
  23.  
  24. void addbfcrc(buffer,count)
  25. char *buffer;
  26. int count;
  27.  
  28. {
  29.    register unsigned int localcrc;
  30.    register int i;
  31.    localcrc = crccode;
  32.  
  33.    for (i=0; i<count; i++)
  34.       localcrc = (localcrc>>8) ^ crctab[(localcrc ^ (buffer[i])) & 0x00ff];
  35.    crccode = localcrc;
  36. }
  37.  
  38.