From: Iain Patterson Date: Mon, 13 Jan 2014 09:33:30 +0000 (+0000) Subject: Added fake NSSM_SERVICE_CONTROL_START constant. X-Git-Tag: v2.22~62 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=f1d6394333ce0f90c423d74a9860620942f2bb6f;p=nssm.git Added fake NSSM_SERVICE_CONTROL_START constant. There's no SERVICE_CONTROL_START constant so we were explicitly checking for a fake control code of 0 when handling service start. Now that we have defined a custom control code (NSSM_SERVICE_CONTROL_ROTATE) we can add NSSM_SERVICE_CONTROL_START for readability and consistency. --- diff --git a/nssm.cpp b/nssm.cpp index 498a213..37f3aea 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -103,7 +103,7 @@ int _tmain(int argc, TCHAR **argv) { Valid commands are: start, stop, pause, continue, install, edit, get, set, reset, unset, remove */ - if (str_equiv(argv[1], _T("start"))) exit(control_service(0, argc - 2, argv + 2)); + if (str_equiv(argv[1], _T("start"))) exit(control_service(NSSM_SERVICE_CONTROL_START, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("stop"))) exit(control_service(SERVICE_CONTROL_STOP, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("pause"))) exit(control_service(SERVICE_CONTROL_PAUSE, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("continue"))) exit(control_service(SERVICE_CONTROL_CONTINUE, argc - 2, argv + 2)); diff --git a/nssm.h b/nssm.h index 79c2065..8e82d59 100644 --- a/nssm.h +++ b/nssm.h @@ -96,6 +96,7 @@ int usage(int); #define NSSM_SERVICE_STATUS_DEADLINE 20000 /* User-defined service controls can be in the range 128-255. */ +#define NSSM_SERVICE_CONTROL_START 0 #define NSSM_SERVICE_CONTROL_ROTATE 128 #endif diff --git a/service.cpp b/service.cpp index 8074227..51c3937 100644 --- a/service.cpp +++ b/service.cpp @@ -1059,7 +1059,7 @@ int control_service(unsigned long control, int argc, TCHAR **argv) { int ret; unsigned long error; SERVICE_STATUS service_status; - if (control == 0) { + if (control == NSSM_SERVICE_CONTROL_START) { ret = StartService(service_handle, (unsigned long) argc, (const TCHAR **) argv); error = GetLastError(); CloseHandle(service_handle); @@ -1281,7 +1281,7 @@ int monitor_service(nssm_service_t *service) { TCHAR *service_control_text(unsigned long control) { switch (control) { /* HACK: there is no SERVICE_CONTROL_START constant */ - case 0: return _T("START"); + case NSSM_SERVICE_CONTROL_START: return _T("START"); case SERVICE_CONTROL_STOP: return _T("STOP"); case SERVICE_CONTROL_SHUTDOWN: return _T("SHUTDOWN"); case SERVICE_CONTROL_PAUSE: return _T("PAUSE");