Hi guys,
I have a problem the my program works in one file and does not work in between files. Can some one throw some light on it.
ifd= open("server.cfg",O_RDONLY);
while((retin = read(ifd,&str,650)) > 0 )
{
printf("String is = %s",str);
pch = strtok (str," \n");
while (pch != NULL)
{
printf ("IN:%s\n",pch);
pch = strtok(NULL," =\n");
if ( pch[0] == 'E') break;
printf("pch =%s",pch);
if ( pch[0] != '[')
add_to_list(pch,true);
}
}
close(ifd);
struct data_struct *head = NULL;
struct data_struct *ptr = head;
ptr = search_in_list("clientip", NULL);
if ( ptr != NULL)
{
printf("\nClientIp:%s\n",ptr->val);
ip = ptr->val;
}
else
{
printf("Can't Find ClientIp to connect\n");
}
Above code works when put in same file.
But when I put above code of adding in link list in file and searching in other file this does not work and search list function fails to return any values.
Any idea why so ??????
I have 2 files : server.c and comfunc.c
when i put my whole code in any single file it works fine but when i divide my code in say
addlist in comfunc.c and
searchlist in server.c
it does not work.
values from searchlist are not returned properly. it returns NULL pointer.
but when in same file search completes fine and returns the searched value.