28 lines
434 B
C
28 lines
434 B
C
#include "file.h"
|
|
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
|
|
int __fputc(int c, struct __opaque_file *stream)
|
|
{
|
|
if (stream->f_flags & (FILE_EOF | FILE_ERR)) {
|
|
return EOF;
|
|
}
|
|
|
|
char cv = c;
|
|
int ret = __libc_file_write(stream, &cv, 1);
|
|
if (ret < 1) {
|
|
return EOF;
|
|
}
|
|
|
|
return c;
|
|
}
|
|
|
|
int fputc(int c, struct __opaque_file *stream)
|
|
{
|
|
__libc_file_lock(stream);
|
|
int ret = __fputc(c, stream);
|
|
__libc_file_unlock(stream);
|
|
return ret;
|
|
}
|