Skip to content

Commit f0fc1d0

Browse files
committed
Merge pull request #141 from cfal/master
Use libimobiledevice idevice_connection_get_fd
2 parents f10c708 + 5a178c5 commit f0fc1d0

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

src/webinspector.c

+8-24
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,21 @@ struct wi_private {
4343
// CONNECT
4444
//
4545

46-
// based on libimobiledevice/src/idevice.h
47-
enum connection_type {
48-
CONNECTION_USBMUXD = 1
49-
};
50-
struct idevice_connection_private {
51-
char *udid; // added in v1.1.6
52-
enum connection_type type;
53-
void *data;
54-
void *ssl_data;
55-
};
56-
57-
wi_status idevice_connection_get_fd(idevice_connection_t connection,
46+
wi_status idevice_connection_get_fd_wrapper(idevice_connection_t connection,
5847
int *to_fd) {
59-
if (!connection || !to_fd) {
60-
return WI_ERROR;
61-
}
62-
idevice_connection_private *c = (
63-
(sizeof(*connection) == sizeof(idevice_connection_private)) ?
64-
(idevice_connection_private *) connection : NULL);
65-
if (!c || c->type != CONNECTION_USBMUXD || c->data <= 0 || c->ssl_data) {
66-
perror("Invalid idevice_connection struct. Please verify that "
67-
__FILE__ "'s idevice_connection_private matches your version of"
68-
" libimbiledevice/src/idevice.h");
48+
49+
int fd;
50+
idevice_error_t err = idevice_connection_get_fd(connection, &fd);
51+
if (err < 0) {
6952
return WI_ERROR;
7053
}
71-
int fd = (int)(long)c->data;
54+
7255
struct stat fd_stat;
7356
if (fstat(fd, &fd_stat) < 0 || !S_ISSOCK(fd_stat.st_mode)) {
7457
perror("idevice_connection fd is not a socket?");
7558
return WI_ERROR;
7659
}
60+
7761
*to_fd = fd;
7862
return WI_SUCCESS;
7963
}
@@ -134,7 +118,7 @@ int wi_connect(const char *device_id, char **to_device_id,
134118
}
135119

136120
// extract the connection fd
137-
if (idevice_connection_get_fd(connection, &fd)) {
121+
if (idevice_connection_get_fd_wrapper(connection, &fd)) {
138122
perror("Unable to get connection file descriptor.");
139123
goto leave_cleanup;
140124
}

0 commit comments

Comments
 (0)