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

Latest commit

 

History

History
executable file
·
113 lines (90 loc) · 2.34 KB

File metadata and controls

executable file
·
113 lines (90 loc) · 2.34 KB
 
Jul 24, 2011
Jul 24, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#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
#define CrcUint32 unsigned int
#endif
#ifndef CrcUint8
#define CrcUint8 unsigned char
#endif
#ifdef ORIGINAL_METHOD
#define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */
#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
/*
* utl_crc32Init: initialize the CRC context
*
* Parameters:
*
* crcContext pointer to context variable
*
* 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
*
* Parameters:
*
* crcContext pointer to context variable
* 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:
*
* crcContext pointer to context variable
*
* 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 */