blob: 06fe9f166bc525a29715af86ad8c02a5d776eb04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO;
with Ada.Command_Line;
with GNAT.Command_Line;
with GNAT.Strings;
with Hypervisor_Check; use Hypervisor_Check;
with HVInfo_Util; use HVInfo_Util;
procedure HVInfo is
package US renames Ada.Strings.Unbounded;
package CL renames Ada.Command_Line;
package IO renames Ada.Text_IO;
package GCL renames GNAT.Command_Line;
CPUID_HV_Name, SMBIOS_HV_Name, Hypervisor_Name : US.Unbounded_String;
begin
-- Handle command line options
declare
-- No declarations
begin
loop
case GCL.Getopt ("-help -version") is
when '-' =>
if GCL.Full_Switch = "-version" then
Print_Version;
return;
elsif GCL.Full_Switch = "-help" then
Print_Help;
return;
end if;
when others =>
exit;
end case;
end loop;
exception
when GCL.Invalid_Switch =>
IO.Put_Line ("Invalid option");
Print_Help;
return;
end;
CPUID_HV_Name := US.To_Unbounded_String ("");
SMBIOS_HV_Name := US.To_Unbounded_String ("");
if Hypervisor_Present then
CPUID_HV_Name := Get_Vendor_Name;
end if;
SMBIOS_HV_Name := Get_DMI_Vendor_Name;
declare
use US;
begin
if (CPUID_HV_Name = "") and (SMBIOS_HV_Name = "") then
CL.Set_Exit_Status (1);
elsif (CPUID_HV_Name /= "") then
CL.Set_Exit_Status (0);
UIO.Put_Line (CPUID_HV_Name);
else
CL.Set_Exit_Status (0);
UIO.Put_Line (SMBIOS_HV_Name);
end if;
end;
end HVInfo;
|