diff options
author | George Hazan <ghazan@miranda.im> | 2019-07-26 20:02:16 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-07-26 20:02:22 +0300 |
commit | 9374c8e701dcb61a46c89a854235d91a23bf672e (patch) | |
tree | ad366bc7f47da578fb33a57c32912689f5aadecb /protocols | |
parent | 3c5923d11431c515db57e4e972d53bf0443f1bcb (diff) |
warning fixes
Diffstat (limited to 'protocols')
26 files changed, 139 insertions, 154 deletions
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 448336e3c9..fdc621b4db 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -1495,10 +1495,10 @@ bool CIrcProto::OnIrc_LIST(const CIrcMessage *pmsg) wchar_t* temp = mir_wstrdup(pmsg->parameters[pmsg->parameters.getCount() - 1]);
wchar_t* find = wcsstr(temp, L"[+");
- wchar_t* find2 = wcsstr(temp, L"]");
+ wchar_t* find2 = wcschr(temp, ']');
wchar_t* save = temp;
if (find == temp && find2 != nullptr && find + 8 >= find2) {
- temp = wcsstr(temp, L"]");
+ temp = wcschr(temp, ']');
if (mir_wstrlen(temp) > 1) {
temp++;
temp[0] = 0;
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index d0758f3faf..ad8ffecd66 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -822,7 +822,7 @@ void CJabberProto::GroupchatProcessPresence(const TiXmlElement *node) if (auto *n = XmlGetChildByTag(node, "nick", "xmlns", JABBER_FEAT_NICK))
cnick = n->GetText();
- const char *nick = cnick ? cnick : (r && r->m_szNick ? r->m_szNick : resource);
+ const char *nick = cnick ? cnick : (r && r->m_szNick ? r->m_szNick.get() : resource);
const TiXmlElement *itemNode = nullptr;
auto *xNode = XmlGetChildByTag(node, "x", "xmlns", JABBER_FEAT_MUC_USER);
@@ -1087,7 +1087,7 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node) if (resource != nullptr) {
pResourceStatus r(item->findResource(resource));
- nick = (r && r->m_szNick) ? r->m_szNick : resource;
+ nick = (r && r->m_szNick) ? r->m_szNick.get() : resource;
}
else nick = nullptr;
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index e2a35eb5c0..31392c3549 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -948,7 +948,7 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM hContact, LPARAM lParam) wchar_t buf[256];
mir_snwprintf(buf, TranslateT("Last active (%s)"),
- LI->m_pLastSeenResource ? Utf2T(LI->m_pLastSeenResource->m_szResourceName.get()) : TranslateT("No activity yet, use server's choice"));
+ LI->m_pLastSeenResource ? Utf2T(LI->m_pLastSeenResource->m_szResourceName).get() : TranslateT("No activity yet, use server's choice"));
AppendMenu(hMenu, MF_STRING, MENUITEM_LASTSEEN, buf);
AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)"));
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index ff84776acf..752ae2cda8 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -739,7 +739,7 @@ HANDLE CJabberProto::SearchByEmail(const wchar_t *email) ptrA szServerName(getStringA("Jud"));
- LPCSTR jid = szServerName == 0 ? "users.jabber.org" : szServerName;
+ LPCSTR jid = szServerName == 0 ? "users.jabber.org" : szServerName.get();
CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultSetSearch, JABBER_IQ_TYPE_SET, jid);
m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY("jabber:iq:search") << XCHILD("email", T2Utf(email)));
return (HANDLE)pInfo->GetIqId();
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index ee0e59b825..39c01b5af0 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -530,7 +530,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR /* Server Combo box */ ptrA jud(dat->ppro->getStringA("Jud")); - char *szServerName = (jud == nullptr) ? "users.jabber.org" : jud; + char *szServerName = (jud == nullptr) ? "users.jabber.org" : jud.get(); SetDlgItemTextA(hwndDlg, IDC_SERVER, szServerName); SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)szServerName); //TO DO: Add Transports here diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 2631783213..82f27729bb 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -821,7 +821,7 @@ BOOL CJabberProto::EnterString(CMStringW &result, const wchar_t *caption, int ty param.recentCount = recentCount;
param.timeout = timeout;
param.ptszInitVal = result;
- BOOL res = ::EnterString(¶m);
+ INT_PTR res = ::EnterString(¶m);
if (res) {
result = param.ptszResult;
mir_free(param.ptszResult);
diff --git a/protocols/NewsAggregator/Src/Utils.cpp b/protocols/NewsAggregator/Src/Utils.cpp index 29c2017b66..00144af250 100644 --- a/protocols/NewsAggregator/Src/Utils.cpp +++ b/protocols/NewsAggregator/Src/Utils.cpp @@ -87,7 +87,7 @@ void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, CFeedEditor if (nlhrReply->resultCode == 200 && nlhrReply->dataLength > 0) { Netlib_LogfW(hNetlibUser, L"Code 200: Succeeded getting feed data %s.", tszUrl); // allocate memory and save the retrieved data - *szData = (char *)mir_alloc((size_t)(nlhrReply->dataLength + 2)); + *szData = (char *)mir_alloc((size_t)nlhrReply->dataLength + 2); memcpy(*szData, nlhrReply->pData, (size_t)nlhrReply->dataLength); (*szData)[nlhrReply->dataLength] = 0; } @@ -132,7 +132,7 @@ time_t DateToUnixTime(const char *stamp, bool FeedType) if (strchr(p, ',')) { strtok(p, ","); p = strtok(nullptr, ","); - sscanf(p + 1, "%d %3s %d %d:%d:%d %1s%02d%02d", &day, &monthstr, &year, &hour, &min, &sec, &timezonesign, &timezoneh, &timezonem); + sscanf(p + 1, "%d %3s %d %d:%d:%d %1s%02d%02d", &day, monthstr, &year, &hour, &min, &sec, timezonesign, &timezoneh, &timezonem); if (!mir_strcmpi(monthstr, "Jan")) month = 1; if (!mir_strcmpi(monthstr, "Feb")) diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp index 2b046799dd..eaeec9c62c 100644 --- a/protocols/SkypeWeb/src/skype_trouter.cpp +++ b/protocols/SkypeWeb/src/skype_trouter.cpp @@ -141,7 +141,7 @@ void CSkypeProto::TRouterThread(void*) errors = 0;
if (response->pData) {
- char *json = strstr(response->pData, "{");
+ char *json = strchr(response->pData, '{');
if (json != NULL) {
JSONNode root = JSONNode::parse(json);
std::string szBody = root["body"].as_string();
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index 66f68b297f..15bbc2853a 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -349,7 +349,7 @@ char *CSkypeProto::RemoveHtml(const char *text) for (std::string::size_type i = 0; i < data.length(); i++) { if (data.at(i) == '<') { - i = data.find(">", i); + i = data.find('>', i); if (i == std::string::npos) break; @@ -358,7 +358,7 @@ char *CSkypeProto::RemoveHtml(const char *text) if (data.at(i) == '&') { std::string::size_type begin = i; - i = data.find(";", i); + i = data.find(';', i); if (i == std::string::npos) { i = begin; } diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index cd576ac374..8eeb7c6eb3 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -458,7 +458,7 @@ void CSteamProto::OnGotBlockList(const JSONNode &root, void *) return; for (auto &_friend : root["friends"]) { - json_string steamId = _friend["steamid"].as_string(); + // json_string steamId = _friend["steamid"].as_string(); json_string relationship = _friend["relationship"].as_string(); if (!mir_strcmp(relationship.c_str(), "ignoredfriend")) { diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp index c89f28fb82..b4c7f62c4d 100644 --- a/protocols/Tox/src/tox_accounts.cpp +++ b/protocols/Tox/src/tox_accounts.cpp @@ -8,7 +8,7 @@ int CToxProto::OnAccountRenamed(WPARAM wParam, LPARAM lParam) ptrW newPath(GetToxProfilePath());
wchar_t oldPath[MAX_PATH];
- mir_snwprintf(oldPath, MAX_PATH, L"%s\\%s.tox", VARSW(L"%miranda_userdata%").get(), m_accountName);
+ mir_snwprintf(oldPath, MAX_PATH, L"%s\\%s.tox", VARSW(L"%miranda_userdata%").get(), m_accountName.get());
_wrename(oldPath, newPath);
m_accountName = mir_wstrdup(m_tszUserName);
}
diff --git a/protocols/Tox/src/tox_address.h b/protocols/Tox/src/tox_address.h index 9ef57caba2..402dc59434 100644 --- a/protocols/Tox/src/tox_address.h +++ b/protocols/Tox/src/tox_address.h @@ -19,8 +19,7 @@ private: {
hexSize = size * 2;
hexData = (char*)mir_calloc(hexSize + 1);
- char *p = bin2hex(bin, size, hexData);
- while (*p++ = toupper(*p));
+ strupr(bin2hex(bin, size, hexData));
}
public:
ToxHexAddress(const char *hex, size_t size = TOX_ADDRESS_SIZE * 2) { Init(hex, size); }
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index ebbddf2ad8..83e4b883cb 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -91,8 +91,6 @@ HWND CToxProto::OnSearchAdvanced(HWND owner) const std::string query = T2Utf(text).str();
if (std::regex_search(query, match, regex)) {
- std::string address = match[1];
-
PROTOSEARCHRESULT psr = { sizeof(psr) };
psr.flags = PSR_UTF8;
psr.id.a = mir_strdup(query.c_str());
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index 251d901cf5..8ec1d5bc9a 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -307,21 +307,15 @@ void TwitterProto::MessageLoop(void*) if (m_iStatus != ID_STATUS_ONLINE)
break;
- // if(i%10 == 0)
- // UpdateFriends();
-
- if (m_iStatus != ID_STATUS_ONLINE)
- break;
+
UpdateStatuses(new_account, popups, tweetToMsg);
-
if (m_iStatus != ID_STATUS_ONLINE)
break;
if (i % 10 == 0)
UpdateMessages(new_account);
- if (new_account) // Not anymore!
- {
+ if (new_account) { // Not anymore!
new_account = false;
setByte(TWITTER_KEY_NEW, 0);
}
diff --git a/protocols/Twitter/src/oauth.cpp b/protocols/Twitter/src/oauth.cpp index afdb23413a..e7ff001450 100644 --- a/protocols/Twitter/src/oauth.cpp +++ b/protocols/Twitter/src/oauth.cpp @@ -172,7 +172,7 @@ wstring mir_twitter::OAuthConcatenateRequestElements(const wstring& httpMethod, map<wstring, wstring> mir_twitter::CrackURL(wstring url)
{
wstring scheme1, domain1, port1, path1, extraInfo, explicitPort;
- vector<wstring> urlToks, urlToks2, extraInfoToks;
+ vector<wstring> urlToks, urlToks2;
Split(url, urlToks, L':', false);
diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp index 3001173ee1..460ef0df3b 100644 --- a/protocols/Twitter/src/utility.cpp +++ b/protocols/Twitter/src/utility.cpp @@ -67,7 +67,7 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu auth = OAuthWebRequestSubmit(url_WSTR, L"GET", nullptr, consumerKey_, consumerSecret_,
oauthAccessToken_, oauthAccessTokenSecret_, pin_);
}
- else if (meth == http::post) {
+ else {
// OAuthParameters postParams;
if (url_WSTR.size() > 0) { ppro_->debugLogW(L"**SLURP::POST - we have a URL: %s", url_WSTR.c_str()); }
if (consumerKey_.size() > 0) { ppro_->debugLogA("**SLURP::POST - we have a consumerKey"); }
@@ -82,7 +82,6 @@ http::response mir_twitter::slurp(const std::string &url, http::method meth, OAu auth = OAuthWebRequestSubmit(url_WSTR, L"POST", &postParams, consumerKey_, consumerSecret_, oauthAccessToken_, oauthAccessTokenSecret_);
}
- else ppro_->debugLogA("**SLURP - There is something really wrong.. the http method was neither get or post.. WHY??");
std::string auth_STR = WideToUTF8(auth);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 638d5e2e37..ecae89cdd5 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -193,7 +193,7 @@ void CVkProto::OnLoggedOut() /////////////////////////////////////////////////////////////////////////////////////////
-void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
+void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest*)
{
debugLogA("CVkProto::OnOAuthAuthorize %d", reply->resultCode);
GrabCookies(reply);
@@ -275,7 +275,7 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq m_prevError = true;
}
- pReq = new AsyncHttpRequest();
+ AsyncHttpRequest *pReq = new AsyncHttpRequest();
pReq->requestType = REQUEST_POST;
pReq->flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
pReq->m_szParam = szBody;
diff --git a/protocols/Weather/src/weather_contacts.cpp b/protocols/Weather/src/weather_contacts.cpp index f572b29564..b22f8a2222 100644 --- a/protocols/Weather/src/weather_contacts.cpp +++ b/protocols/Weather/src/weather_contacts.cpp @@ -205,7 +205,7 @@ static INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPA // check if there are 2 parts in the ID (svc/id) seperated by "/" // if not, don't let user change the setting GetDlgItemText(hwndDlg, IDC_ID, str, _countof(str)); - chop = wcsstr(str, L"/"); + chop = wcschr(str, '/'); if (chop == nullptr) EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE); else diff --git a/protocols/Weather/src/weather_conv.cpp b/protocols/Weather/src/weather_conv.cpp index 9ce8a16ad3..60577e99aa 100644 --- a/protocols/Weather/src/weather_conv.cpp +++ b/protocols/Weather/src/weather_conv.cpp @@ -543,9 +543,11 @@ INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam) // pszID = original 2-part id, return the service internal name void GetSvc(wchar_t *pszID) { - wchar_t *chop = wcsstr(pszID, L"/"); - if (chop != nullptr) *chop = '\0'; - else pszID[0] = 0; + wchar_t *chop = wcschr(pszID, '/'); + if (chop != nullptr) + *chop = '\0'; + else + pszID[0] = 0; } // get the id use for update without the service internal name @@ -553,9 +555,11 @@ void GetSvc(wchar_t *pszID) // pszID = original 2-part id, return the single part id void GetID(wchar_t *pszID) { - wchar_t *chop = wcsstr(pszID, L"/"); - if (chop != nullptr) mir_wstrcpy(pszID, chop + 1); - else pszID[0] = 0; + wchar_t *chop = wcschr(pszID, '/'); + if (chop != nullptr) + mir_wstrcpy(pszID, chop + 1); + else + pszID[0] = 0; } //============ WEATHER ERROR CODE ============ diff --git a/protocols/Weather/src/weather_data.cpp b/protocols/Weather/src/weather_data.cpp index e36ae9dc5b..c6d88e4f1f 100644 --- a/protocols/Weather/src/weather_data.cpp +++ b/protocols/Weather/src/weather_data.cpp @@ -270,7 +270,7 @@ void GetDataValue(WIDATAITEM *UpdateData, wchar_t *Data, wchar_t** szData) if (UpdateData->End[0] != 0) end = wcsstr(szInfo, UpdateData->End); else - end = wcsstr(szInfo, L" "); + end = wcschr(szInfo, ' '); if (end != nullptr) { // set the ending location diff --git a/protocols/Weather/src/weather_ini.cpp b/protocols/Weather/src/weather_ini.cpp index bd60fcaaa0..81a2831736 100644 --- a/protocols/Weather/src/weather_ini.cpp +++ b/protocols/Weather/src/weather_ini.cpp @@ -371,7 +371,7 @@ static void LoadStationData(wchar_t *pszFile, wchar_t *pszShortFile, WIDATA *Dat } } // ignore comments and all lines without an '=' - Value = strstr(Line, "="); + Value = strchr(Line, '='); if (Value == nullptr) continue; // get the string before '=' (ValName) and after '=' (Value) diff --git a/protocols/YAMN/src/proto/netclient.h b/protocols/YAMN/src/proto/netclient.h index 99ec0888f1..dff43ae0f1 100644 --- a/protocols/YAMN/src/proto/netclient.h +++ b/protocols/YAMN/src/proto/netclient.h @@ -5,6 +5,8 @@ class CNetClient { public: CNetClient(): Stopped(FALSE) {} + virtual ~CNetClient() {} + virtual void Connect(const char* servername, const int port)=0; virtual void Send(const char *query)=0; virtual char* Recv(char *buf= nullptr, int buflen=65536)=0; diff --git a/protocols/YAMN/src/proto/netlib.h b/protocols/YAMN/src/proto/netlib.h index 778d6497ed..dfa3d93508 100644 --- a/protocols/YAMN/src/proto/netlib.h +++ b/protocols/YAMN/src/proto/netlib.h @@ -4,7 +4,7 @@ class CNLClient: public CNetClient { public: - CNLClient(): hConnection(nullptr) {} + CNLClient() {} void Connect(const char* servername, const int port) throw(DWORD); void Send(const char *query) throw(DWORD); char* Recv(char *buf= nullptr, int buflen = 65536) throw(DWORD); @@ -14,8 +14,8 @@ public: inline BOOL Connected() {return hConnection != nullptr;} protected: - HNETLIBCONN hConnection; - BOOL isTLSed; + HNETLIBCONN hConnection = nullptr; + BOOL isTLSed = false; int LocalNetlib_Send(HNETLIBCONN hConn, const char *buf, int len, int flags); int LocalNetlib_Recv(HNETLIBCONN hConn, char *buf, int len, int flags); }; diff --git a/protocols/YAMN/src/proto/pop3/pop3.cpp b/protocols/YAMN/src/proto/pop3/pop3.cpp index d47fac4836..d263d332e4 100644 --- a/protocols/YAMN/src/proto/pop3/pop3.cpp +++ b/protocols/YAMN/src/proto/pop3/pop3.cpp @@ -34,51 +34,48 @@ //sets AckFlag char *CPop3Client::Connect(const char* servername,const int port,BOOL UseSSL, BOOL NoTLS) { - char *temp = nullptr; - if (Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + if (Stopped) // check if we can work with this POP3 client session + throw POP3Error = (DWORD)EPOP3_STOPPED; - if (NetClient != nullptr) - delete NetClient; - SSL=UseSSL; - NetClient=new CNLClient; + delete NetClient; + SSL = UseSSL; + NetClient = new CNLClient; #ifdef DEBUG_DECODE - DebugLog(DecodeFile,"Connect:servername: %s port:%d\n",servername,port); + DebugLog(DecodeFile, "Connect:servername: %s port:%d\n", servername, port); #endif - POP3Error=EPOP3_CONNECT; - NetClient->Connect(servername,port); - POP3Error=0; - - if (SSL) - { - try { NetClient->SSLify(); } - catch (...) - { + POP3Error = EPOP3_CONNECT; + NetClient->Connect(servername, port); + POP3Error = 0; + + if (SSL) { + try { + NetClient->SSLify(); + } + catch (...) { NetClient->Disconnect(); return nullptr; } } - temp = RecvRest(NetClient->Recv(),POP3_SEARCHACK); + char *temp = RecvRest(NetClient->Recv(), POP3_SEARCHACK); extern BOOL SSLLoaded; if (!NoTLS & !(SSL)) { if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + throw POP3Error = (DWORD)EPOP3_STOPPED; NetClient->Send("STLS\r\n"); free(temp); - temp=RecvRest(NetClient->Recv(),POP3_SEARCHACK); - if (AckFlag==POP3_FOK) { // Ok, we are going to tls + temp = RecvRest(NetClient->Recv(), POP3_SEARCHACK); + if (AckFlag == POP3_FOK) { // Ok, we are going to tls try { NetClient->SSLify(); - } catch (...) { + } + catch (...) { NetClient->Disconnect(); return nullptr; } -// temp = RecvRest(NetClient->Recv(),POP3_SEARCHACK); } - } -// SSL_DebugLog("Received: %s",temp); + } return temp; } @@ -91,6 +88,7 @@ char *CPop3Client::Connect(const char* servername,const int port,BOOL UseSSL, BO // new memory. New allocated memory has allocated size more bytes // This value can be selectable: if you think it is better to reallocate by 1kB size, select size to 1024, // default is 128. You do not need to use this parameter + char* CPop3Client::RecvRest(char* prev,int mode,int size) { int SizeRead=0; @@ -134,18 +132,17 @@ char* CPop3Client::RecvRest(char* prev,int mode,int size) // if you need to add condition for mode, insert it into switch statement BOOL CPop3Client::SearchFromEnd(char *end,int bs,int mode) { - while(bs>=0) - { - switch(mode) - { - case POP3_SEARCHDOT: - if (DOTLINE(end)) - return 1; - break; - case POP3_SEARCHNL: - if (ENDLINE(end)) - return 1; - break; + while (bs >= 0) { + switch (mode) { + case POP3_SEARCHDOT: + if (DOTLINE(end)) + return 1; + break; + + case POP3_SEARCHNL: + if (ENDLINE(end)) + return 1; + break; } end--; bs--; @@ -159,31 +156,26 @@ BOOL CPop3Client::SearchFromEnd(char *end,int bs,int mode) //if you need to add condition for mode, insert it into switch statement BOOL CPop3Client::SearchFromStart(char *start,int bs,int mode) { - while(bs>=0) - { - switch(mode) - { - case POP3_SEARCHOK: - if (OKLINE(start)) - { - AckFlag=POP3_FOK; - return 1; - } - break; - case POP3_SEARCHERR: - if (ERRLINE(start)) - { - AckFlag=POP3_FERR; - return 1; - } - break; - case POP3_SEARCHACK: - if (ACKLINE(start)) - { - OKLINE(start) ? AckFlag=POP3_FOK : AckFlag=POP3_FERR; - return 1; - } - break; + while (bs >= 0) { + switch (mode) { + case POP3_SEARCHOK: + if (OKLINE(start)) { + AckFlag = POP3_FOK; + return 1; + } + break; + case POP3_SEARCHERR: + if (ERRLINE(start)) { + AckFlag = POP3_FERR; + return 1; + } + break; + case POP3_SEARCHACK: + if (ACKLINE(start)) { + OKLINE(start) ? AckFlag = POP3_FOK : AckFlag = POP3_FERR; + return 1; + } + break; } start++; bs--; @@ -195,18 +187,18 @@ BOOL CPop3Client::SearchFromStart(char *start,int bs,int mode) //sets AckFlag char* CPop3Client::User(char* name) { - if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + if (NetClient->Stopped) // check if we can work with this POP3 client session + throw POP3Error = (DWORD)EPOP3_STOPPED; char query[128]; char *Result; mir_snprintf(query, "USER %s\r\n", name); NetClient->Send(query); - Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); - if (AckFlag==POP3_FERR) - throw POP3Error=(DWORD)EPOP3_BADUSER; - POP3Error=0; + Result = RecvRest(NetClient->Recv(), POP3_SEARCHACK); + if (AckFlag == POP3_FERR) + throw POP3Error = (DWORD)EPOP3_BADUSER; + POP3Error = 0; return Result; } @@ -215,16 +207,15 @@ char* CPop3Client::User(char* name) char* CPop3Client::Pass(char* pw) { if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + throw POP3Error = (DWORD)EPOP3_STOPPED; char query[128]; - char *Result; - mir_snprintf(query, "PASS %s\r\n", pw); NetClient->Send(query); - Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); - if (AckFlag==POP3_FERR) - throw POP3Error=(DWORD)EPOP3_BADPASS; + + char *Result = RecvRest(NetClient->Recv(), POP3_SEARCHACK); + if (AckFlag == POP3_FERR) + throw POP3Error = (DWORD)EPOP3_BADPASS; return Result; } @@ -232,28 +223,28 @@ char* CPop3Client::Pass(char* pw) //sets AckFlag char* CPop3Client::APOP(char* name, char* pw, char* timestamp) { - if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + if (NetClient->Stopped) // check if we can work with this POP3 client session + throw POP3Error = (DWORD)EPOP3_STOPPED; char query[512]; char *Result; unsigned char digest[16]; - if (timestamp==nullptr) - throw POP3Error=(DWORD)EPOP3_APOP; + if (timestamp == nullptr) + throw POP3Error = (DWORD)EPOP3_APOP; mir_md5_state_s ctx; mir_md5_init(&ctx); - mir_md5_append(&ctx,(const unsigned char *)timestamp,(unsigned int)mir_strlen(timestamp)); - mir_md5_append(&ctx,(const unsigned char *)pw,(unsigned int)mir_strlen(pw)); + mir_md5_append(&ctx, (const unsigned char *)timestamp, (unsigned int)mir_strlen(timestamp)); + mir_md5_append(&ctx, (const unsigned char *)pw, (unsigned int)mir_strlen(pw)); mir_md5_finish(&ctx, digest); char hexdigest[40]; mir_snprintf(query, "APOP %s %s\r\n", name, bin2hex(digest, sizeof(digest), hexdigest)); NetClient->Send(query); - Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); - if (AckFlag==POP3_FERR) - throw POP3Error=(DWORD)EPOP3_BADUSER; + Result = RecvRest(NetClient->Recv(), POP3_SEARCHACK); + if (AckFlag == POP3_FERR) + throw POP3Error = (DWORD)EPOP3_BADUSER; return Result; } @@ -271,33 +262,32 @@ char* CPop3Client::Quit() //sets AckFlag char* CPop3Client::Stat() { - if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; - - char query[]="STAT\r\n"; + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error = (DWORD)EPOP3_STOPPED; + char query[] = "STAT\r\n"; NetClient->Send(query); - return RecvRest(NetClient->Recv(),POP3_SEARCHACK); + return RecvRest(NetClient->Recv(), POP3_SEARCHACK); } //Performs "LIST" pop query and returns server response //sets AckFlag char* CPop3Client::List() { - if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + if (NetClient->Stopped) // check if we can work with this POP3 client session + throw POP3Error = (DWORD)EPOP3_STOPPED; - char query[]="LIST\r\n"; + char query[] = "LIST\r\n"; NetClient->Send(query); - return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); + return RecvRest(NetClient->Recv(), POP3_SEARCHDOT); } //Performs "TOP" pop query and returns server response //sets AckFlag char* CPop3Client::Top(int nr, int lines) { - if (NetClient->Stopped) //check if we can work with this POP3 client session + if (NetClient->Stopped) // check if we can work with this POP3 client session throw POP3Error=(DWORD)EPOP3_STOPPED; char query[128]; @@ -311,46 +301,45 @@ char* CPop3Client::Top(int nr, int lines) //sets AckFlag char* CPop3Client::Uidl(int nr) { - if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + if (NetClient->Stopped) // check if we can work with this POP3 client session + throw POP3Error = (DWORD)EPOP3_STOPPED; char query[128]; - - if (nr) - { + if (nr) { mir_snprintf(query, "UIDL %d\r\n", nr); NetClient->Send(query); - return RecvRest(NetClient->Recv(),POP3_SEARCHACK); + return RecvRest(NetClient->Recv(), POP3_SEARCHACK); } mir_snprintf(query, "UIDL\r\n"); NetClient->Send(query); - return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); + return RecvRest(NetClient->Recv(), POP3_SEARCHDOT); } //Performs "DELE" pop query and returns server response //sets AckFlag char* CPop3Client::Dele(int nr) { - if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + if (NetClient->Stopped) // check if we can work with this POP3 client session + throw POP3Error = (DWORD)EPOP3_STOPPED; char query[128]; mir_snprintf(query, "DELE %d\r\n", nr); NetClient->Send(query); - return RecvRest(NetClient->Recv(),POP3_SEARCHACK); + return RecvRest(NetClient->Recv(), POP3_SEARCHACK); } + //Performs "RETR" pop query and returns server response //sets AckFlag char* CPop3Client::Retr(int nr) { - if (NetClient->Stopped) //check if we can work with this POP3 client session - throw POP3Error=(DWORD)EPOP3_STOPPED; + if (NetClient->Stopped) // check if we can work with this POP3 client session + throw POP3Error = (DWORD)EPOP3_STOPPED; char query[128]; - mir_snprintf(query, "RETR %d\r\n", nr); NetClient->Send(query); - RecvRest(NetClient->Recv(),POP3_SEARCHACK); + + RecvRest(NetClient->Recv(), POP3_SEARCHACK); return NetClient->Recv(); -}
\ No newline at end of file +} diff --git a/protocols/YAMN/src/proto/pop3/pop3.h b/protocols/YAMN/src/proto/pop3/pop3.h index 1fd7994bed..1005f3a47b 100644 --- a/protocols/YAMN/src/proto/pop3/pop3.h +++ b/protocols/YAMN/src/proto/pop3/pop3.h @@ -20,7 +20,7 @@ class CPop3Client { public: CPop3Client(): NetClient(nullptr), Stopped(FALSE) {} - ~CPop3Client() {if (NetClient != nullptr) delete NetClient;} + ~CPop3Client() { delete NetClient; } char* Connect(const char* servername,const int port=110,BOOL UseSSL=FALSE, BOOL NoTLS=FALSE); char* RecvRest(char* prev,int mode,int size=65536); diff --git a/protocols/YAMN/src/proto/pop3/pop3comm.cpp b/protocols/YAMN/src/proto/pop3/pop3comm.cpp index 4d85a94f0c..93f7885135 100644 --- a/protocols/YAMN/src/proto/pop3/pop3comm.cpp +++ b/protocols/YAMN/src/proto/pop3/pop3comm.cpp @@ -1488,7 +1488,7 @@ void ExtractList(char *stream, int len, HYAMNMAIL queue) while (!WS(finder)) finder++; //jump characters while (WS(finder)) finder++; //jump whitespace finderend = finder + 1; - if (1 != sscanf(finder, "%d", &queueptr->MailData->Size)) + if (1 != sscanf(finder, "%u", &queueptr->MailData->Size)) throw (DWORD)EPOP3_LIST; #ifdef DEBUG_DECODE DebugLog(DecodeFile,"<Nr>%d</Nr>\n",queueptr->MailData->Size); |