aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/3rdparty/lipi-toolkit/src/util/lib/LTKCheckSumGenerate.h
blob: 511bfbaa50ac580eaa50d58291c13223ef1e7727 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*****************************************************************************************
* Copyright (c) 2007 Hewlett-Packard Development Company, L.P.
* Permission is hereby granted, free of charge, to any person obtaining a copy of 
* this software and associated documentation files (the "Software"), to deal in 
* the Software without restriction, including without limitation the rights to use, 
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 
* Software, and to permit persons to whom the Software is furnished to do so, 
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
*****************************************************************************************/
/************************************************************************
 * FILE DESCR: Definitions for the String Splitter Module
 *
 * CONTENTS: 
 *
 * AUTHOR:     Vijayakumara M.
 *
 * DATE:       July 25, 2005
 * CHANGE HISTORY:
 * Author		Date			Description
 ************************************************************************/
/************************************************************************
 * SVN MACROS
 *
 * $LastChangedDate: 2008-11-19 17:57:12 +0530 (Wed, 19 Nov 2008) $
 * $Revision: 704 $
 * $Author: mnab $
 *
 ************************************************************************/
#ifndef __LTKCHECSUMGENERATE_H
#define __LTKCHECSUMGENERATE_H

#include <sstream>

#include "LTKStringUtil.h"

#include "LTKTypes.h"

#include "LTKMacros.h"

#include "LTKErrors.h"

#include "LTKErrorsList.h"

#ifdef _WIN32
#include <windows.h>
const int BUFSIZE = 256;
#else
#include <stdio.h>
#include <sys/utsname.h>
#endif

class LTKOSUtil;

class LTKCheckSumGenerate
{
private:

	unsigned int m_CRC32Table[256]; // Lookup table array.

    LTKOSUtil* m_OSUtilPtr;

public:

	// @{

	/**
	 * Default constractor, calls initCRC32Table function for intialization.
	 */

   	LTKCheckSumGenerate();

    /**
    * Destructor
    */

    ~LTKCheckSumGenerate();

	
	/**
	 * This method generates the checksum.
	 *
	 * @param text, for which the checksum to be calculated.
	 *
	 * @return checksum for the text.
	 */
	int getCRC(string& text);

	/**
	 * This method reads the header information from the model data header information file and
	 * adds it to the data file with additional header information.
	 *
	 * @param strModelDataHeaderInfoFile, Model data header information file name.
	 * @param referenceModelFile, Model data file name.
	 * @param verson information.
	 * @algoName Name of the alogorithm.
	 *
	 * @return SUCCESS on successful addition of the header to the data file. of the respective 
	 *			errorCode on the occurence of any errors.
	 */

	int addHeaderInfo(const string& modelDataHeaderInfoFilePath, 
					       const string& mdtFilePath, 
						const stringStringMap& headerInfo);

	/**
	 * This method reads the header information from the header information file and
	 * adds it to the data file with additional header information.
	 *
	 * @param headerInfo, Model data header information file name.
	 * @param referenceModelFile, Model data file name.
	 *
	 * @return the new stringStringMap after updation
	 */
	stringStringMap updateHeaderWithMandatoryFields(const stringStringMap& headerInfo);


	/**
	 * This method is used to check the file integrity with the checksum.
	 *
	 * @param mdtFilePath, Model data file Name.
	 * @param string - string map variable, which holds the header keys and the values respectively.
	 *
	 * @return SUCCESS, 
	 */

	int readMDTHeader(const string &mdtFilePath,
	                        stringStringMap &headerSequence);	

private:

    /**
	 * This method intializes the crc32_table with 256 values representing ASCII character 
	 * codes.
	 */

   	void initCRC32Table();

    /**
	 * This method is used only by initCRC32Table() function. reflection is a requirement
	 * for the official CRC-32 standard.
	 *
	 * @param ref value.
	 * @param character.
	 *
	 * @return long integer value which will be used by initCRC32Table functon.
	 */

	unsigned int reflect(unsigned int ref, char ch);


	// @}
};

#endif	//__LTKCHECSUMGENERATE_H