mirror of
https://github.com/drasko/codezero.git
synced 2026-01-21 15:23:15 +01:00
Initial commit
This commit is contained in:
19
libs/c/src/fputc.c
Normal file
19
libs/c/src/fputc.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fputc(int c, FILE *stream)
|
||||
{
|
||||
unsigned char ch = (unsigned char) c;
|
||||
/* This is where we should do output buffering */
|
||||
|
||||
lock_stream(stream);
|
||||
if (stream->write_fn(&ch, stream->current_pos, 1, stream->handle) == 1) {
|
||||
/* Success */
|
||||
stream->current_pos++;
|
||||
unlock_stream(stream);
|
||||
return c;
|
||||
} else {
|
||||
unlock_stream(stream);
|
||||
return EOF;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user