fputc.c - vx32 - Local 9vx git repository for patches.
(HTM) git clone git://r-36.net/vx32
(DIR) Log
(DIR) Files
(DIR) Refs
---
fputc.c (501B)
---
1
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <errno.h>
6
7 #include "ioprivate.h"
8
9 int fputc(int c, FILE *f)
10 {
11 c &= 0xff;
12
13 // Make sure we have output buffer space for one character.
14 if (f->opos >= f->omax) {
15 if (__getospace(f) < 0)
16 return EOF;
17 }
18
19 // Add the character to the buffer
20 f->obuf[f->opos++] = c;
21
22 // Flush the buffer if appropriate.
23 if ((f->bufmode == _IOLBF && c == '\n') || (f->bufmode == _IONBF)) {
24 if (fflush(f) < 0)
25 return EOF;
26 }
27
28 return c;
29 }
30