--
--	Inmos Libraries
--	Copyright (C) 1988, 1989, 1990, 1991, 1993  Inmos Limited
--
--	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 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
--

--** @module streamio

#OPTION "E"  -- no compliler libs
#COMMENT "Stream i/o library, V1.1, 14/06/90"
#COMMENT "(c) Copyright INMOS Limited, 1988"
#INCLUDE "streamio.inc"
--* Copy everything received on the given screen stream input channel
-- to both of the given screen stream output channels.
--
-- Receipt of st.endstream on scrn will terminate this procedure,
-- without sending the stream terminator on.
--
-- @param scrn for input
-- @param screen.out1 for output
-- @param screen.out2 for output
PROC ss.scrstream.fan.out (CHAN OF SS scrn, screen.out1, screen.out2)
  --{{{  history
  -- Introduced the tags st.help and st.initialise into the CASE
  -- input. New version is 1.1 ( old version was 0.01, 23-Dec-88 )
  -- 14-June-90 SRH
  --}}}

  BOOL going:
  SEQ
    going := TRUE
    WHILE going
      SEQ
        scrn ? CASE
          [st.max.string.size]BYTE buffer:
          INT32 len:
          st.out.string; len::buffer
            SEQ
              screen.out1 ! st.out.string; len :: buffer
              screen.out2 ! st.out.string; len :: buffer
          BYTE st.char :
          st.out.byte; st.char
            SEQ
              screen.out1 ! st.out.byte; st.char
              screen.out2 ! st.out.byte; st.char
          BYTE st.char :
          st.ins.char; st.char
            SEQ
              screen.out1 ! st.ins.char; st.char
              screen.out2 ! st.ins.char; st.char
          INT32 x :
          st.out.int; x
            SEQ
              screen.out1 ! st.out.int; x
              screen.out2 ! st.out.int; x
          INT32 x,y:
          st.goto; x; y
            SEQ
              screen.out1 ! st.goto; x; y
              screen.out2 ! st.goto; x; y
          st.reset
            SEQ
              screen.out1 ! st.reset
              screen.out2 ! st.reset
          st.up
            SEQ
              screen.out1 ! st.up
              screen.out2 ! st.up
          st.down
            SEQ
              screen.out1 ! st.down
              screen.out2 ! st.down
          st.left
            SEQ
              screen.out1 ! st.left
              screen.out2 ! st.left
          st.right
            SEQ
              screen.out1 ! st.right
              screen.out2 ! st.right
          st.del.char
            SEQ
              screen.out1 ! st.del.char
              screen.out2 ! st.del.char
          st.clear.eol
            SEQ
              screen.out1 ! st.clear.eol
              screen.out2 ! st.clear.eol
          st.clear.eos
            SEQ
              screen.out1 ! st.clear.eos
              screen.out2 ! st.clear.eos
          st.ins.line
            SEQ
              screen.out1 ! st.ins.line
              screen.out2 ! st.ins.line
          st.del.line
            SEQ
              screen.out1 ! st.del.line
              screen.out2 ! st.del.line
          st.beep
            SEQ
              screen.out1 ! st.beep
              screen.out2 ! st.beep
          st.terminate
            SEQ
              screen.out1 ! st.terminate
              screen.out2 ! st.terminate
          st.help
            SEQ
              screen.out1 ! st.help
              screen.out2 ! st.help
          st.initialise
            SEQ
              screen.out1 ! st.initialise
              screen.out2 ! st.initialise
          st.key.raw
            SEQ
              screen.out1 ! st.key.raw
              screen.out2 ! st.key.raw
          st.key.cooked
            SEQ
              screen.out1 ! st.key.cooked
              screen.out2 ! st.key.cooked
          st.release
            SEQ
              screen.out1 ! st.release
              screen.out2 ! st.release
          st.claim
            SEQ
              screen.out1 ! st.claim
              screen.out2 ! st.claim
          st.endstream
            going := FALSE
          -- if st.spare is received then something is wrong => STOP
:
