Mail Archives: djgpp-workers/2001/07/10/09:36:57
X-Authentication-Warning: | new-smtp2.ihug.com.au: Host p192-tnt4.syd.ihug.com.au [203.173.134.192] claimed to be acceleron
|
Message-ID: | <000c01c10944$9ad2fff0$0a02a8c0@acceleron>
|
From: | "Andrew Cottrell" <acottrel AT ihug DOT com DOT au>
|
To: | <djgpp-workers AT delorie DOT com>
|
Subject: | DJDIR Windows 2000 investigation results #1
|
Date: | Tue, 10 Jul 2001 23:31:18 +1000
|
MIME-Version: | 1.0
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Mailer: | Microsoft Outlook Express 5.50.4522.1200
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4522.1200
|
Reply-To: | djgpp-workers AT delorie DOT com
|
This is a multi-part message in MIME format.
------=_NextPart_000_0009_01C10998.6BA307D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all,
I checked out the code as Eli suggested and traced a quirk (I do not =
know enough about the LFN API to call it a bug) using Ralph Browns =
Interrupt List 6.1. I have attached the app that I used for the =
investigation (only the final version). Sorry for including such a large =
code snippet, but I thought that this would help, let me know what I =
should do in the future so as not to cause any problems.
The quirk I found was that if I remove the "| 0x1000" in the code as =
commented then the DJDIR environment variable is inserted into the app's =
environment on Windows 2000. It made no difference on the WIN 98SE box =
that I used to compile the app on if it was included or not.=20
What does the 0x1000 bit do? It is unused in Ralph's list as indicated =
in the following table (interrupt.h file):
Bitfields for Windows95 file access/sharing modes:
Bit(s) Description (Table 01782)
2-0 file access mode
000 read-only
001 write-only
010 read-write
100 read-only, do not modify file's last-access time
6-4 file sharing modes
7 no-inherit flag
8 do not buffer data (requires that all reads/writes be exact =
physical
sectors)
9 do not compress file even if volume normally compresses files
10 use alias hint in DI as numeric tail for short-name alias
12-11 unused??? (0)
13 return error code instead of generating INT 24h if critical =
error
while opening file
14 commit file after every write operation
The output from Windows 2000 is=20
TEST 1: This app is i:/dj204/contrib/test/main.exe
djgpp_var D:/DJGPP/DJGPP.ENV
main.c 46
main.c 90 D:/DJGPP/DJGPP.ENV
djgpp_env 5
112 116 122 177 210 210 210 241 putenv DJDIR=3Dd:/djgpp
177 186 putenv USER=3Ddosuser
177 186 putenv GROUP=3Droot
177 186 241 putenv TMPDIR=3Dd:/djgpp/tmp
177 186 241 putenv EMU387=3Dd:/djgpp/bin/emu387.dxe
177 186 177 186 241 putenv TEXMFMAIN=3Dd:/djgpp/share/texmf
177 186 241 putenv GO32STUB=3Dd:/djgpp/bin/stubify.exe
TEST 2: This app is i:/dj204/contrib/test/main.exe
djgpp_var D:/DJGPP/DJGPP.ENV
main.c 46
87 D:/DJGPP/DJGPP.ENV, error no (register AX) =3D 0x57djgpp_env -1
Any ideas on what I should do next? Is it worth performing a test and =
remove all of the " | 0x1000" from the LFN functions and re-compile the =
DJGPP CVS 2.04 tarball and test again?
If you need to send me an email then remove then remove the .oz from the =
email address.
Thanks,
Andrew
-------------------------------------------------- CODE START =
-----------------
#include <stdlib.h>
#include <unistd.h>
#include <crt0.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stubinfo.h>
#include <dir.h>
#include <limits.h>
#include <dpmi.h>
#include <errno.h>
#include <libc/dosio.h>
#include <sys/fsext.h>
#include <go32.h>
#include <libc/stubs.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <dos.h>
#define acprintf(A,B) printf("%s %d " A " \n", __FILE__,__LINE__,B)
#define acdebug printf("%s %d \n",__FILE__,__LINE__);
#define acdebugnl printf("%d ",__LINE__);
int ac_open (const char *filename, int oflag, int use_fat32)
{
__dpmi_regs r;
int rv;
int use_lfn =3D _USE_LFN;
if (filename =3D=3D 0)
{
acdebug errno =3D EINVAL;
return -1;
}
if (__FSEXT_call_open_handlers (__FSEXT_open, &rv, &filename))
{
acdebug return rv;
}
if (use_lfn)
{
acdebug
r.x.ax =3D 0x716c;
#if 1
r.x.bx =3D (oflag & 0xff) | use_fat32; /* 0x1000 is FAT32 extended =
size. */
#else
ORIGINAL LINE -- r.x.bx =3D (oflag & 0xff) | 0x1000; /* 0x1000 is =
FAT32 extended size. */
r.x.bx =3D (oflag & 0xff) ; /* 0x1000 is FAT32 extended size. */
#endif
r.x.dx =3D 1; /* Open existing file */
r.x.si =3D __tb_offset;
}
else
{
acdebug
if (7 <=3D _osmajor && _osmajor < 10)
{
acdebug
r.x.ax =3D 0x6c00;
r.x.bx =3D (oflag & 0xff) | 0x1000; /* 0x1000 is FAT32 extended size. =
*/
/* FAT32 extended size flag doesn't help on WINDOZE 4.1 (98). It
seems it has a bug which only lets you create these big files
if LFN is enabled. */
r.x.dx =3D 1; /* Open existing file */
r.x.si =3D __tb_offset;
}
else
{
acdebug
r.h.ah =3D 0x3d;
r.h.al =3D oflag;
r.x.dx =3D __tb_offset;
}
}
r.x.cx =3D 0;
r.x.ds =3D __tb_segment;
_put_path (filename);
__dpmi_int (0x21, &r);
if (r.x.flags & 1)
{
errno =3D __doserr_to_errno (r.x.ax);
printf("%d %s, error no (register AX) =3D 0x%X",__LINE__, =
filename, r.x.ax);
return -1;
}
acprintf("%s",filename);
__file_handle_set (r.x.ax, O_BINARY);
return r.x.ax;
}
void test_environment_file (char *app_name, int use_fat32)
{
int djgpp_env;
char *djgpp_var =3D getenv ("DJGPP");
printf ("djgpp_var %s \n", djgpp_var);
if (djgpp_var)
{
djgpp_env =3D ac_open(djgpp_var, O_RDONLY, use_fat32);
printf ("djgpp_env %d \n", djgpp_env);
if (djgpp_env >=3D 0)
{
char *file;
char base[PATH_MAX], *bp, *a0p, *tb;
int this_prog =3D 1;
int fsize =3D lseek (djgpp_env, 0L, SEEK_END);
acdebugnl
file =3D (char *) malloc (fsize + 2);
if (file =3D=3D 0)
return;
acdebugnl
lseek (djgpp_env, 0L, 0);
_read (djgpp_env, file, fsize);
_close (djgpp_env);
if (file[fsize - 1] =3D=3D '\n')
{
acdebugnl
file[fsize] =3D 0;
}
else
{
acdebugnl
file[fsize] =3D '\n';
file[fsize + 1] =3D 0;
}
tb =3D file;
base[0] =3D '[';
bp =3D app_name;
for (a0p =3D bp; *a0p; a0p++)
if (strchr ("\\/:", *a0p))
bp =3D a0p + 1;
for (a0p =3D base + 1; *bp && *bp !=3D '.';)
*a0p++ =3D tolower ((unsigned char) *bp++);
*a0p++ =3D ']';
*a0p++ =3D 0;
bp =3D tb;
while (1)
{
tb =3D bp;
while (*tb && (*tb =3D=3D '\n' || *tb =3D=3D '\r'))
tb++;
bp =3D tb;
while (*bp && *bp !=3D '\n' && *bp !=3D '\r')
bp++;
if (*bp =3D=3D 0)
break;
*bp++ =3D 0;
if (tb[0] =3D=3D 0 || tb[0] =3D=3D '#')
continue;
if (tb[0] =3D=3D '[')
{
char *p =3D bp - 2;
/* Some losers leave trailing blanks after "[foo]". */
while (p > tb && (*p =3D=3D ' ' || *p =3D=3D '\t'))
p--;
*++p =3D 0;
if (strcmp (tb, base) =3D=3D 0)
this_prog =3D 1;
else
this_prog =3D 0;
}
else
{
if (this_prog)
{
char *buf =3D alloca (fsize);
char *tb2 =3D buf;
char *sp =3D tb, *dp =3D tb2;
acdebugnl while (*sp !=3D '=3D' && *sp !=3D '\n' && *sp)
*dp++ =3D *sp++;
if (*sp =3D=3D '\n' || *sp =3D=3D '\0')
{
tb =3D sp;
continue;
}
if (*tb2 =3D=3D '+') /* non-overriding */
{
acdebugnl * dp =3D 0;
tb2++;
if (getenv (tb2))
continue; /* while scanning bytes */
}
*dp++ =3D *sp++; /* copy the '=3D' */
while (*sp)
{
if (*sp =3D=3D '%')
{
char *pp;
if (sp[1] =3D=3D '%')
{
*dp++ =3D '%';
sp +=3D 2;
}
else
{
char ps, *e, *dirend;
int dirpart =3D 0, apsemi =3D 0;
int mapup =3D 0, maplow =3D 0, mapfs =3D
0, mapbs =3D 0;
while (strchr (":;/\\<>", sp[1]))
{
acdebugnl
switch (sp[1])
{
case ':':
dirpart =3D 1;
break;
case ';':
apsemi =3D 1;
break;
case '/':
mapfs =3D 1;
break;
case '\\':
mapbs =3D 1;
break;
case '<':
mapup =3D 1;
break;
case '>':
maplow =3D 1;
break;
}
sp++;
}
for (pp =3D sp + 1; *pp && *pp !=3D '%'; pp++);
ps =3D *pp;
*pp =3D 0;
e =3D getenv (sp + 1);
dirend =3D dp;
if (e)
{
acdebugnl
while (*e)
{
char ec =3D *e++;
if (strchr ("\\/:", ec))
dirend =3D dp;
if (mapup)
ec =3D toupper ((unsigned char) ec);
if (maplow)
ec =3D tolower ((unsigned char) ec);
if (mapfs && ec =3D=3D '\\')
ec =3D '/';
if (mapbs && ec =3D=3D '/')
ec =3D '\\';
*dp++ =3D ec;
}
}
if (dirpart)
dp =3D dirend;
if (apsemi && e)
*dp++ =3D ';';
if (ps =3D=3D 0)
break;
sp =3D pp + 1;
}
}
else
*dp++ =3D *sp++;
}
*dp++ =3D 0;
printf ("putenv %s \n", tb2);
putenv (tb2);
}
}
}
free (file);
}
}
}
int main (int argc , char * argv[] )
{
printf("TEST 1: This app is %s\n", argv[0]);
test_environment_file(argv[0], 0x0000);
printf("TEST 2: This app is %s\n", argv[0]);
test_environment_file(argv[0], 0x1000);
return 0;
}
-------------------------------------------------- CODE END =
-----------------
On Mon, 9 Jul 2001, Andrew Cottrell wrote:
> 1) On the WIN98 PC the DOS set command does not show an environment
> variable called DJDIR, but it shows up when I display all of the
> environment variables as indicated in the sample app
This is expected behavior: DJDIR is computed and set by the startup code =
of each DJGPP program. That's why you only see it inside a program, and =
in any shells spawned by a program, but not outside.
> 2) On the WIN 2000 PC the DOS set command does not show an environment
> variable called DJDIR and neither does the sample app show it in the
> environment array.
That is the reason for the problem with RHIDE.
> Any ideas on what I should do next or where to look?
You should look at the startup code, specifically at the code in the =
file=20
src/libc/crt0/c1loadef.c. This is the code which reads the djgpp.env=20
file and sets DJDIR when it reads this line from djgpp.env:
DJDIR=3D%:/>DJGPP%
Something is wrong there when the program runs on Windows 2000. (If you =
need to understand the cryptic syntax of djgpp.env, read the section=20
"DJGPP.ENV" in the Info file kb.info.)
Thanks for working on this.
Btw, you might wish to redirect this discussion to the
djgpp-workers AT delorie DOT com mailing list, where all the DJGPP developers
are subscribed.
------=_NextPart_000_0009_01C10998.6BA307D0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I checked out the code as Eli suggested =
and traced=20
a quirk (I do not know enough about the LFN API to call it a bug) using =
Ralph=20
Browns Interrupt List 6.1. I have attached the app that I used for the=20
investigation (only the final version). Sorry for including such a large =
code=20
snippet, but I thought that this would help, let me know what I should =
do in the=20
future so as not to cause any problems.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The quirk I found was that if I remove =
the "|=20
0x1000" in the code as commented then the DJDIR environment =
variable is=20
inserted into the app's environment on Windows 2000. It made no =
difference on=20
the WIN 98SE box that I used to compile the app on if it was included or =
not.=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>What does the 0x1000 bit do? It is =
unused in=20
Ralph's list as indicated in the following table (interrupt.h=20
file):</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Bitfields for Windows95 file =
access/sharing=20
modes:<BR>Bit(s) Description (Table=20
01782)<BR> 2-0 file access=20
mode<BR> 000=20
read-only<BR> 001=20
write-only<BR> 010=20
read-write<BR> 100 read-only, =
do not=20
modify file's last-access time<BR> 6-4 file =
sharing=20
modes<BR> 7 no-inherit=20
flag<BR> 8 do not buffer data =
(requires that=20
all reads/writes be exact=20
physical<BR> =20
sectors)<BR> 9 do not compress file =
even if=20
volume normally compresses files<BR> 10 use =
alias=20
hint in DI as numeric tail for short-name alias<BR> 12-11 =
unused???=20
(0)<BR> 13 return error code instead of =
generating=20
INT 24h if critical=20
error<BR> while =
opening=20
file<BR> 14 commit file after every write=20
operation</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The output from Windows 2000 is =
</DIV></FONT>
<DIV><FONT face=3DArial size=3D2>TEST 1: This app is=20
i:/dj204/contrib/test/main.exe<BR>djgpp_var =
D:/DJGPP/DJGPP.ENV<BR>main.c=20
46<BR>main.c 90 D:/DJGPP/DJGPP.ENV<BR>djgpp_env 5<BR>112 116 122 =
177 210=20
210 210 241 putenv DJDIR=3Dd:/djgpp<BR>177 186 putenv =20
USER=3Ddosuser<BR>177 186 putenv GROUP=3Droot<BR>177 186 241 =
putenv =20
TMPDIR=3Dd:/djgpp/tmp<BR>177 186 241 putenv =20
EMU387=3Dd:/djgpp/bin/emu387.dxe<BR>177 186 177 186 241 putenv =20
TEXMFMAIN=3Dd:/djgpp/share/texmf<BR>177 186 241 putenv =20
GO32STUB=3Dd:/djgpp/bin/stubify.exe<BR>TEST 2: This app is=20
i:/dj204/contrib/test/main.exe<BR>djgpp_var =
D:/DJGPP/DJGPP.ENV<BR>main.c=20
46<BR>87 D:/DJGPP/DJGPP.ENV, error no (register AX) =3D =
0x57djgpp_env =20
-1<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Any ideas on what I should do next? =
</FONT><FONT=20
face=3DArial size=3D2>Is it worth performing a test and remove all of =
the " |=20
0x1000" from the LFN functions and re-compile the DJGPP CVS 2.04 tarball =
and=20
test again?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>If you need to send me an email then =
remove then=20
remove the .oz from the email address.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Andrew</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV>-------------------------------------------------- CODE START=20
-----------------</DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>#include <stdlib.h><BR>#include=20
<unistd.h><BR>#include <crt0.h><BR>#include=20
<sys/stat.h><BR>#include <stdio.h><BR>#include=20
<stubinfo.h><BR>#include <dir.h><BR>#include=20
<limits.h><BR>#include <dpmi.h><BR>#include=20
<errno.h><BR>#include <libc/dosio.h><BR>#include=20
<sys/fsext.h><BR>#include <go32.h><BR>#include=20
<libc/stubs.h><BR>#include <string.h><BR>#include=20
<fcntl.h><BR>#include <io.h><BR>#include =
<dos.h></FONT></DIV>
<DIV> </DIV><FONT face=3DArial size=3D2>
<DIV><BR>#define acprintf(A,B) printf("%s %d " A " \n",=20
__FILE__,__LINE__,B)<BR>#define acdebug printf("%s %d=20
\n",__FILE__,__LINE__);<BR>#define acdebugnl printf("%d =
",__LINE__);</DIV>
<DIV> </DIV>
<DIV>int ac_open (const char *filename, int oflag, int =
use_fat32)<BR>{<BR> =20
__dpmi_regs r;<BR> int rv;<BR> int use_lfn =3D =
_USE_LFN;</DIV>
<DIV> </DIV>
<DIV> if (filename =3D=3D 0)<BR> =20
{<BR> acdebug errno =3D=20
EINVAL;<BR> return =
-1;<BR> =20
}</DIV>
<DIV> </DIV>
<DIV> if (__FSEXT_call_open_handlers (__FSEXT_open, &rv,=20
&filename))<BR> =
{<BR> =20
acdebug return rv;<BR> }</DIV>
<DIV> </DIV>
<DIV> if (use_lfn)<BR> =20
{<BR> =
acdebug<BR> =20
r.x.ax =3D 0x716c;<BR>#if 1<BR> r.x.bx =3D =
(oflag=20
& 0xff) | use_fat32; /* 0x1000 is FAT32 extended size.=20
*/<BR>#else<BR>ORIGINAL LINE -- r.x.bx =3D =
(oflag=20
& 0xff) | 0x1000; /* 0x1000 is FAT32 extended size.=20
*/<BR> r.x.bx =3D (oflag & 0xff) =
; /*=20
0x1000 is FAT32 extended size. =
*/<BR>#endif<BR> =20
r.x.dx =3D 1; /* Open existing file=20
*/<BR> r.x.si =3D =
__tb_offset;<BR> =20
}<BR> else<BR> =
{<BR> =20
acdebug<BR> if (7 <=3D _osmajor =
&&=20
_osmajor < 10)<BR> {<BR> =20
acdebug<BR> r.x.ax =
=3D=20
0x6c00;<BR> r.x.bx =3D (oflag & 0xff) | 0x1000; /* =
0x1000 is=20
FAT32 extended size. */<BR> /* FAT32 extended size flag =
doesn't help=20
on WINDOZE 4.1 (98). It</DIV>
<DIV> </DIV>
<DIV> seems it has a bug which only lets =
you=20
create these big files<BR> if LFN is =
enabled.=20
*/<BR> r.x.dx =3D 1; /* Open existing file=20
*/<BR> r.x.si =3D=20
__tb_offset;<BR> }<BR> =20
else<BR> {<BR> =20
acdebug<BR> r.h.ah =
=3D=20
0x3d;<BR> r.h.al =3D oflag;<BR> r.x.dx =3D=20
__tb_offset;<BR> }<BR> }<BR> r.x.cx =3D =
0;<BR> =20
r.x.ds =3D __tb_segment;<BR> _put_path (filename);<BR> =
__dpmi_int=20
(0x21, &r);<BR> if (r.x.flags & 1)<BR> =20
{<BR> errno =3D __doserr_to_errno=20
(r.x.ax);<BR> printf("%d %s, error no =
(register=20
AX) =3D 0x%X",__LINE__, filename, =
r.x.ax);<BR> =20
return -1;<BR> }<BR> acprintf("%s",filename);<BR> =20
__file_handle_set (r.x.ax, O_BINARY);<BR> return =
r.x.ax;<BR>}</DIV>
<DIV> </DIV>
<DIV>void test_environment_file (char *app_name, int =
use_fat32)<BR>{<BR> =20
int djgpp_env;<BR> char *djgpp_var =3D getenv ("DJGPP");</DIV>
<DIV> </DIV>
<DIV> printf ("djgpp_var %s \n", djgpp_var);<BR> if=20
(djgpp_var)<BR> {<BR> =
djgpp_env=20
=3D ac_open(djgpp_var, O_RDONLY, =
use_fat32);<BR> =20
printf ("djgpp_env %d \n", djgpp_env);</DIV>
<DIV> </DIV>
<DIV> if (djgpp_env >=3D=20
0)<BR> {<BR> char *file;<BR> char =
base[PATH_MAX],=20
*bp, *a0p, *tb;<BR> int this_prog =3D 1;<BR> int =
fsize =3D=20
lseek (djgpp_env, 0L, SEEK_END);<BR> =20
acdebugnl<BR> file =
=3D (char=20
*) malloc (fsize + 2);<BR> if (file =3D=3D=20
0)<BR> return;<BR> =20
acdebugnl<BR> =
lseek=20
(djgpp_env, 0L, 0);<BR> _read (djgpp_env, file,=20
fsize);<BR> _close (djgpp_env);<BR> if =
(file[fsize - 1]=20
=3D=3D '\n')<BR> =
{<BR> =20
acdebugnl<BR> =
=20
file[fsize] =3D 0;<BR> }<BR> =20
else<BR> =
{<BR> =20
acdebugnl<BR> =
=20
file[fsize] =3D '\n';<BR> file[fsize =
+ 1] =3D=20
0;<BR> }<BR> tb =3D file;</DIV>
<DIV> </DIV>
<DIV> base[0] =3D '[';<BR> bp =3D =
app_name;<BR> =20
for (a0p =3D bp; *a0p; a0p++)<BR> if (strchr=20
("<A>\\/</A>:", *a0p))<BR> bp =3D =
a0p +=20
1;<BR> for (a0p =3D base + 1; *bp && *bp !=3D=20
'.';)<BR> *a0p++ =3D tolower ((unsigned char)=20
*bp++);<BR> *a0p++ =3D ']';<BR> *a0p++ =3D =
0;</DIV>
<DIV> </DIV>
<DIV> bp =3D tb;<BR> while =
(1)<BR> =20
{<BR> tb =3D=20
bp;<BR> while (*tb && (*tb =
=3D=3D '\n'=20
|| *tb =3D=3D =
'\r'))<BR> tb++;<BR> bp=20
=3D tb;<BR> while (*bp && =
*bp !=3D '\n'=20
&& *bp !=3D=20
'\r')<BR> bp++;<BR> if =
(*bp =3D=3D=20
0)<BR> break;<BR> *bp++ =
=3D=20
0;<BR> if (tb[0] =3D=3D 0 || tb[0] =
=3D=3D=20
'#')<BR> =20
continue;<BR> if (tb[0] =3D=3D=20
'[')<BR> {<BR> char *p =3D bp - 2;</DIV>
<DIV> </DIV>
<DIV> /* Some losers leave trailing blanks after=20
"[foo]". */<BR> while (p > tb && (*p =
=3D=3D ' '=20
|| *p =3D=3D '\t'))<BR> =
p--;<BR> =20
*++p =3D 0;<BR> if (strcmp (tb, base) =3D=3D=20
0)<BR> this_prog =3D =
1;<BR> =20
else<BR> this_prog =3D=20
0;<BR> }<BR> =20
else<BR> {<BR> if=20
(this_prog)<BR> =20
{<BR> char *buf =3D alloca=20
(fsize);<BR> char *tb2 =3D=20
buf;<BR> char *sp =3D tb, *dp =
=3D=20
tb2;<BR> acdebugnl while (*sp =
!=3D '=3D'=20
&& *sp !=3D '\n' && *sp)<BR> *dp++ =3D=20
*sp++;<BR> if (*sp =3D=3D '\n' =
|| *sp =3D=3D=20
'\0')<BR> {<BR> tb =3D=20
sp;<BR> =20
continue;<BR> }<BR> &=
nbsp;=20
if (*tb2 =3D=3D '+') /* non-overriding=20
*/<BR> {<BR> acdebugnl * dp =3D =
0;<BR> tb2++;<BR> if =
(getenv=20
(tb2))<BR> continue; /* while =
scanning=20
bytes =
*/<BR> }<BR> =20
*dp++ =3D *sp++; /* copy the '=3D'=20
*/<BR> while=20
(*sp)<BR> {<BR> if (*sp =3D=3D=20
'%')<BR> =20
{<BR> char=20
*pp;<BR> if (sp[1] =
=3D=3D=20
'%')<BR> {<BR> =
*dp++ =3D=20
'%';<BR> sp +=3D=20
2;<BR> }<BR> &n=
bsp; =20
else<BR> {<BR> char =
ps, *e,=20
*dirend;<BR> int dirpart =3D 0, apsemi =3D =
0;<BR> int mapup =3D 0, maplow =3D 0, =
mapfs=20
=3D<BR> 0, mapbs =3D=20
0;<BR> while (strchr (":;/\\<>",=20
sp[1]))<BR> =20
{<BR> =20
acdebugnl<BR> =
&=
nbsp; &n=
bsp; =20
switch=20
(sp[1])<BR> {<BR> &nb=
sp;case=20
':':<BR> dirpart =3D=20
1;<BR> =20
break;<BR> case=20
';':<BR> apsemi =3D=20
1;<BR> =20
break;<BR> case=20
'/':<BR> mapfs =3D=20
1;<BR> =20
break;<BR> case=20
'\\':<BR> mapbs =3D=20
1;<BR> =20
break;<BR> case=20
'<':<BR> mapup =3D=20
1;<BR> =20
break;<BR> case=20
'>':<BR> maplow =3D=20
1;<BR> =20
break;<BR> }<BR> &nbs=
p; =20
sp++;<BR> =20
}<BR> for (pp =3D sp + 1; *pp && =
*pp !=3D '%';=20
pp++);<BR> ps =3D=20
*pp;<BR> *pp =3D=20
0;<BR> e =3D getenv (sp +=20
1);<BR> dirend =3D=20
dp;<BR> if=20
(e)<BR> =20
{<BR> =20
acdebugnl<BR> =
&=
nbsp; &n=
bsp; =20
while=20
(*e)<BR> {<BR> =
=20
char ec =3D *e++;<BR> if (strchr=20
("<A>\\/</A>:", ec))<BR> =
dirend=20
=3D dp;<BR> if=20
(mapup)<BR> ec =3D =
toupper=20
((unsigned char) ec);<BR> if=20
(maplow)<BR> ec =3D =
tolower=20
((unsigned char) ec);<BR> if (mapfs=20
&& ec =3D=3D =
'\\')<BR> ec =3D=20
'/';<BR> if (mapbs && ec =
=3D=3D=20
'/')<BR> ec =3D=20
'\\';<BR> *dp++ =3D=20
ec;<BR> }<BR> &=
nbsp; =20
}<BR> if=20
(dirpart)<BR> dp =3D=20
dirend;<BR> if (apsemi &&=20
e)<BR> *dp++ =3D=20
';';<BR> if (ps =3D=3D=20
0)<BR> =20
break;<BR> sp =3D pp +=20
1;<BR> }<BR> =20
}<BR> =
else<BR> *dp++=20
=3D =
*sp++;<BR> }<BR> &nbs=
p;=20
*dp++ =3D 0;<BR> printf =
("putenv =20
%s \n", tb2);<BR> putenv=20
(tb2);<BR> =20
}<BR> }<BR> }<BR> free=20
(file);<BR> }<BR> }<BR>}</DIV>
<DIV> </DIV>
<DIV>int main (int argc , char * argv[] )<BR>{<BR> printf("TEST 1: =
This=20
app is %s\n", argv[0]);<BR> test_environment_file(argv[0],=20
0x0000);<BR> printf("TEST 2: This app is %s\n", =
argv[0]);<BR> =20
test_environment_file(argv[0], 0x1000);<BR> return 0;<BR>}</DIV>
<DIV>
<DIV>-------------------------------------------------- CODE END=20
-----------------</DIV></DIV></FONT>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>On Mon, 9 Jul 2001, Andrew Cottrell=20
wrote:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>> 1) On the WIN98 PC the DOS set =
command does=20
not show an environment<BR>> variable called DJDIR, but it shows up =
when I=20
display all of the<BR>> environment variables as indicated in the =
sample=20
app</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>This is expected behavior: DJDIR is =
computed and=20
set by the startup code <BR>of each DJGPP program. That's why you =
only see=20
it inside a program, and <BR>in any shells spawned by a program, but not =
outside.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>> 2) On the WIN 2000 PC the DOS set =
command does=20
not show an environment<BR>> variable called DJDIR and neither does =
the=20
sample app show it in the<BR>> environment array.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>That is the reason for the problem with =
RHIDE.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>> Any ideas on what I should do next =
or where to=20
look?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>You should look at the startup code, =
specifically=20
at the code in the file <BR>src/libc/crt0/c1loadef.c. This is the =
code=20
which reads the djgpp.env <BR>file and sets DJDIR when it reads this =
line from=20
djgpp.env:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> =
DJDIR=3D%:/>DJGPP%</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Something is wrong there when the =
program runs on=20
Windows 2000. (If you <BR>need to understand the cryptic syntax of =
djgpp.env, read the section <BR>"DJGPP.ENV" in the Info file=20
kb.info.)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for working on =
this.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Btw, you might wish to redirect this =
discussion to=20
the<BR><A =
href=3D"mailto:djgpp-workers AT delorie DOT com">djgpp-workers AT delorie DOT com</A>=20
mailing list, where all the DJGPP developers<BR>are=20
subscribed.</FONT></DIV></BODY></HTML>
------=_NextPart_000_0009_01C10998.6BA307D0--
- Raw text -