DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦964fa1f0b⟧ TextFile

    Length: 6621 (0x19dd)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

with Io;
with Queue;
with Transport;
with Transport_Defs;
with Transport_Name;
with Debug_Tools;
with Error_Reporting;
with Program;

procedure Initialize_Print_Spooler
             (Config_File : String := "!Machine.Printer_Configuration";
              Start_Server : Boolean := True) is

-- Rational internal print spooler initialization
-- Can be used as customer model if desired.
--
--  File format:
-- Line => "--" comment
-- Line => Printer_Net_Id Class Device Options ("--" comment)?
--
begin
    if Start_Server then
        begin
            Program.Run_Job
               (Program.Current
                   ("!Tools.Rpc_Servers", "Queue_Service.Start",
                    Activity => "!Machine.Release.Current.Activity"),
                Context => "!Machine.Error_Logs",
                Options =>
                   "Output = !Machine.Error_Logs.Queue_Server_Output, " &
                      "Error = !Machine.Error_Logs.Queue_Server_Error, " &
                      "User = Network_Public, Password = (), " &
                      "Name =>(Print Queue Server)");
        exception
            when others =>
                Error_Reporting.Report_Error
                   (Caller => "!Machine.Initialize_Servers.Queue_Service.Start",
                    Reason => Error_Reporting.Create_Condition_Name
                                 ("Unhandled_Exception",
                                  Error_Reporting.Problem),
                    Explanation => Debug_Tools.Get_Exception_Name (True, True));
        end;
    end if;


    -- Load the configuration file and set up devices, etc.
    declare
        F : Io.File_Type;
        Next : Integer := -1;

        function Check_Star (S : String) return Boolean is
        begin
            if Next = -1 then
                Next := S'First; -- tricky initialization
            end if;
            -- skip leading blanks
            while Next < S'Last and then S (Next) = ' ' loop
                Next := Next + 1;
            end loop;
            -- on first non-blant
            if S (Next) = '*' then
                Next := Next + 1;
                return True;
            else
                return False;
            end if;
        end Check_Star;

        function Token (S : String) return String is
            Start : Natural;
        begin
            if Next = -1 then
                Next := S'First; -- tricky initialization
            end if;
            Start := Next;
            -- skip leading blanks
            while Start < S'Last and then S (Start) = ' ' loop
                Start := Start + 1;
            end loop;
            Next := Start;
            while Next <= S'Last and then S (Next) /= ' ' loop
                Next := Next + 1;
            end loop;
            if Start < S'Last then
                return S (Start .. Next - 1);
            else
                return "";
            end if;
        end Token;

        function Eq (A, B : Transport_Defs.Host_Id) return Boolean is
        begin
            --io.put_line ("Comparing: " & str
            return Transport_Defs."=" (Transport_Defs.Normalize (A),
                                       Transport_Defs.Normalize (B));
        end Eq;

        procedure Set_File_Contents (File : String; Contents : String) is
            F : Io.File_Type;
        begin
            Io.Create (F, Io.Out_File, File);
            Io.Put_Line (F, Contents);
            Io.Close (F);
        exception
            when others =>
                Io.Put_Line ("Exception creating " & File & "; " &
                             Debug_Tools.Get_Exception_Name);
        end Set_File_Contents;

    begin  
        Io.Set_Error (Io.Current_Output);
        Queue.Restart_Print_Spooler;
        Io.Open (F, Io.In_File, Config_File);
        while not Io.End_Of_File (F) loop
            Next := -1;
            declare
                Line : constant String := Io.Get_Line (F);
                Is_Default : Boolean := Check_Star (Line);
                Net_Id : constant String := Token (Line);
                Class : constant String := Token (Line);
                Device : constant String := Token (Line);
                Options : constant String := Token (Line);
                Class_File : constant String := Token (Line);
            begin
                Io.Put_Line ("Processing: " & Line);  
                if Net_Id'Length >= 2 and then
                   Net_Id (Net_Id'First .. Net_Id'First + 1) /= "--" then
                    -- check if this machine matches the specified host
                    if Eq (Transport_Name.Host_To_Host_Id (Net_Id),
                           Transport.Local_Host ("tcp/ip")) then
                        -- This machine should have a connection
                        Io.Put_Line ("Deleting: may result in errors");
                        Queue.Disable (Device, Immediate => True);
                        Queue.Destroy (Class);  -- try to clean up first
                        Queue.Remove (Device, Immediate => True);

                        Io.Put_Line ("Defining classes");
                        Queue.Create (Class);
                        Queue.Add (Device, Options);
                        Queue.Register (Device, Class);
                        Queue.Enable (Device);
                        -- Set the class for this device
                        Set_File_Contents (Class_File, Class);
                        if Is_Default then
                            Queue.Default (Class);
                            Is_Default := False;
                        end if;
                    else
                        -- remote reference
                        if Is_Default then
                            Queue.Default ("!!" & Net_Id & "." & Class);
                            Is_Default := False;
                        end if;
                        Set_File_Contents (Class_File,
                                           "!!" & Net_Id & "." & Class);
                    end if;  
                end if;
            end;
        end loop;  
        Io.Close (F);
        Queue.Display;
        Queue.Classes;
        Queue.Devices;
    exception
        when others =>
            Error_Reporting.Report_Error
               (Caller => "!Machine.Initialize_Print_Spooler.Configuration",
                Reason => Error_Reporting.Create_Condition_Name
                             ("Unhandled_Exception", Error_Reporting.Problem),
                Explanation => Debug_Tools.Get_Exception_Name (True, True));
    end;


    --Queue.Print ("!machine.machine_name");

end Initialize_Print_Spooler;