diff options
author | Damien Miller <djm@mindrot.org> | 1999-11-22 16:11:05 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-11-22 16:11:05 +1100 |
commit | d770252d3a6dfe5e97d1a6846e2e5bfde92accc2 (patch) | |
tree | ae06bf36e1be1928026832da49c366a8b2d310ce /helper.c | |
parent | d71b12ee5b6b0283ce41ff2d9c8864c6aadc6bbe (diff) |
- Added a setenv replacement for systems which lack it
Diffstat (limited to 'helper.c')
-rw-r--r-- | helper.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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 | ||
154 | int 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 */ | ||