summaryrefslogtreecommitdiffstats
path: root/pts-core/functions/pts-functions_system_parsing.php
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-08-25 21:14:57 -0400
committerMichael Larabel <michael@phx-laptop.(none)>2008-08-25 21:14:57 -0400
commitdc3d4dfff15836be8fe8806aa77ca03f26237bb8 (patch)
treec61b6dbace5419ffd8c1d3df367d7148ac76073b /pts-core/functions/pts-functions_system_parsing.php
parent5cd37bfb1ba0c307e58409f1eec940165f48853a (diff)
downloadphoronix-test-suite-upstream-dc3d4dfff15836be8fe8806aa77ca03f26237bb8.tar.gz
phoronix-test-suite-upstream-dc3d4dfff15836be8fe8806aa77ca03f26237bb8.tar.xz
phoronix-test-suite-upstream-dc3d4dfff15836be8fe8806aa77ca03f26237bb8.zip
pts-core: Add fallback support for read_hal() when the names are
specified in an array and the earlier names can't be found with the proper information
Diffstat (limited to 'pts-core/functions/pts-functions_system_parsing.php')
-rw-r--r--pts-core/functions/pts-functions_system_parsing.php34
1 files changed, 19 insertions, 15 deletions
diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php
index e738bad..d7b5d54 100644
--- a/pts-core/functions/pts-functions_system_parsing.php
+++ b/pts-core/functions/pts-functions_system_parsing.php
@@ -50,24 +50,28 @@ function read_acpi($point, $match)
function read_hal($name, $UDI = NULL)
{
// Read HAL - Hardware Abstraction Layer
- if(empty($UDI))
- $info = shell_exec("lshal 2>&1 | grep \"" . $name . "\"");
- else
- $info = shell_exec("lshal -u $UDI 2>&1 | grep \"" . $name . "\"");
+ $info = "Unknown";
- if(($pos = strpos($info, $name . " = '")) === FALSE)
- {
- $info = "Unknown";
- }
- else
+ if(!is_array($name))
+ $name = array($name);
+
+ for($i = 0; $i < count($name) && $info == "Unknown"; $i++)
{
- $info = substr($info, $pos + strlen($name . " = '"));
- $info = trim(substr($info, 0, strpos($info, "'")));
- }
+ if(empty($UDI))
+ $info = shell_exec("lshal 2>&1 | grep \"" . $name[$i] . "\"");
+ else
+ $info = shell_exec("lshal -u $UDI 2>&1 | grep \"" . $name[$i] . "\"");
- $remove_words = array("empty", "unknow", "system manufacturer", "system version", "name", "system product", "to be filled by o.e.m.", "not applicable");
- if(empty($info) || in_array(strtolower($info), $remove_words))
- $info = "Unknown";
+ if(($pos = strpos($info, $name[$i] . " = '")) !== FALSE)
+ {
+ $info = substr($info, $pos + strlen($name[$i] . " = '"));
+ $info = trim(substr($info, 0, strpos($info, "'")));
+ }
+
+ $remove_words = array("empty", "unknow", "system manufacturer", "system version", "system name", "system product name", "to be filled by o.e.m.", "not applicable");
+ if(empty($info) || in_array(strtolower($info), $remove_words))
+ $info = "Unknown";
+ }
return $info;
}