From a9f9734ea78a618900f1bbf7c1eca9cf83c0cb79 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sun, 30 Sep 2012 00:50:49 +0200 Subject: [PATCH] Add cfw_std{in,out,err}. --- src/file.c | 38 ++++++++++++++++++++++++++++++++++++++ src/file.h | 4 ++++ 2 files changed, 42 insertions(+) diff --git a/src/file.c b/src/file.c index 76e2075..5c21eb2 100644 --- a/src/file.c +++ b/src/file.c @@ -25,6 +25,7 @@ */ #include +#include #include #include @@ -171,3 +172,40 @@ static CFWClass class = { .dtor = dtor }; CFWClass *cfw_file = &class; + +static CFWFile cfw_stdin_ = { + .stream = { + .obj = { + .cls = &class, + .ref_cnt = INT_MAX + }, + .ops = &stream_ops + }, + .fd = 0, + .eof = false +}; +static CFWFile cfw_stdout_ = { + .stream = { + .obj = { + .cls = &class, + .ref_cnt = INT_MAX + }, + .ops = &stream_ops + }, + .fd = 1, + .eof = false +}; +static CFWFile cfw_stderr_ = { + .stream = { + .obj = { + .cls = &class, + .ref_cnt = INT_MAX + }, + .ops = &stream_ops + }, + .fd = 2, + .eof = false +}; +CFWFile *cfw_stdin = &cfw_stdin_; +CFWFile *cfw_stdout = &cfw_stdout_; +CFWFile *cfw_stderr = &cfw_stderr_; diff --git a/src/file.h b/src/file.h index 8208e50..d62c2b4 100644 --- a/src/file.h +++ b/src/file.h @@ -33,4 +33,8 @@ typedef struct CFWFile CFWFile; extern CFWClass *cfw_file; +extern CFWFile *cfw_stdin; +extern CFWFile *cfw_stdout; +extern CFWFile *cfw_stderr; + #endif