22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
use type Ada.Streams.Stream_Element_Offset;
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit);
-- Read two base-64 symbols and assemble them into a base-4096 number
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit)
is
Low, High : Tools.Base_64_Digit;
begin
Tools.Next_Digit (Input, Offset, Low);
Tools.Next_Digit (Input, Offset, High);
Code := Base_4096_Digit (Low) + Base_4096_Digit (High) * 64;
end Read_Code;
----------------------
-- Public Interface --
----------------------
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit;
Verbatim_Length : out Natural;
Last_Code : in Base_4096_Digit;
Variable_Length_Verbatim : in Boolean) is
begin
Read_Code (Input, Offset, Code);
if Code <= Last_Code then
Verbatim_Length := 0;
elsif not Variable_Length_Verbatim then
Verbatim_Length := Positive (Base_4096_Digit'Last - Code + 1);
Code := 0;
elsif Code < Base_4096_Digit'Last then
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
|
>
>
>
>
>
>
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
use type Ada.Streams.Stream_Element_Offset;
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit);
procedure Read_Code_Or_End
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit;
Finished : out Boolean);
-- Read two base-64 symbols and assemble them into a base-4096 number
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit)
is
Low, High : Tools.Base_64_Digit;
begin
Tools.Next_Digit (Input, Offset, Low);
Tools.Next_Digit (Input, Offset, High);
Code := Base_4096_Digit (Low) + Base_4096_Digit (High) * 64;
end Read_Code;
procedure Read_Code_Or_End
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit;
Finished : out Boolean)
is
Low, High : Tools.Base_64_Digit;
begin
Tools.Next_Digit_Or_End (Input, Offset, Low, Finished);
if Finished then
return;
end if;
Tools.Next_Digit (Input, Offset, High);
Code := Base_4096_Digit (Low) + Base_4096_Digit (High) * 64;
end Read_Code_Or_End;
----------------------
-- Public Interface --
----------------------
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit;
Verbatim_Length : out Natural;
Last_Code : in Base_4096_Digit;
Variable_Length_Verbatim : in Boolean)
is
Finished : Boolean;
begin
Read_Code_Or_End (Input, Offset, Code, Finished);
if Finished then
Code := Base_4096_Digit'Last;
Verbatim_Length := 0;
return;
end if;
if Code <= Last_Code then
Verbatim_Length := 0;
elsif not Variable_Length_Verbatim then
Verbatim_Length := Positive (Base_4096_Digit'Last - Code + 1);
Code := 0;
elsif Code < Base_4096_Digit'Last then
|