diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-11-26 18:34:26 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-11-26 18:34:26 +0000 |
commit | a5e0714edc8c7dc20d99957f7587b593e53ffba7 (patch) | |
tree | 43ceac82322f4f69a053849dc98520cfc36dc1d6 | |
parent | 93d6783786b74582dc1451eac4933234b5637144 (diff) |
Sessions: memcpy fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@11103 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 36 | ||||
-rw-r--r-- | plugins/Sessions/Src/Options.cpp | 176 | ||||
-rw-r--r-- | plugins/Sessions/Src/Utils.cpp | 44 |
3 files changed, 128 insertions, 128 deletions
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index eb3e11abb8..92cf5d8b5b 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. HINSTANCE g_hInst = NULL;
-HGENMENU hmSaveCurrentSession, hmLoadLastSession, hmLoadSession, hmSessionsManager;
+HGENMENU hmSaveCurrentSession;
HANDLE hmTBButton[2], hiTBbutton[2], iTBbutton[2];
@@ -61,10 +61,10 @@ PLUGININFOEX pluginInfo = { __AUTHORWEB,
UNICODE_AWARE,
// {60558872-2AAB-45AA-888D-097691C9B683}
- {0x60558872, 0x2aab, 0x45aa, {0x88, 0x8d, 0x9, 0x76, 0x91, 0xc9, 0xb6, 0x83}}
+ { 0x60558872, 0x2aab, 0x45aa, { 0x88, 0x8d, 0x9, 0x76, 0x91, 0xc9, 0xb6, 0x83 } }
};
-IconItem iconList[] =
+IconItem iconList[] =
{
{ LPGEN("Sessions"), "Sessions", IDD_SESSION_CHECKED },
{ LPGEN("Favorite Session"), "SessionMarked", IDD_SESSION_CHECKED },
@@ -114,7 +114,7 @@ INT_PTR CALLBACK ExitDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) return TRUE;
}
-INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
+INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
g_hSDlg = hdlg;
switch (msg) {
@@ -140,7 +140,7 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar switch (((LPNMHDR)lparam)->code) {
case CLN_CHECKCHANGED:
bSC = TRUE;
- memcpy(user_session_list, session_list, SIZEOF(user_session_list));
+ memcpy(user_session_list, session_list, sizeof(user_session_list));
break;
}
}
@@ -213,11 +213,11 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar i++;
}
}
- memcpy(session_list_temp, session_list, SIZEOF(session_list_temp));
- memcpy(session_list, user_session_list, SIZEOF(session_list));
+ memcpy(session_list_temp, session_list, sizeof(session_list_temp));
+ memcpy(session_list, user_session_list, sizeof(session_list));
SaveSessionHandles(0, 1);
SaveUserSessionName(szUserSessionName);
- memcpy(session_list, session_list_temp, SIZEOF(session_list));
+ memcpy(session_list, session_list_temp, sizeof(session_list));
DestroyWindow(hdlg);
g_hSDlg = 0;
}
@@ -322,7 +322,7 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l db_set_b(session_list_recovered[i], MODNAME, "wasInLastSession", 0);
i++;
}
- ZeroMemory(session_list_recovered, SIZEOF(session_list_recovered));
+ ZeroMemory(session_list_recovered, sizeof(session_list_recovered));
g_bIncompletedSave = 0;
EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), FALSE);
@@ -418,7 +418,7 @@ INT_PTR CloseCurrentSession(WPARAM wparam, LPARAM lparam) }
else SendMessage(mwd.hwndWindow, WM_CLOSE, 0, 0);
}
- ZeroMemory(session_list, SIZEOF(session_list));
+ ZeroMemory(session_list, sizeof(session_list));
return 0;
}
@@ -547,7 +547,7 @@ int LoadSession(WPARAM wparam, LPARAM lparam) lparam -= g_ses_limit;
}
if (session_list_recovered[0] && lparam == 256 && mode == 0)
- memcpy(session_list_t, session_list_recovered, SIZEOF(session_list_t));
+ memcpy(session_list_t, session_list_recovered, sizeof(session_list_t));
else
for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (LoadContactsFromMask(hContact, mode, lparam)) {
@@ -575,7 +575,7 @@ int LoadSession(WPARAM wparam, LPARAM lparam) MessageBox(NULL, TranslateT("No contacts to open"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
return 1;
}
-
+
if (dup == i) {
if (!hidden) {
if (g_bOtherWarnings)
@@ -616,7 +616,7 @@ int DelUserDefSession(int ses_count) mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "UserSessionDsc", i - 1);
if (szSessionNameBuf) {
- MarkUserDefSession(i-1, IsMarkedUserDefSession(i));
+ MarkUserDefSession(i - 1, IsMarkedUserDefSession(i));
db_set_ts(NULL, MODNAME, szSessionName, szSessionNameBuf);
}
else {
@@ -643,7 +643,7 @@ int DeleteAutoSession(int ses_count) mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", ses_count);
db_unset(NULL, MODNAME, szSessionName);
- for (int i = ses_count+1;; i++) {
+ for (int i = ses_count + 1;; i++) {
mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i);
ptrT szSessionNameBuf(db_get_tsa(NULL, MODNAME, szSessionName));
@@ -807,18 +807,18 @@ static int PluginInit(WPARAM wparam, LPARAM lparam) cl.pszName = LPGEN("Load session...");
cl.pszService = MS_SESSIONS_OPENMANAGER;
cl.icolibItem = iconList[3].hIcolib;
- hmLoadLastSession = Menu_AddMainMenuItem(&cl);
+ Menu_AddMainMenuItem(&cl);
cl.pszName = LPGEN("Close session");
cl.pszService = MS_SESSIONS_CLOSESESSION;
cl.icolibItem = 0;
- hmLoadSession = Menu_AddMainMenuItem(&cl);
+ Menu_AddMainMenuItem(&cl);
cl.pszName = LPGEN("Load last session");
cl.pszService = MS_SESSIONS_RESTORELASTSESSION;
cl.icolibItem = iconList[5].hIcolib;
cl.position = 10100000;
- hmLoadSession = Menu_AddMainMenuItem(&cl);
+ Menu_AddMainMenuItem(&cl);
ZeroMemory(&cl, sizeof(cl));
cl.cbSize = sizeof(cl);
@@ -884,7 +884,7 @@ extern "C" __declspec(dllexport) int Load(void) if (!session_list_recovered[0])
g_bIncompletedSave = FALSE;
-
+
db_set_b(NULL, MODNAME, "lastSaveCompleted", 0);
if (!db_get_b(NULL, MODNAME, "lastempty", 1) || g_bIncompletedSave)
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index 8ac6acb967..e15609f625 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -128,11 +128,11 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break;
case WM_NCCALCSIZE:
- {
- NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
- ncsParam->rgrc[0].right -= 16;
- }
- break;
+ {
+ NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
+ ncsParam->rgrc[0].right -= 16;
+ }
+ break;
case WM_NCHITTEST:
LRESULT lr = mir_callNextSubclass(hwnd, ComboBoxSubclassProc, msg, wParam, lParam);
@@ -143,9 +143,9 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return mir_callNextSubclass(hwnd, ComboBoxSubclassProc, msg, wParam, lParam);
}
-static INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
-{
- switch(msg) {
+static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hdlg);
{
@@ -240,34 +240,34 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar case WM_NOTIFY:
switch (((LPNMHDR)lparam)->code) {
case PSN_APPLY:
- {
- int iDelay = GetDlgItemInt(hdlg, IDC_STARTDELAY, NULL, FALSE);
- db_set_w(0, MODNAME, "StartupModeDelay", (WORD)iDelay);
- db_set_b(0, MODNAME, "TrackCount", (BYTE)(g_ses_limit = GetDlgItemInt(hdlg, IDC_TRACK, NULL, FALSE)));
- if (IsDlgButtonChecked(hdlg, IDC_REXSAVE))
- db_set_b(NULL, MODNAME, "ShutdownMode", 2);
- else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE))
- db_set_b(NULL, MODNAME, "ShutdownMode", 0);
- else if (IsDlgButtonChecked(hdlg, IDC_REXASK))
- db_set_b(NULL, MODNAME, "ShutdownMode", 1);
-
- if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) {
- if (!IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
- db_set_b(NULL, MODNAME, "StartupMode", 1);
- else
- db_set_b(NULL, MODNAME, "StartupMode", 3);
- }
- else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST))
- db_set_b(NULL, MODNAME, "StartupMode", 2);
- else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING))
- db_set_b(NULL, MODNAME, "StartupMode", 0);
-
- db_set_b(NULL, MODNAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
- db_set_b(NULL, MODNAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
- db_set_b(NULL, MODNAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
- db_set_b(NULL, MODNAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
+ {
+ int iDelay = GetDlgItemInt(hdlg, IDC_STARTDELAY, NULL, FALSE);
+ db_set_w(0, MODNAME, "StartupModeDelay", (WORD)iDelay);
+ db_set_b(0, MODNAME, "TrackCount", (BYTE)(g_ses_limit = GetDlgItemInt(hdlg, IDC_TRACK, NULL, FALSE)));
+ if (IsDlgButtonChecked(hdlg, IDC_REXSAVE))
+ db_set_b(NULL, MODNAME, "ShutdownMode", 2);
+ else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE))
+ db_set_b(NULL, MODNAME, "ShutdownMode", 0);
+ else if (IsDlgButtonChecked(hdlg, IDC_REXASK))
+ db_set_b(NULL, MODNAME, "ShutdownMode", 1);
+
+ if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) {
+ if (!IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
+ db_set_b(NULL, MODNAME, "StartupMode", 1);
+ else
+ db_set_b(NULL, MODNAME, "StartupMode", 3);
}
- return 1;
+ else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST))
+ db_set_b(NULL, MODNAME, "StartupMode", 2);
+ else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING))
+ db_set_b(NULL, MODNAME, "StartupMode", 0);
+
+ db_set_b(NULL, MODNAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
+ db_set_b(NULL, MODNAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
+ db_set_b(NULL, MODNAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
+ db_set_b(NULL, MODNAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
+ }
+ return 1;
case CLN_CHECKCHANGED:
if (((LPNMHDR)lparam)->idFrom == IDC_EMCLIST) {
@@ -294,38 +294,38 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar break;
case CBN_SELCHANGE:
- {
- HWND hCombo = GetDlgItem(hdlg, IDC_LIST);
- int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
- if (index != CB_ERR) {
- opses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0);
- SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
- if (IsMarkedUserDefSession(opses_count)) {
- hIcon = hMarked;
- bChecked = TRUE;
- RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
- }
- else {
- hIcon = hNotMarked;
- bChecked = FALSE;
- RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
- }
- OpLoadSessionContacts(0, opses_count);
- if (!hOpClistControl)
- EnableWindow(GetDlgItem(hdlg, IDC_DEL), TRUE);
- else {
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 0);
-
- for (int i = 0; session_list_t[i] > 0; i++) {
- MCONTACT hContact = (MCONTACT)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
- SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 1);
- }
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
+ {
+ HWND hCombo = GetDlgItem(hdlg, IDC_LIST);
+ int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
+ if (index != CB_ERR) {
+ opses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0);
+ SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
+ if (IsMarkedUserDefSession(opses_count)) {
+ hIcon = hMarked;
+ bChecked = TRUE;
+ RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
+ }
+ else {
+ hIcon = hNotMarked;
+ bChecked = FALSE;
+ RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
+ }
+ OpLoadSessionContacts(0, opses_count);
+ if (!hOpClistControl)
+ EnableWindow(GetDlgItem(hdlg, IDC_DEL), TRUE);
+ else {
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 0);
+
+ for (int i = 0; session_list_t[i] > 0; i++) {
+ MCONTACT hContact = (MCONTACT)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
+ SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 1);
}
+ EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
}
}
}
+ }
break;
case IDC_EDIT:
@@ -360,34 +360,34 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar break;
case IDC_SAVE:
- {
- int i = 0;
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- BYTE res = (BYTE)SendMessage(GetDlgItem(hdlg, IDC_EMCLIST), CLM_GETCHECKMARK,
- SendMessage(GetDlgItem(hdlg, IDC_EMCLIST), CLM_FINDCONTACT, hContact, 0), 0);
- if (res) {
- SetSessionMark(hContact, 1, '1', opses_count);
- SetInSessionOrder(hContact, 1, opses_count, i);
- i++;
- }
- else {
- SetSessionMark(hContact, 1, '0', opses_count);
- SetInSessionOrder(hContact, 1, opses_count, 0);
- }
+ {
+ int i = 0;
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ BYTE res = (BYTE)SendMessage(GetDlgItem(hdlg, IDC_EMCLIST), CLM_GETCHECKMARK,
+ SendMessage(GetDlgItem(hdlg, IDC_EMCLIST), CLM_FINDCONTACT, hContact, 0), 0);
+ if (res) {
+ SetSessionMark(hContact, 1, '1', opses_count);
+ SetInSessionOrder(hContact, 1, opses_count, i);
+ i++;
}
- if (bSesssionNameChanged) {
- if (GetWindowTextLength(hComboBoxEdit)) {
- TCHAR szUserSessionName[MAX_PATH] = { '\0' };
- GetWindowText(hComboBoxEdit, szUserSessionName, SIZEOF(szUserSessionName));
- RenameUserDefSession(opses_count, szUserSessionName);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
- LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", 0);
- }
- bSesssionNameChanged = FALSE;
+ else {
+ SetSessionMark(hContact, 1, '0', opses_count);
+ SetInSessionOrder(hContact, 1, opses_count, 0);
}
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
}
- break;
+ if (bSesssionNameChanged) {
+ if (GetWindowTextLength(hComboBoxEdit)) {
+ TCHAR szUserSessionName[MAX_PATH] = { '\0' };
+ GetWindowText(hComboBoxEdit, szUserSessionName, SIZEOF(szUserSessionName));
+ RenameUserDefSession(opses_count, szUserSessionName);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
+ LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", 0);
+ }
+ bSesssionNameChanged = FALSE;
+ }
+ EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
+ }
+ break;
case IDC_DEL:
DelUserDefSession(opses_count);
diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp index 8a738cd970..18605152d3 100644 --- a/plugins/Sessions/Src/Utils.cpp +++ b/plugins/Sessions/Src/Utils.cpp @@ -51,8 +51,8 @@ void AddSessionMark(MCONTACT hContact, int mode, char bit) char temp_1 = pszBuffer[0];
for (int i = 0; i < g_ses_count; i++) {
- char temp_2 = pszBuffer[i+1];
- pszBuffer[i+1] = temp_1;
+ char temp_2 = pszBuffer[i + 1];
+ pszBuffer[i + 1] = temp_1;
temp_1 = temp_2;
}
pszBuffer[0] = bit;
@@ -73,7 +73,7 @@ void RemoveSessionMark(MCONTACT hContact, int mode, int marknum) ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
if (szValue) {
for (int i = marknum; i < g_ses_limit; i++)
- szValue[i] = szValue[i+1];
+ szValue[i] = szValue[i + 1];
for (int i = g_ses_limit; i < 10; i++)
szValue[i] = '0';
@@ -85,7 +85,7 @@ void RemoveSessionMark(MCONTACT hContact, int mode, int marknum) ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks"));
if (szValue) {
for (int i = marknum; i < g_ses_limit; i++)
- szValue[i] = szValue[i+1];
+ szValue[i] = szValue[i + 1];
db_set_s(hContact, MODNAME, "UserSessionsMarks", szValue);
}
@@ -138,12 +138,12 @@ void AddInSessionOrder(MCONTACT hContact, int mode, int ordernum, int writemode) if (!len)
len = 20;
- char *temp2 = (char*)_alloca(len-1);
- strncpy(temp2, szValue, len-2);
- temp2[len-2]='\0';
+ char *temp2 = (char*)_alloca(len - 1);
+ strncpy(temp2, szValue, len - 2);
+ temp2[len - 2] = '\0';
- char *temp = (char*)_alloca(len+1);
- mir_snprintf(temp, len+1, "%02u%s", ordernum, temp2);
+ char *temp = (char*)_alloca(len + 1);
+ mir_snprintf(temp, len + 1, "%02u%s", ordernum, temp2);
for (int i = (g_ses_limit * 2); i < 20; i++)
temp[i] = '0';
@@ -168,8 +168,8 @@ void AddInSessionOrder(MCONTACT hContact, int mode, int ordernum, int writemode) int len = (int)strlen(pszBuffer);
len = (len == 0) ? 20 : len + 2;
- char *temp = (char*)_alloca(len+1);
- mir_snprintf(temp, len+1, "%02u%s", ordernum, szValue);
+ char *temp = (char*)_alloca(len + 1);
+ mir_snprintf(temp, len + 1, "%02u%s", ordernum, szValue);
db_set_s(hContact, MODNAME, "UserSessionsOrder", temp);
mir_free(pszBuffer);
@@ -187,14 +187,14 @@ int GetInSessionOrder(MCONTACT hContact, int mode, int count) if (mode == 0) {
ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsOrder"));
if (szValue) {
- strncpy_s(szTemp, &szValue[count*2], 2);
+ strncpy_s(szTemp, &szValue[count * 2], 2);
return atoi(szTemp);
}
}
else if (mode == 1) {
ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder"));
if (szValue) {
- strncpy_s(szTemp, &szValue[count*2], 2);
+ strncpy_s(szTemp, &szValue[count * 2], 2);
return atoi(szTemp);
}
}
@@ -204,23 +204,23 @@ int GetInSessionOrder(MCONTACT hContact, int mode, int count) void SetInSessionOrder(MCONTACT hContact, int mode, int count, unsigned int ordernum)
{
int iOrder = 0;
-
+
char szTemp[3];
mir_snprintf(szTemp, SIZEOF(szTemp), "%02u", ordernum);
if (mode == 0) {
ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsOrder"));
if (szValue) {
- szValue[count*2] = szTemp[0];
- szValue[count*2 + 1] = szTemp[1];
+ szValue[count * 2] = szTemp[0];
+ szValue[count * 2 + 1] = szTemp[1];
db_set_s(hContact, MODNAME, "LastSessionsOrder", szValue);
}
}
else if (mode == 1) {
ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder"));
if (szValue) {
- szValue[count*2] = szTemp[0];
- szValue[count*2 + 1] = szTemp[1];
+ szValue[count * 2] = szTemp[0];
+ szValue[count * 2 + 1] = szTemp[1];
db_set_s(hContact, MODNAME, "UserSessionsOrder", szValue);
}
}
@@ -285,7 +285,7 @@ int DelFromCurSession(MCONTACT wparam, LPARAM lparam) int CheckForDuplicate(MCONTACT contact_list[], MCONTACT lparam)
{
MCONTACT s_list[255] = { 0 };
- memcpy(s_list, contact_list, SIZEOF(s_list));
+ memcpy(s_list, contact_list, sizeof(s_list));
for (int i = 0;; i++) {
if (s_list[i] == lparam)
return i;
@@ -301,7 +301,7 @@ int LoadSessionToCombobox(HWND hdlg, BOOL mode, int iLimit, char* pszSetting, in char szBuffer[256] = { 0 };
if (session_list_recovered[0] && !iFirstNum && !mode) {
index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)TranslateT("Session Before Last Crash"));
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, index, 256);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, 256);
}
for (int i = 0; i < iLimit; i++) {
@@ -310,11 +310,11 @@ int LoadSessionToCombobox(HWND hdlg, BOOL mode, int iLimit, char* pszSetting, in if (pszBuffer) {
if (!IsMarkedUserDefSession(i + iFirstNum) || mode == 1) {
index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)pszBuffer);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, i + iFirstNum);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, (LPARAM)(i + iFirstNum));
}
else {
SendDlgItemMessage(hdlg, IDC_LIST, CB_INSERTSTRING, 0, (LPARAM)pszBuffer);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, 0, i + iFirstNum);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, 0, (LPARAM)(i + iFirstNum));
}
mir_free(pszBuffer);
}
|