Jelajahi Sumber

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().
Iain Patterson 10 tahun lalu
induk
melakukan
77855b77fa
3 mengubah file dengan 6 tambahan dan 6 penghapusan
  1. 4 4
      registry.cpp
  2. 1 1
      registry.h
  3. 1 1
      settings.cpp

+ 4 - 4
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) {

+ 1 - 1
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);

+ 1 - 1
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;