home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
misc
/
make.lzh
/
ENVFETCH.C
< prev
next >
Wrap
Text File
|
1986-01-19
|
1KB
|
51 lines
#define CPEEK(off,seg) ((unsigned char) peek (off, seg))
/*
* env_fetch (name, envseg, dest)
*
* Search environment at segment address for variable named and
* if found store value of variable at dest. Return true (nonzero)
* if found.
*/
env_fetch (name, envseg, dest)
char *name, *dest;
unsigned int envseg;
{
unsigned int
envoff;
char
c,
*dp,
leftpart[132];
envoff = 0; /* starting environment offset */
dp = leftpart;
while (1)
{
c = CPEEK (envoff++, envseg);
switch (c)
{
case '=':
*dp = 0; /* make ASCIZ */
if (strcmp (leftpart, "COMSPEC") == 0)
{
dp = dest;
while (*dp++ = CPEEK (envoff++, envseg));
return (1);
};
while (CPEEK (envoff++, envseg)); /* skip to end */
dp = leftpart; /* reset destination pointer */
break;
case 0:
if (CPEEK (envoff + 1, envseg) == 0)
return (0);
dp = leftpart;
break;
default:
*dp++ = c;
};
};
}