From: Iain Patterson Date: Thu, 23 Jan 2014 20:06:54 +0000 (+0000) Subject: Renamed set_environment(). X-Git-Tag: v2.22~41 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=77855b77fa52ac6e844377a191c2ae836a32b5bd;p=nssm.git Renamed set_environment(). The set_environment() function was poorly named. It gets the environment settings from the registry but doesn't actually set any variables. It is more appropriately named get_environment(). --- diff --git a/registry.cpp b/registry.cpp index c794ed1..50f6dc3 100644 --- a/registry.cpp +++ b/registry.cpp @@ -175,7 +175,7 @@ int create_exit_action(TCHAR *service_name, const TCHAR *action_string, bool edi return 0; } -int set_environment(TCHAR *service_name, HKEY key, TCHAR *value, TCHAR **env, unsigned long *envlen) { +int get_environment(TCHAR *service_name, HKEY key, TCHAR *value, TCHAR **env, unsigned long *envlen) { unsigned long type = REG_MULTI_SZ; /* Dummy test to find buffer size */ @@ -205,7 +205,7 @@ int set_environment(TCHAR *service_name, HKEY key, TCHAR *value, TCHAR **env, un *env = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, *envlen); if (! *env) { *envlen = 0; - log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, value, _T("set_environment()"), 0); + log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, value, _T("get_environment()"), 0); return 3; } @@ -462,9 +462,9 @@ int get_parameters(nssm_service_t *service, STARTUPINFO *si) { } /* Try to get environment variables - may fail */ - set_environment(service->name, key, NSSM_REG_ENV, &service->env, &service->envlen); + get_environment(service->name, key, NSSM_REG_ENV, &service->env, &service->envlen); /* Environment variables to add to existing rather than replace - may fail. */ - set_environment(service->name, key, NSSM_REG_ENV_EXTRA, &service->env_extra, &service->env_extralen); + get_environment(service->name, key, NSSM_REG_ENV_EXTRA, &service->env_extra, &service->env_extralen); if (si) { if (service->env_extra) { diff --git a/registry.h b/registry.h index 390e032..aa14e00 100644 --- a/registry.h +++ b/registry.h @@ -34,7 +34,7 @@ HKEY open_registry(const TCHAR *, REGSAM sam); int create_messages(); int create_parameters(nssm_service_t *, bool); int create_exit_action(TCHAR *, const TCHAR *, bool); -int set_environment(TCHAR *, HKEY, TCHAR *, TCHAR **, unsigned long *); +int get_environment(TCHAR *, HKEY, TCHAR *, TCHAR **, unsigned long *); int get_string(HKEY, TCHAR *, TCHAR *, unsigned long, bool, bool, bool); int get_string(HKEY, TCHAR *, TCHAR *, unsigned long, bool); int expand_parameter(HKEY, TCHAR *, TCHAR *, unsigned long, bool, bool); diff --git a/settings.cpp b/settings.cpp index c9bb32d..a3d301b 100644 --- a/settings.cpp +++ b/settings.cpp @@ -329,7 +329,7 @@ static int setting_get_environment(const TCHAR *service_name, void *param, const TCHAR *env = 0; unsigned long envlen; - if (set_environment((TCHAR *) service_name, key, (TCHAR *) name, &env, &envlen)) return -1; + if (get_environment((TCHAR *) service_name, key, (TCHAR *) name, &env, &envlen)) return -1; if (! envlen) return 0; TCHAR *formatted;