2000-05-28 13:40:48 +00:00
|
|
|
/*
|
|
|
|
* fputc.c
|
|
|
|
*
|
|
|
|
* Ullrich von Bassewitz, 02.06.1998
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
/*****************************************************************************/
|
|
|
|
/* Code */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int __fastcall__ fputc (int c, 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) {
|
2002-03-24 13:26:18 +00:00
|
|
|
return EOF;
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the byte (knows about byte order!) */
|
|
|
|
if (write (f->f_fd, &c, 1) <= 0) {
|
|
|
|
/* Error */
|
|
|
|
f->f_flags |= _FERROR;
|
2002-03-24 13:26:18 +00:00
|
|
|
return EOF;
|
2000-05-28 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the byte written */
|
|
|
|
return c & 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|