diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-25 21:39:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-25 21:39:35 +0300 |
commit | 01e48461e3ddf45c2e9065276ff4b4c5f59ae77b (patch) | |
tree | eaa56c5a9dd4441a9de77eec52a3a81c411c14c5 | |
parent | 18ea49746ac254f97f3265131640b605e41b2fd9 (diff) |
MIDatabaseChecker interface removed
-rw-r--r-- | include/m_db_int.h | 26 | ||||
-rw-r--r-- | plugins/Db3x_mmap/db3x_mmap.vcxproj | 29 | ||||
-rw-r--r-- | plugins/Db3x_mmap/db3x_mmap.vcxproj.filters | 5 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcache.cpp | 4 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.cpp | 40 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 16 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/aggressive.cpp | 55 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/contactchain.cpp | 109 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/disk.cpp | 103 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/eventchain.cpp | 392 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/finaltasks.cpp | 37 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/initialchecks.cpp | 74 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/modulechain.cpp | 140 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/settingschain.cpp | 78 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/user.cpp | 76 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/version.h | 2 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.cpp | 30 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.h | 9 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/version.h | 2 |
19 files changed, 8 insertions, 1219 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h index 6bfde8063e..4178434dc0 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -166,32 +166,6 @@ public: };
///////////////////////////////////////////////////////////////////////////////
-// basic database checker interface
-
-#define STATUS_MESSAGE 0
-#define STATUS_WARNING 1
-#define STATUS_ERROR 2
-#define STATUS_FATAL 3
-#define STATUS_SUCCESS 4
-
-struct DBCHeckCallback
-{
- int cbSize;
- DWORD spaceProcessed, spaceUsed;
- HANDLE hOutFile;
- int bCheckOnly, bBackup, bAggressive, bEraseHistory, bMarkRead, bConvertUtf;
-
- void (*pfnAddLogMessage)(int type, const wchar_t* ptszFormat, ...);
-};
-
-interface MIDatabaseChecker
-{
- STDMETHOD_(BOOL,Start)(DBCHeckCallback *callback) PURE;
- STDMETHOD_(BOOL,CheckDb)(int phase, int firstTime) PURE;
- STDMETHOD_(VOID,Destroy)() PURE;
-};
-
-///////////////////////////////////////////////////////////////////////////////
// Each database plugin should register itself using this structure
/*
diff --git a/plugins/Db3x_mmap/db3x_mmap.vcxproj b/plugins/Db3x_mmap/db3x_mmap.vcxproj index ec4c21494b..385b00ca8e 100644 --- a/plugins/Db3x_mmap/db3x_mmap.vcxproj +++ b/plugins/Db3x_mmap/db3x_mmap.vcxproj @@ -25,33 +25,4 @@ <ImportGroup Label="PropertySheets">
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
- <ItemGroup>
- <ClCompile Include="src\dbtool\aggressive.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- <ClCompile Include="src\dbtool\contactchain.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- <ClCompile Include="src\dbtool\disk.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- <ClCompile Include="src\dbtool\eventchain.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- <ClCompile Include="src\dbtool\finaltasks.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- <ClCompile Include="src\dbtool\initialchecks.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- <ClCompile Include="src\dbtool\modulechain.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- <ClCompile Include="src\dbtool\settingschain.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- <ClCompile Include="src\dbtool\user.cpp">
- <PrecompiledHeaderFile>..\stdafx.h</PrecompiledHeaderFile>
- </ClCompile>
- </ItemGroup>
</Project>
\ No newline at end of file diff --git a/plugins/Db3x_mmap/db3x_mmap.vcxproj.filters b/plugins/Db3x_mmap/db3x_mmap.vcxproj.filters index e8bedc67db..869b679cc3 100644 --- a/plugins/Db3x_mmap/db3x_mmap.vcxproj.filters +++ b/plugins/Db3x_mmap/db3x_mmap.vcxproj.filters @@ -5,10 +5,5 @@ <UniqueIdentifier>{18e1a858-92e5-48e6-98f1-e08f4b562ea8}</UniqueIdentifier>
</Filter>
</ItemGroup>
- <ItemGroup>
- <ClCompile Include="src\dbtool\*.cpp">
- <Filter>Source Files\Checker</Filter>
- </ClCompile>
- </ItemGroup>
<Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" />
</Project>
\ No newline at end of file diff --git a/plugins/Db3x_mmap/src/dbcache.cpp b/plugins/Db3x_mmap/src/dbcache.cpp index 1196d4bceb..8d03a2945b 100644 --- a/plugins/Db3x_mmap/src/dbcache.cpp +++ b/plugins/Db3x_mmap/src/dbcache.cpp @@ -26,9 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CDb3Mmap::Map()
{
DWORD dwProtectMode, dwAccess;
- if (cb && cb->bAggressive)
- dwProtectMode = PAGE_WRITECOPY, dwAccess = FILE_MAP_COPY;
- else if (m_bReadOnly)
+ if (m_bReadOnly)
dwProtectMode = PAGE_READONLY, dwAccess = FILE_MAP_READ;
else
dwProtectMode = PAGE_READWRITE, dwAccess = FILE_MAP_ALL_ACCESS;
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp index faf15ebd62..7cb981591f 100644 --- a/plugins/Db3x_mmap/src/dbintf.cpp +++ b/plugins/Db3x_mmap/src/dbintf.cpp @@ -159,43 +159,9 @@ int CDb3Mmap::Create() STDMETHODIMP_(void) CDb3Mmap::SetCacheSafetyMode(BOOL bIsSet)
{
- { mir_cslock lck(m_csDbAccess);
- m_safetyMode = bIsSet != 0;
+ {
+ mir_cslock lck(m_csDbAccess);
+ m_safetyMode = bIsSet != 0;
}
DBFlush(1);
}
-
-///////////////////////////////////////////////////////////////////////////////
-// MIDatabaseChecker
-
-typedef int (CDb3Mmap::*CheckWorker)(int);
-
-static CheckWorker Workers[6] =
-{
- &CDb3Mmap::WorkInitialChecks,
- &CDb3Mmap::WorkModuleChain,
- &CDb3Mmap::WorkUser,
- &CDb3Mmap::WorkContactChain,
- &CDb3Mmap::WorkAggressive,
- &CDb3Mmap::WorkFinalTasks
-};
-
-int CDb3Mmap::Start(DBCHeckCallback *callback)
-{
- cb = callback;
- ReMap(0);
- return ERROR_SUCCESS;
-}
-
-int CDb3Mmap::CheckDb(int phase, int firstTime)
-{
- if (phase >= _countof(Workers))
- return ERROR_OUT_OF_PAPER;
-
- return (this->*Workers[phase])(firstTime);
-}
-
-void CDb3Mmap::Destroy()
-{
- delete this;
-}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index d17c7b2fb0..a882666539 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -183,7 +183,7 @@ struct DBCachedContact : public DBCachedContactBase DWORD dwOfsContact;
};
-struct CDb3Mmap : public MDatabaseCommon, public MIDatabaseChecker, public MZeroedObject
+struct CDb3Mmap : public MDatabaseCommon, public MZeroedObject
{
CDb3Mmap(const wchar_t *tszFileName, int mode);
~CDb3Mmap();
@@ -241,11 +241,6 @@ public: STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub);
protected:
- STDMETHODIMP_(BOOL) Start(DBCHeckCallback *callback);
- STDMETHODIMP_(BOOL) CheckDb(int phase, int firstTime);
- STDMETHODIMP_(VOID) Destroy();
-
-protected:
DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsModuleName);
void InvalidateSettingsGroupOfsCacheEntry(DWORD) {}
int WorkInitialCheckHeaders(void);
@@ -263,14 +258,6 @@ protected: void Map();
void ReMap(DWORD needed);
-public: // Check functions
- int WorkInitialChecks(int);
- int WorkModuleChain(int);
- int WorkUser(int);
- int WorkContactChain(int);
- int WorkAggressive(int);
- int WorkFinalTasks(int);
-
protected:
wchar_t* m_tszProfileName;
HANDLE m_hDbFile;
@@ -350,7 +337,6 @@ protected: void WriteOfsNextToPrevious(DWORD ofsPrev, DBContact *dbc, DWORD ofsNext);
void FinishUp(DWORD ofsLast, DBContact *dbc);
- DBCHeckCallback *cb;
DWORD sourceFileSize, ofsAggrCur;
////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Db3x_mmap/src/dbtool/aggressive.cpp b/plugins/Db3x_mmap/src/dbtool/aggressive.cpp deleted file mode 100644 index b0db2001fd..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/aggressive.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/*
-Miranda Database Tool
-Copyright (C) 2001-2005 Richard Hughes
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "../stdafx.h"
-
-#define BLOCKSIZE 65536
-
-int CDb3Mmap::WorkAggressive(int firstTime)
-{
- if (firstTime) {
- if (!cb->bAggressive)
- return ERROR_NO_MORE_ITEMS;
-
- cb->pfnAddLogMessage(STATUS_MESSAGE, TranslateT("Performing aggressive pass"));
- ofsAggrCur = 0;
- cb->spaceProcessed = 0;
- }
-
- int blockBytes = min(BLOCKSIZE + 3, (int)(sourceFileSize - ofsAggrCur));
- if (blockBytes <= 0)
- return ERROR_NO_MORE_ITEMS;
-
- BYTE *buf = m_pDbCache + ofsAggrCur;
- blockBytes -= 3;
- for (int i = 0; i < blockBytes; i++) {
- if (buf[i]) {
- if ((*(PDWORD)&buf[i] & 0x00FFFFFF) != 0xDECADE)
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Aggressive: random junk at %08X: skipping"), ofsAggrCur + i);
- else
- //TODO: give user the option of placing manually
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Aggressive: unlinked data at %08X: can't automatically place"), ofsAggrCur + i);
-
- for (; i < blockBytes; i++)
- if (buf[i] == 0) { i--; break; }
- }
- }
- ofsAggrCur += BLOCKSIZE;
- cb->spaceProcessed = ofsAggrCur;
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp deleted file mode 100644 index fdc0922aba..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/*
-Miranda Database Tool
-Copyright (C) 2001-2005 Richard Hughes
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../stdafx.h"
-
-static DWORD ofsThisContact, ofsDestPrevContact;
-static DWORD contactCount;
-static DWORD ofsDestThis, ofsNextContact;
-static int phase;
-static DBContact dbc;
-
-int CDb3Mmap::WorkContactChain(int firstTime)
-{
- int first = 0;
- int ret;
-
- if (firstTime) {
- cb->pfnAddLogMessage(STATUS_MESSAGE, TranslateT("Processing contact chain"));
- ofsDestPrevContact = 0;
- ofsThisContact = m_dbHeader.ofsFirstContact;
- contactCount = 0;
- m_dbHeader.ofsFirstContact = 0;
- phase = 0;
- }
-
- switch (phase) {
- case 0:
- if (ofsThisContact == 0) {
- LBL_FinishUp:
- if (contactCount != m_dbHeader.contactCount)
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Contact count marked wrongly: correcting"));
- m_dbHeader.contactCount = contactCount;
- return ERROR_NO_MORE_ITEMS;
- }
- if (!SignatureValid(ofsThisContact, DBCONTACT_SIGNATURE)) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Contact chain corrupted, further entries ignored"));
- goto LBL_FinishUp;
- }
-
- if (m_dbHeader.version < DB_095_VERSION) {
- if (ReadSegment(ofsThisContact, &dbc, offsetof(DBContact, dwContactID)) != ERROR_SUCCESS)
- goto LBL_FinishUp;
- dbc.dwContactID = m_dwMaxContactId++;
- }
- else {
- if (ReadSegment(ofsThisContact, &dbc, sizeof(dbc)) != ERROR_SUCCESS)
- goto LBL_FinishUp;
- }
-
- ofsNextContact = dbc.ofsNext;
- dbc.ofsNext = 0;
- if (!cb->bCheckOnly) {
- if ((ofsDestThis = WriteSegment(WSOFS_END, &dbc, sizeof(dbc))) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- if (ofsDestPrevContact)
- WriteSegment(ofsDestPrevContact + offsetof(DBContact, ofsNext), &ofsDestThis, sizeof(DWORD));
- else
- m_dbHeader.ofsFirstContact = ofsDestThis;
- }
- else ofsDestThis = ofsThisContact; // needed in event chain worker
-
- contactCount++;
- phase++; first = 1;
-
- // fall thru
- case 1:
- ret = WorkSettingsChain(&dbc, first);
- if (ret == ERROR_NO_MORE_ITEMS) {
- phase++; first = 1;
- }
- else if (ret) return ret;
- else break;
-
- // fall thru
- case 2:
- ret = WorkEventChain(ofsDestThis, &dbc, first);
- if (ret == ERROR_NO_MORE_ITEMS) {
- phase++; first = 1;
- }
- else if (ret) return ret;
- else break;
-
- // fall thru
- case 3:
- if (WriteSegment(ofsDestThis, &dbc, sizeof(DBContact)) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- ofsDestPrevContact = ofsDestThis;
- ofsThisContact = ofsNextContact;
- phase = 0;
- break;
- }
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Db3x_mmap/src/dbtool/disk.cpp b/plugins/Db3x_mmap/src/dbtool/disk.cpp deleted file mode 100644 index 3310c7dd67..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/disk.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/*
-Miranda Database Tool
-Copyright (C) 2001-2005 Richard Hughes
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../stdafx.h"
-
-int CDb3Mmap::SignatureValid(DWORD ofs, DWORD signature)
-{
- if (ofs + sizeof(DWORD) >= sourceFileSize) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Invalid offset found (database truncated?)"));
- return 0;
- }
-
- DWORD *sig = (DWORD*)(m_pDbCache + ofs);
- return *sig == signature;
-}
-
-int CDb3Mmap::PeekSegment(DWORD ofs, PVOID buf, int cbBytes)
-{
- if (ofs >= sourceFileSize) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Invalid offset found"));
- return ERROR_SEEK;
- }
-
- DWORD bytesRead;
- if (ofs + cbBytes > sourceFileSize)
- bytesRead = sourceFileSize - ofs;
- else
- bytesRead = cbBytes;
-
- if (bytesRead == 0) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Error reading, database truncated? (%u)"), GetLastError());
- return ERROR_READ_FAULT;
- }
-
- memcpy(buf, m_pDbCache + ofs, bytesRead);
-
- if ((int)bytesRead<cbBytes) return ERROR_HANDLE_EOF;
- return ERROR_SUCCESS;
-}
-
-int CDb3Mmap::ReadSegment(DWORD ofs, PVOID buf, int cbBytes)
-{
- int ret = PeekSegment(ofs, buf, cbBytes);
- if (ret != ERROR_SUCCESS && ret != ERROR_HANDLE_EOF) return ret;
-
- if (cb->bAggressive) {
- if (ofs + cbBytes > sourceFileSize) {
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Can't write to working file, aggressive mode may be too aggressive now"));
- memset((m_pDbCache + ofs), 0, (sourceFileSize - ofs));
- }
- else memset((m_pDbCache + ofs), 0, cbBytes);
- }
- cb->spaceProcessed += cbBytes;
- return ERROR_SUCCESS;
-}
-
-DWORD CDb3Mmap::WriteSegment(DWORD ofs, PVOID buf, int cbBytes)
-{
- DWORD bytesWritten;
- if (cb->bCheckOnly) return 0xbfbfbfbf;
- if (ofs == WSOFS_END) {
- ofs = m_dbHeader.ofsFileEnd;
- m_dbHeader.ofsFileEnd += cbBytes;
- }
- SetFilePointer(cb->hOutFile, ofs, nullptr, FILE_BEGIN);
- WriteFile(cb->hOutFile, buf, cbBytes, &bytesWritten, nullptr);
- if ((int)bytesWritten < cbBytes) {
- cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Can't write to output file - disk full? (%u)"), GetLastError());
- return WS_ERROR;
- }
- return ofs;
-}
-
-int CDb3Mmap::ReadWrittenSegment(DWORD ofs, PVOID buf, int cbBytes)
-{
- DWORD bytesRead;
- if (cb->bCheckOnly) return 0xbfbfbfbf;
- if (ofs + cbBytes > m_dbHeader.ofsFileEnd)
- return ERROR_SEEK;
-
- SetFilePointer(cb->hOutFile, ofs, nullptr, FILE_BEGIN);
- ReadFile(cb->hOutFile, buf, cbBytes, &bytesRead, nullptr);
- if ((int)bytesRead < cbBytes)
- return ERROR_READ_FAULT;
-
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp deleted file mode 100644 index 1546df418d..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/*
-
-Miranda Database Tool
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org),
-Copyright 2000-2011 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-#include "../stdafx.h"
-
-#define DBEF_ALL (DBEF_READ | DBEF_SENT | DBEF_RTL | DBEF_UTF | DBEF_ENCRYPTED)
-
-static BOOL backLookup;
-static DWORD ofsThisEvent, ofsPrevEvent;
-static DWORD ofsDestPrevEvent;
-static DWORD eventCount;
-static DWORD lastTimestamp;
-static DWORD ofsFirstUnread, tsFirstUnread;
-static DWORD memsize = 0;
-static DBEvent* memblock = nullptr;
-static DBEvent* dbePrevEvent = nullptr;
-
-void CDb3Mmap::ConvertOldEvent(DBEvent*& dbei)
-{
- int msglen = (int)mir_strlen((char*)dbei->blob) + 1, msglenW = 0;
- if (msglen != (int)dbei->cbBlob) {
- int count = ((dbei->cbBlob - msglen) / sizeof(WCHAR));
- WCHAR* p = (WCHAR*)&dbei->blob[msglen];
- for (int i = 0; i < count; i++) {
- if (p[i] == 0) {
- msglenW = i;
- break;
- }
- }
- }
- else {
- if (!Utf8CheckString((char*)dbei->blob))
- dbei->flags &= ~DBEF_UTF;
- }
-
- if (msglenW > 0 && msglenW <= msglen) {
- char* utf8str = Utf8EncodeW((WCHAR*)&dbei->blob[msglen]);
- if (utf8str == nullptr)
- return;
-
- dbei->cbBlob = (DWORD)mir_strlen(utf8str) + 1;
- dbei->flags |= DBEF_UTF;
- if (offsetof(DBEvent, blob) + dbei->cbBlob > memsize) {
- memsize = offsetof(DBEvent, blob) + dbei->cbBlob;
- memblock = (DBEvent*)realloc(memblock, memsize);
- dbei = memblock;
- }
- memcpy(&dbei->blob, utf8str, dbei->cbBlob);
- mir_free(utf8str);
- }
-}
-
-void CDb3Mmap::WriteOfsNextToPrevious(DWORD ofsPrev, DBContact *dbc, DWORD ofsNext)
-{
- if (ofsPrev)
- WriteSegment(ofsPrev + offsetof(DBEvent, ofsNext), &ofsNext, sizeof(DWORD));
- else
- dbc->ofsFirstEvent = ofsNext;
-}
-
-void CDb3Mmap::FinishUp(DWORD ofsLast, DBContact *dbc)
-{
- WriteOfsNextToPrevious(ofsLast, dbc, 0);
- if (eventCount != dbc->eventCount && !(dbc->ofsFirstEvent == 0 && dbc->ofsLastEvent == 0 && dbc->ofsFirstUnread == 0)) {
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Event count marked wrongly: correcting"));
- dbc->eventCount = eventCount;
- }
- dbc->ofsLastEvent = ofsLast;
- if (cb->bMarkRead) {
- dbc->ofsFirstUnread = 0;
- dbc->tsFirstUnread = 0;
- }
- else {
- dbc->ofsFirstUnread = ofsFirstUnread;
- dbc->tsFirstUnread = tsFirstUnread;
- }
- if (memsize && memblock) {
- free(memblock);
- memsize = 0;
- memblock = nullptr;
- }
-}
-
-DWORD CDb3Mmap::PeekEvent(DWORD ofs, DWORD dwContactID, DBEvent &dbe)
-{
- if (m_dbHeader.version >= DB_095_1_VERSION)
- return PeekSegment(ofs, &dbe, sizeof(DBEvent));
-
- DBEvent_094 oldEvent;
- DWORD ret = PeekSegment(ofs, &oldEvent, sizeof(oldEvent));
- if (ret != ERROR_SUCCESS)
- return ret;
-
- dbe.signature = oldEvent.signature;
- dbe.contactID = dwContactID;
- memcpy(&dbe.ofsPrev, &oldEvent.ofsPrev, sizeof(oldEvent) - sizeof(DWORD));
- return ERROR_SUCCESS;
-}
-
-DWORD CDb3Mmap::WriteEvent(DBEvent *dbe)
-{
- DWORD ofs = WriteSegment(WSOFS_END, dbe, offsetof(DBEvent, blob) + dbe->cbBlob);
- if (ofs == WS_ERROR) {
- free(memblock);
- memblock = nullptr;
- memsize = 0;
- return 0;
- }
- return ofs;
-}
-
-int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime)
-{
- int isUnread = 0;
-
- if (firstTime) {
- dbePrevEvent = nullptr;
- ofsPrevEvent = 0;
- ofsDestPrevEvent = 0;
- ofsThisEvent = dbc->ofsFirstEvent;
- eventCount = 0;
- backLookup = 0;
- lastTimestamp = 0;
- ofsFirstUnread = tsFirstUnread = 0;
- if (cb->bEraseHistory) {
- dbc->eventCount = 0;
- dbc->ofsFirstEvent = 0;
- dbc->ofsLastEvent = 0;
- dbc->ofsFirstUnread = 0;
- dbc->tsFirstUnread = 0;
- return ERROR_NO_MORE_ITEMS;
- }
- }
-
- if (ofsThisEvent == 0) {
- FinishUp(ofsDestPrevEvent, dbc);
- return ERROR_NO_MORE_ITEMS;
- }
-
- DBEvent dbeOld;
- if (!SignatureValid(ofsThisEvent, DBEVENT_SIGNATURE)) {
- DWORD ofsNew = 0;
- DWORD ofsTmp = dbc->ofsLastEvent;
-
- if (!backLookup && ofsTmp) {
- backLookup = 1;
- while (SignatureValid(ofsTmp, DBEVENT_SIGNATURE)) {
- if (PeekEvent(ofsTmp, dbc->dwContactID, dbeOld) != ERROR_SUCCESS)
- break;
- ofsNew = ofsTmp;
- ofsTmp = dbeOld.ofsPrev;
- }
- }
- if (ofsNew) {
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Event chain corrupted, trying to recover..."));
- ofsThisEvent = ofsNew;
- }
- else {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Event chain corrupted, further entries ignored"));
- FinishUp(ofsDestPrevEvent, dbc);
- return ERROR_NO_MORE_ITEMS;
- }
- }
-
- if (PeekEvent(ofsThisEvent, dbc->dwContactID, dbeOld) != ERROR_SUCCESS) {
- FinishUp(ofsDestPrevEvent, dbc);
- return ERROR_NO_MORE_ITEMS;
- }
-
- if (firstTime) {
- if (dbeOld.ofsPrev != 0)
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("First event not marked as such: correcting"));
-
- dbeOld.ofsPrev = 0;
- lastTimestamp = dbeOld.timestamp;
- }
-
- if (dbeOld.flags & 1)
- dbeOld.flags &= ~1;
-
- if (dbeOld.flags & ~DBEF_ALL) {
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Extra flags found in event: removing"));
- dbeOld.flags &= DBEF_ALL;
- }
-
- if (!(dbeOld.flags & (DBEF_READ | DBEF_SENT))) {
- if (cb->bMarkRead) dbeOld.flags |= DBEF_READ;
- else if (ofsFirstUnread == 0) {
- if (dbc->ofsFirstUnread != ofsThisEvent || dbc->tsFirstUnread != dbeOld.timestamp)
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("First unread event marked wrong: fixing"));
- isUnread = 1;
- }
- }
-
- if (dbeOld.cbBlob > 1024 * 1024 || dbeOld.cbBlob == 0) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Infeasibly large event blob: skipping"));
- ofsThisEvent = dbeOld.ofsNext;
- return ERROR_SUCCESS;
- }
-
- DBEvent *dbePrev = nullptr;
- if (dbePrevEvent && dbeOld.timestamp == lastTimestamp) {
- int len = offsetof(DBEvent, blob) + dbePrevEvent->cbBlob;
- dbePrev = (DBEvent*)malloc(len);
- memcpy(dbePrev, dbePrevEvent, len);
- }
-
- if (offsetof(DBEvent, blob) + dbeOld.cbBlob > memsize) {
- memsize = offsetof(DBEvent, blob) + dbeOld.cbBlob;
- memblock = (DBEvent*)realloc(memblock, memsize);
- }
- DBEvent *dbeNew = memblock;
-
- DWORD ret;
- if (m_dbHeader.version < DB_095_1_VERSION) {
- DBEvent_094 oldEvent;
- ret = ReadSegment(ofsThisEvent, &oldEvent, offsetof(DBEvent_094, blob));
- if (ret == ERROR_SUCCESS) {
- dbeNew->signature = oldEvent.signature;
- dbeNew->contactID = dbc->dwContactID;
- memcpy(&dbeNew->ofsPrev, &oldEvent.ofsPrev, offsetof(DBEvent_094, blob) - sizeof(DWORD));
- ret = ReadSegment(ofsThisEvent + offsetof(DBEvent_094, blob), &dbeNew->blob, dbeOld.cbBlob);
- }
- }
- else ret = ReadSegment(ofsThisEvent, dbeNew, offsetof(DBEvent, blob) + dbeOld.cbBlob);
-
- if (ret != ERROR_SUCCESS) {
- FinishUp(ofsDestPrevEvent, dbc);
- return ERROR_NO_MORE_ITEMS;
- }
-
- if ((dbeNew->ofsModuleName = ConvertModuleNameOfs(dbeOld.ofsModuleName)) == 0) {
- ofsThisEvent = dbeOld.ofsNext;
- return ERROR_SUCCESS;
- }
-
- if (!firstTime && dbeOld.ofsPrev != ofsPrevEvent)
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Event not backlinked correctly: fixing"));
-
- dbeNew->flags = dbeOld.flags;
- dbeNew->ofsPrev = ofsDestPrevEvent;
- dbeNew->ofsNext = 0;
- if (dbeNew->contactID == 0)
- dbeNew->contactID = dbc->dwContactID;
-
- if (dbeOld.wEventType == EVENTTYPE_MESSAGE && cb->bConvertUtf && !(dbeOld.flags & DBEF_ENCRYPTED))
- ConvertOldEvent(dbeNew);
-
- if (dbePrev) {
- if (dbePrev->cbBlob == dbeNew->cbBlob &&
- dbePrev->ofsModuleName == dbeNew->ofsModuleName &&
- dbePrev->wEventType == dbeNew->wEventType &&
- (dbePrev->flags & DBEF_SENT) == (dbeNew->flags & DBEF_SENT) && !memcmp(dbePrev->blob, dbeNew->blob, dbeNew->cbBlob))
- {
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Duplicate event was found: skipping"));
- if (dbc->eventCount)
- dbc->eventCount--;
- free(dbePrev);
- // ofsDestPrevEvent is still the same!
- ofsPrevEvent = ofsThisEvent;
- ofsThisEvent = dbeOld.ofsNext;
- return ERROR_SUCCESS;
- }
- free(dbePrev);
- }
- else if (!firstTime && dbeNew->timestamp < lastTimestamp) {
- DWORD found = 0;
- DBEvent dbeTmp = { 0 };
- DWORD ofsTmp = 0;
-
- if (cb->bCheckOnly) {
- if (!cb->bAggressive) {
- ofsTmp = dbeOld.ofsPrev;
- while (PeekEvent(ofsTmp, dbc->dwContactID, dbeTmp) == ERROR_SUCCESS) {
- if (dbeTmp.ofsPrev == ofsContact) {
- found = 1;
- break;
- }
- if (dbeTmp.timestamp < dbeNew->timestamp) {
- found = 2;
- break;
- }
- ofsTmp = dbeTmp.ofsPrev;
- }
- }
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Event position in chain is not correct"));
- }
- else {
- ofsTmp = ofsDestPrevEvent;
- while (ReadWrittenSegment(ofsTmp, &dbeTmp, sizeof(dbeTmp)) == ERROR_SUCCESS) {
- if (dbeTmp.ofsPrev == ofsContact) {
- found = 1;
- break;
- }
- if (dbeTmp.timestamp < dbeNew->timestamp) {
- found = 2;
- break;
- }
- ofsTmp = dbeTmp.ofsPrev;
- }
- if (found)
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Event position in chain is not correct: fixing"));
- else
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Event position in chain is not correct: unable to fix"));
- }
-
- // insert before FIRST
- if (found == 1 && !cb->bCheckOnly) {
- dbeNew->ofsPrev = 0;
- dbeNew->ofsNext = dbc->ofsFirstEvent;
-
- DWORD ofsDestThis = WriteEvent(dbeNew);
- if (!ofsDestThis)
- return ERROR_HANDLE_DISK_FULL;
-
- if (isUnread && tsFirstUnread >= dbeNew->timestamp) {
- ofsFirstUnread = ofsDestThis;
- tsFirstUnread = dbeNew->timestamp;
- }
- // fix first event
- WriteOfsNextToPrevious(0, dbc, ofsDestThis);
- // fix next event
- WriteSegment(dbeNew->ofsNext + offsetof(DBEvent, ofsPrev), &ofsDestThis, sizeof(DWORD));
- }
- else if (found == 2 && !cb->bCheckOnly) {
- dbeNew->ofsPrev = ofsTmp;
- dbeNew->ofsNext = dbeTmp.ofsNext;
-
- DWORD ofsDestThis = WriteEvent(dbeNew);
- if (!ofsDestThis)
- return ERROR_HANDLE_DISK_FULL;
-
- if (isUnread && tsFirstUnread >= dbeNew->timestamp) {
- ofsFirstUnread = ofsDestThis;
- tsFirstUnread = dbeNew->timestamp;
- }
- // fix previous event
- WriteOfsNextToPrevious(dbeNew->ofsPrev, dbc, ofsDestThis);
- // fix next event
- WriteSegment(dbeNew->ofsNext + offsetof(DBEvent, ofsPrev), &ofsDestThis, sizeof(DWORD));
- }
-
- if (found) {
- eventCount++;
- // ofsDestPrevEvent is still the same!
- ofsPrevEvent = ofsThisEvent;
- ofsThisEvent = dbeOld.ofsNext;
- return ERROR_SUCCESS;
- }
- }
-
- lastTimestamp = dbeNew->timestamp;
- dbePrevEvent = dbeNew;
-
- DWORD ofsDestThis = WriteEvent(dbeNew);
- if (!ofsDestThis)
- return ERROR_HANDLE_DISK_FULL;
-
- if (isUnread) {
- ofsFirstUnread = ofsDestThis;
- tsFirstUnread = dbeOld.timestamp;
- }
-
- eventCount++;
- WriteOfsNextToPrevious(ofsDestPrevEvent, dbc, ofsDestThis);
-
- ofsDestPrevEvent = ofsDestThis;
- ofsPrevEvent = ofsThisEvent;
- ofsThisEvent = dbeOld.ofsNext;
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp deleted file mode 100644 index 82a8b29a09..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*
-Miranda Database Tool
-Copyright (C) 2001-2005 Richard Hughes
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../stdafx.h"
-
-int CDb3Mmap::WorkFinalTasks(int)
-{
- FreeModuleChain();
- cb->pfnAddLogMessage(STATUS_MESSAGE, TranslateT("Processing final tasks"));
- m_dbHeader.slackSpace = 0;
-
- if (m_dbHeader.version < DB_095_1_VERSION) {
- memcpy(&m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature));
- m_dbHeader.version = DB_095_1_VERSION;
- }
-
- if (WriteSegment(0, &m_dbHeader, sizeof(m_dbHeader)) == WS_ERROR)
- return ERROR_WRITE_FAULT;
-
- return ERROR_NO_MORE_ITEMS;
-}
diff --git a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp deleted file mode 100644 index 45c8120442..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*
-Miranda Database Tool
-Copyright (C) 2001-2005 Richard Hughes
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../stdafx.h"
-
-int CDb3Mmap::WorkInitialCheckHeaders()
-{
- if (memcmp(m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) &&
- memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)) &&
- memcmp(m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)) &&
- memcmp(m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature)))
- {
- cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Database signature is corrupted, automatic repair is impossible"));
- return ERROR_BAD_FORMAT;
- }
-
- switch (m_dbHeader.version) {
- case DB_OLD_VERSION:
- case DB_094_VERSION:
- case DB_095_VERSION:
- case DB_095_1_VERSION:
- break;
-
- default:
- cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Database version doesn't match this driver's one. Convert a database first"));
- return ERROR_BAD_FORMAT;
- }
-
- return ERROR_SUCCESS;
-}
-
-int CDb3Mmap::WorkInitialChecks(int)
-{
- sourceFileSize = GetFileSize(m_hDbFile, nullptr);
- if (sourceFileSize == 0) {
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Database is newly created and has no data to process"));
- cb->pfnAddLogMessage(STATUS_SUCCESS, TranslateT("Processing completed successfully"));
- return ERROR_INVALID_DATA;
- }
-
- int res = WorkInitialCheckHeaders();
- if (res)
- return res;
-
- if (!m_pDbCache) {
- cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Can't create map view of file (%u)"), GetLastError());
- return ERROR_ACCESS_DENIED;
- }
- if (ReadSegment(0, &m_dbHeader, sizeof(m_dbHeader)) != ERROR_SUCCESS)
- return ERROR_READ_FAULT;
-
- if (WriteSegment(0, &m_dbHeader, sizeof(m_dbHeader)) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
-
- cb->spaceUsed = m_dbHeader.ofsFileEnd - m_dbHeader.slackSpace;
- m_dbHeader.ofsFileEnd = sizeof(m_dbHeader);
- return ERROR_NO_MORE_ITEMS;
-}
diff --git a/plugins/Db3x_mmap/src/dbtool/modulechain.cpp b/plugins/Db3x_mmap/src/dbtool/modulechain.cpp deleted file mode 100644 index 60ae30af7c..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/modulechain.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/*
-Miranda Database Tool
-Copyright (C) 2001-2005 Richard Hughes
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../stdafx.h"
-
-struct ModChainEntry {
- DWORD ofsOld, ofsNew;
- int size;
- char name[257];
-} static *modChain = nullptr;
-static int modChainCount;
-static DWORD ofsCurrent;
-static int phase, iCurrentModName;
-static DWORD ofsLast;
-static int last_mod = 0;
-
-int CDb3Mmap::WorkModuleChain(int firstTime)
-{
- DBModuleName moduleName, *newModName;
-
- if (firstTime) {
- cb->pfnAddLogMessage(STATUS_MESSAGE, TranslateT("Processing module name chain"));
- modChainCount = 0;
- last_mod = 0;
- free(modChain);
- modChain = (ModChainEntry*)malloc(sizeof(ModChainEntry));
- phase = 0;
- ofsCurrent = m_dbHeader.ofsModuleNames;
- }
-
- switch (phase) {
- case 0:
- if (ofsCurrent == 0) {
- phase++;
- return ERROR_SUCCESS;
- }
- if (!SignatureValid(ofsCurrent, DBMODULENAME_SIGNATURE)) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Module chain corrupted, further entries ignored"));
- phase++;
- return ERROR_SUCCESS;
- }
- if (PeekSegment(ofsCurrent, &moduleName, offsetof(DBModuleName, name)) != ERROR_SUCCESS) {
- phase++;
- return ERROR_SUCCESS;
- }
- modChain = (ModChainEntry*)realloc(modChain, sizeof(ModChainEntry)*++modChainCount);
-
- modChain[modChainCount - 1].ofsOld = ofsCurrent;
- modChain[modChainCount - 1].size = offsetof(DBModuleName, name) + moduleName.cbName;
- modChain[modChainCount - 1].ofsNew = 0;
-
- if (moduleName.cbName)
- PeekSegment(ofsCurrent + offsetof(DBModuleName, name), &modChain[modChainCount - 1].name, moduleName.cbName);
- modChain[modChainCount - 1].name[moduleName.cbName] = 0;
- ofsCurrent = moduleName.ofsNext;
- break;
- case 1:
- ofsLast = 0;
- iCurrentModName = 0;
- m_dbHeader.ofsModuleNames = 0;
- phase++;
- case 2:
- if (iCurrentModName >= modChainCount) {
- DWORD dw = 0;
- if (ofsLast) WriteSegment(ofsLast + offsetof(DBModuleName, ofsNext), &dw, sizeof(DWORD));
- return ERROR_NO_MORE_ITEMS;
- }
- if (modChain[iCurrentModName].ofsNew == 0) {
- newModName = (DBModuleName*)_alloca(modChain[iCurrentModName].size);
- if (ReadSegment(modChain[iCurrentModName].ofsOld, newModName, modChain[iCurrentModName].size) != ERROR_SUCCESS)
- return ERROR_NO_MORE_ITEMS;
- if ((modChain[iCurrentModName].ofsNew = WriteSegment(WSOFS_END, newModName, modChain[iCurrentModName].size)) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
-
- // check duplicated modulenames
- int i, n = 0;
- for (i = iCurrentModName + 1; i < modChainCount; i++)
- if (!mir_strcmp(modChain[i].name, modChain[iCurrentModName].name)) {
- modChain[i].ofsNew = modChain[iCurrentModName].ofsNew;
- n++;
- }
- if (n) {
- wchar_t szModuleName[257];
- MultiByteToWideChar(CP_ACP, 0, modChain[iCurrentModName].name, -1, szModuleName, _countof(szModuleName));
- wchar_t *pszModuleName = szModuleName;
-
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Module name '%s' is not unique: %d duplicates found"), pszModuleName, n);
- }
-
- if (iCurrentModName == 0)
- m_dbHeader.ofsModuleNames = modChain[iCurrentModName].ofsNew;
- else if (WriteSegment(ofsLast + offsetof(DBModuleName, ofsNext), &modChain[iCurrentModName].ofsNew, sizeof(DWORD)) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- ofsLast = modChain[iCurrentModName].ofsNew;
- }
- iCurrentModName++;
- break;
- }
- return ERROR_SUCCESS;
-}
-
-DWORD CDb3Mmap::ConvertModuleNameOfs(DWORD ofsOld)
-{
- if (modChain[last_mod].ofsOld == ofsOld)
- return modChain[last_mod].ofsNew;
-
- for (int i = 0; i < modChainCount; i++)
- if (modChain[i].ofsOld == ofsOld) {
- last_mod = i;
- return modChain[last_mod].ofsNew;
- }
-
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Invalid module name offset, skipping data"));
- return 0;
-}
-
-void CDb3Mmap::FreeModuleChain()
-{
- if (modChain != nullptr) {
- free(modChain);
- modChain = nullptr;
- last_mod = 0;
- }
-}
diff --git a/plugins/Db3x_mmap/src/dbtool/settingschain.cpp b/plugins/Db3x_mmap/src/dbtool/settingschain.cpp deleted file mode 100644 index 775e768d0a..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/settingschain.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/*
-Miranda Database Tool
-Copyright (C) 2001-2005 Richard Hughes
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../stdafx.h"
-
-static DWORD ofsThisSettings, ofsDestPrevSettings;
-
-int CDb3Mmap::WorkSettingsChain(DBContact *dbc, int firstTime)
-{
- DWORD ofsDestThis;
- int ret;
-
- if (firstTime) {
- ofsDestPrevSettings = 0;
- ofsThisSettings = dbc->ofsFirstSettings;
- dbc->ofsFirstSettings = 0;
- }
- if (ofsThisSettings == 0)
- return ERROR_NO_MORE_ITEMS;
-
- if (!SignatureValid(ofsThisSettings, DBCONTACTSETTINGS_SIGNATURE)) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Settings chain corrupted, further entries ignored"));
- return ERROR_NO_MORE_ITEMS;
- }
- DBContactSettings dbcsOld;
- if (PeekSegment(ofsThisSettings, &dbcsOld, sizeof(dbcsOld)) != ERROR_SUCCESS)
- return ERROR_NO_MORE_ITEMS;
-
- if (dbcsOld.cbBlob > 256 * 1024 || dbcsOld.cbBlob == 0) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Infeasibly large settings blob: skipping"));
- ofsThisSettings = dbcsOld.ofsNext;
- return ERROR_SUCCESS;
- }
-
- DBContactSettings *dbcsNew = (DBContactSettings*)_alloca(offsetof(DBContactSettings, blob) + dbcsOld.cbBlob);
- if ((ret = ReadSegment(ofsThisSettings, dbcsNew, offsetof(DBContactSettings, blob) + dbcsOld.cbBlob)) != ERROR_SUCCESS)
- if (ret != ERROR_HANDLE_EOF) //eof is OK because blank space at the end doesn't matter
- return ERROR_NO_MORE_ITEMS;
-
- if ((dbcsNew->ofsModuleName = ConvertModuleNameOfs(dbcsOld.ofsModuleName)) == 0) {
- ofsThisSettings = dbcsOld.ofsNext;
- return ERROR_SUCCESS;
- }
-
- if (dbcsNew->blob[0] == 0) {
- cb->pfnAddLogMessage(STATUS_MESSAGE, TranslateT("Empty settings group at %08X: skipping"), ofsThisSettings);
- ofsThisSettings = dbcsOld.ofsNext;
- return ERROR_SUCCESS;
- }
- dbcsNew->ofsNext = 0;
- //TODO? validate all settings in blob/compact if necessary
- if ((ofsDestThis = WriteSegment(WSOFS_END, dbcsNew, offsetof(DBContactSettings, blob) + dbcsNew->cbBlob)) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
-
- if (ofsDestPrevSettings)
- WriteSegment(ofsDestPrevSettings + offsetof(DBContactSettings, ofsNext), &ofsDestThis, sizeof(DWORD));
- else
- dbc->ofsFirstSettings = ofsDestThis;
- ofsDestPrevSettings = ofsDestThis;
- ofsThisSettings = dbcsOld.ofsNext;
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Db3x_mmap/src/dbtool/user.cpp b/plugins/Db3x_mmap/src/dbtool/user.cpp deleted file mode 100644 index 361e02d559..0000000000 --- a/plugins/Db3x_mmap/src/dbtool/user.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/*
-Miranda Database Tool
-Copyright (C) 2001-2005 Richard Hughes
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "../stdafx.h"
-
-static DBContact user;
-static int phase;
-static DWORD ofsUser;
-
-int CDb3Mmap::WorkUser(int firstTime)
-{
- int first = 0;
-
- if (firstTime) {
- cb->pfnAddLogMessage(STATUS_MESSAGE, TranslateT("Processing user data"));
- if (!SignatureValid(m_dbHeader.ofsUser, DBCONTACT_SIGNATURE)) {
- cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("User corrupted, this could cause major problems"));
- return ERROR_NO_MORE_ITEMS;
- }
-
- DWORD dwSize = (m_dbHeader.version < DB_095_VERSION) ? offsetof(DBContact, dwContactID) : sizeof(DBContact);
- if (ReadSegment(m_dbHeader.ofsUser, &user, dwSize) != ERROR_SUCCESS)
- return ERROR_NO_MORE_ITEMS;
-
- if (user.ofsNext) {
- cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("More than one user contact: keeping only first"));
- user.ofsNext = 0;
- }
-
- if ((ofsUser = WriteSegment(WSOFS_END, &user, sizeof(DBContact))) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
-
- m_dbHeader.ofsUser = ofsUser;
- phase = 0;
- first = 1;
- }
-
- int ret;
- switch (phase) {
- case 0:
- ret = WorkSettingsChain(&user, first);
- if (ret == ERROR_NO_MORE_ITEMS) {
- phase++; first = 1;
- }
- else if (ret) return ret;
- else break;
-
- case 1:
- ret = WorkEventChain(ofsUser, &user, first);
- if (ret == ERROR_NO_MORE_ITEMS) {
- if (WriteSegment(ofsUser, &user, sizeof(DBContact)) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- return ERROR_NO_MORE_ITEMS;
- }
- else if (ret)
- return ret;
- break;
- }
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Db3x_mmap/src/version.h b/plugins/Db3x_mmap/src/version.h index c6d77ab8ab..5da2608004 100644 --- a/plugins/Db3x_mmap/src/version.h +++ b/plugins/Db3x_mmap/src/version.h @@ -1,6 +1,6 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
-#define __RELEASE_NUM 3
+#define __RELEASE_NUM 8
#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp index aa2cd398b3..5ecac705be 100644 --- a/plugins/Dbx_mdbx/src/dbintf.cpp +++ b/plugins/Dbx_mdbx/src/dbintf.cpp @@ -196,33 +196,3 @@ int CDbxMDBX::Map() mode |= MDBX_RDONLY;
return mdbx_env_open(m_env, _T2A(m_tszProfileName), mode, 0664);
}
-
-///////////////////////////////////////////////////////////////////////////////
-// MIDatabaseChecker
-
-typedef int (CDbxMDBX::*CheckWorker)(void);
-
-int CDbxMDBX::Start(DBCHeckCallback *callback)
-{
- cb = callback;
- return ERROR_SUCCESS;
-}
-
-static CheckWorker Workers[6] =
-{
- &CDbxMDBX::CheckEvents1,
- &CDbxMDBX::CheckEvents2,
-};
-
-int CDbxMDBX::CheckDb(int phase, int)
-{
- if (phase >= _countof(Workers))
- return ERROR_OUT_OF_PAPER;
-
- return (this->*Workers[phase])();
-}
-
-void CDbxMDBX::Destroy()
-{
- delete this;
-}
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h index 725bc28c61..66515934b3 100644 --- a/plugins/Dbx_mdbx/src/dbintf.h +++ b/plugins/Dbx_mdbx/src/dbintf.h @@ -129,7 +129,7 @@ struct EventItem MEVENT eventId;
};
-struct CDbxMDBX : public MDatabaseCommon, public MIDatabaseChecker, public MZeroedObject
+struct CDbxMDBX : public MDatabaseCommon, public MZeroedObject
{
friend class MDBXEventCursor;
@@ -195,11 +195,6 @@ public: STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub);
protected:
- STDMETHODIMP_(BOOL) Start(DBCHeckCallback *callback);
- STDMETHODIMP_(BOOL) CheckDb(int phase, int firstTime);
- STDMETHODIMP_(VOID) Destroy();
-
-protected:
void FillContacts(void);
@@ -272,8 +267,6 @@ protected: uint32_t GetModuleID(const char *szName);
char* GetModuleName(uint32_t dwId);
- DBCHeckCallback *cb;
-
////////////////////////////////////////////////////////////////////////////
// encryption
diff --git a/plugins/Dbx_mdbx/src/version.h b/plugins/Dbx_mdbx/src/version.h index 543e9abbe4..094b434a85 100644 --- a/plugins/Dbx_mdbx/src/version.h +++ b/plugins/Dbx_mdbx/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
#define __RELEASE_NUM 8
-#define __BUILD_NUM 5
+#define __BUILD_NUM 6
#include <stdver.h>
|