Define new operations: CLOSE-INPUT, CLOSE-OUTPUT, INPUT-OPEN?,
authorChris Hanson <org/chris-hanson/cph>
Mon, 13 May 1996 23:59:34 +0000 (23:59 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 13 May 1996 23:59:34 +0000 (23:59 +0000)
OUTPUT-OPEN?, and WRITE-CHARS.

v7/src/runtime/fileio.scm
v7/src/runtime/genio.scm
v7/src/runtime/ttyio.scm
v8/src/runtime/runtime.pkg

index 4f894f10bfb9f0f031a092015038d7feae888d4b..23f5dcff00e0f123a74cef95a52b7b504a57c1aa 100644 (file)
@@ -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
index fda9c373fcd08b1713521cedca440569ea2ac4fa..b5e0758f3df6fc29c3838c6b8b5f8455a9ef4e24 100644 (file)
@@ -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
index 80856ee75eb9beafd698d571a279bf330d3876c1..1f3136a2bad15f4c118071ded2ab08a49629cb08 100644 (file)
@@ -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)
index d7f13994fc42d8041d6daf617aee2bb72f6b243f..5fb29bf6742994f07112bdcd3dc5cb1d900d3581 100644 (file)
@@ -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)