2000-05-28 13:40:48 +00:00
|
|
|
/*
|
2014-06-30 09:10:35 +00:00
|
|
|
** fputc.c
|
|
|
|
**
|
|
|
|
** Ullrich von Bassewitz, 02.06.1998
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2003-06-12 18:08:23 +00:00
|
|
|
#include <unistd.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#include "_file.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-11-06 18:04:07 +00:00
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Code */
|
2003-11-06 18:04:07 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-10 18:32:38 +00:00
|
|
|
int __fastcall__ fputc (int c, register FILE* f)
|
2000-05-28 13:40:48 +00:00
|
|
|
{
|
|
|
|
/* Check if the file is open or if there is an error condition */
|
|
|
|
if ((f->f_flags & _FOPEN) == 0 || (f->f_flags & (_FERROR | _FEOF)) != 0) {
|
2013-05-09 11:56:54 +00:00
|
|
|
goto ReturnEOF;
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
2012-06-10 18:32:38 +00:00
|
|
|
/* Write the byte */
|
|
|
|
if (write (f->f_fd, &c, 1) != 1) {
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Error */
|
|
|
|
f->f_flags |= _FERROR;
|
2012-06-10 18:32:38 +00:00
|
|
|
ReturnEOF:
|
2013-05-09 11:56:54 +00:00
|
|
|
return EOF;
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the byte written */
|
|
|
|
return c & 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|