Add cfw_std{in,out,err}.
This commit is contained in:
parent
f9d9a2a9a8
commit
a9f9734ea7
2 changed files with 42 additions and 0 deletions
38
src/file.c
38
src/file.c
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -171,3 +172,40 @@ static CFWClass class = {
|
||||||
.dtor = dtor
|
.dtor = dtor
|
||||||
};
|
};
|
||||||
CFWClass *cfw_file = &class;
|
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_;
|
||||||
|
|
|
@ -33,4 +33,8 @@ typedef struct CFWFile CFWFile;
|
||||||
|
|
||||||
extern CFWClass *cfw_file;
|
extern CFWClass *cfw_file;
|
||||||
|
|
||||||
|
extern CFWFile *cfw_stdin;
|
||||||
|
extern CFWFile *cfw_stdout;
|
||||||
|
extern CFWFile *cfw_stderr;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue