From d5f98458e06b9aee5522dc9475b5676e6fd14317 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sun, 14 Dec 2014 17:35:00 +0000 Subject: Db3x_mmap: changed warning lavel to w4 git-svn-id: http://svn.miranda-ng.org/main/trunk@11418 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db3x_mmap/db3x_mmap_12.vcxproj | 8 +-- plugins/Db3x_mmap/src/database.cpp | 41 ++++++------ plugins/Db3x_mmap/src/database.h | 32 ++++----- plugins/Db3x_mmap/src/dbcache.cpp | 14 ++-- plugins/Db3x_mmap/src/dbcontacts.cpp | 32 ++++----- plugins/Db3x_mmap/src/dbcrypt.cpp | 38 +++++------ plugins/Db3x_mmap/src/dbevents.cpp | 80 +++++++++++------------ plugins/Db3x_mmap/src/dbheaders.cpp | 12 ++-- plugins/Db3x_mmap/src/dbintf.cpp | 20 +++--- plugins/Db3x_mmap/src/dbintf.h | 69 ++++++++++---------- plugins/Db3x_mmap/src/dbmodulechain.cpp | 24 +++---- plugins/Db3x_mmap/src/dbsettings.cpp | 90 +++++++++++++------------- plugins/Db3x_mmap/src/dbtool/contactchain.cpp | 10 +-- plugins/Db3x_mmap/src/dbtool/eventchain.cpp | 10 +-- plugins/Db3x_mmap/src/dbtool/finaltasks.cpp | 2 +- plugins/Db3x_mmap/src/dbtool/initialchecks.cpp | 12 ++-- plugins/Db3x_mmap/src/dbtool/modulechain.cpp | 6 +- plugins/Db3x_mmap/src/dbtool/settingschain.cpp | 4 +- plugins/Db3x_mmap/src/dbtool/user.cpp | 2 +- plugins/Db3x_mmap/src/init.cpp | 6 +- plugins/Db3x_mmap/src/ui.cpp | 8 +-- 21 files changed, 261 insertions(+), 259 deletions(-) diff --git a/plugins/Db3x_mmap/db3x_mmap_12.vcxproj b/plugins/Db3x_mmap/db3x_mmap_12.vcxproj index 0633f218d3..c22f15025a 100644 --- a/plugins/Db3x_mmap/db3x_mmap_12.vcxproj +++ b/plugins/Db3x_mmap/db3x_mmap_12.vcxproj @@ -84,7 +84,7 @@ Fast Use commonheaders.h - Level3 + Level4 EditAndContinue false false @@ -115,7 +115,7 @@ Fast Use commonheaders.h - Level3 + Level4 false @@ -145,7 +145,7 @@ Fast Use commonheaders.h - Level3 + Level4 NDEBUG;%(PreprocessorDefinitions) @@ -176,7 +176,7 @@ Fast Use commonheaders.h - Level3 + Level4 NDEBUG;%(PreprocessorDefinitions) diff --git a/plugins/Db3x_mmap/src/database.cpp b/plugins/Db3x_mmap/src/database.cpp index 7a99d7fe3a..8d4cddfb4c 100644 --- a/plugins/Db3x_mmap/src/database.cpp +++ b/plugins/Db3x_mmap/src/database.cpp @@ -41,12 +41,12 @@ DWORD CDb3Mmap::CreateNewSpace(int bytes) void CDb3Mmap::DeleteSpace(DWORD ofs, int bytes) { - if (ofs+bytes == m_dbHeader.ofsFileEnd) { - log2("freespace %d@%08x",bytes,ofs); + if (ofs + bytes == m_dbHeader.ofsFileEnd) { + log2("freespace %d@%08x", bytes, ofs); m_dbHeader.ofsFileEnd = ofs; } else { - log2("deletespace %d@%08x",bytes,ofs); + log2("deletespace %d@%08x", bytes, ofs); m_dbHeader.slackSpace += bytes; } DBWrite(0, &m_dbHeader, sizeof(m_dbHeader)); @@ -59,16 +59,16 @@ DWORD CDb3Mmap::ReallocSpace(DWORD ofs, int oldSize, int newSize) return ofs; DWORD ofsNew; - if (ofs+oldSize == m_dbHeader.ofsFileEnd) { + if (ofs + oldSize == m_dbHeader.ofsFileEnd) { ofsNew = ofs; - m_dbHeader.ofsFileEnd += newSize-oldSize; + m_dbHeader.ofsFileEnd += newSize - oldSize; DBWrite(0, &m_dbHeader, sizeof(m_dbHeader)); log3("adding newspace %d@%08x+%d", newSize, ofsNew, oldSize); } else { ofsNew = CreateNewSpace(newSize); DBMoveChunk(ofsNew, ofs, oldSize); - DeleteSpace(ofs,oldSize); + DeleteSpace(ofs, oldSize); } return ofsNew; } @@ -79,7 +79,7 @@ static DWORD DatabaseCorrupted = 0; static TCHAR *msg = NULL; static DWORD dwErr = 0; -void __cdecl dbpanic(void *arg) +void __cdecl dbpanic(void *) { if (msg) { @@ -90,12 +90,12 @@ void __cdecl dbpanic(void *arg) mir_sntprintf(err, SIZEOF(err), msg, TranslateT("Database failure. Miranda will now shut down."), dwErr); - MessageBox(0,err,TranslateT("Database Error"),MB_SETFOREGROUND|MB_TOPMOST|MB_APPLMODAL|MB_ICONWARNING|MB_OK); + MessageBox(0, err, TranslateT("Database Error"), MB_SETFOREGROUND | MB_TOPMOST | MB_APPLMODAL | MB_ICONWARNING | MB_OK); } else - MessageBox(0,TranslateT("Miranda has detected corruption in your database. This corruption may be fixed by DbChecker plugin. Please download it from http://miranda-ng.org/p/DbChecker/. Miranda will now shut down."), - TranslateT("Database Panic"),MB_SETFOREGROUND|MB_TOPMOST|MB_APPLMODAL|MB_ICONWARNING|MB_OK); - TerminateProcess(GetCurrentProcess(),255); + MessageBox(0, TranslateT("Miranda has detected corruption in your database. This corruption may be fixed by DbChecker plugin. Please download it from http://miranda-ng.org/p/DbChecker/. Miranda will now shut down."), + TranslateT("Database Panic"), MB_SETFOREGROUND | MB_TOPMOST | MB_APPLMODAL | MB_ICONWARNING | MB_OK); + TerminateProcess(GetCurrentProcess(), 255); } void CDb3Mmap::DatabaseCorruption(TCHAR *text) @@ -108,7 +108,8 @@ void CDb3Mmap::DatabaseCorruption(TCHAR *text) kill++; msg = text; dwErr = GetLastError(); - } else { + } + else { /* db is already corrupted, someone else is dealing with it, wait here so that we don't do any more damage */ LeaveCriticalSection(&m_csDbAccess); @@ -117,7 +118,7 @@ void CDb3Mmap::DatabaseCorruption(TCHAR *text) } LeaveCriticalSection(&m_csDbAccess); if (kill) { - _beginthread(dbpanic,0,NULL); + _beginthread(dbpanic, 0, NULL); Sleep(INFINITE); } } @@ -130,13 +131,13 @@ char* printVariant(DBVARIANT* p) static char boo[1000]; switch (p->type) { - case DBVT_BYTE: mir_snprintf(boo, SIZEOF(boo), "byte: %d", p->bVal ); break; - case DBVT_WORD: mir_snprintf(boo, SIZEOF(boo), "word: %d", p->wVal ); break; - case DBVT_DWORD: mir_snprintf(boo, SIZEOF(boo), "dword: %d", p->dVal ); break; - case DBVT_UTF8: - case DBVT_ASCIIZ: mir_snprintf(boo, SIZEOF(boo), "string: '%s'", p->pszVal); break; - case DBVT_DELETED: strcpy(boo, "deleted"); break; - default: mir_snprintf(boo, SIZEOF(boo), "crap: %d", p->type ); break; + case DBVT_BYTE: mir_snprintf(boo, SIZEOF(boo), "byte: %d", p->bVal ); break; + case DBVT_WORD: mir_snprintf(boo, SIZEOF(boo), "word: %d", p->wVal ); break; + case DBVT_DWORD: mir_snprintf(boo, SIZEOF(boo), "dword: %d", p->dVal ); break; + case DBVT_UTF8: + case DBVT_ASCIIZ: mir_snprintf(boo, SIZEOF(boo), "string: '%s'", p->pszVal); break; + case DBVT_DELETED: strcpy(boo, "deleted"); break; + default: mir_snprintf(boo, SIZEOF(boo), "crap: %d", p->type ); break; } return boo; } diff --git a/plugins/Db3x_mmap/src/database.h b/plugins/Db3x_mmap/src/database.h index 00bad441cd..a0f3132aa2 100644 --- a/plugins/Db3x_mmap/src/database.h +++ b/plugins/Db3x_mmap/src/database.h @@ -29,22 +29,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* tree diagram DBHeader - |-->end of file (plain offset) - |-->first contact (DBContact) - | |-->next contact (DBContact) - | | \--> ... - | |-->first settings (DBContactSettings) - | | |-->next settings (DBContactSettings) - | | | \--> ... - | | \-->module name (DBModuleName) - | \-->first/last/firstunread event - |-->user contact (DBContact) - | |-->next contact = NULL - | |-->first settings as above - | \-->first/last/firstunread event as above - \-->first module name (DBModuleName) - \-->next module name (DBModuleName) - \--> ... +|-->end of file (plain offset) +|-->first contact (DBContact) +| |-->next contact (DBContact) +| | \--> ... +| |-->first settings (DBContactSettings) +| | |-->next settings (DBContactSettings) +| | | \--> ... +| | \-->module name (DBModuleName) +| \-->first/last/firstunread event +|-->user contact (DBContact) +| |-->next contact = NULL +| |-->first settings as above +| \-->first/last/firstunread event as above +\-->first module name (DBModuleName) +\-->next module name (DBModuleName) +\--> ... */ //#define DBLOGGING diff --git a/plugins/Db3x_mmap/src/dbcache.cpp b/plugins/Db3x_mmap/src/dbcache.cpp index 078c7f5f70..d842576762 100644 --- a/plugins/Db3x_mmap/src/dbcache.cpp +++ b/plugins/Db3x_mmap/src/dbcache.cpp @@ -87,7 +87,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 CDb3Mmap::DBRead(DWORD ofs, int *bytesAvail) { // buggy read if (ofs >= m_dwFileSize) { @@ -106,9 +106,9 @@ PBYTE CDb3Mmap::DBRead(DWORD ofs, int bytesRequired, int *bytesAvail) 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); - memmove(m_pDbCache+ofs,pData,bytes); + if (ofs + bytes > m_dwFileSize) + ReMap(ofs + bytes - m_dwFileSize); + memmove(m_pDbCache + ofs, pData, bytes); logg(); } @@ -121,7 +121,7 @@ void CDb3Mmap::DBFill(DWORD ofs, int bytes) logg(); } -static VOID CALLBACK DoBufferFlushTimerProc(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime) +static VOID CALLBACK DoBufferFlushTimerProc(HWND, UINT, UINT_PTR idEvent, DWORD) { for (int i = 0; i < g_Dbs.getCount(); i++) { CDb3Mmap *db = g_Dbs[i]; @@ -182,11 +182,11 @@ int CDb3Mmap::InitMap(void) return 0; } -DWORD CDb3Mmap::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsContact, DWORD ofsModuleName) +DWORD CDb3Mmap::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsModuleName) { DWORD ofsThis = dbc->ofsFirstSettings; while (ofsThis) { - DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis, sizeof(DBContactSettings), NULL); + DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis, NULL); if (dbcs->signature != DBCONTACTSETTINGS_SIGNATURE) DatabaseCorruption(NULL); if (dbcs->ofsModuleName == ofsModuleName) return ofsThis; diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 9d65790c8c..f2ed1da4f1 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -84,7 +84,7 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(MCONTACT contactID) mir_cslockfull lck(m_csDbAccess); DWORD ofsContact = GetContactOffset(contactID); - DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return 1; @@ -106,7 +106,7 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(MCONTACT contactID) DWORD ofsThis = dbc->ofsFirstSettings; DWORD ofsFirstEvent = dbc->ofsFirstEvent; while (ofsThis) { - DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis, sizeof(DBContactSettings), NULL); + DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis, NULL); DWORD ofsNext = dbcs->ofsNext; DeleteSpace(ofsThis, offsetof(DBContactSettings, blob) + dbcs->cbBlob); ofsThis = ofsNext; @@ -115,7 +115,7 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(MCONTACT contactID) // delete event chain ofsThis = ofsFirstEvent; while (ofsThis) { - DBEvent *dbe = (DBEvent*)DBRead(ofsThis, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead(ofsThis, NULL); DWORD ofsNext = dbe->ofsNext; DeleteSpace(ofsThis, offsetof(DBEvent, blob) + dbe->cbBlob); ofsThis = ofsNext; @@ -129,11 +129,11 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(MCONTACT contactID) else { DWORD ofsNext = dbc->ofsNext; ofsThis = m_dbHeader.ofsFirstContact; - DBContact *dbcPrev = (DBContact*)DBRead(ofsThis, sizeof(DBContact), NULL); + DBContact *dbcPrev = (DBContact*)DBRead(ofsThis, NULL); while (dbcPrev->ofsNext != ofsContact) { if (dbcPrev->ofsNext == 0) DatabaseCorruption(NULL); ofsThis = dbcPrev->ofsNext; - dbcPrev = (DBContact*)DBRead(ofsThis, sizeof(DBContact), NULL); + dbcPrev = (DBContact*)DBRead(ofsThis, NULL); } dbcPrev->ofsNext = ofsNext; DBWrite(ofsThis, dbcPrev, sizeof(DBContact)); @@ -188,7 +188,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::IsDbContact(MCONTACT contactID) return FALSE; mir_cslock lck(m_csDbAccess); - DBContact *dbc = (DBContact*)DBRead(cc->dwDriverData, sizeof(DBContact), NULL); + DBContact *dbc = (DBContact*)DBRead(cc->dwDriverData, NULL); if (dbc->signature == DBCONTACT_SIGNATURE) { m_cache->AddContactToCache(contactID); return TRUE; @@ -219,8 +219,8 @@ static int SortEvent(const DBEvent *p1, const DBEvent *p2) BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) { mir_cslock lck(m_csDbAccess); - DBContact *dbMeta = (DBContact*)DBRead(ccMeta->dwDriverData, sizeof(DBContact), NULL); - DBContact *dbSub = (DBContact*)DBRead(ccSub->dwDriverData, sizeof(DBContact), NULL); + DBContact *dbMeta = (DBContact*)DBRead(ccMeta->dwDriverData, NULL); + DBContact *dbSub = (DBContact*)DBRead(ccSub->dwDriverData, NULL); if (dbMeta->signature != DBCONTACT_SIGNATURE || dbSub->signature != DBCONTACT_SIGNATURE) return 1; @@ -242,7 +242,7 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) // there're events in both meta's & sub's event chains // relink sub's event chain to meta without changing events themselves for (DWORD ofsMeta = dbMeta->ofsFirstEvent; ofsMeta != 0;) { - DBEvent *pev = (DBEvent*)DBRead(ofsMeta, sizeof(DBEvent), NULL); + DBEvent *pev = (DBEvent*)DBRead(ofsMeta, NULL); if (pev->signature != DBEVENT_SIGNATURE) { // broken chain, don't touch it ret = 2; __leave; @@ -253,7 +253,7 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) } for (DWORD ofsSub = dbSub->ofsFirstEvent; ofsSub != 0;) { - DBEvent *pev = (DBEvent*)DBRead(ofsSub, sizeof(DBEvent), NULL); + DBEvent *pev = (DBEvent*)DBRead(ofsSub, NULL); if (pev->signature != DBEVENT_SIGNATURE) { // broken chain, don't touch it ret = 2; __leave; @@ -303,8 +303,8 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) { mir_cslock lck(m_csDbAccess); - DBContact dbMeta = *(DBContact*)DBRead(ccMeta->dwDriverData, sizeof(DBContact), NULL); - DBContact dbSub = *(DBContact*)DBRead(ccSub->dwDriverData, sizeof(DBContact), NULL); + DBContact dbMeta = *(DBContact*)DBRead(ccMeta->dwDriverData, NULL); + DBContact dbSub = *(DBContact*)DBRead(ccSub->dwDriverData, NULL); if (dbMeta.signature != DBCONTACT_SIGNATURE || dbSub.signature != DBCONTACT_SIGNATURE) return 1; @@ -314,14 +314,14 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) BOOL ret = 0; __try { if (ret = WipeContactHistory(&dbSub)) - __leave; + __leave; DWORD dwOffset = dbMeta.ofsFirstEvent; DBEvent *evMeta = NULL, *evSub = NULL; dbMeta.eventCount = 0; dbMeta.ofsFirstEvent = dbMeta.ofsLastEvent = dbMeta.ofsFirstUnread = dbMeta.tsFirstUnread = 0; while (dwOffset != 0) { - DBEvent *evCurr = (DBEvent*)DBRead(dwOffset, sizeof(DBEvent), NULL); + DBEvent *evCurr = (DBEvent*)DBRead(dwOffset, NULL); if (evCurr->signature != DBEVENT_SIGNATURE) break; @@ -396,7 +396,7 @@ void CDb3Mmap::FillContacts() OBJLIST arMetas(10, NumericKeySortT); for (DWORD dwOffset = m_dbHeader.ofsFirstContact; dwOffset != 0;) { - DBContact *p = (DBContact*)DBRead(dwOffset, sizeof(DBContact), NULL); + DBContact *p = (DBContact*)DBRead(dwOffset, NULL); if (p->signature != DBCONTACT_SIGNATURE) break; @@ -476,7 +476,7 @@ void CDb3Mmap::FillContacts() // we don't need it anymore if (!GetContactSetting(hContact, META_PROTO, "MetaID", &dbv)) { DeleteContactSetting(hContact, META_PROTO, "MetaID"); - WipeContactHistory((DBContact*)DBRead(ccMeta->dwDriverData, sizeof(DBContact), NULL)); + WipeContactHistory((DBContact*)DBRead(ccMeta->dwDriverData, NULL)); } for (int k = 0; k < ccMeta->nSubs; k++) { diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 7e0b18cff9..30d74f06a3 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -44,18 +44,18 @@ struct VarDescr VarDescr(LPCSTR var, LPCSTR value) : szVar(mir_strdup(var)), szValue(mir_strdup(value)) - {} + {} VarDescr(LPCSTR var, LPSTR value) : szVar(mir_strdup(var)), szValue(value) - {} + {} VarDescr(LPCSTR var, PBYTE value, int len) : szVar(mir_strdup(var)), szValue((char*)memcpy(mir_alloc(len), value, len)), iLen(len) - {} + {} ptrA szVar, szValue; int iLen; @@ -137,7 +137,7 @@ int CDb3Mmap::InitCrypt() DBVARIANT dbv = { 0 }; dbv.type = DBVT_BLOB; if (GetContactSetting(NULL, "CryptoEngine", "Provider", &dbv)) { -LBL_CreateProvider: + LBL_CreateProvider: CRYPTO_PROVIDER **ppProvs; int iNumProvs; Crypto_EnumProviders(&iNumProvs, &ppProvs); @@ -149,7 +149,7 @@ LBL_CreateProvider: DBCONTACTWRITESETTING dbcws = { "CryptoEngine", "Provider" }; dbcws.value.type = DBVT_BLOB; dbcws.value.pbVal = (PBYTE)pProvider->pszName; - dbcws.value.cpbVal = (int)strlen(pProvider->pszName)+1; + dbcws.value.cpbVal = (int)strlen(pProvider->pszName) + 1; WriteContactSetting(NULL, &dbcws); } else { @@ -171,9 +171,9 @@ LBL_CreateProvider: if (GetContactSetting(NULL, "CryptoEngine", "StoredKey", &dbv)) { bMissingKey = true; -LBL_SetNewKey: + LBL_SetNewKey: m_crypto->generateKey(); // unencrypted key - StoreKey(); + StoreKey(); } else { size_t iKeyLength = m_crypto->getKeyLength(); @@ -274,12 +274,12 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) if (ofsContact == 0) return; - DBContact *contact = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact *contact = (DBContact*)DBRead(ofsContact, NULL); if (contact->ofsFirstSettings == 0) return; // fast cycle through all settings - DBContactSettings *setting = (DBContactSettings*)DBRead(contact->ofsFirstSettings, sizeof(DBContactSettings), NULL); + DBContactSettings *setting = (DBContactSettings*)DBRead(contact->ofsFirstSettings, NULL); DWORD offset = contact->ofsFirstSettings; char *szModule = GetModuleNameByOfs(setting->ofsModuleName); if (szModule == NULL) @@ -290,7 +290,7 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) char szSetting[256]; int bytesRemaining, len; DWORD ofsBlobPtr = offset + offsetof(DBContactSettings, blob), ofsNext = setting->ofsNext; - PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, 1, &bytesRemaining); + PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); while (pBlob[0]) { NeedBytes(1); len = pBlob[0]; @@ -301,11 +301,11 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) switch (pBlob[0]) { case DBVT_ASCIIZ: - len = *(PWORD)(pBlob+1); + len = *(PWORD)(pBlob + 1); // we need to convert a string into utf8 and encrypt it if (!m_bEncrypted) { BYTE bSave = pBlob[len + 3]; pBlob[len + 3] = 0; - arSettings.insert(new VarDescr(szSetting, mir_utf8encode((LPCSTR)pBlob+3))); + arSettings.insert(new VarDescr(szSetting, mir_utf8encode((LPCSTR)pBlob + 3))); pBlob[len + 3] = bSave; } NeedBytes(3 + len); @@ -370,7 +370,7 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) if (!ofsNext) break; - setting = (DBContactSettings*)DBRead(offset = ofsNext, sizeof(DBContactSettings), NULL); + setting = (DBContactSettings*)DBRead(offset = ofsNext, NULL); if ((szModule = GetModuleNameByOfs(setting->ofsModuleName)) == NULL) break; } @@ -382,33 +382,33 @@ void CDb3Mmap::ToggleEventsEncryption(MCONTACT contactID) if (ofsContact == 0) return; - DBContact contact = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact contact = *(DBContact*)DBRead(ofsContact, NULL); if (contact.ofsFirstEvent == 0 || contact.signature != DBCONTACT_SIGNATURE) return; // fast cycle through all events for (DWORD offset = contact.ofsFirstEvent; offset != 0;) { - DBEvent evt = *(DBEvent*)DBRead(offset, offsetof(DBEvent, blob), NULL); + DBEvent evt = *(DBEvent*)DBRead(offset, NULL); if (evt.signature != DBEVENT_SIGNATURE) return; size_t len; DWORD ofsDest; mir_ptr pBlob; - BYTE *pSource = DBRead(offset + offsetof(DBEvent, blob), evt.cbBlob, 0); + BYTE *pSource = DBRead(offset + offsetof(DBEvent, blob), 0); if (!m_bEncrypted) { // we need more space if ((pBlob = m_crypto->encodeBuffer(pSource, evt.cbBlob, &len)) == NULL) return; - + ofsDest = ReallocSpace(offset, offsetof(DBEvent, blob) + evt.cbBlob, offsetof(DBEvent, blob) + (DWORD)len); if (evt.ofsNext) { - DBEvent *e = (DBEvent*)DBRead(evt.ofsNext, sizeof(DBEvent), NULL); + DBEvent *e = (DBEvent*)DBRead(evt.ofsNext, NULL); e->ofsPrev = ofsDest; DBWrite(evt.ofsNext, e, sizeof(DBEvent)); } if (evt.ofsPrev) { - DBEvent *e = (DBEvent*)DBRead(evt.ofsPrev, sizeof(DBEvent), NULL); + DBEvent *e = (DBEvent*)DBRead(evt.ofsPrev, NULL); e->ofsNext = ofsDest; DBWrite(evt.ofsPrev, e, sizeof(DBEvent)); } diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index ad94419aec..0283a93c45 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -28,7 +28,7 @@ static HANDLE hEventDeletedEvent, hEventAddedEvent, hEventFilterAddedEvent; STDMETHODIMP_(LONG) CDb3Mmap::GetEventCount(MCONTACT contactID) { mir_cslock lck(m_csDbAccess); - DBContact *dbc = (DBContact*)DBRead(GetContactOffset(contactID), sizeof(DBContact), NULL); + DBContact *dbc = (DBContact*)DBRead(GetContactOffset(contactID), NULL); return (dbc->signature != DBCONTACT_SIGNATURE) ? -1 : dbc->eventCount; } @@ -82,7 +82,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) mir_cslockfull lck(m_csDbAccess); DWORD ofsContact = GetContactOffset(contactID); - DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL); if (dbc.signature != DBCONTACT_SIGNATURE) return NULL; @@ -95,20 +95,20 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) dbc.ofsFirstEvent = dbc.ofsLastEvent = ofsNew; } else { - DBEvent *dbeTest = (DBEvent*)DBRead(dbc.ofsFirstEvent, sizeof(DBEvent), NULL); + DBEvent *dbeTest = (DBEvent*)DBRead(dbc.ofsFirstEvent, NULL); // Should new event be placed before first event in chain? if (dbe.timestamp < dbeTest->timestamp) { dbe.ofsPrev = 0; dbe.ofsNext = dbc.ofsFirstEvent; dbc.ofsFirstEvent = ofsNew; - dbeTest = (DBEvent*)DBRead(dbe.ofsNext, sizeof(DBEvent), NULL); + dbeTest = (DBEvent*)DBRead(dbe.ofsNext, NULL); dbeTest->ofsPrev = ofsNew; DBWrite(dbe.ofsNext, dbeTest, sizeof(DBEvent)); } else { // Loop through the chain, starting at the end DWORD ofsThis = dbc.ofsLastEvent; - dbeTest = (DBEvent*)DBRead(ofsThis, sizeof(DBEvent), NULL); + dbeTest = (DBEvent*)DBRead(ofsThis, NULL); for (;;) { // If the new event's timesstamp is equal to or greater than the // current dbevent, it will be inserted after. If not, continue @@ -121,14 +121,14 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) if (dbe.ofsNext == 0) dbc.ofsLastEvent = ofsNew; else { - dbeTest = (DBEvent*)DBRead(dbe.ofsNext, sizeof(DBEvent), NULL); + dbeTest = (DBEvent*)DBRead(dbe.ofsNext, NULL); dbeTest->ofsPrev = ofsNew; DBWrite(dbe.ofsNext, dbeTest, sizeof(DBEvent)); } break; } ofsThis = dbeTest->ofsPrev; - dbeTest = (DBEvent*)DBRead(ofsThis, sizeof(DBEvent), NULL); + dbeTest = (DBEvent*)DBRead(ofsThis, NULL); } } } @@ -144,7 +144,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) else neednotify = m_safetyMode; if (ccSub != NULL) { - DBContact *pSub = (DBContact*)DBRead(ccSub->dwDriverData, sizeof(DBContact), NULL); + DBContact *pSub = (DBContact*)DBRead(ccSub->dwDriverData, NULL); pSub->eventCount++; } @@ -177,8 +177,8 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) mir_cslockfull lck(m_csDbAccess); DWORD ofsContact = (cc) ? cc->dwDriverData : m_dbHeader.ofsUser; - DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); - DBEvent dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL); + DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL); + DBEvent dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, NULL); if (dbc.signature != DBCONTACT_SIGNATURE || dbe.signature != DBEVENT_SIGNATURE) return 1; @@ -190,8 +190,8 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) // get back in lck.lock(); - dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); - dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL); + dbc = *(DBContact*)DBRead(ofsContact, NULL); + dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, NULL); // check if this was the first unread, if so, recalc the first unread if (dbc.ofsFirstUnread == (DWORD)hDbEvent) { @@ -202,7 +202,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) break; } DWORD ofsThis = dbeNext->ofsNext; - dbeNext = (DBEvent*)DBRead(ofsThis, sizeof(DBEvent), NULL); + dbeNext = (DBEvent*)DBRead(ofsThis, NULL); if (!dbeNext->markedRead()) { dbc.ofsFirstUnread = ofsThis; dbc.tsFirstUnread = dbeNext->timestamp; @@ -216,7 +216,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) if (dbe.ofsNext == 0) dbc.ofsFirstEvent = dbc.ofsLastEvent = 0; else { - DBEvent *dbeNext = (DBEvent*)DBRead(dbe.ofsNext, sizeof(DBEvent), NULL); + DBEvent *dbeNext = (DBEvent*)DBRead(dbe.ofsNext, NULL); dbeNext->ofsPrev = 0; DBWrite(dbe.ofsNext, dbeNext, sizeof(DBEvent)); dbc.ofsFirstEvent = dbe.ofsNext; @@ -224,17 +224,17 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) } else { if (dbe.ofsNext == 0) { - DBEvent *dbePrev = (DBEvent*)DBRead(dbe.ofsPrev, sizeof(DBEvent), NULL); + DBEvent *dbePrev = (DBEvent*)DBRead(dbe.ofsPrev, NULL); dbePrev->ofsNext = 0; DBWrite(dbe.ofsPrev, dbePrev, sizeof(DBEvent)); dbc.ofsLastEvent = dbe.ofsPrev; } else { - DBEvent *dbePrev = (DBEvent*)DBRead(dbe.ofsPrev, sizeof(DBEvent), NULL); + DBEvent *dbePrev = (DBEvent*)DBRead(dbe.ofsPrev, NULL); dbePrev->ofsNext = dbe.ofsNext; DBWrite(dbe.ofsPrev, dbePrev, sizeof(DBEvent)); - DBEvent *dbeNext = (DBEvent*)DBRead(dbe.ofsNext, sizeof(DBEvent), NULL); + DBEvent *dbeNext = (DBEvent*)DBRead(dbe.ofsNext, NULL); dbeNext->ofsPrev = dbe.ofsPrev; DBWrite(dbe.ofsNext, dbeNext, sizeof(DBEvent)); } @@ -249,7 +249,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) // also update a sub if (cc && dbe.contactID != cc->contactID) { - DBContact *pSub = (DBContact*)DBRead(GetContactOffset(dbe.contactID), sizeof(DBContact), NULL); + DBContact *pSub = (DBContact*)DBRead(GetContactOffset(dbe.contactID), NULL); if (pSub->eventCount > 0) pSub->eventCount--; } @@ -261,7 +261,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent) STDMETHODIMP_(LONG) CDb3Mmap::GetBlobSize(HANDLE hDbEvent) { mir_cslock lck(m_csDbAccess); - DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, NULL); return (dbe->signature != DBEVENT_SIGNATURE) ? -1 : dbe->cbBlob; } @@ -274,7 +274,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei) } mir_cslock lck(m_csDbAccess); - DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, NULL); if (dbe->signature != DBEVENT_SIGNATURE) return 1; @@ -285,7 +285,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei) int bytesToCopy = (dbei->cbBlob < dbe->cbBlob) ? dbei->cbBlob : dbe->cbBlob; dbei->cbBlob = dbe->cbBlob; if (bytesToCopy && dbei->pBlob) { - BYTE *pSrc = DBRead(DWORD(hDbEvent) + offsetof(DBEvent, blob), bytesToCopy, NULL); + BYTE *pSrc = DBRead(DWORD(hDbEvent) + offsetof(DBEvent, blob), NULL); if (dbe->flags & DBEF_ENCRYPTED) { dbei->flags &= ~DBEF_ENCRYPTED; size_t len; @@ -317,8 +317,8 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent) mir_cslockfull lck(m_csDbAccess); DWORD ofsContact = (cc) ? cc->dwDriverData : m_dbHeader.ofsUser; - DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); - DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL); + DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL); + DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, NULL); if (dbe->signature != DBEVENT_SIGNATURE || dbc.signature != DBCONTACT_SIGNATURE) return -1; @@ -337,7 +337,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent) break; } DWORD ofsThis = dbe->ofsNext; - dbe = (DBEvent*)DBRead(ofsThis, sizeof(DBEvent), NULL); + dbe = (DBEvent*)DBRead(ofsThis, NULL); if (!dbe->markedRead()) { dbc.ofsFirstUnread = ofsThis; dbc.tsFirstUnread = dbe->timestamp; @@ -347,7 +347,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent) } DBWrite(ofsContact, &dbc, sizeof(DBContact)); DBFlush(0); - + lck.unlock(); NotifyEventHooks(hEventMarkedRead, contactID, (LPARAM)hDbEvent); return ret; @@ -356,7 +356,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent) STDMETHODIMP_(MCONTACT) CDb3Mmap::GetEventContact(HANDLE hDbEvent) { mir_cslock lck(m_csDbAccess); - DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, NULL); return (dbe->signature != DBEVENT_SIGNATURE) ? INVALID_CONTACT_ID : dbe->contactID; } @@ -366,7 +366,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstEvent(MCONTACT contactID) DWORD ofsContact = GetContactOffset(contactID, &cc); mir_cslock lck(m_csDbAccess); - DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return NULL; if (!cc || !cc->IsSub()) @@ -374,12 +374,12 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL) return NULL; - dbc = (DBContact*)DBRead(cc->dwDriverData, sizeof(DBContact), NULL); + dbc = (DBContact*)DBRead(cc->dwDriverData, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return NULL; for (DWORD dwOffset = dbc->ofsFirstEvent; dwOffset != 0;) { - DBEvent *dbe = (DBEvent*)DBRead(dwOffset, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead(dwOffset, NULL); if (dbe->signature != DBEVENT_SIGNATURE) return NULL; if (dbe->contactID == contactID) @@ -395,7 +395,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID) DWORD ofsContact = GetContactOffset(contactID, &cc); mir_cslock lck(m_csDbAccess); - DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return NULL; if (!cc || !cc->IsSub()) @@ -403,12 +403,12 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL) return NULL; - dbc = (DBContact*)DBRead(cc->dwDriverData, sizeof(DBContact), NULL); + dbc = (DBContact*)DBRead(cc->dwDriverData, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return NULL; for (DWORD dwOffset = dbc->ofsFirstUnread; dwOffset != 0;) { - DBEvent *dbe = (DBEvent*)DBRead(dwOffset, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead(dwOffset, NULL); if (dbe->signature != DBEVENT_SIGNATURE) return NULL; if (dbe->contactID == contactID && !dbe->markedRead()) @@ -424,7 +424,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindLastEvent(MCONTACT contactID) DWORD ofsContact = GetContactOffset(contactID, &cc); mir_cslock lck(m_csDbAccess); - DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return NULL; if (!cc || !cc->IsSub()) @@ -432,12 +432,12 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindLastEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL) return NULL; - dbc = (DBContact*)DBRead(cc->dwDriverData, sizeof(DBContact), NULL); + dbc = (DBContact*)DBRead(cc->dwDriverData, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return NULL; for (DWORD dwOffset = dbc->ofsLastEvent; dwOffset != 0;) { - DBEvent *dbe = (DBEvent*)DBRead(dwOffset, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead(dwOffset, NULL); if (dbe->signature != DBEVENT_SIGNATURE) return NULL; if (dbe->contactID == contactID) @@ -452,14 +452,14 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindNextEvent(MCONTACT contactID, HANDLE hDbEven DBCachedContact *cc = (contactID) ? m_cache->GetCachedContact(contactID) : NULL; mir_cslock lck(m_csDbAccess); - DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, NULL); if (dbe->signature != DBEVENT_SIGNATURE) return NULL; if (!cc || !cc->IsSub()) return HANDLE(dbe->ofsNext); for (DWORD dwOffset = dbe->ofsNext; dwOffset != 0;) { - dbe = (DBEvent*)DBRead(dwOffset, sizeof(DBEvent), NULL); + dbe = (DBEvent*)DBRead(dwOffset, NULL); if (dbe->signature != DBEVENT_SIGNATURE) return NULL; if (dbe->contactID == contactID) @@ -474,14 +474,14 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::FindPrevEvent(MCONTACT contactID, HANDLE hDbEven DBCachedContact *cc = (contactID) ? m_cache->GetCachedContact(contactID) : NULL; mir_cslock lck(m_csDbAccess); - DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL); + DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, NULL); if (dbe->signature != DBEVENT_SIGNATURE) return NULL; if (!cc || !cc->IsSub()) return HANDLE(dbe->ofsPrev); for (DWORD dwOffset = dbe->ofsPrev; dwOffset != 0;) { - dbe = (DBEvent*)DBRead(dwOffset, sizeof(DBEvent), NULL); + dbe = (DBEvent*)DBRead(dwOffset, NULL); if (dbe->signature != DBEVENT_SIGNATURE) return NULL; if (dbe->contactID == contactID) @@ -498,7 +498,7 @@ int CDb3Mmap::WipeContactHistory(DBContact *dbc) { // drop subContact's history if any for (DWORD dwOffset = dbc->ofsFirstEvent; dwOffset != 0;) { - DBEvent *pev = (DBEvent*)DBRead(dwOffset, sizeof(DBEvent), NULL); + DBEvent *pev = (DBEvent*)DBRead(dwOffset, NULL); if (pev->signature != DBEVENT_SIGNATURE) // broken chain, don't touch it return 2; diff --git a/plugins/Db3x_mmap/src/dbheaders.cpp b/plugins/Db3x_mmap/src/dbheaders.cpp index f8df60e84d..ac84431b39 100644 --- a/plugins/Db3x_mmap/src/dbheaders.cpp +++ b/plugins/Db3x_mmap/src/dbheaders.cpp @@ -36,7 +36,7 @@ int CDb3Mmap::CreateDbHeaders(const DBSignature& _sign) m_dbHeader.ofsFirstContact = 0; m_dbHeader.ofsModuleNames = 0; m_dbHeader.ofsUser = 0; - + // create user m_dbHeader.ofsUser = m_dbHeader.ofsFileEnd; m_dbHeader.ofsFileEnd += sizeof(DBContact); @@ -55,16 +55,16 @@ int CDb3Mmap::CreateDbHeaders(const DBSignature& _sign) ///////////////////////////////////////////////////////////////////////////////////////// -static TCHAR tszOldHeaders[] = - LPGENT("This profile is too old to be updated with PluginUpdater, your database must be converted first.\n\nWould you like to read how to fix this?"); +static TCHAR tszOldHeaders[] = +LPGENT("This profile is too old to be updated with PluginUpdater, your database must be converted first.\n\nWould you like to read how to fix this?"); int CDb3Mmap::CheckDbHeaders(bool bInteractive) { if (memcmp(m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) && - memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature))) + memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature))) { if (!memcmp(&m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)) || - !memcmp(&m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature))) + !memcmp(&m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature))) return EGROKPRF_OBSOLETE; if (!memcmp(&m_dbHeader.signature, &dbSignatureSD, sizeof(m_dbHeader.signature))) { @@ -102,7 +102,7 @@ int CDb3Mmap::CheckDbHeaders(bool bInteractive) default: return EGROKPRF_VERNEWER; } - + if (m_dbHeader.ofsUser == 0) return EGROKPRF_DAMAGED; diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp index 96fee79626..ef2106f5cb 100644 --- a/plugins/Db3x_mmap/src/dbintf.cpp +++ b/plugins/Db3x_mmap/src/dbintf.cpp @@ -45,14 +45,14 @@ static int stringCompare2(const char *p1, const char *p2) } CDb3Mmap::CDb3Mmap(const TCHAR *tszFileName, int iMode) : - m_hDbFile(INVALID_HANDLE_VALUE), - m_safetyMode(true), - m_bReadOnly((iMode & DBMODE_READONLY) != 0), - m_bShared((iMode & DBMODE_SHARED) != 0), - m_dwMaxContactId(1), - m_lMods(50, ModCompare), - m_lOfs(50, OfsCompare), - m_lResidentSettings(50, stringCompare2) +m_hDbFile(INVALID_HANDLE_VALUE), +m_safetyMode(true), +m_bReadOnly((iMode & DBMODE_READONLY) != 0), +m_bShared((iMode & DBMODE_SHARED) != 0), +m_dwMaxContactId(1), +m_lMods(50, ModCompare), +m_lOfs(50, OfsCompare), +m_lResidentSettings(50, stringCompare2) { m_tszProfileName = mir_tstrdup(tszFileName); InitDbInstance(this); @@ -194,7 +194,7 @@ int CDb3Mmap::PrepareCheck(int *error) STDMETHODIMP_(void) CDb3Mmap::SetCacheSafetyMode(BOOL bIsSet) { { mir_cslock lck(m_csDbAccess); - m_safetyMode = bIsSet != 0; + m_safetyMode = bIsSet != 0; } DBFlush(1); } @@ -204,7 +204,7 @@ STDMETHODIMP_(void) CDb3Mmap::SetCacheSafetyMode(BOOL bIsSet) typedef int (CDb3Mmap::*CheckWorker)(int); -static CheckWorker Workers[6] = +static CheckWorker Workers[6] = { &CDb3Mmap::WorkInitialChecks, &CDb3Mmap::WorkModuleChain, diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 700fc465b0..fc75cc2c31 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -26,22 +26,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* tree diagram DBHeader - |-->end of file (plain offset) - |-->first contact (DBContact) - | |-->next contact (DBContact) - | | \--> ... - | |-->first settings (DBContactSettings) - | | |-->next settings (DBContactSettings) - | | | \--> ... - | | \-->module name (DBModuleName) - | \-->first/last/firstunread event - |-->user contact (DBContact) - | |-->next contact = NULL - | |-->first settings as above - | \-->first/last/firstunread event as above - \-->first module name (DBModuleName) - \-->next module name (DBModuleName) - \--> ... +|-->end of file (plain offset) +|-->first contact (DBContact) +| |-->next contact (DBContact) +| | \--> ... +| |-->first settings (DBContactSettings) +| | |-->next settings (DBContactSettings) +| | | \--> ... +| | \-->module name (DBModuleName) +| \-->first/last/firstunread event +|-->user contact (DBContact) +| |-->next contact = NULL +| |-->first settings as above +| \-->first/last/firstunread event as above +\-->first module name (DBModuleName) +\-->next module name (DBModuleName) +\--> ... */ #define DBMODE_SHARED 0x0001 @@ -62,7 +62,7 @@ DBHeader #define MARKED_READ (DBEF_READ | DBEF_SENT) -#define NeedBytes(n) if (bytesRemaining<(n)) pBlob = (PBYTE)DBRead(ofsBlobPtr,(n),&bytesRemaining) +#define NeedBytes(n) if (bytesRemaining<(n)) pBlob = (PBYTE)DBRead(ofsBlobPtr,&bytesRemaining) #define MoveAlong(n) {int x = n; pBlob += (x); ofsBlobPtr += (x); bytesRemaining -= (x);} DWORD __forceinline GetSettingValueLength(PBYTE pSetting) @@ -91,9 +91,9 @@ struct DBHeader DWORD version; // as 4 bytes, ie 1.2.3.10 = 0x0102030a DWORD ofsFileEnd; // offset of the end of the database - place to write new structures DWORD slackSpace; // a counter of the number of bytes that have been - // wasted so far due to deleting structures and/or - // re-making them at the end. We should compact when - // this gets above a threshold + // wasted so far due to deleting structures and/or + // re-making them at the end. We should compact when + // this gets above a threshold DWORD contactCount; // number of contacts in the chain,excluding the user DWORD ofsFirstContact; // offset to first DBContact in the chain DWORD ofsUser; // offset to DBContact representing the user @@ -105,11 +105,11 @@ struct DBContact { DWORD signature; DWORD ofsNext; // offset to the next contact in the chain. zero if - // this is the 'user' contact or the last contact in the chain + // this is the 'user' contact or the last contact in the chain DWORD ofsFirstSettings; // offset to the first DBContactSettings in the chain for this contact. DWORD eventCount; // number of events in the chain for this contact DWORD ofsFirstEvent, // offsets to the first and - ofsLastEvent; // last DBEvent in the chain for this contact + ofsLastEvent; // last DBEvent in the chain for this contact DWORD ofsFirstUnread; // offset to the first (chronological) unread event in the chain, 0 if all are read DWORD tsFirstUnread; // timestamp of the event at ofsFirstUnread DWORD dwContactID; @@ -131,10 +131,10 @@ struct DBContactSettings DWORD ofsNext; // offset to the next contactsettings in the chain DWORD ofsModuleName; // offset to the DBModuleName of the owner of these settings DWORD cbBlob; // size of the blob in bytes. May be larger than the - // actual size for reducing the number of moves - // required using granularity in resizing + // actual size for reducing the number of moves + // required using granularity in resizing BYTE blob[1]; // the blob. a back-to-back sequence of DBSetting - // structs, the last has cbName = 0 + // structs, the last has cbName = 0 }; #define DBEVENT_SIGNATURE 0x45DECADEu @@ -157,9 +157,9 @@ struct DBEvent DWORD signature; MCONTACT contactID; // a contact this event belongs to DWORD ofsPrev, ofsNext; // offset to the previous and next events in the - // chain. Chain is sorted chronologically + // chain. Chain is sorted chronologically DWORD ofsModuleName; // offset to a DBModuleName struct of the name of - // the owner of this event + // the owner of this event DWORD timestamp; // seconds since 00:00:00 01/01/1970 DWORD flags; // see m_database.h, db/event/add WORD wEventType; // module-defined event type @@ -167,7 +167,8 @@ struct DBEvent BYTE blob[1]; // the blob. module-defined formatting bool __forceinline markedRead() const - { return (flags & MARKED_READ) != 0; + { + return (flags & MARKED_READ) != 0; } }; @@ -246,12 +247,12 @@ protected: STDMETHODIMP_(VOID) Destroy(); protected: - DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsContact, DWORD ofsModuleName); - void InvalidateSettingsGroupOfsCacheEntry(DWORD ofsSettingsGroup) {} + DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsModuleName); + void InvalidateSettingsGroupOfsCacheEntry(DWORD) {} int WorkInitialCheckHeaders(void); void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes); - PBYTE DBRead(DWORD ofs, int bytesRequired, int *bytesAvail); + PBYTE DBRead(DWORD ofs, int *bytesAvail); void DBWrite(DWORD ofs, PVOID pData, int bytes); void DBFill(DWORD ofs, int bytes); void DBFlush(int setting); @@ -308,7 +309,7 @@ protected: //////////////////////////////////////////////////////////////////////////// // contacts - + int WipeContactHistory(DBContact *dbc); //////////////////////////////////////////////////////////////////////////// @@ -321,7 +322,7 @@ protected: MCONTACT m_hLastCachedContact; ModuleName *m_lastmn; - void AddToList(char *name, DWORD len, DWORD ofs); + void AddToList(char *name, DWORD ofs); DWORD FindExistingModuleNameOfs(const char *szName); int InitModuleNames(void); DWORD GetModuleNameOfs(const char *szName); @@ -340,7 +341,7 @@ protected: void ConvertOldEvent(DBEvent*& dbei); int GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic); - int WorkSettingsChain(DWORD ofsContact, DBContact *dbc, int firstTime); + int WorkSettingsChain(DBContact *dbc, int firstTime); int WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime); DWORD WriteSegment(DWORD ofs, PVOID buf, int cbBytes); diff --git a/plugins/Db3x_mmap/src/dbmodulechain.cpp b/plugins/Db3x_mmap/src/dbmodulechain.cpp index 603f55512b..8b2d0ec6ae 100644 --- a/plugins/Db3x_mmap/src/dbmodulechain.cpp +++ b/plugins/Db3x_mmap/src/dbmodulechain.cpp @@ -23,39 +23,39 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h" -void CDb3Mmap::AddToList(char *name, DWORD len, DWORD ofs) +void CDb3Mmap::AddToList(char *name, DWORD ofs) { - ModuleName *mn = (ModuleName*)HeapAlloc(m_hModHeap,0,sizeof(ModuleName)); + ModuleName *mn = (ModuleName*)HeapAlloc(m_hModHeap, 0, sizeof(ModuleName)); mn->name = name; mn->ofs = ofs; if (m_lMods.getIndex(mn) != -1) - DatabaseCorruption( _T("%s (Module Name not unique)")); + DatabaseCorruption(_T("%s (Module Name not unique)")); m_lMods.insert(mn); if (m_lOfs.getIndex(mn) != -1) - DatabaseCorruption( _T("%s (Module Offset not unique)")); + DatabaseCorruption(_T("%s (Module Offset not unique)")); m_lOfs.insert(mn); } int CDb3Mmap::InitModuleNames(void) { DWORD ofsThis = m_dbHeader.ofsModuleNames; - DBModuleName *dbmn = (struct DBModuleName*)DBRead(ofsThis,sizeof(struct DBModuleName),NULL); + DBModuleName *dbmn = (struct DBModuleName*)DBRead(ofsThis, NULL); while (ofsThis) { if (dbmn->signature != DBMODULENAME_SIGNATURE) DatabaseCorruption(NULL); int nameLen = dbmn->cbName; - char *mod = (char*)HeapAlloc(m_hModHeap,0,nameLen+1); - memcpy(mod,DBRead(ofsThis + offsetof(struct DBModuleName,name),nameLen,NULL),nameLen); + char *mod = (char*)HeapAlloc(m_hModHeap, 0, nameLen + 1); + memcpy(mod, DBRead(ofsThis + offsetof(struct DBModuleName, name), NULL), nameLen); mod[nameLen] = 0; - AddToList(mod, nameLen, ofsThis); + AddToList(mod, ofsThis); ofsThis = dbmn->ofsNext; - dbmn = (struct DBModuleName*)DBRead(ofsThis,sizeof(struct DBModuleName),NULL); + dbmn = (struct DBModuleName*)DBRead(ofsThis, NULL); } return 0; } @@ -103,8 +103,8 @@ DWORD CDb3Mmap::GetModuleNameOfs(const char *szName) // add to cache char *mod = (char*)HeapAlloc(m_hModHeap, 0, nameLen + 1); - strcpy(mod,szName); - AddToList(mod, nameLen, ofsNew); + strcpy(mod, szName); + AddToList(mod, ofsNew); // quit return ofsNew; @@ -115,7 +115,7 @@ char* CDb3Mmap::GetModuleNameByOfs(DWORD ofs) if (m_lastmn && m_lastmn->ofs == ofs) return m_lastmn->name; - ModuleName mn = {NULL, ofs}; + ModuleName mn = { NULL, ofs }; int index = m_lOfs.getIndex(&mn); if (index != -1) { ModuleName *pmn = m_lOfs[index]; diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 362aaa82e0..82f65d627e 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -57,7 +57,7 @@ static bool ValidLookupName(LPCSTR szModule, LPCSTR szSetting) } int CDb3Mmap::GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic) -{ +{ if (szSetting == NULL || szModule == NULL) return 1; @@ -65,15 +65,15 @@ int CDb3Mmap::GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCST int settingNameLen = (int)strlen(szSetting); int moduleNameLen = (int)strlen(szModule); if (settingNameLen > 0xFE) { - #ifdef _DEBUG - OutputDebugStringA("GetContactSettingWorker() got a > 255 setting name length. \n"); - #endif +#ifdef _DEBUG + OutputDebugStringA("GetContactSettingWorker() got a > 255 setting name length. \n"); +#endif return 1; } if (moduleNameLen > 0xFE) { - #ifdef _DEBUG - OutputDebugStringA("GetContactSettingWorker() got a > 255 module name length. \n"); - #endif +#ifdef _DEBUG + OutputDebugStringA("GetContactSettingWorker() got a > 255 module name length. \n"); +#endif return 1; } @@ -122,19 +122,19 @@ LBL_Seek: DWORD ofsModuleName = GetModuleNameOfs(szModule); - DBContact dbc = *(DBContact*)DBRead(ofsContact,sizeof(DBContact),NULL); + DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL); if (dbc.signature != DBCONTACT_SIGNATURE) return 1; - DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsContact, ofsModuleName); + DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsModuleName); if (ofsSettingsGroup) { int bytesRemaining; unsigned varLen; DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); - PBYTE pBlob = DBRead(ofsBlobPtr, sizeof(DBContactSettings), &bytesRemaining); + PBYTE pBlob = DBRead(ofsBlobPtr, &bytesRemaining); while (pBlob[0]) { - NeedBytes(1+settingNameLen); - if (pBlob[0] == settingNameLen && !memcmp(pBlob+1,szSetting,settingNameLen)) { + NeedBytes(1 + settingNameLen); + if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, szSetting, settingNameLen)) { MoveAlong(1 + settingNameLen); NeedBytes(5); if (isStatic && (pBlob[0] & DBVTF_VARIABLELENGTH) && VLT(dbv->type) != VLT(pBlob[0])) @@ -149,7 +149,7 @@ LBL_Seek: case DBVT_BYTE: dbv->bVal = pBlob[1]; break; case DBVT_WORD: memmove(&(dbv->wVal), (PWORD)(pBlob + 1), 2); break; case DBVT_DWORD: memmove(&(dbv->dVal), (PDWORD)(pBlob + 1), 4); break; - + case DBVT_UTF8: case DBVT_ASCIIZ: varLen = *(PWORD)(pBlob + 1); @@ -168,7 +168,7 @@ LBL_Seek: dbv->pszVal[varLen] = 0; } break; - + case DBVT_BLOB: varLen = *(PWORD)(pBlob + 1); NeedBytes(int(3 + varLen)); @@ -253,7 +253,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSetting(MCONTACT contactID, LPCSTR szMod if (GetContactSettingWorker(contactID, szModule, szSetting, dbv, 0)) return 1; - if (dbv->type == DBVT_UTF8 ) { + if (dbv->type == DBVT_UTF8) { WCHAR *tmp = NULL; char *p = NEWSTR_ALLOCA(dbv->pszVal); if (mir_utf8decode(p, &tmp) != NULL) { @@ -426,10 +426,10 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSetting(MCONTACT contactID, DBCONTACTW switch (dbcwWork.value.type) { case DBVT_BYTE: case DBVT_WORD: case DBVT_DWORD: break; - + case DBVT_ASCIIZ: case DBVT_UTF8: bIsEncrypted = m_bEncrypted || IsSettingEncrypted(dbcws->szModule, dbcws->szSetting); -LBL_WriteString: + LBL_WriteString: if (dbcwWork.value.pszVal == NULL) return 1; dbcwWork.value.cchVal = (WORD)strlen(dbcwWork.value.pszVal); @@ -443,7 +443,7 @@ LBL_WriteString: } } break; - + case DBVT_UNENCRYPTED: dbcwNotif.value.type = dbcwWork.value.type = DBVT_UTF8; goto LBL_WriteString; @@ -474,11 +474,11 @@ LBL_WriteString: bool bIsIdentical = false; if (pCachedValue->type == dbcwWork.value.type) { switch (dbcwWork.value.type) { - case DBVT_BYTE: bIsIdentical = pCachedValue->bVal == dbcwWork.value.bVal; break; - case DBVT_WORD: bIsIdentical = pCachedValue->wVal == dbcwWork.value.wVal; break; - case DBVT_DWORD: bIsIdentical = pCachedValue->dVal == dbcwWork.value.dVal; break; - case DBVT_UTF8: - case DBVT_ASCIIZ: bIsIdentical = strcmp(pCachedValue->pszVal, dbcwWork.value.pszVal) == 0; break; + case DBVT_BYTE: bIsIdentical = pCachedValue->bVal == dbcwWork.value.bVal; break; + case DBVT_WORD: bIsIdentical = pCachedValue->wVal == dbcwWork.value.wVal; break; + case DBVT_DWORD: bIsIdentical = pCachedValue->dVal == dbcwWork.value.dVal; break; + case DBVT_UTF8: + case DBVT_ASCIIZ: bIsIdentical = strcmp(pCachedValue->pszVal, dbcwWork.value.pszVal) == 0; break; } if (bIsIdentical) return 0; @@ -497,7 +497,7 @@ LBL_WriteString: log1(" write database as %s", printVariant(&dbcwWork.value)); DWORD ofsModuleName = GetModuleNameOfs(dbcwWork.szModule); - DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL); if (dbc.signature != DBCONTACT_SIGNATURE) return 1; @@ -505,7 +505,7 @@ LBL_WriteString: PBYTE pBlob; int bytesRequired, bytesRemaining; DBContactSettings dbcs; - DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsContact, ofsModuleName); + DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsModuleName); if (ofsSettingsGroup == 0) { //module group didn't exist - make it switch (dbcwWork.value.type) { case DBVT_ASCIIZ: case DBVT_UTF8: @@ -529,14 +529,14 @@ LBL_WriteString: DBWrite(ofsContact, &dbc, sizeof(DBContact)); DBWrite(ofsSettingsGroup, &dbcs, sizeof(DBContactSettings)); ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); - pBlob = (PBYTE)DBRead(ofsBlobPtr, 1, &bytesRemaining); + pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); } else { - dbcs = *(DBContactSettings*)DBRead(ofsSettingsGroup, sizeof(DBContactSettings), &bytesRemaining); - + dbcs = *(DBContactSettings*)DBRead(ofsSettingsGroup, &bytesRemaining); + // find if the setting exists ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); - pBlob = (PBYTE)DBRead(ofsBlobPtr, 1, &bytesRemaining); + pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); while (pBlob[0]) { NeedBytes(settingNameLen + 1); if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, dbcwWork.szSetting, settingNameLen)) @@ -553,9 +553,9 @@ LBL_WriteString: MoveAlong(1 + settingNameLen); // if different type or variable length and length is different NeedBytes(3); - if (pBlob[0] != dbcwWork.value.type || - ((pBlob[0] == DBVT_ASCIIZ || pBlob[0] == DBVT_UTF8) && *(PWORD)(pBlob + 1) != dbcwWork.value.cchVal) || - ((pBlob[0] == DBVT_BLOB || pBlob[0] == DBVT_ENCRYPTED) && *(PWORD)(pBlob + 1) != dbcwWork.value.cpbVal)) + if (pBlob[0] != dbcwWork.value.type || + ((pBlob[0] == DBVT_ASCIIZ || pBlob[0] == DBVT_UTF8) && *(PWORD)(pBlob + 1) != dbcwWork.value.cchVal) || + ((pBlob[0] == DBVT_BLOB || pBlob[0] == DBVT_ENCRYPTED) && *(PWORD)(pBlob + 1) != dbcwWork.value.cpbVal)) { // bin it NeedBytes(3); @@ -572,7 +572,7 @@ LBL_WriteString: } DBMoveChunk(ofsSettingToCut, ofsSettingToCut + nameLen + valLen, ofsBlobPtr + 1 - ofsSettingToCut); ofsBlobPtr -= nameLen + valLen; - pBlob = (PBYTE)DBRead(ofsBlobPtr, 1, &bytesRemaining); + pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); } else { // replace existing setting at pBlob @@ -601,7 +601,7 @@ LBL_WriteString: } } } - + // cannot do a simple replace, add setting to end of list // pBlob already points to end of list // see if it fits @@ -630,11 +630,11 @@ LBL_WriteString: ofsDbcsPrev = dbc.ofsFirstSettings; if (ofsDbcsPrev == ofsSettingsGroup) ofsDbcsPrev = 0; else { - dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, sizeof(DBContactSettings), NULL); + dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, NULL); while (dbcsPrev->ofsNext != ofsSettingsGroup) { if (dbcsPrev->ofsNext == 0) DatabaseCorruption(NULL); ofsDbcsPrev = dbcsPrev->ofsNext; - dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, sizeof(DBContactSettings), NULL); + dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, NULL); } } @@ -649,15 +649,15 @@ LBL_WriteString: DBWrite(ofsContact, &dbc, sizeof(DBContact)); } else { - dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, sizeof(DBContactSettings), NULL); + dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, NULL); dbcsPrev->ofsNext = ofsNew; DBWrite(ofsDbcsPrev, dbcsPrev, offsetof(DBContactSettings, blob)); } ofsBlobPtr += ofsNew - ofsSettingsGroup; ofsSettingsGroup = ofsNew; - pBlob = (PBYTE)DBRead(ofsBlobPtr, 1, &bytesRemaining); + pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); } - + // we now have a place to put it and enough space: make it DBWrite(ofsBlobPtr, &settingNameLen, 1); DBWrite(ofsBlobPtr + 1, (PVOID)dbcwWork.szSetting, settingNameLen); @@ -727,19 +727,19 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR sz mir_cslock lck(m_csDbAccess); DWORD ofsModuleName = GetModuleNameOfs(szModule); DWORD ofsContact = GetContactOffset(contactID); - DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return 1; // make sure the module group exists - DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsContact, ofsModuleName); + DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName); if (ofsSettingsGroup == 0) return 1; // find if the setting exists DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); int bytesRemaining; - PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, 1, &bytesRemaining); + PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); while (pBlob[0]) { NeedBytes(settingNameLen + 1); if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, szSetting, settingNameLen)) @@ -793,18 +793,18 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBCONTACTE if (ofsContact == 0) return -1; - DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL); + DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL); if (dbc->signature != DBCONTACT_SIGNATURE) return -1; DWORD ofsModuleName = GetModuleNameOfs(dbces->szModule); - dbces->ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsContact, ofsModuleName); + dbces->ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName); if (!dbces->ofsSettings) return -1; DWORD ofsBlobPtr = dbces->ofsSettings + offsetof(DBContactSettings, blob); int bytesRemaining; - PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, 1, &bytesRemaining); + PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); if (pBlob[0] == 0) return -1; diff --git a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp index 36dc7cf239..639015f67c 100644 --- a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp +++ b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp @@ -42,7 +42,7 @@ int CDb3Mmap::WorkContactChain(int firstTime) switch (phase) { case 0: if (ofsThisContact == 0) { -LBL_FinishUp: + LBL_FinishUp: if (contactCount != m_dbHeader.contactCount) cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Contact count marked wrongly: correcting")); m_dbHeader.contactCount = contactCount; @@ -78,16 +78,16 @@ LBL_FinishUp: contactCount++; phase++; first = 1; - // fall thru + // fall thru case 1: - ret = WorkSettingsChain(ofsDestThis, &dbc, first); + ret = WorkSettingsChain(&dbc, first); if (ret == ERROR_NO_MORE_ITEMS) { phase++; first = 1; } else if (ret) return ret; else break; - // fall thru + // fall thru case 2: ret = WorkEventChain(ofsDestThis, &dbc, first); if (ret == ERROR_NO_MORE_ITEMS) { @@ -96,7 +96,7 @@ LBL_FinishUp: else if (ret) return ret; else break; - // fall thru + // fall thru case 3: if (WriteSegment(ofsDestThis, &dbc, sizeof(DBContact)) == WS_ERROR) return ERROR_HANDLE_DISK_FULL; diff --git a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp index 1204c54cf9..1b0ea041be 100644 --- a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp +++ b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp @@ -195,7 +195,7 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime) dbeOld.ofsPrev = 0; lastTimestamp = dbeOld.timestamp; } - + if (dbeOld.flags & 1) dbeOld.flags &= ~1; @@ -269,8 +269,8 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime) if (dbePrev) { if (dbePrev->cbBlob == dbeNew->cbBlob && - dbePrev->ofsModuleName == dbeNew->ofsModuleName && - dbePrev->wEventType == dbeNew->wEventType && + 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")); @@ -286,8 +286,8 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime) } else if (!firstTime && dbeNew->timestamp < lastTimestamp) { DWORD found = 0; - DBEvent dbeTmp; - DWORD ofsTmp; + DBEvent dbeTmp = { 0 }; + DWORD ofsTmp = 0; if (cb->bCheckOnly) { if (!cb->bAggressive) { diff --git a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp index 5aa01e230c..4151031e27 100644 --- a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp +++ b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\commonheaders.h" -int CDb3Mmap::WorkFinalTasks(int firstTime) +int CDb3Mmap::WorkFinalTasks(int) { FreeModuleChain(); cb->pfnAddLogMessage(STATUS_MESSAGE, TranslateT("Processing final tasks")); diff --git a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp index ec1339d787..d7befbf8bc 100644 --- a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp +++ b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp @@ -22,14 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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))) + 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: @@ -41,11 +41,11 @@ int CDb3Mmap::WorkInitialCheckHeaders() 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 firstTime) +int CDb3Mmap::WorkInitialChecks(int) { sourceFileSize = GetFileSize(m_hDbFile, NULL); if (sourceFileSize == 0) { diff --git a/plugins/Db3x_mmap/src/dbtool/modulechain.cpp b/plugins/Db3x_mmap/src/dbtool/modulechain.cpp index 135935e4ed..522532d8f4 100644 --- a/plugins/Db3x_mmap/src/dbtool/modulechain.cpp +++ b/plugins/Db3x_mmap/src/dbtool/modulechain.cpp @@ -20,13 +20,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\commonheaders.h" struct ModChainEntry { - DWORD ofsOld,ofsNew; + DWORD ofsOld, ofsNew; int size; char name[257]; } static *modChain = NULL; static int modChainCount; static DWORD ofsCurrent; -static int phase,iCurrentModName; +static int phase, iCurrentModName; static DWORD ofsLast; static int last_mod = 0; @@ -87,7 +87,7 @@ int CDb3Mmap::WorkModuleChain(int firstTime) 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++) diff --git a/plugins/Db3x_mmap/src/dbtool/settingschain.cpp b/plugins/Db3x_mmap/src/dbtool/settingschain.cpp index 8911f86e07..01630ca3d2 100644 --- a/plugins/Db3x_mmap/src/dbtool/settingschain.cpp +++ b/plugins/Db3x_mmap/src/dbtool/settingschain.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static DWORD ofsThisSettings, ofsDestPrevSettings; -int CDb3Mmap::WorkSettingsChain(DWORD ofsContact, DBContact *dbc, int firstTime) +int CDb3Mmap::WorkSettingsChain(DBContact *dbc, int firstTime) { DWORD ofsDestThis; int ret; @@ -57,7 +57,7 @@ int CDb3Mmap::WorkSettingsChain(DWORD ofsContact, DBContact *dbc, int firstTime) 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; diff --git a/plugins/Db3x_mmap/src/dbtool/user.cpp b/plugins/Db3x_mmap/src/dbtool/user.cpp index 4f254bdbb9..2f0a317e90 100644 --- a/plugins/Db3x_mmap/src/dbtool/user.cpp +++ b/plugins/Db3x_mmap/src/dbtool/user.cpp @@ -54,7 +54,7 @@ int CDb3Mmap::WorkUser(int firstTime) int ret; switch (phase) { case 0: - ret = WorkSettingsChain(ofsUser, &user, first); + ret = WorkSettingsChain(&user, first); if (ret == ERROR_NO_MORE_ITEMS) { phase++; first = 1; } diff --git a/plugins/Db3x_mmap/src/init.cpp b/plugins/Db3x_mmap/src/init.cpp index f4620b4e1d..3ba2ff2f86 100644 --- a/plugins/Db3x_mmap/src/init.cpp +++ b/plugins/Db3x_mmap/src/init.cpp @@ -37,7 +37,7 @@ static PLUGININFOEX pluginInfo = __AUTHORWEB, UNICODE_AWARE | STATIC_PLUGIN, //{F7A6B27C-9D9C-4A42-BE86-A448AE109161} - {0xf7a6b27c, 0x9d9c, 0x4a42, {0xbe, 0x86, 0xa4, 0x48, 0xae, 0x10, 0x91, 0x61}} + { 0xf7a6b27c, 0x9d9c, 0x4a42, { 0xbe, 0x86, 0xa4, 0x48, 0xae, 0x10, 0x91, 0x61 } } }; HINSTANCE g_hInst = NULL; @@ -115,7 +115,7 @@ static DATABASELINK dblink = ///////////////////////////////////////////////////////////////////////////////////////// -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfo; } @@ -133,7 +133,7 @@ extern "C" __declspec(dllexport) int Unload(void) return 0; } -BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID reserved) +BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD, LPVOID) { g_hInst = hInstDLL; return TRUE; diff --git a/plugins/Db3x_mmap/src/ui.cpp b/plugins/Db3x_mmap/src/ui.cpp index a591c35268..768b297194 100644 --- a/plugins/Db3x_mmap/src/ui.cpp +++ b/plugins/Db3x_mmap/src/ui.cpp @@ -34,13 +34,13 @@ struct DlgChangePassParam static IconItem iconList[] = { - { LPGEN("Logo"), "logo", IDI_LOGO }, + { LPGEN("Logo"), "logo", IDI_LOGO }, { LPGEN("Password"), "password", IDI_ICONPASS } }; static HGENMENU hSetPwdMenu; -static int oldLangID; +static UINT oldLangID; void LanguageChanged(HWND hwndDlg) { UINT LangID = (UINT)GetKeyboardLayout(0); @@ -186,7 +186,7 @@ static INT_PTR CALLBACK sttChangePassword(HWND hwndDlg, UINT uMsg, WPARAM wParam case IDREMOVE: if (!CheckOldPassword(hwndDlg, param->db)) { -LBL_Error: + LBL_Error: SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0); SetDlgItemTextA(hwndDlg, IDC_USERPASS1, ""); SetDlgItemTextA(hwndDlg, IDC_USERPASS2, ""); @@ -270,7 +270,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { - if (IsDlgButtonChecked(hwndDlg, IDC_TOTAL) != (BOOL)db->isEncrypted()) { + if (IsDlgButtonChecked(hwndDlg, IDC_TOTAL) != (UINT)db->isEncrypted()) { db->ToggleEncryption(); CheckRadioButton(hwndDlg, IDC_STANDARD, IDC_TOTAL, IDC_STANDARD + db->isEncrypted()); } -- cgit v1.2.3