From 2f1aafa2a7e36298cc1e0e593b30fac1ab278596 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 15 Apr 2007 20:12:09 +0000 Subject: r22221: merge from samba4: - libreplace unsetenv() and strptime() replacements metze (This used to be commit 057c1c04d09b48c713ebc0b334cabcefc02561e9) --- source3/lib/replace/replace.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source3/lib/replace/replace.c') diff --git a/source3/lib/replace/replace.c b/source3/lib/replace/replace.c index 8310d66d9e..db299130e5 100644 --- a/source3/lib/replace/replace.c +++ b/source3/lib/replace/replace.c @@ -563,6 +563,32 @@ int rep_setenv(const char *name, const char *value, int overwrite) } #endif +#ifndef HAVE_UNSETENV +int rep_unsetenv(const char *name) +{ + extern char **environ; + size_t len = strlen(name); + size_t i; + int found = 0; + + for (i=0; (environ && environ[i]); i++) { + if (found) { + environ[i-1] = environ[i]; + continue; + } + + if (strncmp(environ[i], name, len) == 0 && environ[i][len] == '=') { + free(environ[i]); + environ[i] = NULL; + found = 1; + continue; + } + } + + return 0; +} +#endif + #ifndef HAVE_SOCKETPAIR int rep_socketpair(int d, int type, int protocol, int sv[2]) { -- cgit