aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-23 11:04:55 +0100
committerlemon <lsof@mailbox.org>2026-03-23 11:04:55 +0100
commit24dafc4cd691c3ec121176dbcd56e78ac6e175b7 (patch)
tree344a2cc63ccce471173c549843eab4505f9ac8a6
parent14b4fd3b6a8ca34fa6c1b96b008d1a57c3074028 (diff)
io: use FILE* for buf fp impl
-rw-r--r--src/antcc.h2
-rw-r--r--src/u_io.c16
2 files changed, 10 insertions, 8 deletions
diff --git a/src/antcc.h b/src/antcc.h
index 976b766..fcaf02a 100644
--- a/src/antcc.h
+++ b/src/antcc.h
@@ -305,7 +305,7 @@ typedef struct WriteBuf {
uint len;
int fd;
};
- void *fp;
+ void *_fp;
};
bool err;
bool isfp;
diff --git a/src/u_io.c b/src/u_io.c
index 7506b12..f376c98 100644
--- a/src/u_io.c
+++ b/src/u_io.c
@@ -15,20 +15,22 @@ WriteBuf bstdout, bstderr;
void
ioinit(void)
{
- bstdout.fp = stdout;
+ bstdout._fp = stdout;
bstdout.isfp = 1;
- bstderr.fp = stderr;
+ bstderr._fp = stderr;
bstderr.isfp = 1;
}
+#define b_fp(b) ((FILE *)(b)->_fp)
+
void
iowrite(WriteBuf *buf, const void *Src, int n)
{
const uchar *src = Src;
if (buf->isfp) {
- fwrite(Src, 1, n, buf->fp);
- buf->err = ferror(buf->fp) != 0;
+ fwrite(Src, 1, n, b_fp(buf));
+ buf->err = ferror(b_fp(buf)) != 0;
return;
}
while (n > 0) {
@@ -55,8 +57,8 @@ ioflush(WriteBuf *buf)
int i, ret;
if (buf->isfp) {
- fflush(buf->fp);
- buf->err = ferror(buf->fp) != 0;
+ fflush(b_fp(buf));
+ buf->err = ferror(b_fp(buf)) != 0;
return;
}
buf->err = 0;
@@ -83,7 +85,7 @@ void
ioputc(WriteBuf *buf, uchar c)
{
if (buf->isfp) {
- buf->err = fputc(c, buf->fp) != EOF;
+ buf->err = fputc(c, b_fp(buf)) != EOF;
return;
}
if (buf->len == buf->cap) {