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 - download
Index: ┃ B T

⟦d734f3ecf⟧ TextFile

    Length: 3776 (0xec0)
    Types: TextFile
    Names: »B«

Derivation

└─⟦d10a02448⟧ Bits:30000409 8mm tape, Rational 1000, ENVIRONMENT, D_12_7_3
    └─ ⟦fc9b38f02⟧ »DATA« 
        └─⟦9b46a407a⟧ 
            └─⟦12c68c704⟧ 
                └─⟦this⟧ 
└─⟦5f3412b64⟧ Bits:30000745 8mm tape, Rational 1000, ENVIRONMENT 12_6_5 TOOLS 
    └─ ⟦91c658230⟧ »DATA« 
        └─⟦458657fb6⟧ 
            └─⟦220843204⟧ 
                └─⟦this⟧ 

TextFile

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

procedure Display_Queue (Printer : String := "<Default>") 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 passed value
            return Printer;
        end;
    exception
        when Io_Exceptions.Name_Error =>
            -- map file does not exist!
            return Printer;
    end Get_Queue_Class;

begin
    Queue.Display (Get_Queue_Class);
end Display_Queue;