Leaked source code of windows server 2003
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.

59 lines
1.2 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. CRC32.H
  5. Abstract:
  6. Standard CRC-32 implementation
  7. History:
  8. raymcc 07-Jul-97 Createada
  9. --*/
  10. #ifndef _CRC_H_
  11. #define _CRC_H_
  12. #define STARTING_CRC32_VALUE 0xFFFFFFFF
  13. DWORD UpdateCRC32(
  14. LPBYTE pSrc, // Points to buffer
  15. int nBytes, // Number of bytes to compute
  16. DWORD dwOldCrc // Must be STARTING_CRC_VALUE (0xFFFFFFFF)
  17. // if no previous CRC, otherwise this is the
  18. // CRC of the previous cycle.
  19. );
  20. #define FINALIZE_CRC32(x) (x=~x)
  21. /*
  22. The CRC holding value must be preinitialized to STARTING_CRC32_VALUE
  23. UpdateCRC32() may be called as many times as necessary on a single buffer.
  24. When computing the CRC32
  25. The final value must be post-processed using the FINALIZE_CRC32() macro.
  26. Example:
  27. void main()
  28. {
  29. BYTE Data[] = { 1, 2, 3 };
  30. DWORD dwCRC = STARTING_CRC32_VALUE;
  31. dwCRC = UpdateCRC32(Data, 3, dwCRC);
  32. FINALIZE_CRC32(dwCRC);
  33. printf("CRC32 = 0x%X\n", dwCRC);
  34. }
  35. */
  36. #endif