I have written the following code. It is part of an operating environment for DOS I'm developing, and it's meant to accertain weather the file in inputstx is described in a data file as restricted to the current user. The function ECIREAD does all the file reading from this file, and it works like this:-
Code:
char *eciread(char *locationinfile, char *anotherlocationinfile, int characterstoread, int offsetfromlastlocation, int mode)
this is it:-
Code:
int qfs(char *inputstx) /* Returns 0 for OK, 42 if file is restricted, and 43 if extention is restricted.*/
{
char *tmp, tmp3[700], tmp5[700], tmp6[700], *tmp7;
FILE *tmp4;
int tmp2;
tmp2=0;
tmp7=inputstx;
do
{
tmp3[tmp2]=NULL;
tmp2=tmp2+1;
}
while(tmp2<673);
tmp2=0;
strcpy(tmp3, "f=");
strcat(tmp3, tmp7);
tmp=eciread("[ACCESS]", tmp3, 700, 0, 1);
if(tmp!=NULL)
{
return(42);
}
do
{
tmp3[tmp2]=NULL;
tmp2=tmp2+1;
}
while(tmp2<sizeof(tmp3));
tmp2=0;
tmp=chkext(tmp7, ".", 0);
strcpy(tmp3, "x=");
strcat(tmp3, tmp);
tmp=eciread("[ACCESS]", tmp3, 700, 0, 1);
if(tmp!=NULL)
{
return(43);
}
do
{
tmp3[tmp2]=NULL;
tmp5[tmp2]=NULL;
tmp6[tmp2]=NULL;
tmp2=tmp2+1;
}
while(tmp2<sizeof(tmp3));
tmp2=0;
system("cd >~qfs.tmo");
tmp4=fopen("~qfs.tmo", "r");
do
{
tmp=fgets(tmp3, 2, tmp4);
if(strcmp(tmp, "\n")==0)
{
tmp2=32767;
}
else
{
strcat(tmp6, tmp);
}
}
while(tmp2!=32767);
fclose(tmp4);
tmp2=0;
do
{
tmp3[tmp2]=NULL;
tmp2=tmp2+1;
}
while(tmp2<sizeof(tmp3));
strcat(tmp6, "\\");
strcat(tmp6, tmp7);
strcpy(tmp3, "f=");
strcat(tmp3, tmp6);
strlwr(tmp3);
tmp=eciread("[ACCESS]", tmp3, 700, 0, 1);
if(tmp!=NULL)
{
return(42);
}
return(0);
}
When I run it, it changes makes other char * variables previously defiened before main() null values, and I can't tell why. Any ideas?
..I just figured out that if I make the first do...while loop go round 672 times instead of 700 it works up til the point of the next loop... And that doesnt help me at all am i missing something blindingly obvious?