summaryrefslogtreecommitdiff
path: root/src/modules/database
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-10-30 20:09:34 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-10-30 20:09:34 +0000
commit0edc13560169b35dc38e2923f0d240531221cd03 (patch)
treef9612a145ab9a864f188815bfb289a6e74c4431e /src/modules/database
parentcdff820aeb7d935d18fb66027102f69ec96bf92c (diff)
- contact's base proto is cached now
- settings cache structure had been changed git-svn-id: http://svn.miranda-ng.org/main/trunk@2119 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/database')
-rw-r--r--src/modules/database/dbutils.cpp61
-rw-r--r--src/modules/database/mdatabasecache.cpp25
2 files changed, 35 insertions, 51 deletions
diff --git a/src/modules/database/dbutils.cpp b/src/modules/database/dbutils.cpp
index 4af6e71084..4444c8361c 100644
--- a/src/modules/database/dbutils.cpp
+++ b/src/modules/database/dbutils.cpp
@@ -101,9 +101,9 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam)
if ( !dbei->pBlob) return 0;
if (dbei->eventType == EVENTTYPE_FILE) {
- char* filename = ((char *)dbei->pBlob) + sizeof(DWORD);
- char* descr = filename + lstrlenA(filename) + 1;
- char* str = (*descr == 0) ? filename : descr;
+ char *filename = ((char *)dbei->pBlob) + sizeof(DWORD);
+ char *descr = filename + lstrlenA(filename) + 1;
+ char *str = (*descr == 0) ? filename : descr;
switch (egt->datatype) {
case DBVT_WCHAR:
return (INT_PTR)((dbei->flags & DBEF_UTF) ? Utf8DecodeT(str) : mir_a2t(str));
@@ -120,9 +120,9 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam)
egt->datatype &= ~DBVTF_DENYUNICODE;
if (egt->datatype == DBVT_WCHAR) {
- WCHAR* msg = NULL;
+ WCHAR *msg = NULL;
if (dbei->flags & DBEF_UTF) {
- char* str = (char*)alloca(dbei->cbBlob + 1);
+ char *str = (char*)alloca(dbei->cbBlob + 1);
if (str == NULL) return NULL;
memcpy(str, dbei->pBlob, dbei->cbBlob);
str[dbei->cbBlob] = 0;
@@ -132,7 +132,7 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam)
size_t msglen = strlen((char*)dbei->pBlob) + 1, msglenW = 0;
if (msglen != dbei->cbBlob) {
size_t i, count = ((dbei->cbBlob - msglen) / sizeof(WCHAR));
- WCHAR* p = (WCHAR*)&dbei->pBlob[ msglen ];
+ WCHAR *p = (WCHAR*)&dbei->pBlob[ msglen ];
for (i=0; i < count; i++) {
if (p[i] == 0) {
msglenW = i;
@@ -149,7 +149,7 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam)
return (INT_PTR)msg;
}
else if (egt->datatype == DBVT_ASCIIZ) {
- char* msg = mir_strdup((char*)dbei->pBlob);
+ char *msg = mir_strdup((char*)dbei->pBlob);
if (dbei->flags & DBEF_UTF)
Utf8DecodeCP(msg, egt->codepage, NULL);
@@ -177,8 +177,7 @@ static INT_PTR DbEventGetIcon(WPARAM wParam, LPARAM lParam)
icon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)szName);
}
- if ( !icon)
- {
+ if ( !icon) {
switch(dbei->eventType) {
case EVENTTYPE_URL:
icon = LoadSkinIcon(SKINICON_EVENT_URL);
@@ -200,7 +199,7 @@ static INT_PTR DbEventGetIcon(WPARAM wParam, LPARAM lParam)
static INT_PTR DbEventGetStringT(WPARAM wParam, LPARAM lParam)
{
DBEVENTINFO* dbei = (DBEVENTINFO*)wParam;
- char* string = (char*)lParam;
+ char *string = (char*)lParam;
if (dbei->flags & DBEF_UTF)
return (INT_PTR)Utf8DecodeW(string);
@@ -210,7 +209,7 @@ static INT_PTR DbEventGetStringT(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-static int sttEnumVars(const char* szVarName, LPARAM lParam)
+static int sttEnumVars(const char *szVarName, LPARAM lParam)
{
LIST<char>* vars = (LIST<char>*)lParam;
vars->insert(mir_strdup(szVarName));
@@ -240,17 +239,9 @@ static INT_PTR GetProfilePath(WPARAM wParam, LPARAM lParam)
if ( !wParam || !lParam)
return 1;
- char* dst = (char*)lParam;
-
- char* tmp = mir_t2a(g_profileDir);
- strncpy(dst, tmp, wParam);
- mir_free(tmp);
-
- if (wParam <= _tcslen(g_profileName))
- {
- dst[wParam - 1] = 0;
- return 1;
- }
+ char *dst = (char*)lParam;
+ strncpy(dst, _T2A(g_profileDir), wParam);
+ dst[wParam-1] = 0;
return 0;
}
@@ -259,17 +250,13 @@ static INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam)
if ( !wParam || !lParam)
return 1;
- char* dst = (char*)lParam;
+ char *dst = (char*)lParam;
- char* tmp = makeFileName(g_profileName);
+ char *tmp = makeFileName(g_profileName);
strncpy(dst, tmp, wParam);
mir_free(tmp);
- if (wParam <= _tcslen(g_profileName))
- {
- dst[wParam - 1] = 0;
- return 1;
- }
+ dst[wParam-1] = 0;
return 0;
}
@@ -278,25 +265,17 @@ static INT_PTR GetProfilePathW(WPARAM wParam, LPARAM lParam)
if ( !wParam || !lParam)
return 1;
- wchar_t* dst = (wchar_t*)lParam;
+ wchar_t *dst = (wchar_t*)lParam;
wcsncpy(dst, g_profileDir, wParam);
- if (wParam <= wcslen(g_profileDir))
- {
- dst[wParam - 1] = 0;
- return 1;
- }
+ dst[wParam-1] = 0;
return 0;
}
static INT_PTR GetProfileNameW(WPARAM wParam, LPARAM lParam)
{
- wchar_t* dst = (wchar_t*)lParam;
+ wchar_t *dst = (wchar_t*)lParam;
wcsncpy(dst, g_profileName, wParam);
- if (wParam <= wcslen(g_profileName))
- {
- dst[wParam - 1] = 0;
- return 1;
- }
+ dst[wParam-1] = 0;
return 0;
}
diff --git a/src/modules/database/mdatabasecache.cpp b/src/modules/database/mdatabasecache.cpp
index abb24dd0fe..04edbc66c2 100644
--- a/src/modules/database/mdatabasecache.cpp
+++ b/src/modules/database/mdatabasecache.cpp
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "database.h"
static int stringCompare(const char* p1, const char* p2)
-{ return strcmp(p1+1, p2+1);
+{ return strcmp(p1, p2);
}
static int compareGlobals(const DBCachedGlobalValue* p1, const DBCachedGlobalValue* p2)
@@ -90,8 +90,8 @@ void MDatabaseCache::FreeCachedContact(HANDLE hContact)
char* MDatabaseCache::InsertCachedSetting(const char* szName, int cbLen)
{
char* newValue = (char*)HeapAlloc(m_hCacheHeap, 0, cbLen);
- *newValue = 0;
- strcpy(newValue+1, szName+1);
+ *newValue++ = 0;
+ strcpy(newValue, szName);
m_lSettings.insert(newValue);
return newValue;
}
@@ -99,18 +99,23 @@ char* MDatabaseCache::InsertCachedSetting(const char* szName, int cbLen)
char* MDatabaseCache::GetCachedSetting(const char *szModuleName,const char *szSettingName, int moduleNameLen, int settingNameLen)
{
char szFullName[512];
- strcpy(szFullName+1,szModuleName);
- szFullName[moduleNameLen+1] = '/';
- strcpy(szFullName+moduleNameLen+2,szSettingName);
+ const char *szKey;
+ if (szModuleName != NULL) {
+ strcpy(szFullName, szModuleName);
+ szFullName[moduleNameLen] = '/';
+ strcpy(szFullName+moduleNameLen+1,szSettingName);
+ szKey = szFullName;
+ }
+ else szKey = szSettingName;
- if (m_lastSetting && strcmp(szFullName+1, m_lastSetting) == 0)
+ if (m_lastSetting && !strcmp(szKey, m_lastSetting))
return m_lastSetting;
- int index = m_lSettings.getIndex(szFullName);
+ int index = m_lSettings.getIndex((char*)szKey);
if (index != -1)
- m_lastSetting = m_lSettings[index]+1;
+ m_lastSetting = m_lSettings[index];
else
- m_lastSetting = InsertCachedSetting( szFullName, settingNameLen+moduleNameLen+3)+1;
+ m_lastSetting = InsertCachedSetting(szKey, settingNameLen+moduleNameLen+3);
return m_lastSetting;
}