;;;; ports.scm --- R6RS port API -*- coding: utf-8 -*- ;;;; Copyright (C) 2009-2011, 2013, 2019, 2023 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public ;;;; License as published by the Free Software Foundation; either ;;;; version 3 of the License, or (at your option) any later version. ;;;; ;;;; This library is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;;; Lesser General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Lesser General Public ;;;; License along with this library; if not, write to the Free Software ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;;; Author: Ludovic Courtès ;;; Commentary: ;;; ;;; The I/O port API of the R6RS is provided by this module. In many areas ;;; it complements or refines Guile's own historical port API. For instance, ;;; it allows for binary I/O with bytevectors. ;;; ;;; Code: (library (rnrs io ports (6)) (export eof-object eof-object? ;; auxiliary types file-options buffer-mode buffer-mode? eol-style native-eol-style error-handling-mode make-transcoder transcoder-codec transcoder-eol-style transcoder-error-handling-mode native-transcoder latin-1-codec utf-8-codec utf-16-codec ;; transcoding bytevectors bytevector->string string->bytevector ;; input & output ports port? input-port? output-port? port-eof? port-transcoder binary-port? textual-port? transcoded-port port-position set-port-position! port-has-port-position? port-has-set-port-position!? call-with-port close-port ;; input ports open-bytevector-input-port open-string-input-port open-file-input-port make-custom-binary-input-port make-custom-textual-input-port ;; binary input get-u8 lookahead-u8 get-bytevector-n get-bytevector-n! get-bytevector-some get-bytevector-all ;; output ports open-bytevector-output-port open-string-output-port open-file-output-port make-custom-binary-output-port call-with-bytevector-output-port call-with-string-output-port make-custom-textual-output-port output-port-buffer-mode flush-output-port ;; input/output ports open-file-input/output-port make-custom-binary-input/output-port make-custom-textual-input/output-port ;; binary output put-u8 put-bytevector ;; textual input get-char get-datum get-line get-string-all get-string-n get-string-n! lookahead-char ;; textual output put-char put-datum put-string ;; standard ports standard-input-port standard-output-port standard-error-port current-input-port current-output-port current-error-port ;; condition types &i/o i/o-error? make-i/o-error &i/o-read i/o-read-error? make-i/o-read-error &i/o-write i/o-write-error? make-i/o-write-error &i/o-invalid-position i/o-invalid-position-error? make-i/o-invalid-position-error &i/o-filename i/o-filename-error? make-i/o-filename-error i/o-error-filename &i/o-file-protection i/o-file-protection-error? make-i/o-file-protection-error &i/o-file-is-read-only i/o-file-is-read-only-error? make-i/o-file-is-read-only-error &i/o-file-already-exists i/o-file-already-exists-error? make-i/o-file-already-exists-error &i/o-file-does-not-exist i/o-file-does-not-exist-error? make-i/o-file-does-not-exist-error &i/o-port i/o-port-error? make-i/o-port-error i/o-error-port &i/o-decoding i/o-decoding-error? make-i/o-decoding-error &i/o-encoding i/o-encoding-error? make-i/o-encoding-error i/o-encoding-error-char) (import (ice-9 binary-ports) (only (ice-9 textual-ports) make-custom-textual-input-port make-custom-textual-output-port make-custom-textual-input/output-port) (only (rnrs base) assertion-violation) (only (ice-9 ports internal) port-write-buffer port-buffer-bytevector port-line-buffered?) (only (rnrs bytevectors) bytevector-length) (prefix (ice-9 iconv) iconv:) (rnrs enums) (rnrs records syntactic) (rnrs exceptions) (rnrs conditions) (rnrs files) ;for the condition types (srfi srfi-8) (ice-9 rdelim) (except (guile) raise display) (prefix (only (guile) display) guile:))