summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-04-10 09:25:38 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-04-10 09:25:38 +0000
commitba06deac7058a716d63803d2840534a6da974231 (patch)
tree3041afed1e3951430c8af0056178d5ab53811424 /plugins/Db3x_mmap
parentc7c6cf53887f9c4c7f7bf436a86b973ef91dd6ba (diff)
nasty crutch to allow db_get_tstatic to work correctly
git-svn-id: http://svn.miranda-ng.org/main/trunk@16620 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r--plugins/Db3x_mmap/src/dbsettings.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp
index bea58a8884..a1e89cb4d4 100644
--- a/plugins/Db3x_mmap/src/dbsettings.cpp
+++ b/plugins/Db3x_mmap/src/dbsettings.cpp
@@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
+#pragma warning(disable: 4701)
+
DWORD GetModuleNameOfs(const char *szName);
DBCachedContact* AddToCachedContactList(MCONTACT contactID, int index);
@@ -331,10 +333,28 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSettingStr(MCONTACT contactID, LPCSTR sz
STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
+ bool bNeedsWchars;
+ size_t cbSaved;
+
+ if (dbv->type == DBVT_WCHAR) { // there's no wchar_t strings in a database, we need conversion
+ cbSaved = dbv->cchVal-1;
+ dbv->cchVal *= sizeof(wchar_t); // extend a room for the utf8 string
+ dbv->type = DBVT_UTF8;
+ bNeedsWchars = true;
+ }
+ else bNeedsWchars = false;
+
if (GetContactSettingWorker(contactID, szModule, szSetting, dbv, 1))
return 1;
- if (dbv->type == DBVT_UTF8) {
+ if (bNeedsWchars) {
+ char *pBuf = NEWSTR_ALLOCA(dbv->pszVal);
+ if (Utf8toUcs2(pBuf, dbv->cchVal, dbv->pwszVal, cbSaved) < 0)
+ return 1;
+
+ dbv->pwszVal[cbSaved] = 0;
+ }
+ else if (dbv->type == DBVT_UTF8) {
mir_utf8decode(dbv->pszVal, NULL);
dbv->type = DBVT_ASCIIZ;
}
@@ -835,7 +855,8 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnumResidentSettings(DBMODULEENUMPROC pFunc, void
{
for (int i = 0; i < m_lResidentSettings.getCount(); i++) {
int ret = pFunc(m_lResidentSettings[i], 0, (LPARAM)pParam);
- if (ret) return ret;
+ if (ret)
+ return ret;
}
return 0;
}