<<>> <> <> <> <> <> DIRECTORY CrRPC, TimeP15V2, AuthenticationP14V2, BulkDataP0V1, PrintingP4V3; PrintingP4V3ServerImpl: CEDAR PROGRAM IMPORTS CrRPC, PrintingP4V3 ~ { OPEN PrintingP4V3; GetPrinterPropertiesCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ { properties: PrinterProperties; [properties] ¬ GetPrinterProperties[h]; beginReturn[h]; { MProc42[h, s, properties]; }; }; PrintCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ { master: CrRPC.BulkDataSource; printAttributes: PrintAttributes; printOptions: PrintOptions; printRequestID: RequestID; TRUSTED { master ¬ CrRPC.GetBulkDataSource[h, s]; }; { printAttributes ¬ UProc43[h, s]; }; { printOptions ¬ UProc44[h, s]; }; [printRequestID] ¬ Print[h, master, printAttributes, printOptions]; beginReturn[h]; { FOR i45: CARDINAL IN [0..5) DO CrRPC.PutCard16[s, printRequestID[i45]]; ENDLOOP; }; }; GetPrintRequestStatusCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ { printRequestID: RequestID; status: RequestStatus; { FOR i46: CARDINAL IN [0..5) DO printRequestID[i46] ¬ CrRPC.GetCard16[s]; ENDLOOP; }; [status] ¬ GetPrintRequestStatus[h, printRequestID]; beginReturn[h]; { MProc47[h, s, status]; }; }; GetPrinterStatusCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ { status: PrinterStatus; [status] ¬ GetPrinterStatus[h]; beginReturn[h]; { MProc48[h, s, status]; }; }; Server: CrRPC.ServerProc ~ { <<[h: Handle, s: STREAM, pgm: CARD32, pgmVersion: CARD16, proc: CARD16, beginReturn: BeginReturnProc, beginError: BeginErrorProc, beginReject: BeginRejectProc]>> ENABLE { PrintingP4V3.ConnectionError => { -- (11 ) beginError[h, 11 ]; CrRPC.PutCard16[s, ORD[problem]]; GOTO Finished; }; PrintingP4V3.SpoolingQueueFull => { -- (7 ) beginError[h, 7 ]; GOTO Finished; }; PrintingP4V3.SystemError => { -- (8 ) beginError[h, 8 ]; GOTO Finished; }; PrintingP4V3.InsufficientSpoolSpace => { -- (1 ) beginError[h, 1 ]; GOTO Finished; }; PrintingP4V3.Busy => { -- (0 ) beginError[h, 0 ]; GOTO Finished; }; PrintingP4V3.TransferError => { -- (12 ) beginError[h, 12 ]; CrRPC.PutCard16[s, ORD[problem]]; GOTO Finished; }; PrintingP4V3.SpoolingDisabled => { -- (6 ) beginError[h, 6 ]; GOTO Finished; }; PrintingP4V3.Undefined => { -- (10 ) beginError[h, 10 ]; CrRPC.PutCard16[s, problem]; GOTO Finished; }; PrintingP4V3.MediumUnavailable => { -- (4 ) beginError[h, 4 ]; GOTO Finished; }; PrintingP4V3.InvalidPrintParameters => { -- (2 ) beginError[h, 2 ]; GOTO Finished; }; PrintingP4V3.MasterTooLarge => { -- (3 ) beginError[h, 3 ]; GOTO Finished; }; PrintingP4V3.ServiceUnavailable => { -- (5 ) beginError[h, 5 ]; GOTO Finished; }; PrintingP4V3.TooManyClients => { -- (9 ) beginError[h, 9 ]; GOTO Finished; }; }; IF (pgmVersion # 3) THEN { beginReject[h, CrRPC.noSuchVersion]; CrRPC.PutCard16[s, 3]; --low CrRPC.PutCard16[s, 3]; --high RETURN }; SELECT proc FROM 1 => GetPrinterPropertiesCaller[h, s, beginReturn]; 0 => PrintCaller[h, s, beginReturn]; 2 => GetPrintRequestStatusCaller[h, s, beginReturn]; 3 => GetPrinterStatusCaller[h, s, beginReturn]; ENDCASE => { beginReject[h, CrRPC.noSuchProcedure]; }; EXITS Finished => { NULL }; }; <> UProc44: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: PrintOptions] ~ { { length50: CARDINAL ~ CrRPC.GetCard16[s]; res ¬ NEW[PrintOptionsObject[length50]]; FOR i49: CARDINAL IN [0..length50) DO res.body[i49] ¬ UProc51[h, s]; ENDLOOP; }; }; UProc43: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: PrintAttributes] ~ { { length53: CARDINAL ~ CrRPC.GetCard16[s]; res ¬ NEW[PrintAttributesObject[length53]]; FOR i52: CARDINAL IN [0..length53) DO res.body[i52] ¬ UProc54[h, s]; ENDLOOP; }; }; MProc47: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: RequestStatus] ~ { CrRPC.PutCard16[s, val.length]; FOR i55: CARDINAL IN [0..val.length) DO MProc56[h, s, val.body[i55]]; ENDLOOP; }; UProc51: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: Option] ~ { { tag57: OptionKind ~ VAL[CrRPC.GetCard16[s]]; SELECT tag57 FROM printObjectSize => { temp58: CARD32; temp58 ¬ CrRPC.GetCard32[s]; res ¬ NEW[OptionObject.printObjectSize ¬ [printObjectSize[temp58]]] }; recipientName => { temp58: ROPE; temp58 ¬ CrRPC.GetRope[s]; res ¬ NEW[OptionObject.recipientName ¬ [recipientName[temp58]]] }; message => { temp58: ROPE; temp58 ¬ CrRPC.GetRope[s]; res ¬ NEW[OptionObject.message ¬ [message[temp58]]] }; copyCount => { temp58: CARD16; temp58 ¬ CrRPC.GetCard16[s]; res ¬ NEW[OptionObject.copyCount ¬ [copyCount[temp58]]] }; pagesToPrint => { temp58: DocumentSubrange; temp58.beginningPageNumber ¬ CrRPC.GetCard16[s]; temp58.endingPageNumber ¬ CrRPC.GetCard16[s]; res ¬ NEW[OptionObject.pagesToPrint ¬ [pagesToPrint[temp58]]] }; mediumHint => { temp58: Medium; temp58 ¬ UProc59[h, s]; res ¬ NEW[OptionObject.mediumHint ¬ [mediumHint[temp58]]] }; priorityHint => { temp58: Priority; temp58 ¬ VAL[CrRPC.GetCard16[s]]; res ¬ NEW[OptionObject.priorityHint ¬ [priorityHint[temp58]]] }; releaseKey => { temp58: CARD16; temp58 ¬ CrRPC.GetCard16[s]; res ¬ NEW[OptionObject.releaseKey ¬ [releaseKey[temp58]]] }; staple => { temp58: BOOLEAN; temp58 ¬ CrRPC.GetBool[s]; res ¬ NEW[OptionObject.staple ¬ [staple[temp58]]] }; twoSided => { temp58: BOOLEAN; temp58 ¬ CrRPC.GetBool[s]; res ¬ NEW[OptionObject.twoSided ¬ [twoSided[temp58]]] }; ENDCASE => ERROR; }; }; UProc54: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: Attribute] ~ { { tag60: AttributeKind ~ VAL[CrRPC.GetCard16[s]]; SELECT tag60 FROM printObjectName => { temp61: ROPE; temp61 ¬ CrRPC.GetRope[s]; res ¬ NEW[AttributeObject.printObjectName ¬ [printObjectName[temp61]]] }; printObjectCreateDate => { temp61: CARD32; temp61 ¬ CrRPC.GetCard32[s]; res ¬ NEW[AttributeObject.printObjectCreateDate ¬ [printObjectCreateDate[temp61]]] }; senderName => { temp61: ROPE; temp61 ¬ CrRPC.GetRope[s]; res ¬ NEW[AttributeObject.senderName ¬ [senderName[temp61]]] }; ENDCASE => ERROR; }; }; MProc48: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: PrinterStatus] ~ { CrRPC.PutCard16[s, val.length]; FOR i62: CARDINAL IN [0..val.length) DO MProc63[h, s, val.body[i62]]; ENDLOOP; }; MProc56: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: JobStatus] ~ { CrRPC.PutCard16[s, ORD[val.type]]; WITH val SELECT FROM it: REF JobStatusObject.status => { CrRPC.PutCard16[s, ORD[it­.status]]; }; it: REF JobStatusObject.statusMessage => { CrRPC.PutRope[s, it­.statusMessage]; }; ENDCASE; }; MProc42: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: PrinterProperties] ~ { CrRPC.PutCard16[s, val.length]; FOR i65: CARDINAL IN [0..val.length) DO MProc66[h, s, val.body[i65]]; ENDLOOP; }; MProc66: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: Property] ~ { CrRPC.PutCard16[s, ORD[val.type]]; WITH val SELECT FROM it: REF PropertyObject.ppmedia => { MProc68[h, s, it­.ppmedia]; }; it: REF PropertyObject.ppstaple => { CrRPC.PutBool[s, it­.ppstaple]; }; it: REF PropertyObject.pptwoSided => { CrRPC.PutBool[s, it­.pptwoSided]; }; ENDCASE; }; MProc63: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: ServiceStatus] ~ { CrRPC.PutCard16[s, ORD[val.type]]; WITH val SELECT FROM it: REF ServiceStatusObject.spooler => { CrRPC.PutCard16[s, ORD[it­.spooler]]; }; it: REF ServiceStatusObject.formatter => { CrRPC.PutCard16[s, ORD[it­.formatter]]; }; it: REF ServiceStatusObject.printer => { CrRPC.PutCard16[s, ORD[it­.printer]]; }; it: REF ServiceStatusObject.media => { MProc68[h, s, it­.media]; }; ENDCASE; }; UProc59: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: Medium] ~ { { tag70: MediumKind ~ VAL[CrRPC.GetCard16[s]]; SELECT tag70 FROM paper => { temp71: Paper; temp71 ¬ UProc72[h, s]; res ¬ NEW[MediumObject.paper ¬ [paper[temp71]]] }; ENDCASE => ERROR; }; }; MProc68: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: Media] ~ { CrRPC.PutCard16[s, val.length]; FOR i73: CARDINAL IN [0..val.length) DO MProc74[h, s, val.body[i73]]; ENDLOOP; }; UProc72: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: Paper] ~ { { tag75: PaperKind ~ VAL[CrRPC.GetCard16[s]]; SELECT tag75 FROM unknown => { temp76: EmptyRecord; temp76.null ¬ 0; res ¬ NEW[PaperObject.unknown ¬ [unknown[temp76]]] }; knownSize => { temp76: KnownPaperSize; temp76 ¬ VAL[CrRPC.GetCard16[s]]; res ¬ NEW[PaperObject.knownSize ¬ [knownSize[temp76]]] }; otherSize => { temp76: PaperDimensions; temp76.width ¬ CrRPC.GetCard16[s]; temp76.length ¬ CrRPC.GetCard16[s]; res ¬ NEW[PaperObject.otherSize ¬ [otherSize[temp76]]] }; ENDCASE => ERROR; }; }; MProc74: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: Medium] ~ { CrRPC.PutCard16[s, ORD[val.type]]; WITH val SELECT FROM it: REF MediumObject.paper => { MProc78[h, s, it­.paper]; }; ENDCASE; }; MProc78: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: Paper] ~ { CrRPC.PutCard16[s, ORD[val.type]]; WITH val SELECT FROM it: REF PaperObject.unknown => { NULL; -- RECORD [] -- }; it: REF PaperObject.knownSize => { CrRPC.PutCard16[s, ORD[it­.knownSize]]; }; it: REF PaperObject.otherSize => { CrRPC.PutCard16[s, it­.otherSize.width]; CrRPC.PutCard16[s, it­.otherSize.length]; }; ENDCASE; }; CrRPC.RegisterServerProcs[pgm~4, serverProc~Server, pgmLoVersion~3, pgmHiVersion~3]; CrRPC.EnsureListener[class~$CMUX]; }...