Counter Strike : Global Offensive Source Code
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.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Generic CRC functions
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CHECKSUM_CRC_H
  8. #define CHECKSUM_CRC_H
  9. #include <tier0/platform.h>
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. typedef uint32 CRC32_t;
  14. void CRC32_Init( CRC32_t *pulCRC );
  15. void CRC32_ProcessBuffer( CRC32_t *pulCRC, const void *p, int len );
  16. void CRC32_Final( CRC32_t *pulCRC );
  17. CRC32_t CRC32_GetTableEntry( unsigned int slot );
  18. inline CRC32_t CRC32_ProcessSingleBuffer( const void *p, int len )
  19. {
  20. CRC32_t crc;
  21. CRC32_Init( &crc );
  22. CRC32_ProcessBuffer( &crc, p, len );
  23. CRC32_Final( &crc );
  24. return crc;
  25. }
  26. inline unsigned long CRC32_ConvertToUnsignedLong( CRC32_t *pulCRC )
  27. {
  28. return (unsigned long)(*pulCRC);
  29. }
  30. inline CRC32_t CRC32_ConvertFromUnsignedLong( unsigned long ulCRC )
  31. {
  32. return (CRC32_t)(ulCRC);
  33. }
  34. typedef uint64 CRC64_t;
  35. void CRC64_Init( CRC64_t *pCRC );
  36. void CRC64_ProcessBuffer( CRC64_t *pCRC, const void *p, int len );
  37. void CRC64_Final( CRC64_t *pCRC );
  38. inline CRC64_t CRC64_ProcessSingleBuffer( const void *p, int len )
  39. {
  40. CRC64_t crc;
  41. CRC64_Init( &crc );
  42. CRC64_ProcessBuffer( &crc, p, len );
  43. CRC64_Final( &crc );
  44. return crc;
  45. }
  46. #endif // CHECKSUM_CRC_H