On Jan 14, 2009, at 3:09 PM, Mehul N. Sanghvi wrote:
Sean Allen said the following on 01/14/2009 12:20 PM:
On Jan 14, 2009, at 11:45 AM, Mehul N. Sanghvi wrote:
I would like to be able to get at all of the environment
variables (whether it is the shell environment variables or the
CGI environment variables or something else). What object/class
would I use for that ?
o wait, i think i know this:
Smalltalk getenv: 'foo'
Smalltalk getenv: 'bar'
Is there something that will get all the environment variables and
store it in an Array or something like that ? Using the approach
above, say in a CGI environment when I'm trying to debug, I just
want it to print every environment variable as I probably do not
know what I would be looking for but am hoping
that something in the environment will give me some guidance.
Did that make sense ?
Perl, Tcl, and PHP store the environment variables in an
associative array which can then be poked and peeked at (yes the
usage of the two words was intentional use of BASIC). Scheme also
supports this with a recent enhancement to the language, SRFI-98.
Is there some way to do something similar ? Maybe there is a
message "getenvAll" ? I couldn't find it and there doesn't seem
to be much documentation for getenv on smalltalk.gnu.org site.
i've only been looking at the source for a few days but what i know
by now ( or think i know, corrections from Paolo appreciated... )
getenv is a call out to C's getenv
you want a call out to environ which doesn't exist right now,
someone with more experience than i could put in quickly.
you can see everything in kernel/cFuncs.st and libgst/cint.c
if you are feeling adventurous, there is documentation about
interfacing with C at:
http://www.gnu.org/software/smalltalk/manual/gst.html#C-and-Smalltalk