X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=registry.cpp;h=c63821dc7a3dd60a7dfbd010d8bb84ba6666e2ae;hb=refs%2Ftags%2Fv2.19;hp=382cb0f46076c897c35dacd1ea0639d7ab000ebb;hpb=728c4f6eb96313e764600810aa754663a5091f38;p=nssm.git diff --git a/registry.cpp b/registry.cpp index 382cb0f..c63821d 100644 --- a/registry.cpp +++ b/registry.cpp @@ -68,9 +68,36 @@ int create_parameters(nssm_service_t *service) { if (service->kill_console_delay != NSSM_KILL_CONSOLE_GRACE_PERIOD) set_number(key, NSSM_REG_KILL_CONSOLE_GRACE_PERIOD, service->kill_console_delay); if (service->kill_window_delay != NSSM_KILL_WINDOW_GRACE_PERIOD) set_number(key, NSSM_REG_KILL_WINDOW_GRACE_PERIOD, service->kill_window_delay); if (service->kill_threads_delay != NSSM_KILL_THREADS_GRACE_PERIOD) set_number(key, NSSM_REG_KILL_THREADS_GRACE_PERIOD, service->kill_threads_delay); - if (service->stdin_path[0]) set_expand_string(key, NSSM_REG_STDIN, service->stdin_path); - if (service->stdout_path[0]) set_expand_string(key, NSSM_REG_STDOUT, service->stdout_path); - if (service->stderr_path[0]) set_expand_string(key, NSSM_REG_STDERR, service->stderr_path); + if (service->stdin_path[0]) { + set_expand_string(key, NSSM_REG_STDIN, service->stdin_path); + if (service->stdin_sharing != NSSM_STDIN_SHARING) set_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_SHARING, service->stdin_sharing); + if (service->stdin_disposition != NSSM_STDIN_DISPOSITION) set_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_DISPOSITION, service->stdin_disposition); + if (service->stdin_flags != NSSM_STDIN_FLAGS) set_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_FLAGS, service->stdin_flags); + } + if (service->stdout_path[0]) { + set_expand_string(key, NSSM_REG_STDOUT, service->stdout_path); + if (service->stdout_sharing != NSSM_STDOUT_SHARING) set_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_SHARING, service->stdout_sharing); + if (service->stdout_disposition != NSSM_STDOUT_DISPOSITION) set_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_DISPOSITION, service->stdout_disposition); + if (service->stdout_flags != NSSM_STDOUT_FLAGS) set_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_FLAGS, service->stdout_flags); + } + if (service->stderr_path[0]) { + set_expand_string(key, NSSM_REG_STDERR, service->stderr_path); + if (service->stderr_sharing != NSSM_STDERR_SHARING) set_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_SHARING, service->stderr_sharing); + if (service->stderr_disposition != NSSM_STDERR_DISPOSITION) set_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_DISPOSITION, service->stderr_disposition); + if (service->stderr_flags != NSSM_STDERR_FLAGS) set_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_FLAGS, service->stderr_flags); + } + + /* Environment */ + if (service->env) { + if (RegSetValueEx(key, NSSM_REG_ENV, 0, REG_MULTI_SZ, (const unsigned char *) service->env, (unsigned long) service->envlen) != ERROR_SUCCESS) { + log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_SETVALUE_FAILED, NSSM_REG_ENV, error_string(GetLastError()), 0); + } + } + if (service->env_extra) { + if (RegSetValueEx(key, NSSM_REG_ENV_EXTRA, 0, REG_MULTI_SZ, (const unsigned char *) service->env_extra, (unsigned long) service->env_extralen) != ERROR_SUCCESS) { + log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_SETVALUE_FAILED, NSSM_REG_ENV_EXTRA, error_string(GetLastError()), 0); + } + } /* Close registry. */ RegCloseKey(key);