Here is the entire function that fille the allMenus struct, this should tell you what data is being put in :
void menuCfgParser()
{
FILE *menuFile ;
char *readIn ;
struct stat menuCfgStat ;
char *lToken = malloc(512) ;
int i = 0 ;
char *fLines[8192] ;
int noMenus = 0;
int noKeys = 0 ;
char *toArray ;
char *tempString = malloc(128) ;
menuFile = fopen(mainBbsInfo.menufile, "r") ;
memset(&menuCfgStat,0,sizeof (struct stat));
if((fstat(fileno(menuFile), &menuCfgStat)) == -1)
{
if(debug) perror("fstat() in menuCfgParser() returned -1") ;
}
readIn = malloc(menuCfgStat.st_size);
fread(readIn, menuCfgStat.st_size, 1, menuFile) ;
fclose(menuFile) ;
lToken = strtok(readIn, "\r\n") ;
i = 0 ;
while(lToken != NULL)
{
toArray = trimLeadingWS(lToken) ;
if((toArray[0] != '#') && (strlen(toArray) != 0))
{
fLines = malloc(strlen(toArray)) ;
fLines = toArray ;
lToken = strtok(NULL, "\r\n") ;
i++ ;
}
else
{
lToken = strtok(NULL, "\r\n") ;
}
}
i = 0 ;
while(fLines != NULL)
{
lToken = strtok(fLines, " ") ;
if(strcmp(lToken, "MENU") == 0)
{
lToken = strtok(NULL, "\r\n") ;
allMenus[noMenus].identifier = lToken ;
noMenus++ ;
printf("noMenus : %i\nMenu Identifier : %s\n", noMenus , allMenus[noMenus].identifier) ;
i++ ;
if(strcmp(fLines, "{") != 0)
{
printf("Error parsing menu config file after MENU %s\n", lToken) ;
exit(0) ;
}
else
{
i++ ;
}
while(strcmp(fLines, "}") != 0)
{
lToken = strtok(fLines, " ") ;
if(strcasecmp(lToken, "MENU_NAME") == 0)
{
lToken = strtok(NULL, "\"") ;
allMenus[noMenus].name = lToken ;
if(debug) printf("Menu Name : %s\n", allMenus[noMenus].name) ;
}
else if(strcasecmp(lToken, "MENU_FILE_ANS") == 0)
{
lToken = strtok(NULL, "\r\n") ;
allMenus[noMenus].ansfile = lToken ;
if(debug) printf("Menu ANSI File : %s\n", allMenus[noMenus].ansfile) ;
}
else if(strcasecmp(lToken, "MENU_FILE_ASC") == 0)
{
lToken = strtok(NULL, "\r\n") ;
allMenus[noMenus].ascfile = lToken ;
if(debug) printf("Menu ASCII File : %s\n", allMenus[noMenus].ascfile) ;
}
else if(strcasecmp(lToken, "KEY") == 0)
{
lToken = strtok(NULL, " ") ;
strcpy(tempString, lToken) ;
lToken = strtok(NULL, "\r\n") ;
strcat(tempString, lToken) ;
allMenus[noMenus].keys[noKeys] = tempString ;
if(debug) printf("Menus key binding set : %s\n", allMenus[noMenus].keys[noKeys]) ;
noKeys++ ;
}
i++ ;
}
}
i++ ;
}
}
Here is the function that is failing at the while(blah)
char *getFNFromIden(char *ident)
{
int i = 0 ;
printf("identifier %s\n", allMenus.identifier) ;
while(allMenus.identifier[0] != '\0')
{
printf("going through the loop again") ;
i++ ;
}
}
This function does not print out "going through the loop again" at all so the loop is obviously not being entered
and this is how the function is being called
getFNFromIden(mainBbsInfo.initmenu) ;
mainBbsInfo.initmenu is "main.ans" but this is pretty much irrelevant i think as it does not get used yet
Thanks again
Matt