the function is really long so i will give you the highlights:
this is the main loop:
do
{
if((ssBytesRead=read(fp,input,BUFFER_SIZE)))
{
...
fp=lseek(fp,-1*total_read,SEEK_CUR);
...
here i call the second function with the duplicate fp:
get_token_value(dup(fp));
}
}while(ssBytesRead!=0);
the get_token value function reads the text the same way the main loop does (using the read function) and at the end just before return it moves the fp one step back (using lseek).
After that the file pointer in the main loop won't move even as a result of read.