-#if FILE_READ_BUFSIZE
- int l = p->file_bufsize - p->file_offset;
-
- if (count > l)
- {
- int r;
- if (l > 0)
- memcpy (buf, p->file_buf + p->file_offset, l);
- count = count-l;
- if (count > FILE_READ_BUFSIZE)
- {
- if ((r = read (fd, buf + l, count)) == -1)
- {
- logf (LOG_FATAL|LOG_ERRNO, "read");
- exit (1);
- }
- p->file_bufsize = 0;
- p->file_offset = 0;
- p->file_noread += l+r;
- return l+r;
- }
- p->file_bufsize = r = read (fd, p->file_buf, FILE_READ_BUFSIZE);
- if (r == -1)
- {
- logf (LOG_FATAL|LOG_ERRNO, "read");
- exit (1);
- }
- else if (r <= count)
- {
- p->file_offset = r;
- memcpy (buf + l, p->file_buf, r);
- p->file_noread += l+r;
- return l+r;
- }
- else
- {
- p->file_offset = count;
- memcpy (buf + l, p->file_buf, count - l);
- p->file_noread += count;
- return count;
- }
- }
- memcpy (buf, p->file_buf + p->file_offset, count);
- p->file_offset += count;
- p->file_noread += count;
- return count;
-#else