<> <> <> <<>> <> DIRECTORY BootSwitch USING [promptForInitializationParameters, Set], Environment USING [PageCount], Heap USING [Create, FreeNode, MakeNode], Message USING [Expand, StringArray], MiscUtilities USING [CalcPagesForBandBuffers, CalcRMPagesForMarker, pagesPerBandBuffer], NetMgtServiceSupport USING [UnRegisterService], NSExec USING [AddClientCommands, BroadcastAsyncMessage, ClientID, ClientStatus, Command, DestroyClient, Error, ExecProc, GetTTY, Handle, localExec, OutputHandle, Predicate, Run, StopMode, SystemFilingSession, UserAServerSA, UserLoggedOn, UserName, WorkingDirectory], NSFile USING [Attributes, AttributesProc, DeleteByName, Error, GetAttributesByName, GetAttributesRecord, Handle, List, noSelections, ReleaseAttributesRecord, Selections, Session], NSName USING [Name, NameRecord, nullNameRecord], NSString USING [EquivalentStrings, FreeString, nullString, String, StringFromMesaString], PaperTypes USING [PaperMMDimension], PrintingTypes USING [Option, RavenBuild], ProductFactoring USING [Enabled], PS USING [bansheeConfigName, d1ConfigName, faxConfigName, fepsConfigName, fx3500ConfigName, ravenConfigName, reservedMemSaved], PSAsyncMsg USING [nullInsertArray, nullMsg, Proc], PSCommand USING [GetPrintServiceActivity, GetPrintServiceStatus, RegisterAsyncMessageProc, Start, Stop, StopPrinting, StopQueuing], PSCommandExtras USING [ServiceState], PSExec USING [GetClientID], PSExecInternal, PSExecMessages USING [Key], PSInit USING [calculateDefaultBBAllocation, calculateDefaultRMAllocation, ExpungePrintService, InitializePrintService, InitializeState, OptionalParms, RequiredParms, unlimitedPrintingCutOffMemSize], PSKMessages USING [DestroyMsgs, GetHandle], PSState USING [CurrentActivity, StateHandle], Runtime USING [VersionMismatch], ServicesError USING [Catch, Caught, SetCatching], ServicesPFOptions USING [psFax, psLowSpeed], ServicesPFOptionsExtrasExtras USING [psFormatting, psLaserCP], SpecialSpace USING [realMemorySize], String USING [AppendLongDecimal], TextInput USING [ChoiceIndex, Confirm, GetChoice, GetLongDecimal, GetTimedYesNo, nilChoice, nilDecimal, nilLongDecimal, nilYesNo], Time USING [Unpack, Unpacked], TTY USING [Handle, Rubout], XFormat USING [Blanks, Handle, NSLine, NSString], XMessage USING [Get, Handle, MsgKey], XString USING [ReaderBody]; PSExecInitImpl: CEDAR PROGRAM IMPORTS BootSwitch, Heap, Message, MiscUtilities, NetMgtServiceSupport, NSExec, NSFile, NSString, ProductFactoring, PS, PSCommand, PSCommandExtras, PSExec, PSExecInternal, PSInit, PSKMessages, Runtime, ServicesError, String, SpecialSpace, TextInput, Time, TTY, XFormat, XMessage EXPORTS PSExecInternal SHARES XString = BEGIN NonNormalInitType: TYPE = {configure, deleteBackingFiles}; execHeap: PUBLIC UNCOUNTED ZONE _ Heap.Create[initial: 4]; --Heap used by PSExec*Impls for miscellaneous strings, etc; exported by PSExecInternal. developmentMode: PUBLIC BOOLEAN _ BootSwitch.Set[BootSwitch.promptForInitializationParameters]; <> psClientID: NSExec.ClientID _ PSExec.GetClientID[]; <> execMsgs: XMessage.Handle _ PSKMessages.GetHandle[exec]; <<************************************************>> <> <> <> <> <<************************************************>> Initialize: PUBLIC PROCEDURE [exec: NSExec.Handle, normal: BOOLEAN] = BEGIN nonNormalInit: NonNormalInitType _ configure; engineFakerName: NSString.String = Str["EngineFakerConfig.bcd"L]; <> runningInTajo: BOOLEAN _ NSString.EquivalentStrings[PS.ravenConfigName, engineFakerName]; outputHandle: XFormat.Handle _ NSExec.OutputHandle[exec]; printingOption, oldPrintingOption: PrintingTypes.Option _ unknown; state: PSState.StateHandle _ NIL; newOptionChosen: BOOLEAN _ FALSE; printServiceName: NSName.Name _ NIL; requiredParms: PSInit.RequiredParms _ [printingOptionParms: unknown[]]; optionalParms: PSInit.OptionalParms _ [printingOptionParms: unknown[]]; DevelopmentModeInit: PROCEDURE = BEGIN <> <> <> <<>> defaultVMPagesForDecomposer: LONG CARDINAL _ IF newOptionChosen THEN 6000 ELSE state.decomposerVMPages; defaultDecomposerRMPageLimit: LONG CARDINAL _ IF newOptionChosen THEN PSInit.calculateDefaultRMAllocation ELSE state.decomposerRMPagesForMarker; <> <> defaultSpoolWhileMarking: BOOLEAN _ IF newOptionChosen THEN TRUE ELSE state.spoolWhileMarking; defaultBandBufferPages: LONG CARDINAL _ IF newOptionChosen THEN PSInit.calculateDefaultBBAllocation ELSE state.markerRMPagesForBands; defaultDecomposeWhileMarking: BOOLEAN _ IF newOptionChosen THEN TRUE ELSE state.decomposeWhileMarking; IF normal THEN <> SELECT printingOption FROM bansheeDl => optionalParms _ [ vmPagesForDecomposer: defaultVMPagesForDecomposer, bandBufferPages: defaultBandBufferPages, decomposerRMPageLimit: defaultDecomposerRMPageLimit, deleteIncompatibleFontsandTPs: TRUE, printingOptionParms: bansheeDl[ spoolWhileMarking: defaultSpoolWhileMarking, decomposeWhileMarking: defaultDecomposeWhileMarking] ]; d1 => optionalParms _ [ vmPagesForDecomposer: defaultVMPagesForDecomposer, bandBufferPages: defaultBandBufferPages, decomposerRMPageLimit: defaultDecomposerRMPageLimit, deleteIncompatibleFontsandTPs: TRUE, printingOptionParms: d1[ spoolWhileMarking: defaultSpoolWhileMarking, decomposeWhileMarking: defaultDecomposeWhileMarking] ]; fax295 => optionalParms _ [ vmPagesForDecomposer: defaultVMPagesForDecomposer, bandBufferPages: defaultBandBufferPages, decomposerRMPageLimit: defaultDecomposerRMPageLimit, deleteIncompatibleFontsandTPs: TRUE, printingOptionParms: fax295[ spoolWhileMarking: defaultSpoolWhileMarking, decomposeWhileMarking: defaultDecomposeWhileMarking] ]; fax495 => optionalParms _ [ vmPagesForDecomposer: defaultVMPagesForDecomposer, bandBufferPages: defaultBandBufferPages, decomposerRMPageLimit: defaultDecomposerRMPageLimit, deleteIncompatibleFontsandTPs: TRUE, printingOptionParms: fax495[ spoolWhileMarking: defaultSpoolWhileMarking, decomposeWhileMarking: defaultDecomposeWhileMarking] ]; feps9700 => optionalParms _ [ vmPagesForDecomposer: defaultVMPagesForDecomposer, bandBufferPages: defaultBandBufferPages, decomposerRMPageLimit: defaultDecomposerRMPageLimit, deleteIncompatibleFontsandTPs: TRUE, printingOptionParms: feps9700[]]; fx3500 => optionalParms _ [ vmPagesForDecomposer: defaultVMPagesForDecomposer, bandBufferPages: defaultBandBufferPages, decomposerRMPageLimit: defaultDecomposerRMPageLimit, deleteIncompatibleFontsandTPs: TRUE, printingOptionParms: fx3500[ spoolWhileMarking: defaultSpoolWhileMarking, decomposeWhileMarking: defaultDecomposeWhileMarking] ]; raven => optionalParms _ [ vmPagesForDecomposer: defaultVMPagesForDecomposer, bandBufferPages: defaultBandBufferPages, decomposerRMPageLimit: defaultDecomposerRMPageLimit, deleteIncompatibleFontsandTPs: TRUE, printingOptionParms: raven[ spoolWhileMarking: defaultSpoolWhileMarking, decomposeWhileMarking: defaultDecomposeWhileMarking] ]; ENDCASE => ERROR ELSE BEGIN << For NON-NORMAL STARTUP IN DEVELOPMENT MODE>> <> SELECT printingOption FROM bansheeDl => optionalParms _ GetOptionalBansheeInitParms[ exec, requiredParms, defaultVMPagesForDecomposer, defaultDecomposerRMPageLimit, defaultSpoolWhileMarking, defaultDecomposeWhileMarking, defaultBandBufferPages]; d1 => optionalParms _ GetOptionalD1InitParms[exec, defaultVMPagesForDecomposer, defaultDecomposerRMPageLimit, defaultSpoolWhileMarking, defaultDecomposeWhileMarking, defaultBandBufferPages]; fax295 => optionalParms _ GetOptionalFax295InitParms[exec, defaultVMPagesForDecomposer, defaultDecomposerRMPageLimit, defaultSpoolWhileMarking, defaultDecomposeWhileMarking, defaultBandBufferPages]; fax495 => optionalParms _ GetOptionalFax495InitParms[exec, defaultVMPagesForDecomposer, defaultDecomposerRMPageLimit, defaultSpoolWhileMarking, defaultDecomposeWhileMarking, defaultBandBufferPages]; feps9700 => optionalParms _ GetOptionalFEPS9700InitParms[ exec, defaultVMPagesForDecomposer, defaultDecomposerRMPageLimit, defaultBandBufferPages]; fx3500 => optionalParms _ GetOptionalFX3500InitParms[exec, defaultVMPagesForDecomposer, defaultDecomposerRMPageLimit, defaultSpoolWhileMarking, defaultDecomposeWhileMarking, defaultBandBufferPages]; raven => optionalParms _ GetOptionalRavenInitParms[ exec, requiredParms, defaultVMPagesForDecomposer, defaultDecomposerRMPageLimit, defaultSpoolWhileMarking, defaultDecomposeWhileMarking, defaultBandBufferPages]; ENDCASE => ERROR; END; END; --DevelopmentModeInit <<*********** MAINLINE OF INITIALIZE ************-->> IF ~ProductFactoring.Enabled[ServicesPFOptions.psLowSpeed] AND ~ProductFactoring.Enabled[ServicesPFOptions.psFax] AND ~ProductFactoring.Enabled[ServicesPFOptionsExtrasExtras.psFormatting] AND ~ProductFactoring.Enabled[ServicesPFOptionsExtrasExtras.psLaserCP] THEN BEGIN outputHandle.NSLine[M[mCannotRunPS]]; outputHandle.NSLine[M[mPSNotProductFactored]]; ERROR NSExec.Error[cannotInitialize]; END; IF NOT PS.reservedMemSaved THEN BEGIN outputHandle.NSLine[M[mCannotRunPS]]; outputHandle.NSLine[M[mMemoryNotAvailable]]; outputHandle.NSLine[M[mMeans]]; outputHandle.Blanks[8]; outputHandle.NSLine[M[mDeactivated]]; outputHandle.Blanks[8]; outputHandle.NSLine[M[mActivate]]; outputHandle.Blanks[8]; outputHandle.NSLine[M[mMemoryTaken]]; outputHandle.Blanks[8]; outputHandle.NSLine[M[mRunBeforeOtherServices]]; ERROR NSExec.Error[cannotInitialize]; END; IF NOT normal THEN BEGIN nonNormalInit _ GetNonNormalInitType[exec]; IF nonNormalInit = deleteBackingFiles THEN BEGIN outputHandle.Blanks[8]; outputHandle.NSString[M[mDeletingFiles]]; PSInit.ExpungePrintService[deleteFonts: FALSE]; outputHandle.NSString[M[mFloppyDone]]; END; END; PSInit.InitializeState[]; state _ PSCommand.GetPrintServiceStatus[]; oldPrintingOption _ state.option; <> IF normal AND developmentMode THEN normal _ TextInput.GetTimedYesNo[ tty: NSExec.GetTTY[exec], prompt: M[mRetainParameters], timeAllotted: 10 --seconds--, valueIfTimedOut: yes] = yes; <<****** NOTE: Remove this code in a later release ******>> DeleteObsoleteBcds[workingDir: NSExec.WorkingDirectory[], session: NSExec.SystemFilingSession[]]; printingOption _ GetPrintingOption[exec, normal, state, runningInTajo]; IF NOT runningInTajo THEN IF NOT LoadAndRunPrintingOptionBcd[exec, printingOption] THEN ERROR NSExec.Error[cannotInitialize]; newOptionChosen _ printingOption # oldPrintingOption; requiredParms _ SELECT printingOption FROM bansheeDl => GetRequiredBansheeInitParms[exec, normal, state, newOptionChosen], d1 => [printingOptionParms: d1[]], --no required parms for d1 fax295 => GetRequiredFax295InitParms[exec, normal, state, newOptionChosen], fax495 => GetRequiredFax495InitParms[exec, normal, state, newOptionChosen], feps9700 => [printingOptionParms: feps9700[]], --no required parms for feps9700 fx3500 => [printingOptionParms: fx3500[]], --no required parms for fx3500 ENDCASE => GetRequiredRavenInitParms[exec, normal, state, newOptionChosen]; IF newOptionChosen THEN requiredParms.newParametersSpecified _ TRUE; <> <> IF developmentMode THEN DevelopmentModeInit[]; --this proc sets the optional parameters [, printServiceName] _ PSExecInternal.RegisterServiceAtClearinghouse[exec]; PSCommand.RegisterAsyncMessageProc[PutAsyncMessage]; --This is called before calling Initialize, since Initialize may generate some asynchronous messages. PSInit.InitializePrintService[normal, printServiceName, requiredParms, optionalParms]; RegisterCommands[]; <> IF newOptionChosen THEN SetInitialState[oldOption: oldPrintingOption, newOption: printingOption]; <> IF NOT normal THEN StopQueuingAndPrintingAbnormal[exec]; Start[exec]; --Call start proc. END; --Initialize Start: PUBLIC NSExec.ExecProc = {PSCommand.Start[]}; Stop: PUBLIC PROCEDURE [exec: NSExec.Handle, stopMode: NSExec.StopMode] = BEGIN <> ENABLE BEGIN TTY.Rubout => GOTO Exit; NSExec.Error => IF type = invalidExec THEN GOTO Exit; END; IF stopMode = quiesce AND RepairMode[] THEN IF TextInput.GetTimedYesNo [ tty: NSExec.GetTTY[exec], prompt: M[mPrintServerinRepairMode], timeAllotted: 60--seconds--, valueIfTimedOut: no] = no THEN RETURN; PSCommand.Stop[]; EXITS Exit => NULL; END; --Stop Expunge: PUBLIC NSExec.ExecProc = BEGIN servicesWorkDir: NSFile.Handle _ NSExec.WorkingDirectory[]; servicesSession: NSFile.Session _ NSExec.SystemFilingSession[]; IF TextInput.Confirm[NSExec.GetTTY[exec], M[mExpungeWarning]] THEN BEGIN [] _ PSExecInternal.DeleteServiceFromClearinghouse[exec]; PSInit.ExpungePrintService[deleteFonts: TRUE]; PSKMessages.DestroyMsgs[]; NetMgtServiceSupport.UnRegisterService[psClientID]; NSExec.DestroyClient[psClientID]; END ELSE ERROR NSExec.Error[cannotExpunge]; END; --Expunge Name: PUBLIC PROCEDURE [nameProc: PROCEDURE [clientName: NSString.String]] = BEGIN IF PSExecInternal.printServiceName # NIL THEN nameProc[PSExecInternal.printServiceName.local] ELSE nameProc[M[mNull]]; END; --Name Status: PUBLIC PROCEDURE [ statusProc: PROCEDURE [status: NSExec.ClientStatus, comment: NSString.String]] = BEGIN statusProc[status: SELECT PSCommandExtras.ServiceState[] FROM starting => starting, stopped => stopped, stopping => stopping, ENDCASE => started, comment: NSString.nullString]; END; --Status PrintServiceCommand: PUBLIC NSExec.ExecProc = BEGIN --called whenever "Print Service" command is entered END; --PrintServiceCommand <<================================================>> <> <<================================================>> <<**** NON NORMAL INIT TYPE ****>> GetNonNormalInitType: PROCEDURE [exec: NSExec.Handle] RETURNS [type: NonNormalInitType] = BEGIN DO type _ PromptForNonNormalInitType[exec]; SELECT type FROM configure => EXIT; deleteBackingFiles => IF TextInput.Confirm[ NSExec.GetTTY[exec], M[mConfirmDeleteBackingFiles]] THEN EXIT; ENDCASE; ENDLOOP; END; -- GetNonNormalInitType <<**** ENGINE TYPE ****>> GetPrintingOption: PROCEDURE [exec: NSExec.Handle, normal: BOOLEAN, state: PSState.StateHandle, runningInTajo: BOOLEAN] RETURNS [option: PrintingTypes.Option] = <