Lines Matching full:handle
67 static int try_interfaces(IOUSBDeviceInterface182 **dev, usb_handle *handle) {
171 if ((*interface)->GetInterfaceClass(interface, &handle->info.ifc_class) != 0 ||
172 (*interface)->GetInterfaceSubClass(interface, &handle->info.ifc_subclass) != 0 ||
173 (*interface)->GetInterfaceProtocol(interface, &handle->info.ifc_protocol) != 0)
179 handle->info.has_bulk_in = 0;
180 handle->info.has_bulk_out = 0;
201 handle->info.has_bulk_in = 1;
202 handle->bulkIn = endpoint;
204 handle->info.has_bulk_out = 1;
205 handle->bulkOut = endpoint;
208 if (handle->info.ifc_protocol == 0x01) {
209 handle->zero_mask = maxPacketSize - 1;
215 if (handle->info.has_bulk_in && handle->info.has_bulk_out) {
220 if (handle->callback(&handle->info) == 0) {
221 handle->interface = interface;
222 handle->success = 1;
230 if (handle->info.has_bulk_in) {
232 handle->bulkIn);
238 if (handle->info.has_bulk_out) {
240 handle->bulkOut);
260 static int try_device(io_service_t device, usb_handle *handle) {
296 kr = (*dev)->GetDeviceVendor(dev, &handle->info.dev_vendor);
302 kr = (*dev)->GetDeviceProduct(dev, &handle->info.dev_product);
308 kr = (*dev)->GetDeviceClass(dev, &handle->info.dev_class);
314 kr = (*dev)->GetDeviceSubClass(dev, &handle->info.dev_subclass);
320 kr = (*dev)->GetDeviceProtocol(dev, &handle->info.dev_protocol);
331 snprintf(handle->info.device_path, sizeof(handle->info.device_path),
355 handle->info.serial_number[i] = buffer[i + 1];
356 handle->info.serial_number[i] = 0;
360 handle->info.serial_number[0] = 0;
362 handle->info.writable = 1;
364 if (try_interfaces(dev, handle)) {
382 static int init_usb(ifc_match_func callback, usb_handle **handle) {
435 *handle = calloc(1, sizeof(usb_handle));
436 memcpy(*handle, &h, sizeof(usb_handle));
456 usb_handle *handle = NULL;
458 if (init_usb(callback, &handle) < 0) {
463 return handle;