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/CmdLine | |
parent | 591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff) |
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/CmdLine')
-rw-r--r-- | plugins/CmdLine/src/CmdLine.cpp | 2 | ||||
-rw-r--r-- | plugins/CmdLine/src/hooked_events.cpp | 2 | ||||
-rw-r--r-- | plugins/CmdLine/src/mimcmd_handlers.cpp | 46 | ||||
-rw-r--r-- | plugins/CmdLine/src/mimcmd_ipc.cpp | 32 | ||||
-rw-r--r-- | plugins/CmdLine/src/services.cpp | 6 | ||||
-rw-r--r-- | plugins/CmdLine/src/utils.cpp | 18 |
6 files changed, 53 insertions, 53 deletions
diff --git a/plugins/CmdLine/src/CmdLine.cpp b/plugins/CmdLine/src/CmdLine.cpp index f73288f91b..b28fe18a7d 100644 --- a/plugins/CmdLine/src/CmdLine.cpp +++ b/plugins/CmdLine/src/CmdLine.cpp @@ -50,7 +50,7 @@ extern "C" int __declspec(dllexport) Load(void) pcli = Clist_GetInterface();
if (InitServer())
- MessageBox(0, TranslateT("Could not initialize CmdLine plugin property"), TranslateT("Error"), MB_ICONEXCLAMATION | MB_OK);
+ MessageBox(nullptr, TranslateT("Could not initialize CmdLine plugin property"), TranslateT("Error"), MB_ICONEXCLAMATION | MB_OK);
HookEvents();
return 0;
diff --git a/plugins/CmdLine/src/hooked_events.cpp b/plugins/CmdLine/src/hooked_events.cpp index 1d7c336e03..663a7fe3b0 100644 --- a/plugins/CmdLine/src/hooked_events.cpp +++ b/plugins/CmdLine/src/hooked_events.cpp @@ -76,7 +76,7 @@ ACKDATA* GetAck(HANDLE hProcess) }
}
- return NULL;
+ return nullptr;
}
int OnProtoAck(WPARAM, LPARAM lParam)
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index d50af580e2..d8f7f39c5e 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -70,7 +70,7 @@ int Get2StateValue(char *state) int AccountName2Protocol(const char *accountName, OUT char *uniqueProtocolName, size_t length)
{
int count;
- PROTOACCOUNT **accounts = NULL;
+ PROTOACCOUNT **accounts = nullptr;
Proto_EnumAccounts(&count, &accounts);
strncpy_s(uniqueProtocolName, length, accountName, _TRUNCATE);
@@ -213,7 +213,7 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep CMStringA perAccountStatus;
int count;
- PROTOACCOUNT **accounts = NULL;
+ PROTOACCOUNT **accounts = nullptr;
Proto_EnumAccounts(&count, &accounts);
char pn[128];
@@ -243,7 +243,7 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep INT_PTR old = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
char po[128];
if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) {
- announce_status_change(NULL, status, NULL);
+ announce_status_change(nullptr, status, nullptr);
}
PrettyStatusMode(old, po, sizeof(po));
@@ -272,7 +272,7 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep INT_PTR old = CallProtoService(protocol, PS_GETSTATUS, 0, 0);
char po[128];
if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) {
- announce_status_change(protocol, status, NULL);
+ announce_status_change(protocol, status, nullptr);
}
PrettyStatusMode(old, po, sizeof(po));
@@ -316,7 +316,7 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re {
char *awayMsg = argv[2];
int count = 0;
- PROTOACCOUNT **accounts = NULL;
+ PROTOACCOUNT **accounts = nullptr;
Proto_EnumAccounts(&count, &accounts);
CMStringA szReply;
@@ -704,8 +704,8 @@ void HandleCallServiceCommand(PCommand command, TArgument *argv, int argc, PRepl {
char *service = argv[2];
if (ServiceExists(service)) {
- void *wParam = NULL;
- void *lParam = NULL;
+ void *wParam = nullptr;
+ void *lParam = nullptr;
INT_PTR res1 = ParseValueParam(argv[3], wParam);
INT_PTR res2 = ParseValueParam(argv[4], lParam);
if ((res1 != 0) && (res2 != 0)) {
@@ -757,8 +757,8 @@ MCONTACT ParseContactParam(char *contact) char account[128];
char protocol[128];
char *p = strrchr(contact, ':');
- if (p == 0)
- return GetContactFromID(contact, (char*)NULL);
+ if (p == nullptr)
+ return GetContactFromID(contact, (char*)nullptr);
*p = 0;
strncpy_s(name, contact, _TRUNCATE);
@@ -775,7 +775,7 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re ParseMessage(message, argv[argc - 1]); //get the message
CMStringA szReply;
- ACKDATA *ack = NULL;
+ ACKDATA *ack = nullptr;
for (int i = 2; i < argc - 1; i++) {
char *contact = argv[i];
MCONTACT hContact = ParseContactParam(contact);
@@ -788,7 +788,7 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re HANDLE hProcess = (HANDLE)ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)message);
const int MAX_COUNT = 60;
int counter = 0;
- while (((ack = GetAck(hProcess)) == NULL) && (counter < MAX_COUNT)) {
+ while (((ack = GetAck(hProcess)) == nullptr) && (counter < MAX_COUNT)) {
SleepEx(250, TRUE);
counter++;
}
@@ -799,7 +799,7 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re if (ack->szModule) {
szReply.AppendFormat(Translate("Message sent to '%s'."), contact);
- DBEVENTINFO e = { 0 };
+ DBEVENTINFO e = {};
char module[128];
e.eventType = EVENTTYPE_MESSAGE;
e.flags = DBEF_SENT;
@@ -809,7 +809,7 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re strncpy_s(module, ack->szModule, sizeof(module));
e.szModule = module;
- e.timestamp = (DWORD)time(NULL);
+ e.timestamp = (DWORD)time(nullptr);
db_event_add(ack->hContact, &e);
}
@@ -903,8 +903,8 @@ void HandleDatabaseCommand(PCommand command, TArgument *argv, int argc, PReply r char *module = argv[3];
char *key = argv[4];
- void *value = NULL;
- char *wrote = NULL;
+ void *value = nullptr;
+ char *wrote = nullptr;
int type = ParseValueParam(argv[5], value);
switch (type) {
@@ -1130,7 +1130,7 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe int type = ParseProxyType(argv[4]);
char *host = argv[5];
long port;
- char *stop = NULL;
+ char *stop = nullptr;
port = strtol(argv[6], &stop, 10);
if ((*stop == 0) && (type > 0)) {
@@ -1181,7 +1181,7 @@ void HandleProxyCommand(PCommand command, TArgument *argv, int argc, PReply repl AccountName2Protocol(account, protocol, sizeof(protocol));
int count = 0;
- PROTOACCOUNT **accounts = NULL;
+ PROTOACCOUNT **accounts = nullptr;
Proto_EnumAccounts(&count, &accounts);
int i;
@@ -1243,7 +1243,7 @@ int ContactMatchSearch(MCONTACT hContact, char *contact, char *id, char *account pos = strstr(lwrKeyword, "account:");
if (pos) {
pos += 8;
- if (strstr(lwrAccount, pos) == NULL) {
+ if (strstr(lwrAccount, pos) == nullptr) {
matches = 0;
break;
@@ -1267,12 +1267,12 @@ int ContactMatchSearch(MCONTACT hContact, char *contact, char *id, char *account pos = strstr(lwrKeyword, "id:");
if (pos) {
pos += 3;
- if (strstr(lwrID, pos) == NULL) {
+ if (strstr(lwrID, pos) == nullptr) {
matches = 0;
break;
}
}
- else if ((strstr(lwrName, lwrKeyword) == NULL)) {
+ else if ((strstr(lwrName, lwrKeyword) == nullptr)) {
matches = 0;
break;
}
@@ -1483,8 +1483,8 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re MCONTACT hContact = ParseContactParam(contact);
if (hContact) {
if (_stricmp(cmd, "show") == 0) {
- char *stop1 = NULL;
- char *stop2 = NULL;
+ char *stop1 = nullptr;
+ char *stop2 = nullptr;
long start = strtol(argv[4], &stop1, 10);
long stop = strtol(argv[5], &stop2, 10);
if (!(*stop1) && !(*stop2)) {
@@ -1619,7 +1619,7 @@ void HandleLuaCommand(PCommand command, TArgument *argv, int argc, PReply reply) if (_stricmp(argv[2], "call") == 0) {
wchar_t *result = argc == 4
- ? lua_call(NULL, _A2T(argv[3]))
+ ? lua_call(nullptr, _A2T(argv[3]))
: lua_call(_A2T(argv[3]), _A2T(argv[4]));
mir_strcpy(reply->message, _T2A(result));
mir_free(result);
diff --git a/plugins/CmdLine/src/mimcmd_ipc.cpp b/plugins/CmdLine/src/mimcmd_ipc.cpp index f61b70eb82..d9cf61a21a 100644 --- a/plugins/CmdLine/src/mimcmd_ipc.cpp +++ b/plugins/CmdLine/src/mimcmd_ipc.cpp @@ -20,14 +20,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-HANDLE hsmCmdLine = NULL;
-HANDLE hmClient = NULL;
-HANDLE heServerExec = NULL;
-HANDLE heServerDone = NULL;
-HANDLE heServerClose = NULL;
-HANDLE heServerBufferFull = NULL;
+HANDLE hsmCmdLine = nullptr;
+HANDLE hmClient = nullptr;
+HANDLE heServerExec = nullptr;
+HANDLE heServerDone = nullptr;
+HANDLE heServerClose = nullptr;
+HANDLE heServerBufferFull = nullptr;
-PSharedData sdCmdLine = NULL;
+PSharedData sdCmdLine = nullptr;
int InitClient()
@@ -60,26 +60,26 @@ int DestroyServer() int CreateSystemEvents()
{
- heServerExec = CreateEventA(NULL, FALSE, FALSE, EVENT_SERVER_EXEC);
- heServerDone = CreateEventA(NULL, FALSE, FALSE, EVENT_SERVER_DONE);
- heServerClose = CreateEventA(NULL, FALSE, FALSE, EVENT_SERVER_CLOSE);
- heServerBufferFull = CreateEventA(NULL, FALSE, FALSE, EVENT_SERVER_BUFFERFULL);
+ heServerExec = CreateEventA(nullptr, FALSE, FALSE, EVENT_SERVER_EXEC);
+ heServerDone = CreateEventA(nullptr, FALSE, FALSE, EVENT_SERVER_DONE);
+ heServerClose = CreateEventA(nullptr, FALSE, FALSE, EVENT_SERVER_CLOSE);
+ heServerBufferFull = CreateEventA(nullptr, FALSE, FALSE, EVENT_SERVER_BUFFERFULL);
- return (heServerExec == NULL) || (heServerDone == NULL) || (heServerClose == NULL) || (heServerBufferFull == NULL);
+ return (heServerExec == nullptr) || (heServerDone == nullptr) || (heServerClose == nullptr) || (heServerBufferFull == nullptr);
}
int CreateMutexes()
{
- hmClient = CreateMutexA(NULL, FALSE, MUTEX_CLIENT_NAME);
- return (hmClient == NULL);
+ hmClient = CreateMutexA(nullptr, FALSE, MUTEX_CLIENT_NAME);
+ return (hmClient == nullptr);
}
int CreateSharedMem()
{
- hsmCmdLine = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(TSharedData), SHAREDMEM_NAME);
+ hsmCmdLine = CreateFileMappingA(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, sizeof(TSharedData), SHAREDMEM_NAME);
sdCmdLine = (PSharedData) MapViewOfFile(hsmCmdLine, FILE_MAP_WRITE, 0, 0, sizeof(TSharedData));
- return (hsmCmdLine == NULL) || (sdCmdLine == NULL);
+ return (hsmCmdLine == nullptr) || (sdCmdLine == nullptr);
}
int DestroySystemEvents()
diff --git a/plugins/CmdLine/src/services.cpp b/plugins/CmdLine/src/services.cpp index ae146cd8ef..5faff619b9 100644 --- a/plugins/CmdLine/src/services.cpp +++ b/plugins/CmdLine/src/services.cpp @@ -72,11 +72,11 @@ int StartServer() {
if (sdCmdLine->instances == 0)
{
- HANDLE server = mir_forkthread(ServerWorkerThread, 0);
+ HANDLE server = mir_forkthread(ServerWorkerThread, nullptr);
if (server)
{
char path[MIMFOLDER_SIZE];
- GetModuleFileNameA(GetModuleHandle(NULL), path, sizeof(path));
+ GetModuleFileNameA(GetModuleHandle(nullptr), path, sizeof(path));
char *p = strrchr(path, '\\');
if (p) { *p = 0; }
strncpy_s(sdCmdLine->mimFolder, path, _TRUNCATE);
@@ -86,7 +86,7 @@ int StartServer() }
else PUShowMessageT(TranslateT("Could not create CommandLine listening server!"), SM_WARNING);
}
- else MessageBox(NULL, TranslateT("You can only run one instance of CmdLine plugin."), TranslateT("Error"), MB_ICONERROR | MB_OK);
+ else MessageBox(nullptr, TranslateT("You can only run one instance of CmdLine plugin."), TranslateT("Error"), MB_ICONERROR | MB_OK);
}
return failure;
diff --git a/plugins/CmdLine/src/utils.cpp b/plugins/CmdLine/src/utils.cpp index df4f62e31d..3e10c68950 100644 --- a/plugins/CmdLine/src/utils.cpp +++ b/plugins/CmdLine/src/utils.cpp @@ -32,7 +32,7 @@ int Info(char *title, char *format, ...) str[tBytes] = 0;
}
va_end(vararg);
- return MessageBoxA(0, str, title, MB_OK | MB_ICONINFORMATION);
+ return MessageBoxA(nullptr, str, title, MB_OK | MB_ICONINFORMATION);
}
int MyPUShowMessage(char *lpzText, BYTE kind)
@@ -41,14 +41,14 @@ int MyPUShowMessage(char *lpzText, BYTE kind) return PUShowMessage(lpzText, kind);
char *title = (kind == SM_NOTIFY) ? Translate("Notify") : Translate("Warning");
- return MessageBoxA(NULL, lpzText, title, MB_OK | (kind == SM_NOTIFY) ? MB_ICONINFORMATION : MB_ICONEXCLAMATION);
+ return MessageBoxA(nullptr, lpzText, title, MB_OK | (kind == SM_NOTIFY) ? MB_ICONINFORMATION : MB_ICONEXCLAMATION);
}
#define HEX_SIZE 8
char *BinToHex(int size, PBYTE data)
{
- char *szresult = NULL;
+ char *szresult = nullptr;
int maxSize = size * 2 + HEX_SIZE + 1;
szresult = (char *) new char[ maxSize ];
mir_snprintf(szresult, maxSize, "%0*X", HEX_SIZE, size);
@@ -153,14 +153,14 @@ int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, char* GetContactName(MCONTACT hContact, char *szProto)
{
ptrW name(Contact_GetInfo(CNF_DISPLAY, hContact, szProto));
- return (name == NULL) ? NULL : strdup(_T2A(name));
+ return (name == NULL) ? nullptr : strdup(_T2A(name));
}
#pragma warning (default: 4312)
#pragma warning (disable: 4312)
void GetContactProto(MCONTACT hContact, char *szProto, size_t size)
{
- GetStringFromDatabase(hContact, "Protocol", "p", NULL, szProto, size);
+ GetStringFromDatabase(hContact, "Protocol", "p", nullptr, szProto, size);
}
#pragma warning (default: 4312)
@@ -176,7 +176,7 @@ char* GetContactID(MCONTACT hContact) char* GetContactID(MCONTACT hContact, char *szProto)
{
ptrW name(Contact_GetInfo(CNF_UNIQUEID, hContact, szProto));
- return (name == NULL) ? NULL : strdup(_T2A(name));
+ return (name == NULL) ? nullptr : strdup(_T2A(name));
}
#pragma warning (default: 4312)
@@ -194,7 +194,7 @@ MCONTACT GetContactFromID(char *szID, char *szProto) wchar_t *tmp = pcli->pfnGetContactDisplayName(hContact, 0);
strncpy_s(dispName, _T2A(tmp), _TRUNCATE);
- if ((szHandle) && ((mir_strcmpi(szHandle, szID) == 0) || (mir_strcmpi(dispName, szID) == 0)) && ((szProto == NULL) || (_stricmp(szProto, cProtocol) == 0)))
+ if ((szHandle) && ((mir_strcmpi(szHandle, szID) == 0) || (mir_strcmpi(dispName, szID) == 0)) && ((szProto == nullptr) || (_stricmp(szProto, cProtocol) == 0)))
found = 1;
free(szHandle);
@@ -203,7 +203,7 @@ MCONTACT GetContactFromID(char *szID, char *szProto) return hContact;
}
- return NULL;
+ return 0;
}
#pragma warning (default: 4312)
@@ -211,7 +211,7 @@ MCONTACT GetContactFromID(char *szID, char *szProto) MCONTACT GetContactFromID(char *szID, wchar_t *szProto)
{
char protocol[1024];
- WideCharToMultiByte(CP_ACP, 0, szProto, -1, protocol, sizeof(protocol), NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, szProto, -1, protocol, sizeof(protocol), nullptr, nullptr);
return GetContactFromID(szID, protocol);
}
#pragma warning (default: 4312)
|