summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbcache.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-29 19:55:04 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-29 19:55:04 +0000
commit7e0c7c426f9c8a453deef09c3d6679824af5f3d5 (patch)
tree6e247cf898b38c430cf1924242177e91a02226a5 /plugins/Db3x_mmap/src/dbcache.cpp
parent5dbf04acc4094bdf762bbadb71b7ab6024e09dd5 (diff)
preparing mmap_sa, that it finally compatible with new mmap
git-svn-id: http://svn.miranda-ng.org/main/trunk@7415 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbcache.cpp')
-rw-r--r--plugins/Db3x_mmap/src/dbcache.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/plugins/Db3x_mmap/src/dbcache.cpp b/plugins/Db3x_mmap/src/dbcache.cpp
index 7f07540b56..d5700d2db7 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 CDb3Mmap::Map()
+void CDb3Base::Map()
{
m_hMap = CreateFileMapping(m_hDbFile, NULL, PAGE_READWRITE, 0, m_dwFileSize, NULL);
if (m_hMap) {
@@ -34,7 +34,7 @@ void CDb3Mmap::Map()
else DatabaseCorruption( _T("%s (CreateFileMapping failed. Code: %d)"));
}
-void CDb3Mmap::ReMap(DWORD needed)
+void CDb3Base::ReMap(DWORD needed)
{
KillTimer(NULL,m_flushBuffersTimerId);
@@ -58,7 +58,7 @@ void CDb3Mmap::ReMap(DWORD needed)
Map();
}
-void CDb3Mmap::DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes)
+void CDb3Base::DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes)
{
int x = 0;
//log3("move %d %08x->%08x",bytes,ofsSource,ofsDest);
@@ -76,7 +76,7 @@ void CDb3Mmap::DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes)
}
//we are assumed to be in a mutex here
-PBYTE CDb3Mmap::DBRead(DWORD ofs,int bytesRequired,int *bytesAvail)
+PBYTE CDb3Base::DBRead(DWORD ofs, int bytesRequired, int *bytesAvail)
{
// buggy read
if (ofs >= m_dwFileSize) {
@@ -90,7 +90,7 @@ PBYTE CDb3Mmap::DBRead(DWORD ofs,int bytesRequired,int *bytesAvail)
}
//we are assumed to be in a mutex here
-void CDb3Mmap::DBWrite(DWORD ofs,PVOID pData,int bytes)
+void CDb3Base::DBWrite(DWORD ofs, PVOID pData, int bytes)
{
//log2("write %d@%08x",bytes,ofs);
if (ofs+bytes > m_dwFileSize) ReMap(ofs+bytes-m_dwFileSize);
@@ -99,7 +99,7 @@ void CDb3Mmap::DBWrite(DWORD ofs,PVOID pData,int bytes)
}
//we are assumed to be in a mutex here
-void CDb3Mmap::DBFill(DWORD ofs,int bytes)
+void CDb3Base::DBFill(DWORD ofs, int bytes)
{
//log2("zerofill %d@%08x",bytes,ofs);
if (ofs+bytes <= m_dwFileSize)
@@ -110,7 +110,7 @@ void CDb3Mmap::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++) {
- CDb3Mmap* db = g_Dbs[i];
+ CDb3Base *db = g_Dbs[i];
if (db->m_flushBuffersTimerId != idEvent)
continue;
@@ -130,7 +130,7 @@ static VOID CALLBACK DoBufferFlushTimerProc(HWND hwnd, UINT message, UINT_PTR id
}
}
-void CDb3Mmap::DBFlush(int setting)
+void CDb3Base::DBFlush(int setting)
{
if (!setting) {
log0("nflush1");
@@ -151,7 +151,7 @@ void CDb3Mmap::DBFlush(int setting)
m_flushBuffersTimerId = SetTimer(NULL, m_flushBuffersTimerId, 50, DoBufferFlushTimerProc);
}
-int CDb3Mmap::InitCache(void)
+int CDb3Base::InitCache(void)
{
m_dwFileSize = GetFileSize(m_hDbFile, NULL);
@@ -166,3 +166,17 @@ int CDb3Mmap::InitCache(void)
m_pNull = (PBYTE)calloc(m_ChunkSize, 1);
return 0;
}
+
+DWORD CDb3Base::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsContact, DWORD ofsModuleName)
+{
+ DWORD ofsThis = dbc->ofsFirstSettings;
+ while (ofsThis) {
+ DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis, sizeof(DBContactSettings), NULL);
+ if (dbcs->signature != DBCONTACTSETTINGS_SIGNATURE) DatabaseCorruption(NULL);
+ if (dbcs->ofsModuleName == ofsModuleName)
+ return ofsThis;
+
+ ofsThis = dbcs->ofsNext;
+ }
+ return 0;
+}