From 813ce064f3eb5ab56b80b0560c2c06138084ccf3 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 9 Sep 2014 02:12:51 +0900 Subject: [PATCH] add port-open? --- port.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/port.c b/port.c index f53832f5..1b217873 100644 --- a/port.c +++ b/port.c @@ -206,6 +206,16 @@ pic_port_eof_object(pic_state *pic) return pic_eof_object(); } +static pic_value +pic_port_port_open_p(pic_state *pic) +{ + struct pic_port *port; + + pic_get_args(pic, "p", &port); + + return pic_bool_value(port->status == PIC_PORT_OPEN); +} + static pic_value pic_port_close_port(pic_state *pic) { @@ -665,6 +675,8 @@ pic_init_port(pic_state *pic) pic_defun(pic, "textual-port?", pic_port_textual_port_p); pic_defun(pic, "binary-port?", pic_port_binary_port_p); pic_defun(pic, "port?", pic_port_port_p); + + pic_defun(pic, "port-open?", pic_port_port_open_p); pic_defun(pic, "close-port", pic_port_close_port); /* string I/O */