Fix typos

This commit is contained in:
binarymaster 2014-12-04 21:22:57 +03:00
parent e2e4a33954
commit 8b85f43605
2 changed files with 27 additions and 27 deletions

View File

@ -88,24 +88,24 @@ bool INI_FILE::CreateStringsMap()
return true; return true;
} }
int INI_FILE::StrTrim(char* Str) int INI_FILE::StrTrim(char* Str)
{ {
int i = 0, j; int i = 0, j;
while((Str[i]==' ')||(Str[i]=='\t')) while((Str[i]==' ')||(Str[i]=='\t'))
{ {
i++; i++;
} }
if(i>0) if(i>0)
{ {
for(j=0; j < strlen(Str); j++) for(j=0; j < strlen(Str); j++)
{ {
Str[j]=Str[j+i]; Str[j]=Str[j+i];
} }
Str[j]='\0'; Str[j]='\0';
} }
i = strlen(Str)-1; i = strlen(Str)-1;
while((Str[i] == ' ')||(Str[i]=='\t')) while((Str[i] == ' ')||(Str[i]=='\t'))
{ {
i--; i--;
} }
@ -161,7 +161,7 @@ bool INI_FILE::FillVariable(INI_SECTION_VARIABLE *Variable, char *Str, DWORD Str
for(DWORD i = 0; i < StrSize; i++) for(DWORD i = 0; i < StrSize; i++)
{ {
if(Str[i] == '"' || Str[i] == '\'') Quotes = !Quotes; if(Str[i] == '"' || Str[i] == '\'') Quotes = !Quotes;
if(Str[i] == '=' && !Quotes) if(Str[i] == '=' && !Quotes)
{ {
memcpy(Variable->VariableName, Str, i); memcpy(Variable->VariableName, Str, i);
memcpy(Variable->VariableValue, &(Str[i+1]), StrSize-(i-1)); memcpy(Variable->VariableValue, &(Str[i+1]), StrSize-(i-1));
@ -190,9 +190,9 @@ bool INI_FILE::Parse()
{ {
CurrentStringSize = GetFileStringFromNum(CurrentStringNum, CurrentString, 512); CurrentStringSize = GetFileStringFromNum(CurrentStringNum, CurrentString, 512);
if(CurrentString[0] == ';') continue; // It's comment if(CurrentString[0] == ';') continue; // It's a comment
if(CurrentString[0] == '[' && CurrentString[CurrentStringSize-1] == ']') // It's section diclarate if(CurrentString[0] == '[' && CurrentString[CurrentStringSize-1] == ']') // It's section declaration
{ {
SectionsCount++; SectionsCount++;
continue; continue;
@ -206,15 +206,15 @@ bool INI_FILE::Parse()
{ {
CurrentStringSize = GetFileStringFromNum(CurrentStringNum, CurrentString, 512); CurrentStringSize = GetFileStringFromNum(CurrentStringNum, CurrentString, 512);
if(CurrentString[0] == ';') continue; // It's comment if(CurrentString[0] == ';') continue; // It's a comment
if(CurrentString[0] == '[' && CurrentString[CurrentStringSize-1] == ']') // It's section diclarate if(CurrentString[0] == '[' && CurrentString[CurrentStringSize-1] == ']') // It's section declaration
{ {
CurrentSectionNum++; CurrentSectionNum++;
continue; continue;
} }
if(IsVariable(CurrentString, CurrentStringSize)) if(IsVariable(CurrentString, CurrentStringSize))
{ {
VariablesCount++; VariablesCount++;
SectionVariableCount[CurrentSectionNum]++; SectionVariableCount[CurrentSectionNum]++;
@ -242,9 +242,9 @@ bool INI_FILE::Parse()
{ {
CurrentStringSize = GetFileStringFromNum(CurrentStringNum, CurrentString, 512); CurrentStringSize = GetFileStringFromNum(CurrentStringNum, CurrentString, 512);
if(CurrentString[0] == ';') // It's comment if(CurrentString[0] == ';') // It's a comment
{ {
continue; continue;
} }
if(CurrentString[0] == '[' && CurrentString[CurrentStringSize-1] == ']') if(CurrentString[0] == '[' && CurrentString[CurrentStringSize-1] == ']')
@ -255,7 +255,7 @@ bool INI_FILE::Parse()
continue; continue;
} }
if(IsVariable(CurrentString, CurrentStringSize)) if(IsVariable(CurrentString, CurrentStringSize))
{ {
FillVariable(&(IniData.Section[CurrentSectionNum].Variables[CurrentVariableNum]), CurrentString, CurrentStringSize); FillVariable(&(IniData.Section[CurrentSectionNum].Variables[CurrentVariableNum]), CurrentString, CurrentStringSize);
CurrentVariableNum++; CurrentVariableNum++;
@ -292,7 +292,7 @@ bool INI_FILE::GetVariableInSectionPrivate(char *SectionName, char *VariableName
break; break;
} }
} }
if(Section == NULL) if(Section == NULL)
{ {
SetLastError(318); // This region is not found SetLastError(318); // This region is not found
return false; return false;
@ -330,7 +330,7 @@ bool INI_FILE::GetVariableInSection(char *SectionName, char *VariableName, INI_V
memset(RetVariable, 0x00, sizeof(*RetVariable)); memset(RetVariable, 0x00, sizeof(*RetVariable));
memcpy(RetVariable->Name, Variable.VariableName, strlen(Variable.VariableName)); memcpy(RetVariable->Name, Variable.VariableName, strlen(Variable.VariableName));
memcpy(RetVariable->Value, Variable.VariableValue, strlen(Variable.VariableValue)); memcpy(RetVariable->Value, Variable.VariableValue, strlen(Variable.VariableValue));
return true; return true;
} }
@ -341,7 +341,7 @@ bool INI_FILE::GetVariableInSection(char *SectionName, char *VariableName, INI_V
Status = GetVariableInSectionPrivate(SectionName, VariableName, &Variable); Status = GetVariableInSectionPrivate(SectionName, VariableName, &Variable);
if(!Status) return Status; if(!Status) return Status;
memset(RetVariable, 0x00, sizeof(*RetVariable)); memset(RetVariable, 0x00, sizeof(*RetVariable));
memcpy(RetVariable->Name, Variable.VariableName, strlen(Variable.VariableName)); memcpy(RetVariable->Name, Variable.VariableName, strlen(Variable.VariableName));
@ -362,7 +362,7 @@ bool INI_FILE::GetVariableInSection(char *SectionName, char *VariableName, INI_V
Status = GetVariableInSectionPrivate(SectionName, VariableName, &Variable); Status = GetVariableInSectionPrivate(SectionName, VariableName, &Variable);
if(!Status) return Status; if(!Status) return Status;
DWORD ValueLen = strlen(Variable.VariableValue); DWORD ValueLen = strlen(Variable.VariableValue);
if((ValueLen % 2) != 0) return false; if((ValueLen % 2) != 0) return false;
@ -372,7 +372,7 @@ bool INI_FILE::GetVariableInSection(char *SectionName, char *VariableName, INI_V
for(DWORD i = 0; i <= ValueLen; i++) for(DWORD i = 0; i <= ValueLen; i++)
{ {
if((i % 2) != 0) continue; if((i % 2) != 0) continue;
switch(Variable.VariableValue[i]) switch(Variable.VariableValue[i])
{ {
case '0': break; case '0': break;
@ -391,7 +391,7 @@ bool INI_FILE::GetVariableInSection(char *SectionName, char *VariableName, INI_V
case 'D': RetVariable->Value[(i/2)] += (13 << 4); break; case 'D': RetVariable->Value[(i/2)] += (13 << 4); break;
case 'E': RetVariable->Value[(i/2)] += (14 << 4); break; case 'E': RetVariable->Value[(i/2)] += (14 << 4); break;
case 'F': RetVariable->Value[(i/2)] += (15 << 4); break; case 'F': RetVariable->Value[(i/2)] += (15 << 4); break;
} }
switch(Variable.VariableValue[i+1]) switch(Variable.VariableValue[i+1])
{ {

View File

@ -28,10 +28,10 @@ typedef struct _INI_VAR_DWORD
{ {
char Name[128]; char Name[128];
#ifndef _WIN64 #ifndef _WIN64
DWORD ValueDec; DWORD ValueDec;
DWORD ValueHex; DWORD ValueHex;
#else #else
DWORD64 ValueDec; DWORD64 ValueDec;
DWORD64 ValueHex; DWORD64 ValueHex;
#endif #endif
@ -88,7 +88,7 @@ public:
private: private:
DWORD FileSize; // Ini file size DWORD FileSize; // Ini file size
char *FileRaw; // Ini file raw dump char *FileRaw; // Ini file raw dump
DWORD FileStringsCount; // String-map lenght DWORD FileStringsCount; // String-map length
DWORD *FileStringsMap; // String-map DWORD *FileStringsMap; // String-map
INI_DATA IniData; // Parsed data INI_DATA IniData; // Parsed data
@ -98,7 +98,7 @@ private:
// Class service functions // Class service functions
bool CreateStringsMap(); // Create file string-map bool CreateStringsMap(); // Create file string-map
bool Parse(); // Parse file to class structures bool Parse(); // Parse file to class structures
DWORD GetFileStringFromNum(DWORD StringNumber, char *RetString, DWORD Size); // Get stroing from string-map DWORD GetFileStringFromNum(DWORD StringNumber, char *RetString, DWORD Size); // Get string from string-map
bool IsVariable(char *Str, DWORD StrSize); bool IsVariable(char *Str, DWORD StrSize);
bool FillVariable(INI_SECTION_VARIABLE *Variable, char *Str, DWORD StrSize); // Fill INI_SECTION_VARIABLE struct (for Parse) bool FillVariable(INI_SECTION_VARIABLE *Variable, char *Str, DWORD StrSize); // Fill INI_SECTION_VARIABLE struct (for Parse)
bool GetVariableInSectionPrivate(char *SectionName, char *VariableName, INI_SECTION_VARIABLE *RetVariable); bool GetVariableInSectionPrivate(char *SectionName, char *VariableName, INI_SECTION_VARIABLE *RetVariable);