1 /* fputc( int, FILE * )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
10 #include <_PDCLIB_io.h>
12 /* Write the value c (cast to unsigned char) to the given stream.
13 Returns c if successful, EOF otherwise.
14 If a write error occurs, the error indicator of the stream is set.
16 int _PDCLIB_fputc_unlocked( int c, FILE * stream )
18 if ( _PDCLIB_prepwrite( stream ) == EOF )
22 stream->buffer[stream->bufidx++] = (char)c;
23 if ( ( stream->bufidx == stream->bufsize ) /* _IOFBF */
24 || ( ( stream->status & _IOLBF ) && ( (char)c == '\n' ) ) /* _IOLBF */
25 || ( stream->status & _IONBF ) /* _IONBF */
28 /* buffer filled, unbuffered stream, or end-of-line. */
29 return ( _PDCLIB_flushbuffer( stream ) == 0 ) ? c : EOF;
34 int fputc( int c, FILE * stream )
36 _PDCLIB_flockfile( stream );
37 int r = _PDCLIB_fputc_unlocked( c, stream );
38 _PDCLIB_funlockfile( stream );
45 #include <_PDCLIB_test.h>
49 /* Testing covered by ftell.c */