home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / OS2LHX.LZH / ADDBFCRC.C next >
C/C++ Source or Header  |  1989-04-15  |  955b  |  39 lines

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