diff --git a/include/picrin/port.h b/include/picrin/port.h index b02c173d..0340b3a3 100644 --- a/include/picrin/port.h +++ b/include/picrin/port.h @@ -27,4 +27,8 @@ struct pic_port { pic_value pic_eof_object(); +struct pic_port *pic_stdin(pic_state *); +struct pic_port *pic_stdout(pic_state *); +struct pic_port *pic_stderr(pic_state *); + #endif diff --git a/src/port.c b/src/port.c index 4a73d3ad..cfe6b1bc 100644 --- a/src/port.c +++ b/src/port.c @@ -17,6 +17,16 @@ pic_eof_object() return v; } +struct pic_port * +pic_stdin(pic_state *pic) +{ + struct pic_proc *proc; + + proc = pic_proc_ptr(pic_ref(pic, "current-input-port")); + + return pic_port_ptr(pic_apply(pic, proc, pic_nil_value())); +} + static void write_pair(pic_state *pic, struct pic_pair *pair); static void write_str(pic_state *pic, struct pic_string *str);