diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-07-25 15:32:06 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-07-25 15:32:06 +0000 |
commit | a757184e5db3112d3de0b69eec7d39b937e396bc (patch) | |
tree | e903787b3ca3af22a4d95ddf757e178b23da8619 /plugins/Weather | |
parent | 33ebc5347bee5432ca63efb330acdd5a3b82f3fd (diff) |
replace sprintf to mir_snprintf (part 5)
git-svn-id: http://svn.miranda-ng.org/main/trunk@5481 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Weather')
-rw-r--r-- | plugins/Weather/src/weather_addstn.cpp | 12 | ||||
-rw-r--r-- | plugins/Weather/src/weather_contacts.cpp | 6 | ||||
-rw-r--r-- | plugins/Weather/src/weather_conv.cpp | 40 | ||||
-rw-r--r-- | plugins/Weather/src/weather_data.cpp | 4 | ||||
-rw-r--r-- | plugins/Weather/src/weather_http.cpp | 2 | ||||
-rw-r--r-- | plugins/Weather/src/weather_svcs.cpp | 4 | ||||
-rw-r--r-- | plugins/Weather/src/weather_update.cpp | 12 |
7 files changed, 40 insertions, 40 deletions
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index cc51c71e26..25e95846e6 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -110,7 +110,7 @@ INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam) opt.DefStn = hContact;
if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
// notification message box
- wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
@@ -309,7 +309,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR * // replace spaces with %20
char loc[256];
ptrA szSearchName( mir_utf8encodeT(name));
- wsprintfA(loc, sData->SearchURL, ptrA( mir_urlEncode(szSearchName)));
+ mir_snprintf(loc, SIZEOF(loc), sData->SearchURL, ptrA( mir_urlEncode(szSearchName)));
if (InternetDownloadFile(loc, NULL, &szData) == 0) {
TCHAR* szInfo = szData;
search = _tcsstr(szInfo, sData->NotFoundStr); // determine if data is available
@@ -322,14 +322,14 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR * // if station ID appears first in the downloaded data
if ( !_tcsicmp(sData->Single.First, _T("ID"))) {
GetDataValue(&sData->Single.ID, str, &szInfo);
- wsprintf(sID, _T("%s/%s"), svc, str);
+ mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
GetDataValue(&sData->Single.Name, Name, &szInfo);
}
// if station name appears first in the downloaded data
else if ( !_tcsicmp(sData->Single.First, _T("NAME"))) {
GetDataValue(&sData->Single.Name, Name, &szInfo);
GetDataValue(&sData->Single.ID, str, &szInfo);
- wsprintf(sID, _T("%s/%s"), svc, str);
+ mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
}
// if no station ID is obtained, quit the search
if (str[0] == 0) {
@@ -360,14 +360,14 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR * // if station ID appears first in the downloaded data
if ( !_tcsicmp(sData->Multiple.First, _T("ID"))) {
GetDataValue(&sData->Multiple.ID, str, &szInfo);
- wsprintf(sID, _T("%s/%s"), svc, str);
+ mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
GetDataValue(&sData->Multiple.Name, Name, &szInfo);
}
// if station name appears first in the downloaded data
else if ( !_tcsicmp(sData->Multiple.First, _T("NAME"))) {
GetDataValue(&sData->Multiple.Name, Name, &szInfo);
GetDataValue(&sData->Multiple.ID, str, &szInfo);
- wsprintf(sID, _T("%s/%s"), svc, str);
+ mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
}
// if no station ID is obtained, search completed and quit the search
if (str[0] == 0) break;
diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp index 2cc4187bf1..44df9e7386 100644 --- a/plugins/Weather/src/weather_contacts.cpp +++ b/plugins/Weather/src/weather_contacts.cpp @@ -30,7 +30,7 @@ static void OpenUrl( TCHAR* format, TCHAR* id ) TCHAR loc[512];
GetID( id );
- mir_sntprintf( loc, SIZEOF(loc), format, id );
+ mir_sntprintf(loc, SIZEOF(loc), format, id);
CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)loc );
}
@@ -260,7 +260,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa TCHAR *szData = NULL;
// load the page
- wsprintfA(loc, sData->IDSearch.SearchURL, str);
+ mir_snprintf(loc, SIZEOF(loc), sData->IDSearch.SearchURL, str);
str[0] = 0;
if (InternetDownloadFile(loc, NULL, &szData) == 0) {
TCHAR *szInfo = szData;
@@ -370,7 +370,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa }
GetDlgItemText(hwndDlg, IDC_NAME, city, SIZEOF(city));
db_set_ts(hContact, WEATHERPROTONAME, "Nick", city);
- wsprintf(str2, TranslateT("Current weather information for %s."), city);
+ mir_sntprintf(str2, SIZEOF(str2), TranslateT("Current weather information for %s."), city);
if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) {
GetDlgItemText(hwndDlg, IDC_LOG, str, SIZEOF(str));
db_set_ts(hContact, WEATHERPROTONAME, "Log", str);
diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp index 565def07cb..a86ac070c4 100644 --- a/plugins/Weather/src/weather_conv.cpp +++ b/plugins/Weather/src/weather_conv.cpp @@ -65,9 +65,9 @@ static void numToStr(double num, TCHAR* str) if (i < 0 && (w || r)) *(str++) = '-';
if (r)
- wsprintf(str, _T("%i.%i"), w, r);
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i"), w, r);
else
- wsprintf(str, _T("%i"), w);
+ mir_sntprintf(str, SIZEOF(str), _T("%i"), w);
}
//============ UNIT CONVERSIONS ============
@@ -109,17 +109,17 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str) // rounding
numToStr((temp-32)/9*5, tstr);
if (opt.DoNotAppendUnit)
- wsprintf(str, _T("%s"), tstr);
+ mir_sntprintf(str, SIZEOF(str), _T("%s"), tstr);
else
- wsprintf(str, _T("%s%sC"), tstr, opt.DegreeSign);
+ mir_sntprintf(str, SIZEOF(str), _T("%s%sC"), tstr, opt.DegreeSign);
break;
case 2:
numToStr(temp, tstr);
if (opt.DoNotAppendUnit)
- wsprintf(str, _T("%s"), tstr);
+ mir_sntprintf(str, SIZEOF(str), _T("%s"), tstr);
else
- wsprintf(str, _T("%s%sF"), tstr, opt.DegreeSign);
+ mir_sntprintf(str, SIZEOF(str), _T("%s%sF"), tstr, opt.DegreeSign);
break;
}
}
@@ -160,19 +160,19 @@ void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str) switch (opt.pUnit) {
case 1:
intunit = (int)(tempunit + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
break;
case 2:
intunit = (int)(tempunit + 0.5);
- wsprintf(str, _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb"));
break;
case 3:
intunit = (int)((tempunit*10 / 33.86388) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
break;
case 4:
intunit = (int)((tempunit*10 / 1.33322) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
break;
default:
_tcscpy(str, tempchar);
@@ -213,19 +213,19 @@ void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.wUnit) {
case 1:
numToStr(tempunit * 3.6, tstr);
- wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h"));
+ mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h"));
break;
case 2:
numToStr(tempunit, tstr);
- wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s"));
+ mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s"));
break;
case 3:
numToStr(tempunit / 0.44704, tstr);
- wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph"));
+ mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph"));
break;
case 4:
numToStr(tempunit / 0.514444, tstr);
- wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots"));
+ mir_sntprintf(str, SIZEOF(str), _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots"));
break;
}
}
@@ -258,11 +258,11 @@ void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.vUnit) {
case 1:
intunit = (int)((tempunit*10) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km"));
break;
case 2:
intunit = (int)((tempunit*10 / 1.609) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles"));
break;
default:
_tcscpy(str, tempchar);
@@ -298,11 +298,11 @@ void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str) switch (opt.eUnit) {
case 1:
intunit = (int)((tempunit*10 * 3.28) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
break;
case 2:
intunit = (int)((tempunit*10) + 0.5);
- wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
+ mir_sntprintf(str, SIZEOF(str), _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
break;
default:
_tcscpy(str, tempchar);
@@ -550,7 +550,7 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str) name[0] = 0;
// read the entire variable name
while (dis[i] != ']' && i < _tcslen(dis)) {
- wsprintfA(temp, "%c", dis[i++]);
+ mir_snprintf(temp, SIZEOF(temp), "%c", dis[i++]);
strcat(name, temp);
}
// access the database to get its value
@@ -564,7 +564,7 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str) }
// if the character is not a variable, write the original character to the new string
else {
- wsprintf( lpzDate, _T("%c"), dis[i]);
+ mir_sntprintf(lpzDate, SIZEOF(lpzDate), _T("%c"), dis[i]);
_tcscat(str, lpzDate);
} }
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp index 935cf33dfd..78ff5e60b4 100644 --- a/plugins/Weather/src/weather_data.cpp +++ b/plugins/Weather/src/weather_data.cpp @@ -154,7 +154,7 @@ void EraseAllInfo() opt.DefStn = hContact;
if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) {
- wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
@@ -181,7 +181,7 @@ void EraseAllInfo() }
opt.DefStn = LastContact;
if ( !db_get_ts(LastContact,WEATHERPROTONAME, "Nick",&dbv)) {
- wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
diff --git a/plugins/Weather/src/weather_http.cpp b/plugins/Weather/src/weather_http.cpp index d9038db9c8..7cf39bfd54 100644 --- a/plugins/Weather/src/weather_http.cpp +++ b/plugins/Weather/src/weather_http.cpp @@ -156,7 +156,7 @@ int InternetDownloadFile (char *szUrl, char* cookie, TCHAR** szData) else {
*szData = ( TCHAR* )mir_alloc(512);
// store the error code in szData
- wsprintf(*szData, _T("Error occured! HTTP Error: %i\n"), nlhrReply->resultCode);
+ mir_sntprintf(*szData, 512, _T("Error occured! HTTP Error: %i\n"), nlhrReply->resultCode);
result = (int)nlhrReply->resultCode;
}
diff --git a/plugins/Weather/src/weather_svcs.cpp b/plugins/Weather/src/weather_svcs.cpp index 34e026b0d5..a398b748b9 100644 --- a/plugins/Weather/src/weather_svcs.cpp +++ b/plugins/Weather/src/weather_svcs.cpp @@ -148,12 +148,12 @@ INT_PTR WeatherGetAvatarInfo(WPARAM wParam, LPARAM lParam) return GAIR_NOAVATAR;
ai->format = PA_FORMAT_PNG;
- wsprintf(ai->filename, _T("%s\\Plugins\\Weather\\%s.png"), szSearchPath, statusStr[i]);
+ mir_sntprintf(ai->filename, SIZEOF(ai->filename), _T("%s\\Plugins\\Weather\\%s.png"), szSearchPath, statusStr[i]);
if ( _taccess(ai->filename, 4) == 0)
return GAIR_SUCCESS;
ai->format = PA_FORMAT_GIF;
- wsprintf(ai->filename, _T("%s\\Plugins\\Weather\\%s.gif"), szSearchPath, statusStr[i]);
+ mir_sntprintf(ai->filename, SIZEOF(ai->filename), _T("%s\\Plugins\\Weather\\%s.gif"), szSearchPath, statusStr[i]);
if ( _taccess(ai->filename, 4) == 0)
return GAIR_SUCCESS;
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index a6cee642ff..72eeb2cbf7 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -58,7 +58,7 @@ int UpdateWeather(HANDLE hContact) // error occurs if the return value is not equals to 0
if (opt.ShowWarnings)
{ // show warnings by popup
- mir_sntprintf(str, SIZEOF(str)-105,
+ mir_sntprintf(str, SIZEOF(str) - 105,
TranslateT("Unable to retrieve weather information for %s"), dbv.ptszVal);
_tcscat(str, _T("\n"));
_tcscat(str, GetError(code));
@@ -104,7 +104,7 @@ int UpdateWeather(HANDLE hContact) if ( !dbres && dbv.ptszVal[0] != 0) {
if (opt.AlertPopup && !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch) {
// display alert popup
- wsprintf(str, _T("Alert for %s%c%s"), winfo.city, 255, dbv.ptszVal);
+ mir_sntprintf(str, SIZEOF(str), _T("Alert for %s%c%s"), winfo.city, 255, dbv.ptszVal);
WPShowMessage(str, SM_WEATHERALERT);
}
// alert issued, set display to italic
@@ -406,19 +406,19 @@ int GetWeatherData(HANDLE hContact) // generate update URL
switch(i) {
case 0:
- _snprintf(loc, SIZEOF(loc), Data->UpdateURL, _T2A(id));
+ mir_snprintf(loc, SIZEOF(loc), Data->UpdateURL, _T2A(id));
break;
case 1:
- _snprintf(loc, SIZEOF(loc), Data->UpdateURL2, _T2A(id));
+ mir_snprintf(loc, SIZEOF(loc), Data->UpdateURL2, _T2A(id));
break;
case 2:
- _snprintf(loc, SIZEOF(loc), Data->UpdateURL3, _T2A(id));
+ mir_snprintf(loc, SIZEOF(loc), Data->UpdateURL3, _T2A(id));
break;
case 3:
- _snprintf(loc, SIZEOF(loc), Data->UpdateURL4, _T2A(id));
+ mir_snprintf(loc, SIZEOF(loc), Data->UpdateURL4, _T2A(id));
break;
default:
|