#include int feof(FILE *fp) { if(!fp->buf) return fp->eof; /* If there is read data to be accessed, the flag doesn't count */ if(fp->bufdir == __FILE_BUF_READ && fp->bufpos < fp->bufread) return 0; else return fp->eof; }