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

⟦817522307⟧ TextFile

    Length: 6866 (0x1ad2)
    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 Errors;
with Files;
with Files;
with Interchange;
with Mac_Files;  
with Mac_Path;
with Mac_Types;
with Mac_Text;
with Memory;
with Osutils;
with Rational_Error;
with System;
with Talk_Utils;
with Text_Io;
use Text_Io;
with Unchecked_Conversion;
package body Copy_R is

    package Copy_F is

        procedure Link_In (Is_Link : Boolean);
        procedure From_Remote_File_In (Name : Mac_Text.Text);  
        procedure To_Remote_File_In (Name : Mac_Text.Text);
        procedure Options_In (Options : Mac_Text.Text);
        procedure End_Copy;

    end Copy_F;

    package body Copy_F is  
        Err : Mac_Types.Oserr := Mac_Types.Noerr;
        Link_It : Boolean;  
        From_File_Name : Mac_Types.Str255;

        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 Link_In (Is_Link : Boolean) is
        begin
            Err := Mac_Types.Noerr;
            Link_It := Is_Link;
        end Link_In;

        procedure From_Remote_File_In (Name : Mac_Text.Text) is
        begin
            From_File_Name := Mac_Text.Value (Name);
        end From_Remote_File_In;

        procedure To_Remote_File_In (Name : Mac_Text.Text) is
            To_File_Name : Mac_Types.Str255 := Mac_Text.Value (Name);
            From_Refnum, To_Refnum : Mac_Types.Integer;  
            Err2 : Mac_Types.Oserr;  
            Max_Length : constant Mac_Types.Longint := 4096;
            A_Ptr : Mac_Types.Ptr;  
            Count : Mac_Types.Longint;
        begin  
            if Link_It then
                Err := Errors.Ioerr;
            else
                Err := Mac_Files.Create_File (Name);
                Err := Files.Fsopen (To_File_Name, 0,
                                     As_Varinteger (To_Refnum'Address));
                if Err /= Mac_Types.Noerr then
                    return;
                end if;
                Err := Files.Fsopen (From_File_Name, 0,
                                     As_Varinteger (From_Refnum'Address));
                if Err /= Mac_Types.Noerr then
                    Err2 := Files.Fsclose (To_Refnum);
                    return;
                end if;
                A_Ptr := Memory.Newptr (Bytecount => Max_Length);
                if Mac_Types."=" (A_Ptr, null) then
                    Err := Errors.Memfullerr;
                    Err2 := Files.Fsclose (To_Refnum);
                    Err2 := Files.Fsclose (From_Refnum);
                    return;
                end if;
                loop
                    Count := Max_Length;
                    Err := Files.Fsread (From_Refnum,
                                         As_Varlongint (Count'Address), A_Ptr);  
                    Err2 := Files.Fswrite
                               (To_Refnum,
                                As_Varlongint (Count'Address), A_Ptr);
                    exit when Err /= Mac_Types.Noerr or Err2 /= Mac_Types.Noerr;
                end loop;  
                Memory.Disposptr (A_Ptr);  
                if Err2 /= Mac_Types.Noerr then
                    Err := Err2;
                end if;
                if Err /= Mac_Types.Noerr and Err /= Errors.Eoferr then
                    Err2 := Files.Fsclose (To_Refnum);
                    Err2 := Files.Fsclose (From_Refnum);
                    return;
                end if;  
                Err := Files.Fsclose (To_Refnum);
                Err2 := Files.Fsclose (From_Refnum);
                if Err2 /= Mac_Types.Noerr then
                    Err := Err2;
                end if;
            end if;
        end To_Remote_File_In;

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

        procedure End_Copy is
        begin  
            if Err /= Mac_Types.Noerr then
                Rational_Error.Raise_Mac_Error (Err);
            end if;
        end End_Copy;

    end Copy_F;

    procedure Read (A_Connection : in out Communications.Connection) is
        I : Mac_Types.Longint;
        B : Boolean;
        T : Mac_Text.Text (256);  
    begin  
        Put_Line ("copy_r:read begin");
        Interchange.Get_Int (A_Connection, I);
        if I /= Talk_Utils.F_Link then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;  
        Interchange.Get_Bool (A_Connection, B);
        Copy_F.Link_In (B);
        Interchange.Get_Int (A_Connection, I);
        if I /= Talk_Utils.F_From_Remote_File then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;  
        Interchange.Get_Text (A_Connection, T);
        Copy_F.From_Remote_File_In (T);
        Put ("copy_r:from 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_To_Remote_File then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;  
        Interchange.Get_Text (A_Connection, T);
        Copy_F.To_Remote_File_In (T);
        Put ("copy_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);
        Copy_F.Options_In (T);
        Interchange.Get_Int (A_Connection, I);
        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_Copy then
            Rational_Error.Raise_Error (Rational_Error.Internal_Error);
        end if;
        Put_Line ("copy_r:read end");

    end Read;

    procedure Write (A_Connection : in out Communications.Connection) is
    begin
        Put_Line ("copy_r:write begin");
        begin  
            Copy_F.End_Copy;
        exception
            when others =>
                Rational_Error.Report
                   (A_Connection, Talk_Utils.R_Copy, Rational_Error.Get);
        end;
        Interchange.Put_Int (A_Connection, Talk_Utils.F_Delimitor);
        Interchange.Put_Int (A_Connection, Talk_Utils.R_Copy);
        Put_Line ("copy_r:write end");
    end Write;

end Copy_R;