summaryrefslogtreecommitdiffstats
path: root/src/iphone.c
diff options
context:
space:
mode:
authorGravatar Matt Colyer2009-07-26 19:34:22 -0700
committerGravatar Matt Colyer2009-07-26 19:34:22 -0700
commiteea538c94f01f8054f69f059614f19400187a472 (patch)
tree209a12dc8c8eaece15b8153d15e689c8c2147ab6 /src/iphone.c
parent8ebfd7d8eea89bb27e4e6dbb1f37fd90d98b439c (diff)
parent19c9750d670435ce430f0fc85a55faf127bdfbf9 (diff)
downloadlibimobiledevice-eea538c94f01f8054f69f059614f19400187a472.tar.gz
libimobiledevice-eea538c94f01f8054f69f059614f19400187a472.tar.bz2
Merge commit 'martin-s/martin'
[#46 state:resolved]
Diffstat (limited to 'src/iphone.c')
-rw-r--r--src/iphone.c37
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
98uint32_t iphone_get_device_handle(iphone_device_t device) 97iphone_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
107char* iphone_get_uuid(iphone_device_t device) 106iphone_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 */
122iphone_error_t iphone_free_device(iphone_device_t device) 121iphone_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;