- off_t cur_offset = (*p->tellf)(p->fh);
- if (cur_offset <= 27)
- return NULL;
- if (p->endf)
- (*p->endf)(p->fh, cur_offset - 1);
+ if (record_length > sizeof(buf)-2)
+ break;
+ read_bytes = p->stream->readf(p->stream, buf+record_length, 1);
+ if (read_bytes != 1)
+ break;
+ record_length++;
+ }
+ /* read one byte ahead to see if there is more ... */
+ read_bytes = p->stream->readf(p->stream, buf+record_length, 1);
+ if (read_bytes == 1)
+ {
+ off_t cur_offset = p->stream->tellf(p->stream);
+ if (p->stream->endf)
+ {
+ off_t end_offset = cur_offset - 1;
+ p->stream->endf(p->stream, &end_offset);
+ }