home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / ZOO21E.EXE / ADDBFCRC.C next >
C/C++ Source or Header  |  1991-07-11  |  887b  |  37 lines

  1. #ifndef LINT
  2. static char sccsid[]="@(#) addbfcrc.c 2.2 88/01/29 17:04:31";
  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 originally from an article by David Schwaderer
  12. in the April 1985 issue of PC Tech Journal.
  13.  
  14. Loop optimization done by J. Brian Waters.
  15.  
  16. I claim no copyright over the contents of this file.
  17.  
  18.                                     -- Rahul Dhesi 1986/08/27
  19.  
  20. */
  21.  
  22. extern unsigned int crccode;
  23. extern unsigned crctab[];
  24.  
  25. void addbfcrc(buffer,count)
  26. register char *buffer;
  27. register int count;
  28.  
  29. {
  30.    register unsigned int localcrc;
  31.    localcrc = crccode;
  32.  
  33.    for (; count--; )
  34.       localcrc = (localcrc>>8) ^ crctab[(localcrc ^ (*buffer++)) & 0x00ff];
  35.    crccode = localcrc;
  36. }
  37.