blob: ad9189f4b692cb3c73b45fe96558ff1a5effb8fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* See LICENSE file for copyright and license details. */
#include "internal.h"
void
liberror_putenv_failed(char *string)
{
const char *desc;
if (!string) {
errno = EINVAL;
desc = "Environment string is NULL";
} else if (*string == '=') {
errno = EINVAL;
desc = "Environment variable name is the empty string";
} else if (!strchr(string, '=')) {
errno = EINVAL;
desc = "Environment does not contain an '=' symbol";
} else {
desc = "";
}
liberror_set_error_errno(desc, "putenv", errno);
}
int
liberror_putenv(char *string)
{
const char *desc = "";
if (!string) {
errno = EINVAL;
desc = "Environment string is NULL";
goto error;
} else if (*string == '=') {
errno = EINVAL;
desc = "Environment variable name is the empty string";
goto error;
} else if (!strchr(string, '=')) {
errno = EINVAL;
desc = "Environment does not contain an '=' symbol";
goto error;
} else if (!putenv(string)) {
return 0;
}
error:
liberror_save_backtrace(NULL);
liberror_set_error_errno(desc, "putenv", errno);
return -1;
}
|