3 /* _PDCLIB_prepread( FILE * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
13 #include <_PDCLIB_glue.h>
15 int _PDCLIB_prepread( FILE * stream )
17 if ( ( stream->bufidx > stream->bufend ) ||
18 ( stream->status & ( _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||
19 ! ( stream->status & ( _PDCLIB_FREAD | _PDCLIB_FRW ) ) )
21 /* Function called on illegal (e.g. output) stream.
22 See comments on implementation-defined errno values in
26 stream->status |= _PDCLIB_ERRORFLAG;
29 stream->status |= _PDCLIB_FREAD | _PDCLIB_BYTESTREAM;
30 if ( ( stream->bufidx == stream->bufend ) && ( stream->ungetidx == 0 ) )
32 return _PDCLIB_fillbuffer( stream );
42 #include <_PDCLIB_test.h>
46 /* Testing covered by ftell.c */