3 /* _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
9 /* This is an example implementation of _PDCLIB_fillbuffer() fit for
10 use with POSIX kernels.
16 #include <_PDCLIB_glue.h>
18 #include </usr/include/errno.h>
21 extern ssize_t read( int fd, void * buf, size_t count );
23 int _PDCLIB_fillbuffer( struct _PDCLIB_file_t * stream )
25 /* No need to handle buffers > INT_MAX, as PDCLib doesn't allow them */
26 ssize_t rc = read( stream->handle, stream->buffer, stream->bufsize );
29 /* Reading successful. */
30 if ( ! ( stream->status & _PDCLIB_FBIN ) )
32 /* TODO: Text stream conversion here */
34 stream->pos.offset += rc;
49 _PDCLIB_errno = _PDCLIB_EIO;
52 _PDCLIB_errno = _PDCLIB_EUNKNOWN;
55 stream->status |= _PDCLIB_ERRORFLAG;
59 stream->status |= _PDCLIB_EOFFLAG;
66 #include <_PDCLIB_test.h>
70 /* Testing covered by ftell.c */