/* * Scans the hotplug driver directory and looks in the system for * matching devices. * Adds or removes matching readers as necessary. */ LONG HPSearchHotPluggables(void) { HPDriver *drivers = HPDriversGetFromDirectory(PCSCLITE_HP_DROPDIR); if (!drivers) return 1; HPDeviceList devices = NULL; if (HPDriversMatchUSBDevices(drivers, &devices)) return -1; if (HPDriversMatchPCCardDevices(drivers, &devices)) return -1; HPDevice *a; for (a = devices; a; a = a->m_next) { int found = FALSE; HPDevice *b; for (b = sDeviceList; b; b = b->m_next) { if (HPDeviceEquals(a, b)) { found = TRUE; break; } } if (!found) { char deviceName[MAX_DEVICENAME]; /* the format should be "usb:%04x/%04x" but Apple uses the * friendly name instead */ snprintf(deviceName, sizeof(deviceName), "%s", a->m_driver->m_friendlyName); deviceName[sizeof(deviceName)-1] = '\0'; RFAddReader(a->m_driver->m_friendlyName, PCSCLITE_HP_BASE_PORT + a->m_address, a->m_driver->m_libPath, deviceName); } } for (a = sDeviceList; a; a = a->m_next) { int found = FALSE; HPDevice *b; for (b = devices; b; b = b->m_next) { if (HPDeviceEquals(a, b)) { found = TRUE; break; } } if (!found) { RFRemoveReader(a->m_driver->m_friendlyName, PCSCLITE_HP_BASE_PORT + a->m_address); } } HPDeviceListRelease(sDeviceList); sDeviceList = devices; HPDriverVectorRelease(drivers); return 0; }
/* * Scans the hotplug driver directory and looks in the system for * matching devices. * Adds or removes matching readers as necessary. */ LONG HPSearchHotPluggables(void) { HPDriver *drivers = HPDriversGetFromDirectory(PCSCLITE_HP_DROPDIR); if (!drivers) return 1; HPDeviceList devices = NULL; if (HPDriversMatchUSBDevices(drivers, &devices)) return -1; if (HPDriversMatchPCCardDevices(drivers, &devices)) return -1; HPDevice *a; for (a = devices; a; a = a->m_next) { int found = FALSE; HPDevice *b; for (b = sDeviceList; b; b = b->m_next) { if (HPDeviceEquals(a, b)) { found = TRUE; break; } } if (!found) { char deviceName[MAX_DEVICENAME]; /* the format should be "usb:%04x/%04x:libusb:%s" but we do not * know the libusb string. So it is not possible to differentiate * two identical readers :-( */ snprintf(deviceName, sizeof(deviceName), "usb:%04x/%04x", (unsigned int)a->m_driver->m_vendorId, (unsigned int)a->m_driver->m_productId); deviceName[sizeof(deviceName)-1] = '\0'; RFAddReader(a->m_driver->m_friendlyName, PCSCLITE_HP_BASE_PORT + a->m_address, a->m_driver->m_libPath, deviceName); } } for (a = sDeviceList; a; a = a->m_next) { int found = FALSE; HPDevice *b; for (b = devices; b; b = b->m_next) { if (HPDeviceEquals(a, b)) { found = TRUE; break; } } if (!found) { RFRemoveReader(a->m_driver->m_friendlyName, PCSCLITE_HP_BASE_PORT + a->m_address); } } HPDeviceListRelease(sDeviceList); sDeviceList = devices; HPDriverVectorRelease(drivers); return 0; }