Back to index

lshw  02.16
main.cc
Go to the documentation of this file.
00001 /*
00002  * main.cc
00003  *
00004  * this module is shared between the command-line and graphical interfaces of
00005  * lshw (currently, only the text interface is available).
00006  *
00007  * It calls all the defined scans in a certain order that tries to ensure
00008  * that devices are only reported once and that information coming from
00009  * different sources about a given device is kept consistent.
00010  *
00011  * Individual tests can be disabled on the command-line by using the -disable
00012  * option.
00013  * Status is reported during the execution of tests.
00014  *
00015  */
00016 
00017 #include "hw.h"
00018 #include "print.h"
00019 
00020 #include "version.h"
00021 #include "options.h"
00022 #include "mem.h"
00023 #include "dmi.h"
00024 #include "cpuinfo.h"
00025 #include "cpuid.h"
00026 #include "device-tree.h"
00027 #include "pci.h"
00028 #include "pcmcia.h"
00029 #include "pcmcia-legacy.h"
00030 #include "ide.h"
00031 #include "scsi.h"
00032 #include "spd.h"
00033 #include "network.h"
00034 #include "isapnp.h"
00035 #include "fb.h"
00036 #include "usb.h"
00037 #include "sysfs.h"
00038 #include "display.h"
00039 #include "parisc.h"
00040 #include "cpufreq.h"
00041 #include "ideraid.h"
00042 #include "mounts.h"
00043 #include "smp.h"
00044 #include "abi.h"
00045 
00046 #include <unistd.h>
00047 #include <stdio.h>
00048 
00049 __ID("@(#) $Id: main.cc 2433 2012-01-10 22:01:30Z lyonel $");
00050 
00051 bool scan_system(hwNode & system)
00052 {
00053   char hostname[80];
00054 
00055   if (gethostname(hostname, sizeof(hostname)) == 0)
00056   {
00057     hwNode computer(::enabled("output:sanitize")?"computer":hostname,
00058       hw::system);
00059 
00060     status("DMI");
00061     if (enabled("dmi"))
00062       scan_dmi(computer);
00063     status("SMP");
00064     if (enabled("smp"))
00065       scan_smp(computer);
00066     status("PA-RISC");
00067     if (enabled("parisc"))
00068       scan_parisc(computer);
00069     status("device-tree");
00070     if (enabled("device-tree"))
00071       scan_device_tree(computer);
00072     status("SPD");
00073     if (enabled("spd"))
00074       scan_spd(computer);
00075     status("memory");
00076     if (enabled("memory"))
00077       scan_memory(computer);
00078     status("/proc/cpuinfo");
00079     if (enabled("cpuinfo"))
00080       scan_cpuinfo(computer);
00081     status("CPUID");
00082     if (enabled("cpuid"))
00083       scan_cpuid(computer);
00084     status("PCI (sysfs)");
00085     if (enabled("pci"))
00086     {
00087       if(!scan_pci(computer))
00088       {
00089         if (enabled("pcilegacy"))
00090           scan_pci_legacy(computer);
00091       }
00092     }
00093     else
00094     {
00095       status("PCI (legacy)");
00096       if (enabled("pcilegacy"))
00097         scan_pci_legacy(computer);
00098     }
00099     status("ISA PnP");
00100     if (enabled("isapnp"))
00101       scan_isapnp(computer);
00102     status("PCMCIA");
00103     if (enabled("pcmcia"))
00104       scan_pcmcia(computer);
00105     status("PCMCIA");
00106     if (enabled("pcmcia-legacy"))
00107       scan_pcmcialegacy(computer);
00108     status("kernel device tree (sysfs)");
00109     if (enabled("sysfs"))
00110       scan_sysfs(computer);
00111     status("USB");
00112     if (enabled("usb"))
00113       scan_usb(computer);
00114     status("IDE");
00115     if (enabled("ide"))
00116       scan_ide(computer);
00117     if (enabled("ideraid"))
00118       scan_ideraid(computer);
00119     status("SCSI");
00120     if (enabled("scsi"))
00121       scan_scsi(computer);
00122     if (enabled("mounts"))
00123       scan_mounts(computer);
00124     status("Network interfaces");
00125     if (enabled("network"))
00126       scan_network(computer);
00127     status("Framebuffer devices");
00128     if (enabled("fb"))
00129       scan_fb(computer);
00130     status("Display");
00131     if (enabled("display"))
00132       scan_display(computer);
00133     status("CPUFreq");
00134     if (enabled("cpufreq"))
00135       scan_cpufreq(computer);
00136     status("ABI");
00137     if (enabled("abi"))
00138       scan_abi(computer);
00139     status("");
00140 
00141     if (computer.getDescription() == "")
00142       computer.setDescription("Computer");
00143     computer.assignPhysIds();
00144     computer.fixInconsistencies();
00145 
00146     system = computer;
00147   }
00148   else
00149     return false;
00150 
00151   return true;
00152 }