Back to index

lshw  02.16
Functions
heuristics.h File Reference
#include "hw.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

hwNodeguessParent (const hwNode &child, hwNode &base)
string guessBusInfo (const string &)
string guessParentBusInfo (const string &)
bool guessVendor (hwNode &device)
bool guessProduct (hwNode &device)

Function Documentation

string guessBusInfo ( const string &  )

Definition at line 17 of file heuristics.cc.

{
                                                  // 2.6-style PCI
  if(matches(info,"^[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]\\.[[:xdigit:]]$"))
  {
    return "pci@" + info;
  }
                                                  // 2.4-style PCI
  if(matches(info,"^[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]\\.[[:xdigit:]]$"))
  {
    return "pci@0000:" + info;
  }

                                                  // USB: host-port[.port]:config.interface
  if(matches(info, "^[0-9]+-[0-9]+(\\.[0-9]+)*:[0-9]+\\.[0-9]+$"))
  {
    size_t colon = info.rfind(":");
    size_t dash = info.find("-");

    return "usb@" + info.substr(0, dash) + ":" + info.substr(dash+1, colon-dash-1);
  }

  if(matches(info, "^[[:xdigit:]]+-[0-9]+$"))     // Firewire: guid-function
  {
    size_t dash = info.find("-");

    return "firewire@" + info.substr(0, dash);
  }

#if 1
//#ifdef __hppa__
  if(matches(info, "^[0-9]+(:[0-9]+)*$"))         // PA-RISC: x:y:z:t corresponds to /x/y/z/t
  {
    string result = "parisc@";

    for(unsigned i=0; i<info.length(); i++)
      if(info[i] == ':')
        result += '/';
    else
      result += info[i];
    return result;
  }
#endif
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

hwNode* guessParent ( const hwNode child,
hwNode base 
)

Definition at line 88 of file heuristics.cc.

{
  return base.findChildByBusInfo(guessParentBusInfo(child));
}

Here is the call graph for this function:

Here is the caller graph for this function:

string guessParentBusInfo ( const string &  )
bool guessProduct ( hwNode device)

Definition at line 167 of file heuristics.cc.

{
  string product = device.getProduct();

  if(product == "")
    return false;

  device.setProduct(parsehex(product));

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool guessVendor ( hwNode device)

Definition at line 115 of file heuristics.cc.

{
  int i = 0;
  bool result = false;


  device.setVendor(jedec_resolve(device.getVendor()));

  if(device.getVendor() != "")
    return false;

 
  if(device.getClass() == hw::disk)
    while (disk_manufacturers[i])
    {
      if (matches(device.getProduct().c_str(), disk_manufacturers[i], REG_ICASE))
      {
        device.setVendor(disk_manufacturers[i + 1]);
        result = true;
      }
      i += 2;
    }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: