diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-09 08:36:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-25 11:21:20 +0000 |
commit | eae52fdaa9298e00f14b0b6256400d200db9c373 (patch) | |
tree | a3040a19bd024295ded05370853647bab9d7c225 /src/libnetdata/os/setenv.c | |
parent | Adding upstream version 1.47.5. (diff) | |
download | netdata-upstream/2.0.3.tar.xz netdata-upstream/2.0.3.zip |
Adding upstream version 2.0.3.upstream/2.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libnetdata/os/setenv.c')
-rw-r--r-- | src/libnetdata/os/setenv.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/libnetdata/os/setenv.c b/src/libnetdata/os/setenv.c index 5aa4302b8..c0de1b4b6 100644 --- a/src/libnetdata/os/setenv.c +++ b/src/libnetdata/os/setenv.c @@ -1,13 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later
-#include "config.h"
+#include "libnetdata/libnetdata.h"
#ifndef HAVE_SETENV
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
int os_setenv(const char *name, const char *value, int overwrite) {
char *env_var;
int result;
@@ -28,3 +23,21 @@ int os_setenv(const char *name, const char *value, int overwrite) { }
#endif
+
+void nd_setenv(const char *name, const char *value, int overwrite) {
+#if defined(OS_WINDOWS)
+ if(overwrite)
+ SetEnvironmentVariable(name, value);
+ else {
+ char buf[1024];
+ if(GetEnvironmentVariable(name, buf, sizeof(buf)) == 0)
+ SetEnvironmentVariable(name, value);
+ }
+#endif
+
+#ifdef HAVE_SETENV
+ setenv(name, value, overwrite);
+#else
+ os_setenv(name, value, overwite);
+#endif
+}
|