3 /* fputc( int, 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.
12 #include <_PDCLIB_io.h>
14 /* Write the value c (cast to unsigned char) to the given stream.
15 Returns c if successful, EOF otherwise.
16 If a write error occurs, the error indicator of the stream is set.
18 int fputc_unlocked( int c, FILE * stream )
20 if ( _PDCLIB_prepwrite( stream ) == EOF )
24 stream->buffer[stream->bufidx++] = (char)c;
25 if ( ( stream->bufidx == stream->bufsize ) /* _IOFBF */
26 || ( ( stream->status & _IOLBF ) && ( (char)c == '\n' ) ) /* _IOLBF */
27 || ( stream->status & _IONBF ) /* _IONBF */
30 /* buffer filled, unbuffered stream, or end-of-line. */
31 return ( _PDCLIB_flushbuffer( stream ) == 0 ) ? c : EOF;
36 int fputc( int c, FILE * stream )
39 int r = fputc_unlocked( c, stream );
40 funlockfile( stream );
47 #include <_PDCLIB_test.h>
51 /* Testing covered by ftell.c */