diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-02-12 11:49:25 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-02-12 11:49:25 +0000 |
commit | ac5c734f32ccd9787762253192de0d559609abae (patch) | |
tree | 9a652b97ea5faa3c9379b58275b5a101e2076b90 /win32 | |
parent | a2093a06980c0ef77ac4631e8b8f383be904f06a (diff) | |
download | perl-ac5c734f32ccd9787762253192de0d559609abae.tar.gz |
support win32_putenv()
p4raw-id: //depot/perl@2898
Diffstat (limited to 'win32')
-rw-r--r-- | win32/GenCAPI.pl | 5 | ||||
-rw-r--r-- | win32/makedef.pl | 1 | ||||
-rw-r--r-- | win32/perlhost.h | 2 | ||||
-rw-r--r-- | win32/win32.c | 34 | ||||
-rw-r--r-- | win32/win32iop.h | 3 |
5 files changed, 44 insertions, 1 deletions
diff --git a/win32/GenCAPI.pl b/win32/GenCAPI.pl index 5e7868ddf7..af71291830 100644 --- a/win32/GenCAPI.pl +++ b/win32/GenCAPI.pl @@ -995,6 +995,11 @@ char* _win32_getenv(const char *name) return pPerl->PL_piENV->Getenv(name, ErrorNo()); } +int _win32_putenv(const char *name) +{ + return pPerl->PL_piENV->Putenv(name, ErrorNo()); +} + int _win32_open_osfhandle(long handle, int flags) { return pPerl->PL_piStdIO->OpenOSfhandle(handle, flags); diff --git a/win32/makedef.pl b/win32/makedef.pl index 0d9069b9fd..fa1b58081b 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -497,6 +497,7 @@ win32_setnetent win32_setprotoent win32_setservent win32_getenv +win32_putenv win32_perror win32_setbuf win32_setvbuf diff --git a/win32/perlhost.h b/win32/perlhost.h index 21908098a5..e514bf1342 100644 --- a/win32/perlhost.h +++ b/win32/perlhost.h @@ -88,7 +88,7 @@ public: }; virtual int Putenv(const char *envstring, int &err) { - return putenv(envstring); + return win32_putenv(envstring); }; virtual char* LibPath(char *pl) { diff --git a/win32/win32.c b/win32/win32.c index 2c74fc25af..7b9acd4a8f 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1002,6 +1002,40 @@ win32_getenv(const char *name) return curitem; } +DllExport int +win32_putenv(const char *name) +{ + char* curitem; + char* val; + int relval = -1; + if(name) { + New(1309,curitem,strlen(name)+1,char); + strcpy(curitem, name); + val = strchr(curitem, '='); + if(val) { + /* The sane way to deal with the environment. + * Has these advantages over putenv() & co.: + * * enables us to store a truly empty value in the + * environment (like in UNIX). + * * we don't have to deal with RTL globals, bugs and leaks. + * * Much faster. + * Why you may want to enable USE_WIN32_RTL_ENV: + * * environ[] and RTL functions will not reflect changes, + * which might be an issue if extensions want to access + * the env. via RTL. This cuts both ways, since RTL will + * not see changes made by extensions that call the Win32 + * functions directly, either. + * GSAR 97-06-07 + */ + *val++ = '\0'; + if(SetEnvironmentVariable(curitem, *val ? val : NULL)) + relval = 0; + } + Safefree(curitem); + } + return relval; +} + #endif static long diff --git a/win32/win32iop.h b/win32/win32iop.h index 12fe63e38f..c7a74444e0 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -115,6 +115,7 @@ DllExport long win32_get_osfhandle(int fd); #ifndef USE_WIN32_RTL_ENV DllExport char* win32_getenv(const char *name); +DllExport int win32_putenv(const char *name); #endif DllExport unsigned win32_sleep(unsigned int); @@ -279,6 +280,8 @@ END_EXTERN_C #ifndef USE_WIN32_RTL_ENV #undef getenv #define getenv win32_getenv +#undef putenv +#define putenv win32_putenv #endif #endif /* WIN32IO_IS_STDIO */ |