diff options
author | Goraf <22941576+Goraf@users.noreply.github.com> | 2017-11-13 15:03:31 +0100 |
---|---|---|
committer | Goraf <22941576+Goraf@users.noreply.github.com> | 2017-11-13 15:07:33 +0100 |
commit | a7c24ca48995cf2bf436156302f96b91bf135409 (patch) | |
tree | 953835509ff1b778833e78fd7b74b05e05e77c84 /plugins/CryptoPP | |
parent | 591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff) |
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/CryptoPP')
-rw-r--r-- | plugins/CryptoPP/src/base16.cpp | 2 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_cntx.cpp | 4 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_gpgw.cpp | 14 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_keys.cpp | 4 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_misc.cpp | 10 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_pgpw.cpp | 16 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_rsam.cpp | 48 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_rsau.cpp | 2 | ||||
-rw-r--r-- | plugins/CryptoPP/src/cpp_svcs.cpp | 44 | ||||
-rw-r--r-- | plugins/CryptoPP/src/main.cpp | 16 | ||||
-rw-r--r-- | plugins/CryptoPP/src/mmi.cpp | 4 | ||||
-rw-r--r-- | plugins/CryptoPP/src/utf8.cpp | 18 |
12 files changed, 91 insertions, 91 deletions
diff --git a/plugins/CryptoPP/src/base16.cpp b/plugins/CryptoPP/src/base16.cpp index 689d54c88a..e716b4be4f 100644 --- a/plugins/CryptoPP/src/base16.cpp +++ b/plugins/CryptoPP/src/base16.cpp @@ -40,7 +40,7 @@ char *base16decode(const char *inBuffer, unsigned int *count) if ((c0 | c1) == BERR) {
free(outBuffer);
*count = 0;
- return(NULL);
+ return(nullptr);
}
*outBufferPtr++ = (c0 << 4) | c1;
*count -= 2;
diff --git a/plugins/CryptoPP/src/cpp_cntx.cpp b/plugins/CryptoPP/src/cpp_cntx.cpp index 327890f4ea..9628477124 100644 --- a/plugins/CryptoPP/src/cpp_cntx.cpp +++ b/plugins/CryptoPP/src/cpp_cntx.cpp @@ -12,7 +12,7 @@ pCNTX get_context_on_id(HANDLE context) Sent_NetLog("get_context_on_id: corrupted context %08X", cntx);
#endif
}
- return NULL;
+ return nullptr;
}
// create context, return context id
@@ -71,7 +71,7 @@ PBYTE cpp_alloc_pdata(pCNTX ptr) void cpp_free_keys(pCNTX ptr)
{
mir_free(ptr->tmp);
- ptr->tmp = 0;
+ ptr->tmp = nullptr;
cpp_alloc_pdata(ptr);
if (ptr->mode & MODE_PGP) {
pPGPDATA p = (pPGPDATA)ptr->pdata;
diff --git a/plugins/CryptoPP/src/cpp_gpgw.cpp b/plugins/CryptoPP/src/cpp_gpgw.cpp index a86d2219cd..bda82d6e6f 100644 --- a/plugins/CryptoPP/src/cpp_gpgw.cpp +++ b/plugins/CryptoPP/src/cpp_gpgw.cpp @@ -30,7 +30,7 @@ int __cdecl gpg_done() int r = 0;
if (hgpg) {
r = _gpg_done();
- hgpg = 0;
+ hgpg = nullptr;
}
return r;
}
@@ -68,7 +68,7 @@ LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg) LPSTR szEncMsg = _gpg_encrypt(szPlainMsg, (LPCSTR)p->gpgKeyID);
mir_free(ptr->tmp);
if (!szEncMsg) {
- return ptr->tmp = 0;
+ return ptr->tmp = nullptr;
}
else {
ptr->tmp = mir_strdup(szEncMsg);
@@ -93,11 +93,11 @@ LPSTR __cdecl gpg_encode(HANDLE context, LPCSTR szPlainMsg) {
pCNTX ptr = get_context_on_id(context);
if (!ptr)
- return NULL;
+ return nullptr;
pGPGDATA p = (pGPGDATA)cpp_alloc_pdata(ptr);
if (!p->gpgKeyID) {
ptr->error = ERROR_NO_GPG_KEY;
- return NULL;
+ return nullptr;
}
// utf8 message: encrypt.
@@ -106,7 +106,7 @@ LPSTR __cdecl gpg_encode(HANDLE context, LPCSTR szPlainMsg) LPWSTR wszMsg = utf8decode(szPlainMsg);
int wlen = (int)wcslen(wszMsg) + 1;
szUtfMsg = (LPSTR)alloca(wlen);
- WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szUtfMsg, wlen, 0, 0);
+ WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szUtfMsg, wlen, nullptr, nullptr);
}
else {
szUtfMsg = (LPSTR)szPlainMsg;
@@ -119,9 +119,9 @@ LPSTR __cdecl gpg_decode(HANDLE context, LPCSTR szEncMsg) {
pCNTX ptr = get_context_on_id(context);
if (!ptr)
- return NULL;
+ return nullptr;
- LPSTR szNewMsg = NULL;
+ LPSTR szNewMsg = nullptr;
LPSTR szOldMsg = gpg_decrypt(ptr, szEncMsg);
if (szOldMsg) {
diff --git a/plugins/CryptoPP/src/cpp_keys.cpp b/plugins/CryptoPP/src/cpp_keys.cpp index 37a197d70f..8cfea1c040 100644 --- a/plugins/CryptoPP/src/cpp_keys.cpp +++ b/plugins/CryptoPP/src/cpp_keys.cpp @@ -5,7 +5,7 @@ const unsigned char IV[] = "PSKhell@MIRANDA!"; // generate KeyA pair, return public key as ASCII
LPSTR __cdecl cpp_init_keya(HANDLE context, int features)
{
- pCNTX ptr = get_context_on_id(context); if (!ptr) return NULL;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return nullptr;
pSIMDATA p = (pSIMDATA)cpp_alloc_pdata(ptr);
int send_features = FEATURES;
@@ -156,7 +156,7 @@ int __cdecl cpp_calc_keyx(HANDLE context) // not needed anymore
SAFE_FREE(p->PubA);
SAFE_FREE(p->KeyA);
- mir_free(p->KeyB); p->KeyB = 0;
+ mir_free(p->KeyB); p->KeyB = nullptr;
BYTE buffer[Tiger::DIGESTSIZE]; // buffer for hash
memset(buffer, 0, sizeof(buffer));
diff --git a/plugins/CryptoPP/src/cpp_misc.cpp b/plugins/CryptoPP/src/cpp_misc.cpp index 6f9ca08ab4..bdd3f2a645 100644 --- a/plugins/CryptoPP/src/cpp_misc.cpp +++ b/plugins/CryptoPP/src/cpp_misc.cpp @@ -54,7 +54,7 @@ void __cdecl cpp_set_keyx(HANDLE context, BYTE *key) return;
SAFE_FREE(p->PubA);
SAFE_FREE(p->KeyA);
- mir_free(p->KeyB); p->KeyB = 0;
+ mir_free(p->KeyB); p->KeyB = nullptr;
SAFE_FREE(p->KeyX);
p->KeyX = (PBYTE)malloc(Tiger::DIGESTSIZE + 2);
memcpy(p->KeyX, key, Tiger::DIGESTSIZE);
@@ -92,7 +92,7 @@ int __cdecl cpp_keya(HANDLE context) pSIMDATA p;
if (!cpp_get_simdata(context, &ptr, &p))
return 0;
- return p->KeyA != NULL;
+ return p->KeyA != nullptr;
}
int __cdecl cpp_keyb(HANDLE context)
@@ -101,7 +101,7 @@ int __cdecl cpp_keyb(HANDLE context) pSIMDATA p;
if (!cpp_get_simdata(context, &ptr, &p))
return 0;
- return p->KeyB != NULL;
+ return p->KeyB != nullptr;
}
int __cdecl cpp_keyx(HANDLE context)
@@ -110,7 +110,7 @@ int __cdecl cpp_keyx(HANDLE context) pSIMDATA p;
if (!cpp_get_simdata(context, &ptr, &p))
return 0;
- return p->KeyX != NULL;
+ return p->KeyX != nullptr;
}
int __cdecl cpp_keyp(HANDLE context)
@@ -119,5 +119,5 @@ int __cdecl cpp_keyp(HANDLE context) pSIMDATA p;
if (!cpp_get_simdata(context, &ptr, &p))
return 0;
- return p->KeyP != NULL;
+ return p->KeyP != nullptr;
}
diff --git a/plugins/CryptoPP/src/cpp_pgpw.cpp b/plugins/CryptoPP/src/cpp_pgpw.cpp index 366a3776de..d574c2f236 100644 --- a/plugins/CryptoPP/src/cpp_pgpw.cpp +++ b/plugins/CryptoPP/src/cpp_pgpw.cpp @@ -107,7 +107,7 @@ int __cdecl pgp_done() pgpVer = 0;
if (hpgpsdk) {
r = p_pgp_done();
- hpgpsdk = 0;
+ hpgpsdk = nullptr;
}
return r;
}
@@ -140,7 +140,7 @@ LPSTR __cdecl pgp_encrypt(pCNTX ptr, LPCSTR szPlainMsg) LPSTR szEncMsg = (p->pgpKey ? p_pgp_encrypt_key(szPlainMsg, (LPCSTR)p->pgpKey) : p_pgp_encrypt_keydb(szPlainMsg, p->pgpKeyID));
if (!szEncMsg) {
- return ptr->tmp = 0;
+ return ptr->tmp = nullptr;
}
else {
ptr->tmp = mir_strdup(szEncMsg);
@@ -154,7 +154,7 @@ LPSTR __cdecl pgp_decrypt(pCNTX ptr, LPCSTR szEncMsg) {
ptr->error = ERROR_NONE;
mir_free(ptr->tmp);
- ptr->tmp = NULL;
+ ptr->tmp = nullptr;
LPSTR szPlainMsg = p_pgp_decrypt_keydb(szEncMsg);
if (!szPlainMsg) {
@@ -165,7 +165,7 @@ LPSTR __cdecl pgp_decrypt(pCNTX ptr, LPCSTR szEncMsg) szPlainMsg = p_pgp_decrypt_key(szEncMsg, (LPCSTR)p->pgpKey);
}
if (!szPlainMsg) {
- return NULL;
+ return nullptr;
}
}
@@ -176,11 +176,11 @@ LPSTR __cdecl pgp_decrypt(pCNTX ptr, LPCSTR szEncMsg) LPSTR __cdecl pgp_encode(HANDLE context, LPCSTR szPlainMsg)
{
- pCNTX ptr = get_context_on_id(context); if (!ptr) return NULL;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return nullptr;
pPGPDATA p = (pPGPDATA)cpp_alloc_pdata(ptr);
if (!p->pgpKeyID && !p->pgpKey) {
ptr->error = ERROR_NO_PGP_KEY;
- return NULL;
+ return nullptr;
}
// utf8 message: encrypt.
@@ -191,10 +191,10 @@ LPSTR __cdecl pgp_decode(HANDLE context, LPCSTR szEncMsg) {
pCNTX ptr = get_context_on_id(context);
if (!ptr)
- return NULL;
+ return nullptr;
mir_free(ptr->tmp);
- LPSTR szNewMsg = NULL;
+ LPSTR szNewMsg = nullptr;
LPSTR szOldMsg = pgp_decrypt(ptr, szEncMsg);
if (szOldMsg) {
diff --git a/plugins/CryptoPP/src/cpp_rsam.cpp b/plugins/CryptoPP/src/cpp_rsam.cpp index ebf0564bc6..c2eddf6cc8 100644 --- a/plugins/CryptoPP/src/cpp_rsam.cpp +++ b/plugins/CryptoPP/src/cpp_rsam.cpp @@ -72,9 +72,9 @@ int __cdecl rsa_done(void) pCNTX tmp = (pCNTX)hRSA4096;
pRSAPRIV p = (pRSAPRIV)tmp->pdata;
delete p;
- tmp->pdata = 0;
+ tmp->pdata = nullptr;
cpp_delete_context(hRSA4096);
- hRSA4096 = NULL;
+ hRSA4096 = nullptr;
}
return 1;
@@ -86,18 +86,18 @@ int __cdecl rsa_done(void) pRSAPRIV rsa_gen_keys(HANDLE context)
{
- if (context != hRSA4096) return 0;
+ if (context != hRSA4096) return nullptr;
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_gen_keys: %d", context);
#endif
- pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return nullptr;
pRSAPRIV r = (pRSAPRIV)ptr->pdata;
string priv, pub;
GenerateRSAKey(4096, priv, pub);
- StringSource privsrc(priv, true, NULL);
+ StringSource privsrc(priv, true, nullptr);
RSAES_PKCS1v15_Decryptor Decryptor(privsrc);
priv = tlv(1, IntegerToBinary(Decryptor.GetTrapdoorFunction().GetModulus())) +
@@ -116,7 +116,7 @@ pRSAPRIV rsa_gen_keys(HANDLE context) pRSAPRIV rsa_get_priv(pCNTX ptr)
{
- pCNTX p = get_context_on_id(hRSA4096); if (!p) return 0;
+ pCNTX p = get_context_on_id(hRSA4096); if (!p) return nullptr;
pRSAPRIV r = (pRSAPRIV)p->pdata;
return r;
}
@@ -316,18 +316,18 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) #if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_recv: %s", msg);
#endif
- pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return nullptr;
pRSADATA p = (pRSADATA)cpp_alloc_pdata(ptr);
pRSAPRIV r = rsa_get_priv(ptr);
rtrim(msg);
string buf = base64decode(msg);
- if (!buf.length()) return 0;
+ if (!buf.length()) return nullptr;
string data; int type;
un_tlv(buf, type, data);
- if (type == -1) return 0;
+ if (type == -1) return nullptr;
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_recv: %02x %d", type, p->state);
@@ -338,7 +338,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) p->state = 0; p->time = 0;
rsa_free(ptr); // удалим трэд и очередь сообщений
null_msg(context, 0x00, -1); // сессия разорвана по ошибке, неверный тип сообщения
- return 0;
+ return nullptr;
}
switch (type) {
@@ -346,7 +346,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) case 0x00: // прерывание сессии по ошибке другой стороной
{
// если соединение установлено - ничего не делаем
- if (p->state == 0 || p->state == 7) return 0;
+ if (p->state == 0 || p->state == 7) return nullptr;
// иначе сбрасываем текущее состояние
p->state = 0; p->time = 0;
imp->rsa_notify(context, -2); // сессия разорвана по ошибке другой стороной
@@ -365,9 +365,9 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) case 0x0D: // запрос паблика
case 0xD0: // ответ пабликом
if (!p->event) {
- p->event = CreateEvent(NULL, FALSE, FALSE, NULL);
+ p->event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
unsigned int tID;
- p->thread = (HANDLE)_beginthreadex(NULL, 0, sttConnectThread, (PVOID)context, 0, &tID);
+ p->thread = (HANDLE)_beginthreadex(nullptr, 0, sttConnectThread, (PVOID)context, 0, &tID);
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_recv: _beginthreadex(sttConnectThread)");
#endif
@@ -383,7 +383,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) if (!decode_msg(p, data).length()) {
p->state = 0; p->time = 0;
null_msg(context, 0x00, -type); // сессия разорвана по ошибке
- return 0;
+ return nullptr;
}
{
PBYTE buffer = (PBYTE)alloca(RAND_SIZE);
@@ -399,7 +399,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) if (!decode_msg(p, data).length()) {
p->state = 0; p->time = 0;
null_msg(context, 0x00, -type); // сессия разорвана по ошибке
- return 0;
+ return nullptr;
}
p->state = 7; p->time = 0;
rsa_free_thread(p); // удалим трэд и очередь сообщений
@@ -414,7 +414,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) return ptr->tmp = mir_strdup(msg.c_str());
else {
imp->rsa_notify(context, -5); // ошибка декодирования AES сообщения
- return ptr->tmp = NULL;
+ return ptr->tmp = nullptr;
}
}
@@ -426,15 +426,15 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) return ptr->tmp = mir_strdup(msg.c_str());
else {
imp->rsa_notify(context, -6); // ошибка декодирования RSA сообщения
- return ptr->tmp = NULL;
+ return ptr->tmp = nullptr;
}
}
case 0xF0: // разрыв соединения вручную
{
- if (p->state != 7) return 0;
+ if (p->state != 7) return nullptr;
string msg = decode_msg(p, data);
- if (!msg.length()) return 0;
+ if (!msg.length()) return nullptr;
p->state = 0;
rsa_free(ptr); // удалим трэд и очередь сообщений
imp->rsa_notify(context, -4); // соединение разорвано вручную другой стороной
@@ -451,7 +451,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) if (p->state != 0 && p->state != 7)
p->time = gettime() + timeout;
- return 0;
+ return nullptr;
}
int __cdecl rsa_send(HANDLE context, LPCSTR msg)
@@ -846,7 +846,7 @@ void rsa_alloc(pCNTX ptr) pRSADATA p = new RSADATA;
p->state = 0;
p->time = 0;
- p->thread = p->event = NULL;
+ p->thread = p->event = nullptr;
p->thread_exit = 0;
p->queue = new STRINGQUEUE;
ptr->pdata = (PBYTE)p;
@@ -855,7 +855,7 @@ void rsa_alloc(pCNTX ptr) int rsa_free(pCNTX ptr)
{
pRSADATA p = (pRSADATA)ptr->pdata;
- if (p == NULL)
+ if (p == nullptr)
return true;
if (p->event) {
@@ -866,7 +866,7 @@ int rsa_free(pCNTX ptr) delete p->queue;
delete p;
- ptr->pdata = NULL;
+ ptr->pdata = nullptr;
return true;
}
@@ -879,7 +879,7 @@ void rsa_free_thread(pRSADATA p) WaitForSingleObject(p->thread, INFINITE);
CloseHandle(p->thread);
CloseHandle(p->event);
- p->thread = p->event = NULL;
+ p->thread = p->event = nullptr;
p->thread_exit = 0;
}
p->time = 0;
diff --git a/plugins/CryptoPP/src/cpp_rsau.cpp b/plugins/CryptoPP/src/cpp_rsau.cpp index b2bc42d302..d476c4fb1c 100644 --- a/plugins/CryptoPP/src/cpp_rsau.cpp +++ b/plugins/CryptoPP/src/cpp_rsau.cpp @@ -157,7 +157,7 @@ string hash256(PBYTE b, size_t l) Integer BinaryToInteger(const string& data)
{
- StringSource ss(data, true, NULL);
+ StringSource ss(data, true, nullptr);
SecByteBlock result(ss.MaxRetrievable());
ss.Get(result, result.size());
return Integer(result, result.size());
diff --git a/plugins/CryptoPP/src/cpp_svcs.cpp b/plugins/CryptoPP/src/cpp_svcs.cpp index ed5af8bdbb..089d535a8f 100644 --- a/plugins/CryptoPP/src/cpp_svcs.cpp +++ b/plugins/CryptoPP/src/cpp_svcs.cpp @@ -93,7 +93,7 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) Sent_NetLog("cpp_decrypt: error bad_len");
#endif
ptr->error = ERROR_BAD_LEN;
- return NULL;
+ return nullptr;
}
BYTE crc32[CRC32::DIGESTSIZE];
@@ -106,7 +106,7 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) Sent_NetLog("cpp_decrypt: error bad_crc");
#endif
ptr->error = ERROR_BAD_CRC;
- return NULL;
+ return nullptr;
}
bciphered += CRC32::DIGESTSIZE; // cut CRC32 digest
clen = len;
@@ -138,8 +138,8 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) #if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("cpp_decrypt: error seh");
#endif
- mir_free(ptr->tmp); ptr->tmp = 0;
- return NULL;
+ mir_free(ptr->tmp); ptr->tmp = nullptr;
+ return nullptr;
}
}
@@ -148,11 +148,11 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) LPSTR __cdecl cpp_encodeA(HANDLE context, LPCSTR msg)
{
pCNTX ptr = get_context_on_id(context);
- if (!ptr) return NULL;
+ if (!ptr) return nullptr;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA)ptr->pdata;
- if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return nullptr; }
- LPSTR szNewMsg = NULL;
+ LPSTR szNewMsg = nullptr;
LPSTR szOldMsg = (LPSTR)msg;
if (ptr->features & FEATURES_UTF8) {
@@ -176,11 +176,11 @@ LPSTR __cdecl cpp_encodeA(HANDLE context, LPCSTR msg) LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg)
{
pCNTX ptr = get_context_on_id(context);
- if (!ptr) return NULL;
+ if (!ptr) return nullptr;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA)ptr->pdata;
- if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return nullptr; }
- LPSTR szNewMsg = NULL;
+ LPSTR szNewMsg = nullptr;
LPSTR szOldMsg = (LPSTR)msg;
if (ptr->features & FEATURES_UTF8) {
@@ -192,7 +192,7 @@ LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg) LPWSTR wstring = utf8decode(szOldMsg);
int wlen = (int)wcslen(wstring) + 1;
LPSTR astring = (LPSTR)alloca(wlen);
- WideCharToMultiByte(CP_ACP, 0, (LPWSTR)szOldMsg, -1, astring, wlen, 0, 0);
+ WideCharToMultiByte(CP_ACP, 0, (LPWSTR)szOldMsg, -1, astring, wlen, nullptr, nullptr);
szNewMsg = cpp_encrypt(ptr, astring);
}
@@ -203,11 +203,11 @@ LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg) LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg)
{
pCNTX ptr = get_context_on_id(context);
- if (!ptr) return NULL;
+ if (!ptr) return nullptr;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA)ptr->pdata;
- if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return nullptr; }
- LPSTR szNewMsg = NULL;
+ LPSTR szNewMsg = nullptr;
LPSTR szOldMsg = (LPSTR)msg;
if (ptr->features & FEATURES_UTF8) {
@@ -218,7 +218,7 @@ LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg) // unicode message: convert to ansi and encrypt.
int wlen = (int)wcslen((LPWSTR)szOldMsg) + 1;
LPSTR astring = (LPSTR)alloca(wlen);
- WideCharToMultiByte(CP_ACP, 0, (LPWSTR)szOldMsg, -1, astring, wlen, 0, 0);
+ WideCharToMultiByte(CP_ACP, 0, (LPWSTR)szOldMsg, -1, astring, wlen, nullptr, nullptr);
szNewMsg = cpp_encrypt(ptr, astring);
}
@@ -230,11 +230,11 @@ LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg) LPSTR __cdecl cpp_decode(HANDLE context, LPCSTR szEncMsg)
{
pCNTX ptr = get_context_on_id(context);
- if (!ptr) return NULL;
+ if (!ptr) return nullptr;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA)ptr->pdata;
- if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return nullptr; }
- LPSTR szNewMsg = NULL;
+ LPSTR szNewMsg = nullptr;
LPSTR szOldMsg = cpp_decrypt(ptr, szEncMsg);
if (szOldMsg) {
@@ -243,7 +243,7 @@ LPSTR __cdecl cpp_decode(HANDLE context, LPCSTR szEncMsg) LPWSTR wstring = utf8decode(szOldMsg);
int wlen = (int)wcslen(wstring) + 1;
szNewMsg = (LPSTR)mir_alloc(wlen*(sizeof(WCHAR)+2)); // work.zy@gmail.com
- WideCharToMultiByte(CP_ACP, 0, wstring, -1, szNewMsg, wlen, 0, 0);
+ WideCharToMultiByte(CP_ACP, 0, wstring, -1, szNewMsg, wlen, nullptr, nullptr);
memcpy(szNewMsg + strlen(szNewMsg) + 1, wstring, wlen*sizeof(WCHAR)); // work.zy@gmail.com
}
else {
@@ -265,12 +265,12 @@ LPSTR __cdecl cpp_decodeU(HANDLE context, LPCSTR szEncMsg) {
pCNTX ptr = get_context_on_id(context);
if (!ptr)
- return NULL;
+ return nullptr;
mir_free(ptr->tmp);
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA)ptr->pdata;
- if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return nullptr; }
- LPSTR szNewMsg = NULL;
+ LPSTR szNewMsg = nullptr;
LPSTR szOldMsg = cpp_decrypt(ptr, szEncMsg);
if (szOldMsg) {
diff --git a/plugins/CryptoPP/src/main.cpp b/plugins/CryptoPP/src/main.cpp index dc5e3c67e9..9adee52785 100644 --- a/plugins/CryptoPP/src/main.cpp +++ b/plugins/CryptoPP/src/main.cpp @@ -5,8 +5,8 @@ LPCSTR szModuleName = MODULENAME; LPCSTR szVersionStr = MODULENAME" DLL (" __VERSION_STRING_DOTS ")";
HINSTANCE g_hInst;
-HANDLE hPGPPRIV = NULL;
-HANDLE hRSA4096 = NULL;
+HANDLE hPGPPRIV = nullptr;
+HANDLE hRSA4096 = nullptr;
mir_cs localQueueMutex;
mir_cs localContextMutex;
@@ -72,15 +72,15 @@ extern "C" __declspec(dllexport) int Unload() BOOL ExtractFileFromResource(HANDLE FH, int ResType, int ResId, DWORD* Size)
{
HRSRC RH = FindResource(g_hInst, MAKEINTRESOURCE(ResId), MAKEINTRESOURCE(ResType));
- if (RH == NULL)
+ if (RH == nullptr)
return FALSE;
PBYTE RP = (PBYTE)LoadResource(g_hInst, RH);
- if (RP == NULL)
+ if (RP == nullptr)
return FALSE;
DWORD x, s = SizeofResource(g_hInst, RH);
- if (!WriteFile(FH, RP, s, &x, NULL)) return FALSE;
+ if (!WriteFile(FH, RP, s, &x, nullptr)) return FALSE;
if (x != s) return FALSE;
if (Size) *Size = s;
return TRUE;
@@ -88,12 +88,12 @@ BOOL ExtractFileFromResource(HANDLE FH, int ResType, int ResId, DWORD* Size) void ExtractFile(char *FileName, int ResType, int ResId)
{
- HANDLE FH = CreateFile(FileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+ HANDLE FH = CreateFile(FileName, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, nullptr);
if (FH == INVALID_HANDLE_VALUE)
return;
- if (!ExtractFileFromResource(FH, ResType, ResId, NULL))
- MessageBoxA(0, "Can't extract", "!!!", MB_OK);
+ if (!ExtractFileFromResource(FH, ResType, ResId, nullptr))
+ MessageBoxA(nullptr, "Can't extract", "!!!", MB_OK);
CloseHandle(FH);
}
diff --git a/plugins/CryptoPP/src/mmi.cpp b/plugins/CryptoPP/src/mmi.cpp index 321dc1d871..5eb6f4af3e 100644 --- a/plugins/CryptoPP/src/mmi.cpp +++ b/plugins/CryptoPP/src/mmi.cpp @@ -4,7 +4,7 @@ void __fastcall safe_free(void** p) {
if (*p) {
free(*p);
- *p = NULL;
+ *p = nullptr;
}
}
@@ -13,6 +13,6 @@ void __fastcall safe_delete(void** p) {
if (*p) {
delete(*p);
- *p = NULL;
+ *p = nullptr;
}
}
diff --git a/plugins/CryptoPP/src/utf8.cpp b/plugins/CryptoPP/src/utf8.cpp index 77c13fa3bc..83d4e4a97a 100644 --- a/plugins/CryptoPP/src/utf8.cpp +++ b/plugins/CryptoPP/src/utf8.cpp @@ -1,15 +1,15 @@ #include "commonheaders.h"
-LPSTR szOut = NULL;
-LPWSTR wszOut = NULL;
+LPSTR szOut = nullptr;
+LPWSTR wszOut = nullptr;
LPSTR __cdecl utf8encode(LPCWSTR str)
{
LPWSTR wszTemp, w;
int len, i;
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
wszTemp = (LPWSTR)str;
@@ -21,8 +21,8 @@ LPSTR __cdecl utf8encode(LPCWSTR str) }
SAFE_FREE(szOut);
- if ((szOut = (LPSTR)malloc(len + 1)) == NULL)
- return NULL;
+ if ((szOut = (LPSTR)malloc(len + 1)) == nullptr)
+ return nullptr;
i = 0;
for (w = wszTemp; *w; w++) {
@@ -49,13 +49,13 @@ LPWSTR __cdecl utf8decode(LPCSTR str) LPSTR p;
// LPWSTR wszOut;
- if (str == NULL) return NULL;
+ if (str == nullptr) return nullptr;
size_t len = strlen(str) + 1;
SAFE_FREE(wszOut);
- if ((wszOut = (LPWSTR)malloc(len*sizeof(WCHAR))) == NULL)
- return NULL;
+ if ((wszOut = (LPWSTR)malloc(len*sizeof(WCHAR))) == nullptr)
+ return nullptr;
p = (LPSTR)str;
i = 0;
while (*p) {
|