From d4ce5e71516c9420f0b7af99b702f59828e517f7 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 13 May 1996 23:59:34 +0000 Subject: [PATCH] Define new operations: CLOSE-INPUT, CLOSE-OUTPUT, INPUT-OPEN?, OUTPUT-OPEN?, and WRITE-CHARS. --- v7/src/runtime/fileio.scm | 9 +++++++-- v7/src/runtime/genio.scm | 32 ++++++++++++++++++++++++++++---- v7/src/runtime/ttyio.scm | 6 ++++-- v8/src/runtime/runtime.pkg | 10 +++++++++- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/v7/src/runtime/fileio.scm b/v7/src/runtime/fileio.scm index 4f894f10b..23f5dcff0 100644 --- a/v7/src/runtime/fileio.scm +++ b/v7/src/runtime/fileio.scm @@ -1,8 +1,8 @@ #| -*-Scheme-*- -$Id: fileio.scm,v 1.9 1995/01/31 19:34:39 cph Exp $ +$Id: fileio.scm,v 1.10 1996/05/13 23:59:22 cph Exp $ -Copyright (c) 1991-95 Massachusetts Institute of Technology +Copyright (c) 1991-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -42,12 +42,14 @@ MIT in each case. |# `((BUFFERED-INPUT-CHARS ,operation/buffered-input-chars) (CHAR-READY? ,operation/char-ready?) (CHARS-REMAINING ,operation/chars-remaining) + (CLOSE-INPUT ,operation/close-input) (DISCARD-CHAR ,operation/discard-char) (DISCARD-CHARS ,operation/discard-chars) (EOF? ,operation/eof?) (INPUT-BLOCKING-MODE ,operation/input-blocking-mode) (INPUT-BUFFER-SIZE ,operation/input-buffer-size) (INPUT-CHANNEL ,operation/input-channel) + (INPUT-OPEN? ,operation/input-open?) (INPUT-TERMINAL-MODE ,operation/input-terminal-mode) (LENGTH ,operation/length) (PEEK-CHAR ,operation/peek-char) @@ -61,15 +63,18 @@ MIT in each case. |# (SET-INPUT-TERMINAL-MODE ,operation/set-input-terminal-mode))) (output-operations `((BUFFERED-OUTPUT-CHARS ,operation/buffered-output-chars) + (CLOSE-OUTPUT ,operation/close-output) (FLUSH-OUTPUT ,operation/flush-output) (OUTPUT-BLOCKING-MODE ,operation/output-blocking-mode) (OUTPUT-BUFFER-SIZE ,operation/output-buffer-size) (OUTPUT-CHANNEL ,operation/output-channel) + (OUTPUT-OPEN? ,operation/output-open?) (OUTPUT-TERMINAL-MODE ,operation/output-terminal-mode) (SET-OUTPUT-BLOCKING-MODE ,operation/set-output-blocking-mode) (SET-OUTPUT-BUFFER-SIZE ,operation/set-output-buffer-size) (SET-OUTPUT-TERMINAL-MODE ,operation/set-output-terminal-mode) (WRITE-CHAR ,operation/write-char) + (WRITE-CHARS ,operation/write-chars) (WRITE-STRING ,operation/write-string) (WRITE-SUBSTRING ,operation/write-substring))) (other-operations diff --git a/v7/src/runtime/genio.scm b/v7/src/runtime/genio.scm index fda9c373f..b5e0758f3 100644 --- a/v7/src/runtime/genio.scm +++ b/v7/src/runtime/genio.scm @@ -1,8 +1,8 @@ #| -*-Scheme-*- -$Id: genio.scm,v 1.6 1995/09/13 19:56:13 cph Exp $ +$Id: genio.scm,v 1.7 1996/05/13 23:59:15 cph Exp $ -Copyright (c) 1991-95 Massachusetts Institute of Technology +Copyright (c) 1991-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -42,12 +42,14 @@ MIT in each case. |# `((BUFFERED-INPUT-CHARS ,operation/buffered-input-chars) (CHAR-READY? ,operation/char-ready?) (CHARS-REMAINING ,operation/chars-remaining) + (CLOSE-INPUT ,operation/close-input) (DISCARD-CHAR ,operation/discard-char) (DISCARD-CHARS ,operation/discard-chars) (EOF? ,operation/eof?) (INPUT-BLOCKING-MODE ,operation/input-blocking-mode) (INPUT-BUFFER-SIZE ,operation/input-buffer-size) (INPUT-CHANNEL ,operation/input-channel) + (INPUT-OPEN? ,operation/input-open?) (INPUT-TERMINAL-MODE ,operation/input-terminal-mode) (PEEK-CHAR ,operation/peek-char) (READ-CHAR ,operation/read-char) @@ -59,15 +61,18 @@ MIT in each case. |# (SET-INPUT-TERMINAL-MODE ,operation/set-input-terminal-mode))) (output-operations `((BUFFERED-OUTPUT-CHARS ,operation/buffered-output-chars) + (CLOSE-OUTPUT ,operation/close-output) (FLUSH-OUTPUT ,operation/flush-output) (OUTPUT-BLOCKING-MODE ,operation/output-blocking-mode) (OUTPUT-BUFFER-SIZE ,operation/output-buffer-size) (OUTPUT-CHANNEL ,operation/output-channel) + (OUTPUT-OPEN? ,operation/output-open?) (OUTPUT-TERMINAL-MODE ,operation/output-terminal-mode) (SET-OUTPUT-BLOCKING-MODE ,operation/set-output-blocking-mode) (SET-OUTPUT-BUFFER-SIZE ,operation/set-output-buffer-size) (SET-OUTPUT-TERMINAL-MODE ,operation/set-output-terminal-mode) (WRITE-CHAR ,operation/write-char) + (WRITE-CHARS ,operation/write-chars) (WRITE-STRING ,operation/write-string) (WRITE-SUBSTRING ,operation/write-substring))) (other-operations @@ -247,6 +252,9 @@ MIT in each case. |# (output-buffer/write-substring-block (port/output-buffer port) string start end)) +(define (operation/write-chars port string start end) + (output-buffer/write-substring (port/output-buffer port) string start end)) + (define (operation/output-buffer-size port) (output-buffer/size (port/output-buffer port))) @@ -287,9 +295,25 @@ MIT in each case. |# ;; Must close output-buffer first, because it may need to flush ;; buffered data, and there might only be one channel for both the ;; input and output buffers. + (operation/close-output port) + (operation/close-input port)) + +(define (operation/close-output port) (let ((output-buffer (port/output-buffer port))) (if output-buffer - (output-buffer/close output-buffer))) + (output-buffer/close output-buffer)))) + +(define (operation/close-input port) (let ((input-buffer (port/input-buffer port))) (if input-buffer - (input-buffer/close input-buffer)))) \ No newline at end of file + (input-buffer/close input-buffer)))) + +(define (operation/output-open? port) + (let ((output-buffer (port/output-buffer port))) + (and output-buffer + (channel-open? (output-buffer/channel output-buffer))))) + +(define (operation/input-open? port) + (let ((input-buffer (port/input-buffer port))) + (and input-buffer + (channel-open? (input-buffer/channel input-buffer))))) \ No newline at end of file diff --git a/v7/src/runtime/ttyio.scm b/v7/src/runtime/ttyio.scm index 80856ee75..1f3136a2b 100644 --- a/v7/src/runtime/ttyio.scm +++ b/v7/src/runtime/ttyio.scm @@ -1,8 +1,8 @@ #| -*-Scheme-*- -$Id: ttyio.scm,v 1.4 1993/10/21 14:52:43 cph Exp $ +$Id: ttyio.scm,v 1.5 1996/05/13 23:59:27 cph Exp $ -Copyright (c) 1991-93 Massachusetts Institute of Technology +Copyright (c) 1991-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -58,10 +58,12 @@ MIT in each case. |# (INPUT-BLOCKING-MODE ,operation/input-blocking-mode) (INPUT-BUFFER-SIZE ,operation/input-buffer-size) (INPUT-CHANNEL ,operation/input-channel) + (INPUT-OPEN? ,operation/input-open?) (INPUT-TERMINAL-MODE ,operation/input-terminal-mode) (OUTPUT-BLOCKING-MODE ,operation/output-blocking-mode) (OUTPUT-BUFFER-SIZE ,operation/output-buffer-size) (OUTPUT-CHANNEL ,operation/output-channel) + (OUTPUT-OPEN? ,operation/output-open?) (OUTPUT-TERMINAL-MODE ,operation/output-terminal-mode) (PEEK-CHAR ,(lambda (port) (hook/peek-char port))) (WRITE-SELF ,operation/write-self) diff --git a/v8/src/runtime/runtime.pkg b/v8/src/runtime/runtime.pkg index d7f13994f..5fb29bf67 100644 --- a/v8/src/runtime/runtime.pkg +++ b/v8/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: runtime.pkg,v 14.270 1996/04/24 04:17:17 cph Exp $ +$Id: runtime.pkg,v 14.271 1996/05/13 23:59:34 cph Exp $ Copyright (c) 1988-96 Massachusetts Institute of Technology @@ -814,10 +814,12 @@ MIT in each case. |# operation/input-blocking-mode operation/input-buffer-size operation/input-channel + operation/input-open? operation/input-terminal-mode operation/output-blocking-mode operation/output-buffer-size operation/output-channel + operation/output-open? operation/output-terminal-mode operation/set-input-blocking-mode operation/set-input-buffer-size @@ -831,6 +833,8 @@ MIT in each case. |# operation/char-ready? operation/chars-remaining operation/close + operation/close-input + operation/close-output operation/discard-char operation/discard-chars operation/eof? @@ -838,10 +842,12 @@ MIT in each case. |# operation/input-blocking-mode operation/input-buffer-size operation/input-channel + operation/input-open? operation/input-terminal-mode operation/output-blocking-mode operation/output-buffer-size operation/output-channel + operation/output-open? operation/output-terminal-mode operation/peek-char operation/read-char @@ -855,6 +861,7 @@ MIT in each case. |# operation/set-output-buffer-size operation/set-output-terminal-mode operation/write-char + operation/write-chars operation/write-string operation/write-substring) (initialization (initialize-package!))) @@ -1745,6 +1752,7 @@ MIT in each case. |# output-buffer/size output-buffer/write-char-block output-buffer/write-string-block + output-buffer/write-substring output-buffer/write-substring-block set-channel-port!) (export (runtime file-i/o-port) -- 2.25.1