Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. 1998 Seagate Software, Inc. All rights reserved.
  4. Module Name:
  5. wsbfile.h
  6. Abstract:
  7. This module defines very specific CRC algorithm code
  8. Author:
  9. Christopher J. Timmes [ctimmes@avail.com] 23 Jun 1997
  10. Revision History:
  11. Michael Lotz [lotz] 30-Sept-1997
  12. --*/
  13. #ifndef _WSBFILE_H
  14. #define _WSBFILE_H
  15. extern unsigned long crc_32_tab[];
  16. extern "C"
  17. {
  18. extern
  19. WSB_EXPORT
  20. HRESULT WsbCRCReadFile ( BYTE* pchCurrent,
  21. ULONG* oldcrc32 );
  22. }
  23. // ---------- implementation code for WsbCalcCRCofFile() ----------
  24. // This is the CRC calculation algorythm.
  25. // It is called with the current byte in the file and the current CRC value,
  26. // and uses the 'crc_32_tab[]' table. The crc_32_tab[] look up table is externed above and resides
  27. // in the wsbfile.obj object module. Any function or method using the macro below must include
  28. // the wsbfile.obj in the link list.
  29. //
  30. // For example, it can be used in the following way:
  31. // unsigned long ulCRC ;
  32. //
  33. // INITIALIZE_CRC( ulCRC );
  34. // for( all *bytes* that are to be CRCed )
  35. // CALC_CRC( current_byte, ulCRC );
  36. // FINIALIZE_CRC( ulCRC );
  37. //
  38. // at this point ulCRC is the CRC value and can be used as the calculated CRC value
  39. //
  40. #define INITIALIZE_CRC( crc ) ((crc) = 0xFFFFFFFF )
  41. #define CALC_CRC( octet, crc ) ((crc) = ( crc_32_tab[((crc)^ (octet)) & 0xff] ^ ((crc) >> 8) ) )
  42. #define FINIALIZE_CRC( crc ) ((crc) = ~(crc) )
  43. // ---------------------- Defines to identify the CRC calculation types -------------
  44. #define WSB_CRC_CALC_NONE 0x00000000
  45. // Identify this algorithm and the Microsoft 32 bit CRC calculation
  46. #define WSB_CRC_CALC_MICROSOFT_32 0x00000001
  47. #endif // _WSBFILE_H