|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 5347 (0x14e3)
Types: TextFile
Names: »B«
└─⟦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⟧
with Bit_Ops;
with Mac_Types;
with Communications;
with Mac_Text;
package body Interchange is
-- R1000 RPC interchange package for Unix C
use Bit_Ops;
procedure Put_Short (A_Connection : in out Communications.Connection;
Value : Mac_Types.Integer) is
Buf : Communications.Bytearray (0 .. 1);
begin
Buf (0) := Mac_Types.Byte ((Value / 256) and 8#377#);
Buf (1) := Mac_Types.Byte (Value and 8#377#);
Communications.Write (A_Connection, Buf);
end Put_Short;
procedure Get_Short (A_Connection : in out Communications.Connection;
Value : out Mac_Types.Integer) is
Buf : Communications.Bytearray (0 .. 1);
Read_Count : Natural;
begin
Communications.Read (A_Connection, Buf);
Value := Mac_Types.Integer (Buf (0)) * 256 +
Mac_Types.Integer (Buf (1));
end Get_Short;
procedure Put_Int (A_Connection : in out Communications.Connection;
Value : Mac_Types.Longint) is -- 32 bit signed, 4 bytes
Buf : Communications.Bytearray (0 .. 3);
begin
Buf (0) := Mac_Types.Byte ((Value / (2 ** 24)) and 8#377#);
Buf (1) := Mac_Types.Byte ((Value / (2 ** 16)) and 8#377#);
Buf (2) := Mac_Types.Byte ((Value / (2 ** 8)) and 8#377#);
Buf (3) := Mac_Types.Byte (Value and 8#377#);
Communications.Write (A_Connection, Buf);
end Put_Int;
procedure Get_Int (A_Connection : in out Communications.Connection;
Value : out Mac_Types.Longint) is
Buf : Communications.Bytearray (0 .. 3);
Read_Count : Natural;
begin
Communications.Read (A_Connection, Buf);
Value :=
((Mac_Types.Longint (Buf (0)) * 256 + Mac_Types.Longint (Buf (1))) *
256 + Mac_Types.Longint (Buf (2))) * 256 +
Mac_Types.Longint (Buf (3));
end Get_Int;
procedure Put_Bool (A_Connection : in out Communications.Connection;
Value : Boolean) is
begin
if Value then
Put_Short (A_Connection, 1);
else
Put_Short (A_Connection, 0);
end if;
end Put_Bool;
procedure Get_Bool (A_Connection : in out Communications.Connection;
Value : out Boolean) is
I : Mac_Types.Integer;
begin
Get_Short (A_Connection, I);
Value := I /= 0;
end Get_Bool;
procedure Put_Text (A_Connection : in out Communications.Connection;
Value : in Mac_Text.Text) is
Text_Length : Mac_Text.Index;
begin
Text_Length := Mac_Text.Length (Value);
Put_Int (A_Connection, Text_Length);
if Text_Length > 0 then
declare
Buf : Communications.Bytearray (1 .. Text_Length);
Extra : Communications.Bytearray (1 .. 1) := (others => 0);
begin
for I in 1 .. Text_Length loop
Buf (I) := Mac_Types.Char'Pos (Mac_Text.Value (I, Value));
end loop;
Communications.Write (A_Connection, Buf);
if Text_Length mod 2 /= 0 then
Communications.Write (A_Connection, Extra);
end if;
end;
end if;
end Put_Text;
procedure Get_Text (A_Connection : in out Communications.Connection;
Value : in out Mac_Text.Text) is
Length : Mac_Types.Longint;
Remaining : Mac_Types.Longint;
Load : Mac_Types.Longint;
begin
Get_Int (A_Connection, Length);
Mac_Text.Set_Empty (Value);
if Length = 0 then
return;
end if;
if Length <= Mac_Text.Maximum_Length (Value) then
declare
Buf : Communications.Bytearray (1 .. Length);
begin
Communications.Read (A_Connection, Buf);
for I in 1 .. Length loop
Mac_Text.Append (Mac_Types.Char'Val (Buf (I)), Value);
end loop;
end;
else
-- Must truncate string
declare
Buf : Communications.Bytearray
(1 .. Mac_Text.Maximum_Length (Value));
begin
Communications.Read (A_Connection, Buf);
for I in 1 .. Mac_Text.Maximum_Length (Value) loop
Mac_Text.Append (Mac_Types.Char'Val (Buf (I)), Value);
end loop;
end;
Remaining := Length - Mac_Text.Maximum_Length (Value);
while Remaining > 0 loop
if Remaining > 256 then
Load := 256;
else
Load := Remaining;
end if;
declare
Buf : Communications.Bytearray (1 .. Load);
begin
Communications.Read (A_Connection, Buf);
end;
Remaining := Remaining - Load;
end loop;
end if;
if Length mod 2 /= 0 then
declare
Buf : Communications.Bytearray (1 .. 1);
begin
Communications.Read (A_Connection, Buf);
end;
end if;
end Get_Text;
end Interchange;