🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

124 lines
3.3 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_test_crc32.h
  20. *
  21. * Include file for SDL test framework.
  22. *
  23. * This code is a part of the SDL2_test library, not the main SDL library.
  24. */
  25. /*
  26. Implements CRC32 calculations (default output is Perl String::CRC32 compatible).
  27. */
  28. #ifndef SDL_test_crc32_h_
  29. #define SDL_test_crc32_h_
  30. #include "begin_code.h"
  31. /* Set up for C function definitions, even when using C++ */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /* ------------ Definitions --------- */
  36. /* Definition shared by all CRC routines */
  37. #ifndef CrcUint32
  38. #define CrcUint32 unsigned int
  39. #endif
  40. #ifndef CrcUint8
  41. #define CrcUint8 unsigned char
  42. #endif
  43. #ifdef ORIGINAL_METHOD
  44. #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */
  45. #else
  46. #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */
  47. #endif
  48. /**
  49. * Data structure for CRC32 (checksum) computation
  50. */
  51. typedef struct {
  52. CrcUint32 crc32_table[256]; /* CRC table */
  53. } SDLTest_Crc32Context;
  54. /* ---------- Function Prototypes ------------- */
  55. /**
  56. * \brief Initialize the CRC context
  57. *
  58. * Note: The function initializes the crc table required for all crc calculations.
  59. *
  60. * \param crcContext pointer to context variable
  61. *
  62. * \returns 0 for OK, -1 on error
  63. *
  64. */
  65. int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext);
  66. /**
  67. * \brief calculate a crc32 from a data block
  68. *
  69. * \param crcContext pointer to context variable
  70. * \param inBuf input buffer to checksum
  71. * \param inLen length of input buffer
  72. * \param crc32 pointer to Uint32 to store the final CRC into
  73. *
  74. * \returns 0 for OK, -1 on error
  75. *
  76. */
  77. int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
  78. /* Same routine broken down into three steps */
  79. int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
  80. int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
  81. int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
  82. /**
  83. * \brief clean up CRC context
  84. *
  85. * \param crcContext pointer to context variable
  86. *
  87. * \returns 0 for OK, -1 on error
  88. *
  89. */
  90. int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext);
  91. /* Ends C function definitions when using C++ */
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #include "close_code.h"
  96. #endif /* SDL_test_crc32_h_ */
  97. /* vi: set ts=4 sw=4 expandtab: */