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

    :Program.    ModuleInfos.def
    :Contents.   Procedures reading the version key and import list of
    :Contents.   m2amiga def, mod, sym and obj files
    :Author.     Nicolas Benezan [bne]
    :Address.    Postwiesenstr. 2, D7000 Stuttgart 60
    :Phone.      711/333679
    :Copyright.  Shareware, see Dok-File
    :Language.   Modula-2
    :Translator. M2Amiga AMSoft V3.2d
    :Imports.    MemSystem1.2, ErrorReq1.2, PathFinder1.3 [bne]
    :Imports.    Queue1.2 [mif]
    :History.    V1.0b [bne] 5.Feb.1989
    :History.    V1.1b [bne] 10.Feb.1989 (+ ReadMainInfo, project)
    :History.    V1.2b [bne] 16.Feb.1989 (bugs fixed, cosmetics)
    :History.    V1.3a [bne] 4.Apr.1989 (+ LastFileDate);

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

DEFINITION MODULE ModuleInfos;

FROM Arts       IMPORT ModKeys, ModType, ModName;
FROM Dos        IMPORT Date, FileLockPtr;
FROM PathFinder IMPORT ProjectLock, ModNamePtr;
FROM Queue      IMPORT queue;

TYPE
  InfoFlags=(symValid,objValid,defExist,modExist);
  InfoFlagSet=SET OF InfoFlags;
  ModuleInfoPtr=POINTER TO ModuleInfo;
  ModuleInfo=RECORD
    project:ProjectLock;
    key:ModKeys;
    type:ModType;
    compiled:BOOLEAN;
    flags:InfoFlagSet;
  END;
  ImportInfoPtr=POINTER TO ImportInfo;
  ImportInfo=RECORD
    name:ModName;
    key:ModKeys;
  END;

VAR
  LastFileDate:Date; (* Date of last modified file *)

PROCEDURE ResetLastFileDate;
(*:Semantic.    Sets LastFileDate to the earliest possible date (null) *)

PROCEDURE GetDate(file:FileLockPtr;VAR date:Date);
(*:Input.       file: FileLockPtr of the file to be examined
  :Output.      date: creation date of the file (set by Dos)
*)

PROCEDURE MatchKeys(key1,key2:ModKeys):BOOLEAN;
(*:Input.       key1,key2: version keys used by Arts
  :Result.      TRUE if the versions are compatible, otherwise FALSE
*)

PROCEDURE EarlierDate(earlyDate,lateDate:Date):BOOLEAN;
(*:Input.   earlyDate,lateDate: dates got from GetDate() or Dos.DateStamp()
  :Note.    earlyDate,lateDate must be normalized !
  :Result.  TRUE if earlyDate was before lateDate, otherwise FALSE
  :Note.    It is senseless to test dates on equality because
  :Note.    DateStamp() always returns different dates.
*)

PROCEDURE ReadDefInfo(Project:ProjectLock;
                      Module:ModNamePtr;
                      ImportList:queue;
                  VAR Info:ModuleInfoPtr);
(*:Input.       Project: where to start searching
  :Input.       Module: pointer to the name of the module to be examined
  :Input.       ImportList: initialised empty queue
  :Output.      Info: pointer to Information about Module
  :Semantic.    Searches def and sym files, examines their dates and
  :Semantic.    decides if the sym is valid.
  :Semantic.    Info^ is allocated and its fields are initialised.
  :Semantic.    If a def-module exists, imported modules are queued
  :Semanic.     in ImportList, if not, it is considered as stdlib.
  :Note.        You are responsible of Deallocate(Info).
  :Note.        Module:ModNamePtr must not contain an extension
*)

PROCEDURE ReadModInfo(Module:ModNamePtr;
                      ImportList:queue;
                      Info:ModuleInfoPtr;
                  VAR ObjKey:ModKeys);
(*:Input.       Module: pointer to the name of the module to be examined
  :Input.       ImportList: initialised empty queue
  :Input.       Info: pointer to an initialised ModuleInfo
  :Semantic.    Queues the names of all imported modules.
  :Note.        Module:ModNamePtr must not contain an extension
*)

PROCEDURE ReadMainInfo(Project:ProjectLock;
                       Module:ModNamePtr;
                   VAR Info:ModuleInfoPtr);
(*:Semantic.    Returns a dummy ModuleInfo (there's no DEFINITION MODULE
  :Semantic.    of the main MODULE)
  :Note.        parameters: see ReadDefInfo()
*)

END ModuleInfos.

