(********************************************************************************

Name         : AMIGADos.DEF
Version      : 1.0
Purpose      : Interface to AMIGADos
Authors      : cn/jr/ms/red
Modified     : 12.3.86  20:26  cn
State        : should be ok
Requirements : 

********************************************************************************)

DEFINITION MODULE AMIGADos;

FROM SYSTEM IMPORT ADDRESS;

TYPE AMIGADateStamp      = RECORD
                             days: LONGINT;    (* nr of days *)
                             minutes: LONGINT; (* nr of minutes this day *)
                             ticks: LONGINT    (* nr of ticks in current minute *)
                           END;
    
     AMIGAFileInfoBlock  = RECORD         (* must be longword-aligned! *)
                             diskKey: LONGINT;                  (*   4 *)
                             dirEntry: LONGINT;                 (*   4 *)
                             fileName: ARRAY [0..107] OF CHAR;  (* 108 *)
                             protection: LONGINT;               (*   4 *)
                             entryType: LONGINT;                (*   4 *)
                             size: LONGINT;                     (*   4 *)
                             blocks: LONGINT;                   (*   4 *)
                             date: AMIGADateStamp;              (*  12 *)
                             comment: ARRAY [0..115] OF CHAR    (* 116 *)
                           END;                        (* TSIZE =  260 *)

     AMIGALockPtr;

     AMIGAFile;

     AMIGAInfoData       = RECORD
                             numSoftErrors,
                             unitNumber,
                             diskState,
                             numBlocks,
                             numBlocksUsed,
                             bytesPerBlock: LONGINT;
                             diskType: RECORD
                                         CASE :BOOLEAN OF
                                         | TRUE: val: LONGINT;
                                         | FALSE: typ: ARRAY [0..3] OF CHAR;
                                         END
                                       END;
                                       (*  val = -1    : no disk present
                                         | typ = 'BAD' : unreadable disk
                                         | typ = 'DOS' : dos disk
                                         | typ = 'NDOS': not really dos
                                         | typ = 'KICK': kickstart disk  *)
                             volumeNode, 
                             inUse: LONGINT
                           END;

     AMIGASeekMode       = (ofsBeginning, ofsCurrent, ofsEnd);
                           (* Note: the values must be -1, 0, 1 for AMIGALib *)

     AMIGAFileProtection = (deletionProtection, executeProtection,
                            writeProtection, readProtection);

     AMIGAFileProtectSET = SET OF AMIGAFileProtection;
                           (* Note: the bits according to the values
                              must be included in mask *)

     AMIGAProcessPtr;

     AMIGASegmentPtr;


(* File Handling  *)

PROCEDURE Close(f: AMIGAFile);

PROCEDURE CreateDir(name: ARRAY OF CHAR): AMIGALockPtr;

PROCEDURE CurrentDir(lockPtr: AMIGALockPtr): AMIGALockPtr;

PROCEDURE DeleteFile(name: ARRAY OF CHAR; VAR done: BOOLEAN);

PROCEDURE DupLock(lockPtr: AMIGALockPtr): AMIGALockPtr;

PROCEDURE Examine(lockPtr: AMIGALockPtr;
                  VAR fileInfo: AMIGAFileInfoBlock; VAR done: BOOLEAN);

PROCEDURE ExNext(lockPtr: AMIGALockPtr;
                  VAR fileInfo: AMIGAFileInfoBlock; VAR done: BOOLEAN);

PROCEDURE Info(lockPtr: AMIGALockPtr;
               VAR infoData: AMIGAInfoData; VAR done: BOOLEAN);

PROCEDURE Input(): AMIGAFile;

PROCEDURE IoErr(): LONGINT;

PROCEDURE IsInteractive(f: AMIGAFile): BOOLEAN;

PROCEDURE Lock(name: ARRAY OF CHAR;
               accessWrite: BOOLEAN): AMIGALockPtr;

PROCEDURE Open(name: ARRAY OF CHAR; newFile: BOOLEAN): AMIGAFile;

PROCEDURE Output(): AMIGAFile;

PROCEDURE ParentDir(lockPtr: AMIGALockPtr): AMIGALockPtr;

PROCEDURE Read(f: AMIGAFile; buffer: ADDRESS; length: LONGINT): LONGINT;

PROCEDURE Rename(oldname, newname: ARRAY OF CHAR; VAR done: BOOLEAN);

PROCEDURE Seek(f: AMIGAFile; pos: LONGINT; seekMode: AMIGASeekMode): LONGINT;

PROCEDURE SetComment(name, comment: ARRAY OF CHAR; VAR done: BOOLEAN);

PROCEDURE SetProtection(name: ARRAY OF CHAR;
                        mask: AMIGAFileProtectSET; VAR done: BOOLEAN);

PROCEDURE UnLock(lockPtr: AMIGALockPtr);

PROCEDURE WaitForChar(f: AMIGAFile; timeout: LONGINT): BOOLEAN;

PROCEDURE Write(f: AMIGAFile; buffer: ADDRESS; length: LONGINT): LONGINT;


(* Process Handling *)

PROCEDURE CreateProc(name: ARRAY OF CHAR; priorty: LONGINT;
                     segment: AMIGASegmentPtr;
                     stackSize: LONGINT): AMIGAProcessPtr;

PROCEDURE DateStamp(VAR v: AMIGADateStamp);

PROCEDURE Delay(timeout: LONGINT);
(* delay in ticks  --  1 tick = 20 ms *)

PROCEDURE DeviceProc(name: ARRAY OF CHAR): AMIGAProcessPtr;

PROCEDURE Exit(returnCode: LONGINT);


(* Loading Code *)

PROCEDURE Execute(command: ARRAY OF CHAR;
                  VAR input, output: AMIGAFile; VAR done: BOOLEAN);

PROCEDURE LoadSeg(name: ARRAY OF CHAR): AMIGASegmentPtr;

PROCEDURE UnLoadSeg(segment: AMIGASegmentPtr);


END AMIGADos.
