1 /* _PDCLIB_prepread( struct _PDCLIB_file_t * )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
10 #include "_PDCLIB_glue.h"
12 int _PDCLIB_prepread( struct _PDCLIB_file_t * stream )
14 if ( ( stream->bufidx > stream->bufend ) ||
15 ( stream->status & ( _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||
16 ! ( stream->status & ( _PDCLIB_FREAD | _PDCLIB_FRW ) ) )
18 /* Function called on illegal (e.g. output) stream.
19 See comments on implementation-defined errno values in
22 _PDCLIB_errno = _PDCLIB_ERROR;
23 stream->status |= _PDCLIB_ERRORFLAG;
26 stream->status |= _PDCLIB_FREAD | _PDCLIB_BYTESTREAM;
27 if ( ( stream->bufidx == stream->bufend ) && ( stream->ungetidx == 0 ) )
29 return _PDCLIB_fillbuffer( stream );
40 #include "_PDCLIB_test.h"
44 /* Testing covered by ftell.c */