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

#COMMENT "Host i/o library, V1.1, 13/05/90"
#COMMENT "(c) Copyright INMOS Limited 1989"
#PRAGMA EXTERNAL "PROC C.fseek (INT result, VAL INT32 handle, VAL INT32 origin, VAL INT32 position)  = 0 "
#INCLUDE "hostio.inc"
--{{{  sp.seek
--* Set the file position for the specified stream.
--
-- @param fs from server
-- @param ts to server
-- @param streamid the identification number of the open stream
--   associated with the file the position of which is to be set
-- @param offset the offset from origin of the new position for reading
--   or writing.  For a binary file the new position will be offset
--   bytes, perhaps negative, from the position defined by origin. For
--   a text file offset must be zero or a value returned by so.tell; in
--   the latter case origin must be spo.start, and offset greater than
--   or equal to zero.
-- @param origin one of spo.start    the start of the file spo.current
--   the current position in the file spo.end      the end of the file
-- @param result equal to spr.ok if the file position was successfully
--   set; otherwise takes on a value indicating what the problem was:
--   spr.bad.origin        invalid origin >=spr.operation.failed  the
--   seek failed - see hostio.inc or iserver documentation for further
--   details
PROC sp.seek (CHAN OF SP fs, ts, VAL INT32 streamid, offset, origin, BYTE result)
  IF
    (origin <> spo.start) AND (origin <> spo.current) AND (origin <> spo.end)
      result := spr.bad.origin
    TRUE
      VAL UnixMoveMethod IS origin - 1(INT32):
      INT res:
      SEQ
        C.fseek (res, streamid, UnixMoveMethod, offset) -- corrected 8.8.97 MDP
        IF
          res = 0
            result := spr.ok
          TRUE
            result := spr.operation.failed
:
--}}}  sp.seek
--{{{  so.seek
PROC so.seek (CHAN OF SP fs, ts, VAL INT32 streamid, offset, origin, BYTE result)

  sp.seek (fs, ts, streamid, offset, origin, result)
:
--}}}  so.seek
