--- a/UnixOperatingSystem.st Wed Jun 01 09:39:32 2005 +0200
+++ b/UnixOperatingSystem.st Thu Jun 02 16:03:08 2005 +0200
@@ -6254,6 +6254,59 @@
!UnixOperatingSystem class methodsFor:'os queries'!
+environmentAt:aKeyStringOrSymbol put:aString
+ "put a string to the environment.
+ If aString isNil, the variable will be removed from the environment.
+ Currently there is some malloced memory lost each time a variable is put to the environment.
+ We could use ExternalBytes and keep the references in a Dictionary to free the
+ memory on change or delete"
+
+%{ /* NOCONTEXT */
+
+ char *env;
+ int valueSize;
+
+ if (__isStringLike(aKeyStringOrSymbol)) {
+ if (aString == nil) {
+ /* env used only temporary for deregistration */
+ valueSize = 0;
+ env = __stringVal(aKeyStringOrSymbol);
+ } else if (__isStringLike(aString)) {
+ /* have to use stable memory for env */
+ valueSize = __stringSize(aString);
+ env = (char *)malloc(__stringSize(aKeyStringOrSymbol) + valueSize + 2);
+ if (env == 0)
+ goto err;
+ strcpy(env, __stringVal(aKeyStringOrSymbol));
+ strcat(env, "=");
+ strncat(env, __stringVal(aString), valueSize);
+ } else
+ goto err;
+
+ if (putenv(env) == 0) {
+ RETURN(self);
+ }
+
+ if (valueSize > 0) {
+ /* could not register, free */
+ free(env);
+ }
+err:;
+ }
+%}.
+ ^ self primitiveFailed
+
+ "
+ OperatingSystem environmentAt:#TEST put:'abc'.
+ OperatingSystem getEnvironment:#TEST.
+
+ OperatingSystem environmentAt:#TEST put:nil.
+ OperatingSystem environmentAt:#TEST put:''.
+
+ OperatingSystem environmentAt:#LD_LIBRARY_PATH put:'/opt/oracle/instantclient10_1'.
+ "
+!
+
executableFileExtensions
"return a collection of extensions for executable program files.
Only req'd for msdos like systems ..."
@@ -12302,7 +12355,7 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.227 2005-06-01 07:39:32 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.228 2005-06-02 14:03:08 stefan Exp $'
! !
UnixOperatingSystem initialize!