<> <> <> <> DIRECTORY CrRPC, TimeP15V2, AuthenticationP14V2, BulkDataP0V1, PrintingP4V3; PrintingP4V3ServerImpl: CEDAR PROGRAM IMPORTS CrRPC, PrintingP4V3 ~ { OPEN PrintingP4V3; GetPrintRequestStatusCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ { printRequestID: RequestID; status: RequestStatus; { FOR i42: CARDINAL IN [0..5) DO printRequestID[i42] _ CrRPC.GetCard16[s]; ENDLOOP; }; [status] _ GetPrintRequestStatus[h, printRequestID]; beginReturn[h]; { MProc43[h, s, status]; }; }; GetPrinterPropertiesCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ { properties: PrinterProperties; [properties] _ GetPrinterProperties[h]; beginReturn[h]; { MProc44[h, s, properties]; }; }; GetPrinterStatusCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ { status: PrinterStatus; [status] _ GetPrinterStatus[h]; beginReturn[h]; { MProc45[h, s, status]; }; }; 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 _ UProc46[h, s]; }; { printOptions _ UProc47[h, s]; }; [printRequestID] _ Print[h, master, printAttributes, printOptions]; beginReturn[h]; { FOR i48: CARDINAL IN [0..5) DO CrRPC.PutCard16[s, printRequestID[i48]]; ENDLOOP; }; }; Server: CrRPC.ServerProc ~ { <<[h: Handle, s: STREAM, pgm: CARD32, pgmVersion: CARD16, proc: CARD16, beginReturn: BeginReturnProc, beginError: BeginErrorProc, beginReject: BeginRejectProc]>> ENABLE { PrintingP4V3.TransferError => { -- (12 ) beginError[h, 12 ]; CrRPC.PutCard16[s, ORD[problem]]; GOTO Finished; }; PrintingP4V3.InsufficientSpoolSpace => { -- (1 ) beginError[h, 1 ]; GOTO Finished; }; PrintingP4V3.Busy => { -- (0 ) beginError[h, 0 ]; GOTO Finished; }; PrintingP4V3.SpoolingQueueFull => { -- (7 ) beginError[h, 7 ]; GOTO Finished; }; PrintingP4V3.SpoolingDisabled => { -- (6 ) beginError[h, 6 ]; GOTO Finished; }; PrintingP4V3.ConnectionError => { -- (11 ) beginError[h, 11 ]; CrRPC.PutCard16[s, ORD[problem]]; GOTO Finished; }; PrintingP4V3.MediumUnavailable => { -- (5 ) beginError[h, 5 ]; GOTO Finished; }; PrintingP4V3.InvalidPrintParameters => { -- (2 ) beginError[h, 2 ]; GOTO Finished; }; PrintingP4V3.Undefined => { -- (10 ) beginError[h, 10 ]; CrRPC.PutCard16[s, problem]; GOTO Finished; }; PrintingP4V3.SystemError => { -- (8 ) beginError[h, 8 ]; GOTO Finished; }; PrintingP4V3.MasterTooLarge => { -- (3 ) beginError[h, 3 ]; GOTO Finished; }; PrintingP4V3.ServiceUnavailable => { -- (4 ) beginError[h, 4 ]; 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 2 => GetPrintRequestStatusCaller[h, s, beginReturn]; 1 => GetPrinterPropertiesCaller[h, s, beginReturn]; 3 => GetPrinterStatusCaller[h, s, beginReturn]; 0 => PrintCaller[h, s, beginReturn]; ENDCASE => { beginReject[h, CrRPC.noSuchProcedure]; }; EXITS Finished => { NULL }; }; <> UProc46: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: PrintAttributes] ~ { { length50: CARDINAL ~ CrRPC.GetCard16[s]; res _ NEW[PrintAttributesObject[length50]]; FOR i49: CARDINAL IN [0..length50) DO res.body[i49] _ UProc51[h, s]; ENDLOOP; }; }; UProc47: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: PrintOptions] ~ { { length53: CARDINAL ~ CrRPC.GetCard16[s]; res _ NEW[PrintOptionsObject[length53]]; FOR i52: CARDINAL IN [0..length53) DO res.body[i52] _ UProc54[h, s]; ENDLOOP; }; }; MProc43: 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; }; UProc54: 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; }; }; MProc45: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: PrinterStatus] ~ { CrRPC.PutCard16[s, val.length]; FOR i60: CARDINAL IN [0..val.length) DO MProc61[h, s, val.body[i60]]; 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; }; MProc44: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: PrinterProperties] ~ { CrRPC.PutCard16[s, val.length]; FOR i63: CARDINAL IN [0..val.length) DO MProc64[h, s, val.body[i63]]; ENDLOOP; }; UProc51: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: Attribute] ~ { { tag65: AttributeKind ~ VAL[CrRPC.GetCard16[s]]; SELECT tag65 FROM printObjectName => { temp66: ROPE; temp66 _ CrRPC.GetRope[s]; res _ NEW[AttributeObject.printObjectName _ [printObjectName[temp66]]] }; printObjectCreateDate => { temp66: CARD32; temp66 _ CrRPC.GetCard32[s]; res _ NEW[AttributeObject.printObjectCreateDate _ [printObjectCreateDate[temp66]]] }; senderName => { temp66: ROPE; temp66 _ CrRPC.GetRope[s]; res _ NEW[AttributeObject.senderName _ [senderName[temp66]]] }; ENDCASE => ERROR; }; }; MProc61: 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; }; MProc64: 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; }; 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.RegisterServerProc[pgm~4, serverProc~Server, pgmVersion~3]; CrRPC.EnsureListener[class~$SPP]; }...