Subversion Repositories ALCASAR

Rev

Rev 2770 | Rev 3037 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2770 Rev 2976
Line 32... Line 32...
32
     * @return array
32
     * @return array
33
     */
33
     */
34
    public static function lspci($debug = PSI_DEBUG)
34
    public static function lspci($debug = PSI_DEBUG)
35
    {
35
    {
36
        $arrResults = array();
36
        $arrResults = array();
37
        if (CommonFunctions::executeProgram("lspci", "", $strBuf, $debug)) {
37
        if (CommonFunctions::executeProgram("lspci", (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS)?"-m":"", $strBuf, $debug)) {
38
            $arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
38
            $arrLines = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
39
            foreach ($arrLines as $strLine) {
39
            foreach ($arrLines as $strLine) {
40
                $arrParams = preg_split('/ /', trim($strLine), 2);
-
 
41
                if (count($arrParams) == 2)
-
 
42
                   $strName = $arrParams[1];
-
 
43
                else
-
 
44
                   $strName = "unknown";
-
 
45
                $strName = preg_replace('/\(.*\)/', '', $strName);
-
 
46
                $dev = new HWDevice();
40
                $dev = new HWDevice();
-
 
41
                $arrParams = preg_split('/(\"? ")|(\" (?=-))/', trim($strLine));
-
 
42
                if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && ($cp = count($arrParams)) >= 6) {
-
 
43
                    $arrParams[$cp-1] = trim($arrParams[$cp-1],'"'); // remove last "
-
 
44
                    $dev->setName($arrParams[1].': '.$arrParams[2].' '.$arrParams[3]);
-
 
45
                    if (preg_match('/^-/', $arrParams[4])) {
-
 
46
                        if (($arrParams[5] !== "") && !preg_match('/^Unknown vendor/', $arrParams[5])) {
-
 
47
                            $dev->setManufacturer(trim($arrParams[5]));
-
 
48
                        }
-
 
49
                        if (($arrParams[6] !== "") && !preg_match('/^Device /', $arrParams[6])) {
-
 
50
                            $dev->setProduct(trim($arrParams[6]));
-
 
51
                        }
-
 
52
                    } else {
-
 
53
                        if (($arrParams[4] !== "") && !preg_match('/^Unknown vendor/', $arrParams[4])) {
-
 
54
                            $dev->setManufacturer(trim($arrParams[4]));
-
 
55
                        }
-
 
56
                        if (($arrParams[5] !== "") && !preg_match('/^Device /', $arrParams[5])) {
-
 
57
                            $dev->setProduct(trim($arrParams[5]));
-
 
58
                        }
-
 
59
                    }
-
 
60
                } else {
-
 
61
                    $strLine=trim(preg_replace('/(")|( -\S+)/', '', $strLine));
-
 
62
                    $arrParams = preg_split('/ /', trim($strLine), 2);
-
 
63
                    if (count($arrParams) == 2)
-
 
64
                        $strName = preg_replace('/\(rev\s[^\)]+\)/', '', $arrParams[1]);
-
 
65
                    else
-
 
66
                       $strName = "unknown";
47
                $dev->setName($strName);
67
                    $dev->setName($strName);
-
 
68
                }
48
                $arrResults[] = $dev;
69
                $arrResults[] = $dev;
49
            }
70
            }
50
        }
71
        }
51
 
72
 
52
        return $arrResults;
73
        return $arrResults;