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

⟦aef66b6c0⟧ TextFile

    Length: 14460 (0x387c)
    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 File_Transfer;
with Ftp_Defs;
with Transport_Defs;
with Transport_Name;
with Profile;
with Log;
with String_Utilities;

package body Ftp_Interface is

    function Indicates_Success (Status : Ftp_Defs.Status_Code) return Boolean is
    begin
        return Status in Ftp_Defs.Successful .. Ftp_Defs.Transfer_Complete;
    end Indicates_Success;

    function Indicates_Success
                (Status : Ftp_Defs.Transfer_Status) return Boolean is
    begin
        return Ftp_Defs."=" (Status, Ftp_Defs.Ok);
    end Indicates_Success;

    procedure Write_To_Log (Item : String;
                            Do_Write : Boolean;
                            Msg_Class : Profile.Msg_Kind;
                            Response : Profile.Response_Profile) is
    begin
        if Do_Write then
            Log.Put_Line (Item, Msg_Class, Response);
        end if;
    end Write_To_Log;

    function Command_Status (Connection : File_Transfer.Connect_Id;
                             Log_It : Boolean;
                             Response : Profile.Response_Profile)
                            return Ftp_Defs.Status_Code is
        Message : String (1 .. 128);
        Length : Natural;
        Status : Ftp_Defs.Status_Code;
    begin
        if Log_It then
            while not File_Transfer.End_Of_Response (Connection) loop
                File_Transfer.Read_Response (Connection, Message, Length);
                Write_To_Log (Message (1 .. Length), True,
                              Profile.Note_Msg, Response);
            end loop;
        end if;

        File_Transfer.Command_Status (Connection, Status);
        return Status;
    end Command_Status;

    procedure Open (Chan : out Channel;
                    To_Machine : String;
                    Status : out Ftp_Defs.Status_Code;
                    Log_Responses : Boolean := False;
                    Response : Profile.Response_Profile := Profile.Get) is
        Connection : File_Transfer.Connect_Id;
        The_Status : Transport_Defs.Status_Code;
    begin
        Status := Ftp_Defs.Successful;
        File_Transfer.Open (Connection, The_Status);

        if Transport_Defs."/=" (The_Status, Transport_Defs.Ok) then
            Write_To_Log ("Bad open status: " &
                          Transport_Defs.Image (The_Status),
                          Log_Responses, Profile.Error_Msg, Response);
            Status := Ftp_Defs.Network_Error;

        end if;
        Chan := Channel (Connection);

    end Open;

    procedure Connect (Chan : in out Channel;
                       To_Machine : String;
                       For_User : String;
                       With_Password : String;
                       Status : out Ftp_Defs.Status_Code;
                       Log_Responses : Boolean := False;
                       Response : Profile.Response_Profile := Profile.Get) is
        The_Status : Transport_Defs.Status_Code;
        Cmd_Status : Ftp_Defs.Status_Code;
        Host_Id : constant Transport_Defs.Host_Id :=
           Transport_Name.Host_To_Host_Id (To_Machine);
        Connection : File_Transfer.Connect_Id :=
           File_Transfer.Connect_Id (Chan);
    begin
        File_Transfer.Connect (Connection, Host_Id);
        Cmd_Status := Command_Status (Connection, Log_Responses, Response);

        if Ftp_Defs."/=" (Cmd_Status, Ftp_Defs.Successful) then
            Write_To_Log ("Connect failed - " &
                          Ftp_Defs.Status_Code'Image (Cmd_Status),
                          Log_Responses, Profile.Error_Msg, Response);
            Status := Cmd_Status;
            File_Transfer.Close (Connection);
            Chan := Channel (Connection);
            return;
        end if;

        File_Transfer.Send_Username (Connection, For_User);
        Cmd_Status := Command_Status (Connection, Log_Responses, Response);

        case Cmd_Status is
            when Ftp_Defs.Successful =>
                Status := Cmd_Status;
                Chan := Channel (Connection);
            when Ftp_Defs.Need_Password =>

                File_Transfer.Send_Password (Connection, With_Password);
                Cmd_Status :=

                   Command_Status (Connection, Log_Responses, Response);
                Status := Cmd_Status;

                if Ftp_Defs."/=" (Cmd_Status, Ftp_Defs.Successful) and then
                   String_Utilities.Equal (To_Machine, "LOGO",
                                           Ignore_Case => True) and then
                   String_Utilities.Equal (For_User, "RATNET",
                                           Ignore_Case => True) and then
                   not String_Utilities.Equal
                          (With_Password, "star\tree", Ignore_Case => True) then

                    File_Transfer.Send_Quit (Connection);
                    Cmd_Status := Command_Status (Connection, False,
                                                  Profile.Default_Profile);

                    if Ftp_Defs."/=" (Cmd_Status, Ftp_Defs.Successful) then
                        File_Transfer.Disconnect (Connection);
                    end if;

                    delay 5.0;
                    Chan := Channel (Connection);
                    Connect (Chan, To_Machine, For_User,
                             With_Password => "star\tree",
                             Status => Status,
                             Log_Responses => Log_Responses,
                             Response => Response);

                    return;
                end if;

                if Ftp_Defs."/=" (Cmd_Status, Ftp_Defs.Successful) then

                    Write_To_Log ("Connection failed - sending password - " &
                                  Ftp_Defs.Status_Code'Image (Cmd_Status),
                                  Log_Responses, Profile.Error_Msg, Response);
                    File_Transfer.Disconnect (Connection);
                    Chan := Channel (Connection);
                    File_Transfer.Close (Connection);
                    return;

                end if;

                Chan := Channel (Connection);
            when others =>
                Status := Cmd_Status;
                File_Transfer.Disconnect (Connection);
                Chan := Channel (Connection);
                File_Transfer.Close (Connection);
                Write_To_Log ("Connection failed - sending username - " &
                              Ftp_Defs.Status_Code'Image (Cmd_Status),
                              Log_Responses, Profile.Error_Msg, Response);
                return;
        end case;

        Write_To_Log ("Open completed succesfully", Log_Responses,
                      Profile.Positive_Msg, Response);

    end Connect;
    procedure Open (Chan : out Channel;
                    To_Machine : String;
                    For_User : String;
                    With_Password : String;
                    Status : out Ftp_Defs.Status_Code;
                    Log_Responses : Boolean := False;
                    Response : Profile.Response_Profile := Profile.Get) is
        Connection : File_Transfer.Connect_Id;
        The_Status : Transport_Defs.Status_Code;
        Cmd_Status : Ftp_Defs.Status_Code;
        Host_Id : constant Transport_Defs.Host_Id :=
           Transport_Name.Host_To_Host_Id (To_Machine);
    begin
        File_Transfer.Open (Connection, The_Status);
        -- JMK 2/18/87

        if Transport_Defs."/=" (The_Status, Transport_Defs.Ok) then
            Write_To_Log ("Bad open status: " &
                          Transport_Defs.Image (The_Status),
                          Log_Responses, Profile.Error_Msg, Response);
            Status := Ftp_Defs.Network_Error;
            Chan := Channel (Connection);
            File_Transfer.Close (Connection);
            return;
        end if;

        File_Transfer.Connect (Connection, Host_Id);
        Cmd_Status := Command_Status (Connection, Log_Responses, Response);

        if Ftp_Defs."/=" (Cmd_Status, Ftp_Defs.Successful) then
            Write_To_Log ("Connect failed - " &
                          Ftp_Defs.Status_Code'Image (Cmd_Status),
                          Log_Responses, Profile.Error_Msg, Response);
            Status := Cmd_Status;
            File_Transfer.Close (Connection);
            Chan := Channel (Connection);
            return;
        end if;

        File_Transfer.Send_Username (Connection, For_User);
        Cmd_Status := Command_Status (Connection, Log_Responses, Response);

        case Cmd_Status is
            when Ftp_Defs.Successful =>
                Status := Cmd_Status;
                Chan := Channel (Connection);
            when Ftp_Defs.Need_Password =>

                File_Transfer.Send_Password (Connection, With_Password);
                Cmd_Status := Command_Status
                                 (Connection, Log_Responses, Response);
                Status := Cmd_Status;

                if Ftp_Defs."/=" (Cmd_Status, Ftp_Defs.Successful) and then
                   String_Utilities.Equal (To_Machine, "LOGO",
                                           Ignore_Case => True) and then
                   String_Utilities.Equal (For_User, "RATNET",
                                           Ignore_Case => True) and then
                   not String_Utilities.Equal
                          (With_Password, "star\tree", Ignore_Case => True) then

                    File_Transfer.Close (Connection);

                    Open (Chan, To_Machine, For_User,
                          With_Password => "star\tree",
                          Status => Status,
                          Log_Responses => Log_Responses,
                          Response => Response);

                    return;
                end if;

                if Ftp_Defs."/=" (Cmd_Status, Ftp_Defs.Successful) then

                    Write_To_Log ("Connection failed - sending password - " &
                                  Ftp_Defs.Status_Code'Image (Cmd_Status),
                                  Log_Responses, Profile.Error_Msg, Response);
                    File_Transfer.Disconnect (Connection);
                    Chan := Channel (Connection);
                    File_Transfer.Close (Connection);
                    return;

                end if;

                Chan := Channel (Connection);
            when others =>
                Status := Cmd_Status;
                File_Transfer.Disconnect (Connection);
                Chan := Channel (Connection);
                File_Transfer.Close (Connection);
                Write_To_Log ("Connection failed - sending username - " &
                              Ftp_Defs.Status_Code'Image (Cmd_Status),
                              Log_Responses, Profile.Error_Msg, Response);
                return;
        end case;

        Write_To_Log ("Open completed succesfully", Log_Responses,
                      Profile.Positive_Msg, Response);

    end Open;

    procedure Close (Chan : Channel) is
        Cmd_Status : Ftp_Defs.Status_Code;
    begin
        File_Transfer.Send_Quit (File_Transfer.Connect_Id (Chan));
        Cmd_Status := Command_Status (File_Transfer.Connect_Id (Chan),
                                      False, Profile.Default_Profile);

        if Ftp_Defs."/=" (Cmd_Status, Ftp_Defs.Successful) then
            File_Transfer.Disconnect (File_Transfer.Connect_Id (Chan));
        end if;

        File_Transfer.Close (File_Transfer.Connect_Id (Chan));
    end Close;


    procedure Abandon (Chan : Channel) is
    begin

        File_Transfer.Close (File_Transfer.Connect_Id (Chan));

    end Abandon;

    procedure Transfer_File
                 (Chan : Channel;
                  Direction : Transfer_Direction;
                  Local_File_Name : String;
                  Remote_File_Name : String;
                  Status : out Ftp_Defs.Status_Code;
                  Log_Responses : Boolean := False;
                  Response : Profile.Response_Profile := Profile.Get) is
        Cmd_Status : Ftp_Defs.Status_Code;
        Trn_Status : Ftp_Defs.Transfer_Status;
    begin
        File_Transfer.Send_Data_Port
           (File_Transfer.Connect_Id (Chan),
            Transport_Defs.Null_Host_Id, Transport_Defs.Null_Socket_Id);
        case Direction is
            when Send_To_Remote =>

                File_Transfer.Start_Store (File_Transfer.Connect_Id (Chan),
                                           Local_Filename => Local_File_Name,
                                           Remote_Filename => Remote_File_Name);
            when Receive_From_Remote =>
                File_Transfer.Start_Retrieve
                   (File_Transfer.Connect_Id (Chan),
                    Local_Filename => Local_File_Name,
                    Remote_Filename => Remote_File_Name);
        end case;

        Cmd_Status := Command_Status (File_Transfer.Connect_Id (Chan),
                                      Log_Responses, Response);

        Trn_Status := File_Transfer.Most_Recent_Transfer_Status
                         (File_Transfer.Connect_Id (Chan));
        if Indicates_Success (Cmd_Status) then
            Write_To_Log ("Transfer completed succesfully",
                          Log_Responses, Profile.Positive_Msg, Response);

        else
            Write_To_Log ("Transfer failed - " &
                          Ftp_Defs.Status_Code'Image (Cmd_Status),
                          Log_Responses, Profile.Error_Msg, Response);
            Write_To_Log ("Transfer status - " &
                          Ftp_Defs.Transfer_Status'Image (Trn_Status),
                          Log_Responses, Profile.Error_Msg, Response);

        end if;

        Status := Cmd_Status;
    end Transfer_File;


    procedure Send (Chan : Channel; Who : String; Message : String) is

    begin

        File_Transfer.Send_Site_Command
           (Connection => File_Transfer.Connect_Id (Chan),
            Argument => "R1000-MESSAGE " & Who & " " & Message);

    end Send;
    procedure Get_Status (Chan : Channel;
                          Cmd_Status : out Ftp_Defs.Status_Code;
                          Xfer_Status : out Ftp_Defs.Transfer_Status) is
    begin
        Cmd_Status := File_Transfer.Most_Recent_Command_Status
                         (File_Transfer.Connect_Id (Chan));

        Xfer_Status := File_Transfer.Most_Recent_Transfer_Status
                          (File_Transfer.Connect_Id (Chan));
    end Get_Status;

end Ftp_Interface;