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

⟦cb052b588⟧ Ada Source

    Length: 25600 (0x6400)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Communication, seg_0570e6

Derivation

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

E3 Source Code



with Transport;
with Text_Io;
with Transport_Defs;
with Utils;
with Byte_Defs;
with Our_Constantes;
use Our_Constantes;
with Message;
use Message;
with Our_String;
with Id_Object;

package body Communication is


    -- ******************************************************************************
    -- Creation de la connection
    -- =========================
    procedure Open_Transmit (The_Message : in out Message.Type_Of_Message;
                             The_Connection_Data : in out Connection_Data) is

        Nul_Socket : Transport_Defs.Socket_Id (1 .. 2) := (0, 0);
        A_Message : Message.Type_Of_Message;
        The_Socket : Transport_Defs.Socket_Id (1 .. 2);
    begin

        -- verification de la socket
        -- =========================
        A_Message := The_Message;
        A_Message.The_Socket_Send := Nul_Socket;

        if A_Message = The_Message then
            -- socket non definie
            -- ==================
            Transport.Open (The_Connection_Data.Connection,
                            The_Connection_Data.Status, "TCP/IP", The_Socket);
            if Transport.Is_Open (The_Connection_Data.Connection) then
                Text_Io.Put_Line ("connection ouverte");
            end if;
            The_Message.The_Socket_Send := Transport.Local_Socket
                                              (The_Connection_Data.Connection);
            The_Message.The_Host_Machine_Send :=
               Transport.Local_Host (The_Connection_Data.Connection);

        else
            -- socket definie
            -- ==============
            Transport.Open (The_Connection_Data.Connection,
                            The_Connection_Data.Status, "TCP/IP",
                            The_Message.The_Socket_Receive);
            if Transport.Is_Open (The_Connection_Data.Connection) then
                Text_Io.Put_Line ("connection ouverte");
            end if;       end if;

    end Open_Transmit;


    -- **********************************************************************
    procedure Connect_Transmit (The_Message : in out Message.Type_Of_Message;
                                The_Connection_Data : in out Connection_Data) is
    begin

        while not (Transport.Is_Connected (The_Connection_Data.Connection)) loop
            Transport.Connect (The_Connection_Data.Connection,
                               The_Connection_Data.Status,
                               The_Message.The_Host_Machine_Receive,
                               The_Message.The_Socket_Receive, Duration'Last);
            Text_Io.Put (".");
        end loop;

        Text_Io.New_Line;
        if Transport.Is_Connected (The_Connection_Data.Connection) then
            null; -- ok connection realisee
        end if;

    end Connect_Transmit;

    -- ******************************************************************************
    -- Transmission du message
    -- =======================
    procedure Transmitter (The_Message : in Message.Type_Of_Message;
                           The_Connection_Data : in out Connection_Data) is

        String_Tempo : Our_String.Variable_String;


        procedure Transmit_String (Str : Our_String.Variable_String;
                                   The_Connection : in out Connection_Data) is

        begin
            Transport.Transmit (The_Connection.Connection,
                                The_Connection.Status,
                                Utils.String_To_Byte_String
                                   (Our_String.Image (Str)),
                                The_Connection.Count);
        end Transmit_String;

    begin

        Our_String.Copy (String_Tempo,
                         Type_Of_Command'Image (The_Message.The_Command));
        Our_String.Append (String_Tempo, "+++");
        Transmit_String (String_Tempo, The_Connection_Data);
       Transport.Transmit (The_Connection_Data.Connection,
                            The_Connection_Data.Status,
                            Byte_Defs.Byte_String (The_Message.
                                                   The_Host_Machine_Send),
                            The_Connection_Data.Count);

        Transmit_String (Our_String.Value
                            (Natural'Image (Natural
                                               (The_Message.The_Id_User_Send))),
                         The_Connection_Data);

        Transport.Transmit (The_Connection_Data.Connection,
                            The_Connection_Data.Status,
                            Byte_Defs.Byte_String (The_Message.
                                                   The_Host_Machine_Receive),
                            The_Connection_Data.Count);
        Transmit_String
           (Our_String.Value
               (Natural'Image (Natural (The_Message.The_Id_User_Receive))),
            The_Connection_Data);

        Transport.Transmit (The_Connection_Data.Connection,
                            The_Connection_Data.Status,
                            Byte_Defs.Byte_String (The_Message.
                                                   The_Host_Machine_To_Execute),
                            The_Connection_Data.Count);

        if (The_Message.Command_Is_Ok = True) then
            Transmit_String (Our_String.Value (Natural'Image (1)),
                             The_Connection_Data);
        else
            Transmit_String (Our_String.Value (Natural'Image (0)),
                             The_Connection_Data);
        end if;

        Transmit_String (Our_String.Value
                            (Natural'Image (The_Message.
                                            Number_Of_Return_Parameter)),
                         The_Connection_Data);

        Transport.Transmit (The_Connection_Data.Connection,
                            The_Connection_Data.Status,
                            Byte_Defs.Byte_String (The_Message.The_Socket_Send),
                            The_Connection_Data.Count);

        Transport.Transmit (The_Connection_Data.Connection,
                            The_Connection_Data.Status,
                            Byte_Defs.Byte_String
                               (The_Message.The_Socket_Receive),
                            The_Connection_Data.Count);

        Transport.Transmit (The_Connection_Data.Connection,
                            The_Connection_Data.Status,
                            Byte_Defs.Byte_String (The_Message.
                                                   The_Socket_To_Execute),
                            The_Connection_Data.Count);

        Our_String.Copy (String_Tempo, The_Message.Data);
        Transmit_String (String_Tempo, The_Connection_Data);

    end Transmitter;

    -- ******************************************************************************
    -- etablissement de la connection
    -- ==============================
    procedure Open_Receive (The_Socket : in Transport_Defs.Socket_Id;
                            The_Connection_Data : in out Connection_Data) is

    begin

        Transport.Open (The_Connection_Data.Connection,
                        The_Connection_Data.Status, "TCP/IP", The_Socket);
        if Transport.Is_Open (The_Connection_Data.Connection) then
            Text_Io.Put_Line ("connection ouverte");
        end if;

    end Open_Receive;


    -- ******************************************************************************
    procedure Connect_Receive (The_Connection_Data : in out Connection_Data) is

    begin
        while not (Transport.Is_Connected (The_Connection_Data.Connection)) loop
            Transport.Connect (The_Connection_Data.Connection,
                               The_Connection_Data.Status, Duration'Last);
            Text_Io.Put (".");
        end loop;

        Text_Io.New_Line;
        if Transport.Is_Connected (The_Connection_Data.Connection) then
            null; -- connection realisee Ok
        end if;

    end Connect_Receive;


    -- ******************************************************************************
    -- reception
    -- =========
    procedure Receiver (The_Message : out Message.Type_Of_Message;
                        The_Connection_Data : in out Connection_Data) is

        Data : Byte_Defs.Byte_String (1 .. 255);
        I : Positive := 1;
        Data_One : Byte_Defs.Byte_String (1 .. 2);
        Data_Four : Byte_Defs.Byte_String (1 .. 4);
        Data_Two : Byte_Defs.Byte_String (1 .. 2);
        String_Tempo : Our_String.Variable_String;
        End_Of_Data : Boolean := False;
        Last : Positive;
        The_String : String (1 .. Our_Constantes.Length_Of_A_Line);

    begin
        -- The_Message.The_Command
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data,
                           The_Connection_Data.Count);
        String_Tempo := Our_String.Value (Utils.Byte_String_To_String (Data));
        End_Of_Data := False;
        I := 1;
        while (not End_Of_Data) and (I <=
                                     (Our_Constantes.Length_Of_A_Line - 2)) loop
            if (Our_String.Char_At (String_Tempo, I) = '+') and
               (Our_String.Char_At (String_Tempo, I + 1) = '+') and
               (Our_String.Char_At (String_Tempo, I + 2) = '+') then
                String_Tempo := Our_String.Value
                                   (Utils.Byte_String_To_String (Data));
                Our_String.Set_Length (String_Tempo, I - 1);
                End_Of_Data := True;
            else
                I := I + 1;
            end if;
        end loop;
        Our_Enumeration.Get (Our_String.Image (String_Tempo),
                             The_Message.The_Command, Last);


        -- The_Message.The_Host_Machine_Send
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_Four,
                           The_Connection_Data.Count);
        The_Message.The_Host_Machine_Send := Transport_Defs.Host_Id (Data_Four);


        -- The_Message.The_Id_User_Send
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_One,
                           The_Connection_Data.Count);
        The_Message.The_Id_User_Send :=
           Id_Object.Type_Id (Natural'Value
                                 (Utils.Byte_String_To_String (Data_One)));

        -- The_Message.The_Host_Machine_Receive
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_Four,
                           The_Connection_Data.Count);
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_One,
                           The_Connection_Data.Count);
        The_Message.The_Id_User_Receive :=
           Id_Object.Type_Id (Natural'Value
                                 (Utils.Byte_String_To_String (Data_One)));

        -- The_Message.The_Host_Machine_To_Execute
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_Four,
                           The_Connection_Data.Count);
        The_Message.The_Host_Machine_To_Execute :=
           Transport_Defs.Host_Id (Data_Four);

        --The_Message.Command_Is_Ok
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_One,
                           The_Connection_Data.Count);
        if (Natural'Value (Utils.Byte_String_To_String (Data_One)) = 1) then
            The_Message.Command_Is_Ok := True;
        else
            The_Message.Command_Is_Ok := False;
        end if;


        -- The_Message.Number_Of_The_Question
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_One,
                           The_Connection_Data.Count);
        The_Message.Number_Of_Return_Parameter :=
           Natural'Value (Utils.Byte_String_To_String (Data_One));
       -- The_Message.The_Socket_Send
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_Two,
                           The_Connection_Data.Count);
        The_Message.The_Socket_Send := Transport_Defs.Socket_Id (Data_Two);

        -- The_Message.The_Socket_Receive
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_Two,
                           The_Connection_Data.Count);
        The_Message.The_Socket_Receive := Transport_Defs.Socket_Id (Data_Two);

        -- The_Message.The_Socket_To_Execute
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data_Two,
                           The_Connection_Data.Count);
        The_Message.The_Socket_To_Execute :=
           Transport_Defs.Socket_Id (Data_Two);

        -- The_Message.Data
        -- ================
        Transport.Receive (The_Connection_Data.Connection,
                           The_Connection_Data.Status, Data,
                           The_Connection_Data.Count);
        String_Tempo := Our_String.Value (Utils.Byte_String_To_String (Data));
        End_Of_Data := False;
        I := 1;

        String_Tempo := Our_String.Value (Utils.Byte_String_To_String (Data));

        while (not End_Of_Data) and (I <=
                                     Our_Constantes.Length_Of_A_Line - 2) loop
            if (Our_String.Char_At (String_Tempo, I) = '+') and
               (Our_String.Char_At (String_Tempo, I + 1) = '+') and
               (Our_String.Char_At (String_Tempo, I + 2) = '+') then
                String_Tempo := Our_String.Value
                                   (Utils.Byte_String_To_String (Data));
                Our_String.Set_Length (String_Tempo, I - 1);
                End_Of_Data := True;
            else
                I := I + 1;
            end if;
        end loop;
        The_Message.Data := String_Tempo;

    end Receiver;


    -- ******************************************************************************
    procedure Disconnect (The_Connection_Data : in out Connection_Data) is

    begin
        Transport.Disconnect (The_Connection_Data.Connection);  
    end Disconnect;

    -- ******************************************************************************
    procedure Close (The_Connection_Data : in out Connection_Data) is
    begin
        Transport.Close (The_Connection_Data.Connection);  
        Text_Io.Put_Line ("connection fermee");
    end Close;


begin
    null;
end Communication;

E3 Meta Data

    nblk1=18
    nid=9
    hdr6=22
        [0x00] rec0=23 rec1=00 rec2=01 rec3=026
        [0x01] rec0=14 rec1=00 rec2=02 rec3=002
        [0x02] rec0=1a rec1=00 rec2=05 rec3=006
        [0x03] rec0=00 rec1=00 rec2=03 rec3=01a
        [0x04] rec0=1a rec1=00 rec2=14 rec3=002
        [0x05] rec0=13 rec1=00 rec2=0b rec3=004
        [0x06] rec0=16 rec1=00 rec2=0a rec3=030
        [0x07] rec0=15 rec1=00 rec2=10 rec3=07e
        [0x08] rec0=18 rec1=00 rec2=07 rec3=02e
        [0x09] rec0=14 rec1=00 rec2=17 rec3=066
        [0x0a] rec0=15 rec1=00 rec2=16 rec3=02e
        [0x0b] rec0=18 rec1=00 rec2=0f rec3=004
        [0x0c] rec0=0f rec1=00 rec2=06 rec3=016
        [0x0d] rec0=17 rec1=00 rec2=0c rec3=002
        [0x0e] rec0=15 rec1=00 rec2=15 rec3=00c
        [0x0f] rec0=14 rec1=00 rec2=04 rec3=01e
        [0x10] rec0=19 rec1=00 rec2=0e rec3=000
        [0x11] rec0=19 rec1=00 rec2=0e rec3=000
        [0x12] rec0=18 rec1=00 rec2=0c rec3=054
        [0x13] rec0=18 rec1=00 rec2=06 rec3=036
        [0x14] rec0=11 rec1=00 rec2=0f rec3=000
        [0x15] rec0=19 rec1=00 rec2=06 rec3=000
        [0x16] rec0=18 rec1=00 rec2=0c rec3=054
        [0x17] rec0=19 rec1=00 rec2=06 rec3=000
    tail 0x2154dde5087c59a4a9250 0x42a00088462060003
Free Block Chain:
  0x9: 0000  00 13 00 28 80 12 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ┆   (  **********┆
  0x13: 0000  00 11 03 fc 00 00 00 00 00 00 00 27 20 20 20 20  ┆           '    ┆
  0x11: 0000  00 12 03 fb 80 14 20 3a 3d 20 4f 75 72 5f 53 74  ┆       := Our_St┆
  0x12: 0000  00 0d 03 c9 80 2d 20 20 20 44 61 74 61 5f 54 77  ┆     -   Data_Tw┆
  0xd: 0000  00 18 00 6b 80 16 28 42 79 74 65 5f 44 65 66 73  ┆   k  (Byte_Defs┆
  0x18: 0000  00 08 03 fc 80 0d 5f 44 61 74 61 2e 53 74 61 74  ┆      _Data.Stat┆
  0x8: 0000  00 00 00 1a 80 05 66 69 6e 69 65 05 00 0f 20 20  ┆      finie     ┆