diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-07-25 20:15:05 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-07-25 20:15:05 +0000 |
commit | 9d32b9cd791fb5f51dad17567152c70a8511a500 (patch) | |
tree | fd7aa3250ed409e720f26c341c0a5d736ed8083c /plugins/Non-IM Contact | |
parent | 125a25c86eed41352d45eb8fb6f994f65700c3ec (diff) |
replace sprintf to mir_snprintf (part 6)
git-svn-id: http://svn.miranda-ng.org/main/trunk@5485 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Non-IM Contact')
-rw-r--r-- | plugins/Non-IM Contact/src/contactinfo.cpp | 31 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/dialog.cpp | 8 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/files.cpp | 36 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/http.cpp | 2 |
4 files changed, 39 insertions, 38 deletions
diff --git a/plugins/Non-IM Contact/src/contactinfo.cpp b/plugins/Non-IM Contact/src/contactinfo.cpp index 36fdb3c339..daf3f96ce4 100644 --- a/plugins/Non-IM Contact/src/contactinfo.cpp +++ b/plugins/Non-IM Contact/src/contactinfo.cpp @@ -157,7 +157,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP /* group*/
while (i != -1) {
char str[3];
- wsprintfA(str, "%d", i);
+ mir_snprintf(str, SIZEOF(str), "%d", i);
if (!db_get_ts(NULL, "CListGroups", str, &dbv)) {
SendMessage(GetDlgItem(hwnd, IDC_GROUP), CB_INSERTSTRING,0, LPARAM(dbv.ptszVal+1));
db_free(&dbv);
@@ -186,7 +186,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP if (!db_get_w(NULL, MODNAME ,"Timer", 1))
SetDlgItemTextA(hwnd,IDC_TIMER_INTERVAL_MSG, "Non-IM Contact protocol timer is Disabled");
else {
- _snprintf(string, sizeof(string), "Timer intervals... Non-IM Contact Protocol timer is %d seconds",db_get_w(NULL, MODNAME ,"Timer", 1));
+ mir_snprintf(string, sizeof(string), "Timer intervals... Non-IM Contact Protocol timer is %d seconds",db_get_w(NULL, MODNAME ,"Timer", 1));
SetDlgItemTextA(hwnd,IDC_TIMER_INTERVAL_MSG, string);
}
}
@@ -233,7 +233,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP {
char szFileName[512];
if (BrowseForFolder(hwnd, szFileName)) {
- wsprintfA(szFileName, "%s ,/e", szFileName);
+ mir_snprintf(szFileName, SIZEOF(szFileName), "%s ,/e", szFileName);
SetDlgItemTextA(hwnd, IDC_LINK, "explorer.exe");
SetDlgItemTextA(hwnd, IDC_PARAMS, szFileName);
}
@@ -595,8 +595,9 @@ INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam) }
else if (contactDone && !strcmp(line,"[/Non-IM Contact]\r\n")) {
if (!name) continue;
- char *msg = (char*)malloc(strlen(name) + strlen("Do you want to import this Non-IM Contact?\r\n\r\nName: \r\n") + 1);
- wsprintfA(msg, "Do you want to import this Non-IM Contact?\r\n\r\nName: %s\r\n", name);
+ int size = strlen(name) + strlen("Do you want to import this Non-IM Contact?\r\n\r\nName: \r\n") + 1;
+ char *msg = (char*)malloc(size);
+ mir_snprintf(msg, size, "Do you want to import this Non-IM Contact?\r\n\r\nName: %s\r\n", name);
if (program) {
msg = (char*)realloc(msg, strlen(msg) + strlen(program) +strlen("Program: \r\n") +1);
strcat(msg, "Program: ");
@@ -624,23 +625,23 @@ INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam) if (icon) {
char tmp[64];
if (icon == ID_STATUS_ONLINE)
- wsprintfA(tmp, "Icon: Online\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: Online\r\n");
else if (icon == ID_STATUS_AWAY)
- wsprintfA(tmp, "Icon: Away\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: Away\r\n");
else if (icon == ID_STATUS_NA)
- wsprintfA(tmp, "Icon: NA\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: NA\r\n");
else if (icon == ID_STATUS_DND)
- wsprintfA(tmp, "Icon: DND\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: DND\r\n");
else if (icon == ID_STATUS_OCCUPIED)
- wsprintfA(tmp, "Icon: Occupied\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: Occupied\r\n");
else if (icon == ID_STATUS_FREECHAT)
- wsprintfA(tmp, "Icon: Free For Chat\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: Free For Chat\r\n");
else if (icon == ID_STATUS_INVISIBLE)
- wsprintfA(tmp, "Icon: Invisible\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: Invisible\r\n");
else if (icon == ID_STATUS_ONTHEPHONE)
- wsprintfA(tmp, "Icon: On The Phone\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: On The Phone\r\n");
else if (icon == ID_STATUS_OUTTOLUNCH)
- wsprintfA(tmp, "Icon: Out To Lunch\r\n");
+ mir_snprintf(tmp, SIZEOF(tmp), "Icon: Out To Lunch\r\n");
msg = (char*)realloc(msg, strlen(msg) + strlen(tmp) +1);
strcat(msg,tmp);
}
@@ -649,7 +650,7 @@ INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam) if (minutes)
strcpy(tmp2,"Minutes");
else strcpy(tmp2,"Seconds");
- wsprintfA(tmp, "UseTimer: Yes\r\nTimer: %d %s",timer, tmp2);
+ mir_snprintf(tmp, SIZEOF(tmp), "UseTimer: Yes\r\nTimer: %d %s",timer, tmp2);
msg = (char*)realloc(msg, strlen(msg) + strlen(tmp) +1);
strcat(msg,tmp);
}
diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp index 168caa6482..c457ab1ed6 100644 --- a/plugins/Non-IM Contact/src/dialog.cpp +++ b/plugins/Non-IM Contact/src/dialog.cpp @@ -191,15 +191,15 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP GetDlgItemTextA(hwnd, IDC_STRING, str2replace, MAX_STRING_LENGTH);
switch (stringReplacer(str2replace, replacedString, NULL)) {
case ERROR_NO_LINE_AFTER_VAR_F:
- wsprintfA(replacedString, "ERROR: no %s","%line or %wholeline or %lastline after %fn");
+ mir_snprintf(replacedString, SIZEOF(replacedString), "ERROR: no %s","%line or %wholeline or %lastline after %fn");
error = 1;
break;
case ERROR_LINE_NOT_READ:
- wsprintfA(replacedString, "ERROR: file couldnt be opened ");
+ mir_snprintf(replacedString, SIZEOF(replacedString), "ERROR: file couldnt be opened ");
error = 1;
break;
case ERROR_NO_FILE:
- wsprintfA(replacedString, "ERROR: no file specified in settings");
+ mir_snprintf(replacedString, SIZEOF(replacedString), "ERROR: no file specified in settings");
error = 1;
break;
default:
@@ -298,7 +298,7 @@ void DoPropertySheet(HANDLE hContact, HINSTANCE hInst) psh.hInstance = hInst;
psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN);
db_get_static(hContact, MODNAME, "Nick", nick);
- wsprintfA(title, "Edit Non-IM Contact \"%s\"", nick);
+ mir_snprintf(title, SIZEOF(title), "Edit Non-IM Contact \"%s\"", nick);
psh.pszCaption = title;
psh.nPages = SIZEOF(psp);
psh.ppsp = (LPCPROPSHEETPAGEA)&psp;
diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp index d559fc6df8..fc3174e7ad 100644 --- a/plugins/Non-IM Contact/src/files.cpp +++ b/plugins/Non-IM Contact/src/files.cpp @@ -77,7 +77,7 @@ void reloadFiles(HWND fileList) SendMessage(fileList,CB_RESETCONTENT, 0,0);
for (i=0; ;i++)
{
- wsprintfA(fn, "fn%d", i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
if (db_get_static(NULL, MODNAME, fn, file)) {
index = SendMessageA(fileList, CB_ADDSTRING,0, (LPARAM)(char*)file);
SendMessage(fileList, CB_SETITEMDATA, index, (LPARAM)(int)i);
@@ -108,14 +108,14 @@ void readFile(HWND hwnd) char temp[MAX_STRING_LENGTH], szFileName[512], temp1[MAX_STRING_LENGTH], fn[8];
FILE* filen;
int fileNumber = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0,0);
- wsprintfA(fn, "fn%d", fileNumber);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", fileNumber);
if (!db_get_static(NULL, MODNAME, fn, szFileName)) {
msg(Translate("File couldn't be opened"),fn);
return;
}
if ( (!strncmp("http://", szFileName, strlen("http://"))) || (!strncmp("https://", szFileName, strlen("https://"))) )
- wsprintfA(szFileName,"%s\\plugins\\fn%d.html",getMimDir(temp), fileNumber);
+ mir_snprintf(szFileName, SIZEOF(szFileName), "%s\\plugins\\fn%d.html", getMimDir(temp), fileNumber);
filen = fopen(szFileName,"r");
if (!filen) {
@@ -132,7 +132,7 @@ void readFile(HWND hwnd) else if (temp[strlen(temp)-1]=='\n')
temp[strlen(temp)-1]='\0';
else temp[strlen(temp)]='\0';
- wsprintfA( temp1, Translate("line(%-3d) = | %s"), lineNumber, temp);
+ mir_snprintf(temp1, SIZEOF(temp1), Translate("line(%-3d) = | %s"), lineNumber, temp);
SendMessageA(GetDlgItem(hwnd, IDC_FILE_CONTENTS),LB_ADDSTRING,0,(LPARAM)(char*)temp1);
lineNumber++;
fileLength++;
@@ -154,7 +154,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) char fn[MAX_PATH], string[MAX_STRING_LENGTH], tmp[MAX_STRING_LENGTH];
reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
int i = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0 ,0);
- wsprintfA(fn , "fn%d", i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
SendMessage(GetDlgItem(hwnd, IDC_FILE_CONTENTS),LB_RESETCONTENT, 0,0);
if (db_get_static(NULL, MODNAME, fn, string) )
{
@@ -189,14 +189,14 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
for (i=0; ;i++)
{
- wsprintfA(fn, "fn%d", i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
if (!db_get_static(NULL, MODNAME, fn, text))
break;
}
- wsprintfA(szFileName,"%s\\plugins\\%s.html",getMimDir(temp), fn);
+ mir_snprintf(szFileName, SIZEOF(szFileName), "%s\\plugins\\%s.html", getMimDir(temp), fn);
if (savehtml(szFileName))
{
- wsprintfA(fn, "fn%d", i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
db_set_s(NULL, MODNAME, fn, url);
if (!GetWindowTextLength(GetDlgItem(hwnd,IDC_WWW_TIMER)))
timer = 60;
@@ -222,7 +222,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) char file[MAX_PATH], fn[6];
for (i=0; ;i++)
{
- wsprintfA(fn, "fn%d", i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
if (!db_get_static(NULL, MODNAME, fn, file))
break;
}
@@ -233,7 +233,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_SETITEMDATA,index,(LPARAM)(int)i);
SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_SETCURSEL, index ,0);
SetDlgItemTextA(hwnd, IDC_FN, _itoa(i, fn, 10));
- wsprintfA(fn , "fn%d", index);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", index);
readFile(hwnd);
}
@@ -246,7 +246,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int count = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCOUNT, 0,0) -1;
if (index == count)
{
- wsprintfA(fn, "fn%d", index);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", index);
db_unset(NULL, MODNAME, fn);
SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_DELETESTRING, index ,0);
SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
@@ -258,14 +258,14 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) }
else
{
- wsprintfA(fn, "fn%d", i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
while (db_get_static(NULL, MODNAME, fn,tmp))
{
- wsprintfA(fn1, "fn%d", i-1);
+ mir_snprintf(fn1, SIZEOF(fn1), "fn%d", i-1);
db_set_s(NULL, MODNAME, fn1 , tmp);
- wsprintfA(fn, "fn%d", ++i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", ++i);
}
- wsprintfA(fn, "fn%d", --i);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", --i);
db_unset(NULL, MODNAME, fn);
SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_DELETESTRING, index ,0);
SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
@@ -281,7 +281,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int index = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0,0);
char fn[6], tmp[MAX_PATH];
SetDlgItemTextA(hwnd, IDC_FN, _itoa(index, fn, 10));
- wsprintfA(fn, "fn%d", index);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", index);
if (db_get_static(NULL, MODNAME, fn, tmp) )
{
if (!strncmp("http://", tmp, strlen("http://")) || !strncmp("https://", tmp, strlen("https://")))
@@ -311,8 +311,8 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case PSN_APPLY:
int i = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0 ,0);
int timer;
- char fn[MAX_PATH], string[1000];;
- wsprintfA(fn , "fn%d", i);
+ char fn[MAX_PATH], string[1000];
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
if (GetWindowTextLength(GetDlgItem(hwnd,IDC_WWW_TIMER))) {
char text[5];
GetDlgItemTextA(hwnd,IDC_WWW_TIMER,text,sizeof(text));
diff --git a/plugins/Non-IM Contact/src/http.cpp b/plugins/Non-IM Contact/src/http.cpp index 502d34e585..f4b8b006d8 100644 --- a/plugins/Non-IM Contact/src/http.cpp +++ b/plugins/Non-IM Contact/src/http.cpp @@ -70,7 +70,7 @@ int InternetDownloadFile (CHAR *szUrl) if (!lstrcmpA(nlhrReply->headers[i].szName, "Location")) {
szData = (char *)malloc(512);
// add "Moved/Location:" in front of the new URL for identification
- wsprintfA(szData, "Moved/Location: %s\n", nlhrReply->headers[i].szValue);
+ mir_snprintf(szData, 512, "Moved/Location: %s\n", nlhrReply->headers[i].szValue);
break;
}
}
|