if (translated) *timeout = configured;\r
}\r
\r
-static inline void check_io(TCHAR *name, TCHAR *buffer, size_t bufsize, unsigned long control) {\r
+static inline void check_io(TCHAR *name, TCHAR *buffer, unsigned long len, unsigned long control) {\r
if (! SendMessage(GetDlgItem(tablist[NSSM_TAB_IO], control), WM_GETTEXTLENGTH, 0, 0)) return;\r
- if (GetDlgItemText(tablist[NSSM_TAB_IO], control, buffer, (int) bufsize)) return;\r
+ if (GetDlgItemText(tablist[NSSM_TAB_IO], control, buffer, (int) len)) return;\r
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_PATH_TOO_LONG, name);\r
- ZeroMemory(buffer, bufsize);\r
+ ZeroMemory(buffer, len * sizeof(TCHAR));\r
}\r
\r
/* Install the service. */\r
set_nssm_service_defaults(service);\r
\r
/* Get service name. */\r
- if (! GetDlgItemText(window, IDC_NAME, service->name, sizeof(service->name))) {\r
+ if (! GetDlgItemText(window, IDC_NAME, service->name, _countof(service->name))) {\r
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_SERVICE_NAME);\r
cleanup_nssm_service(service);\r
return 2;\r
}\r
\r
/* Get executable name */\r
- if (! GetDlgItemText(tablist[NSSM_TAB_APPLICATION], IDC_PATH, service->exe, sizeof(service->exe))) {\r
+ if (! GetDlgItemText(tablist[NSSM_TAB_APPLICATION], IDC_PATH, service->exe, _countof(service->exe))) {\r
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PATH);\r
return 3;\r
}\r
\r
/* Get startup directory. */\r
- if (! GetDlgItemText(tablist[NSSM_TAB_APPLICATION], IDC_DIR, service->dir, sizeof(service->dir))) {\r
+ if (! GetDlgItemText(tablist[NSSM_TAB_APPLICATION], IDC_DIR, service->dir, _countof(service->dir))) {\r
_sntprintf_s(service->dir, _countof(service->dir), _TRUNCATE, _T("%s"), service->exe);\r
strip_basename(service->dir);\r
}\r
\r
/* Get flags. */\r
if (SendMessage(GetDlgItem(tablist[NSSM_TAB_APPLICATION], IDC_FLAGS), WM_GETTEXTLENGTH, 0, 0)) {\r
- if (! GetDlgItemText(tablist[NSSM_TAB_APPLICATION], IDC_FLAGS, service->flags, sizeof(service->flags))) {\r
+ if (! GetDlgItemText(tablist[NSSM_TAB_APPLICATION], IDC_FLAGS, service->flags, _countof(service->flags))) {\r
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_OPTIONS);\r
return 4;\r
}\r
if (service->default_exit_action == CB_ERR) service->default_exit_action = 0;\r
\r
/* Get I/O stuff. */\r
- check_io(_T("stdin"), service->stdin_path, sizeof(service->stdin_path), IDC_STDIN);\r
- check_io(_T("stdout"), service->stdout_path, sizeof(service->stdout_path), IDC_STDOUT);\r
- check_io(_T("stderr"), service->stderr_path, sizeof(service->stderr_path), IDC_STDERR);\r
+ check_io(_T("stdin"), service->stdin_path, _countof(service->stdin_path), IDC_STDIN);\r
+ check_io(_T("stdout"), service->stdout_path, _countof(service->stdout_path), IDC_STDOUT);\r
+ check_io(_T("stderr"), service->stderr_path, _countof(service->stderr_path), IDC_STDERR);\r
\r
/* Override stdout and/or stderr. */\r
if (SendDlgItemMessage(tablist[NSSM_TAB_ROTATION], IDC_TRUNCATE, BM_GETCHECK, 0, 0) & BST_CHECKED) {\r
nssm_service_t *service = alloc_nssm_service();\r
if (service) {\r
/* Get service name */\r
- if (! GetDlgItemText(window, IDC_NAME, service->name, sizeof(service->name))) {\r
+ if (! GetDlgItemText(window, IDC_NAME, service->name, _countof(service->name))) {\r
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_SERVICE_NAME);\r
cleanup_nssm_service(service);\r
return 2;\r
/* Browse for application. */\r
case IDC_BROWSE:\r
dlg = GetDlgItem(tab, IDC_PATH);\r
- GetDlgItemText(tab, IDC_PATH, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_PATH, buffer, _countof(buffer));\r
browse(dlg, buffer, OFN_FILEMUSTEXIST, NSSM_GUI_BROWSE_FILTER_APPLICATIONS, NSSM_GUI_BROWSE_FILTER_ALL_FILES, 0);\r
/* Fill in startup directory if it wasn't already specified. */\r
- GetDlgItemText(tab, IDC_DIR, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_DIR, buffer, _countof(buffer));\r
if (! buffer[0]) {\r
- GetDlgItemText(tab, IDC_PATH, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_PATH, buffer, _countof(buffer));\r
strip_basename(buffer);\r
SetDlgItemText(tab, IDC_DIR, buffer);\r
}\r
/* Browse for startup directory. */\r
case IDC_BROWSE_DIR:\r
dlg = GetDlgItem(tab, IDC_DIR);\r
- GetDlgItemText(tab, IDC_DIR, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_DIR, buffer, _countof(buffer));\r
browse(dlg, buffer, OFN_NOVALIDATE, NSSM_GUI_BROWSE_FILTER_DIRECTORIES, 0);\r
break;\r
\r
/* Browse for stdin. */\r
case IDC_BROWSE_STDIN:\r
dlg = GetDlgItem(tab, IDC_STDIN);\r
- GetDlgItemText(tab, IDC_STDIN, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_STDIN, buffer, _countof(buffer));\r
browse(dlg, buffer, 0, NSSM_GUI_BROWSE_FILTER_ALL_FILES, 0);\r
break;\r
\r
/* Browse for stdout. */\r
case IDC_BROWSE_STDOUT:\r
dlg = GetDlgItem(tab, IDC_STDOUT);\r
- GetDlgItemText(tab, IDC_STDOUT, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_STDOUT, buffer, _countof(buffer));\r
browse(dlg, buffer, 0, NSSM_GUI_BROWSE_FILTER_ALL_FILES, 0);\r
/* Fill in stderr if it wasn't already specified. */\r
- GetDlgItemText(tab, IDC_STDERR, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_STDERR, buffer, _countof(buffer));\r
if (! buffer[0]) {\r
- GetDlgItemText(tab, IDC_STDOUT, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_STDOUT, buffer, _countof(buffer));\r
SetDlgItemText(tab, IDC_STDERR, buffer);\r
}\r
break;\r
/* Browse for stderr. */\r
case IDC_BROWSE_STDERR:\r
dlg = GetDlgItem(tab, IDC_STDERR);\r
- GetDlgItemText(tab, IDC_STDERR, buffer, sizeof(buffer));\r
+ GetDlgItemText(tab, IDC_STDERR, buffer, _countof(buffer));\r
browse(dlg, buffer, 0, NSSM_GUI_BROWSE_FILTER_ALL_FILES, 0);\r
break;\r
\r