File: addbfcrc.c

package info (click to toggle)
zoo 2.10-27
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,444 kB
  • ctags: 2,007
  • sloc: ansic: 18,494; asm: 793; makefile: 698
file content (36 lines) | stat: -rw-r--r-- 852 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef LINT
static char sccsid[]="@(#) addbfcrc.c 2.2 88/01/29 17:04:31";
#endif /* LINT */

#include "options.h"
/*
addbfcrc() accepts a buffer address and a count and adds the CRC for
all bytes in the buffer to the global variable crccode using
CRC-16.

CRC computation algorithm originally from an article by David Schwaderer 
in the April 1985 issue of PC Tech Journal.

Loop optimization done by J. Brian Waters.

I claim no copyright over the contents of this file.

                                    -- Rahul Dhesi 1986/08/27

*/

extern unsigned int crccode;
extern unsigned crctab[];

void addbfcrc(buffer,count)
register char *buffer;
register int count;

{
   register unsigned int localcrc;
   localcrc = crccode;

   for (; count--; )
      localcrc = (localcrc>>8) ^ crctab[(localcrc ^ (*buffer++)) & 0x00ff];
   crccode = localcrc;
}