summaryrefslogtreecommitdiff
path: root/plugins/BasicHistory/src/BinaryExport.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-22 19:18:39 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-22 19:18:39 +0000
commit09a1a03baff001ef9aef7310f918e79c8c1f6e97 (patch)
tree5fbb985787f779e692fefb7df3de183bd5207e87 /plugins/BasicHistory/src/BinaryExport.cpp
parent0ce46bb5808b2c825766afa3f39e3c8b42ae871e (diff)
minor code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@6187 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/BasicHistory/src/BinaryExport.cpp')
-rw-r--r--plugins/BasicHistory/src/BinaryExport.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/plugins/BasicHistory/src/BinaryExport.cpp b/plugins/BasicHistory/src/BinaryExport.cpp
index 76239cb098..0e1636af2f 100644
--- a/plugins/BasicHistory/src/BinaryExport.cpp
+++ b/plugins/BasicHistory/src/BinaryExport.cpp
@@ -65,11 +65,9 @@ bool BinaryExport::ReadString(std::wstring &str)
int size = 1024;
int pos = 0;
int totalSize = 0;
- while(1)
- {
+ while(true) {
buf.resize(size);
- if (IMP_FILE.peek() == 0)
- {
+ if (IMP_FILE.peek() == 0) {
IMP_FILE.get();
break;
}
@@ -96,6 +94,7 @@ bool BinaryExport::ReadString(std::wstring &str)
if (totalSize == 0)
return true;
+
int sizeW = MultiByteToWideChar(codepage, 0, (char*)buf.c_str(), totalSize, NULL, 0);
str.resize(sizeW);
MultiByteToWideChar(codepage, 0, (char*)buf.c_str(), totalSize, (wchar_t*)str.c_str(), sizeW);
@@ -133,8 +132,7 @@ void BinaryExport::WriteGroup(bool isMe, const std::wstring &time, const std::ws
void BinaryExport::WriteMessage(bool isMe, const std::wstring &longDate, const std::wstring &shortDate, const std::wstring &user, const std::wstring &message, const DBEVENTINFO& dbei)
{
- if (dbei.timestamp >= lTime)
- {
+ if (dbei.timestamp >= lTime) {
BinaryFileMessageHeader header;
header.eventType = dbei.eventType;
header.flags = dbei.flags & (~(0x800));
@@ -150,8 +148,10 @@ bool ReadHeader(BinaryFileHeader& header, std::istream* stream)
stream->read((char*)&header, sizeof(BinaryFileHeader));
if (!stream->good())
return false;
+
if (memcmp(header.signature, "BHBF", 4) != 0)
return false;
+
if (header.version != 0 || header.codepage == 12000 || header.codepage == 12001)
return false;
@@ -163,6 +163,7 @@ int BinaryExport::IsContactInFile(const std::vector<HANDLE>& contacts)
BinaryFileHeader header;
if (!ReadHeader(header, IImport::stream))
return -2;
+
codepage = header.codepage;
std::wstring filterName;
std::wstring myName;
@@ -188,14 +189,11 @@ int BinaryExport::IsContactInFile(const std::vector<HANDLE>& contacts)
return -2;
IMP_FILE.seekg(0, std::ios_base::beg);
- for(int i = 0; i < (int)contacts.size(); ++i)
- {
+ for (int i = 0; i < (int)contacts.size(); ++i) {
std::wstring pn = GetProtocolName(contacts[i]);
std::wstring id = GetContactId(contacts[i]);
if (pn == proto1 && id == id1)
- {
return i;
- }
}
return -1;
@@ -206,11 +204,11 @@ bool BinaryExport::GetEventList(std::vector<IImport::ExternalMessage>& eventList
BinaryFileHeader header;
if (!ReadHeader(header, IImport::stream))
return false;
+
codepage = header.codepage;
IMP_FILE.seekg(header.dataStart, std::ios_base::beg);
BinaryFileMessageHeader messageHeader;
- while(1)
- {
+ while(true) {
IMP_FILE.read((char*)&messageHeader, sizeof(BinaryFileMessageHeader));
if (IMP_FILE.eof())
break;