--
--	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 hostsp

#OPTION "V"
#COMMENT "Host i/o library, V1.00, 10/03/89"
#COMMENT "(c) Copyright INMOS Limited 1989"
#COMMENT "KROC hostsp version 1996"
#INCLUDE "hostio.inc"
--{{{  sp.time
--* Retrieve the local and UTC time from the host system.
--
-- Both times are expressed as the number of seconds that have elapsed
-- since midnight on the 1st of January, 1970, and are given as
-- unsigned INT32s UTC time used to be known as Greenwich Mean Time (
-- GMT )
--
-- @param fs from server
-- @param ts to server
-- @param localtime the local time
-- @param UTCtime the Coordinated Universal Time, if available; zero if
--   not available
-- @param result spr.ok if operation successful; otherwise >=
--   spr.operation.failed - refer to hostio.inc or iserver
--   documentation for details
PROC sp.time (CHAN OF SP fs, ts, INT32 localtime, UTCtime, BYTE result)
  [10]BYTE buffer :  -- 9 needed, plus 1 to make it even
  SEQ
    --{{{  pack the data into the buffer (1 byte)
    buffer [0] := sp.time.tag
    --}}}
    --{{{  send and receive the buffer
    ts ! INT16 sp.min.packet.data.size :: buffer
    
    INT16 len :
    fs ?  len :: buffer
    --}}}send and receive the buffer
    --{{{  copy out the result           (1 or 9 bytes)
    result := buffer [0]
    
    [4]BYTE b.localtime RETYPES localtime :
    b.localtime := [buffer FROM 1 FOR 4]
    
    [4]BYTE b.UTCtime RETYPES UTCtime :
    b.UTCtime := [buffer FROM 5 FOR 4]
    --}}}copy out the result           (1 or 9 bytes)
:
--}}}sp.time
--{{{  so.time
--* Retrieve the local and UTC time from the host system.
--
-- Both times are expressed as the number of seconds that have elapsed
-- since midnight on the 1st of January, 1970, and are given as
-- unsigned INT32s UTC time used to be known as Greenwich Mean Time (
-- GMT )
--
-- @param fs from server
-- @param ts to server
-- @param localtime the local time
-- @param UTCtime the Coordinated Universal Time, if available; zero if
--   not available
PROC so.time (CHAN OF SP fs, ts, INT32 localtime, UTCtime)
  BYTE result:
  sp.time (fs, ts, localtime, UTCtime, result)
:
--}}}so.time
