2
* @file libimobiledevice/libimobiledevice.h
3
* @brief Common code and device handling
6
* Copyright (c) 2008 Jonathan Beck All Rights Reserved.
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
#ifndef LIBIMOBILEDEVICE_H
24
#define LIBIMOBILEDEVICE_H
31
#include <sys/types.h>
33
#include <plist/plist.h>
36
#define IDEVICE_E_SUCCESS 0
37
#define IDEVICE_E_INVALID_ARG -1
38
#define IDEVICE_E_UNKNOWN_ERROR -2
39
#define IDEVICE_E_NO_DEVICE -3
40
#define IDEVICE_E_NOT_ENOUGH_DATA -4
41
#define IDEVICE_E_BAD_HEADER -5
42
#define IDEVICE_E_SSL_ERROR -6
44
typedef int16_t idevice_error_t;
47
typedef struct idevice_int *idevice_t;
49
struct idevice_connection_int;
50
typedef struct idevice_connection_int *idevice_connection_t;
53
void idevice_set_debug_level(int level);
55
/* discovery (events/asynchronous) */
57
enum idevice_event_type {
58
IDEVICE_DEVICE_ADD = 1,
62
// event data structure
64
enum idevice_event_type event;
69
// event callback function prototype
70
typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_data);
73
idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data);
74
idevice_error_t idevice_event_unsubscribe();
76
/* discovery (synchronous) */
77
idevice_error_t idevice_get_device_list(char ***devices, int *count);
78
idevice_error_t idevice_device_list_free(char **devices);
80
/* device structure creation and destruction */
81
idevice_error_t idevice_new(idevice_t *device, const char *uuid);
82
idevice_error_t idevice_free(idevice_t device);
84
/* connection/disconnection */
85
idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection);
86
idevice_error_t idevice_disconnect(idevice_connection_t connection);
89
idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes);
90
idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout);
91
idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes);
94
idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle);
95
idevice_error_t idevice_get_uuid(idevice_t device, char **uuid);