summaryrefslogtreecommitdiffstats
path: root/src/unix/core.c
diff options
context:
space:
mode:
authorlibuv upstream <libuv@googlegroups.com>2017-05-09 19:51:26 (GMT)
committerBrad King <brad.king@kitware.com>2017-05-15 14:43:03 (GMT)
commit12a78bc824655524d817508d6107ef4dcf8e3626 (patch)
tree39bcf5989f7696efbb2cb777b1ce5b0062df7939 /src/unix/core.c
parent1f661e87a6a8304edb77bd30b546e5d113477c59 (diff)
downloadCMake-12a78bc824655524d817508d6107ef4dcf8e3626.zip
CMake-12a78bc824655524d817508d6107ef4dcf8e3626.tar.gz
CMake-12a78bc824655524d817508d6107ef4dcf8e3626.tar.bz2
libuv 2017-05-09 (e11dcd43)
Code extracted from: https://github.com/libuv/libuv.git at commit e11dcd4377185359874e67f4962995fdb7e83d19 (v1.x).
Diffstat (limited to 'src/unix/core.c')
-rw-r--r--src/unix/core.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/unix/core.c b/src/unix/core.c
index 9ef7134..96495b8 100644
--- a/src/unix/core.c
+++ b/src/unix/core.c
@@ -1240,3 +1240,48 @@ int uv_translate_sys_error(int sys_errno) {
/* If < 0 then it's already a libuv error. */
return sys_errno <= 0 ? sys_errno : -sys_errno;
}
+
+
+int uv_os_getenv(const char* name, char* buffer, size_t* size) {
+ char* var;
+ size_t len;
+
+ if (name == NULL || buffer == NULL || size == NULL || *size == 0)
+ return -EINVAL;
+
+ var = getenv(name);
+
+ if (var == NULL)
+ return -ENOENT;
+
+ len = strlen(var);
+
+ if (len >= *size) {
+ *size = len + 1;
+ return -ENOBUFS;
+ }
+
+ memcpy(buffer, var, len + 1);
+ *size = len;
+
+ return 0;
+}
+
+
+int uv_os_setenv(const char* name, const char* value) {
+ if (name == NULL || value == NULL)
+ return -EINVAL;
+
+ if (setenv(name, value, 1) != 0)
+ return -errno;
+
+ return 0;
+}
+
+
+int uv_os_unsetenv(const char* name) {
+ if (unsetenv(name) != 0)
+ return -errno;
+
+ return 0;
+}