SDL standard library
Embed:
(wiki syntax)
Show/hide line numbers
SDL_test_crc32.h
Go to the documentation of this file.
00001 /* 00002 Simple DirectMedia Layer 00003 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any damages 00007 arising from the use of this software. 00008 00009 Permission is granted to anyone to use this software for any purpose, 00010 including commercial applications, and to alter it and redistribute it 00011 freely, subject to the following restrictions: 00012 00013 1. The origin of this software must not be misrepresented; you must not 00014 claim that you wrote the original software. If you use this software 00015 in a product, an acknowledgment in the product documentation would be 00016 appreciated but is not required. 00017 2. Altered source versions must be plainly marked as such, and must not be 00018 misrepresented as being the original software. 00019 3. This notice may not be removed or altered from any source distribution. 00020 */ 00021 00022 /** 00023 * \file SDL_test_crc32.h 00024 * 00025 * Include file for SDL test framework. 00026 * 00027 * This code is a part of the SDL2_test library, not the main SDL library. 00028 */ 00029 00030 /* 00031 00032 Implements CRC32 calculations (default output is Perl String::CRC32 compatible). 00033 00034 */ 00035 00036 #ifndef _SDL_test_crc32_h 00037 #define _SDL_test_crc32_h 00038 00039 #include "begin_code.h" 00040 /* Set up for C function definitions, even when using C++ */ 00041 #ifdef __cplusplus 00042 extern "C" { 00043 #endif 00044 00045 00046 /* ------------ Definitions --------- */ 00047 00048 /* Definition shared by all CRC routines */ 00049 00050 #ifndef CrcUint32 00051 #define CrcUint32 unsigned int 00052 #endif 00053 #ifndef CrcUint8 00054 #define CrcUint8 unsigned char 00055 #endif 00056 00057 #ifdef ORIGINAL_METHOD 00058 #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ 00059 #else 00060 #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ 00061 #endif 00062 00063 /** 00064 * Data structure for CRC32 (checksum) computation 00065 */ 00066 typedef struct { 00067 CrcUint32 crc32_table[256]; /* CRC table */ 00068 } SDLTest_Crc32Context; 00069 00070 /* ---------- Function Prototypes ------------- */ 00071 00072 /** 00073 * /brief Initialize the CRC context 00074 * 00075 * Note: The function initializes the crc table required for all crc calculations. 00076 * 00077 * /param crcContext pointer to context variable 00078 * 00079 * /returns 0 for OK, -1 on error 00080 * 00081 */ 00082 int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); 00083 00084 00085 /** 00086 * /brief calculate a crc32 from a data block 00087 * 00088 * /param crcContext pointer to context variable 00089 * /param inBuf input buffer to checksum 00090 * /param inLen length of input buffer 00091 * /param crc32 pointer to Uint32 to store the final CRC into 00092 * 00093 * /returns 0 for OK, -1 on error 00094 * 00095 */ 00096 int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 00097 00098 /* Same routine broken down into three steps */ 00099 int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 00100 int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 00101 int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 00102 00103 00104 /** 00105 * /brief clean up CRC context 00106 * 00107 * /param crcContext pointer to context variable 00108 * 00109 * /returns 0 for OK, -1 on error 00110 * 00111 */ 00112 00113 int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); 00114 00115 00116 /* Ends C function definitions when using C++ */ 00117 #ifdef __cplusplus 00118 } 00119 #endif 00120 #include "close_code.h" 00121 00122 #endif /* _SDL_test_crc32_h */ 00123 00124 /* vi: set ts=4 sw=4 expandtab: */
Generated on Tue Jul 12 2022 13:56:25 by 1.7.2