summaryrefslogtreecommitdiff
path: root/protocols/Weather/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-01 18:34:53 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-01 18:34:53 +0300
commit1cd75c5336a5ecdea2003bd45fb1875f021b1c6b (patch)
treeb5d97ae736f97edaf1705e3a293ea709266593c7 /protocols/Weather/src
parentc39c8e1373abf80a88c943d657119081a3d07c89 (diff)
mode code cleaning
Diffstat (limited to 'protocols/Weather/src')
-rw-r--r--protocols/Weather/src/stdafx.h1
-rw-r--r--protocols/Weather/src/weather_addstn.cpp4
-rw-r--r--protocols/Weather/src/weather_contacts.cpp6
-rw-r--r--protocols/Weather/src/weather_conv.cpp14
-rw-r--r--protocols/Weather/src/weather_data.cpp4
-rw-r--r--protocols/Weather/src/weather_http.cpp8
-rw-r--r--protocols/Weather/src/weather_icons.cpp1
-rw-r--r--protocols/Weather/src/weather_info.cpp16
-rw-r--r--protocols/Weather/src/weather_ini.cpp24
-rw-r--r--protocols/Weather/src/weather_update.cpp8
10 files changed, 37 insertions, 49 deletions
diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h
index d8b0b224c9..82bbbdaa87 100644
--- a/protocols/Weather/src/stdafx.h
+++ b/protocols/Weather/src/stdafx.h
@@ -433,6 +433,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
// functions in weather_info.c
void GetINIInfo(wchar_t *pszSvc);
+wchar_t* GetINIVersionNum(int iVersion);
void MoreVarList();
diff --git a/protocols/Weather/src/weather_addstn.cpp b/protocols/Weather/src/weather_addstn.cpp
index 3ef5a46894..15b4f6e25a 100644
--- a/protocols/Weather/src/weather_addstn.cpp
+++ b/protocols/Weather/src/weather_addstn.cpp
@@ -237,7 +237,7 @@ int IDSearchProc(wchar_t *sID, const int searchId, WIIDSEARCH *sData, wchar_t *s
mir_snprintf(loc, sData->SearchURL, sID);
BOOL bFound = (InternetDownloadFile(loc, nullptr, nullptr, &szData) == 0);
if (bFound) {
- wchar_t* szInfo = szData;
+ wchar_t *szInfo = szData;
// not found
if (wcsstr(szInfo, sData->NotFoundStr) == nullptr)
@@ -312,7 +312,7 @@ int NameSearchProc(wchar_t *name, const int searchId, WINAMESEARCH *sData, wchar
T2Utf szSearchName(name);
mir_snprintf(loc, sData->SearchURL, mir_urlEncode(szSearchName).c_str());
if (InternetDownloadFile(loc, nullptr, nullptr, &szData) == 0) {
- wchar_t* szInfo = szData;
+ wchar_t *szInfo = szData;
search = wcsstr(szInfo, sData->NotFoundStr); // determine if data is available
if (search == nullptr) { // if data is found
// test if it is single result
diff --git a/protocols/Weather/src/weather_contacts.cpp b/protocols/Weather/src/weather_contacts.cpp
index 0ba7473c49..19f1b03d80 100644
--- a/protocols/Weather/src/weather_contacts.cpp
+++ b/protocols/Weather/src/weather_contacts.cpp
@@ -25,7 +25,7 @@ the contact.
#include "stdafx.h"
-static void OpenUrl(wchar_t* format, wchar_t* id)
+static void OpenUrl(wchar_t *format, wchar_t *id)
{
wchar_t loc[512];
GetID(id);
@@ -239,7 +239,7 @@ static INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
wchar_t *pData = nullptr;
if (InternetDownloadFile(loc, nullptr, sData->UserAgent, &pData) == 0) {
wchar_t *szInfo = pData;
- wchar_t* search = wcsstr(szInfo, sData->IDSearch.NotFoundStr);
+ wchar_t *search = wcsstr(szInfo, sData->IDSearch.NotFoundStr);
// if the page is found (ie. valid ID), get the name of the city
if (search == nullptr)
@@ -270,7 +270,7 @@ static INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
ofn.hwndOwner = hwndDlg;
ofn.lpstrFile = str;
ofn.nMaxFile = _countof(str);
-
+
// set filters
mir_snwprintf(filter, L"%s (*.txt)%c*.txt%c%s (*.*)%c*.*%c%c", TranslateT("Text Files"), 0, 0, TranslateT("All Files"), 0, 0, 0);
ofn.lpstrFilter = filter;
diff --git a/protocols/Weather/src/weather_conv.cpp b/protocols/Weather/src/weather_conv.cpp
index 60577e99aa..880166305d 100644
--- a/protocols/Weather/src/weather_conv.cpp
+++ b/protocols/Weather/src/weather_conv.cpp
@@ -75,7 +75,7 @@ static void numToStr(double num, wchar_t *str, size_t strSize)
// tempchar = the string containing the temperature value
// unit = the unit for temperature
// return value = the converted temperature with degree sign and unit; if fails, return N/A
-void GetTemp(wchar_t *tempchar, wchar_t *unit, wchar_t* str)
+void GetTemp(wchar_t *tempchar, wchar_t *unit, wchar_t *str)
{
// unit can be C, F
double temp;
@@ -83,7 +83,7 @@ void GetTemp(wchar_t *tempchar, wchar_t *unit, wchar_t* str)
TrimString(tempchar);
if (tempchar[0] == '-' && tempchar[1] == ' ')
- memmove(&tempchar[1], &tempchar[2], sizeof(wchar_t)*(mir_wstrlen(&tempchar[2]) + 1));
+ memmove(&tempchar[1], &tempchar[2], sizeof(wchar_t) * (mir_wstrlen(&tempchar[2]) + 1));
// quit if the value obtained is N/A or not a number
if (!mir_wstrcmp(tempchar, NODATA) || !mir_wstrcmp(tempchar, L"N/A")) {
@@ -127,7 +127,7 @@ void GetTemp(wchar_t *tempchar, wchar_t *unit, wchar_t* str)
// tempchar = the string containing the pressure value
// unit = the unit for pressure
// return value = the converted pressure with unit; if fail, return the original string
-void GetPressure(wchar_t *tempchar, wchar_t *unit, wchar_t* str)
+void GetPressure(wchar_t *tempchar, wchar_t *unit, wchar_t *str)
{
// unit can be kPa, hPa, mb, in, mm, torr
double tempunit = 0, output;
@@ -319,7 +319,7 @@ void GetElev(wchar_t *tempchar, wchar_t *unit, wchar_t *str)
static const wchar_t *statusStr[10] = { L"Lightning", L"Fog", L"Snow", L"Rain", L"Partly Cloudy", L"Cloudy", L"Sunny", L"N/A" };
static const WORD statusValue[10] = { LIGHT, FOG, SNOW, RAIN, PCLOUDY, CLOUDY, SUNNY, NA };
-WORD GetIcon(const wchar_t* cond, WIDATA *Data)
+WORD GetIcon(const wchar_t *cond, WIDATA *Data)
{
// set the icon using ini
for (int i = 0; i < 10; i++)
@@ -378,7 +378,7 @@ void CaseConv(wchar_t *str)
for (wchar_t *pstr = str; *pstr; pstr++) {
if (*pstr == ' ' || *pstr == '-')
nextUp = true;
- else if (nextUp) {
+ else if (nextUp) {
CharUpperBuffW(pstr, 1);
nextUp = false;
}
@@ -405,7 +405,7 @@ void TrimString(WCHAR *str)
len = mir_wstrlen(str);
while (len && (unsigned char)str[len - 1] <= ' ') str[--len] = 0;
for (start = 0; (unsigned char)str[start] <= ' ' && str[start]; start++);
- memmove(str, str + start, (len - start + 1)*sizeof(WCHAR));
+ memmove(str, str + start, (len - start + 1) * sizeof(WCHAR));
}
// convert \t to tab and \n to linefeed
@@ -448,7 +448,7 @@ char *GetSearchStr(char *dis)
// w = WEATHERINFO data to be parsed
// dis = the string to parse
// return value = the parsed string
-wchar_t* GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t* str)
+wchar_t *GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t *str)
{
wchar_t lpzDate[32], chr;
char name[256], temp[2];
diff --git a/protocols/Weather/src/weather_data.cpp b/protocols/Weather/src/weather_data.cpp
index b4d4393a42..2ba284d2fa 100644
--- a/protocols/Weather/src/weather_data.cpp
+++ b/protocols/Weather/src/weather_data.cpp
@@ -30,7 +30,7 @@ saving individual weather data for a weather contact.
// hContact = the current contact handle
// return value = the string for station ID
//
-void GetStationID(MCONTACT hContact, wchar_t* id, int idlen)
+void GetStationID(MCONTACT hContact, wchar_t *id, int idlen)
{
// accessing the database
if (db_get_wstatic(hContact, MODULENAME, "ID", id, idlen))
@@ -245,7 +245,7 @@ void ConvertDataValue(WIDATAITEM *UpdateData, wchar_t *Data)
// Data = the string containing weather data obtained from UpdateData
// global var. used: szInfo = the downloaded string
//
-void GetDataValue(WIDATAITEM *UpdateData, wchar_t *Data, wchar_t** szData)
+void GetDataValue(WIDATAITEM *UpdateData, wchar_t *Data, wchar_t **szData)
{
wchar_t last = 0, current, *start, *end;
unsigned startloc = 0, endloc = 0, respos = 0;
diff --git a/protocols/Weather/src/weather_http.cpp b/protocols/Weather/src/weather_http.cpp
index b6e4edfa75..2f09c46acc 100644
--- a/protocols/Weather/src/weather_http.cpp
+++ b/protocols/Weather/src/weather_http.cpp
@@ -89,12 +89,10 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s
while (end) {
// look for
// <meta http-equiv="Content-Type" content="utf-8" />
- char* beg = strstr(end, "<meta");
- if (beg)
- {
+ char *beg = strstr(end, "<meta");
+ if (beg) {
end = strchr(beg, '>');
- if (end)
- {
+ if (end) {
char tmp = *end;
*end = 0;
diff --git a/protocols/Weather/src/weather_icons.cpp b/protocols/Weather/src/weather_icons.cpp
index 5e993cd443..b869dbcdb2 100644
--- a/protocols/Weather/src/weather_icons.cpp
+++ b/protocols/Weather/src/weather_icons.cpp
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include "stdafx.h"
static IconItem iconList[] =
diff --git a/protocols/Weather/src/weather_info.cpp b/protocols/Weather/src/weather_info.cpp
index bdc5115195..d9d76afe7f 100644
--- a/protocols/Weather/src/weather_info.cpp
+++ b/protocols/Weather/src/weather_info.cpp
@@ -35,7 +35,6 @@ static void INIInfo(HWND hwndDlg)
wchar_t str[16];
size_t memused = 0;
-
HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST);
ListView_DeleteAllItems(hIniList);
@@ -55,16 +54,7 @@ static void INIInfo(HWND hwndDlg)
lvi.pszText = Item->Data.Version;
ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 3;
- switch (Item->Data.InternalVer) {
- case 1: lvi.pszText = L"1.0"; break;
- case 2: lvi.pszText = L"1.1"; break;
- case 3: lvi.pszText = L"1.1a"; break;
- case 4: lvi.pszText = L"1.2"; break;
- case 5: lvi.pszText = L"1.3"; break;
- case 6: lvi.pszText = L"1.4"; break;
- case 7: lvi.pszText = L"1.5"; break;
- default: lvi.pszText = L""; break;
- }
+ lvi.pszText = GetINIVersionNum(Item->Data.InternalVer);
ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 4;
lvi.pszText = _ltow(Item->Data.UpdateDataCount, str, 10);
@@ -142,7 +132,7 @@ INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
// get the info of individual ini file
// pszSvc = the internal name of the service to get the data
-static wchar_t* GetVersionNum(int iVersion)
+wchar_t* GetINIVersionNum(int iVersion)
{
switch (iVersion) {
case 1: return L"1.0";
@@ -172,7 +162,7 @@ void GetINIInfo(wchar_t *pszSvc)
str.AppendFormat(L"%s\t%s\n", TranslateT("Internal Name:"), sData->InternalName);
str.AppendFormat(L"%s\t%s\n", TranslateT("Author:"), sData->Author);
str.AppendFormat(L"%s\t%s\n", TranslateT("Version:"), sData->Version);
- str.AppendFormat(L"%s\t%s\n", TranslateT("INI Version:"), GetVersionNum(sData->InternalVer));
+ str.AppendFormat(L"%s\t%s\n", TranslateT("INI Version:"), GetINIVersionNum(sData->InternalVer));
str.AppendFormat(L"%s\t%s\n", TranslateT("File Name:"), sData->ShortFileName);
str.AppendFormat(L"%s\t%i\n", TranslateT("Item Count:"), sData->UpdateDataCount);
str.AppendFormat(L"%s\t%i %s\n\n", TranslateT("Memory Used:"), (int)sData->MemUsed, TranslateT("bytes"));
diff --git a/protocols/Weather/src/weather_ini.cpp b/protocols/Weather/src/weather_ini.cpp
index 0948e4c8a3..101f5e5d09 100644
--- a/protocols/Weather/src/weather_ini.cpp
+++ b/protocols/Weather/src/weather_ini.cpp
@@ -177,18 +177,18 @@ static INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
case IDC_STEP2:
- {
- CMStringW wszPath('\x00', MAX_PATH);
- GetModuleFileName(GetModuleHandle(nullptr), wszPath.GetBuffer(), MAX_PATH);
- int idx = wszPath.Find('\\');
- if (idx != -1) {
- wszPath.Truncate(idx);
- wszPath += L"\\Plugins\\weather\\";
- if (_wmkdir(wszPath) == 0)
- ShellExecute((HWND)lParam, L"open", wszPath, L"", L"", SW_SHOW);
+ {
+ CMStringW wszPath('\x00', MAX_PATH);
+ GetModuleFileName(GetModuleHandle(nullptr), wszPath.GetBuffer(), MAX_PATH);
+ int idx = wszPath.Find('\\');
+ if (idx != -1) {
+ wszPath.Truncate(idx);
+ wszPath += L"\\Plugins\\weather\\";
+ if (_wmkdir(wszPath) == 0)
+ ShellExecute((HWND)lParam, L"open", wszPath, L"", L"", SW_SHOW);
+ }
+ break;
}
- break;
- }
case IDC_STEP3:
if (LoadWIData(false))
@@ -323,7 +323,7 @@ static void LoadStationData(const wchar_t *pszFile, wchar_t *pszShortFile, WIDAT
// initialize the linked list for update items
Data->UpdateDataCount = 0;
- Data->MemUsed = sizeof(WIDATA) + sizeof(WIDATALIST) + (mir_wstrlen(pszShortFile) + mir_wstrlen(pszFile) + 20)*sizeof(wchar_t);
+ Data->MemUsed = sizeof(WIDATA) + sizeof(WIDATALIST) + (mir_wstrlen(pszShortFile) + mir_wstrlen(pszFile) + 20) * sizeof(wchar_t);
Data->UpdateData = nullptr;
Data->UpdateDataTail = nullptr;
diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp
index ae875de91f..54fe72a5cb 100644
--- a/protocols/Weather/src/weather_update.cpp
+++ b/protocols/Weather/src/weather_update.cpp
@@ -242,7 +242,7 @@ MCONTACT UpdateGetFirst()
WaitForSingleObject(hUpdateMutex, INFINITE);
if (UpdateListHead != nullptr) {
- UPDATELIST* Item = UpdateListHead;
+ UPDATELIST *Item = UpdateListHead;
hContact = Item->hContact;
UpdateListHead = Item->next;
@@ -378,7 +378,7 @@ int GetWeatherData(MCONTACT hContact)
GetStationID(hContact, id, _countof(id));
// test ID format
- wchar_t* szInfo = wcschr(id, '/');
+ wchar_t *szInfo = wcschr(id, '/');
if (szInfo == nullptr)
return INVALID_ID_FORMAT;
@@ -426,7 +426,7 @@ int GetWeatherData(MCONTACT hContact)
continue;
// download the html file from the internet
- wchar_t* szData = nullptr;
+ wchar_t *szData = nullptr;
int retval = InternetDownloadFile(loc, Data->Cookie, Data->UserAgent, &szData);
if (retval != 0) {
mir_free(szData);
@@ -517,7 +517,7 @@ int GetWeatherData(MCONTACT hContact)
}
// generate the strings
- wchar_t* end = wcsstr(DataValue, Item->Item.Break);
+ wchar_t *end = wcsstr(DataValue, Item->Item.Break);
if (end == nullptr) {
DataValue[0] = 0;
break; // exit if break string is not found