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.
master
Iain Patterson 11 years ago
parent e78394a548
commit f1d6394333

@ -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));

@ -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

@ -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");

Loading…
Cancel
Save