(*
    Title: 	Unix system calls (File handling) - Definitions
    LastEdit:	"Wed Mar 28 17:18:09 1984"
    Author: 	Mick Jordan
		Cambridge University Computer Laboratory

    BSD.4.2 variant
*)

DEFINITION MODULE SysFiles;

FROM SYSTEM IMPORT WORD;
FROM SYSTEMTYPES IMPORT SHORTCARDINAL, LONGCARDINAL;

EXPORT QUALIFIED  
    SysChmod, SysClose, SysCreat,
    SysDup, SysDup2,  SysFstat, SysStat,
    SysLink, SysLseek, SysOpen,  SysRead,
    SysUnlink,  SysWrite, SysUmask, SysWriteV,
    (* assoc types  *) STATBUF;

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

PROCEDURE SysClose(fildes : INTEGER) : INTEGER;

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

PROCEDURE SysDup(fildes : INTEGER) : INTEGER;

PROCEDURE SysDup2(fildes, fildes2 : INTEGER) : INTEGER;

TYPE
    STATBUF = RECORD
		dev   : SHORTCARDINAL;
		ino   : SHORTCARDINAL;
		mode  : BITSET;
		nlink : SHORTCARDINAL;
		uid   : SHORTCARDINAL;
		gid   : SHORTCARDINAL;
		rdev  : SHORTCARDINAL;
		size  : LONGCARDINAL;
		atime : LONGCARDINAL;
		mtime : LONGCARDINAL;
		ctime : LONGCARDINAL;
                blksize: LONGCARDINAL;
                blocks: LONGCARDINAL;
	      END;

PROCEDURE SysFstat(fildes : INTEGER; VAR buf : STATBUF) : INTEGER;

PROCEDURE SysLink(name1, name2 : ARRAY OF CHAR) : INTEGER;

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

PROCEDURE SysOpen(name : ARRAY OF CHAR; mode : CARDINAL) : INTEGER;

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

PROCEDURE SysStat(name : ARRAY OF CHAR; VAR buf : STATBUF) : INTEGER;

PROCEDURE SysUnlink(name : ARRAY OF CHAR) : INTEGER;

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

PROCEDURE SysUmask(VAR oldmask: BITSET; newmask: BITSET);

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

END SysFiles.
