ArpaSMTPDescr.mesa
Last Edited by: HGM, April 29, 1984 3:37:08 am PDT
Last Edited by: DCraft, December 21, 1983 8:40 pm
Last Edited by: Taft, January 3, 1984 2:03 pm
John Larson, October 9, 1987 2:39:22 pm PDT
Hal Murray May 27, 1985 7:54:13 pm PDT
Descriptors contain the information about mail items (name of message file, reverse-path, recipients, timeout, etc.). They are kept internally on Queues, and are partially backed up on the filestore. The intention is that, at start of day, the server will initialize its internal queues by requesting the existing descriptors from the filestore (those left over from before the crash or shutdown). The server will create new descriptors as mail items come in, move the descriptors through the queue system, and destroy the descriptors once the mail has been delivered.
DIRECTORY
BasicTime USING [GMT],
Rope USING [ROPE],
IO USING [STREAM];
ArpaSMTPDescr: CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
STREAM: TYPE = IO.STREAM;
Descr: TYPE = REF DescrRep;
DescrRep: TYPE;
Format: TYPE = {gv, arpa};
Create: PROC [
arpaReversePath: ROPENIL,
gvSender: ROPENIL,
rawRecipients: LIST OF ROPE,
source: ROPENIL,
format: Format,
msgStream: STREAM,
precedeMsgText: ROPENIL,
returnPathLine: ROPENIL]
RETURNS [Descr];
! CreateFailed if unable to store on disk.
GetUserHandle: PROC [self: Descr] RETURNS [INT];
GetFileName: PROC [self: Descr] RETURNS [ROPE]; -- should be called only by ArpaSMTPQueue.DeleteFromAll
GetExpiryDate: PROC [self: Descr] RETURNS [BasicTime.GMT];
GetArpaReversePath: PROC [self: Descr] RETURNS [path: ROPE];
SetArpaReversePath: PROC [self: Descr, path: ROPE];
GetGvSender: PROC [self: Descr] RETURNS [rName: ROPE];
SetGvSender: PROC [self: Descr, rName: ROPE];
GetSource: PROC [self: Descr] RETURNS [ROPE];
EnumerateRawRecipients: PROC [self: Descr, proc: RawRecipProc, procData: REF ANYNIL];
This is used by the processing procs to convert raw recipients, one at a time, into processed host/user pairs which can then be added to the item with AddProcessedRecipient.
RawRecipProc: TYPE = PROC [rawRecipient: ROPE, procData: REF ANY] RETURNS [continue: BOOLTRUE];
! WrongState
RemoveRawRecipients: PROC [self: Descr];
! WrongState
Remove them all, item probably being returned to sender.
AddProcessedRecipient: PROC [self: Descr, hostName: ROPE, userName: ROPE, checkDuplicate: BOOL];
Add the given host/user pair to the item descriptor. (StoreItemInfo should be called when processing is finished.)
RemoveRecipientHost: PROC [self: Descr, hostName: ROPE];
! WrongState
The item has been delivered to the given host so remove all recipients at this host from the recipient list.
EnumerateRecipientHosts: PROC [self: Descr, proc: HostProc, procData: REF ANYNIL];
! WrongState
Enumerate the (processed) recipient hosts, giving the host name and all recipient users at that host for each.
HostProc: TYPE = PROC [hostName: ROPE, userNames: LIST OF ROPE, procData: REF ANY] RETURNS [continue: BOOLTRUE];
MoreRecipients: PROC [self: Descr] RETURNS [BOOL];
Returns whether there are any more recipients (either raw or processed). Should be checked before calling Destroy.
StoreItemInfo: PROC [descr: Descr];
The item descriptor is in a consistent state which should be backed up to the filestore.
GetFormat: PROC [self: Descr] RETURNS [Format];
Get the format of the message body.
GetPrecedeMsgText: PROC [self: Descr] RETURNS [ROPE];
Get the text which should precede the message body upon sending.
SetPrecedeMsgText: PROC [self: Descr, new: ROPE];
GetReturnPathLine: PROC [self: Descr] RETURNS [ROPE];
Get the return path line which was assigned for incoming SMTP mail. (NIL for items with GV format)
RetrieveMsgStream: PROC [self: Descr] RETURNS [STREAM];
! PutOnBadQueue
Open the associated file and provide a subrange stream for the message body.
UniqueID: PROC [self: Descr] RETURNS [rope: ROPE];
Destroy: PROC [self: Descr];
Destroy the descriptor (basically, delete the file). Repeatable.
Print: PROC [descr: Descr, out: STREAM, form: PrintForm ← long];
Prints info from the given item descriptor on the given output stream. The short form includes only the handle and file name. The long form ends with a newline.
Unparse: PROC [descr: Descr, form: PrintForm ← short] RETURNS [ROPE];
Like Print, except returns the info as a rope. The long form is somewhat inefficient and shouldn't be used frequently.
PrintForm: TYPE = {short, long};
CopyForReturn: PROC [old: Descr, reason: ROPE] RETURNS [new: Descr];
! CreateFailed
The given item is to be returned to the sender. Copy the old file, update the descriptor fields to return the item, and store the info changes to the new file, returning the new descriptor.
ReadItemFile: PROC [fileName: ROPE] RETURNS [Descr];
! Failed;
Read the item file with the given name. Client should ensure there are no items in the queue system which already reference this file to ensure no duplicate items. This will be used only as a result of the user having edited an item file and requested it to be read.
Failed: ERROR [reason: ROPE];
EnumerateInitialItems: PROC [proc: InitialItemProc];
Scan the filestore directory for item files left from the previous run, creating a descriptor and calling proc for each.
InitialItemProc: TYPE = PROC [descr: Descr];
CreateFailed, WrongState, PutOnBadQueue: ERROR;
END.