diff options
Diffstat (limited to 'src/iphone.c')
| -rw-r--r-- | src/iphone.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/iphone.c b/src/iphone.c index 0e179e7..e694373 100644 --- a/src/iphone.c +++ b/src/iphone.c | |||
| @@ -19,13 +19,12 @@ | |||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include "iphone.h" | ||
| 23 | #include "utils.h" | ||
| 24 | #include <stdio.h> | 22 | #include <stdio.h> |
| 25 | #include <stdlib.h> | 23 | #include <stdlib.h> |
| 26 | #include <string.h> | 24 | #include <string.h> |
| 27 | #include <errno.h> | 25 | |
| 28 | #include <libiphone/libiphone.h> | 26 | #include "iphone.h" |
| 27 | #include "utils.h" | ||
| 29 | 28 | ||
| 30 | /** | 29 | /** |
| 31 | * Retrieves a list of connected devices from usbmuxd and matches their | 30 | * Retrieves a list of connected devices from usbmuxd and matches their |
| @@ -52,11 +51,11 @@ iphone_error_t iphone_get_device_by_uuid(iphone_device_t * device, const char *u | |||
| 52 | } | 51 | } |
| 53 | if (dev_list && dev_list[0].handle > 0) { | 52 | if (dev_list && dev_list[0].handle > 0) { |
| 54 | if (!uuid) { | 53 | if (!uuid) { |
| 55 | // select first device found if no UUID specified | 54 | /* select first device found if no UUID specified */ |
| 56 | handle = dev_list[0].handle; | 55 | handle = dev_list[0].handle; |
| 57 | strcpy(serial_number, dev_list[0].serial_number); | 56 | strcpy(serial_number, dev_list[0].serial_number); |
| 58 | } else { | 57 | } else { |
| 59 | // otherwise walk through the list | 58 | /* otherwise walk through the list */ |
| 60 | for (i = 0; dev_list[i].handle > 0; i++) { | 59 | for (i = 0; dev_list[i].handle > 0; i++) { |
| 61 | log_debug_msg("%s: device handle=%d, uuid=%s\n", __func__, dev_list[i].handle, dev_list[i].serial_number); | 60 | log_debug_msg("%s: device handle=%d, uuid=%s\n", __func__, dev_list[i].handle, dev_list[i].serial_number); |
| 62 | if (strcasecmp(uuid, dev_list[i].serial_number) == 0) { | 61 | if (strcasecmp(uuid, dev_list[i].serial_number) == 0) { |
| @@ -95,22 +94,22 @@ iphone_error_t iphone_get_device(iphone_device_t * device) | |||
| 95 | return iphone_get_device_by_uuid(device, NULL); | 94 | return iphone_get_device_by_uuid(device, NULL); |
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | uint32_t iphone_get_device_handle(iphone_device_t device) | 97 | iphone_error_t iphone_device_get_handle(iphone_device_t device, uint32_t *handle) |
| 99 | { | 98 | { |
| 100 | if (device) { | 99 | if (!device) |
| 101 | return device->handle; | 100 | return IPHONE_E_INVALID_ARG; |
| 102 | } else { | 101 | |
| 103 | return 0; | 102 | *handle = device->handle; |
| 104 | } | 103 | return IPHONE_E_SUCCESS; |
| 105 | } | 104 | } |
| 106 | 105 | ||
| 107 | char* iphone_get_uuid(iphone_device_t device) | 106 | iphone_error_t iphone_device_get_uuid(iphone_device_t device, char **uuid) |
| 108 | { | 107 | { |
| 109 | if (device) { | 108 | if (!device) |
| 110 | return device->serial_number; | 109 | return IPHONE_E_INVALID_ARG; |
| 111 | } else { | 110 | |
| 112 | return NULL; | 111 | *uuid = strdup(device->serial_number); |
| 113 | } | 112 | return IPHONE_E_SUCCESS; |
| 114 | } | 113 | } |
| 115 | 114 | ||
| 116 | /** Cleans up an iPhone structure, then frees the structure itself. | 115 | /** Cleans up an iPhone structure, then frees the structure itself. |
| @@ -119,7 +118,7 @@ char* iphone_get_uuid(iphone_device_t device) | |||
| 119 | * | 118 | * |
| 120 | * @param phone A pointer to an iPhone structure. | 119 | * @param phone A pointer to an iPhone structure. |
| 121 | */ | 120 | */ |
| 122 | iphone_error_t iphone_free_device(iphone_device_t device) | 121 | iphone_error_t iphone_device_free(iphone_device_t device) |
| 123 | { | 122 | { |
| 124 | if (!device) | 123 | if (!device) |
| 125 | return IPHONE_E_INVALID_ARG; | 124 | return IPHONE_E_INVALID_ARG; |
