;;; ----------------------------------------------------------------------
;;;
;;; ILTCPLIBRTE: Runtime for the C++ library
;;;
;;; ----------------------------------------------------------------------
;;;
;;; This file is part of ILOG Talk.
;;; Inquiries to ILOG S.A.
;;;              9 rue de Verdun, BP 85,
;;;              94253 Gentilly Cedex, France.
;;;
;;; Copyright (c) 1995-1996 by ILOG
;;; ----------------------------------------------------------------------
;;;

(defextern .ilt_ostream (<int>) ptr)
(defextern .ilt_istream (<int>) ptr)

(defun ostream (stream)
  (assert (posix-stream-p stream)
    (error 'ostream #!.errnposixstr stream))
  (let ((fd (.posix-stream-output-fd stream)))
    (assert fd
      (error 'ostream #!.cantwrite stream))
    (let ((ptr (.ilt_ostream fd)))
      (assert ptr
	(error 'ostream #!.cantcreateos stream))
      (ptr-proxy ostream* ptr))))

(defun istream (stream)
  (assert (posix-stream-p stream)
    (error 'istream #!.errnposixstr stream))
  (let ((fd (.posix-stream-input-fd stream)))
    (assert fd
      (error 'istream #!.cantread stream))
    (let ((ptr (.ilt_istream fd)))
      (assert ptr
	(error 'ostream #!.cantcreateis stream))
      (ptr-proxy istream* ptr))))

(defmessage .cantcreateos
  english: "cannot create an ostream for %A"
  french: "impossible de créer un ostream pour %A")

(defmessage .cantcreateis
  english: "cannot create an istream for %A"
  french: "impossible de créer un istream pour %A")
