3 /* _PDCLIB_prepread( struct _PDCLIB_file_t * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
11 #define _PDCLIB_GLUE_H _PDCLIB_GLUE_H
12 #include <_PDCLIB_glue.h>
14 int _PDCLIB_prepread( struct _PDCLIB_file_t * stream )
16 if ( ( stream->bufidx > stream->bufend ) ||
17 ( stream->status & ( _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||
18 ! ( stream->status & ( _PDCLIB_FREAD | _PDCLIB_FRW ) ) )
20 _PDCLIB_errno = _PDCLIB_EIO;
21 stream->status |= _PDCLIB_ERRORFLAG;
24 stream->status |= _PDCLIB_FREAD | _PDCLIB_BYTESTREAM;
25 if ( ( stream->bufidx == stream->bufend ) && ( stream->ungetidx == 0 ) )
27 return _PDCLIB_fillbuffer( stream );