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

⟦872e2c494⟧ TextFile

    Length: 5263 (0x148f)
    Types: TextFile
    Names: »B«

Derivation

└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
    └─ ⟦d65440be7⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Communications;
with Files;
with Interchange;
with Mac_Files;  
with Mac_Path;
with Mac_Types;
with Mac_Text;
with Osutils;
with Rational_Error;
with System;
with Talk_Utils;
with Text_Io;
use Text_Io;
with Unchecked_Conversion;
package body Put_R is

    package Put_F is

        procedure Append_In (Must_Append : Boolean);
        procedure To_Remote_File_In (Name : Mac_Text.Text);
        procedure Content_In (Content : Mac_Text.Text);
        procedure Options_In (Options : Mac_Text.Text);
        procedure End_Put;

    end Put_F;

    package body Put_F is  
        Err : Mac_Types.Oserr := Mac_Types.Noerr;
        Append : Boolean;
        Refnum : Mac_Types.Integer;

        function As_Varinteger is new Unchecked_Conversion
                                         (Source => System.Address,
                                          Target => Mac_Types.Varinteger);

        function As_Varlongint is new Unchecked_Conversion
                                         (Source => System.Address,
                                          Target => Mac_Types.Varlongint);


        procedure Append_In (Must_Append : Boolean) is  
        begin
            Append := Must_Append;
        end Append_In;

        procedure To_Remote_File_In (Name : Mac_Text.Text) is
            S : Mac_Types.Str255 := Mac_Text.Value (Name);
        begin
            Err := Mac_Files.Create_File (Name);
            Err := Files.Fsopen (S, 0, As_Varinteger (Refnum'Address));
            if Err /= Mac_Types.Noerr then
                return;
            end if;
            if Append then
                Err := Files.Setfpos (Refnum, Files.Fsfromleof, 0);
            else
                Err := Files.Seteof (Refnum, 0);
            end if;
        end To_Remote_File_In;

        procedure Content_In (Content : Mac_Text.Text) is
            Length : Mac_Types.Longint;
        begin  
            Length := Mac_Text.Length (Content);
            if Err = Mac_Types.Noerr then
                Err := Files.Fswrite (Refnum, As_Varlongint (Length'Address),
                                      Mac_Text.As_Ptr (Content));
            end if;
        end Content_In;

        procedure Options_In (Options : Mac_Text.Text) is
        begin
            null;
        end Options_In;

        procedure End_Put is
            L : Mac_Types.Longint;
        begin  
            if Err = Mac_Types.Noerr then
                if (Files.Getfpos (Refnum, As_Varlongint (L'Address)) =
                    Mac_Types.Noerr) then
                    Err := Files.Seteof (Refnum, L);
                end if;
                Err := Files.Fsclose (Refnum);
            end if;
            if Err /= Mac_Types.Noerr then
                Rational_Error.Raise_Mac_Error (Err);
            end if;
        end End_Put;
    end Put_F;

    procedure Read (A_Connection : in out Communications.Connection) is
        I : Mac_Types.Longint;
        B : Boolean;
        T : Mac_Text.Text (256);  
        Buffer : Mac_Text.Text (2010);
    begin
        Put_Line ("put_r:read begin");
        Interchange.Get_Int (A_Connection, I);
        if I /= Talk_Utils.F_Append then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;
        Interchange.Get_Bool (A_Connection, B);
        Put_F.Append_In (B);
        Put ("put_r:append: ");
        Put_Line (Boolean'Image (B));
        Interchange.Get_Int (A_Connection, I);
        if I /= Talk_Utils.F_To_Remote_File then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;
        Interchange.Get_Text (A_Connection, T);
        Put_F.To_Remote_File_In (T);
        Put ("put_r:to file '");
        for I in 1 .. Mac_Text.Length (T) loop
            Put (Character'Val (Mac_Types.Char'Pos (Mac_Text.Value (I, T))));
        end loop;
        Put_Line ("'");
        Interchange.Get_Int (A_Connection, I);
        if I /= Talk_Utils.F_Options then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;
        Interchange.Get_Text (A_Connection, T);
        Put_F.Options_In (T);
        Interchange.Get_Int (A_Connection, I);
        while I = Talk_Utils.F_Content loop  
            Interchange.Get_Text (A_Connection, Buffer);
            Put_F.Content_In (Buffer);
            Interchange.Get_Int (A_Connection, I);
        end loop;
        if I /= Talk_Utils.F_Delimitor then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;
        Interchange.Get_Int (A_Connection, I);
        if I /= Talk_Utils.R_Put then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;
        Put_Line ("put_r:read end");
    end Read;

    procedure Write (A_Connection : in out Communications.Connection) is
    begin
        Put_Line ("put_r:write begin");
        begin
            Put_F.End_Put;
        exception
            when others =>
                Rational_Error.Report
                   (A_Connection, Talk_Utils.R_Put, Rational_Error.Get);
        end;
        Interchange.Put_Int (A_Connection, Talk_Utils.F_Delimitor);
        Interchange.Put_Int (A_Connection, Talk_Utils.R_Put);  
        Put_Line ("put_r:write end");
    end Write;

end Put_R;