Lines Matching refs: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) {
295 kr = (*dev)->GetDeviceVendor(dev, &handle->info.dev_vendor);
301 kr = (*dev)->GetDeviceProduct(dev, &handle->info.dev_product);
307 kr = (*dev)->GetDeviceClass(dev, &handle->info.dev_class);
313 kr = (*dev)->GetDeviceSubClass(dev, &handle->info.dev_subclass);
319 kr = (*dev)->GetDeviceProtocol(dev, &handle->info.dev_protocol);
346 handle->info.serial_number[i] = buffer[i + 1];
347 handle->info.serial_number[i] = 0;
351 handle->info.serial_number[0] = 0;
353 handle->info.writable = 1;
355 if (try_interfaces(dev, handle)) {
373 static int init_usb(ifc_match_func callback, usb_handle **handle) {
426 *handle = calloc(1, sizeof(usb_handle));
427 memcpy(*handle, &h, sizeof(usb_handle));
447 usb_handle *handle = NULL;
449 if (init_usb(callback, &handle) < 0) {
454 return handle;