@@ -43,37 +43,21 @@ struct wi_private {
43
43
// CONNECT
44
44
//
45
45
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 ,
58
47
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 ) {
69
52
return WI_ERROR ;
70
53
}
71
- int fd = ( int )( long ) c -> data ;
54
+
72
55
struct stat fd_stat ;
73
56
if (fstat (fd , & fd_stat ) < 0 || !S_ISSOCK (fd_stat .st_mode )) {
74
57
perror ("idevice_connection fd is not a socket?" );
75
58
return WI_ERROR ;
76
59
}
60
+
77
61
* to_fd = fd ;
78
62
return WI_SUCCESS ;
79
63
}
@@ -134,7 +118,7 @@ int wi_connect(const char *device_id, char **to_device_id,
134
118
}
135
119
136
120
// extract the connection fd
137
- if (idevice_connection_get_fd (connection , & fd )) {
121
+ if (idevice_connection_get_fd_wrapper (connection , & fd )) {
138
122
perror ("Unable to get connection file descriptor." );
139
123
goto leave_cleanup ;
140
124
}
0 commit comments