summaryrefslogtreecommitdiff
path: root/plugins/WhoUsesMyFiles
diff options
context:
space:
mode:
authorGoraf <22941576+Goraf@users.noreply.github.com>2017-11-13 15:03:31 +0100
committerGoraf <22941576+Goraf@users.noreply.github.com>2017-11-13 15:07:33 +0100
commita7c24ca48995cf2bf436156302f96b91bf135409 (patch)
tree953835509ff1b778833e78fd7b74b05e05e77c84 /plugins/WhoUsesMyFiles
parent591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff)
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/WhoUsesMyFiles')
-rw-r--r--plugins/WhoUsesMyFiles/src/list.cpp16
-rw-r--r--plugins/WhoUsesMyFiles/src/wumf.cpp36
-rw-r--r--plugins/WhoUsesMyFiles/src/wumfplug.cpp50
3 files changed, 51 insertions, 51 deletions
diff --git a/plugins/WhoUsesMyFiles/src/list.cpp b/plugins/WhoUsesMyFiles/src/list.cpp
index 028d17f035..a597d99235 100644
--- a/plugins/WhoUsesMyFiles/src/list.cpp
+++ b/plugins/WhoUsesMyFiles/src/list.cpp
@@ -11,7 +11,7 @@ PWumf new_wumf( DWORD dwID,
{
PWumf w = (PWumf)mir_calloc(sizeof(Wumf));
if (!w)
- return NULL;
+ return nullptr;
w->szUser = mir_wstrdup(szUser);
w->szPath = mir_wstrdup(szPath);
@@ -31,7 +31,7 @@ PWumf new_wumf( DWORD dwID,
w->dwAttr = dwAttr;
w->dwPerm = dwPerm;
w->mark = FALSE;
- w->next = NULL;
+ w->next = nullptr;
return w;
}
@@ -56,7 +56,7 @@ BOOL add_cell(PWumf* l, PWumf w)
while(p->next) p = p->next;
p->next = w;
}
- w->next = NULL;
+ w->next = nullptr;
return TRUE;
}
@@ -85,12 +85,12 @@ BOOL cpy_cell(PWumf *l, PWumf w)
PWumf cpy_list(PWumf *l)
{
- PWumf w, p = NULL;
+ PWumf w, p = nullptr;
- if (!l || !*l) return NULL;
+ if (!l || !*l) return nullptr;
w = *l;
while(w) {
- if (!cpy_cell(&p, w))return NULL;
+ if (!cpy_cell(&p, w))return nullptr;
w = w->next;
}
return p;
@@ -98,7 +98,7 @@ PWumf cpy_list(PWumf *l)
PWumf fnd_cell(PWumf *l, DWORD dwID)
{
- if (!l || !*l)return NULL;
+ if (!l || !*l)return nullptr;
PWumf w = *l;
while(w && w->dwID != dwID) w = w->next;
return w;
@@ -115,7 +115,7 @@ BOOL del_all(PWumf *l)
w = p;
}
- *l = NULL;
+ *l = nullptr;
return TRUE;
}
diff --git a/plugins/WhoUsesMyFiles/src/wumf.cpp b/plugins/WhoUsesMyFiles/src/wumf.cpp
index 99e2102d04..c4c3969081 100644
--- a/plugins/WhoUsesMyFiles/src/wumf.cpp
+++ b/plugins/WhoUsesMyFiles/src/wumf.cpp
@@ -5,10 +5,10 @@
#define NAME "WUMF"
#define WM_MYCMD 0x0401
-PWumf list = NULL;
-PWumf lst = NULL;
+PWumf list = nullptr;
+PWumf lst = nullptr;
-HANDLE hLogger = NULL;
+HANDLE hLogger = nullptr;
BOOL wumf();
static int DlgResizer(HWND, LPARAM, UTILRESIZECONTROL *urc)
@@ -83,12 +83,12 @@ INT_PTR CALLBACK ConnDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
lvc.cx = 50;
lvc.pszText = TranslateT("Access");
ListView_InsertColumn(hList, 3, &lvc);
- KillTimer(NULL, 777);
+ KillTimer(nullptr, 777);
lst = cpy_list(&list);
if (IsUserAnAdmin())
- SetTimer(NULL, 777, TIME, TimerProc);
+ SetTimer(nullptr, 777, TIME, TimerProc);
else
- MessageBox(NULL, TranslateT("Plugin WhoUsesMyFiles requires admin privileges in order to work."), L"Miranda NG", MB_OK);
+ MessageBox(nullptr, TranslateT("Plugin WhoUsesMyFiles requires admin privileges in order to work."), L"Miranda NG", MB_OK);
ShowList(lst, hList);
}
Utils_RestoreWindowPosition(hWnd, NULL, MODULENAME,"conn");
@@ -136,12 +136,12 @@ void LogWumf(PWumf w)
{
if (!WumfOptions.LogFolders && (w->dwAttr & FILE_ATTRIBUTE_DIRECTORY)) return;
- if (hLogger == NULL) {
+ if (hLogger == nullptr) {
hLogger = mir_createLog("wumf", L"WhoIsUsingMyFiles log file", WumfOptions.LogFile, 0);
- if (hLogger == NULL) {
+ if (hLogger == nullptr) {
wchar_t str[256];
mir_snwprintf(str, L"Can't open log file %s", WumfOptions.LogFile);
- MessageBox(NULL, str, TranslateT("Error opening file"), MB_OK | MB_ICONSTOP);
+ MessageBox(nullptr, str, TranslateT("Error opening file"), MB_OK | MB_ICONSTOP);
WumfOptions.LogToFile = FALSE;
return;
}
@@ -151,17 +151,17 @@ void LogWumf(PWumf w)
GetLocalTime(&time);
wchar_t lpDateStr[20], lpTimeStr[20];
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &time, NULL, lpDateStr, 20);
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &time, NULL, lpTimeStr, 20);
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &time, nullptr, lpDateStr, 20);
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &time, nullptr, lpTimeStr, 20);
mir_writeLogW(hLogger, L"%s %s %20s\t%s\r\n", lpDateStr, lpTimeStr, w->szUser, w->szPath);
}
BOOL wumf()
{
- LPSESSION_INFO_1 s_info = NULL;
+ LPSESSION_INFO_1 s_info = nullptr;
DWORD ent_read = 0, ent_total = 0, res_handle = 0;
NET_API_STATUS res = NERR_Success;
- if ((res = NetSessionEnum(NULL, NULL, NULL, 1, (LPBYTE *)&s_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, &res_handle)) == NERR_Success ||
+ if ((res = NetSessionEnum(nullptr, nullptr, nullptr, 1, (LPBYTE *)&s_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, &res_handle)) == NERR_Success ||
res == ERROR_MORE_DATA)
{
mark_all(&list, TRUE);
@@ -177,10 +177,10 @@ BOOL wumf()
void process_session(SESSION_INFO_1 s_info)
{
- LPFILE_INFO_3 f_info = NULL;
+ LPFILE_INFO_3 f_info = nullptr;
DWORD ent_read = 0, ent_total = 0, res_handle = 0;
NET_API_STATUS res = NERR_Success;
- if ((res = NetFileEnum(NULL, NULL, s_info.sesi1_username, 3, (LPBYTE *)&f_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, (PDWORD_PTR)&res_handle)) == NERR_Success ||
+ if ((res = NetFileEnum(nullptr, nullptr, s_info.sesi1_username, 3, (LPBYTE *)&f_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, (PDWORD_PTR)&res_handle)) == NERR_Success ||
res == ERROR_MORE_DATA)
{
for(unsigned i=0; i < ent_read; i++)
@@ -195,7 +195,7 @@ void process_file(SESSION_INFO_1 s_info, FILE_INFO_3 f_info)
{
PWumf w = fnd_cell(&list, f_info.fi3_id);
if (!w) {
- w = new_wumf(f_info.fi3_id, f_info.fi3_username, f_info.fi3_pathname, s_info.sesi1_cname, NULL, 0, f_info.fi3_permissions, GetFileAttributes(f_info.fi3_pathname));
+ w = new_wumf(f_info.fi3_id, f_info.fi3_username, f_info.fi3_pathname, s_info.sesi1_cname, nullptr, 0, f_info.fi3_permissions, GetFileAttributes(f_info.fi3_pathname));
w->mark = FALSE;
if (!add_cell(&list, w))
msg(TranslateT("Error memory allocation"));
@@ -209,7 +209,7 @@ void process_file(SESSION_INFO_1 s_info, FILE_INFO_3 f_info)
void printError(DWORD res)
{
LPVOID lpMsgBuf;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, res, 0, (LPTSTR) &lpMsgBuf, 0, NULL );
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, res, 0, (LPTSTR) &lpMsgBuf, 0, nullptr );
OutputDebugString((LPCTSTR)lpMsgBuf);
msg((LPCTSTR)lpMsgBuf);
LocalFree( lpMsgBuf );
@@ -218,7 +218,7 @@ void printError(DWORD res)
VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
if (!wumf())
- KillTimer(NULL, 777);
+ KillTimer(nullptr, 777);
};
void FreeAll()
diff --git a/plugins/WhoUsesMyFiles/src/wumfplug.cpp b/plugins/WhoUsesMyFiles/src/wumfplug.cpp
index 54643218f3..1a6ae70dad 100644
--- a/plugins/WhoUsesMyFiles/src/wumfplug.cpp
+++ b/plugins/WhoUsesMyFiles/src/wumfplug.cpp
@@ -2,7 +2,7 @@
HINSTANCE hInst;
WUMF_OPTIONS WumfOptions = { 0 };
-HGENMENU hMenuItem = 0;
+HGENMENU hMenuItem = nullptr;
int hLangpack;
HWND hDlg;
@@ -69,15 +69,15 @@ void ExecuteMenu(HWND hWnd)
return;
}
AppendMenu(hMenu, MF_STRING, IDM_ABOUT, L"About\0");
- AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);//------------------
+ AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);//------------------
AppendMenu(hMenu, MF_STRING, IDM_SHOW, L"Show connections\0");
- AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);//------------------
+ AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);//------------------
AppendMenu(hMenu, MF_STRING, IDM_EXIT, L"Dismiss popup\0");
POINT point;
GetCursorPos(&point);
SetForegroundWindow(hWnd);
- TrackPopupMenu(hMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RIGHTALIGN | TPM_TOPALIGN, point.x, point.y, 0, hWnd, NULL);
+ TrackPopupMenu(hMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RIGHTALIGN | TPM_TOPALIGN, point.x, point.y, 0, hWnd, nullptr);
PostMessage(hWnd, WM_USER, 0, 0);
DestroyMenu(hMenu);
}
@@ -156,33 +156,33 @@ void ShowThePopup(PWumf w, LPTSTR title, LPTSTR text)
void ShowThePreview()
{
if ( !ServiceExists(MS_POPUP_ADDPOPUPT)) {
- MessageBox(NULL, TranslateT("Popup plugin not found!"), TranslateT("Error"), MB_OK|MB_ICONSTOP);
+ MessageBox(nullptr, TranslateT("Popup plugin not found!"), TranslateT("Error"), MB_OK|MB_ICONSTOP);
return;
}
if (WumfOptions.AlertFolders) {
- ShowThePopup(NULL, L"Guest", L"C:\\My Share");
+ ShowThePopup(nullptr, L"Guest", L"C:\\My Share");
Sleep(300);
- ShowThePopup(NULL, L"Guest", L"C:\\My Share\\Photos");
+ ShowThePopup(nullptr, L"Guest", L"C:\\My Share\\Photos");
Sleep(300);
}
- ShowThePopup(NULL, L"Guest", L"C:\\Share\\My Photos\\photo.jpg");
+ ShowThePopup(nullptr, L"Guest", L"C:\\Share\\My Photos\\photo.jpg");
Sleep(300);
if (WumfOptions.AlertFolders) {
- ShowThePopup(NULL, L"User", L"C:\\My Share");
+ ShowThePopup(nullptr, L"User", L"C:\\My Share");
Sleep(300);
- ShowThePopup(NULL, L"User", L"C:\\My Share\\Movies");
+ ShowThePopup(nullptr, L"User", L"C:\\My Share\\Movies");
Sleep(300);
}
- ShowThePopup(NULL, L"User", L"C:\\My Share\\Movies\\The Two Towers.avi");
+ ShowThePopup(nullptr, L"User", L"C:\\My Share\\Movies\\The Two Towers.avi");
Sleep(300);
if (WumfOptions.AlertFolders) {
- ShowThePopup(NULL, L"Administrator", L"C:\\Distributives");
+ ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives");
Sleep(300);
- ShowThePopup(NULL, L"Administrator", L"C:\\Distributives\\Win2k");
+ ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives\\Win2k");
Sleep(300);
}
- ShowThePopup(NULL, L"Administrator", L"C:\\Distributives\\Win2k\\setup.exe");
+ ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives\\Win2k\\setup.exe");
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
@@ -199,21 +199,21 @@ void ThreadProc(LPVOID)
return;
}
- hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CONNLIST), NULL, ConnDlgProc);
+ hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CONNLIST), nullptr, ConnDlgProc);
SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE)));
ShowWindow(hDlg, SW_SHOW);
MSG msg;
- while(GetMessage(&msg, NULL, 0, 0) == TRUE) {
+ while(GetMessage(&msg, nullptr, 0, 0) == TRUE) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
- hDlg = NULL;
+ hDlg = nullptr;
}
static INT_PTR WumfShowConnections(WPARAM,LPARAM)
{
- mir_forkthread(ThreadProc, NULL);
+ mir_forkthread(ThreadProc, nullptr);
CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hWumfBut, 0);
return 0;
}
@@ -265,7 +265,7 @@ void ChooseFile(HWND hwndDlg)
ofn.Flags = OFN_CREATEPROMPT;
// Display the Open dialog box.
if (GetSaveFileName(&ofn)) {
- HANDLE hf = CreateFile(szFile,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hf = CreateFile(szFile,GENERIC_WRITE,0,nullptr,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, nullptr);
if (hf != INVALID_HANDLE_VALUE) {
SetDlgItemText(hwndDlg,IDC_FILE,szFile);
mir_wstrncpy(WumfOptions.LogFile, szFile, MAX_PATH);
@@ -358,7 +358,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wparam,LPARAM lpara
case IDC_ALERT_COMP:
case IDC_LOG_UNC:
case IDC_ALERT_UNC:
- MessageBox(NULL, TranslateT("Not implemented yet..."), L"WUMF", MB_OK | MB_ICONINFORMATION);
+ MessageBox(nullptr, TranslateT("Not implemented yet..."), L"WUMF", MB_OK | MB_ICONINFORMATION);
break;
/* end */
case IDC_LOG_INTO_FILE:
@@ -396,7 +396,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wparam,LPARAM lpara
case EN_CHANGE:
switch(wControlId) {
case IDC_DELAY_SEC:
- seconds = GetDlgItemInt(hwndDlg, IDC_DELAY_SEC, NULL, FALSE);
+ seconds = GetDlgItemInt(hwndDlg, IDC_DELAY_SEC, nullptr, FALSE);
if (seconds > LIFETIME_MAX)
WumfOptions.DelaySec = LIFETIME_MAX;
else if (seconds < LIFETIME_MIN)
@@ -457,7 +457,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wparam,LPARAM lpara
int InitTopToolbar(WPARAM,LPARAM)
{
- TTBButton ttb = { 0 };
+ TTBButton ttb = {};
ttb.hIconUp = LoadIcon(hInst, MAKEINTRESOURCE(IDI_DRIVE));
ttb.pszService = MS_WUMF_CONNECTIONSSHOW;
ttb.dwFlags = TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
@@ -514,15 +514,15 @@ extern "C" __declspec(dllexport) int Load(void)
HookEvent(ME_TTB_MODULELOADED, InitTopToolbar);
if (IsUserAnAdmin())
- SetTimer(NULL, 777, TIME, TimerProc);
+ SetTimer(nullptr, 777, TIME, TimerProc);
else
- MessageBox(NULL, TranslateT("Plugin WhoUsesMyFiles requires admin privileges in order to work."), L"Miranda NG", MB_OK);
+ MessageBox(nullptr, TranslateT("Plugin WhoUsesMyFiles requires admin privileges in order to work."), L"Miranda NG", MB_OK);
return 0;
}
extern "C" __declspec(dllexport) int Unload(void)
{
- KillTimer(NULL, 777);
+ KillTimer(nullptr, 777);
if (hLogger)
mir_closeLog(hLogger);
FreeAll();