summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-23 20:32:10 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-23 20:32:10 +0000
commitc1075c9ea02e77bcb55fa627623b1ac598abda44 (patch)
treee140de04b3f1d4cbd517f270d8720baef8cf9353 /plugins/Db3x_mmap/src
parent35d4044e1958d2cd68553837a0da0829bd3b98f4 (diff)
slightly changed class hierarchy
git-svn-id: http://svn.miranda-ng.org/main/trunk@1141 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src')
-rw-r--r--plugins/Db3x_mmap/src/commonheaders.h2
-rw-r--r--plugins/Db3x_mmap/src/database.cpp8
-rw-r--r--plugins/Db3x_mmap/src/dbcache.cpp19
-rw-r--r--plugins/Db3x_mmap/src/dbcontacts.cpp16
-rw-r--r--plugins/Db3x_mmap/src/dbevents.cpp24
-rw-r--r--plugins/Db3x_mmap/src/dbheaders.cpp4
-rw-r--r--plugins/Db3x_mmap/src/dbintf.cpp22
-rw-r--r--plugins/Db3x_mmap/src/dbintf.h50
-rw-r--r--plugins/Db3x_mmap/src/dbmodulechain.cpp12
-rw-r--r--plugins/Db3x_mmap/src/dbsettings.cpp32
-rw-r--r--plugins/Db3x_mmap/src/init.cpp12
11 files changed, 109 insertions, 92 deletions
diff --git a/plugins/Db3x_mmap/src/commonheaders.h b/plugins/Db3x_mmap/src/commonheaders.h
index ea615956e1..8fe5b1f87f 100644
--- a/plugins/Db3x_mmap/src/commonheaders.h
+++ b/plugins/Db3x_mmap/src/commonheaders.h
@@ -53,7 +53,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "resource.h"
#include "version.h"
-extern LIST<CDdxMmap> g_Dbs;
+extern LIST<CDb3Mmap> g_Dbs;
#ifdef __GNUC__
#define mir_i64(x) (x##LL)
diff --git a/plugins/Db3x_mmap/src/database.cpp b/plugins/Db3x_mmap/src/database.cpp
index 1962805a35..4a0357d680 100644
--- a/plugins/Db3x_mmap/src/database.cpp
+++ b/plugins/Db3x_mmap/src/database.cpp
@@ -28,7 +28,7 @@ int InitCache(void);
int InitIni(void);
void UninitIni(void);
-DWORD CDdxMmap::CreateNewSpace(int bytes)
+DWORD CDb3Base::CreateNewSpace(int bytes)
{
DWORD ofsNew = m_dbHeader.ofsFileEnd;
m_dbHeader.ofsFileEnd += bytes;
@@ -37,7 +37,7 @@ DWORD CDdxMmap::CreateNewSpace(int bytes)
return ofsNew;
}
-void CDdxMmap::DeleteSpace(DWORD ofs, int bytes)
+void CDb3Base::DeleteSpace(DWORD ofs, int bytes)
{
if (ofs+bytes == m_dbHeader.ofsFileEnd) {
log2("freespace %d@%08x",bytes,ofs);
@@ -51,7 +51,7 @@ void CDdxMmap::DeleteSpace(DWORD ofs, int bytes)
DBFill(ofs, bytes);
}
-DWORD CDdxMmap::ReallocSpace(DWORD ofs, int oldSize, int newSize)
+DWORD CDb3Base::ReallocSpace(DWORD ofs, int oldSize, int newSize)
{
if (oldSize >= newSize)
return ofs;
@@ -96,7 +96,7 @@ void __cdecl dbpanic(void *arg)
TerminateProcess(GetCurrentProcess(),255);
}
-void CDdxMmap::DatabaseCorruption(TCHAR *text)
+void CDb3Base::DatabaseCorruption(TCHAR *text)
{
int kill = 0;
diff --git a/plugins/Db3x_mmap/src/dbcache.cpp b/plugins/Db3x_mmap/src/dbcache.cpp
index 466aa7a00d..4e09335bae 100644
--- a/plugins/Db3x_mmap/src/dbcache.cpp
+++ b/plugins/Db3x_mmap/src/dbcache.cpp
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-void CDdxMmap::Map()
+void CDb3Mmap::Map()
{
m_hMap = CreateFileMapping(m_hDbFile, NULL, PAGE_READWRITE, 0, m_dwFileSize, NULL);
@@ -37,7 +37,7 @@ void CDdxMmap::Map()
DatabaseCorruption( _T("%s (CreateFileMapping failed. Code: %d)"));
}
-void CDdxMmap::ReMap(DWORD needed)
+void CDb3Mmap::ReMap(DWORD needed)
{
KillTimer(NULL,m_flushBuffersTimerId);
@@ -64,7 +64,7 @@ void CDdxMmap::ReMap(DWORD needed)
Map();
}
-void CDdxMmap::DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes)
+void CDb3Mmap::DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes)
{
int x = 0;
log3("move %d %08x->%08x",bytes,ofsSource,ofsDest);
@@ -72,7 +72,6 @@ void CDdxMmap::DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes)
if (ofsSource+bytes > m_dwFileSize) {
x = ofsSource+bytes-m_dwFileSize;
log0("buggy move!");
- _ASSERT(0);
}
if (x > 0)
ZeroMemory(m_pDbCache+ofsDest+bytes-x, x);
@@ -83,7 +82,7 @@ void CDdxMmap::DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes)
}
//we are assumed to be in a mutex here
-PBYTE CDdxMmap::DBRead(DWORD ofs,int bytesRequired,int *bytesAvail)
+PBYTE CDb3Mmap::DBRead(DWORD ofs,int bytesRequired,int *bytesAvail)
{
// buggy read
if (ofs>= m_dwFileSize) {
@@ -97,7 +96,7 @@ PBYTE CDdxMmap::DBRead(DWORD ofs,int bytesRequired,int *bytesAvail)
}
//we are assumed to be in a mutex here
-void CDdxMmap::DBWrite(DWORD ofs,PVOID pData,int bytes)
+void CDb3Mmap::DBWrite(DWORD ofs,PVOID pData,int bytes)
{
log2("write %d@%08x",bytes,ofs);
if (ofs+bytes > m_dwFileSize) ReMap(ofs+bytes-m_dwFileSize);
@@ -106,7 +105,7 @@ void CDdxMmap::DBWrite(DWORD ofs,PVOID pData,int bytes)
}
//we are assumed to be in a mutex here
-void CDdxMmap::DBFill(DWORD ofs,int bytes)
+void CDb3Mmap::DBFill(DWORD ofs,int bytes)
{
log2("zerofill %d@%08x",bytes,ofs);
if (ofs+bytes <= m_dwFileSize)
@@ -117,7 +116,7 @@ void CDdxMmap::DBFill(DWORD ofs,int bytes)
static VOID CALLBACK DoBufferFlushTimerProc(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime)
{
for (int i=0; i < g_Dbs.getCount(); i++) {
- CDdxMmap* db = g_Dbs[i];
+ CDb3Mmap* db = g_Dbs[i];
if (db->m_flushBuffersTimerId != idEvent)
continue;
@@ -137,7 +136,7 @@ static VOID CALLBACK DoBufferFlushTimerProc(HWND hwnd, UINT message, UINT_PTR id
}
}
-void CDdxMmap::DBFlush(int setting)
+void CDb3Mmap::DBFlush(int setting)
{
if (!setting) {
log0("nflush1");
@@ -158,7 +157,7 @@ void CDdxMmap::DBFlush(int setting)
m_flushBuffersTimerId = SetTimer(NULL, m_flushBuffersTimerId, 50, DoBufferFlushTimerProc);
}
-int CDdxMmap::InitCache(void)
+int CDb3Mmap::InitCache(void)
{
m_dwFileSize = GetFileSize(m_hDbFile, NULL);
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp
index b8d4a843b8..3dc0260fa8 100644
--- a/plugins/Db3x_mmap/src/dbcontacts.cpp
+++ b/plugins/Db3x_mmap/src/dbcontacts.cpp
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-DBCachedContactValueList* CDdxMmap::AddToCachedContactList(HANDLE hContact, int index)
+DBCachedContactValueList* CDb3Base::AddToCachedContactList(HANDLE hContact, int index)
{
DBCachedContactValueList* VL = (DBCachedContactValueList*)HeapAlloc(m_hCacheHeap,HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
VL->hContact = hContact;
@@ -37,7 +37,7 @@ DBCachedContactValueList* CDdxMmap::AddToCachedContactList(HANDLE hContact, int
#define proto_module "Protocol"
#define proto_setting "p"
-int CDdxMmap::CheckProto(HANDLE hContact, const char *proto)
+int CDb3Base::CheckProto(HANDLE hContact, const char *proto)
{
char protobuf[MAX_PATH] = {0};
DBVARIANT dbv;
@@ -53,13 +53,13 @@ int CDdxMmap::CheckProto(HANDLE hContact, const char *proto)
return !strcmp(protobuf,proto);
}
-STDMETHODIMP_(LONG) CDdxMmap::GetContactCount(void)
+STDMETHODIMP_(LONG) CDb3Base::GetContactCount(void)
{
mir_cslock lck(m_csDbAccess);
return m_dbHeader.contactCount;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::FindFirstContact(const char *szProto)
+STDMETHODIMP_(HANDLE) CDb3Base::FindFirstContact(const char *szProto)
{
mir_cslock lck(m_csDbAccess);
HANDLE ret = (HANDLE)m_dbHeader.ofsFirstContact;
@@ -68,7 +68,7 @@ STDMETHODIMP_(HANDLE) CDdxMmap::FindFirstContact(const char *szProto)
return ret;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::FindNextContact(HANDLE hContact, const char *szProto)
+STDMETHODIMP_(HANDLE) CDb3Base::FindNextContact(HANDLE hContact, const char *szProto)
{
int index;
DBContact *dbc;
@@ -104,7 +104,7 @@ STDMETHODIMP_(HANDLE) CDdxMmap::FindNextContact(HANDLE hContact, const char *szP
return NULL;
}
-STDMETHODIMP_(LONG) CDdxMmap::DeleteContact(HANDLE hContact)
+STDMETHODIMP_(LONG) CDb3Base::DeleteContact(HANDLE hContact)
{
if (hContact == NULL)
return 1;
@@ -200,7 +200,7 @@ STDMETHODIMP_(LONG) CDdxMmap::DeleteContact(HANDLE hContact)
return 0;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::AddContact()
+STDMETHODIMP_(HANDLE) CDb3Base::AddContact()
{
DWORD ofsNew;
log0("add contact");
@@ -224,7 +224,7 @@ STDMETHODIMP_(HANDLE) CDdxMmap::AddContact()
return (HANDLE)ofsNew;
}
-STDMETHODIMP_(BOOL) CDdxMmap::IsDbContact(HANDLE hContact)
+STDMETHODIMP_(BOOL) CDb3Base::IsDbContact(HANDLE hContact)
{
mir_cslock lck(m_csDbAccess);
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp
index 917d1680b2..c499361557 100644
--- a/plugins/Db3x_mmap/src/dbevents.cpp
+++ b/plugins/Db3x_mmap/src/dbevents.cpp
@@ -30,7 +30,7 @@ char *GetModuleNameByOfs(DWORD ofs);
static HANDLE hEventDeletedEvent,hEventAddedEvent,hEventFilterAddedEvent;
-STDMETHODIMP_(LONG) CDdxMmap::GetEventCount(HANDLE hContact)
+STDMETHODIMP_(LONG) CDb3Base::GetEventCount(HANDLE hContact)
{
mir_cslock lck(m_csDbAccess);
if (hContact == 0)
@@ -40,7 +40,7 @@ STDMETHODIMP_(LONG) CDdxMmap::GetEventCount(HANDLE hContact)
return (dbc->signature != DBCONTACT_SIGNATURE) ? -1 : dbc->eventCount;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::AddEvent(HANDLE hContact, DBEVENTINFO *dbei)
+STDMETHODIMP_(HANDLE) CDb3Base::AddEvent(HANDLE hContact, DBEVENTINFO *dbei)
{
if (dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 0;
if (dbei->timestamp == 0) return 0;
@@ -138,7 +138,7 @@ STDMETHODIMP_(HANDLE) CDdxMmap::AddEvent(HANDLE hContact, DBEVENTINFO *dbei)
return (HANDLE)ofsNew;
}
-STDMETHODIMP_(BOOL) CDdxMmap::DeleteEvent(HANDLE hContact, HANDLE hDbEvent)
+STDMETHODIMP_(BOOL) CDb3Base::DeleteEvent(HANDLE hContact, HANDLE hDbEvent)
{
mir_cslockfull lck(m_csDbAccess);
@@ -216,14 +216,14 @@ STDMETHODIMP_(BOOL) CDdxMmap::DeleteEvent(HANDLE hContact, HANDLE hDbEvent)
return 0;
}
-STDMETHODIMP_(LONG) CDdxMmap::GetBlobSize(HANDLE hDbEvent)
+STDMETHODIMP_(LONG) CDb3Base::GetBlobSize(HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
DBEvent *dbe = (DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
return (dbe->signature != DBEVENT_SIGNATURE) ? -1 : dbe->cbBlob;
}
-STDMETHODIMP_(BOOL) CDdxMmap::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei)
+STDMETHODIMP_(BOOL) CDb3Base::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei)
{
if (dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 1;
if (dbei->cbBlob > 0 && dbei->pBlob == NULL) {
@@ -254,7 +254,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei)
return 0;
}
-STDMETHODIMP_(BOOL) CDdxMmap::MarkEventRead(HANDLE hContact, HANDLE hDbEvent)
+STDMETHODIMP_(BOOL) CDb3Base::MarkEventRead(HANDLE hContact, HANDLE hDbEvent)
{
DBEvent *dbe;
DBContact dbc;
@@ -296,7 +296,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::MarkEventRead(HANDLE hContact, HANDLE hDbEvent)
return ret;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::GetEventContact(HANDLE hDbEvent)
+STDMETHODIMP_(HANDLE) CDb3Base::GetEventContact(HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
DBEvent *dbe = (DBEvent*)DBRead(hDbEvent,sizeof(DBEvent),NULL);
@@ -309,7 +309,7 @@ STDMETHODIMP_(HANDLE) CDdxMmap::GetEventContact(HANDLE hDbEvent)
return (HANDLE)dbe->ofsPrev;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::FindFirstEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDb3Base::FindFirstEvent(HANDLE hContact)
{
mir_cslock lck(m_csDbAccess);
if (hContact == 0)
@@ -319,7 +319,7 @@ STDMETHODIMP_(HANDLE) CDdxMmap::FindFirstEvent(HANDLE hContact)
return (dbc->signature != DBCONTACT_SIGNATURE) ? 0 : (HANDLE)dbc->ofsFirstEvent;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::FindFirstUnreadEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDb3Base::FindFirstUnreadEvent(HANDLE hContact)
{
mir_cslock lck(m_csDbAccess);
if (hContact == 0)
@@ -329,7 +329,7 @@ STDMETHODIMP_(HANDLE) CDdxMmap::FindFirstUnreadEvent(HANDLE hContact)
return (dbc->signature != DBCONTACT_SIGNATURE) ? 0 : (HANDLE)dbc->ofsFirstUnreadEvent;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::FindLastEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDb3Base::FindLastEvent(HANDLE hContact)
{
mir_cslock lck(m_csDbAccess);
if (hContact == 0)
@@ -339,14 +339,14 @@ STDMETHODIMP_(HANDLE) CDdxMmap::FindLastEvent(HANDLE hContact)
return (dbc->signature != DBCONTACT_SIGNATURE) ? 0 : (HANDLE)dbc->ofsLastEvent;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::FindNextEvent(HANDLE hDbEvent)
+STDMETHODIMP_(HANDLE) CDb3Base::FindNextEvent(HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
DBEvent *dbe = (DBEvent*)DBRead(hDbEvent,sizeof(DBEvent),NULL);
return (dbe->signature != DBEVENT_SIGNATURE) ? 0 : (HANDLE)dbe->ofsNext;
}
-STDMETHODIMP_(HANDLE) CDdxMmap::FindPrevEvent(HANDLE hDbEvent)
+STDMETHODIMP_(HANDLE) CDb3Base::FindPrevEvent(HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
DBEvent *dbe = (DBEvent*)DBRead(hDbEvent,sizeof(DBEvent),NULL);
diff --git a/plugins/Db3x_mmap/src/dbheaders.cpp b/plugins/Db3x_mmap/src/dbheaders.cpp
index 3d18a373fa..394b66acfc 100644
--- a/plugins/Db3x_mmap/src/dbheaders.cpp
+++ b/plugins/Db3x_mmap/src/dbheaders.cpp
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern DBSignature dbSignature;
-int CDdxMmap::CreateDbHeaders()
+int CDb3Base::CreateDbHeaders()
{
DBContact user;
DWORD bytesWritten;
@@ -56,7 +56,7 @@ int CDdxMmap::CreateDbHeaders()
return 0;
}
-int CDdxMmap::CheckDbHeaders()
+int CDb3Base::CheckDbHeaders()
{
if (memcmp(m_dbHeader.signature, &dbSignature, sizeof(m_dbHeader.signature))) return 1;
if (m_dbHeader.version != DB_THIS_VERSION) return 2;
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp
index 83ae3aa4ca..0479be3691 100644
--- a/plugins/Db3x_mmap/src/dbintf.cpp
+++ b/plugins/Db3x_mmap/src/dbintf.cpp
@@ -50,7 +50,7 @@ static int OfsCompare(const ModuleName *mn1, const ModuleName *mn2 )
return ( mn1->ofs - mn2->ofs );
}
-CDdxMmap::CDdxMmap(const TCHAR* tszFileName) :
+CDb3Base::CDb3Base(const TCHAR* tszFileName) :
m_hDbFile(INVALID_HANDLE_VALUE),
m_safetyMode(TRUE),
m_lSettings(100, stringCompare),
@@ -73,7 +73,7 @@ CDdxMmap::CDdxMmap(const TCHAR* tszFileName) :
m_hModHeap = HeapCreate(0,0,0);
}
-CDdxMmap::~CDdxMmap()
+CDb3Base::~CDb3Base()
{
// destroy settings
HeapDestroy(m_hCacheHeap);
@@ -93,10 +93,6 @@ CDdxMmap::~CDdxMmap()
FlushViewOfFile(m_pDbCache, 0);
UnmapViewOfFile(m_pDbCache);
}
- if (m_hMap)
- CloseHandle(m_hMap);
- if (m_pNull)
- free(m_pNull);
// update profile last modified time
DWORD bytesWritten;
@@ -109,7 +105,7 @@ CDdxMmap::~CDdxMmap()
mir_free(m_tszProfileName);
}
-int CDdxMmap::Load(bool bSkipInit)
+int CDb3Base::Load(bool bSkipInit)
{
log0("DB logging running");
@@ -138,13 +134,13 @@ int CDdxMmap::Load(bool bSkipInit)
return 0;
}
-int CDdxMmap::Create()
+int CDb3Base::Create()
{
m_hDbFile = CreateFile(m_tszProfileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL);
return ( m_hDbFile == INVALID_HANDLE_VALUE );
}
-STDMETHODIMP_(void) CDdxMmap::SetCacheSafetyMode(BOOL bIsSet)
+STDMETHODIMP_(void) CDb3Base::SetCacheSafetyMode(BOOL bIsSet)
{
{ mir_cslock lck(m_csDbAccess);
m_safetyMode = bIsSet;
@@ -152,22 +148,22 @@ STDMETHODIMP_(void) CDdxMmap::SetCacheSafetyMode(BOOL bIsSet)
DBFlush(1);
}
-void CDdxMmap::EncodeCopyMemory(void *dst, void *src, size_t size)
+void CDb3Base::EncodeCopyMemory(void *dst, void *src, size_t size)
{
MoveMemory(dst, src, size);
}
-void CDdxMmap::DecodeCopyMemory(void *dst, void *src, size_t size)
+void CDb3Base::DecodeCopyMemory(void *dst, void *src, size_t size)
{
MoveMemory(dst, src, size);
}
-void CDdxMmap::EncodeDBWrite(DWORD ofs, void *src, int size)
+void CDb3Base::EncodeDBWrite(DWORD ofs, void *src, int size)
{
DBWrite(ofs, src, size);
}
-void CDdxMmap::DecodeDBWrite(DWORD ofs, void *src, int size)
+void CDb3Base::DecodeDBWrite(DWORD ofs, void *src, int size)
{
DBWrite(ofs, src, size);
}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h
index 4dff427516..c3a14c0c01 100644
--- a/plugins/Db3x_mmap/src/dbintf.h
+++ b/plugins/Db3x_mmap/src/dbintf.h
@@ -156,16 +156,19 @@ struct DBCachedContactValueList
#define MAXCACHEDREADSIZE 65536
-struct CDdxMmap : public MIDatabase, public MZeroedObject
+struct CDb3Base : public MIDatabase, public MZeroedObject
{
- CDdxMmap(const TCHAR* tszFileName);
- ~CDdxMmap();
+ CDb3Base(const TCHAR* tszFileName);
+ ~CDb3Base();
int Load(bool bSkipInit);
int Create(void);
int CreateDbHeaders();
int CheckDbHeaders();
void DatabaseCorruption(TCHAR *text);
+
+ __forceinline HANDLE getFile() const { return m_hDbFile; }
+
protected:
STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
@@ -202,6 +205,14 @@ protected:
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
protected:
+ virtual void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes) = 0;
+ virtual PBYTE DBRead(DWORD ofs, int bytesRequired, int *bytesAvail) = 0;
+ virtual void DBWrite(DWORD ofs, PVOID pData, int bytes) = 0;
+ virtual void DBFill(DWORD ofs, int bytes) = 0;
+ virtual void DBFlush(int setting) = 0;
+ virtual int InitCache(void) = 0;
+
+protected:
virtual void EncodeCopyMemory(void *dst, void *src, size_t size);
virtual void DecodeCopyMemory(void *dst, void *src, size_t size);
virtual void EncodeDBWrite(DWORD ofs, void *src, int size);
@@ -220,9 +231,8 @@ public:
UINT_PTR m_flushBuffersTimerId;
DWORD m_flushFailTick;
PBYTE m_pDbCache;
+
protected:
- PBYTE m_pNull;
- HANDLE m_hMap;
DWORD m_dwFileSize;
CRITICAL_SECTION m_csDbAccess;
@@ -232,15 +242,6 @@ protected:
void DeleteSpace(DWORD ofs, int bytes);
DWORD ReallocSpace(DWORD ofs, int oldSize, int newSize);
- void Map();
- void ReMap(DWORD needed);
- void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes);
- PBYTE DBRead(DWORD ofs, int bytesRequired, int *bytesAvail);
- void DBWrite(DWORD ofs, PVOID pData, int bytes);
- void DBFill(DWORD ofs, int bytes);
- void DBFlush(int setting);
- int InitCache(void);
-
__forceinline PBYTE DBRead(HANDLE hContact, int bytesRequired, int *bytesAvail)
{ return DBRead((DWORD)hContact, bytesRequired, bytesAvail);
}
@@ -287,3 +288,24 @@ protected:
DWORD GetModuleNameOfs(const char *szName);
char *GetModuleNameByOfs(DWORD ofs);
};
+
+struct CDb3Mmap : public CDb3Base
+{
+ CDb3Mmap(const TCHAR* ptszFileName);
+ ~CDb3Mmap();
+
+protected:
+ virtual void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes);
+ virtual PBYTE DBRead(DWORD ofs, int bytesRequired, int *bytesAvail);
+ virtual void DBWrite(DWORD ofs, PVOID pData, int bytes);
+ virtual void DBFill(DWORD ofs, int bytes);
+ virtual void DBFlush(int setting);
+ virtual int InitCache(void);
+
+protected:
+ PBYTE m_pNull;
+ HANDLE m_hMap;
+
+ void Map();
+ void ReMap(DWORD needed);
+};
diff --git a/plugins/Db3x_mmap/src/dbmodulechain.cpp b/plugins/Db3x_mmap/src/dbmodulechain.cpp
index f8b25ef879..67d723eec3 100644
--- a/plugins/Db3x_mmap/src/dbmodulechain.cpp
+++ b/plugins/Db3x_mmap/src/dbmodulechain.cpp
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-void CDdxMmap::AddToList(char *name, DWORD len, DWORD ofs)
+void CDb3Base::AddToList(char *name, DWORD len, DWORD ofs)
{
ModuleName *mn = (ModuleName*)HeapAlloc(m_hModHeap,0,sizeof(ModuleName));
mn->name = name;
@@ -38,7 +38,7 @@ void CDdxMmap::AddToList(char *name, DWORD len, DWORD ofs)
m_lOfs.insert(mn);
}
-int CDdxMmap::InitModuleNames(void)
+int CDb3Base::InitModuleNames(void)
{
DWORD ofsThis = m_dbHeader.ofsFirstModuleName;
DBModuleName *dbmn = (struct DBModuleName*)DBRead(ofsThis,sizeof(struct DBModuleName),NULL);
@@ -60,7 +60,7 @@ int CDdxMmap::InitModuleNames(void)
return 0;
}
-DWORD CDdxMmap::FindExistingModuleNameOfs(const char *szName)
+DWORD CDb3Base::FindExistingModuleNameOfs(const char *szName)
{
ModuleName mn = { (char*)szName, 0 };
if (m_lastmn && !strcmp(mn.name, m_lastmn->name))
@@ -77,7 +77,7 @@ DWORD CDdxMmap::FindExistingModuleNameOfs(const char *szName)
}
//will create the offset if it needs to
-DWORD CDdxMmap::GetModuleNameOfs(const char *szName)
+DWORD CDb3Base::GetModuleNameOfs(const char *szName)
{
struct DBModuleName dbmn;
int nameLen;
@@ -109,7 +109,7 @@ DWORD CDdxMmap::GetModuleNameOfs(const char *szName)
return ofsNew;
}
-char* CDdxMmap::GetModuleNameByOfs(DWORD ofs)
+char* CDb3Base::GetModuleNameByOfs(DWORD ofs)
{
if (m_lastmn && m_lastmn->ofs == ofs)
return m_lastmn->name;
@@ -126,7 +126,7 @@ char* CDdxMmap::GetModuleNameByOfs(DWORD ofs)
return NULL;
}
-STDMETHODIMP_(BOOL) CDdxMmap::EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam)
+STDMETHODIMP_(BOOL) CDb3Base::EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam)
{
for (int i = 0; i < m_lMods.getCount(); i++) {
ModuleName *pmn = m_lMods[i];
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp
index 49ac018047..dac7f88b18 100644
--- a/plugins/Db3x_mmap/src/dbsettings.cpp
+++ b/plugins/Db3x_mmap/src/dbsettings.cpp
@@ -28,7 +28,7 @@ DBCachedContactValueList* AddToCachedContactList(HANDLE hContact, int index);
int DBPreset_QuerySetting(const char *szModule, const char *szSetting, DBVARIANT *dbv, BOOL isStatic);
-DWORD CDdxMmap::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsModuleName)
+DWORD CDb3Base::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsModuleName)
{
DWORD ofsThis = dbc->ofsFirstSettings;
while (ofsThis) {
@@ -49,7 +49,7 @@ DWORD __forceinline GetSettingValueLength(PBYTE pSetting)
return pSetting[0];
}
-char* CDdxMmap::InsertCachedSetting(const char* szName, size_t cbNameLen)
+char* CDb3Base::InsertCachedSetting(const char* szName, size_t cbNameLen)
{
char* newValue = (char*)HeapAlloc(m_hCacheHeap, 0, cbNameLen);
*newValue = 0;
@@ -58,7 +58,7 @@ char* CDdxMmap::InsertCachedSetting(const char* szName, size_t cbNameLen)
return newValue;
}
-char* CDdxMmap::GetCachedSetting(const char *szModuleName,const char *szSettingName, int moduleNameLen, int settingNameLen)
+char* CDb3Base::GetCachedSetting(const char *szModuleName,const char *szSettingName, int moduleNameLen, int settingNameLen)
{
char szFullName[512];
strcpy(szFullName+1,szModuleName);
@@ -77,7 +77,7 @@ char* CDdxMmap::GetCachedSetting(const char *szModuleName,const char *szSettingN
return m_lastSetting;
}
-void CDdxMmap::SetCachedVariant( DBVARIANT* s /* new */, DBVARIANT* d /* cached */ )
+void CDb3Base::SetCachedVariant( DBVARIANT* s /* new */, DBVARIANT* d /* cached */ )
{
char* szSave = ( d->type == DBVT_UTF8 || d->type == DBVT_ASCIIZ ) ? d->pszVal : NULL;
@@ -104,13 +104,13 @@ void CDdxMmap::SetCachedVariant( DBVARIANT* s /* new */, DBVARIANT* d /* cached
#endif
}
-void CDdxMmap::FreeCachedVariant( DBVARIANT* V )
+void CDb3Base::FreeCachedVariant( DBVARIANT* V )
{
if (( V->type == DBVT_ASCIIZ || V->type == DBVT_UTF8 ) && V->pszVal != NULL )
HeapFree(m_hCacheHeap,0,V->pszVal);
}
-DBVARIANT* CDdxMmap::GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllocate )
+DBVARIANT* CDb3Base::GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllocate )
{
if ( hContact == 0 ) {
DBCachedGlobalValue Vtemp, *V;
@@ -201,7 +201,7 @@ DBVARIANT* CDdxMmap::GetCachedValuePtr( HANDLE hContact, char* szSetting, int bA
#define MoveAlong(n) {int x = n; pBlob += (x); ofsBlobPtr += (x); bytesRemaining -= (x);}
#define VLT(n) ((n == DBVT_UTF8)?DBVT_ASCIIZ:n)
-int CDdxMmap::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs,int isStatic)
+int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs,int isStatic)
{
DBContact *dbc;
DWORD ofsModuleName,ofsContact,ofsSettingsGroup,ofsBlobPtr;
@@ -374,7 +374,7 @@ int CDdxMmap::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs
return 1;
}
-STDMETHODIMP_(BOOL) CDdxMmap::GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dgs)
+STDMETHODIMP_(BOOL) CDb3Base::GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dgs)
{
dgs->pValue->type = 0;
if ( GetContactSettingWorker(hContact, dgs, 0 ))
@@ -408,7 +408,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::GetContactSetting(HANDLE hContact, DBCONTACTGETSET
return 0;
}
-STDMETHODIMP_(BOOL) CDdxMmap::GetContactSettingStr(HANDLE hContact, DBCONTACTGETSETTING *dgs)
+STDMETHODIMP_(BOOL) CDb3Base::GetContactSettingStr(HANDLE hContact, DBCONTACTGETSETTING *dgs)
{
int iSaveType = dgs->pValue->type;
@@ -455,7 +455,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::GetContactSettingStr(HANDLE hContact, DBCONTACTGET
return 0;
}
-STDMETHODIMP_(BOOL) CDdxMmap::GetContactSettingStatic(HANDLE hContact, DBCONTACTGETSETTING *dgs)
+STDMETHODIMP_(BOOL) CDb3Base::GetContactSettingStatic(HANDLE hContact, DBCONTACTGETSETTING *dgs)
{
if ( GetContactSettingWorker(hContact, dgs, 1 ))
return 1;
@@ -468,7 +468,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::GetContactSettingStatic(HANDLE hContact, DBCONTACT
return 0;
}
-STDMETHODIMP_(BOOL) CDdxMmap::FreeVariant(DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDb3Base::FreeVariant(DBVARIANT *dbv)
{
if ( dbv == 0 ) return 1;
switch ( dbv->type ) {
@@ -491,7 +491,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::FreeVariant(DBVARIANT *dbv)
return 0;
}
-STDMETHODIMP_(BOOL) CDdxMmap::SetSettingResident(BOOL bIsResident, const char *pszSettingName)
+STDMETHODIMP_(BOOL) CDb3Base::SetSettingResident(BOOL bIsResident, const char *pszSettingName)
{
size_t cbSettingNameLen = strlen(pszSettingName) + 2;
if (cbSettingNameLen < 512) {
@@ -519,7 +519,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::SetSettingResident(BOOL bIsResident, const char *p
return 0;
}
-STDMETHODIMP_(BOOL) CDdxMmap::WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws)
+STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws)
{
DBCONTACTWRITESETTING tmp;
DWORD ofsModuleName;
@@ -788,7 +788,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT
return 0;
}
-STDMETHODIMP_(BOOL) CDdxMmap::DeleteContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
+STDMETHODIMP_(BOOL) CDb3Base::DeleteContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
{
DBContact *dbc;
DWORD ofsModuleName,ofsSettingsGroup,ofsBlobPtr;
@@ -880,7 +880,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::DeleteContactSetting(HANDLE hContact, DBCONTACTGET
return 0;
}
-STDMETHODIMP_(BOOL) CDdxMmap::EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces)
+STDMETHODIMP_(BOOL) CDb3Base::EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces)
{
DBContact *dbc;
DWORD ofsModuleName,ofsContact,ofsBlobPtr;
@@ -923,7 +923,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::EnumContactSettings(HANDLE hContact, DBCONTACTENUM
return result;
}
-STDMETHODIMP_(BOOL) CDdxMmap::EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam)
+STDMETHODIMP_(BOOL) CDb3Base::EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam)
{
for(int i = 0; i < m_lResidentSettings.getCount(); i++) {
int ret = pFunc(m_lResidentSettings[i], 0, (LPARAM)pParam);
diff --git a/plugins/Db3x_mmap/src/init.cpp b/plugins/Db3x_mmap/src/init.cpp
index b38fab0ce2..032b43b5d4 100644
--- a/plugins/Db3x_mmap/src/init.cpp
+++ b/plugins/Db3x_mmap/src/init.cpp
@@ -41,14 +41,14 @@ static PLUGININFOEX pluginInfo =
HINSTANCE g_hInst = NULL;
-LIST<CDdxMmap> g_Dbs(1, (LIST<CDdxMmap>::FTSortFunc)HandleKeySort);
+LIST<CDb3Mmap> g_Dbs(1, (LIST<CDb3Mmap>::FTSortFunc)HandleKeySort);
/////////////////////////////////////////////////////////////////////////////////////////
// returns 0 if the profile is created, EMKPRF*
static int makeDatabase(const TCHAR *profile, int *error)
{
- CDdxMmap *tmp = new CDdxMmap(profile);
+ CDb3Mmap *tmp = new CDb3Mmap(profile);
if (tmp->Create() == ERROR_SUCCESS) {
tmp->CreateDbHeaders();
delete tmp;
@@ -62,7 +62,7 @@ static int makeDatabase(const TCHAR *profile, int *error)
// returns 0 if the given profile has a valid header
static int grokHeader(const TCHAR *profile, int *error)
{
- CDdxMmap *tmp = new CDdxMmap(profile);
+ CDb3Mmap *tmp = new CDb3Mmap(profile);
if (tmp->Load(true) != ERROR_SUCCESS) {
delete tmp;
if (error != NULL) *error = EGROKPRF_CANTREAD;
@@ -104,7 +104,7 @@ static MIDatabase* LoadDatabase(const TCHAR *profile)
// set the memory, lists & UTF8 manager
mir_getLP( &pluginInfo );
- CDdxMmap* db = new CDdxMmap(profile);
+ CDb3Mmap* db = new CDb3Mmap(profile);
if (db->Load(false) != ERROR_SUCCESS) {
delete db;
return NULL;
@@ -116,8 +116,8 @@ static MIDatabase* LoadDatabase(const TCHAR *profile)
static int UnloadDatabase(MIDatabase* db)
{
- g_Dbs.remove((CDdxMmap*)db);
- delete (CDdxMmap*)db;
+ g_Dbs.remove((CDb3Mmap*)db);
+ delete (CDb3Mmap*)db;
return 0;
}