OSDN Git Service

add sdl-1.3
[android-x86/external-stagefright-plugins.git] / SDL-1.3 / android-project / jni / SDL / test / test-automation / src / libSDLtest / fuzzer / utl_crc32.h
1 #ifndef _utl_crc32_h
2 #define _utl_crc32_h
3
4 /* Set up for C function definitions, even when using C++ */
5 #ifdef __cplusplus
6 extern    "C" {
7 #endif
8
9 /* ----------- Includes -------------- */
10
11 #include <stdlib.h>
12
13 /* ------------ Definitions --------- */
14
15 /* Definition shared by all CRC routines */
16
17 #ifndef CrcUint32
18  #define CrcUint32      unsigned int
19 #endif
20 #ifndef CrcUint8
21  #define CrcUint8       unsigned char
22 #endif
23
24 #ifdef ORIGINAL_METHOD
25  #define CRC32_POLY 0x04c11db7   /* AUTODIN II, Ethernet, & FDDI */
26 #else
27  #define CRC32_POLY 0xEDB88320   /* Perl String::CRC32 compatible */
28 #endif
29
30 /* Data structure for CRC32 (checksum) computation */
31
32   typedef struct {
33    CrcUint32    crc32_table[256]; /* CRC table */
34   } CRC32_CTX;
35
36 /* ---------- Function Prototypes ------------- */
37
38 #ifdef WIN32
39 #ifdef BUILD_DLL
40 #define DLLINTERFACE __declspec(dllexport)
41 #else
42 #define DLLINTERFACE __declspec(dllimport)
43 #endif
44 #else
45 #define DLLINTERFACE
46 #endif
47
48 /* 
49  * utl_crc32Init: initialize the CRC context
50  *
51  * Parameters:
52  *
53  *   crcContext         pointer to context variable
54  *
55  * Return value:
56  *
57  *   0          OK
58  *  -1          error
59  *
60  * Note: The function initializes the crc table required for crc calcs.
61  */
62   DLLINTERFACE int utl_crc32Init(CRC32_CTX * crcContext);
63
64
65 /*
66  * utl_crc32Calc: calculate a crc32 from a data block
67  * 
68  * Parameters:
69  *
70  *   crcContext         pointer to context variable
71  *   inBuf              input buffer to checksum
72  *   inLen              length of input buffer
73  *   crc32              pointer to Uint32 to store the final CRC into
74  *
75  * Return value:
76  *
77  *   0        OK
78  *  -1        error
79  *
80 */
81
82   DLLINTERFACE int utl_crc32Calc(CRC32_CTX * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
83
84 /* Same routine broken down into three steps */
85
86  DLLINTERFACE int utl_crc32CalcStart(CRC32_CTX * crcContext, CrcUint32 *crc32);
87  DLLINTERFACE int utl_crc32CalcEnd(CRC32_CTX * crcContext, CrcUint32 *crc32);
88  DLLINTERFACE int utl_crc32CalcBuffer(CRC32_CTX * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
89
90
91 /*
92  * utl_crc32Done: clean up CRC context
93  *
94  * Parameters:
95  *
96  *   crcContext         pointer to context variable
97  *
98  * Return value:
99  *
100  *   0            OK
101  *  -1            error
102  *
103 */
104
105   DLLINTERFACE int utl_crc32Done(CRC32_CTX * crcContext);
106
107
108 /* Ends C function definitions when using C++ */
109 #ifdef __cplusplus
110 };
111 #endif
112
113 #endif /* _utl_crc32_h */