From d296f9f99daf102b9af5d56690e2bd00d61c1267 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 24 Jul 2018 11:11:26 +0300 Subject: database: - senseless fiels ptszVal removed from DBVARIANT, pwszVal is used instead; - if you want db_get to return a string, you need to use db_get_s. --- plugins/HTTPServer/src/GuiElements.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'plugins/HTTPServer/src') diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp index 44c430dd8b..726f5947da 100644 --- a/plugins/HTTPServer/src/GuiElements.cpp +++ b/plugins/HTTPServer/src/GuiElements.cpp @@ -97,16 +97,12 @@ string DBGetString(MCONTACT hContact, const char *szModule, const char *szSettin { string ret; DBVARIANT dbv = { 0 }; - if (!db_get(hContact, szModule, szSetting, &dbv)) { - if (dbv.type != DBVT_ASCIIZ) { - MessageBox(nullptr, "DB: Attempt to get wrong type of value, string", MSG_BOX_TITEL, MB_OK); - ret = pszError; - } - else ret = dbv.pszVal; + if (!db_get_s(hContact, szModule, szSetting, &dbv)) { + ret = dbv.pszVal; + db_free(&dbv); } else ret = pszError; - db_free(&dbv); return ret; } @@ -1033,14 +1029,12 @@ static INT_PTR nShareNewFile(WPARAM hContact, LPARAM lParam) if (hContact) { // Try to locate an IP address. DBVARIANT dbv = { 0 }; - if (!db_get(hContact, "Protocol", "p", &dbv)) { - if (dbv.type == DBVT_ASCIIZ) { - stNewShare.dwAllowedIP = db_get_dw(hContact, dbv.pszVal, "IP", 0); - if (!stNewShare.dwAllowedIP) - stNewShare.dwAllowedIP = db_get_dw(hContact, dbv.pszVal, "RealIP", 0); - if (!stNewShare.dwAllowedIP) - stNewShare.dwAllowedIP = db_get_dw(hContact, MODULENAME, "LastUsedIP", 0); - } + if (!db_get_s(hContact, "Protocol", "p", &dbv)) { + stNewShare.dwAllowedIP = db_get_dw(hContact, dbv.pszVal, "IP", 0); + if (!stNewShare.dwAllowedIP) + stNewShare.dwAllowedIP = db_get_dw(hContact, dbv.pszVal, "RealIP", 0); + if (!stNewShare.dwAllowedIP) + stNewShare.dwAllowedIP = db_get_dw(hContact, MODULENAME, "LastUsedIP", 0); } db_free(&dbv); -- cgit v1.2.3