1
----------------------------------------------------------------------
2
-- Adactl - Main program body --
4
-- This software is (c) The European Organisation for the Safety --
5
-- of Air Navigation (EUROCONTROL) and Adalog 2004-2005. The Ada --
6
-- Controller is free software; you can redistribute it and/or --
7
-- modify it under terms of the GNU General Public License as --
8
-- published by the Free Software Foundation; either version 2, or --
9
-- (at your option) any later version. This unit is distributed --
10
-- in the hope that it will be useful, but WITHOUT ANY WARRANTY; --
11
-- without even the implied warranty of MERCHANTABILITY or FITNESS --
12
-- FOR A PARTICULAR PURPOSE. See the GNU General Public License --
13
-- for more details. You should have received a copy of the GNU --
14
-- General Public License distributed with this program; see file --
15
-- COPYING. If not, write to the Free Software Foundation, 59 --
16
-- Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
18
-- As a special exception, if other files instantiate generics --
19
-- from the units of this program, or if you link this unit with --
20
-- other files to produce an executable, this unit does not by --
21
-- itself cause the resulting executable to be covered by the GNU --
22
-- General Public License. This exception does not however --
23
-- invalidate any other reasons why the executable file might be --
24
-- covered by the GNU Public License. --
26
-- This software is distributed in the hope that it will be --
27
-- useful, but WITHOUT ANY WARRANTY; without even the implied --
28
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR --
30
----------------------------------------------------------------------
34
Ada.Characters.Handling,
42
Asis.Ada_Environments,
60
use Ada.Characters.Handling, Ada.Exceptions, Ada.Calendar;
61
use Asis.Exceptions, Asis.Implementation;
62
use Utilities, Adactl_Options;
65
OK : constant Ada.Command_Line.Exit_Status := 0;
66
Checks_Failed : constant Ada.Command_Line.Exit_Status := 1;
67
Bad_Command : constant Ada.Command_Line.Exit_Status := 2;
68
Failure : constant Ada.Command_Line.Exit_Status := 10;
70
Start_Time : constant Time := Clock;
72
use Framework.Language;
77
if Action /= Help then
81
User_Log ("Loading units, please wait...");
82
Asis.Implementation.Initialize (Initialize_String);
83
Asis.Ada_Environments.Associate (Ruler.My_Context, "Adactl", Asis_Options);
84
Asis.Ada_Environments.Open (Ruler.My_Context);
85
Units_List.Register (Unit_Spec => Ada_Units_List,
86
Recursive => Recursive_Option,
88
My_Context => Ruler.My_Context);
93
null; -- Help message printed from Analyse_Options
96
Execute (Command_Line_Commands); -- For a possible -o option
98
while not Units_List.Is_Exhausted loop
99
Ada.Wide_Text_IO.Put_Line (Units_List.Current_Unit);
104
Execute (Command_Line_Commands);
105
if not Go_Command_Found then
109
when Interactive_Process =>
110
Execute (Command_Line_Commands);
111
Execute ("source console;");
115
if Action /= Help then
116
-- Close output file if any
117
Execute ("set output console;");
122
Asis.Ada_Environments.Close (Ruler.My_Context);
123
Asis.Ada_Environments.Dissociate (Ruler.My_Context);
124
Asis.Implementation.Finalize;
129
if Framework.Language.Had_Failure then
130
Ada.Command_Line.Set_Exit_Status (Failure);
131
elsif Framework.Reports.Error_Reported then
132
Ada.Command_Line.Set_Exit_Status (Checks_Failed);
134
Ada.Command_Line.Set_Exit_Status (OK);
138
Exec_Time_String : constant Wide_String
139
:= Integer'Wide_Image (Integer ((Clock - Start_Time)*10));
141
User_Log ("Execution_Time: "
142
& Choose (Exec_Time_String (2 .. Exec_Time_String'Last - 1), "0")
144
& Exec_Time_String (Exec_Time_String'Last)
150
when Occur : Options_Error | Units_List.Specification_Error =>
151
Ada.Command_Line.Set_Exit_Status (Bad_Command);
152
User_Message ("Parameter or option error: " & To_Wide_String (Ada.Exceptions.Exception_Message (Occur)));
153
User_Message ("try -h for help");
155
when Occur : Utilities.User_Error =>
156
User_Message ("Error in rule: " & To_Wide_String (Ada.Exceptions.Exception_Message (Occur)));
158
when Asis.Exceptions.ASIS_Failed =>
160
when Asis.Errors.Use_Error =>
161
Ada.Command_Line.Set_Exit_Status (Bad_Command);
162
User_Message (Diagnosis);
164
Ada.Command_Line.Set_Exit_Status (Failure);
165
raise; -- To get stack trace