/[dtapublic]/projs/trunk/shared_source/c_datd/crchashfuncs.h
ViewVC logotype

Diff of /projs/trunk/shared_source/c_datd/crchashfuncs.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 70 by dashley, Sat Oct 29 01:53:01 2016 UTC revision 71 by dashley, Sat Nov 5 11:07:06 2016 UTC
# Line 1  Line 1 
1  //$Header$  //$Header$
2  //-------------------------------------------------------------------------------------------------  //-------------------------------------------------------------------------------------------------
3  //This file is part of "David T. Ashley's Shared Source Code", a set of shared components  //This file is part of "David T. Ashley's Shared Source Code", a set of shared components
4  //integrated into many of David T. Ashley's projects.  //integrated into many of David T. Ashley's projects.
5  //-------------------------------------------------------------------------------------------------  //-------------------------------------------------------------------------------------------------
6  //This source code and any program in which it is compiled/used is provided under the MIT License,  //This source code and any program in which it is compiled/used is provided under the MIT License,
7  //reproduced below.  //reproduced below.
8  //-------------------------------------------------------------------------------------------------  //-------------------------------------------------------------------------------------------------
9  //Permission is hereby granted, free of charge, to any person obtaining a copy of  //Permission is hereby granted, free of charge, to any person obtaining a copy of
10  //this software and associated documentation files(the "Software"), to deal in the  //this software and associated documentation files(the "Software"), to deal in the
11  //Software without restriction, including without limitation the rights to use,  //Software without restriction, including without limitation the rights to use,
12  //copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the  //copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the
13  //Software, and to permit persons to whom the Software is furnished to do so,  //Software, and to permit persons to whom the Software is furnished to do so,
14  //subject to the following conditions :  //subject to the following conditions :
15  //  //
16  //The above copyright notice and this permission notice shall be included in all  //The above copyright notice and this permission notice shall be included in all
17  //copies or substantial portions of the Software.  //copies or substantial portions of the Software.
18  //  //
19  //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE  //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
22  //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  //SOFTWARE.  //SOFTWARE.
26  //-------------------------------------------------------------------------------------------------  //-------------------------------------------------------------------------------------------------
27  //This software module is concerned with functions to support the generation  //This software module is concerned with functions to support the generation
28  //of CRCs and hash functions.  CRCs and hash functions are similar in that they  //of CRCs and hash functions.  CRCs and hash functions are similar in that they
29  //provide an abstraction of a large amount of data, although CRCs may have better  //provide an abstraction of a large amount of data, although CRCs may have better
30  //(or different) statistical properties than hash functions.  These functions  //(or different) statistical properties than hash functions.  These functions
31  //are split out from any specific application for maximum reusability of the  //are split out from any specific application for maximum reusability of the
32  //code.  //code.
33    
34  #ifndef CRCHASHFUNCS_H_INCLUDED  #ifndef CRCHASHFUNCS_H_INCLUDED
35     #define CRCHASHFUNCS_H_INCLUDED     #define CRCHASHFUNCS_H_INCLUDED
36    
37     #ifdef MODULE_CRCHASHFUNCS     #ifdef MODULE_CRCHASHFUNCS
38        #define DECMOD_CRCHASHFUNCS        #define DECMOD_CRCHASHFUNCS
39     #else     #else
40        #define DECMOD_CRCHASHFUNCS extern        #define DECMOD_CRCHASHFUNCS extern
41     #endif     #endif
42    
43     //Define the state object that holds CRC-32 intermediate results as the CRC is     //Define the state object that holds CRC-32 intermediate results as the CRC is
44     //being formed.  This is conceptually private for the caller.     //being formed.  This is conceptually private for the caller.
45     //     //
46     struct CRCHASHFUNCS_Crc32StateStruct     struct CRCHASHFUNCS_Crc32StateStruct
47        {        {
48        unsigned crc;        unsigned crc;
49        //This is the only state for now.        //This is the only state for now.
50        };        };
51    
52     //All CRC32 functions are courtesy of Richard A. Ellingson     //All CRC32 functions are courtesy of Richard A. Ellingson
53     //from the Internet.     //from the Internet.
54     //     //
55     //Checks the CRC-32 table for integrity, returns non-zero if     //Checks the CRC-32 table for integrity, returns non-zero if
56     //the table is OK, or 0 if the table is corrupted.  The table     //the table is OK, or 0 if the table is corrupted.  The table
57     //is a table of constants in memory--it is not known how     //is a table of constants in memory--it is not known how
58     //much protection the "const" keyword can give it, i.e. if     //much protection the "const" keyword can give it, i.e. if
59     //the tools can put it in a memory segment where some kind     //the tools can put it in a memory segment where some kind
60     //of protection is afforded by the OS.     //of protection is afforded by the OS.
61     DECMOD_CRCHASHFUNCS     DECMOD_CRCHASHFUNCS
62     int CRCHASHFUNCS_Crc32TableCheck(void);     int CRCHASHFUNCS_Crc32TableCheck(void);
63    
64     //Initializes the CRC formation structure.     //Initializes the CRC formation structure.
65     DECMOD_CRCHASHFUNCS     DECMOD_CRCHASHFUNCS
66     void CRCHASHFUNCS_Crc32StateStructOpen(struct CRCHASHFUNCS_Crc32StateStruct *arg);     void CRCHASHFUNCS_Crc32StateStructOpen(struct CRCHASHFUNCS_Crc32StateStruct *arg);
67    
68     //Adds data to it.     //Adds data to it.
69     DECMOD_CRCHASHFUNCS     DECMOD_CRCHASHFUNCS
70     void CRCHASHFUNCS_Crc32StateStructAddData(struct CRCHASHFUNCS_Crc32StateStruct *arg,     void CRCHASHFUNCS_Crc32StateStructAddData(struct CRCHASHFUNCS_Crc32StateStruct *arg,
71                                               void *data,                                               void *data,
72                                               unsigned len);                                               unsigned len);
73    
74     //Reads the CRC out at any time.     //Reads the CRC out at any time.
75     DECMOD_CRCHASHFUNCS     DECMOD_CRCHASHFUNCS
76     unsigned CRCHASHFUNCS_Crc32Extract(struct CRCHASHFUNCS_Crc32StateStruct *arg);     unsigned CRCHASHFUNCS_Crc32Extract(struct CRCHASHFUNCS_Crc32StateStruct *arg);
77    
78     //Closes the structure.     //Closes the structure.
79     DECMOD_CRCHASHFUNCS     DECMOD_CRCHASHFUNCS
80     void CRCHASHFUNCS_Crc32StateStructClose(struct CRCHASHFUNCS_Crc32StateStruct *arg);     void CRCHASHFUNCS_Crc32StateStructClose(struct CRCHASHFUNCS_Crc32StateStruct *arg);
81    
82     DECMOD_CRCHASHFUNCS const char *CRCHASHFUNCS_cvcinfo(void);     DECMOD_CRCHASHFUNCS const char *CRCHASHFUNCS_cvcinfo(void);
83     DECMOD_CRCHASHFUNCS const char *CRCHASHFUNCS_hvcinfo(void);     DECMOD_CRCHASHFUNCS const char *CRCHASHFUNCS_hvcinfo(void);
84    
85     //Definition of the version of the H file, used for providing version control     //Definition of the version of the H file, used for providing version control
86     //information to external callers.     //information to external callers.
87     #define CRCHASHFUNCS_H_VERSION ("$Header$")     #define CRCHASHFUNCS_H_VERSION ("$Header$")
88  #endif  #endif
89    
90  //End of crchashfuncs.h.  //End of crchashfuncs.h.

Legend:
Removed from v.70  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25