- 23DCF3C0EFF5D5CA20CE1C5091E4DC9B739D2D98630208AA16DEC1298A13C28962089C0311E8E50AF9801C026E79F003FE8B9CE9341C351CB4E4556347D14734+ 11C17FEDC3C0442C3CA93589A47F5FDC4B9AB3BAB4361A96CBFF4BBB15E031D44BFECEED59E5EA6942F552FCA67214C3FC9D956779F77B8A0E7432CA609F779Fvtools/src/vpatch.adb(1 . 6)(1 . 4)
95 with Bits; use Bits;
96 with Interfaces.C;
97 with Interfaces.C.Strings;
98 with Ada.Text_IO; use Ada.Text_IO;
99 with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
100 with Character_IO; use Character_IO;
(11 . 6)(9 . 7)
102 with Ada.Characters.Latin_1;
103 with Ada.Sequential_IO;
104 with SMG_Keccak; use SMG_Keccak;
105 with Temporary_File; use Temporary_File;
106
107 procedure VPatch is
108 package Latin_1 renames Ada.Characters.Latin_1;
(59 . 36)(58 . 22)
110
111 -- Temporary File
112
113 procedure MkTemp(Template: Interfaces.C.Strings.Chars_Ptr);
114 pragma Import(C, mktemp);
115
116 function Temp_File_Name(Template: String) return String is
117 X: Interfaces.C.Strings.Chars_Ptr
118 := Interfaces.C.Strings.New_String(Template);
119 begin
120 MkTemp(X);
121 declare
122 Result: String := Interfaces.C.Strings.Value(X);
123 begin
124 Interfaces.C.Strings.Free(X);
125 return Result;
126 end;
127 end;
128
129 procedure Create_Temp(File : in out File_Type;
130 Mode : in File_Mode := Out_File;
131 Template : in String := "vpatch.XXX";
132 Prefix : in String;
133 Seed : in String := "";
134 Form : in String := "") is
135 Name: String := Temp_File_Name(Template);
136 Name: String := Temporary_File.Temporary_File(Prefix, Seed);
137 begin
138 Create(File, Mode, Name, Form);
139 end;
140
141 procedure Create_Temp(File : in out CIO.File_Type;
142 Mode : in CIO.File_Mode := CIO.Out_File;
143 Template : in String := "vpatch.XXX";
144 Prefix : in String;
145 Seed : in String := "";
146 Form : in String := "") is
147 Name: String := Temp_File_Name(Template);
148 Name: String := Temporary_File.Temporary_File(Prefix, Seed);
149 begin
150 Create(File, Mode, Name, Form);
151 end;
(466 . 7)(451 . 7)
153
154 -- prepare keccak and open files
155 KeccakBegin(To_Ctx);
156 Create_Temp(To_F, Template => "tmp.XXX");
157 Create_Temp(To_F, Prefix => "vpatch-", Seed => To_F_Name);
158 case Op is
159 when Op_Create =>
160 Has_Input_File := False;