]> git.sur5r.net Git - cc65/blob - libsrc/common/fputc.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / common / fputc.c
1 /*
2  * fputc.c
3  *
4  * Ullrich von Bassewitz, 02.06.1998
5  */
6
7
8
9 #include <stdio.h>
10 #include <unistd.h>
11 #include "_file.h"
12
13
14
15 /*****************************************************************************/
16 /*                                   Code                                    */
17 /*****************************************************************************/
18
19
20
21 int __fastcall__ fputc (int c, register FILE* f)
22 {
23     /* Check if the file is open or if there is an error condition */
24     if ((f->f_flags & _FOPEN) == 0 || (f->f_flags & (_FERROR | _FEOF)) != 0) {
25         goto ReturnEOF;
26     }
27
28     /* Write the byte */
29     if (write (f->f_fd, &c, 1) != 1) {
30         /* Error */
31         f->f_flags |= _FERROR;
32 ReturnEOF:
33         return EOF;
34     }
35
36     /* Return the byte written */
37     return c & 0xFF;
38 }
39
40
41