PDInterpMainImpl.mesa
Copyright (C) 1984, Xerox Corporation. All rights reserved.
Michael Plass, September 20, 1984 9:14:01 am PDT
DIRECTORY PDInterpReader, PDInterpPage, PDRemoteStream, PDQueue, Process, Stream, String, PDInterpOutput;
PDInterpMainImpl: PROGRAM IMPORTS PDInterpReader, PDInterpPage, PDRemoteStream, PDQueue, Process, String, PDInterpOutput = BEGIN
DoFile: PROC [request: PDQueue.Request, requestNumber: CARDINAL, abort: LONG POINTER TO BOOLEAN] = {
Action: PROC[stream: Stream.Handle] = {
reader: PDInterpReader.Handle ← PDInterpReader.Open[stream];
separator: LONG STRING ← [160];
String.Copy[separator, request.requestTime];
THROUGH [0..2) DO String.AppendChar[separator, ' ] ENDLOOP;
String.AppendString[separator, request.fileName];
THROUGH [0..2) DO String.AppendChar[separator, ' ] ENDLOOP;
String.AppendString[separator, request.requestor];
THROUGH [0..2) DO String.AppendChar[separator, ' ] ENDLOOP;
reader.herald.copies ← request.copies;
WHILE PDInterpPage.InterpretPage[reader, request, abort].ok DO IF abort^ THEN ABORTED ENDLOOP;
[] ← PDInterpReader.Close[reader];
};
IF request.fileName = NIL THEN PDInterpOutput.ReprintLastPage[request.copies]
ELSE {
PDRemoteStream.Read[request.fileName, request.requestor, request.requestorPassword, Action !
PDRemoteStream.Error => {
message: LONG STRING ← [160];
String.AppendString[message, request.fileName];
String.AppendString[message, " "];
String.AppendString[message, expl];
PDQueue.LogMessage[message, requestNumber];
CONTINUE;
};
PDInterpReader.Error => {
message: LONG STRING ← [160];
String.AppendString[message, "PD file error: "];
String.AppendString[message, SELECT code FROM
invalidPassword => "Not a PD file",
objectOutOfBounds => "Object out of bounds",
missingStartImage => "Missing start image",
badLoadReference => "Bad load reference",
unrecognisedImagingCommand => "Unrecognised imaging command",
loadOutOfBounds => "Load out of bounds",
unrecognisedControlCommand => "Unrecognised control command",
unrecognisedCommandType => "Unrecognised command type",
unexpectedEOF => "Unexpected EOF",
runGroupTooLong => "Run group too long",
bitmapTooBig => "Bitmap too big",
deviceCommandTooBig => "Device command too big",
ENDCASE => "??"
];
String.AppendString[message, " wordIndex: "];
String.AppendDecimal[message, wordIndex];
String.AppendString[message, " wordCount: "];
String.AppendDecimal[message, wordCount];
PDQueue.LogMessage[message, requestNumber];
CONTINUE;
};
PDInterpReader.Warning => {
message: LONG STRING ← [160];
String.AppendString[message, "PD file warning: "];
String.AppendString[message, SELECT code FROM
wrongFormatVersion => "Wrong version of PD file format",
unreasonableResolution => "Unreasonable resolution",
unreasonableBandSSize => "Unreasonable bandSSize",
unreasonableImageSize => "Unreasonable imageSize",
unreasonableLoadSize => "Unreasonable loadSize",
unreasonableNumberOfCopies => "Unreasonable number of copies",
objectOutOfBand => "Object out of band",
emptyRunGroup => "Empty run group",
nonZeroFill => "Non-zero fill",
imageBoundsExceedPageBounds => "Image bounds exceed page bounds",
tooFewBands => "Too few bands",
unknownColorTileFlag => "Unknown color tile flag",
ENDCASE => "??"
];
String.AppendString[message, " wordIndex: "];
String.AppendDecimal[message, wordIndex];
String.AppendString[message, " wordCount: "];
String.AppendDecimal[message, wordCount];
PDQueue.LogMessage[message, requestNumber];
RESUME;
};
];
};
};
Main: PROC = {
DO
PDQueue.DoRequest[DoFile !
ABORTED => CONTINUE;
]
ENDLOOP
};
PDQueue.LogMessage["Booted."];
Process.Detach[FORK Main[]];
END.