// Crc16.h: interface for the Crc16 class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_CRC16_H__8BE9FD91_A066_4984_AEBA_EA04F8836263__INCLUDED_) #define AFX_CRC16_H__8BE9FD91_A066_4984_AEBA_EA04F8836263__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class Crc16 { private : static unsigned short table[ 256 ]; static int initialized; unsigned short crc; public : Crc16( unsigned short init_value ); void update( int c ); unsigned short value( void ){ return crc; } // public: // Crc16(); // virtual ~Crc16(); }; inline void Crc16::update( int c ) { crc = (unsigned short) ( table[ (( crc >> 8 ) & 0xff ) ] ^ ( crc << 8 ) ^ ( c & 0xff ) ); } #endif // !defined(AFX_CRC16_H__8BE9FD91_A066_4984_AEBA_EA04F8836263__INCLUDED_)