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, ...) /* FIXME */ } #endif /* !HAVE_SETPROCTITLE */ + +#ifndef HAVE_SETENV +int setenv(const char *name, const char *value, int overwrite) +{ + char *env_string; + int result; + + /* Don't overwrite existing env. var if overwrite is 0 */ + if (!overwrite && (getenv(name) != NULL)) + return(0); + + env_string = xmalloc(strlen(name) + strlen(value) + 2); + sprintf(env_string, "%s=%s", name, value); + + result = putenv(env_string); + + xfree(env_string); + + return(result); +} +#endif /* !HAVE_SETENV */ |