transmission: upgrade 2.31 to 2.32
[tomato.git] / release / src / router / gettext / djgpp / unsetenv.c
blobf00c5d0739468b70b8c350ac0daaedaa4f5e1708
1 /*
2 libc of DJGPP 2.03 does not offer function unsetenv,
3 so this version from DJGPP 2.04 CVS tree is supplied.
4 This file will become superflous and will be removed
5 from the distribution as soon as DJGPP 2.04 has been
6 released.
7 */
9 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
11 #include <libc/stubs.h>
12 #include <libc/unconst.h>
13 #include <errno.h>
14 #include <stdlib.h>
15 #include <string.h>
17 extern char **environ;
19 int
20 unsetenv(const char *name)
22 /* No environment == success */
23 if (environ == 0)
24 return 0;
26 /* Check for the failure conditions */
27 if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
29 errno = EINVAL;
30 return -1;
33 /* Let putenv() do the work
34 * Note that we can just pass name directly as our putenv() treats
35 * this the same as passing 'name='. */
36 /* The cast is needed because POSIX specifies putenv() to take a non-const
37 * parameter. Our putenv is well-behaved, so this is OK. */
38 putenv (unconst (name, char*));
40 return 0;