diff options
| author | 2015-09-23 02:19:27 +0200 | |
|---|---|---|
| committer | 2016-04-01 22:53:13 +0200 | |
| commit | 692f7c9de72ca7fcaba51659972270d445751438 (patch) | |
| tree | cc03556a0e4b39638885c2f8a602a9258494dfaa | |
| parent | 15173c59a00a8e9c154bd6787e35c243c383160e (diff) | |
| download | libimobiledevice-692f7c9de72ca7fcaba51659972270d445751438.tar.gz libimobiledevice-692f7c9de72ca7fcaba51659972270d445751438.tar.bz2 | |
Add new function to get the underlying file descriptor of an idevice connection
| -rw-r--r-- | include/libimobiledevice/libimobiledevice.h | 10 | ||||
| -rw-r--r-- | src/idevice.c | 16 |
2 files changed, 26 insertions, 0 deletions
diff --git a/include/libimobiledevice/libimobiledevice.h b/include/libimobiledevice/libimobiledevice.h index 016cadb..b125adf 100644 --- a/include/libimobiledevice/libimobiledevice.h +++ b/include/libimobiledevice/libimobiledevice.h | |||
| @@ -239,6 +239,16 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection); | |||
| 239 | */ | 239 | */ |
| 240 | idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection); | 240 | idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection); |
| 241 | 241 | ||
| 242 | /** | ||
| 243 | * Get the underlying file descriptor for a connection | ||
| 244 | * | ||
| 245 | * @param connection The connection to get fd of | ||
| 246 | * @param fd Pointer to an int where the fd is stored | ||
| 247 | * | ||
| 248 | * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. | ||
| 249 | */ | ||
| 250 | idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd); | ||
| 251 | |||
| 242 | /* misc */ | 252 | /* misc */ |
| 243 | 253 | ||
| 244 | /** | 254 | /** |
diff --git a/src/idevice.c b/src/idevice.c index b776e84..5912aeb 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -463,6 +463,22 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive(idevice_connecti | |||
| 463 | return internal_connection_receive(connection, data, len, recv_bytes); | 463 | return internal_connection_receive(connection, data, len, recv_bytes); |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd) | ||
| 467 | { | ||
| 468 | if (!connection || !fd) { | ||
| 469 | return IDEVICE_E_INVALID_ARG; | ||
| 470 | } | ||
| 471 | |||
| 472 | idevice_error_t result = IDEVICE_E_UNKNOWN_ERROR; | ||
| 473 | if (connection->type == CONNECTION_USBMUXD) { | ||
| 474 | *fd = (int)(long)connection->data; | ||
| 475 | result = IDEVICE_E_SUCCESS; | ||
| 476 | } else { | ||
| 477 | debug_info("Unknown connection type %d", connection->type); | ||
| 478 | } | ||
| 479 | return result; | ||
| 480 | } | ||
| 481 | |||
| 466 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) | 482 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) |
| 467 | { | 483 | { |
| 468 | if (!device) | 484 | if (!device) |
