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;
44 /* See comments on implementation-defined errno values in
52 _PDCLIB_errno = _PDCLIB_ERROR;
55 /* This should be something like EUNKNOWN. */
56 _PDCLIB_errno = _PDCLIB_ERROR;
59 stream->status |= _PDCLIB_ERRORFLAG;
63 stream->status |= _PDCLIB_EOFFLAG;
70 #include <_PDCLIB_test.h>
74 /* Testing covered by ftell.c */