diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-01 10:21:56 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-01 10:21:56 +0000 |
commit | a41c9020b7fcbc4d05fcb37097177cc0efc7cdce (patch) | |
tree | 5bda74986883a9152123474152c6546547211b9d /plugins | |
parent | 0ae8779546586eba91408d03949d45ec9ced5133 (diff) |
db_helpers.cpp deleted
git-svn-id: http://svn.miranda-ng.org/main/trunk@708 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/StatusPlugins/KeepStatus/action_keepstatus.cpp | 13 | ||||
-rw-r--r-- | plugins/StatusPlugins/StartupStatus/options.cpp | 42 | ||||
-rw-r--r-- | plugins/StatusPlugins/StartupStatus/profiles.cpp | 12 | ||||
-rw-r--r-- | plugins/StatusPlugins/StartupStatus/startupstatus.h | 3 | ||||
-rw-r--r-- | plugins/StatusPlugins/commonstatus.h | 1 | ||||
-rw-r--r-- | plugins/Variables/Variables_10.vcxproj | 3 | ||||
-rw-r--r-- | plugins/Variables/Variables_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/Variables/action_variables.cpp | 7 | ||||
-rw-r--r-- | plugins/Variables/help.cpp | 11 | ||||
-rw-r--r-- | plugins/Variables/main.cpp | 3 | ||||
-rw-r--r-- | plugins/Variables/options.cpp | 18 | ||||
-rw-r--r-- | plugins/Variables/parse_str.cpp | 316 | ||||
-rw-r--r-- | plugins/Variables/variables.cpp | 10 | ||||
-rw-r--r-- | plugins/Variables/variables.h | 6 | ||||
-rw-r--r-- | plugins/helpers/db_helpers.cpp | 71 | ||||
-rw-r--r-- | plugins/helpers/db_helpers.h | 489 |
16 files changed, 198 insertions, 810 deletions
diff --git a/plugins/StatusPlugins/KeepStatus/action_keepstatus.cpp b/plugins/StatusPlugins/KeepStatus/action_keepstatus.cpp index bf71c81543..f51f258ec7 100644 --- a/plugins/StatusPlugins/KeepStatus/action_keepstatus.cpp +++ b/plugins/StatusPlugins/KeepStatus/action_keepstatus.cpp @@ -2,7 +2,6 @@ #include "keepstatus.h"
#include "../resource.h"
#include "m_trigger.h"
-#include "../../helpers/db_helpers.h"
extern HINSTANCE hInst;
@@ -13,12 +12,12 @@ static BOOL ProtocolEnabled(DWORD id, char *szPrefix, REPORTINFO *ri, char *szPr {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s_%s", szPrefix, id, szProto, SETTING_PROTO_ENABLED);
- if (db_getb(dbSetting, 0))
+ if ( db_get_b(NULL, MODULENAME, dbSetting, 0))
return TRUE;
if ( ri != NULL && ri->td != NULL && (ri->td->dFlags & DF_PROTO) && !strcmp(szProto, ri->td->szProto)) {
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s_%s", szPrefix, id, STR_PROTOFROMTRIGGER, SETTING_PROTO_ENABLED);
- return db_getb(dbSetting, 0);
+ return db_get_b(NULL, MODULENAME, dbSetting, 0);
}
return FALSE;
@@ -53,7 +52,7 @@ static void BuildProtoList(HWND hList, BOOL bFromTrigger, char* szPrefix, DWORD ListView_InsertItem(hList, &lvItem);
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s_%s", szPrefix, id, protos[i]->szModuleName, SETTING_PROTO_ENABLED);
- ListView_SetCheckState(hList, lvItem.iItem, db_getb(dbSetting, 0));
+ ListView_SetCheckState(hList, lvItem.iItem, db_get_b(NULL, MODULENAME, dbSetting, 0));
ListView_SetItem(hList, &lvItem);
lvItem.iItem++;
if (lvItem.pszText != NULL)
@@ -64,7 +63,7 @@ static void BuildProtoList(HWND hList, BOOL bFromTrigger, char* szPrefix, DWORD ListView_InsertItem(hList, &lvItem);
lvItem.lParam = (LPARAM)STR_PROTOFROMTRIGGER;
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s_%s", szPrefix, id, STR_PROTOFROMTRIGGER, SETTING_PROTO_ENABLED);
- ListView_SetCheckState(hList, lvItem.iItem, db_getb(dbSetting, 0));
+ ListView_SetCheckState(hList, lvItem.iItem, db_get_b(NULL, MODULENAME, dbSetting, 0));
ListView_SetItem(hList, &lvItem);
lvItem.iItem++;
}
@@ -84,10 +83,10 @@ static void SaveProtoList(HWND hList, char *szPrefix, DWORD id) char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s_%s", szPrefix, id, (const char*)lvItem.lParam, SETTING_PROTO_ENABLED);
if (ListView_GetCheckState(hList, lvItem.iItem))
- db_setb(dbSetting, TRUE);
+ db_set_b(NULL, MODULENAME, dbSetting, TRUE);
else {
log_debugA("deleting: %s", dbSetting);
- db_del(dbSetting);
+ db_unset(NULL, MODULENAME, dbSetting);
}
}
}
diff --git a/plugins/StatusPlugins/StartupStatus/options.cpp b/plugins/StatusPlugins/StartupStatus/options.cpp index a790561310..63edb34d4c 100644 --- a/plugins/StatusPlugins/StartupStatus/options.cpp +++ b/plugins/StatusPlugins/StartupStatus/options.cpp @@ -16,6 +16,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
#include "../commonstatus.h"
#include "startupstatus.h"
#include "../resource.h"
@@ -552,19 +553,19 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP if ( ar[j].szMsg != NULL)
ar[j].szMsg = _strdup( ar[j].szMsg );
- dat[i].szName = dbi_getAs(i, SETTING_PROFILENAME, NULL);
+ dat[i].szName = db_get_sa(NULL, MODULENAME, OptName(i, SETTING_PROFILENAME));
if (dat[i].szName == NULL) {
if (i == defProfile)
dat[i].szName = _strdup(Translate("default"));
else
dat[i].szName = _strdup(Translate("unknown"));
}
- dat[i].createTtb = dbi_getb(i, SETTING_CREATETTBBUTTON, 0);
- dat[i].showDialog = dbi_getb(i, SETTING_SHOWCONFIRMDIALOG, 0);
- dat[i].createMmi = dbi_getb(i, SETTING_CREATEMMITEM, 0);
- dat[i].inSubMenu = dbi_getb(i, SETTING_INSUBMENU, 1);
- dat[i].regHotkey = dbi_getb(i, SETTING_REGHOTKEY, 0);
- dat[i].hotKey = dbi_getw(i, SETTING_HOTKEY, MAKEWORD((char)('0'+i), HOTKEYF_CONTROL|HOTKEYF_SHIFT));
+ dat[i].createTtb = db_get_b(NULL, MODULENAME, OptName(i, SETTING_CREATETTBBUTTON), 0);
+ dat[i].showDialog = db_get_b(NULL, MODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), 0);
+ dat[i].createMmi = db_get_b(NULL, MODULENAME, OptName(i, SETTING_CREATEMMITEM), 0);
+ dat[i].inSubMenu = db_get_b(NULL, MODULENAME, OptName(i, SETTING_INSUBMENU), 1);
+ dat[i].regHotkey = db_get_b(NULL, MODULENAME, OptName(i, SETTING_REGHOTKEY), 0);
+ dat[i].hotKey = db_get_w(NULL, MODULENAME, OptName(i, SETTING_HOTKEY), MAKEWORD((char)('0'+i), HOTKEYF_CONTROL|HOTKEYF_SHIFT));
}
}
if ( !ServiceExists( MS_TTB_ADDBUTTON ) && !ServiceExists( MS_TB_ADDBUTTON ))
@@ -847,21 +848,21 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP ClearDatabase(setting);
}
for (i=0;i<profileCount;i++) {
- dbi_setb(i, SETTING_SHOWCONFIRMDIALOG, dat[i].showDialog);
- dbi_setb(i, SETTING_CREATETTBBUTTON, dat[i].createTtb);
- dbi_setb(i, SETTING_CREATEMMITEM, dat[i].createMmi);
- dbi_setb(i, SETTING_INSUBMENU, dat[i].inSubMenu);
- dbi_setb(i, SETTING_REGHOTKEY, dat[i].regHotkey);
- dbi_setw(i, SETTING_HOTKEY, dat[i].hotKey);
- dbi_setAs(i, SETTING_PROFILENAME, dat[i].szName);
+ db_set_b(NULL, MODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), dat[i].showDialog);
+ db_set_b(NULL, MODULENAME, OptName(i, SETTING_CREATETTBBUTTON), dat[i].createTtb);
+ db_set_b(NULL, MODULENAME, OptName(i, SETTING_CREATEMMITEM), dat[i].createMmi);
+ db_set_b(NULL, MODULENAME, OptName(i, SETTING_INSUBMENU), dat[i].inSubMenu);
+ db_set_b(NULL, MODULENAME, OptName(i, SETTING_REGHOTKEY), dat[i].regHotkey);
+ db_set_w(NULL, MODULENAME, OptName(i, SETTING_HOTKEY), dat[i].hotKey);
+ db_set_s(NULL, MODULENAME, OptName(i, SETTING_PROFILENAME), dat[i].szName);
TSettingsList& ar = *dat[i].ps;
for ( j=0; j < ar.getCount(); j++ ) {
if ( ar[j].szMsg != NULL ) {
mir_snprintf(setting, sizeof(setting), "%s_%s", ar[j].szName, SETTING_PROFILE_STSMSG);
- dbi_setAs(i, setting, ar[j].szMsg);
+ db_set_s(NULL, MODULENAME, OptName(i, setting), ar[j].szMsg);
}
- dbi_setw(i, ar[j].szName, ar[j].status);
+ db_set_w(NULL, MODULENAME, OptName(i, ar[j].szName), ar[j].status);
}
}
DBWriteContactSettingWord(NULL, MODULENAME, SETTING_PROFILECOUNT, (WORD)profileCount);
@@ -988,7 +989,7 @@ static int ClearDatabase(char* filter) dbces.lParam = (LPARAM)&settings;
dbces.pfnEnumProc = DeleteSetting;
CallService(MS_DB_CONTACT_ENUMSETTINGS,(WPARAM)NULL,(LPARAM)&dbces);
- for (i=0;i<settingCount;i++) {
+ for (i=0; i < settingCount; i++) {
if ((filter == NULL) || (!strncmp(filter, settings[i], strlen(filter))))
DBDeleteContactSetting(NULL, MODULENAME, settings[i]);
free(settings[i]);
@@ -1016,3 +1017,10 @@ static int DeleteSetting(const char *szSetting,LPARAM lParam) return 0;
}
+
+char* OptName(int i, const char* setting)
+{
+ static char buf[100];
+ mir_snprintf(buf, sizeof(buf), "%d_%s", i, setting);
+ return buf;
+}
diff --git a/plugins/StatusPlugins/StartupStatus/profiles.cpp b/plugins/StatusPlugins/StartupStatus/profiles.cpp index 309c249a6a..3d93f1b37d 100644 --- a/plugins/StatusPlugins/StartupStatus/profiles.cpp +++ b/plugins/StatusPlugins/StartupStatus/profiles.cpp @@ -98,12 +98,12 @@ static int CreateMainMenuItems(WPARAM wParam, LPARAM lParam) mi.popupPosition = 2000100000;
mcount = 0;
count = GetProfileCount(0, 0);
- for (i=0;i<count;i++) {
- if ( !dbi_getb(i, SETTING_CREATEMMITEM, 0) || GetProfileName((WPARAM)i, (LPARAM)profilename))
+ for (i=0; i < count; i++) {
+ if ( !db_get_b(NULL, MODULENAME, OptName(i, SETTING_CREATEMMITEM), 0) || GetProfileName((WPARAM)i, (LPARAM)profilename))
continue;
- if (dbi_getb(i, SETTING_INSUBMENU, 1))
- mi.pszPopupName = Translate("StatusProfiles");
+ if ( db_get_b(NULL, MODULENAME, OptName(i, SETTING_INSUBMENU), 1))
+ mi.pszPopupName = "StatusProfiles";
mi.pszName = profilename;
mi.position = 2000100000 + mcount;
@@ -315,10 +315,10 @@ static int RegisterHotKeys() int count = GetProfileCount(0, 0);
for ( int i=0; i < count; i++ ) {
- if (!dbi_getb(i, SETTING_REGHOTKEY, 0))
+ if (!db_get_b(NULL, MODULENAME, OptName(i, SETTING_REGHOTKEY), 0))
continue;
- WORD wHotKey = dbi_getw(i, SETTING_HOTKEY, 0);
+ WORD wHotKey = db_get_w(NULL, MODULENAME, OptName(i, SETTING_HOTKEY), 0);
hkInfo = ( HKINFO* )realloc(hkInfo, (hkiCount+1)*sizeof(HKINFO));
if (hkInfo == NULL)
return -1;
diff --git a/plugins/StatusPlugins/StartupStatus/startupstatus.h b/plugins/StatusPlugins/StartupStatus/startupstatus.h index 0d9a325839..e3ce6e8acb 100644 --- a/plugins/StatusPlugins/StartupStatus/startupstatus.h +++ b/plugins/StatusPlugins/StartupStatus/startupstatus.h @@ -27,8 +27,8 @@ #include <m_toptoolbar.h>
#include <m_toolbar.h>
#include "version.h"
+
#define MODULENAME "StartupStatus"
-#include "../../helpers/db_helpers.h"
struct TSSSetting : public PROTOCOLSETTINGEX
{
@@ -131,6 +131,7 @@ typedef struct { // options
int OptionsInit(WPARAM wparam,LPARAM lparam);
+char* OptName(int i, const char* setting);
// startupstatus
int LoadMainOptions();
diff --git a/plugins/StatusPlugins/commonstatus.h b/plugins/StatusPlugins/commonstatus.h index e0909e94ac..797fd6ed4b 100644 --- a/plugins/StatusPlugins/commonstatus.h +++ b/plugins/StatusPlugins/commonstatus.h @@ -39,6 +39,7 @@ #include <m_database.h>
#include <m_protosvc.h>
#include <m_clist.h>
+#include <m_clistint.h>
#include <m_langpack.h>
#include <m_popup.h>
#include <m_variables.h>
diff --git a/plugins/Variables/Variables_10.vcxproj b/plugins/Variables/Variables_10.vcxproj index 209eb885f5..1350edd98b 100644 --- a/plugins/Variables/Variables_10.vcxproj +++ b/plugins/Variables/Variables_10.vcxproj @@ -208,9 +208,6 @@ <ClCompile Include="action_variables.cpp" />
<ClCompile Include="condition_variables.cpp" />
<ClCompile Include="trigger_variables.cpp" />
- <ClCompile Include="..\helpers\db_helpers.cpp">
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- </ClCompile>
<ClCompile Include="..\helpers\gen_helpers.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
diff --git a/plugins/Variables/Variables_10.vcxproj.filters b/plugins/Variables/Variables_10.vcxproj.filters index ecd6ebe9ce..03ffbf41a4 100644 --- a/plugins/Variables/Variables_10.vcxproj.filters +++ b/plugins/Variables/Variables_10.vcxproj.filters @@ -94,9 +94,6 @@ <ClCompile Include="trigger_variables.cpp">
<Filter>TriggerPlugin</Filter>
</ClCompile>
- <ClCompile Include="..\helpers\db_helpers.cpp">
- <Filter>External</Filter>
- </ClCompile>
<ClCompile Include="..\helpers\gen_helpers.cpp">
<Filter>External</Filter>
</ClCompile>
diff --git a/plugins/Variables/action_variables.cpp b/plugins/Variables/action_variables.cpp index d767250578..e4d1a17aa1 100644 --- a/plugins/Variables/action_variables.cpp +++ b/plugins/Variables/action_variables.cpp @@ -139,11 +139,8 @@ INT_PTR CALLBACK DlgProcOptsParseString(HWND hwndDlg, UINT msg, WPARAM wParam, L case TM_ADDACTION: {
// wParam = action ID
// lParam = 0
- DWORD actionID;
- TCHAR *tszText;
-
- actionID = (DWORD)wParam;
- tszText = Hlp_GetDlgItemText(hwndDlg, IDC_PARSESTRING);
+ DWORD actionID = (DWORD)wParam;
+ TCHAR *tszText = Hlp_GetDlgItemText(hwndDlg, IDC_PARSESTRING);
if (tszText != NULL) {
DBWriteActionSettingTString(actionID, NULL, MODULENAME, SETTING_PARSESTRING, tszText);
mir_free(tszText);
diff --git a/plugins/Variables/help.cpp b/plugins/Variables/help.cpp index 66d24ee12f..9c35806f11 100644 --- a/plugins/Variables/help.cpp +++ b/plugins/Variables/help.cpp @@ -148,14 +148,13 @@ static INT_PTR CALLBACK clistDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM break;
case VARM_SETSUBJECT: {
- TCHAR *tszContact;
LPARAM res = 0;
HANDLE hContact, hItem;
hContact = (HANDLE)wParam;
log_debugA("VARM_SETSUBJECT: %u", hContact);
if (hContact == INVALID_HANDLE_VALUE) {
- tszContact = db_gets(SETTING_SUBJECT, NULL);
+ TCHAR *tszContact = db_get_tsa(NULL, MODULENAME, SETTING_SUBJECT);
log_debugA("VARM_SETSUBJECT: %s", tszContact);
if (tszContact != NULL) {
hContact = decodeContactFromString(tszContact);
@@ -233,13 +232,13 @@ static INT_PTR CALLBACK clistDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM break;
case WM_DESTROY:
- db_del(SETTING_SUBJECT);
+ db_unset(NULL, MODULENAME, SETTING_SUBJECT);
{
HANDLE hContact = (HANDLE)SendMessage(hwndDlg, VARM_GETSUBJECT, 0, 0);
if (hContact != NULL) {
TCHAR *tszContact = encodeContactToString(hContact);
if (tszContact != NULL) {
- db_sets(SETTING_SUBJECT, tszContact);
+ db_set_ts(NULL, MODULENAME, SETTING_SUBJECT, tszContact);
mir_free(tszContact);
} } }
break;
@@ -677,7 +676,7 @@ static INT_PTR CALLBACK inputDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM ZeroMemory(dat, sizeof(INPUTDLGDATA));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
// splitter things
- dat->splitterPos = (INT_PTR)db_getd(SETTING_SPLITTERPOS, -1);
+ dat->splitterPos = (INT_PTR)db_get_dw(NULL, MODULENAME, SETTING_SPLITTERPOS, -1);
{
RECT rc;
POINT pt;
@@ -816,7 +815,7 @@ static INT_PTR CALLBACK inputDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM case WM_DESTROY:
KillTimer(hwndDlg, IDT_PARSE);
- db_setd(SETTING_SPLITTERPOS, dat->splitterPos);
+ db_set_dw(NULL, MODULENAME, SETTING_SPLITTERPOS, dat->splitterPos);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SPLITTER), GWLP_WNDPROC, (LONG_PTR) OldSplitterProc);
if (dat != NULL) {
mir_free(dat);
diff --git a/plugins/Variables/main.cpp b/plugins/Variables/main.cpp index 4d47d84439..fc0d49147a 100644 --- a/plugins/Variables/main.cpp +++ b/plugins/Variables/main.cpp @@ -80,9 +80,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" int __declspec(dllexport) Load(void)
{
-
- if (UnicodeCheck(pluginInfoEx.shortName, FALSE))
- return 0;
mir_getLP( &pluginInfoEx );
hExitHook = HookEvent(ME_SYSTEM_OKTOEXIT, Exit);
diff --git a/plugins/Variables/options.cpp b/plugins/Variables/options.cpp index e94e27fcdf..0220386564 100644 --- a/plugins/Variables/options.cpp +++ b/plugins/Variables/options.cpp @@ -34,10 +34,10 @@ static INT_PTR CALLBACK SetOptsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA DBFreeVariant(&dbv);
}
}
- CheckDlgButton(hwndDlg, IDC_PARSEATSTARTUP, db_getb(SETTING_PARSEATSTARTUP, 0));
- CheckDlgButton(hwndDlg, IDC_STRIPCRLF, db_getb(SETTING_STRIPCRLF, 0));
- CheckDlgButton(hwndDlg, IDC_STRIPWS, db_getb(SETTING_STRIPWS, 0));
- CheckDlgButton(hwndDlg, IDC_STRIPALL, db_getb(SETTING_STRIPALL, 0));
+ CheckDlgButton(hwndDlg, IDC_PARSEATSTARTUP, db_get_b(NULL, MODULENAME, SETTING_PARSEATSTARTUP, 0));
+ CheckDlgButton(hwndDlg, IDC_STRIPCRLF, db_get_b(NULL, MODULENAME, SETTING_STRIPCRLF, 0));
+ CheckDlgButton(hwndDlg, IDC_STRIPWS, db_get_b(NULL, MODULENAME, SETTING_STRIPWS, 0));
+ CheckDlgButton(hwndDlg, IDC_STRIPALL, db_get_b(NULL, MODULENAME, SETTING_STRIPALL, 0));
EnableWindow(GetDlgItem(hwndDlg, IDC_STRIPCRLF), IsDlgButtonChecked(hwndDlg, IDC_STRIPALL)?FALSE:TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_STRIPWS), IsDlgButtonChecked(hwndDlg, IDC_STRIPALL)?FALSE:TRUE);
variables_skin_helpbutton(hwndDlg, IDC_SHOWHELP);
@@ -93,14 +93,14 @@ static INT_PTR CALLBACK SetOptsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA break;
if (GetDlgItemText(hwndDlg, IDC_FORMATTEXT, szFormatText, len+1) != 0)
- db_sets(SETTING_STARTUPTEXT, szFormatText);
+ db_set_ts(NULL, MODULENAME, SETTING_STARTUPTEXT, szFormatText);
mir_free(szFormatText);
}
- db_setb(SETTING_PARSEATSTARTUP, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_PARSEATSTARTUP)?1:0));
- db_setb(SETTING_STRIPCRLF, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_STRIPCRLF)?1:0));
- db_setb(SETTING_STRIPWS, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_STRIPWS)?1:0));
- db_setb(SETTING_STRIPALL, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_STRIPALL)?1:0));
+ db_set_b(NULL, MODULENAME, SETTING_PARSEATSTARTUP, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_PARSEATSTARTUP)?1:0));
+ db_set_b(NULL, MODULENAME, SETTING_STRIPCRLF, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_STRIPCRLF)?1:0));
+ db_set_b(NULL, MODULENAME, SETTING_STRIPWS, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_STRIPWS)?1:0));
+ db_set_b(NULL, MODULENAME, SETTING_STRIPALL, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_STRIPALL)?1:0));
}
break;
diff --git a/plugins/Variables/parse_str.cpp b/plugins/Variables/parse_str.cpp index 4ee815cdae..112b064d1f 100644 --- a/plugins/Variables/parse_str.cpp +++ b/plugins/Variables/parse_str.cpp @@ -19,15 +19,13 @@ #include "variables.h"
#include "parse_str.h"
-static TCHAR *parseCaps(ARGUMENTSINFO *ai) {
-
- TCHAR *cur, *res;
-
+static TCHAR *parseCaps(ARGUMENTSINFO *ai)
+{
if (ai->argc != 2)
return NULL;
- res = mir_tstrdup(ai->targv[1]);
- cur = res;
+ TCHAR *res = mir_tstrdup(ai->targv[1]);
+ TCHAR *cur = res;
CharLower(res);
*cur = (TCHAR)CharUpper((LPTSTR)*cur);
cur++;
@@ -46,15 +44,13 @@ static TCHAR *parseCaps(ARGUMENTSINFO *ai) { return res;
}
-static TCHAR *parseCaps2(ARGUMENTSINFO *ai) {
-
- TCHAR *cur, *res;
-
+static TCHAR *parseCaps2(ARGUMENTSINFO *ai)
+{
if (ai->argc != 2)
return NULL;
- res = mir_tstrdup(ai->targv[1]);
- cur = res;
+ TCHAR *res = mir_tstrdup(ai->targv[1]);
+ TCHAR *cur = res;
*cur = (TCHAR)CharUpper((LPTSTR)*cur);
cur++;
while (*cur != _T('\0')) {
@@ -68,93 +64,84 @@ static TCHAR *parseCaps2(ARGUMENTSINFO *ai) { return res;
}
-static TCHAR *parseCrlf(ARGUMENTSINFO *ai) {
-
+static TCHAR *parseCrlf(ARGUMENTSINFO *ai)
+{
ai->flags |= AIF_DONTPARSE;
-
return mir_tstrdup(_T("\r\n"));
}
-static TCHAR *parseEolToCrlf(ARGUMENTSINFO *ai) {
-
- int loc;
- TCHAR *cur, *res;
-
- if (ai->argc != 2) {
+static TCHAR *parseEolToCrlf(ARGUMENTSINFO *ai)
+{
+ if (ai->argc != 2)
return NULL;
- }
- res = mir_tstrdup(ai->targv[1]);
- cur = res;
+
+ TCHAR *res = mir_tstrdup(ai->targv[1]);
+ TCHAR *cur = res;
do {
cur = _tcschr(cur, _T('\n'));
- if ((cur == NULL) || ((cur > res) && (*(cur-1) == '\r'))) {
+ if ((cur == NULL) || ((cur > res) && (*(cur-1) == '\r')))
continue;
- }
+
log_debug(cur);
- loc = cur - res;
+ int loc = cur - res;
res = (TCHAR*)mir_realloc(res, (_tcslen(res)+2)*sizeof(TCHAR));
cur = res + loc;
MoveMemory(cur+2, cur+1, (_tcslen(cur+1)+1)*sizeof(TCHAR));
CopyMemory(cur, _T("\r\n"), 2*sizeof(TCHAR));
cur += 2;
- } while (cur != NULL);
+ }
+ while (cur != NULL);
return res;
}
-static TCHAR *parseFixeol(ARGUMENTSINFO *ai) {
-
- TCHAR *cur, *szReplacement, *res;
-
- if (ai->argc == 2) {
+static TCHAR *parseFixeol(ARGUMENTSINFO *ai)
+{
+ TCHAR *szReplacement;
+ if (ai->argc == 2)
szReplacement = _T("(...)");
- }
- else if (ai->argc == 3) {
+ else if (ai->argc == 3)
szReplacement = ai->targv[2];
- }
- else {
+ else
return NULL;
- }
- cur = ai->targv[1];
- while ( (_tcscmp(cur, _T("\r\n"))) && (*cur != _T('\n')) && (*cur != _T('\0'))) {
+
+ TCHAR *cur = ai->targv[1];
+ while ( (_tcscmp(cur, _T("\r\n"))) && (*cur != _T('\n')) && (*cur != _T('\0')))
cur++;
- }
- if (*cur == '\0') {
+
+ if (*cur == '\0')
return mir_tstrdup(ai->targv[1]);
- }
+
cur--;
- res = (TCHAR*)mir_alloc((cur-ai->targv[1] + _tcslen(szReplacement) + 1)*sizeof(TCHAR));
- if (res == NULL) {
+ TCHAR *res = (TCHAR*)mir_alloc((cur-ai->targv[1] + _tcslen(szReplacement) + 1)*sizeof(TCHAR));
+ if (res == NULL)
return res;
- }
+
ZeroMemory(res, ((cur - ai->targv[1]) + 1)*sizeof(TCHAR));
_tcsncpy(res, ai->targv[1], cur-ai->targv[1]);
_tcscat(res, szReplacement);
-
return res;
}
-static TCHAR *parseFixeol2(ARGUMENTSINFO *ai) {
-
- TCHAR *res, *cur, *szEol, *szReplacement;
-
- unsigned int pos = 0;
- res = mir_tstrdup(ai->targv[1]);
+static TCHAR *parseFixeol2(ARGUMENTSINFO *ai)
+{
+ TCHAR *szReplacement;
switch( ai->argc ) {
case 2: szReplacement = _T(" "); break;
case 3: szReplacement = ai->targv[2]; break;
default: return NULL;
}
- for ( pos=0; pos < _tcslen(res); pos++ ) {
- cur = res+pos;
- szEol = NULL;
- if (!_tcsncmp(cur, _T("\r\n"), _tcslen(_T("\r\n")))) {
+ TCHAR *res = mir_tstrdup(ai->targv[1]);
+ for (unsigned int pos=0; pos < _tcslen(res); pos++ ) {
+ TCHAR *cur = res+pos;
+ TCHAR *szEol = NULL;
+ if (!_tcsncmp(cur, _T("\r\n"), _tcslen(_T("\r\n"))))
szEol = _T("\r\n");
- }
- if (*cur == _T('\n')) {
+
+ if (*cur == _T('\n'))
szEol = _T("\n");
- }
+
if (szEol != NULL) {
if ( _tcslen(szReplacement) > _tcslen(szEol)) {
res = (TCHAR*)mir_realloc(res, (_tcslen(res) + _tcslen(szReplacement) - _tcslen(szEol) + 1)*sizeof(TCHAR));
@@ -165,218 +152,185 @@ static TCHAR *parseFixeol2(ARGUMENTSINFO *ai) { pos += _tcslen(szReplacement) - 1;
}
}
- res = (TCHAR*)mir_realloc(res, (_tcslen(res)+1)*sizeof(TCHAR));
-
- return res;
+ return (TCHAR*)mir_realloc(res, (_tcslen(res)+1)*sizeof(TCHAR));
}
-static TCHAR *parseInsert(ARGUMENTSINFO *ai) {
-
- TCHAR *res;
- unsigned int pos;
-
- if (ai->argc != 4) {
+static TCHAR *parseInsert(ARGUMENTSINFO *ai)
+{
+ if (ai->argc != 4)
return NULL;
- }
- pos = ttoi(ai->targv[3]);
- if (pos > _tcslen(ai->targv[1])) {
+ unsigned int pos = ttoi(ai->targv[3]);
+ if (pos > _tcslen(ai->targv[1]))
return NULL;
- }
- res = (TCHAR*)mir_alloc((_tcslen(ai->targv[1]) + _tcslen(ai->targv[2]) + 1)*sizeof(TCHAR));
- if (res == NULL) {
+
+ TCHAR *res = (TCHAR*)mir_alloc((_tcslen(ai->targv[1]) + _tcslen(ai->targv[2]) + 1)*sizeof(TCHAR));
+ if (res == NULL)
return NULL;
- }
+
ZeroMemory(res, (_tcslen(ai->targv[1]) + _tcslen(ai->targv[2]) + 1)*sizeof(TCHAR));
_tcsncpy(res, ai->targv[1], pos);
_tcscpy(res + pos, ai->targv[2]);
_tcscpy(res+pos+_tcslen(ai->targv[2]), ai->targv[1]+pos);
-
return res;
}
-static TCHAR *parseLeft(ARGUMENTSINFO *ai) {
-
- int len;
- TCHAR *res;
-
- if (ai->argc != 3) {
+static TCHAR *parseLeft(ARGUMENTSINFO *ai)
+{
+ if (ai->argc != 3)
return NULL;
- }
- len = ttoi(ai->targv[2]);
- if (len < 0) {
+
+ int len = ttoi(ai->targv[2]);
+ if (len < 0)
return NULL;
- }
+
len = min(len, (signed int)_tcslen(ai->targv[1]));
- res = (TCHAR*)mir_alloc((len + 1)*sizeof(TCHAR));
- if (res == NULL) {
+ TCHAR *res = (TCHAR*)mir_alloc((len + 1)*sizeof(TCHAR));
+ if (res == NULL)
return NULL;
- }
+
ZeroMemory(res, (len+1)*sizeof(TCHAR));
_tcsncpy(res, ai->targv[1], len);
-
return res;
}
-static TCHAR *parseLen(ARGUMENTSINFO *ai) {
-
- int len;
-
- if (ai->argc != 2) {
+static TCHAR *parseLen(ARGUMENTSINFO *ai)
+{
+ if (ai->argc != 2)
return NULL;
- }
- len = _tcslen(ai->targv[1]);
-
- return itot(len);
-}
-static TCHAR *parseLineCount(ARGUMENTSINFO *ai) {
-
- int count;
- TCHAR *cur;
+ return itot( _tcslen( ai->targv[1] ));
+}
- if (ai->argc != 2) {
+static TCHAR *parseLineCount(ARGUMENTSINFO *ai)
+{
+ if (ai->argc != 2)
return NULL;
- }
- count = 1;
- cur = ai->targv[1];
+
+ int count = 1;
+ TCHAR *cur = ai->targv[1];
while (cur < (ai->targv[1] + _tcslen(ai->targv[1]))) {
if (!_tcsncmp(cur, _T("\r\n"), 2)) {
count += 1;
cur++;
}
- else if (*cur == _T('\n')) {
- count += 1;
- }
+ else if (*cur == _T('\n'))
+ count++;
+
cur++;
}
return itot(count);
}
-static TCHAR *parseLower(ARGUMENTSINFO *ai) {
-
- TCHAR *res;
-
- if (ai->argc != 2) {
+static TCHAR *parseLower(ARGUMENTSINFO *ai)
+{
+ if (ai->argc != 2)
return NULL;
- }
- res = mir_tstrdup(ai->targv[1]);
- if (res == NULL) {
+
+ TCHAR *res = mir_tstrdup(ai->targv[1]);
+ if (res == NULL)
return NULL;
- }
return CharLower(res);
}
-static TCHAR *parseLongest(ARGUMENTSINFO *ai) {
-
- unsigned int i, iLong;
-
- if (ai->argc < 2) {
+static TCHAR *parseLongest(ARGUMENTSINFO *ai)
+{
+ if (ai->argc < 2)
return NULL;
- }
- iLong = 1;
- for (i=2;i<ai->argc;i++) {
- if ( _tcslen(ai->targv[i]) > _tcslen(ai->targv[iLong])) {
+
+ unsigned int iLong = 1;
+ for (unsigned int i=2; i < ai->argc; i++)
+ if ( _tcslen(ai->targv[i]) > _tcslen(ai->targv[iLong]))
iLong = i;
- }
- }
- return mir_tstrdup(ai->targv[iLong]);
-}
-static TCHAR *parseNoOp(ARGUMENTSINFO *ai) {
+ return mir_tstrdup( ai->targv[iLong] );
+}
- if (ai->argc != 2) {
+static TCHAR *parseNoOp(ARGUMENTSINFO *ai)
+{
+ if (ai->argc != 2)
return NULL;
- }
- return mir_tstrdup(ai->targv[1]);
+ return mir_tstrdup( ai->targv[1] );
}
-static TCHAR *parsePad(ARGUMENTSINFO *ai) {
-
- unsigned int addcount, i;
- int padding;
- TCHAR *res, padchar, *cur;
-
+static TCHAR *parsePad(ARGUMENTSINFO *ai)
+{
+ TCHAR padchar;
switch( ai->argc ) {
case 3: padchar = _T(' '); break;
case 4: padchar = *ai->targv[3]; break;
default: return NULL;
}
- padding = ttoi(ai->targv[2]);
+ int padding = ttoi(ai->targv[2]);
if (padding < 0)
return NULL;
- addcount = max(padding - (signed int)_tcslen(ai->targv[1]), 0);
- res = (TCHAR*)mir_alloc((addcount + _tcslen(ai->targv[1]) + 1)*sizeof(TCHAR));
+ unsigned int addcount = max(padding - (signed int)_tcslen(ai->targv[1]), 0);
+ TCHAR *res = (TCHAR*)mir_alloc((addcount + _tcslen(ai->targv[1]) + 1)*sizeof(TCHAR));
if (res == NULL)
return NULL;
ZeroMemory(res, (addcount + _tcslen(ai->targv[1]) + 1)*sizeof(TCHAR));
- cur = res;
- for ( i=0; i < addcount; i++ )
+ TCHAR *cur = res;
+ for ( unsigned int i=0; i < addcount; i++ )
*cur++ = padchar;
_tcscat(res, ai->targv[1]);
return res;
}
-static TCHAR *parsePadright(ARGUMENTSINFO *ai) {
-
- unsigned int addcount, i;
- int padding;
- TCHAR *res, padchar, *cur;
-
+static TCHAR *parsePadright(ARGUMENTSINFO *ai)
+{
+ TCHAR padchar;
switch (ai->argc ) {
case 3: padchar = _T(' '); break;
case 4: padchar = *ai->targv[3]; break;
default: return NULL;
}
- padding = ttoi(ai->targv[2]);
+ int padding = ttoi(ai->targv[2]);
if (padding < 0)
return NULL;
- addcount = max(padding - (signed int)_tcslen(ai->targv[1]), 0);
- res = (TCHAR*)mir_alloc((addcount + _tcslen(ai->targv[1]) + 1)*sizeof(TCHAR));
+ unsigned int addcount = max(padding - (signed int)_tcslen(ai->targv[1]), 0);
+ TCHAR *res = (TCHAR*)mir_alloc((addcount + _tcslen(ai->targv[1]) + 1)*sizeof(TCHAR));
if (res == NULL)
return NULL;
ZeroMemory(res, (addcount + _tcslen(ai->targv[1]) + 1)*sizeof(TCHAR));
_tcscpy(res, ai->targv[1]);
- cur = res + _tcslen(ai->targv[1]);
- for (i=0;i<addcount;i++)
+ TCHAR *cur = res + _tcslen(ai->targv[1]);
+ for (unsigned int i=0; i < addcount; i++)
*cur++ = padchar;
return res;
}
-static TCHAR *parsePadcut(ARGUMENTSINFO *ai) {
-
- int padding, addcount, i;
- TCHAR *res, padchar, *cur;
-
+static TCHAR *parsePadcut(ARGUMENTSINFO *ai)
+{
+ TCHAR padchar;
switch( ai->argc ) {
case 3: padchar = _T(' '); break;
case 4: padchar = *ai->targv[3]; break;
default: return NULL;
}
- padding = ttoi(ai->targv[2]);
+ int padding = ttoi(ai->targv[2]);
if (padding < 0)
return NULL;
- addcount = max(padding - (signed int)_tcslen(ai->targv[1]), 0);
- res = (TCHAR*)mir_alloc((padding + 1)*sizeof(TCHAR));
+ int addcount = max(padding - (signed int)_tcslen(ai->targv[1]), 0);
+ TCHAR *res = (TCHAR*)mir_alloc((padding + 1)*sizeof(TCHAR));
if (res == NULL)
return NULL;
ZeroMemory(res, (padding + 1)*sizeof(TCHAR));
- cur = res;
- for (i=0;i<addcount;i++)
+ TCHAR *cur = res;
+ for (int i=0; i < addcount; i++)
*cur++ = padchar;
if (padding > addcount)
@@ -385,29 +339,27 @@ static TCHAR *parsePadcut(ARGUMENTSINFO *ai) { return res;
}
-static TCHAR *parsePadcutright(ARGUMENTSINFO *ai) {
-
- int padding, addcount, i;
- TCHAR *res, padchar, *cur;
-
+static TCHAR *parsePadcutright(ARGUMENTSINFO *ai)
+{
+ TCHAR padchar;
switch( ai->argc ) {
case 3: padchar = _T(' '); break;
case 4: padchar = *ai->targv[3]; break;
default: return NULL;
}
- padding = ttoi(ai->targv[2]);
+ int padding = ttoi(ai->targv[2]);
if (padding < 0)
return NULL;
- addcount = max(padding - (signed int)_tcslen(ai->targv[1]), 0);
- res = (TCHAR*)mir_alloc((padding + 1)*sizeof(TCHAR));
+ int addcount = max(padding - (signed int)_tcslen(ai->targv[1]), 0);
+ TCHAR *res = (TCHAR*)mir_alloc((padding + 1)*sizeof(TCHAR));
if (res == NULL)
return NULL;
ZeroMemory(res, (padding + 1)*sizeof(TCHAR));
- cur = res + padding - addcount;
- for (i=0; i < addcount; i++ )
+ TCHAR *cur = res + padding - addcount;
+ for (int i=0; i < addcount; i++ )
*cur++ = padchar;
if (padding > addcount )
@@ -416,8 +368,8 @@ static TCHAR *parsePadcutright(ARGUMENTSINFO *ai) { return res;
}
-static TCHAR *parseRepeat(ARGUMENTSINFO *ai) {
-
+static TCHAR *parseRepeat(ARGUMENTSINFO *ai)
+{
TCHAR *res;
unsigned int i, count;
diff --git a/plugins/Variables/variables.cpp b/plugins/Variables/variables.cpp index f5666b4279..9a451fb671 100644 --- a/plugins/Variables/variables.cpp +++ b/plugins/Variables/variables.cpp @@ -541,9 +541,9 @@ int setParseOptions(struct ParseOptions *po) { po = &gParseOpts;
}
ZeroMemory(po, sizeof(struct ParseOptions));
- if (!db_getb(SETTING_STRIPALL, 0)) {
- po->bStripEOL = db_getb(SETTING_STRIPCRLF, 0);
- po->bStripWS = db_getb(SETTING_STRIPWS, 0);
+ if (!db_get_b(NULL, MODULENAME, SETTING_STRIPALL, 0)) {
+ po->bStripEOL = db_get_b(NULL, MODULENAME, SETTING_STRIPCRLF, 0);
+ po->bStripWS = db_get_b(NULL, MODULENAME, SETTING_STRIPWS, 0);
}
else {
po->bStripAll = TRUE;
@@ -607,10 +607,10 @@ int LoadVarModule() log_debugA("Variables: Internal tokens registered");
- if (db_getb(SETTING_PARSEATSTARTUP, 0)) {
+ if (db_get_b(NULL, MODULENAME, SETTING_PARSEATSTARTUP, 0)) {
FORMATINFO fi = { 0 };
fi.cbSize = sizeof(fi);
- fi.tszFormat = db_gets(SETTING_STARTUPTEXT, NULL);
+ fi.tszFormat = db_get_tsa(NULL, MODULENAME, SETTING_STARTUPTEXT);
if (fi.tszFormat != NULL) {
freeMemory((WPARAM)formatString(&fi), 0);
mir_free(fi.tszFormat);
diff --git a/plugins/Variables/variables.h b/plugins/Variables/variables.h index 17de157cf1..68ac51aa3a 100644 --- a/plugins/Variables/variables.h +++ b/plugins/Variables/variables.h @@ -21,6 +21,7 @@ #define MIRANDA_VER 0x0A00
#include <tchar.h>
+#include <malloc.h>
#include <windows.h>
#include <commctrl.h>
@@ -43,11 +44,10 @@ #include <m_utils.h>
#include <m_icolib.h>
#include "m_variables.h"
-//#include "dbhelpers.h"
+
#define MODULENAME "Variables"
-//#define LOGLEVEL __LOGLEVEL_DEBUG
+
#include "../helpers/gen_helpers.h"
-#include "../helpers/db_helpers.h"
#define SETTING_STARTUPTEXT "StartupText"
#define SETTING_STRIPCRLF "StripCRLF"
diff --git a/plugins/helpers/db_helpers.cpp b/plugins/helpers/db_helpers.cpp deleted file mode 100644 index a9e1a2b389..0000000000 --- a/plugins/helpers/db_helpers.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/*
- Helper functions for Miranda-IM (www.miranda-im.org)
- Copyright 2006 P. Boon
-
- This program is mir_free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-#include "db_helpers.h"
-
-struct RemoveSettings{
- char *szPrefix;
- int count;
- char **szSettings;
-};
-
-static int DBRemoveEnumProc(const char *szSetting, LPARAM lParam) {
-
- struct RemoveSettings *rs;
-
- rs = (struct RemoveSettings *)lParam;
- if (!strncmp(szSetting, rs->szPrefix, strlen(rs->szPrefix))) {
- rs->szSettings = ( char** )mir_realloc(rs->szSettings, (rs->count+1)*sizeof(char *));
- rs->szSettings[rs->count] = mir_strdup(szSetting);
- rs->count += 1;
- }
-
- return 0;
-}
-
-int Hlp_RemoveDatabaseSettings(HANDLE hContact, char *szModule, char *szPrefix) {
-
- DBCONTACTENUMSETTINGS dbces;
- struct RemoveSettings rs;
- int i, count;
-
- ZeroMemory(&rs, sizeof(struct RemoveSettings));
- rs.szPrefix = szPrefix;
- ZeroMemory(&dbces, sizeof(DBCONTACTENUMSETTINGS));
- dbces.pfnEnumProc = DBRemoveEnumProc;
- dbces.lParam = (LPARAM)&rs;
- dbces.szModule = szModule;
- if (CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)(HANDLE)hContact, (LPARAM)&dbces) == -1) {
-
- return -1;
- }
- count = 0;
- if (rs.szSettings != NULL) {
- for (i=0;i<rs.count;i++) {
- if (rs.szSettings[i] != NULL) {
- if (!DBDeleteContactSetting(hContact, szModule, rs.szSettings[i])) {
- count += 1;
- }
- mir_free(rs.szSettings[i]);
- }
- }
- mir_free(rs.szSettings);
- }
-
- return count;
-}
diff --git a/plugins/helpers/db_helpers.h b/plugins/helpers/db_helpers.h deleted file mode 100644 index a2d4a4c2ac..0000000000 --- a/plugins/helpers/db_helpers.h +++ /dev/null @@ -1,489 +0,0 @@ -/*
- Helper functions for Miranda-IM (www.miranda-im.org)
- Copyright 2006 P. Boon
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-#ifndef __DB_HELPERS_H
-#define __DB_HELPERS_H
-
-#include "commonheaders.h"
-
-int Hlp_RemoveDatabaseSettings(HANDLE hContact, char *szModule, char *szPrefix);
-
-/* the Hlp_DBGetContactSetting(X)String(Y) functions return a copy in local memory, free it using your own free() */
-#define db_getb(c,d) DBGetContactSettingByte(NULL,MODULENAME,c,d)
-#define db_getw(c,d) DBGetContactSettingWord(NULL,MODULENAME,c,d)
-#define db_getd(c,d) DBGetContactSettingDword(NULL,MODULENAME,c,d)
-#define db_getAs(c,d) Hlp_DBGetContactSettingString(NULL,MODULENAME,c,d)
-#define db_gets(c,d) Hlp_DBGetContactSettingTString(NULL,MODULENAME,c,d)
-#define db_getWs(c,d) Hlp_DBGetContactSettingWString(NULL,MODULENAME,c,d)
-#define db_getUs(c,d) Hlp_DBGetContactSettingStringUtf(NULL,MODULENAME,c,d)
-
-#define db_setb(c,d) DBWriteContactSettingByte(NULL,MODULENAME,c, (BYTE)d)
-#define db_setw(c,d) DBWriteContactSettingWord(NULL,MODULENAME,c, (WORD)d)
-#define db_setd(c,d) DBWriteContactSettingDword(NULL,MODULENAME,c, (DWORD)d)
-#define db_setAs(c,d) DBWriteContactSettingString(NULL,MODULENAME,c,d)
-#define db_sets(c,d) DBWriteContactSettingTString(NULL,MODULENAME,c,d)
-#define db_setWs(c,d) DBWriteContactSettingWString(NULL,MODULENAME,c,d)
-#define db_setUs(c,d) DBWriteContactSettingStringUtf(NULL,MODULENAME,c,d)
-
-#define db_del(c) DBDeleteContactSetting(NULL,MODULENAME,c);
-
-#define dbi_getb(a,b,c) Hlp_DBGetIthSettingByte(a, NULL, MODULENAME, b, c)
-#define dbi_getw(a,b,c) Hlp_DBGetIthSettingWord(a, NULL, MODULENAME, b, c)
-#define dbi_getd(a,b,c) Hlp_DBGetIthSettingDword(a, NULL, MODULENAME, b, c)
-#define dbi_getAs(a,b,c) Hlp_DBGetIthSettingString(a, NULL, MODULENAME, b, c)
-#define dbi_gets(a,b,c) Hlp_DBGetIthSettingTString(a, NULL, MODULENAME, b, c)
-#define dbi_getWs(a,b,c) Hlp_DBGetIthSettingWString(a, NULL, MODULENAME, b, c)
-#define dbi_getUs(a,b,c) Hlp_DBGetIthSettingStringUtf(a, NULL, MODULENAME, b, c)
-
-#define dbi_setb(a,b,c) Hlp_DBWriteIthSettingByte(a, NULL, MODULENAME, b, (BYTE)c)
-#define dbi_setw(a,b,c) Hlp_DBWriteIthSettingWord(a, NULL, MODULENAME, b, (WORD)c)
-#define dbi_setd(a,b,c) Hlp_DBWriteIthSettingDword(a, NULL, MODULENAME, b, (DWORD)c)
-#define dbi_setAs(a,b,c) Hlp_DBWriteIthSettingString(a, NULL, MODULENAME, b, c)
-#define dbi_sets(a,b,c) Hlp_DBWriteIthSettingTString(a, NULL, MODULENAME, b, c)
-#define dbi_setWs(a,b,c) Hlp_DBWriteIthSettingWString(a, NULL, MODULENAME, b, c)
-#define dbi_setUs(a,b,c) Hlp_DBWriteIthSettingStringUtf(a, NULL, MODULENAME, b, c)
-
-#define dbi_del(a,b) Hlp_DBDeleteIthSetting(a, NULL, MODULENAME, b)
-
-#define dbs_getb(a,b,c) Hlp_DBGetXthSettingByte(a, NULL, MODULENAME, b, c)
-#define dbs_getw(a,b,c) Hlp_DBGetXthSettingWord(a, NULL, MODULENAME, b, c)
-#define dbs_getd(a,b,c) Hlp_DBGetXthSettingDword(a, NULL, MODULENAME, b, c)
-#define dbs_getAs(a,b,c) Hlp_DBGetXthSettingString(a, NULL, MODULENAME, b, c)
-#define dbs_gets(a,b,c) Hlp_DBGetXthSettingTString(a, NULL, MODULENAME, b, c)
-#define dbs_getWs(a,b,c) Hlp_DBGetXthSettingWString(a, NULL, MODULENAME, b, c)
-#define dbs_getUs(a,b,c) Hlp_DBGetXthSettingStringUtf(a, NULL, MODULENAME, b, c)
-
-#define dbs_setb(a,b,c) Hlp_DBWriteXthSettingByte(a, NULL, MODULENAME, b, (BYTE)c)
-#define dbs_setw(a,b,c) Hlp_DBWriteXthSettingWord(a, NULL, MODULENAME, b, (WORD)c)
-#define dbs_setd(a,b,c) Hlp_DBWriteXthSettingDword(a, NULL, MODULENAME, b, (DWORD)c)
-#define dbs_setAs(a,b,c) Hlp_DBWriteXthSettingString(a, NULL, MODULENAME, b, c)
-#define dbs_sets(a,b,c) Hlp_DBWriteXthSettingTString(a, NULL, MODULENAME, b, c)
-#define dbs_setWs(a,b,c) Hlp_DBWriteXthSettingWString(a, NULL, MODULENAME, b, c)
-#define dbs_setUs(a,b,c) Hlp_DBWriteXthSettingStringUtf(a, NULL, MODULENAME, b, c)
-
-#define dbs_del(a,b) Hlp_DBDeleteXthSetting(a, NULL, MODULENAME, b)
-
-__inline static char *Hlp_DBGetContactSettingString(HANDLE hContact,const char *szModule,
- const char *szSetting,char *errVal)
-{
- int rc;
- DBCONTACTGETSETTING cgs;
- DBVARIANT dbv = {0};
- char *res;
- cgs.szModule=szModule;
- cgs.szSetting=szSetting;
- cgs.pValue=&dbv;
- dbv.type = DBVT_ASCIIZ;
-
- rc=CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs);
-#if defined(_DEBUG) && defined(DBCHECKSETTINGS)
- if (rc != 0) {
- char buf[128];
- _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting);
- db_msg_dbg(buf);
- }
-#endif
- if (rc == 0) {
- res = _strdup(dbv.pszVal);
- DBFreeVariant(&dbv);
- return res;
- }
- else {
- DBFreeVariant(&dbv);
- return errVal!=NULL?_strdup(errVal):NULL;
- }
-}
-
-__inline static TCHAR *Hlp_DBGetContactSettingTString(HANDLE hContact,const char *szModule,
- const char *szSetting,TCHAR *errVal)
-{
- int rc;
- DBCONTACTGETSETTING cgs;
- DBVARIANT dbv = {0};
- TCHAR *res;
- cgs.szModule=szModule;
- cgs.szSetting=szSetting;
- cgs.pValue=&dbv;
-#if defined(_UNICODE)
- dbv.type = DBVT_WCHAR;
-#else
- dbv.type = DBVT_ASCIIZ;
-#endif
-
- rc=CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs);
-#if defined(_DEBUG) && defined(DBCHECKSETTINGS)
- if (rc != 0) {
- char buf[128];
- _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting);
- db_msg_dbg(buf);
- }
-#endif
- if (rc == 0) {
- res = mir_tstrdup(dbv.ptszVal);
- DBFreeVariant(&dbv);
- return res;
- }
- else {
- DBFreeVariant(&dbv);
- return errVal!=NULL?mir_tstrdup(errVal):NULL;
- }
-}
-
-__inline static WCHAR *Hlp_DBGetContactSettingWString(HANDLE hContact,const char *szModule,
- const char *szSetting,WCHAR *errVal)
-{
- int rc;
- DBCONTACTGETSETTING cgs;
- DBVARIANT dbv = {0};
- WCHAR *res;
- cgs.szModule=szModule;
- cgs.szSetting=szSetting;
- cgs.pValue=&dbv;
- dbv.type = DBVT_WCHAR;
-
- rc=CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs);
-#if defined(_DEBUG) && defined(DBCHECKSETTINGS)
- if (rc != 0) {
- char buf[128];
- _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting);
- db_msg_dbg(buf);
- }
-#endif
- if (rc == 0) {
- res = _wcsdup(dbv.pwszVal);
- DBFreeVariant(&dbv);
- return res;
- }
- else {
- DBFreeVariant(&dbv);
- return errVal!=NULL?_wcsdup(errVal):NULL;
- }
-}
-
-__inline static char *Hlp_DBGetContactSettingStringUtf(HANDLE hContact,const char *szModule,
- const char *szSetting,char *errVal)
-{
- int rc;
- DBCONTACTGETSETTING cgs;
- DBVARIANT dbv = {0};
- char *res;
- cgs.szModule=szModule;
- cgs.szSetting=szSetting;
- cgs.pValue=&dbv;
- dbv.type = DBVT_UTF8;
-
- rc=CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs);
-#if defined(_DEBUG) && defined(DBCHECKSETTINGS)
- if (rc != 0) {
- char buf[128];
- _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting);
- db_msg_dbg(buf);
- }
-#endif
- if (rc == 0) {
- res = _strdup(dbv.pszVal);
- DBFreeVariant(&dbv);
- return res;
- }
- else {
- DBFreeVariant(&dbv);
- return errVal!=NULL?_strdup(errVal):NULL;
- }
-}
-
-#ifndef PREFIX_ITH
-#define PREFIX_ITH ""
-#endif
-
-__inline static int Hlp_DBWriteIthSettingByte(unsigned int i, HANDLE hContact,const char *szModule,const char *szSetting,BYTE val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingByte(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteIthSettingWord(unsigned int i, HANDLE hContact,const char *szModule,const char *szSetting,WORD val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingWord(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteIthSettingDword(unsigned int i, HANDLE hContact,const char *szModule,const char *szSetting,DWORD val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingDword(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteIthSettingString(unsigned int i, HANDLE hContact,const char *szModule,const char *szSetting,const char *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingString(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteIthSettingTString(unsigned int i, HANDLE hContact,const char *szModule,const char *szSetting,const TCHAR *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingTString(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteIthSettingWString(unsigned int i, HANDLE hContact,const char *szModule,const char *szSetting,const WCHAR *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingWString(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteIthSettingStringUtf(unsigned int i, HANDLE hContact,const char *szModule,const char *szSetting,const char *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingStringUtf(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBGetIthSettingByte(unsigned int i, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBGetContactSettingByte(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static WORD Hlp_DBGetIthSettingWord(unsigned int i, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBGetContactSettingWord(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static DWORD Hlp_DBGetIthSettingDword(unsigned int i, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBGetContactSettingDword(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static char *Hlp_DBGetIthSettingString(unsigned int i, HANDLE hContact, const char *szModule, const char *szSetting, char *errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return Hlp_DBGetContactSettingString(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static TCHAR *Hlp_DBGetIthSettingTString(unsigned int i, HANDLE hContact, const char *szModule, const char *szSetting, TCHAR *errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return Hlp_DBGetContactSettingTString(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static WCHAR *Hlp_DBGetIthSettingWString(unsigned int i, HANDLE hContact, const char *szModule, const char *szSetting, WCHAR *errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return Hlp_DBGetContactSettingWString(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static char *Hlp_DBGetIthSettingStringUtf(unsigned int i, HANDLE hContact, const char *szModule, const char *szSetting, char *errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return Hlp_DBGetContactSettingStringUtf(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static int Hlp_DBGetIthSetting(unsigned int i, HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBGetContactSetting(hContact, szModule, dbSetting, dbv);
-}
-
-__inline static int Hlp_DBDeleteIthSetting(unsigned int i, HANDLE hContact,const char *szModule,const char *szSetting) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBDeleteContactSetting(hContact, szModule, dbSetting);
-}
-
-#ifndef PREFIX_XTH
-#define PREFIX_XTH ""
-#endif
-
-__inline static int Hlp_DBWriteXthSettingByte(char *x, HANDLE hContact,const char *szModule,const char *szSetting,BYTE val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBWriteContactSettingByte(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteXthSettingWord(char *x, HANDLE hContact,const char *szModule,const char *szSetting,WORD val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBWriteContactSettingWord(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteXthSettingDword(char *x, HANDLE hContact,const char *szModule,const char *szSetting,DWORD val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBWriteContactSettingDword(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteXthSettingString(char *x, HANDLE hContact,const char *szModule,const char *szSetting,const char *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBWriteContactSettingString(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteXthSettingTString(char *x, HANDLE hContact,const char *szModule,const char *szSetting,const TCHAR *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBWriteContactSettingTString(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteXthSettingWString(char *x, HANDLE hContact,const char *szModule,const char *szSetting,const WCHAR *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBWriteContactSettingWString(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBWriteXthSettingStringUtf(char *x, HANDLE hContact,const char *szModule,const char *szSetting,const char *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBWriteContactSettingStringUtf(hContact, szModule, dbSetting, val);
-}
-
-__inline static int Hlp_DBGetXthSettingByte(char *x, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBGetContactSettingByte(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static WORD Hlp_DBGetXthSettingWord(char *x, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBGetContactSettingWord(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static DWORD Hlp_DBGetXthSettingDword(char *x, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBGetContactSettingDword(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static char *Hlp_DBGetXthSettingString(char *x, HANDLE hContact, const char *szModule, const char *szSetting, char *errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return Hlp_DBGetContactSettingString(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static TCHAR *Hlp_DBGetXthSettingTString(char *x, HANDLE hContact, const char *szModule, const char *szSetting, TCHAR *errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return Hlp_DBGetContactSettingTString(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static WCHAR *Hlp_DBGetXthSettingWString(char *x, HANDLE hContact, const char *szModule, const char *szSetting, WCHAR *errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return Hlp_DBGetContactSettingWString(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static char *Hlp_DBGetXthSettingStringUtf(char *x, HANDLE hContact, const char *szModule, const char *szSetting, char *errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return Hlp_DBGetContactSettingStringUtf(hContact, szModule, dbSetting, errorValue);
-}
-
-__inline static int Hlp_DBGetXthSetting(char *x, HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBGetContactSetting(hContact, szModule, dbSetting, dbv);
-}
-
-__inline static int Hlp_DBDeleteXthSetting(char *x, HANDLE hContact,const char *szModule,const char *szSetting) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%s_%s", PREFIX_XTH, x, szSetting);
- return DBDeleteContactSetting(hContact, szModule, dbSetting);
-}
-
-#endif
|