Lines Matching defs:handle

70 int recognized_device(usb_handle* handle, ifc_match_func callback);
75 /// Writes data to the opened usb handle
76 int usb_write(usb_handle* handle, const void* data, int len);
78 /// Reads data using the opened usb handle
79 int usb_read(usb_handle *handle, void* data, int len);
81 /// Cleans up opened usb handle
82 void usb_cleanup_handle(usb_handle* handle);
84 /// Cleans up (but don't close) opened usb handle
85 void usb_kick(usb_handle* handle);
87 /// Closes opened usb handle
88 int usb_close(usb_handle* handle);
92 // Allocate our handle
154 int usb_write(usb_handle* handle, const void* data, int len) {
161 if (NULL != handle) {
165 ret = AdbWriteEndpointSync(handle->adb_write_pipe,
175 usb_kick(handle);
187 DBG("usb_write NULL handle\n");
196 int usb_read(usb_handle *handle, void* data, int len) {
202 if (NULL != handle) {
206 ret = AdbReadEndpointSync(handle->adb_read_pipe,
218 usb_kick(handle);
224 DBG("usb_read NULL handle\n");
233 void usb_cleanup_handle(usb_handle* handle) {
234 if (NULL != handle) {
235 if (NULL != handle->interface_name)
236 free(handle->interface_name);
237 if (NULL != handle->adb_write_pipe)
238 AdbCloseHandle(handle->adb_write_pipe);
239 if (NULL != handle->adb_read_pipe)
240 AdbCloseHandle(handle->adb_read_pipe);
241 if (NULL != handle->adb_interface)
242 AdbCloseHandle(handle->adb_interface);
244 handle->interface_name = NULL;
245 handle->adb_write_pipe = NULL;
246 handle->adb_read_pipe = NULL;
247 handle->adb_interface = NULL;
251 void usb_kick(usb_handle* handle) {
252 if (NULL != handle) {
253 usb_cleanup_handle(handle);
260 int usb_close(usb_handle* handle) {
263 if (NULL != handle) {
264 // Cleanup handle
265 usb_cleanup_handle(handle);
266 free(handle);
272 int recognized_device(usb_handle* handle, ifc_match_func callback) {
277 if (NULL == handle)
281 if (!AdbGetUsbDeviceDescriptor(handle->adb_interface,
287 if (!AdbGetUsbInterfaceDescriptor(handle->adb_interface,
309 if (!AdbGetSerialNumber(handle->adb_interface, info.serial_number,
324 usb_handle* handle = NULL;
350 handle = do_usb_open(next_interface->device_name);
351 if (NULL != handle) {
353 if (recognized_device(handle, callback)) {
357 usb_cleanup_handle(handle);
358 free(handle);
359 handle = NULL;
367 return handle;