summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--iphone.c45
-rw-r--r--libusbmuxd.c6
-rw-r--r--main.c6
-rw-r--r--sock_stuff.c2
4 files changed, 13 insertions, 46 deletions
diff --git a/iphone.c b/iphone.c
index 21b8281..c759899 100644
--- a/iphone.c
+++ b/iphone.c
@@ -314,7 +314,7 @@ iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t
314 314
315 // Set the device configuration 315 // Set the device configuration
316 for (bus = usb_get_busses(); bus; bus = bus->next) 316 for (bus = usb_get_busses(); bus; bus = bus->next)
317 if (bus->location == bus_n) 317 //if (bus->location == bus_n)
318 for (dev = bus->devices; dev != NULL; dev = dev->next) 318 for (dev = bus->devices; dev != NULL; dev = dev->next)
319 if (dev->devnum == dev_n) { 319 if (dev->devnum == dev_n) {
320 phone->__device = dev; 320 phone->__device = dev;
@@ -374,41 +374,6 @@ iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t
374 return IPHONE_E_UNKNOWN_ERROR; // if it got to this point it's gotta be bad 374 return IPHONE_E_UNKNOWN_ERROR; // if it got to this point it's gotta be bad
375} 375}
376 376
377
378/**
379 * Scans all USB busses and devices for a known AFC-compatible device and
380 * returns a handle to the first such device it finds. Known devices include
381 * those with vendor ID 0x05ac and product ID between 0x1290 and 0x1293
382 * inclusive.
383 *
384 * This function is convenient, but on systems where higher-level abstractions
385 * (such as HAL) are available it may be preferable to use
386 * iphone_get_specific_device instead, because it can deal with multiple
387 * connected devices as well as devices not known to libiphone.
388 *
389 * @param device Upon calling this function, a pointer to a location of type
390 * iphone_device_t, which must have the value NULL. On return, this location
391 * will be filled with a handle to the device.
392 * @return IPHONE_E_SUCCESS if ok, otherwise an error code.
393 */
394iphone_error_t iphone_get_device(iphone_device_t * device)
395{
396 struct usb_bus *bus;
397 struct usb_device *dev;
398
399 usb_init();
400 usb_find_busses();
401 usb_find_devices();
402
403 for (bus = usb_get_busses(); bus != NULL; bus = bus->next)
404 for (dev = bus->devices; dev != NULL; dev = dev->next)
405 if (dev->descriptor.idVendor == 0x05ac
406 && dev->descriptor.idProduct >= 0x1290 && dev->descriptor.idProduct <= 0x1293)
407 return iphone_get_specific_device(bus->location, dev->devnum, device);
408
409 return IPHONE_E_NO_DEVICE;
410}
411
412/** Cleans up an iPhone structure, then frees the structure itself. 377/** Cleans up an iPhone structure, then frees the structure itself.
413 * This is a library-level function; deals directly with the iPhone to tear 378 * This is a library-level function; deals directly with the iPhone to tear
414 * down relations, but otherwise is mostly internal. 379 * down relations, but otherwise is mostly internal.
@@ -845,7 +810,7 @@ iphone_error_t iphone_mux_send(iphone_umux_client_t client, const char *data, ui
845 ntoh_header(client->header); 810 ntoh_header(client->header);
846 811
847 // update counts ONLY if the send succeeded. 812 // update counts ONLY if the send succeeded.
848 if (sendresult == blocksize) { 813 if ((uint32_t)sendresult == blocksize) {
849 // Re-calculate scnt 814 // Re-calculate scnt
850 client->header->scnt += datalen; 815 client->header->scnt += datalen;
851 client->wr_window -= blocksize; 816 client->wr_window -= blocksize;
@@ -863,7 +828,7 @@ iphone_error_t iphone_mux_send(iphone_umux_client_t client, const char *data, ui
863 else if (sendresult < 0) { 828 else if (sendresult < 0) {
864 return IPHONE_E_UNKNOWN_ERROR; 829 return IPHONE_E_UNKNOWN_ERROR;
865 } 830 }
866 else if (sendresult == blocksize) { 831 else if ((uint32_t)sendresult == blocksize) {
867 // actual number of data bytes sent. 832 // actual number of data bytes sent.
868 *sent_bytes = sendresult - HEADERLEN; 833 *sent_bytes = sendresult - HEADERLEN;
869 return IPHONE_E_SUCCESS; 834 return IPHONE_E_SUCCESS;
@@ -1097,7 +1062,7 @@ int iphone_mux_pullbulk(iphone_device_t phone)
1097 // now that we have a header, check if there is sufficient data 1062 // now that we have a header, check if there is sufficient data
1098 // to construct a full packet, including its data 1063 // to construct a full packet, including its data
1099 uint32_t packetlen = ntohl(header->length); 1064 uint32_t packetlen = ntohl(header->length);
1100 if (phone->usbReceive.leftover < packetlen) { 1065 if ((uint32_t)phone->usbReceive.leftover < packetlen) {
1101 fprintf(stderr, "%s: not enough data to construct a full packet\n", __func__); 1066 fprintf(stderr, "%s: not enough data to construct a full packet\n", __func__);
1102 break; 1067 break;
1103 } 1068 }
@@ -1205,7 +1170,7 @@ iphone_error_t iphone_mux_recv_timeout(iphone_umux_client_t client, char *data,
1205 *recv_bytes = 0; 1170 *recv_bytes = 0;
1206 if (client->recv_buffer != NULL && client->r_len > 0) { 1171 if (client->recv_buffer != NULL && client->r_len > 0) {
1207 uint32_t foolen = datalen; 1172 uint32_t foolen = datalen;
1208 if (foolen > client->r_len) foolen = client->r_len; 1173 if ((int)foolen > client->r_len) foolen = client->r_len;
1209 memcpy(data, client->recv_buffer, foolen); 1174 memcpy(data, client->recv_buffer, foolen);
1210 *recv_bytes = foolen; 1175 *recv_bytes = foolen;
1211 1176
diff --git a/libusbmuxd.c b/libusbmuxd.c
index c12a7c0..edd585c 100644
--- a/libusbmuxd.c
+++ b/libusbmuxd.c
@@ -28,7 +28,7 @@ static int usbmuxd_get_result(int sfd, uint32_t tag, uint32_t *result)
28 return -errno; 28 return -errno;
29 } else { 29 } else {
30 if ((recv_len == sizeof(res)) 30 if ((recv_len == sizeof(res))
31 && (res.header.length == recv_len) 31 && (res.header.length == (uint32_t)recv_len)
32 && (res.header.reserved == 0) 32 && (res.header.reserved == 0)
33 && (res.header.type == USBMUXD_RESULT) 33 && (res.header.type == USBMUXD_RESULT)
34 ) { 34 ) {
@@ -68,7 +68,7 @@ int usbmuxd_scan(usbmuxd_scan_result **available_devices)
68 s_req.header.tag = 2; 68 s_req.header.tag = 2;
69 69
70 // send scan request packet 70 // send scan request packet
71 if (send_buf(sfd, &s_req, s_req.header.length) == s_req.header.length) { 71 if (send_buf(sfd, &s_req, s_req.header.length) == (int)s_req.header.length) {
72 res = -1; 72 res = -1;
73 // get response 73 // get response
74 if (usbmuxd_get_result(sfd, s_req.header.tag, &res) && (res == 0)) { 74 if (usbmuxd_get_result(sfd, s_req.header.tag, &res) && (res == 0)) {
@@ -99,7 +99,7 @@ int usbmuxd_scan(usbmuxd_scan_result **available_devices)
99 if (recv_len <= 0) { 99 if (recv_len <= 0) {
100 fprintf(stderr, "%s: Error when receiving device info record\n", __func__); 100 fprintf(stderr, "%s: Error when receiving device info record\n", __func__);
101 break; 101 break;
102 } else if (recv_len < pktlen) { 102 } else if ((uint32_t)recv_len < pktlen) {
103 fprintf(stderr, "%s: received less data than specified in header!\n", __func__); 103 fprintf(stderr, "%s: received less data than specified in header!\n", __func__);
104 } else { 104 } else {
105 //fprintf(stderr, "%s: got device record with id %d, UUID=%s\n", __func__, dev_info_pkt.device_info.device_id, dev_info_pkt.device_info.serial_number); 105 //fprintf(stderr, "%s: got device record with id %d, UUID=%s\n", __func__, dev_info_pkt.device_info.device_id, dev_info_pkt.device_info.serial_number);
diff --git a/main.c b/main.c
index 8fb36ef..c9bf884 100644
--- a/main.c
+++ b/main.c
@@ -95,7 +95,7 @@ static pthread_mutex_t usb_mutex = PTHREAD_MUTEX_INITIALIZER;
95 * @param prio The logging priority. 95 * @param prio The logging priority.
96 * @param format The message to be printed. 96 * @param format The message to be printed.
97 */ 97 */
98static void logmsg(int prio, char *format, ...) 98static void logmsg(int prio, const char *format, ...)
99{ 99{
100 va_list args; 100 va_list args;
101 va_start(args, format); 101 va_start(args, format);
@@ -179,7 +179,7 @@ static int usbmuxd_get_request(int fd, void **data, size_t len)
179 uint32_t pktlen; 179 uint32_t pktlen;
180 int recv_len; 180 int recv_len;
181 181
182 if (peek_buf(fd, &pktlen, sizeof(pktlen)) < sizeof(pktlen)) { 182 if (peek_buf(fd, &pktlen, sizeof(pktlen)) < (int)sizeof(pktlen)) {
183 return -errno; 183 return -errno;
184 } 184 }
185 185
@@ -193,7 +193,7 @@ static int usbmuxd_get_request(int fd, void **data, size_t len)
193 } 193 }
194 194
195 recv_len = recv_buf(fd, *data, pktlen); 195 recv_len = recv_buf(fd, *data, pktlen);
196 if ((recv_len > 0) && (recv_len < pktlen)) { 196 if ((recv_len > 0) && ((uint32_t)recv_len < pktlen)) {
197 if (verbose >= 2) logmsg(LOG_WARNING, "%s: Uh-oh, we got less than the packet's size, %d instead of %d...", __func__, recv_len, pktlen); 197 if (verbose >= 2) logmsg(LOG_WARNING, "%s: Uh-oh, we got less than the packet's size, %d instead of %d...", __func__, recv_len, pktlen);
198 } 198 }
199 199
diff --git a/sock_stuff.c b/sock_stuff.c
index 8a06135..43fdf0e 100644
--- a/sock_stuff.c
+++ b/sock_stuff.c
@@ -224,6 +224,8 @@ int check_fd(int fd, fd_mode fdm, unsigned int timeout)
224 case FD_EXCEPT: 224 case FD_EXCEPT:
225 sret = select(fd+1,NULL,NULL,&fds,&to); 225 sret = select(fd+1,NULL,NULL,&fds,&to);
226 break; 226 break;
227 default:
228 return -1;
227 } 229 }
228 230
229 if (sret < 0) { 231 if (sret < 0) {