void Data::fillDevices(MHWD::DEVICETYPE type) { hd_data_t *hd_data; hd_t *hd; hw_item hw; std::vector<Device*>* devices; if (type == MHWD::DEVICETYPE::USB) { hw = hw_usb; devices = &USBDevices; } else { hw = hw_pci; devices = &PCIDevices; } // Get the hardware devices hd_data = (hd_data_t*) calloc(1, sizeof *hd_data); hd = hd_list(hd_data, hw, 1, nullptr); Device *device; for (; hd; hd = hd->next) { device = new Device(); device->type = type; device->classID = from_Hex(hd->base_class.id, 2) + from_Hex(hd->sub_class.id, 2).toLower(); device->vendorID = from_Hex(hd->vendor.id, 4).toLower(); device->deviceID = from_Hex(hd->device.id, 4).toLower(); device->className = from_CharArray(hd->base_class.name); device->vendorName = from_CharArray(hd->vendor.name); device->deviceName = from_CharArray(hd->device.name); device->sysfsBusID = from_CharArray(hd->sysfs_bus_id); device->sysfsID = from_CharArray(hd->sysfs_id); devices->push_back(device); } hd_free_hd_list(hd); hd_free_hd_data(hd_data); free(hd_data); }
void mhwd::fillDevices(mhwd::Data *data, mhwd::TYPE type) { hd_data_t *hd_data; hd_t *hd; hw_item hw; std::vector<mhwd::Device*>* devices; if (type == mhwd::TYPE_USB) { hw = hw_usb; devices = &data->USBDevices; } else { hw = hw_pci; devices = &data->PCIDevices; } // Get the hardware devices hd_data = (hd_data_t*)calloc(1, sizeof *hd_data); hd = hd_list(hd_data, hw, 1, NULL); for(; hd; hd = hd->next) { struct mhwd::Device *device = new mhwd::Device(); device->type = type; device->classID = from_Hex(hd->base_class.id, 2) + from_Hex(hd->sub_class.id, 2).toLower(); device->vendorID = from_Hex(hd->vendor.id, 4).toLower(); device->deviceID = from_Hex(hd->device.id, 4).toLower(); device->className = from_CharArray(hd->base_class.name); device->vendorName = from_CharArray(hd->vendor.name); device->deviceName = from_CharArray(hd->device.name); device->sysfsBusID = from_CharArray(hd->sysfs_bus_id); device->sysfsID = from_CharArray(hd->sysfs_id); devices->push_back(device); } hd_free_hd_list(hd); hd_free_hd_data(hd_data); free(hd_data); }