aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-12-10 21:23:42 +0100
committerMattias Andrée <maandree@kth.se>2021-12-10 21:24:00 +0100
commit070e1be74da744cc58b5d01eba5ff21e035bca0b (patch)
tree609e3b8ee33041823ee074d900036ff8743d78b0
parentm (diff)
downloadliberror-libc-070e1be74da744cc58b5d01eba5ff21e035bca0b.tar.gz
liberror-libc-070e1be74da744cc58b5d01eba5ff21e035bca0b.tar.bz2
liberror-libc-070e1be74da744cc58b5d01eba5ff21e035bca0b.tar.xz
Add liberror_setenv_failed
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--liberror-libc.h1
-rw-r--r--setenv.c21
2 files changed, 22 insertions, 0 deletions
diff --git a/liberror-libc.h b/liberror-libc.h
index fad436b..14ca4a0 100644
--- a/liberror-libc.h
+++ b/liberror-libc.h
@@ -65,6 +65,7 @@ _LIBERROR_WUR ssize_t liberror_send_require(int, const void *, size_t, int, size
void liberror_send_failed(int, const void *, size_t, int, const char *);
void liberror_send_short(int, const void *, size_t, int, size_t min, size_t max, ssize_t returned, const char *);
_LIBERROR_WUR int liberror_setenv(const char *, const char *, int);
+void liberror_setenv_failed(const char *, const char *, int);
_LIBERROR_WUR int liberror_shutdown(int, int, const char *);
void liberror_shutdown_failed(int, int, const char *);
_LIBERROR_WUR int liberror_sockatmark(int, const char *);
diff --git a/setenv.c b/setenv.c
index 0bb7831..4066489 100644
--- a/setenv.c
+++ b/setenv.c
@@ -2,6 +2,27 @@
#include "internal.h"
+void
+liberror_setenv_failed(const char *envname, const char *envval, int overwrite)
+{
+ const char *desc = "";
+ if (!envname) {
+ if (!envval)
+ desc = "Environment variable name and value are NULL";
+ else
+ desc = "Environment variable name is NULL";
+ } else if (!envval) {
+ desc = "Environment variable value is NULL";
+ } else if (!*envname) {
+ desc = "Environment variable name is the empty string";
+ } else if (errno == EINVAL) {
+ desc = "Environment variable name contains the '=' character";
+ }
+ liberror_set_error_errno(desc, "setenv", errno);
+ (void) overwrite;
+}
+
+
int
liberror_setenv(const char *envname, const char *envval, int overwrite)
{