DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

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

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦fdd802039⟧ Ada Source

    Length: 9216 (0x2400)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, procedure Cancel_Print_Request, seg_006329

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



with Io;
with Io_Exceptions;
with String_Utilities;
with System_Utilities;
with Queue;
with Remote;

procedure Cancel_Print_Request
             (Printer : String := "<Default>"; Request_Id : Positive) is

    package Strings renames String_Utilities;

    Map_Filename : constant String := "!Machine.Queues.User_To_Printer_Map";

    function Eq (A, B : String; Ignore_Case : Boolean := True) return Boolean
        renames Strings.Equal;

    function Get_Queue_Class return String is

        F : Io.File_Type;

        Next : Integer;


        function Match (Pattern, Name : String) return Boolean is
        begin
            if Name'Length /= 0 and then Name (Name'First) = '*' then
                return Eq (Pattern, Name);
            elsif Eq (Pattern, "others") then
                return True;
            elsif Pattern = "@" then
                return True;
            else
                return Eq (Pattern, Name);
            end if;
        end Match;


        function Get_User_Printer (Printer : String) return String is
            -- given the global printer parameter which is either <default> or
            -- a printer name, return the string to search for in the user
            -- to printer map file.  If <default> this is the user name,
            -- else it is the value of the parameter prefixed with an "*".
        begin
            if Eq (Printer, "<Default>") then
                return System_Utilities.User_Name;
            elsif Eq (Printer, "Others") then
                return Printer;
            else
                return "*" & Printer;
            end if;
        end Get_User_Printer;


        function Token (S : String) return String is
            Start, Stop : 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
                if Next > S'Last then
                    Stop := S'Last;
                else -- S (Next) = ' '
                    Stop := Next - 1;
                end if;
                return S (Start .. Stop);
            else
                return "";
            end if;
        end Token;

    begin
        -- Find printer information in the user printer map
        declare
            User : constant String := Get_User_Printer (Printer);
        begin
            Io.Open (F, Io.In_File, Map_Filename);
            while not Io.End_Of_File (F) loop
                Next := -1;
                declare
                    Line       : constant String := Io.Get_Line (F);
                    User_Name  : constant String := Token (Line);
                    Class_Name : constant String := Token (Line);
                begin
                    if User_Name'Length < 2 or else
                       User_Name (User_Name'First .. User_Name'First + 1) /=
                          "--" then
                        if Match (User_Name, User) then
                            Io.Close (F);
                            return Class_Name;
                        end if;
                    end if;
                end;
            end loop;
            -- Didn't find a match!
            Io.Close (F);
            -- Therefore return the passed value
            return Printer;
        end;
    exception
        when Io_Exceptions.Name_Error =>
            -- map file does not exist!
            return Printer;
    end Get_Queue_Class;


    function Is_Remote_Name (Name : String) return Boolean is  begin
        return Name'Length >= 2 and then
                  Name (Name'First .. Name'First + 1) = "!!";
    end Is_Remote_Name;


begin
    declare
        Printer_Class : constant String := Get_Queue_Class;
    begin
        if Is_Remote_Name (Printer_Class) then
            declare
                Machine_Start : Natural := Strings.Locate
                                              ("!!", Printer_Class, True) + 2;
                Machine_End   : Natural := Strings.Locate
                                              (".", Printer_Class, True) - 1;
                Machine_Name  : constant String :=
                   Printer_Class (Machine_Start .. Machine_End);
            begin
                Remote.Run (Machine => Machine_Name,
                            Command => "Queue.Cancel(Request_Id =>" &
                                          Positive'Image (Request_Id) & ");",
                            File_Context => "!Machine",
                            Run_Context => "!Machine",
                            Options => "",
                            Response => "<PROGRESS>");
            end;
        else
            Queue.Cancel (Request_Id => Request_Id);
        end if;
    end;
end Cancel_Print_Request;

E3 Meta Data

    nblk1=8
    nid=0
    hdr6=10
        [0x00] rec0=24 rec1=00 rec2=01 rec3=016
        [0x01] rec0=1b rec1=00 rec2=02 rec3=038
        [0x02] rec0=1d rec1=00 rec2=03 rec3=040
        [0x03] rec0=00 rec1=00 rec2=08 rec3=00c
        [0x04] rec0=1b rec1=00 rec2=04 rec3=002
        [0x05] rec0=00 rec1=00 rec2=07 rec3=002
        [0x06] rec0=17 rec1=00 rec2=05 rec3=01e
        [0x07] rec0=09 rec1=00 rec2=06 rec3=000
    tail 0x21701a24a81bf7f7c7f02 0x42a00088462065003