-- Transport Mechanism Mail Server - DEFS for policy module --

-- [Juniper]<Grapevine>MS>PolicyDefs.mesa

-- Randy Gobbel		19-May-81 18:43:01 --
-- Andrew Birrell	September 13, 1982 3:47 pm --

DIRECTORY
Time		USING[ Packed ];

PolicyDefs:	DEFINITIONS =

BEGIN



-- Egg-timer --

Wait:		PROC[ days: CARDINAL ← 0,
		      hrs:  [0..24)  ← 0,
		      mins: [0..60)  ← 0,
		      secs: [0..60)  ← 0 ];
   -- Returns after specified time has elapsed --

WaitUntil:	PROC[time: Time.Packed];
   -- Returns at the specified time --



-- Compactor scheduling strategy --

CompactorStart:	PROC;
   -- Returns when it is appropriate for compactor to start a cycle --

CompactorPause:	PROC;
   -- Returns after a pause suitable for the compactor between pages --

AmountOfFreeHeap: PROC[ [0..100] ];
   -- Notifies the percentage of the heap currently empty --

GapExists:	PROC;
   -- Notifies the fact that there is now an empty area in the heap --



-- Other Time delays --

PeriodicProcess: TYPE = { readPending, prodServers, archiver, regPurger };

PeriodicWait:     PROC[process: PeriodicProcess];

Activate:         PROC[process: PeriodicProcess];

ReadPendingPause: PROC = INLINE { PeriodicWait[readPending] };

ProdServersPause: PROC = INLINE { PeriodicWait[prodServers] };

ArchiverPause:	  PROC = INLINE { PeriodicWait[archiver] };

RegPurgerPause:   PROC = INLINE { PeriodicWait[regPurger] };

ExpressAllowed: PROC[inputLength: CARDINAL] RETURNS[BOOLEAN];

SetExpressThreshold: PROC[CARDINAL];

-- Control of operations --

Operation:	TYPE = {
		work,		-- any form of operation --
		  connection,	-- any form of connection --
                    clientInput,-- receiver accepting input from client --
                    serverInput,-- receiver accepting input from server --
                    readMail,	-- client reading mail --
                    regExpand,	-- RServer connections --
                    lily,       -- Lily connections --
		    MTP,	-- MTP server --
		    FTP,	-- FTP server --
                  telnet,	-- miscellaneous Telnet connections --
		  mainLine,	-- main server processes --
                    readExpress, -- reading express-mail queue --
                    readInput,	-- reading input queue --
                    readPending,-- reading pending queue --
                    readMailbox,-- reading locked mailbox queue --
                    readForward,-- reading forward queue --
                    remailing,  -- transfering mail from inbox to input --
		  background,	-- non-urgent background stuff --
		    RSReadMail, -- R-Server reading internal mail --
		    MSReadMail, -- M-Server reading internal mail --
		    archiver,   -- Mailbox archiver process --
		    regPurger   -- R-Server BTree cleanup --
		};

WaitOperation:	PROC[ op: Operation ];
   -- Returns when the given operation is permissable, and notes that it is
   -- in progress --

CheckOperation:	PROC[ op: Operation ] RETURNS[ BOOLEAN ];
   -- Returns whether the given operation is permissable, and if it is
   -- permissable notes that it is in progress --

EndOperation:	PROC[ op: Operation ];
   -- Notifies that the operation has been completed --

OpLimit:	TYPE = [0..128);
   -- Limit on instances of operations, used in Control (below) --

Control:	TYPE = RECORD[ limit: OpLimit, allowed: BOOLEAN ];
   -- values for operation controls, below --

ReadOperationControl: PROC[ op: Operation ] RETURNS[ Control ];
   -- Returns the control on the given operation --

SetOperationLimit: PROC[ op: Operation, limit: OpLimit ];
   -- Sets the limit on the given operation --

SetOperationAllowed: PROC[ op: Operation, allowed: BOOLEAN ];
   -- allows or disallows the given operation --

SetTelnetAllowed: PROC;
   -- allows everything needed for telnet connections --

ReadOperationCurrent: PROC[ op: Operation ] RETURNS[OpLimit];
   -- returns current count for the operation --

END.