(*
    Title: 	UnixIO - Definitions
    LastEdit:	"Mon Sep 24 13:03:21 1984"
    Author: 	Mick Jordan
		Acorn Research Centre

    Interface to the basic Unix I/O calls.
    
    These procedures match the spec in the Unix manual,
    save that an error is indicated by a negative result,
    where -result is the Unix error number.
*)

DEFINITION MODULE UnixIO;

FROM SYSTEM IMPORT WORD, ADDRESS;

EXPORT QUALIFIED 
  Creat, Open, Close, Read, Write, Lseek,
  OpenForRead, OpenForWrite, OpenForReadWrite,
  OpenNDelay, OpenAppend, OpenCreat, 
  OpenTrunc, OpenExcl;

CONST
  OpenForRead = {}; OpenForWrite = {0}; OpenForReadWrite = {1};
  OpenNDelay = {2}; OpenAppend = {3}; OpenCreat = {9}; 
  OpenTrunc = {10}; OpenExcl = {11};

PROCEDURE Close(fildes : INTEGER) : INTEGER;

PROCEDURE Creat(name : ARRAY OF CHAR; mode : BITSET) : INTEGER;

PROCEDURE Lseek(fildes : INTEGER; VAR offset : INTEGER; 
    whence : CARDINAL) : INTEGER;

PROCEDURE Open(name : ARRAY OF CHAR; flags, mode : BITSET) : INTEGER;

PROCEDURE Read(fildes : INTEGER; VAR buffer : ARRAY OF WORD; 
                 nbytes : CARDINAL) : INTEGER;

PROCEDURE Write(fildes : INTEGER; buffer: ADDRESS; 
                   nbytes : CARDINAL) : INTEGER;


END UnixIO.
