Path: blob/master/waterbox/libc/functions/stdio/_PDCLIB_prepwrite.c
2 views
/* _PDCLIB_prepwrite( 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_io.h"1112int _PDCLIB_prepwrite( FILE * stream )13{14if ( ( stream->bufidx < stream->bufend ) || ( stream->ungetidx > 0 ) ||15( stream->status & ( _PDCLIB_FREAD | _PDCLIB_ERRORFLAG | _PDCLIB_WIDESTREAM | _PDCLIB_EOFFLAG ) ) ||16! ( stream->status & ( _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_FRW ) ) )17{18/* Function called on illegal (e.g. input) stream.19See the comments on implementation-defined errno values in20<_PDCLIB_config.h>.21*/22errno = EINVAL;23stream->status |= _PDCLIB_ERRORFLAG;24return EOF;25}26stream->status |= _PDCLIB_FWRITE | _PDCLIB_BYTESTREAM;27return 0;28}29#endif3031#ifdef TEST32#include "_PDCLIB_test.h"3334int main( void )35{36/* Testing covered by ftell.c */37return TEST_RESULTS;38}3940#endif41424344