-- ChollaCmdDefs.mesa
-- edited by Barth, October 13, 1981 3:07 PM
-- edited by Brotz, September 17, 1982 11:35 AM
-- edited by Crowther, January 13, 1982 11:36 AM

DIRECTORY
Ascii,
inD: FROM "InteractorDefs",
MessageParse,
vmD: FROM "VirtualMgrDefs";

ccD: DEFINITIONS =

BEGIN

-- Constants

maxRunNameLength: CARDINAL = 16;
maxSpecNameLength: CARDINAL = 20;
maxProcessNameLength: CARDINAL = 40;
maxUserNameLength: CARDINAL = 50;
maxItemsInDeletionList: CARDINAL = 32;
maxUniqueIDLength: CARDINAL = 20;
timeOffset: LONG CARDINAL = 20000000000B;
sixteenDays: LONG CARDINAL = LONG[60] * LONG[60] * LONG[24] * LONG[16];
stepListMarkChar: CHARACTER = Ascii.ControlG;

-- Types

Action: TYPE = {insert, replace, delete, none};
ChollaFileType: TYPE = {done, bb, step, technician, spec, data, prototypes, none};

StepStatus: TYPE = {none, notStarted, started, inProcess, processDone, rejected, finished};
maxStatusStringLength: CARDINAL = 12;

ParsedStep: TYPE = RECORD
[specName: STRING,
specVersion: CARDINAL,
dataName: STRING,
dataVersion: CARDINAL,
stepName: STRING,
status: StepStatus, --watch out, this can get out of date!
statusIndex: CARDINAL,
paramIndex: CARDINAL];
ParsedStepPtr: TYPE = POINTER TO ParsedStep;


TOCCache: TYPE = RECORD
[a, b: TOCCacheX ← [NIL, NIL],
spare: vmD.TOCHandle ← NIL];

TOCCacheX: TYPE = RECORD [file: STRING, toc: vmD.TOCHandle];
TOCCachePtr: TYPE = POINTER TO TOCCache;
tocCacheFileStringLength: CARDINAL = 64;

TOCCacheType: TYPE = {laurel, bb, spec, data, done, technician, stepList, pending,
unsentMail, prototypes, archive};

UniqueID: TYPE = RECORD [machine: CARDINAL, time: LONG CARDINAL];
UniqueIDPtr: TYPE = POINTER TO UniqueID;
IDType: TYPE = {thisID, uniqueID};

DeletionList: TYPE = RECORD
[first: CARDINAL,
nItems: CARDINAL,
item: ARRAY [0 .. maxItemsInDeletionList) OF UniqueID];

AuthorizationClass: TYPE = {kahuna, maven, technician, onlooker};


-- ************************** --
-- Exported by ChollaCmd
-- ************************** --


stepListRunName: STRING;
activeStepSpecName: STRING; -- last displayed by step or spec
stepListLowerHp: inD.HousePtr;

iOwnThisStep: BOOLEAN;
currentStepNumber: vmD.TOCIndex;
displayedStep: vmD.TOCIndex;
currentDoneFileName: STRING;
shutDownCholla: BOOLEAN;
cacheTable: ARRAY TOCCacheType OF TOCCache;


StartChollaMailProcess: PROCEDURE;
-- May be called ONCE per session to begin Cholla background mail processing.


FinishChollaMailProcess: PROCEDURE;
-- May be called ONCE per session to close down Cholla background mail processing.


RestoreLaurel: PROCEDURE;


GetTOCForFile: PROCEDURE
[fileName: STRING, cacheType: TOCCacheType, usingA: BOOLEAN ← TRUE]
RETURNS [toc: vmD.TOCHandle, key: CARDINAL];
-- Returns a toc corresponding to a mail file with "filename". ".mail" is added if no dot is
-- present in the "filename" parameter. "cacheType" determines which category of mail
-- file is requested; different categories do not interfere with each others replacement
-- strategy. "usingA" TRUE means that the toc is requested for user interaction; FALSE
-- means that the Cholla mail process is requesting this toc. Normally, the toc is returned
-- locked. If anything goes wrong, "toc" retruned is NIL.
-- A new toc requested from the same cacheType with the same "usingA" will cause the
-- previous toc held in that cacheType to be returned. To force a return of both tocs held
-- in the cacheType without getting a toc on a new file, call GetTOCForFile with
-- "filename" = NIL.


CleanUpTOCCaches: PROCEDURE;
-- Returns all tocs in all toc caches except for the ones held in the laurel toc cache.


LoadComposedMessage:PROCEDURE
[toc: vmD.TOCHandle, key, index: CARDINAL, cm: vmD.ComposedMessagePtr];
-- like LoadDisplayMessage. (when done, just free cm.)


CleanupDisplayMessage: PROCEDURE;


IsAuthorized: PROCEDURE
[class: AuthorizationClass, hp: inD.HousePtr, displayNotAuthMessage: BOOLEAN ← TRUE]
RETURNS [ok: BOOLEAN];


ResetAuthorization: PROCEDURE;


StringToStatus: PROCEDURE [STRING] RETURNS [StepStatus];


-- ************************** --
-- Exported by ChollaBBoard
-- ************************** --


BBoardCommand: inD.CommandProcedure;


InstallBB: PROCEDURE;


ObtainRunName: PROCEDURE
[vm: vmD.VirtualMessagePtr, fieldList: MessageParse.FieldList, runName: STRING]
RETURNS [isRun: BOOLEAN];


ChollaGet: inD.CommandProcedure;


-- ************************** --
-- Exported by ChollaStepList
-- ************************** --


InstallStepList: PROCEDURE [runName: STRING] RETURNS [worked: BOOLEAN];


StepListUpdate: PROCEDURE [update: vmD.VirtualMessagePtr];


CurrentStep: PROCEDURE RETURNS [vmD.TOCIndex];


GetStepStatus: PROCEDURE [toc: vmD.TOCHandle, key: CARDINAL, index: vmD.TOCIndex]
RETURNS [s: StepStatus];


CopyUniqueIDsIntoMessage: PROCEDURE
[toc: vmD.TOCHandle, key: CARDINAL, index: vmD.TOCIndex,
cm: vmD.ComposedMessagePtr, fieldListPtr: MessageParse.FieldListPtr];
--The ID’s from <toc,key,index> are copied into cm. Useful for hiding ID’s from user.


SetStepStatus: PROCEDURE
[toc: vmD.TOCHandle, key: CARDINAL, index: vmD.TOCIndex, s: StepStatus];


StatusToString: PROCEDURE [s: ccD.StepStatus, t: STRING];


DoLowerMenu: PROCEDURE [hp: inD.HousePtr];
-- Sets the editor window menu to the list headed by hp.


-- ************************** --
-- Exported by ChollaStep
-- ************************** --


StepOperation: PROCEDURE [stepListString: STRING];
-- display the spec and data for the current step. "stepListString" contains a toc string
-- from which the spec name, version, data form name, version and parameters may be
-- extracted.


SpecCommand: inD.CommandProcedure;


StartStepCommand: inD.CommandProcedure;


ProcessStepCommand: inD.CommandProcedure;


CancelStepCommand: inD.CommandProcedure;


ProcessDoneStepCommand: inD.CommandProcedure;


RejectStepCommand: inD.CommandProcedure;


FinishStepCommand: inD.CommandProcedure;


ReceivedUpdate: PROCEDURE [update: vmD.VirtualMessagePtr];


PreserveChangeInDoneFile: PROCEDURE;


InsertString: PROCEDURE [cm: vmD.ComposedMessagePtr, start: vmD.CharIndex, s: STRING];


UpdateTechnician: PROCEDURE [technician: STRING, spec: STRING, version: CARDINAL];


WriteMessageIntoComposeWindow: PROCEDURE
[newm: vmD.VirtualMessagePtr, fieldListPtr: MessageParse.FieldListPtr];


ResetTheEditor: PROCEDURE
[keepDeletionBuffer: BOOLEAN ← FALSE, fieldList: MessageParse.FieldList ← NIL];
-- If fieldList is non-NIL, then the fields in that list will be protected from editing.


-- ************************** --
-- exported by ChollaSpecs
-- ************************** --


InstallSpecs: PROCEDURE;


RetrieveFromArchive: PUBLIC PROCEDURE
[name: STRING, version: CARDINAL, cm: vmD.ComposedMessagePtr]
RETURNS [haveIt: BOOLEAN];
-- Fills in cm with a copy of the version’th message from the archived file whose root is
-- "name".


-- ************************** --
-- exported by ChollaStepListParse
-- ************************** --


ParseStep: PROCEDURE [s: STRING, p: ParsedStepPtr];


StatusOfTOCEntry: PROCEDURE
[toc: vmD.TOCHandle, key: CARDINAL, index: vmD.TOCIndex, status: STRING];


-- ***************** --
-- Exported by ChollaMail
-- ***************** --


SendChollaMail: PROCEDURE
[action: Action, type: ChollaFileType, toc: vmD.TOCHandle, key: CARDINAL,
index: vmD.TOCIndex, cm: vmD.ComposedMessagePtr,
fieldListPtr: MessageParse.FieldListPtr, dummy: BOOLEAN ← FALSE,
nIDs: CARDINAL ← 1]
RETURNS [worked: BOOLEAN];


AppendToUnsentMailQueue: PROCEDURE [cm: vmD.ComposedMessagePtr];


ChollaMailProcess: PROCEDURE;


CallSomethingToDo: PROCEDURE;


-- *********************** --
-- Exported by ChollaMailUtils
-- *********************** --


StartMultiTOCOperation: PROCEDURE;
-- Used by Cholla operations that need to lock more than one TOC simultaneously.


FinishMultiTOCOperation: PROCEDURE;


GetIDUsingIndex: PROCEDURE
[toc: vmD.TOCHandle, key: CARDINAL, index: CARDINAL, idType: IDType]
RETURNS [u: UniqueID];


GetBothIDsUsingIndex: PROCEDURE
[toc: vmD.TOCHandle, key: CARDINAL, index: CARDINAL, thisID, uniqueID: UniqueIDPtr];


GetIDUsingVM: PROCEDURE
[vm: vmD.VirtualMessagePtr, fieldListPtr: MessageParse.FieldListPtr, name: STRING]
RETURNS [u: UniqueID];


ExtractID: PROCEDURE
[vm: vmD.VirtualMessagePtr, fieldList: MessageParse.FieldList] RETURNS [u: UniqueID];


FillIDField: PROCEDURE [cm: vmD.ComposedMessagePtr,
fieldListPtr: MessageParse.FieldListPtr, s: STRING, u: UniqueIDPtr];


MakeUniqueID: PROCEDURE [dummy: BOOLEAN, nIDs: CARDINAL] RETURNS [UniqueID];


UniqueIDToString: PROCEDURE [id: UniqueID, s: STRING];


NewerUniqueID: PROCEDURE [a, b: UniqueIDPtr] RETURNS [BOOLEAN];


NewMatchesOld: PROCEDURE [new, old: UniqueIDPtr] RETURNS [BOOLEAN];


IsIllegalID: PROCEDURE [id: UniqueID] RETURNS [BOOLEAN];


IsDummyID: PROCEDURE [id: UniqueID] RETURNS [BOOLEAN];


MakeBBRunEntryString: PROCEDURE
[toc: vmD.TOCHandle, key: CARDINAL, doneFF: vmD.TOCIndex, run, string: STRING];
-- Creates a string containing details of steps to be displayed in a run BBoard entry.


UpdateBBRunEntry: PROCEDURE [run, string: STRING, newID: UniqueID];
-- Looks for BB entry for "run". If the tocString is non-NIL, then a new BB entry is
-- constructed, and the old BB entry is replaced. If the old BB entry was not found, a
-- new one is created. If string = NIL, then any existing BB entry for this run is
-- deleted.


DoAFileRequest: PROCEDURE
[request: vmD.VirtualMessagePtr, fieldList: MessageParse.FieldList];


StringToType: PROCEDURE [s: STRING] RETURNS [ChollaFileType];


StringToAction: PROCEDURE [s: STRING] RETURNS [Action];


InsertInDeletionList: PROCEDURE [uniqueID: UniqueID];


UniqueIDIsInDeletionList: PROCEDURE [uniqueID: UniqueID] RETURNS [BOOLEAN];


-- **************************** --
-- Exported by ChollaMachineDriver
-- **************************** --


MachineDriver: PROCEDURE [data, spec: vmD.VirtualMessagePtr, name: STRING]
RETURNS [result: STRING];
--returns NIL when ok, else an error string.


MachineTalker: PROCEDURE [name: STRING] RETURNS [worked: BOOLEAN];


MachineCancel: PROCEDURE [data, spec: vmD.VirtualMessagePtr, name: STRING]
RETURNS [cancelled: BOOLEAN];


END. -- of ChollaCmdDefs --