From 129687d805025b4e292174ffb3d224a55baf24d2 Mon Sep 17 00:00:00 2001 From: ghazan Date: Sun, 26 Dec 2021 14:36:32 +0300 Subject: further code cleaning --- include/m_types.h | 2 ++ include/m_utils.h | 2 -- src/mir_app/src/contacts.cpp | 2 +- src/mir_app/src/db_events.cpp | 30 +++++++++++++++--------------- src/mir_app/src/db_intf.cpp | 2 +- src/mir_app/src/plugins.h | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/m_types.h b/include/m_types.h index dd22aa373f..8740be7f30 100644 --- a/include/m_types.h +++ b/include/m_types.h @@ -32,6 +32,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +using namespace std; + #define CALLBACK #define EXTERN_C extern "C" diff --git a/include/m_utils.h b/include/m_utils.h index 9e3f8139e0..f6f06f9988 100644 --- a/include/m_utils.h +++ b/include/m_utils.h @@ -424,8 +424,6 @@ namespace PU MIR_APP_DLL(int) SafeCreateDirectory(const wchar_t *pwszFolder); MIR_APP_DLL(int) SafeDeleteDirectory(const wchar_t *pwszDirName); MIR_APP_DLL(int) SafeCreateFilePath(const wchar_t *pwszFolder); - - }; #endif // M_UTILS_H__ diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index 06bedc465d..1a33be2375 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -147,7 +147,7 @@ MIR_APP_DLL(wchar_t*) Contact_GetInfo(int type, MCONTACT hContact, const char *s DBVARIANT dbv2; if (!db_get_ws(hContact, szProto, "LastName", &dbv2)) { size_t len = mir_wstrlen(dbv.pwszVal) + mir_wstrlen(dbv2.pwszVal) + 2; - wchar_t *buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*len); + wchar_t *buf = (wchar_t*)mir_alloc(sizeof(wchar_t)*len); if (buf != nullptr) mir_wstrcat(mir_wstrcat(mir_wstrcpy(buf, dbv.pwszVal), L" "), dbv2.pwszVal); db_free(&dbv); diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp index 5e7d3b376d..9f7653d1c0 100644 --- a/src/mir_app/src/db_events.cpp +++ b/src/mir_app/src/db_events.cpp @@ -162,7 +162,7 @@ static INT_PTR DbEventGetTextWorker(DBEVENTINFO *dbei, int codepage, int datatyp } if (dbei->eventType == EVENTTYPE_FILE) { - char *buf = LPSTR(dbei->pBlob) + sizeof(DWORD); + char *buf = LPSTR(dbei->pBlob) + sizeof(uint32_t); ptrW tszFileName(getEventString(dbei, buf)); ptrW tszDescription(getEventString(dbei, buf)); CMStringW wszText(tszFileName); @@ -187,7 +187,7 @@ static INT_PTR DbEventGetTextWorker(DBEVENTINFO *dbei, int codepage, int datatyp str[dbei->cbBlob] = 0; if (dbei->flags & DBEF_UTF) { - WCHAR *msg = nullptr; + wchar_t *msg = nullptr; mir_utf8decodecp(str, codepage, &msg); if (msg) return (INT_PTR)msg; @@ -272,37 +272,37 @@ DB::AUTH_BLOB::AUTH_BLOB(MCONTACT hContact, LPCSTR nick, LPCSTR fname, LPCSTR ln m_szEmail(mir_strdup(email)), m_szReason(mir_strdup(reason)) { - m_size = DWORD(sizeof(DWORD) * 2 + 5 + mir_strlen(m_szNick) + mir_strlen(m_szFirstName) + mir_strlen(m_szLastName) + mir_strlen(m_szEmail) + mir_strlen(m_szReason)); + m_size = uint32_t(sizeof(uint32_t) * 2 + 5 + mir_strlen(m_szNick) + mir_strlen(m_szFirstName) + mir_strlen(m_szLastName) + mir_strlen(m_szEmail) + mir_strlen(m_szReason)); } DB::AUTH_BLOB::AUTH_BLOB(PBYTE blob) { PBYTE pCurBlob = blob; - m_dwUin = *(PDWORD)pCurBlob; - pCurBlob += sizeof(DWORD); - m_hContact = *(PDWORD)pCurBlob; - pCurBlob += sizeof(DWORD); + m_dwUin = *(Puint32_t)pCurBlob; + pCurBlob += sizeof(uint32_t); + m_hContact = *(Puint32_t)pCurBlob; + pCurBlob += sizeof(uint32_t); m_szNick = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1; m_szFirstName = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1; m_szLastName = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1; m_szEmail = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1; m_szReason = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1; - m_size = DWORD(pCurBlob - blob); + m_size = uint32_t(pCurBlob - blob); } DB::AUTH_BLOB::~AUTH_BLOB() { } -PBYTE DB::AUTH_BLOB::makeBlob() +uint8_t* DB::AUTH_BLOB::makeBlob() { - PBYTE pBlob, pCurBlob; - pCurBlob = pBlob = (PBYTE)mir_alloc(m_size + 1); + uint8_t *pBlob, *pCurBlob; + pCurBlob = pBlob = (uint8_t*)mir_alloc(m_size + 1); - *((PDWORD)pCurBlob) = m_dwUin; - pCurBlob += sizeof(DWORD); - *((PDWORD)pCurBlob) = (DWORD)m_hContact; - pCurBlob += sizeof(DWORD); + *((uint32_t*)pCurBlob) = m_dwUin; + pCurBlob += sizeof(uint32_t); + *((uint32_t*)pCurBlob) = (uint32_t)m_hContact; + pCurBlob += sizeof(uint32_t); mir_snprintf((char*)pCurBlob, m_size - 8, "%s%c%s%c%s%c%s%c%s%c", (m_szNick) ? m_szNick.get() : "", 0, diff --git a/src/mir_app/src/db_intf.cpp b/src/mir_app/src/db_intf.cpp index af6ab6c1f9..16ec3a4e16 100644 --- a/src/mir_app/src/db_intf.cpp +++ b/src/mir_app/src/db_intf.cpp @@ -48,7 +48,7 @@ MIR_APP_DLL(DATABASELINK*) FindDatabasePlugin(const wchar_t *ptszFileName) { for (auto &it : arDbPlugins) { int error = it->grokHeader(ptszFileName); - if (error == ERROR_SUCCESS || error == EGROKPRF_OBSOLETE) + if (error == EGROKPRF_NOERROR || error == EGROKPRF_OBSOLETE) return it; } diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h index 6c6d8153b2..6b686265ab 100644 --- a/src/mir_app/src/plugins.h +++ b/src/mir_app/src/plugins.h @@ -5,8 +5,8 @@ #define DEFMOD_REMOVED_PROTOCOLNETLIB 22 // basic export prototypes -typedef int(__cdecl *Miranda_Plugin_Load) (void); -typedef int(__cdecl *Miranda_Plugin_Unload) (void); +typedef int(MIR_CDECL *Miranda_Plugin_Load) (void); +typedef int(MIR_CDECL *Miranda_Plugin_Unload) (void); struct pluginEntry { -- cgit v1.2.3