Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
113 lines (90 loc) · 2.35 KB

File metadata and controls

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