diff options
Diffstat (limited to 'src/iphone.c')
| -rw-r--r-- | src/iphone.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/iphone.c b/src/iphone.c index 9551173..0e179e7 100644 --- a/src/iphone.c +++ b/src/iphone.c | |||
| @@ -43,6 +43,7 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u | |||
| 43 | { | 43 | { |
| 44 | iphone_device_t phone; | 44 | iphone_device_t phone; |
| 45 | uint32_t handle = 0; | 45 | uint32_t handle = 0; |
| 46 | char *serial_number = malloc(41); | ||
| 46 | usbmuxd_scan_result *dev_list = NULL; | 47 | usbmuxd_scan_result *dev_list = NULL; |
| 47 | int i; | 48 | int i; |
| 48 | 49 | ||
| @@ -53,12 +54,14 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u | |||
| 53 | if (!uuid) { | 54 | if (!uuid) { |
| 54 | // select first device found if no UUID specified | 55 | // select first device found if no UUID specified |
| 55 | handle = dev_list[0].handle; | 56 | handle = dev_list[0].handle; |
| 57 | strcpy(serial_number, dev_list[0].serial_number); | ||
| 56 | } else { | 58 | } else { |
| 57 | // otherwise walk through the list | 59 | // otherwise walk through the list |
| 58 | for (i = 0; dev_list[i].handle > 0; i++) { | 60 | for (i = 0; dev_list[i].handle > 0; i++) { |
| 59 | log_debug_msg("%s: device handle=%d, uuid=%s\n", __func__, dev_list[i].handle, dev_list[i].serial_number); | 61 | log_debug_msg("%s: device handle=%d, uuid=%s\n", __func__, dev_list[i].handle, dev_list[i].serial_number); |
| 60 | if (strcasecmp(uuid, dev_list[i].serial_number) == 0) { | 62 | if (strcasecmp(uuid, dev_list[i].serial_number) == 0) { |
| 61 | handle = dev_list[i].handle; | 63 | handle = dev_list[i].handle; |
| 64 | strcpy(serial_number, dev_list[i].serial_number); | ||
| 62 | break; | 65 | break; |
| 63 | } | 66 | } |
| 64 | } | 67 | } |
| @@ -68,6 +71,7 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u | |||
| 68 | if (handle > 0) { | 71 | if (handle > 0) { |
| 69 | phone = (iphone_device_t) malloc(sizeof(struct iphone_device_int)); | 72 | phone = (iphone_device_t) malloc(sizeof(struct iphone_device_int)); |
| 70 | phone->handle = handle; | 73 | phone->handle = handle; |
| 74 | phone->serial_number = serial_number; | ||
| 71 | *device = phone; | 75 | *device = phone; |
| 72 | return IPHONE_E_SUCCESS; | 76 | return IPHONE_E_SUCCESS; |
| 73 | } | 77 | } |
| @@ -100,6 +104,15 @@ uint32_t iphone_get_device_handle(iphone_device_t device) | |||
| 100 | } | 104 | } |
| 101 | } | 105 | } |
| 102 | 106 | ||
| 107 | char* iphone_get_uuid(iphone_device_t device) | ||
| 108 | { | ||
| 109 | if (device) { | ||
| 110 | return device->serial_number; | ||
| 111 | } else { | ||
| 112 | return NULL; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 103 | /** Cleans up an iPhone structure, then frees the structure itself. | 116 | /** Cleans up an iPhone structure, then frees the structure itself. |
| 104 | * This is a library-level function; deals directly with the iPhone to tear | 117 | * This is a library-level function; deals directly with the iPhone to tear |
| 105 | * down relations, but otherwise is mostly internal. | 118 | * down relations, but otherwise is mostly internal. |
| @@ -114,6 +127,7 @@ iphone_error_t iphone_free_device(iphone_device_t device) | |||
| 114 | 127 | ||
| 115 | ret = IPHONE_E_SUCCESS; | 128 | ret = IPHONE_E_SUCCESS; |
| 116 | 129 | ||
| 130 | free(device->serial_number); | ||
| 117 | free(device); | 131 | free(device); |
| 118 | return ret; | 132 | return ret; |
| 119 | } | 133 | } |
