summaryrefslogtreecommitdiff
path: root/helper.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>1999-11-22 16:11:05 +1100
committerDamien Miller <djm@mindrot.org>1999-11-22 16:11:05 +1100
commitd770252d3a6dfe5e97d1a6846e2e5bfde92accc2 (patch)
treeae06bf36e1be1928026832da49c366a8b2d310ce /helper.c
parentd71b12ee5b6b0283ce41ff2d9c8864c6aadc6bbe (diff)
- Added a setenv replacement for systems which lack it
Diffstat (limited to 'helper.c')
-rw-r--r--helper.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/helper.c b/helper.c
index 47e797b6c..91a78b577 100644
--- a/helper.c
+++ b/helper.c
@@ -149,3 +149,24 @@ void setproctitle(const char *fmt, ...)
149 /* FIXME */ 149 /* FIXME */
150} 150}
151#endif /* !HAVE_SETPROCTITLE */ 151#endif /* !HAVE_SETPROCTITLE */
152
153#ifndef HAVE_SETENV
154int setenv(const char *name, const char *value, int overwrite)
155{
156 char *env_string;
157 int result;
158
159 /* Don't overwrite existing env. var if overwrite is 0 */
160 if (!overwrite && (getenv(name) != NULL))
161 return(0);
162
163 env_string = xmalloc(strlen(name) + strlen(value) + 2);
164 sprintf(env_string, "%s=%s", name, value);
165
166 result = putenv(env_string);
167
168 xfree(env_string);
169
170 return(result);
171}
172#endif /* !HAVE_SETENV */