Path: blob/master/waterbox/libc/functions/stdio/_PDCLIB_prepread.c
2 views
/* _PDCLIB_prepread( FILE * )12This file is part of the Public Domain C Library (PDCLib).3Permission is granted to use, modify, and / or redistribute at will.4*/56#include <stdio.h>7#include <errno.h>89#ifndef REGTEST10#include "_PDCLIB_glue.h"1112int _PDCLIB_prepread( FILE * stream )13{14if ( ( stream->bufidx > stream->bufend ) ||15( stream->status & ( _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||16! ( stream->status & ( _PDCLIB_FREAD | _PDCLIB_FRW ) ) )17{18/* Function called on illegal (e.g. output) stream.19See comments on implementation-defined errno values in20<_PDCLIB_config.h>.21*/22errno = EINVAL;23stream->status |= _PDCLIB_ERRORFLAG;24return EOF;25}26stream->status |= _PDCLIB_FREAD | _PDCLIB_BYTESTREAM;27if ( ( stream->bufidx == stream->bufend ) && ( stream->ungetidx == 0 ) )28{29return _PDCLIB_fillbuffer( stream );30}31else32{33return 0;34}35}36#endif3738#ifdef TEST39#include "_PDCLIB_test.h"4041int main( void )42{43/* Testing covered by ftell.c */44return TEST_RESULTS;45}4647#endif48495051