Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!mcnc!decvax!ucbvax!agate!violet.berkeley.edu!pete From: pete@violet.berkeley.edu Newsgroups: comp.sys.amiga Subject: Re: getenv() -- Lattice 4.0 Message-ID: <6893@agate.BERKELEY.EDU> Date: 7 Feb 88 10:12:56 GMT Sender: usenet@agate.BERKELEY.EDU Reply-To: pete@violet.berkeley.edu () Organization: University of California, Berkeley Lines: 43 Keywords: getenv, stdlib.h, Lattice In a recent posting, David Roch [roch@b.uiuc.edu] asked: > While looking through the include files for Lattice 4.0, I noticed > that getenv is defined in stdlib.h. Curious, I tried accessing > the environment variables set by assign, both with and without > the colon, but in each case the null string was returned. > > [...sample program omitted...] > > The map file shows that getenv is 0x328 bytes. Can anyone tell > me what's going on? > thanks, > david roch > roch@b.uiuc.edu OK -- you got me curious, so I did some code disassembly... You're right [strangely...!] in that getenv searches the Device List for names. However, what's returned is NOT another character string (despite the prototype in stdlib.h!), but the ADDRESS of the relevant DevInfo block. (It can be any device -- not just assigned ones.) Try feeding this little test program some device names (no colons): /* stalking the phantom environment */ #include #include void main(argc,argv) char **argv; { APTR v; while (--argc) { v = getenv(*++argv); printf("%s = %x\n", *argv, v); } } I wonder what Lattice intends this for? You can of course use it just to test if a device is "mounted" (just like Bryce and others have done). Why use the name "getenv" though? ...Not exactly ANSI compatible! -- Pete G. --