summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml31
-rw-r--r--3rd_party/ed25519/Makefile.am2
-rw-r--r--3rd_party/ed25519/seed.c2
-rw-r--r--3rd_party/libsrp6a-sha512/Makefile.am14
-rw-r--r--3rd_party/libsrp6a-sha512/t_conv.c35
-rw-r--r--3rd_party/libsrp6a-sha512/t_math.c116
-rw-r--r--3rd_party/libsrp6a-sha512/t_misc.c21
-rw-r--r--3rd_party/libsrp6a-sha512/t_sha.c40
-rw-r--r--3rd_party/libsrp6a-sha512/t_sha.h24
-rw-r--r--3rd_party/libsrp6a-sha512/t_truerand.c3
-rw-r--r--README.md5
-rw-r--r--common/Makefile.am18
-rw-r--r--common/debug.c6
-rw-r--r--common/userpref.c27
-rw-r--r--configure.ac70
-rw-r--r--cython/Makefile.am16
-rw-r--r--cython/lockdown.pxi5
-rw-r--r--docs/Makefile.am1
-rw-r--r--docs/afcclient.176
-rw-r--r--docs/idevicebackup2.12
-rw-r--r--docs/idevicedebugserverproxy.13
-rw-r--r--docs/idevicedevmodectl.158
-rw-r--r--docs/idevicesyslog.19
-rw-r--r--doxygen.cfg.in8
-rwxr-xr-xgit-version-gen3
-rw-r--r--include/libimobiledevice/afc.h55
-rw-r--r--include/libimobiledevice/bt_packet_logger.h12
-rw-r--r--include/libimobiledevice/companion_proxy.h22
-rw-r--r--include/libimobiledevice/debugserver.h32
-rw-r--r--include/libimobiledevice/diagnostics_relay.h22
-rw-r--r--include/libimobiledevice/file_relay.h10
-rw-r--r--include/libimobiledevice/heartbeat.h12
-rw-r--r--include/libimobiledevice/house_arrest.h14
-rw-r--r--include/libimobiledevice/installation_proxy.h48
-rw-r--r--include/libimobiledevice/libimobiledevice.h63
-rw-r--r--include/libimobiledevice/lockdown.h64
-rw-r--r--include/libimobiledevice/misagent.h16
-rw-r--r--include/libimobiledevice/mobile_image_mounter.h14
-rw-r--r--include/libimobiledevice/mobileactivation.h20
-rw-r--r--include/libimobiledevice/mobilebackup.h24
-rw-r--r--include/libimobiledevice/mobilebackup2.h20
-rw-r--r--include/libimobiledevice/mobilesync.h42
-rw-r--r--include/libimobiledevice/notification_proxy.h14
-rw-r--r--include/libimobiledevice/preboard.h16
-rw-r--r--include/libimobiledevice/property_list_service.h18
-rw-r--r--include/libimobiledevice/restore.h22
-rw-r--r--include/libimobiledevice/reverse_proxy.h16
-rw-r--r--include/libimobiledevice/sbservices.h16
-rw-r--r--include/libimobiledevice/screenshotr.h8
-rw-r--r--include/libimobiledevice/service.h21
-rw-r--r--include/libimobiledevice/syslog_relay.h16
-rw-r--r--include/libimobiledevice/webinspector.h12
-rw-r--r--src/Makefile.am14
-rw-r--r--src/afc.c117
-rw-r--r--src/bt_packet_logger.c12
-rw-r--r--src/bt_packet_logger.h1
-rw-r--r--src/companion_proxy.c22
-rw-r--r--src/companion_proxy.h1
-rw-r--r--src/debugserver.c32
-rw-r--r--src/debugserver.h1
-rw-r--r--src/device_link_service.h1
-rw-r--r--src/diagnostics_relay.c22
-rw-r--r--src/diagnostics_relay.h1
-rw-r--r--src/file_relay.c10
-rw-r--r--src/file_relay.h1
-rw-r--r--src/heartbeat.c12
-rw-r--r--src/heartbeat.h1
-rw-r--r--src/house_arrest.c14
-rw-r--r--src/house_arrest.h1
-rw-r--r--src/idevice.c205
-rw-r--r--src/idevice.h16
-rw-r--r--src/installation_proxy.c50
-rw-r--r--src/installation_proxy.h1
-rw-r--r--src/lockdown-cu.c17
-rw-r--r--src/lockdown.c110
-rw-r--r--src/lockdown.h1
-rw-r--r--src/misagent.c16
-rw-r--r--src/misagent.h1
-rw-r--r--src/mobile_image_mounter.c14
-rw-r--r--src/mobile_image_mounter.h1
-rw-r--r--src/mobileactivation.c20
-rw-r--r--src/mobileactivation.h1
-rw-r--r--src/mobilebackup.c45
-rw-r--r--src/mobilebackup.h1
-rw-r--r--src/mobilebackup2.c20
-rw-r--r--src/mobilebackup2.h1
-rw-r--r--src/mobilesync.c42
-rw-r--r--src/mobilesync.h1
-rw-r--r--src/notification_proxy.c14
-rw-r--r--src/notification_proxy.h1
-rw-r--r--src/preboard.c16
-rw-r--r--src/preboard.h1
-rw-r--r--src/property_list_service.c18
-rw-r--r--src/property_list_service.h1
-rw-r--r--src/restore.c24
-rw-r--r--src/restore.h1
-rw-r--r--src/reverse_proxy.c26
-rw-r--r--src/reverse_proxy.h1
-rw-r--r--src/sbservices.c21
-rw-r--r--src/sbservices.h1
-rw-r--r--src/screenshotr.c8
-rw-r--r--src/screenshotr.h1
-rw-r--r--src/service.c20
-rw-r--r--src/service.h2
-rw-r--r--src/syslog_relay.c16
-rw-r--r--src/syslog_relay.h1
-rw-r--r--src/webinspector.c12
-rw-r--r--src/webinspector.h1
-rw-r--r--tools/Makefile.am23
-rw-r--r--tools/afcclient.c1346
-rw-r--r--tools/idevicebackup.c41
-rw-r--r--tools/idevicebackup2.c12
-rw-r--r--tools/idevicecrashreport.c4
-rw-r--r--tools/idevicedebug.c5
-rw-r--r--tools/idevicedebugserverproxy.c33
-rw-r--r--tools/idevicedevmodectl.c462
-rw-r--r--tools/ideviceimagemounter.c55
-rw-r--r--tools/ideviceinfo.c6
-rw-r--r--tools/idevicepair.c5
-rw-r--r--tools/ideviceprovision.c4
-rw-r--r--tools/idevicesyslog.c30
121 files changed, 3294 insertions, 988 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5302c01..d054366 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,6 +1,9 @@
name: build
-on: [push]
+on:
+ push:
+ schedule:
+ - cron: '0 0 1 * *'
jobs:
build-linux-ubuntu:
@@ -9,7 +12,7 @@ jobs:
- name: install dependencies
run: |
sudo apt-get update
- sudo apt-get install cython
+ sudo apt-get install cython3
- name: prepare environment
run: |
echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV
@@ -42,7 +45,7 @@ jobs:
done
sudo cp -r extract/* /
sudo ldconfig
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
fetch-depth: 0
- name: autogen
@@ -57,7 +60,7 @@ jobs:
DESTDIR=`pwd`/dest make install
tar -C dest -cf libimobiledevice.tar usr
- name: publish artifact
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: libimobiledevice-latest_${{env.target_triplet}}
path: libimobiledevice.tar
@@ -71,7 +74,7 @@ jobs:
else
brew install libtool autoconf automake pkgconfig
fi
- pip install cython
+ pip3 install cython==0.29.24
shell: bash
- name: fetch libplist
uses: dawidd6/action-download-artifact@v2
@@ -101,7 +104,7 @@ jobs:
tar -C extract -xvf $I
done
sudo cp -r extract/* /
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: install additional requirements
run: |
mkdir -p lib
@@ -130,6 +133,16 @@ jobs:
done
export CFLAGS="$USEARCHS -isysroot $SDKDIR"
echo "Using CFLAGS: $CFLAGS"
+ PYTHON3_BIN=`xcrun -f python3`
+ if test -x $PYTHON3_BIN; then
+ export PYTHON=$PYTHON3_BIN
+ PYTHON_VER=`$PYTHON3_BIN -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'))"`
+ PYTHON_EXEC_PREFIX=`$PYTHON3_BIN -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('exec_prefix'))"`
+ PYTHON_LIBS_PATH=$PYTHON_EXEC_PREFIX/lib
+ PYTHON_FRAMEWORK_PATH=$PYTHON_EXEC_PREFIX/Python3
+ export PYTHON_LIBS="-L$PYTHON_LIBS_PATH -lpython$PYTHON_VER"
+ export PYTHON_EXTRA_LDFLAGS="-Wl,-stack_size,1000000 -framework CoreFoundation $PYTHON_FRAMEWORK_PATH"
+ fi
./autogen.sh PKG_CONFIG_PATH=/usr/local/lib/pkgconfig --enable-debug \
openssl_CFLAGS="-I${{ env.DEPSDIR }}/libressl-${{ env.LIBRESSL_VER }}/include" \
openssl_LIBS="-Xlinker ${{ env.LIBSSL }} -Xlinker ${{ env.LIBCRYPTO }}"
@@ -143,7 +156,7 @@ jobs:
DESTDIR=`pwd`/dest make install
tar -C dest -cf libimobiledevice.tar usr
- name: publish artifact
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: libimobiledevice-latest_macOS
path: libimobiledevice.tar
@@ -207,7 +220,7 @@ jobs:
tar -C extract -xvf $I
done
cp -r extract/* /
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: autogen
run: ./autogen.sh CC=gcc CXX=g++ --enable-debug
- name: make
@@ -220,7 +233,7 @@ jobs:
DESTDIR=`pwd`/dest make install
tar -C dest -cf libimobiledevice.tar ${{ env.dest }}
- name: publish artifact
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: libimobiledevice-latest_${{ matrix.arch }}-${{ env.dest }}
path: libimobiledevice.tar
diff --git a/3rd_party/ed25519/Makefile.am b/3rd_party/ed25519/Makefile.am
index c475331..d8e4e04 100644
--- a/3rd_party/ed25519/Makefile.am
+++ b/3rd_party/ed25519/Makefile.am
@@ -6,7 +6,7 @@ AM_CPPFLAGS = \
AM_CFLAGS = \
$(GLOBAL_CFLAGS) \
- $(openssl_CFLAGS)
+ $(ssl_lib_CFLAGS)
AM_LDFLAGS =
diff --git a/3rd_party/ed25519/seed.c b/3rd_party/ed25519/seed.c
index 11a2e3e..cf252b8 100644
--- a/3rd_party/ed25519/seed.c
+++ b/3rd_party/ed25519/seed.c
@@ -30,7 +30,7 @@ int ed25519_create_seed(unsigned char *seed) {
return 1;
}
- fread(seed, 1, 32, f);
+ if(fread(seed, 1, 32, f)){}
fclose(f);
#endif
diff --git a/3rd_party/libsrp6a-sha512/Makefile.am b/3rd_party/libsrp6a-sha512/Makefile.am
index 8c6e2f5..2acd582 100644
--- a/3rd_party/libsrp6a-sha512/Makefile.am
+++ b/3rd_party/libsrp6a-sha512/Makefile.am
@@ -5,11 +5,9 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \
-Wno-incompatible-pointer-types
-include_HEADERS = srp.h srp_aux.h cstr.h
-
AM_CFLAGS = -DHAVE_CONFIG_H
if HAVE_OPENSSL
-AM_CFLAGS += -DOPENSSL=1 -DOPENSSL_ENGINE=1 $(openssl_CFLAGS)
+AM_CFLAGS += -DOPENSSL=1 $(openssl_CFLAGS)
else
if HAVE_GCRYPT
AM_CFLAGS += -DGCRYPT=1 $(libgcrypt_CFLAGS)
@@ -25,7 +23,9 @@ noinst_LTLIBRARIES = libsrp6a-sha512.la
libsrp6a_sha512_la_SOURCES = \
t_conv.c t_math.c t_misc.c \
t_truerand.c cstr.c \
- srp.c srp6a_sha512_client.c
-if !HAVE_OPENSSL
-libsrp6a_sha512_la_SOURCES += t_sha.c
-endif
+ srp.c srp6a_sha512_client.c \
+ srp.h srp_aux.h cstr.h \
+ t_sha.c
+#if !HAVE_OPENSSL
+#libsrp6a_sha512_la_SOURCES += t_sha.c
+#endif
diff --git a/3rd_party/libsrp6a-sha512/t_conv.c b/3rd_party/libsrp6a-sha512/t_conv.c
index f7f50e2..76d4e58 100644
--- a/3rd_party/libsrp6a-sha512/t_conv.c
+++ b/3rd_party/libsrp6a-sha512/t_conv.c
@@ -33,8 +33,7 @@
#include "cstr.h"
static int
-hexDigitToInt(c)
- char c;
+hexDigitToInt(char c)
{
if(c >= '0' && c <= '9')
return c - '0';
@@ -50,9 +49,7 @@ hexDigitToInt(c)
* Convert a hex string to a string of bytes; return size of dst
*/
_TYPE( int )
-t_fromhex(dst, src)
- char * dst;
- const char * src;
+t_fromhex(char *dst, const char *src)
{
register char *chp = dst;
register unsigned size = strlen(src);
@@ -76,10 +73,7 @@ t_fromhex(dst, src)
* Convert a string of bytes to their hex representation
*/
_TYPE( char * )
-t_tohex(dst, src, size)
- char * dst;
- const char * src;
- unsigned size;
+t_tohex(char *dst, const char *src, unsigned size)
{
int notleading = 0;
@@ -103,10 +97,7 @@ t_tohex(dst, src, size)
}
_TYPE( char * )
-t_tohexcstr(dst, src, size)
- cstr * dst;
- const char * src;
- unsigned size;
+t_tohexcstr(cstr *dst, const char *src, unsigned size)
{
cstr_set_length(dst, 2 * size + 1);
return t_tohex(dst->data, src, size);
@@ -119,9 +110,7 @@ static char b64table[] =
* Convert a base64 string into raw byte array representation.
*/
_TYPE( int )
-t_fromb64(dst, src)
- char * dst;
- const char * src;
+t_fromb64(char *dst, const char *src)
{
unsigned char *a;
char *loc;
@@ -179,9 +168,7 @@ t_fromb64(dst, src)
}
_TYPE( int )
-t_cstrfromb64(dst, src)
- cstr * dst;
- const char * src;
+t_cstrfromb64(cstr *dst, const char *src)
{
int len;
cstr_set_length(dst, (strlen(src) * 6 + 7) / 8);
@@ -194,10 +181,7 @@ t_cstrfromb64(dst, src)
* Convert a raw byte string into a null-terminated base64 ASCII string.
*/
_TYPE( char * )
-t_tob64(dst, src, size)
- char * dst;
- const char * src;
- unsigned size;
+t_tob64(char *dst, const char *src, unsigned size)
{
int c, pos = size % 3;
unsigned char b0 = 0, b1 = 0, b2 = 0, notleading = 0;
@@ -248,10 +232,7 @@ t_tob64(dst, src, size)
}
_TYPE( char * )
-t_tob64cstr(dst, src, sz)
- cstr * dst;
- const char * src;
- unsigned int sz;
+t_tob64cstr(cstr *dst, const char *src, unsigned int sz)
{
cstr_set_length(dst, (sz * 8 + 5) / 6 + 1);
return t_tob64(dst->data, src, sz);
diff --git a/3rd_party/libsrp6a-sha512/t_math.c b/3rd_party/libsrp6a-sha512/t_math.c
index 88ae12f..037650e 100644
--- a/3rd_party/libsrp6a-sha512/t_math.c
+++ b/3rd_party/libsrp6a-sha512/t_math.c
@@ -39,10 +39,13 @@ typedef BIGNUM * BigInteger;
typedef BN_CTX * BigIntegerCtx;
typedef BN_MONT_CTX * BigIntegerModAccel;
#include <limits.h>
-# ifdef OPENSSL_ENGINE
+#if OPENSSL_VERSION_NUMBER < 0x30000000L
+# ifndef OPENSSL_NO_ENGINE
+# define OPENSSL_ENGINE
# include "openssl/engine.h"
static ENGINE * default_engine = NULL;
# endif /* OPENSSL_ENGINE */
+#endif
typedef int (*modexp_meth)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *mctx);
static modexp_meth default_modexp = NULL;
@@ -98,8 +101,7 @@ typedef void * BigIntegerModAccel;
/* Math library interface stubs */
BigInteger
-BigIntegerFromInt(n)
- unsigned int n;
+BigIntegerFromInt(unsigned int n)
{
#ifdef OPENSSL
BIGNUM * a = BN_new();
@@ -135,9 +137,7 @@ BigIntegerFromInt(n)
}
BigInteger
-BigIntegerFromBytes(bytes, length)
- const unsigned char * bytes;
- int length;
+BigIntegerFromBytes(const unsigned char *bytes, int length)
{
#ifdef OPENSSL
BIGNUM * a = BN_new();
@@ -205,10 +205,7 @@ BigIntegerFromBytes(bytes, length)
}
int
-BigIntegerToBytes(src, dest, destlen)
- BigInteger src;
- unsigned char * dest;
- int destlen;
+BigIntegerToBytes(BigInteger src, unsigned char *dest, int destlen)
{
#ifdef OPENSSL
return BN_bn2bin(src, dest);
@@ -289,10 +286,7 @@ BigIntegerToCstrEx(BigInteger x, cstr * out, int len)
}
BigIntegerResult
-BigIntegerToHex(src, dest, destlen)
- BigInteger src;
- char * dest;
- int destlen;
+BigIntegerToHex(BigInteger src, char *dest, int destlen)
{
#ifdef OPENSSL
strncpy(dest, BN_bn2hex(src), destlen);
@@ -316,11 +310,7 @@ static char b64table[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./";
BigIntegerResult
-BigIntegerToString(src, dest, destlen, radix)
- BigInteger src;
- char * dest;
- int destlen;
- unsigned int radix;
+BigIntegerToString(BigInteger src, char *dest, int destlen, unsigned int radix)
{
BigInteger t = BigIntegerFromInt(0);
char * p = dest;
@@ -344,8 +334,7 @@ BigIntegerToString(src, dest, destlen, radix)
}
int
-BigIntegerBitLen(b)
- BigInteger b;
+BigIntegerBitLen(BigInteger b)
{
#ifdef OPENSSL
return BN_num_bits(b);
@@ -363,8 +352,7 @@ BigIntegerBitLen(b)
}
int
-BigIntegerCmp(c1, c2)
- BigInteger c1, c2;
+BigIntegerCmp(BigInteger c1, BigInteger c2)
{
#ifdef OPENSSL
return BN_cmp(c1, c2);
@@ -382,9 +370,7 @@ BigIntegerCmp(c1, c2)
}
int
-BigIntegerCmpInt(c1, c2)
- BigInteger c1;
- unsigned int c2;
+BigIntegerCmpInt(BigInteger c1, unsigned int c2)
{
#ifdef OPENSSL
BigInteger bc2 = BigIntegerFromInt(c2);
@@ -413,9 +399,7 @@ BigIntegerCmpInt(c1, c2)
}
BigIntegerResult
-BigIntegerLShift(result, x, bits)
- BigInteger result, x;
- unsigned int bits;
+BigIntegerLShift(BigInteger result, BigInteger x, unsigned int bits)
{
#ifdef OPENSSL
BN_lshift(result, x, bits);
@@ -435,8 +419,7 @@ BigIntegerLShift(result, x, bits)
}
BigIntegerResult
-BigIntegerAdd(result, a1, a2)
- BigInteger result, a1, a2;
+BigIntegerAdd(BigInteger result, BigInteger a1, BigInteger a2)
{
#ifdef OPENSSL
BN_add(result, a1, a2);
@@ -455,9 +438,7 @@ BigIntegerAdd(result, a1, a2)
}
BigIntegerResult
-BigIntegerAddInt(result, a1, a2)
- BigInteger result, a1;
- unsigned int a2;
+BigIntegerAddInt(BigInteger result, BigInteger a1, unsigned int a2)
{
#ifdef OPENSSL
if(result != a1)
@@ -482,8 +463,7 @@ BigIntegerAddInt(result, a1, a2)
}
BigIntegerResult
-BigIntegerSub(result, s1, s2)
- BigInteger result, s1, s2;
+BigIntegerSub(BigInteger result, BigInteger s1, BigInteger s2)
{
#ifdef OPENSSL
BN_sub(result, s1, s2);
@@ -502,9 +482,7 @@ BigIntegerSub(result, s1, s2)
}
BigIntegerResult
-BigIntegerSubInt(result, s1, s2)
- BigInteger result, s1;
- unsigned int s2;
+BigIntegerSubInt(BigInteger result, BigInteger s1, unsigned int s2)
{
#ifdef OPENSSL
if(result != s1)
@@ -529,9 +507,7 @@ BigIntegerSubInt(result, s1, s2)
}
BigIntegerResult
-BigIntegerMul(result, m1, m2, c)
- BigInteger result, m1, m2;
- BigIntegerCtx c;
+BigIntegerMul(BigInteger result, BigInteger m1, BigInteger m2, BigIntegerCtx c)
{
#ifdef OPENSSL
BN_CTX * ctx = NULL;
@@ -555,10 +531,7 @@ BigIntegerMul(result, m1, m2, c)
}
BigIntegerResult
-BigIntegerMulInt(result, m1, m2, c)
- BigInteger result, m1;
- unsigned int m2;
- BigIntegerCtx c;
+BigIntegerMulInt(BigInteger result, BigInteger m1, unsigned int m2, BigIntegerCtx c)
{
#ifdef OPENSSL
if(result != m1)
@@ -583,10 +556,7 @@ BigIntegerMulInt(result, m1, m2, c)
}
BigIntegerResult
-BigIntegerDivInt(result, d, m, c)
- BigInteger result, d;
- unsigned int m;
- BigIntegerCtx c;
+BigIntegerDivInt(BigInteger result, BigInteger d, unsigned int m, BigIntegerCtx c)
{
#ifdef OPENSSL
if(result != d)
@@ -623,9 +593,7 @@ BigIntegerDivInt(result, d, m, c)
}
BigIntegerResult
-BigIntegerMod(result, d, m, c)
- BigInteger result, d, m;
- BigIntegerCtx c;
+BigIntegerMod(BigInteger result, BigInteger d, BigInteger m, BigIntegerCtx c)
{
#ifdef OPENSSL
BN_CTX * ctx = NULL;
@@ -649,10 +617,7 @@ BigIntegerMod(result, d, m, c)
}
unsigned int
-BigIntegerModInt(d, m, c)
- BigInteger d;
- unsigned int m;
- BigIntegerCtx c;
+BigIntegerModInt(BigInteger d, unsigned int m, BigIntegerCtx c)
{
#ifdef OPENSSL
return BN_mod_word(d, m);
@@ -710,9 +675,7 @@ BigIntegerModInt(d, m, c)
}
BigIntegerResult
-BigIntegerModMul(r, m1, m2, modulus, c)
- BigInteger r, m1, m2, modulus;
- BigIntegerCtx c;
+BigIntegerModMul(BigInteger r, BigInteger m1, BigInteger m2, BigInteger modulus, BigIntegerCtx c)
{
#ifdef OPENSSL
BN_CTX * ctx = NULL;
@@ -742,10 +705,7 @@ BigIntegerModMul(r, m1, m2, modulus, c)
}
BigIntegerResult
-BigIntegerModExp(r, b, e, m, c, a)
- BigInteger r, b, e, m;
- BigIntegerCtx c;
- BigIntegerModAccel a;
+BigIntegerModExp(BigInteger r, BigInteger b, BigInteger e, BigInteger m, BigIntegerCtx c, BigIntegerModAccel a)
{
#ifdef OPENSSL
#if OPENSSL_VERSION_NUMBER >= 0x00906000
@@ -792,9 +752,7 @@ int _mbedtls_f_rng(void* unused, unsigned char *buf, size_t size)
#endif
int
-BigIntegerCheckPrime(n, c)
- BigInteger n;
- BigIntegerCtx c;
+BigIntegerCheckPrime(BigInteger n, BigIntegerCtx c)
{
#ifdef OPENSSL
int rv;
@@ -802,7 +760,11 @@ BigIntegerCheckPrime(n, c)
if(c == NULL)
c = ctx = BN_CTX_new();
#if OPENSSL_VERSION_NUMBER >= 0x00908000
- rv = BN_is_prime_ex(n, 25, c, NULL);
+ #if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ rv = BN_check_prime(n, c, NULL);
+ #else
+ rv = BN_is_prime_ex(n, 25, c, NULL);
+ #endif
#else
rv = BN_is_prime(n, 25, NULL, c, NULL);
#endif
@@ -845,8 +807,7 @@ BigIntegerCheckPrime(n, c)
}
BigIntegerResult
-BigIntegerFree(b)
- BigInteger b;
+BigIntegerFree(BigInteger b)
{
#ifdef OPENSSL
BN_free(b);
@@ -868,8 +829,7 @@ BigIntegerFree(b)
}
BigIntegerResult
-BigIntegerClearFree(b)
- BigInteger b;
+BigIntegerClearFree(BigInteger b)
{
#ifdef OPENSSL
BN_clear_free(b);
@@ -905,8 +865,7 @@ BigIntegerCtxNew()
}
BigIntegerResult
-BigIntegerCtxFree(ctx)
- BigIntegerCtx ctx;
+BigIntegerCtxFree(BigIntegerCtx ctx)
{
#ifdef OPENSSL
if(ctx)
@@ -916,9 +875,7 @@ BigIntegerCtxFree(ctx)
}
BigIntegerModAccel
-BigIntegerModAccelNew(m, c)
- BigInteger m;
- BigIntegerCtx c;
+BigIntegerModAccelNew(BigInteger m, BigIntegerCtx c)
{
#ifdef OPENSSL
BN_CTX * ctx = NULL;
@@ -938,8 +895,7 @@ BigIntegerModAccelNew(m, c)
}
BigIntegerResult
-BigIntegerModAccelFree(accel)
- BigIntegerModAccel accel;
+BigIntegerModAccelFree(BigIntegerModAccel accel)
{
#ifdef OPENSSL
if(accel)
@@ -951,7 +907,7 @@ BigIntegerModAccelFree(accel)
BigIntegerResult
BigIntegerInitialize()
{
-#if OPENSSL_VERSION_NUMBER >= 0x00907000
+#if OPENSSL_VERSION_NUMBER >= 0x00907000 && defined(OPENSSL_ENGINE)
ENGINE_load_builtin_engines();
#endif
return BIG_INTEGER_SUCCESS;
diff --git a/3rd_party/libsrp6a-sha512/t_misc.c b/3rd_party/libsrp6a-sha512/t_misc.c
index 3053358..3a2cda1 100644
--- a/3rd_party/libsrp6a-sha512/t_misc.c
+++ b/3rd_party/libsrp6a-sha512/t_misc.c
@@ -80,8 +80,7 @@ SHA1_CTX randctxt;
extern char ** environ;
static void
-t_envhash(out)
- unsigned char * out;
+t_envhash(unsigned char * out)
{
char ** ptr;
char ebuf[256];
@@ -115,8 +114,7 @@ t_envhash(out)
* The entire buffer is run once through SHA to obtain the final result.
*/
static void
-t_fshash(out)
- unsigned char * out;
+t_fshash(unsigned char * out)
{
char dotpath[128];
struct stat st;
@@ -317,9 +315,7 @@ t_stronginitrand()
* Each cycle generates 20 bytes of new output.
*/
_TYPE( void )
-t_random(data, size)
- unsigned char * data;
- unsigned size;
+t_random(unsigned char * data, unsigned size)
{
if(!initialized)
t_initrand();
@@ -369,10 +365,7 @@ t_random(data, size)
* single 320-bit value.
*/
_TYPE( unsigned char * )
-t_sessionkey(key, sk, sklen)
- unsigned char * key;
- unsigned char * sk;
- unsigned sklen;
+t_sessionkey(unsigned char * key, unsigned char * sk, unsigned sklen)
{
unsigned i, klen;
unsigned char * hbuf;
@@ -411,11 +404,7 @@ t_sessionkey(key, sk, sklen)
}
_TYPE( void )
-t_mgf1(mask, masklen, seed, seedlen)
- unsigned char * mask;
- unsigned masklen;
- const unsigned char * seed;
- unsigned seedlen;
+t_mgf1(unsigned char * mask, unsigned masklen, const unsigned char * seed, unsigned seedlen)
{
SHA1_CTX ctxt;
unsigned i = 0;
diff --git a/3rd_party/libsrp6a-sha512/t_sha.c b/3rd_party/libsrp6a-sha512/t_sha.c
index 4029de8..8e54cb6 100644
--- a/3rd_party/libsrp6a-sha512/t_sha.c
+++ b/3rd_party/libsrp6a-sha512/t_sha.c
@@ -107,6 +107,44 @@ SHA512Final_mbed(unsigned char digest[64], SHA512_CTX * ctx)
mbedtls_md_free(ctx);
}
+#elif defined(OPENSSL_SHA)
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+void
+SHA1Init_openssl(SHA1_CTX *ctx)
+{
+ *ctx = EVP_MD_CTX_new();
+ EVP_DigestInit(*ctx, EVP_sha1());
+}
+
+void SHA1Update_openssl(SHA1_CTX *ctx, const void *data, unsigned int len)
+{
+ EVP_DigestUpdate(*ctx, data, (size_t)len);
+}
+
+void SHA1Final_openssl(unsigned char digest[20], SHA1_CTX *ctx)
+{
+ EVP_DigestFinal(*ctx, digest, NULL);
+ EVP_MD_CTX_destroy(*ctx);
+}
+
+void
+SHA512Init_openssl(SHA512_CTX *ctx)
+{
+ *ctx = EVP_MD_CTX_new();
+ EVP_DigestInit(*ctx, EVP_sha512());
+}
+
+void SHA512Update_openssl(SHA512_CTX *ctx, const void *data, unsigned int len)
+{
+ EVP_DigestUpdate(*ctx, data, (size_t)len);
+}
+
+void SHA512Final_openssl(unsigned char digest[64], SHA512_CTX *ctx)
+{
+ EVP_DigestFinal(*ctx, digest, NULL);
+ EVP_MD_CTX_destroy(*ctx);
+}
+#endif
#elif !defined(OPENSSL_SHA) && !defined(TOMCRYPT_SHA)
/* Use the free SHA1 if the library doesn't have it */
@@ -273,4 +311,4 @@ unsigned char finalcount[8];
SHA1Transform(context->state, context->buffer);
#endif
}
-#endif /* OPENSSL */
+#endif
diff --git a/3rd_party/libsrp6a-sha512/t_sha.h b/3rd_party/libsrp6a-sha512/t_sha.h
index 18deec5..2e38067 100644
--- a/3rd_party/libsrp6a-sha512/t_sha.h
+++ b/3rd_party/libsrp6a-sha512/t_sha.h
@@ -38,6 +38,28 @@
#endif
#ifdef OPENSSL_SHA
+#include <openssl/err.h>
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+#include <openssl/evp.h>
+
+typedef EVP_MD_CTX* SHA1_CTX;
+#define SHA1Init SHA1Init_openssl
+#define SHA1Update SHA1Update_openssl
+#define SHA1Final SHA1Final_openssl
+
+typedef EVP_MD_CTX* SHA512_CTX;
+#define SHA512Init SHA512Init_openssl
+#define SHA512Update SHA512Update_openssl
+#define SHA512Final SHA512Final_openssl
+
+void SHA1Init_openssl(SHA1_CTX *ctx);
+void SHA1Update_openssl(SHA1_CTX *ctx, const void *data, unsigned int len);
+void SHA1Final_openssl(unsigned char digest[20], SHA1_CTX *ctx);
+
+void SHA512Init_openssl(SHA512_CTX *ctx);
+void SHA512Update_openssl(SHA512_CTX *ctx, const void *data, unsigned int len);
+void SHA512Final_openssl(unsigned char digest[64], SHA1_CTX *ctx);
+#else /* for OpenSSL < 3.0 */
#include <openssl/sha.h>
typedef SHA_CTX SHA1_CTX;
@@ -48,7 +70,7 @@ typedef SHA_CTX SHA1_CTX;
#define SHA512Init SHA512_Init
#define SHA512Update SHA512_Update
#define SHA512Final SHA512_Final
-
+#endif /* for OpenSSL < 3.0 */
#elif defined(TOMCRYPT_SHA)
/* mycrypt.h already included above */
diff --git a/3rd_party/libsrp6a-sha512/t_truerand.c b/3rd_party/libsrp6a-sha512/t_truerand.c
index 4a4c3d2..f995ed7 100644
--- a/3rd_party/libsrp6a-sha512/t_truerand.c
+++ b/3rd_party/libsrp6a-sha512/t_truerand.c
@@ -227,8 +227,7 @@ raw_truerand()
}
int
-raw_n_truerand(n)
-int n;
+raw_n_truerand(int n)
{
int slop, v;
diff --git a/README.md b/README.md
index 61c34a0..89db882 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Some key features are:
- **Implementation**: Object oriented architecture and service abstraction layer
- **Cross-Platform:** Tested on Linux, macOS, Windows and Android platforms
- **Utilities**: Provides various command-line utilities for device services
-- **SSL**: Allows choosing between OpenSSL or GnuTLS to handle SSL communication
+- **SSL**: Allows choosing between OpenSSL, GnuTLS, or MbedTLS to handle SSL communication
- **Network**: Supports network connections with "WiFi sync" enabled devices
- **Python:** Provides Cython based bindings for Python
@@ -144,6 +144,7 @@ The library bundles the following command-line utilities in the tools directory:
| `idevicescreenshot` | Gets a screenshot from the connected device |
| `idevicesetlocation` | Simulate location on device |
| `idevicesyslog` | Relay syslog of a connected device |
+| `afcclient` | Interact with device filesystem via AFC/HouseArrest |
Please consult the usage information or manual pages of each utility for a
documentation of available command line options and usage examples like this:
@@ -193,4 +194,4 @@ iPadOS, tvOS, watchOS, and macOS are trademarks of Apple Inc.
This project is an independent software and has not been authorized, sponsored,
or otherwise approved by Apple Inc.
-README Updated on: 2022-04-04
+README Updated on: 2023-12-30
diff --git a/common/Makefile.am b/common/Makefile.am
index 1a90571..bd09bad 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -4,22 +4,16 @@ AM_CPPFLAGS = \
AM_CFLAGS = \
$(GLOBAL_CFLAGS) \
+ $(ssl_lib_CFLAGS) \
+ $(LFS_CFLAGS) \
$(libusbmuxd_CFLAGS) \
- $(libplist_CFLAGS) \
- $(libgnutls_CFLAGS) \
- $(libtasn1_CFLAGS) \
- $(libgcrypt_CFLAGS) \
- $(openssl_CFLAGS) \
- $(LFS_CFLAGS)
+ $(libplist_CFLAGS)
AM_LDFLAGS = \
+ $(ssl_lib_LIBS) \
+ ${libpthread_LIBS} \
$(libusbmuxd_LIBS) \
- $(libplist_LIBS) \
- $(libgnutls_LIBS) \
- $(libtasn1_LIBS) \
- $(libgcrypt_LIBS) \
- $(openssl_LIBS) \
- ${libpthread_LIBS}
+ $(libplist_LIBS)
noinst_LTLIBRARIES = libinternalcommon.la
libinternalcommon_la_LIBADD =
diff --git a/common/debug.c b/common/debug.c
index 6212e71..cf1bc2f 100644
--- a/common/debug.c
+++ b/common/debug.c
@@ -31,9 +31,9 @@
#include <stdlib.h>
#include <time.h>
+#include "src/idevice.h"
#include "debug.h"
#include "libimobiledevice/libimobiledevice.h"
-#include "src/idevice.h"
#ifndef STRIP_DEBUG_CODE
#include "asprintf.h"
@@ -60,7 +60,7 @@ static void debug_print_line(const char *func, const char *file, int line, const
strftime(str_time, 254, "%H:%M:%S", localtime (&the_time));
/* generate header text */
- (void)asprintf(&header, "%s %s:%d %s()", str_time, file, line, func);
+ if(asprintf(&header, "%s %s:%d %s()", str_time, file, line, func)<0){}
free (str_time);
/* trim ending newlines */
@@ -86,7 +86,7 @@ void debug_info_real(const char *func, const char *file, int line, const char *f
/* run the real fprintf */
va_start(args, format);
- (void)vasprintf(&buffer, format, args);
+ if(vasprintf(&buffer, format, args)<0){}
va_end(args);
debug_print_line(func, file, line, buffer);
diff --git a/common/userpref.c b/common/userpref.c
index ddd380a..b64c703 100644
--- a/common/userpref.c
+++ b/common/userpref.c
@@ -338,7 +338,7 @@ userpref_error_t userpref_read_pair_record(const char *udid, plist_t *pair_recor
}
*pair_record = NULL;
- plist_from_memory(record_data, record_size, pair_record);
+ plist_from_memory(record_data, record_size, pair_record, NULL);
free(record_data);
if (!*pair_record) {
@@ -435,6 +435,10 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
debug_info("Generating keys and certificates...");
#if defined(HAVE_OPENSSL)
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ EVP_PKEY* root_pkey = EVP_RSA_gen(2048);
+ EVP_PKEY* host_pkey = EVP_RSA_gen(2048);
+#else
BIGNUM *e = BN_new();
RSA* root_keypair = RSA_new();
RSA* host_keypair = RSA_new();
@@ -451,6 +455,7 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
EVP_PKEY* host_pkey = EVP_PKEY_new();
EVP_PKEY_assign_RSA(host_pkey, host_keypair);
+#endif
/* generate root certificate */
X509* root_cert = X509_new();
@@ -561,12 +566,22 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
}
}
- RSA *pubkey = NULL;
+ EVP_PKEY *pubkey = NULL;
{
BIO *membp = BIO_new_mem_buf(public_key.data, public_key.size);
- if (!PEM_read_bio_RSAPublicKey(membp, &pubkey, NULL, NULL)) {
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ if (!PEM_read_bio_PUBKEY(membp, &pubkey, NULL, NULL)) {
debug_info("WARNING: Could not read public key");
}
+#else
+ RSA *rsa_pubkey = NULL;
+ if (!PEM_read_bio_RSAPublicKey(membp, &rsa_pubkey, NULL, NULL)) {
+ debug_info("WARNING: Could not read public key");
+ } else {
+ pubkey = EVP_PKEY_new();
+ EVP_PKEY_assign_RSA(pubkey, rsa_pubkey);
+ }
+#endif
BIO_free(membp);
}
@@ -588,10 +603,7 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
X509_set1_notAfter(dev_cert, asn1time);
ASN1_TIME_free(asn1time);
- EVP_PKEY* pkey = EVP_PKEY_new();
- EVP_PKEY_assign_RSA(pkey, pubkey);
- X509_set_pubkey(dev_cert, pkey);
- EVP_PKEY_free(pkey);
+ X509_set_pubkey(dev_cert, pubkey);
X509_add_ext_helper(dev_cert, NID_subject_key_identifier, (char*)"hash");
X509_add_ext_helper(dev_cert, NID_key_usage, (char*)"critical,digitalSignature,keyEncipherment");
@@ -618,6 +630,7 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
X509V3_EXT_cleanup();
X509_free(dev_cert);
+ EVP_PKEY_free(pubkey);
EVP_PKEY_free(root_pkey);
EVP_PKEY_free(host_pkey);
diff --git a/configure.ac b/configure.ac
index 503051f..3c12010 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ fi
dnl Minimum package versions
LIBUSBMUXD_VERSION=2.0.2
-LIBPLIST_VERSION=2.2.0
+LIBPLIST_VERSION=2.3.0
LIMD_GLUE_VERSION=1.0.0
AC_SUBST(LIBUSBMUXD_VERSION)
@@ -43,6 +43,18 @@ LT_INIT
PKG_CHECK_MODULES(libusbmuxd, libusbmuxd-2.0 >= $LIBUSBMUXD_VERSION)
PKG_CHECK_MODULES(libplist, libplist-2.0 >= $LIBPLIST_VERSION)
PKG_CHECK_MODULES(limd_glue, libimobiledevice-glue-1.0 >= $LIMD_GLUE_VERSION)
+AC_ARG_WITH([readline],
+ [AS_HELP_STRING([--without-readline],
+ [build without support for libreadline (default is yes)])],
+ [check_libreadline=false],
+ [check_libreadline=true])
+if test "$check_libreadline" = "true"; then
+ PKG_CHECK_MODULES(readline, readline >= 1.0, have_readline=yes, have_readline=no)
+ if test "x$have_readline" = "xyes"; then
+ AC_DEFINE(HAVE_READLINE, 1, [Define if readline library is available])
+ fi
+fi
+AM_CONDITIONAL([HAVE_READLINE],[test "x$have_readline" = "xyes"])
# Checks for header files.
AC_CHECK_HEADERS([stdint.h stdlib.h string.h sys/time.h])
@@ -165,7 +177,7 @@ AC_ARG_WITH([mbedtls],
[Do not look for mbedtls])],
[use_mbedtls=$withval],
[use_mbedtls=no])
-if test "x$use_mbedtls" == "xyes"; then
+if test "x$use_mbedtls" = "xyes"; then
default_openssl=no
fi
AC_ARG_WITH([gnutls],
@@ -173,7 +185,7 @@ AC_ARG_WITH([gnutls],
[Do not look for GnuTLS])],
[use_gnutls=$withval],
[use_gnutls=no])
-if test "x$use_gnutls" == "xyes"; then
+if test "x$use_gnutls" = "xyes"; then
default_openssl=no
fi
AC_ARG_WITH([openssl],
@@ -182,7 +194,7 @@ AC_ARG_WITH([openssl],
[use_openssl=$withval],
[use_openssl=$default_openssl])
-if test "x$use_mbedtls" == "xyes"; then
+if test "x$use_mbedtls" = "xyes"; then
CACHED_CFLAGS="$CFLAGS"
conf_mbedtls_CFLAGS=""
if test -n "$mbedtls_INCLUDES"; then
@@ -209,7 +221,7 @@ if test "x$use_mbedtls" == "xyes"; then
ssl_requires=""
AC_SUBST(ssl_requires)
else
- if test "x$use_openssl" == "xyes"; then
+ if test "x$use_openssl" = "xyes"; then
pkg_req_openssl="openssl >= 0.9.8"
PKG_CHECK_MODULES(openssl, $pkg_req_openssl, have_openssl=yes, have_openssl=no)
if test "x$have_openssl" != "xyes"; then
@@ -222,10 +234,40 @@ else
AC_SUBST(ssl_lib_LIBS)
ssl_provider="OpenSSL";
ssl_requires="$pkg_req_openssl"
+ # test if we have LibreSSL
+ CACHED_CFLAGS="$CFLAGS"
+ CFLAGS="$openssl_CFLAGS"
+ ac_cv_is_libressl=no
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [[
+ #include <openssl/opensslv.h>
+ ]], [
+ #ifndef LIBRESSL_VERSION_NUMBER
+ #error No LibreSSL
+ #endif
+ ])],
+ [
+ ac_cv_is_libressl=yes
+ ],
+ )
+ CFLAGS="$CACHED_CFLAGS"
+ if test "x$ac_cv_is_libressl" = "xyes"; then
+ ssl_provider="LibreSSL"
+ case ${host_os} in
+ darwin*)
+ case ${openssl_LIBS} in
+ *.tbd*)
+ # using system LibreSSL on Darwin
+ ssl_requires=""
+ ;;
+ esac
+ ;;
+ esac
+ fi
AC_SUBST(ssl_requires)
fi
else
- if test "x$use_gnutls" == "xyes"; then
+ if test "x$use_gnutls" = "xyes"; then
pkg_req_gnutls="gnutls >= 2.2.0"
pkg_req_libtasn1="libtasn1 >= 1.1"
PKG_CHECK_MODULES(libgnutls, $pkg_req_gnutls)
@@ -246,9 +288,9 @@ else
fi
fi
fi
-AM_CONDITIONAL(HAVE_MBEDTLS, test "x$use_mbedtls" == "xyes")
-AM_CONDITIONAL(HAVE_OPENSSL, test "x$use_openssl" == "xyes")
-AM_CONDITIONAL(HAVE_GCRYPT, test "x$use_gnutls" == "xyes")
+AM_CONDITIONAL(HAVE_MBEDTLS, test "x$use_mbedtls" = "xyes")
+AM_CONDITIONAL(HAVE_OPENSSL, test "x$use_openssl" = "xyes")
+AM_CONDITIONAL(HAVE_GCRYPT, test "x$use_gnutls" = "xyes")
AC_ARG_ENABLE([wireless-pairing],
[AS_HELP_STRING([--disable-wireless-pairing],
@@ -271,12 +313,12 @@ else
fi
AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden")
-AC_SUBST(GLOBAL_CFLAGS)
-case "$GLOBAL_CFLAGS" in
- *-fvisibility=hidden*)
- AC_DEFINE([HAVE_FVISIBILITY], [1], [Define if compiled with -fvisibility=hidden])
-esac
+if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then
+ GLOBAL_CFLAGS+=" -DLIBIMOBILEDEVICE_STATIC"
+fi
+
+AC_SUBST(GLOBAL_CFLAGS)
# check for large file support
AC_SYS_LARGEFILE
diff --git a/cython/Makefile.am b/cython/Makefile.am
index 3577c4e..93ea6ed 100644
--- a/cython/Makefile.am
+++ b/cython/Makefile.am
@@ -3,19 +3,15 @@ AM_CPPFLAGS = \
AM_CFLAGS = \
$(GLOBAL_CFLAGS) \
- $(libgnutls_CFLAGS) \
- $(libtasn1_CFLAGS) \
- $(openssl_CFLAGS) \
- $(libplist_CFLAGS) \
+ $(ssl_lib_CFLAGS) \
$(LFS_CFLAGS) \
- $(PTHREAD_CFLAGS)
+ $(PTHREAD_CFLAGS) \
+ $(libplist_CFLAGS)
AM_LIBS = \
- $(libgnutls_LIBS) \
- $(libtasn1_LIBS) \
- $(openssl_LIBS) \
- $(libplist_LIBS) \
- $(PTHREAD_LIBS)
+ $(ssl_lib_LIBS) \
+ $(PTHREAD_LIBS) \
+ $(libplist_LIBS)
if HAVE_CYTHON
diff --git a/cython/lockdown.pxi b/cython/lockdown.pxi
index 1bf7072..6b88f9d 100644
--- a/cython/lockdown.pxi
+++ b/cython/lockdown.pxi
@@ -231,11 +231,12 @@ cdef class LockdownClient(PropertyListService):
if issubclass(service, BaseService) and \
service.__service_name__ is not None \
and isinstance(service.__service_name__, (str, bytes)):
- c_service_name = <bytes>service.__service_name__
+ c_service_name_str = service.__service_name__.encode('utf-8')
elif isinstance(service, (str, bytes)):
- c_service_name = <bytes>service
+ c_service_name_str = service.encode('utf-8')
else:
raise TypeError("LockdownClient.start_service() takes a BaseService or string as its first argument")
+ c_service_name = c_service_name_str
try:
self.handle_error(lockdownd_start_service(self._c_client, c_service_name, &c_descriptor))
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 9cdf82e..4a4c56f 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -16,6 +16,7 @@ man_MANS = \
idevicecrashreport.1 \
idevicename.1 \
idevicedebug.1 \
+ idevicedevmodectl.1 \
idevicenotificationproxy.1 \
idevicesetlocation.1
diff --git a/docs/afcclient.1 b/docs/afcclient.1
new file mode 100644
index 0000000..ca7cb86
--- /dev/null
+++ b/docs/afcclient.1
@@ -0,0 +1,76 @@
+.TH "afcclient" 1
+.SH NAME
+afcclient \- Interact with AFC/HouseArrest service on a connected device.
+.SH SYNOPSIS
+.B afcclient
+[OPTIONS] [COMMAND ...]
+
+.SH DESCRIPTION
+
+Utility to interact with AFC/HouseArrest service. This allows access to parts
+of the filesystem on an iOS device.
+
+\f[B]afcclient\f[] can be used interactively with a command prompt, or run a single command and exit.
+
+.SH COMMANDS
+.TP
+.B devinfo
+print device information
+.TP
+.B info PATH
+print file attributes of file at PATH
+.TP
+.B ls PATH
+print directory contents of PATH
+.TP
+.B mv OLD NEW
+rename file OLD to NEW
+.TP
+.B mkdir PATH
+create directory at PATH
+.TP
+.B ln [-s] FILE [LINK]
+Create a (symbolic) link to file named LINKNAME. \f[B]NOTE: This feature has been disabled in newer versions of iOS\f[].
+.TP
+.B rm PATH
+remove item at PATH
+.TP
+.B get PATH [LOCALPATH]
+transfer file at PATH from device to LOCALPATH, or current directory if omitted. If LOCALPATH is a directory, the file will be stored inside the directory.
+\f[B]WARNING\f[]: Existing files will be overwritten!
+.TP
+.B put LOCALPATH [PATH]
+transfer local file at LOCALPATH to device at PATH, or current directory if omitted. If PATH is a directory, the file will be stored inside the directory.
+\f[B]WARNING\f[]: Existing files will be overwritten!
+.TP
+
+.SH OPTIONS
+.TP
+.B \-u, \-\-udid UDID
+target specific device by UDID
+.TP
+.B \-n, \-\-network
+connect to network device (not recommended, since the connection might be terminated at any time)
+.TP
+.B \--container <appid>
+Access the app container directory of the app with given \f[B]appid\f[]
+.TP
+.B \--documents <appid>
+Access the Documents directory of the app with given \f[B]appid\f[]
+.TP
+.B \-h, \-\-help
+Prints usage information
+.TP
+.B \-d, \-\-debug
+Enable communication debugging
+.TP
+.B \-v, \-\-version
+Prints version information
+
+.SH AUTHOR
+Nikias Bassen
+
+.SH ON THE WEB
+https://libimobiledevice.org
+
+https://github.com/libimobiledevice/libimobiledevice
diff --git a/docs/idevicebackup2.1 b/docs/idevicebackup2.1
index abbe38a..79b6dc4 100644
--- a/docs/idevicebackup2.1
+++ b/docs/idevicebackup2.1
@@ -47,7 +47,7 @@ restore last backup to the device.
restore system files, too.
.TP
.B \t\-\-no\-reboot
-reboot the system when done.
+do NO reboot the system when done.
.TP
.B \t\-\-copy
create a copy of backup folder before restoring.
diff --git a/docs/idevicedebugserverproxy.1 b/docs/idevicedebugserverproxy.1
index 248c694..69200ee 100644
--- a/docs/idevicedebugserverproxy.1
+++ b/docs/idevicedebugserverproxy.1
@@ -22,6 +22,9 @@ target specific device by UDID.
.B \-n, \-\-network
connect to network device.
.TP
+.B \-l, \-\-lldb
+Enable lldb support.
+.TP
.B \-d, \-\-debug
enable communication debugging.
.TP
diff --git a/docs/idevicedevmodectl.1 b/docs/idevicedevmodectl.1
new file mode 100644
index 0000000..5edaa80
--- /dev/null
+++ b/docs/idevicedevmodectl.1
@@ -0,0 +1,58 @@
+.TH "idevicedevmodectl" 1
+.SH NAME
+idevicedevmodectl \- Enable Developer Mode on iOS 16+ devices or print the current status.
+.SH SYNOPSIS
+.B idevicedevmodectl
+COMMAND
+[OPTIONS]
+
+.SH DESCRIPTION
+
+Enable Developer Mode on iOS 16+ devices or print the current status.
+
+.SH NOTE
+Passcode-protected devices will NOT allow enabling of Developer Mode from the command line. It has to be enabled on the device itself under Settings -> Privacy & Security -> Developer Mode.
+The \f[B]enable\f[] command will try to enable it, and tell you if that's the case.
+If the menu is not shown, you may use the \f[B]reveal\f[] command to reveal it.
+
+.SH COMMANDS
+.TP
+.B list
+Prints the Developer Mode status of all connected devices, or for a specific one if \f[B]\-\-udid\f[] is given.
+.TP
+.B enable
+Enable Developer Mode (device will reboot), and confirm it after device booted up again.
+.TP
+.B arm
+Arm the Developer Mode (device will reboot)
+.TP
+.B confirm
+Confirm enabling of Developer Mode
+.TP
+.B reveal
+Reveal the Developer Mode menu on the device under Settings -> Privacy & Security
+
+.SH OPTIONS
+.TP
+.B \-u, \-\-udid UDID
+target specific device by UDID
+.TP
+.B \-n, \-\-network
+connect to network device
+.TP
+.B \-d, \-\-debug
+enable communication debugging
+.TP
+.B \-h, \-\-help
+print usage information
+.TP
+.B \-v, \-\-version
+print version information
+
+.SH AUTHORS
+Nikias Bassen
+
+.SH ON THE WEB
+https://libimobiledevice.org
+
+https://github.com/libimobiledevice/libimobiledevice
diff --git a/docs/idevicesyslog.1 b/docs/idevicesyslog.1
index b7d4bab..66ae2e4 100644
--- a/docs/idevicesyslog.1
+++ b/docs/idevicesyslog.1
@@ -27,10 +27,17 @@ enable communication debugging
prints usage information
.TP
.B \-v, \-\-version
-prints version information.
+Prints version information.
.TP
.B \-\-no\-colors
disable colored output
+.TP
+.B \-o, \-\-output FILE
+Write to FILE instead of stdout. This will disable writing colored output, but can be re-enabled with \f[B]\-\-colors\f[].
+If FILE already exists, it will be overwritten without warning.
+.TP
+.B \-\-colors
+Force writing colored output, e.g. when using \f[B]\-\-output\f[].
.SH FILTER OPTIONS
.TP
diff --git a/doxygen.cfg.in b/doxygen.cfg.in
index b099b42..4cbbb2d 100644
--- a/doxygen.cfg.in
+++ b/doxygen.cfg.in
@@ -874,7 +874,7 @@ EXCLUDE_PATTERNS =
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories use the pattern */test/*
-EXCLUDE_SYMBOLS =
+EXCLUDE_SYMBOLS = LIBIMOBILEDEVICE_API
# The EXAMPLE_PATH tag can be used to specify one or more files or directories
# that contain example code fragments that are included (see the \include
@@ -2023,7 +2023,7 @@ ENABLE_PREPROCESSING = YES
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-MACRO_EXPANSION = NO
+MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
# the macro expansion is limited to the macros specified with the PREDEFINED and
@@ -2031,7 +2031,7 @@ MACRO_EXPANSION = NO
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-EXPAND_ONLY_PREDEF = NO
+EXPAND_ONLY_PREDEF = YES
# If the SEARCH_INCLUDES tag is set to YES, the include files in the
# INCLUDE_PATH will be searched if a #include is found.
@@ -2072,7 +2072,7 @@ PREDEFINED =
# definition found in the source code.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-EXPAND_AS_DEFINED =
+EXPAND_AS_DEFINED = LIBIMOBILEDEVICE_API
# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
# remove all references to function-like macros that are alone on a line, have
diff --git a/git-version-gen b/git-version-gen
index 3eb6a42..d868952 100755
--- a/git-version-gen
+++ b/git-version-gen
@@ -3,7 +3,7 @@ SRCDIR=`dirname $0`
if test -n "$1"; then
VER=$1
else
- if test -d "${SRCDIR}/.git" && test -x "`which git`" ; then
+ if test -r "${SRCDIR}/.git" && test -x "`which git`" ; then
git update-index -q --refresh
if ! VER=`git describe --tags --dirty 2>/dev/null`; then
COMMIT=`git rev-parse --short HEAD`
@@ -16,4 +16,5 @@ else
fi
fi
fi
+VER=`printf %s "$VER" | head -n1`
printf %s "$VER"
diff --git a/include/libimobiledevice/afc.h b/include/libimobiledevice/afc.h
index a2d70d3..4ad3dbd 100644
--- a/include/libimobiledevice/afc.h
+++ b/include/libimobiledevice/afc.h
@@ -107,7 +107,7 @@ typedef afc_client_private *afc_client_t; /**< The client handle. */
* invalid, AFC_E_MUX_ERROR if the connection cannot be established,
* or AFC_E_NO_MEM if there is a memory allocation problem.
*/
-afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t *client);
+LIBIMOBILEDEVICE_API afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t *client);
/**
* Starts a new AFC service on the specified device and connects to it.
@@ -120,7 +120,7 @@ afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t serv
*
* @return AFC_E_SUCCESS on success, or an AFC_E_* error code otherwise.
*/
-afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, const char* label);
/**
* Frees up an AFC client. If the connection was created by the client itself,
@@ -128,7 +128,7 @@ afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, con
*
* @param client The client to free.
*/
-afc_error_t afc_client_free(afc_client_t client);
+LIBIMOBILEDEVICE_API afc_error_t afc_client_free(afc_client_t client);
/**
* Get device information for a connected client. The device information
@@ -142,7 +142,7 @@ afc_error_t afc_client_free(afc_client_t client);
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_get_device_info(afc_client_t client, char ***device_information);
+LIBIMOBILEDEVICE_API afc_error_t afc_get_device_info(afc_client_t client, char ***device_information);
/**
* Gets a directory listing of the directory requested.
@@ -155,7 +155,7 @@ afc_error_t afc_get_device_info(afc_client_t client, char ***device_information)
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***directory_information);
+LIBIMOBILEDEVICE_API afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***directory_information);
/**
* Gets information about a specific file.
@@ -168,7 +168,7 @@ afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***di
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***file_information);
+LIBIMOBILEDEVICE_API afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***file_information);
/**
* Opens a file on the device.
@@ -180,7 +180,7 @@ afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***fil
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle);
+LIBIMOBILEDEVICE_API afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle);
/**
* Closes a file on the device.
@@ -188,7 +188,7 @@ afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mo
* @param client The client to close the file with.
* @param handle File handle of a previously opened file.
*/
-afc_error_t afc_file_close(afc_client_t client, uint64_t handle);
+LIBIMOBILEDEVICE_API afc_error_t afc_file_close(afc_client_t client, uint64_t handle);
/**
* Locks or unlocks a file on the device.
@@ -202,7 +202,7 @@ afc_error_t afc_file_close(afc_client_t client, uint64_t handle);
* AFC_LOCK_SH (shared lock), AFC_LOCK_EX (exclusive lock), or
* AFC_LOCK_UN (unlock).
*/
-afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation);
+LIBIMOBILEDEVICE_API afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation);
/**
* Attempts to the read the given number of bytes from the given file.
@@ -215,7 +215,7 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read);
+LIBIMOBILEDEVICE_API afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read);
/**
* Writes a given number of bytes to a file.
@@ -228,7 +228,7 @@ afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written);
+LIBIMOBILEDEVICE_API afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written);
/**
* Seeks to a given position of a pre-opened file on the device.
@@ -240,7 +240,7 @@ afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *dat
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence);
+LIBIMOBILEDEVICE_API afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence);
/**
* Returns current position in a pre-opened file on the device.
@@ -251,7 +251,7 @@ afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset,
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position);
+LIBIMOBILEDEVICE_API afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position);
/**
* Sets the size of a file on the device.
@@ -265,7 +265,7 @@ afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *positi
* @note This function is more akin to ftruncate than truncate, and truncate
* calls would have to open the file before calling this, sadly.
*/
-afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize);
+LIBIMOBILEDEVICE_API afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize);
/**
* Deletes a file or directory.
@@ -275,7 +275,7 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_remove_path(afc_client_t client, const char *path);
+LIBIMOBILEDEVICE_API afc_error_t afc_remove_path(afc_client_t client, const char *path);
/**
* Renames a file or directory on the device.
@@ -286,7 +286,7 @@ afc_error_t afc_remove_path(afc_client_t client, const char *path);
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to);
+LIBIMOBILEDEVICE_API afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to);
/**
* Creates a directory on the device.
@@ -297,7 +297,7 @@ afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *t
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_make_directory(afc_client_t client, const char *path);
+LIBIMOBILEDEVICE_API afc_error_t afc_make_directory(afc_client_t client, const char *path);
/**
* Sets the size of a file on the device without prior opening it.
@@ -308,7 +308,7 @@ afc_error_t afc_make_directory(afc_client_t client, const char *path);
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize);
+LIBIMOBILEDEVICE_API afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize);
/**
* Creates a hard link or symbolic link on the device.
@@ -320,7 +320,7 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname);
+LIBIMOBILEDEVICE_API afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname);
/**
* Sets the modification time of a file on the device.
@@ -331,7 +331,7 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime);
+LIBIMOBILEDEVICE_API afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime);
/**
* Deletes a file or directory including possible contents.
@@ -343,7 +343,7 @@ afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mt
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path);
+LIBIMOBILEDEVICE_API afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path);
/* Helper functions */
@@ -358,7 +358,7 @@ afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path);
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value);
+LIBIMOBILEDEVICE_API afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value);
/**
* Frees up a char dictionary as returned by some AFC functions.
@@ -367,7 +367,16 @@ afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char *
*
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
*/
-afc_error_t afc_dictionary_free(char **dictionary);
+LIBIMOBILEDEVICE_API afc_error_t afc_dictionary_free(char **dictionary);
+
+/**
+ * Gets a readable error string for a given AFC error code.
+ *
+ * @param err An AFC error code
+ *
+ * @returns A readable error string
+ */
+LIBIMOBILEDEVICE_API const char* afc_strerror(afc_error_t err);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/bt_packet_logger.h b/include/libimobiledevice/bt_packet_logger.h
index 230040a..590e5c1 100644
--- a/include/libimobiledevice/bt_packet_logger.h
+++ b/include/libimobiledevice/bt_packet_logger.h
@@ -70,7 +70,7 @@ typedef void (*bt_packet_logger_receive_cb_t)(uint8_t * data, uint16_t len, void
* @return BT_PACKET_LOGGER_E_SUCCESS on success, BT_PACKET_LOGGER_E_INVALID_ARG when
* client is NULL, or an BT_PACKET_LOGGER_E_* error code otherwise.
*/
-bt_packet_logger_error_t bt_packet_logger_client_new(idevice_t device, lockdownd_service_descriptor_t service, bt_packet_logger_client_t * client);
+LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_new(idevice_t device, lockdownd_service_descriptor_t service, bt_packet_logger_client_t * client);
/**
* Starts a new bt_packet_logger service on the specified device and connects to it.
@@ -85,7 +85,7 @@ bt_packet_logger_error_t bt_packet_logger_client_new(idevice_t device, lockdownd
* @return BT_PACKET_LOGGER_E_SUCCESS on success, or an BT_PACKET_LOGGER_E_* error
* code otherwise.
*/
-bt_packet_logger_error_t bt_packet_logger_client_start_service(idevice_t device, bt_packet_logger_client_t * client, const char* label);
+LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_start_service(idevice_t device, bt_packet_logger_client_t * client, const char* label);
/**
* Disconnects a bt_packet_logger client from the device and frees up the
@@ -96,7 +96,7 @@ bt_packet_logger_error_t bt_packet_logger_client_start_service(idevice_t device,
* @return BT_PACKET_LOGGER_E_SUCCESS on success, BT_PACKET_LOGGER_E_INVALID_ARG when
* client is NULL, or an BT_PACKET_LOGGER_E_* error code otherwise.
*/
-bt_packet_logger_error_t bt_packet_logger_client_free(bt_packet_logger_client_t client);
+LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_free(bt_packet_logger_client_t client);
/**
@@ -113,7 +113,7 @@ bt_packet_logger_error_t bt_packet_logger_client_free(bt_packet_logger_client_t
* invalid or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified
* error occurs or an hci capture has already been started.
*/
-bt_packet_logger_error_t bt_packet_logger_start_capture(bt_packet_logger_client_t client, bt_packet_logger_receive_cb_t callback, void* user_data);
+LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_start_capture(bt_packet_logger_client_t client, bt_packet_logger_receive_cb_t callback, void* user_data);
/**
* Stops capturing the hci interface from the device.
@@ -127,7 +127,7 @@ bt_packet_logger_error_t bt_packet_logger_start_capture(bt_packet_logger_client_
* invalid or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified
* error occurs or an hci capture has already been started.
*/
-bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t client);
+LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t client);
/* Receiving */
@@ -146,7 +146,7 @@ bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t
* occurs, or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified
* error occurs.
*/
-bt_packet_logger_error_t bt_packet_logger_receive_with_timeout(bt_packet_logger_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
+LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_receive_with_timeout(bt_packet_logger_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
#ifdef __cplusplus
diff --git a/include/libimobiledevice/companion_proxy.h b/include/libimobiledevice/companion_proxy.h
index d786766..544322a 100644
--- a/include/libimobiledevice/companion_proxy.h
+++ b/include/libimobiledevice/companion_proxy.h
@@ -67,7 +67,7 @@ typedef void (*companion_proxy_device_event_cb_t) (plist_t event, void* userdata
* @return COMPANION_PROXY_E_SUCCESS on success, COMPANION_PROXY_E_INVALID_ARG when
* the arguments are invalid, or an COMPANION_PROXY_E_* error code otherwise.
*/
-companion_proxy_error_t companion_proxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, companion_proxy_client_t* client);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, companion_proxy_client_t* client);
/**
* Starts a new companion_proxy service on the specified device and connects to it.
@@ -82,7 +82,7 @@ companion_proxy_error_t companion_proxy_client_new(idevice_t device, lockdownd_s
* @return COMPANION_PROXY_E_SUCCESS on success, or an COMPANION_PROXY_E_* error
* code otherwise.
*/
-companion_proxy_error_t companion_proxy_client_start_service(idevice_t device, companion_proxy_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_start_service(idevice_t device, companion_proxy_client_t* client, const char* label);
/**
* Disconnects a companion_proxy client from the device and frees up the
@@ -93,7 +93,7 @@ companion_proxy_error_t companion_proxy_client_start_service(idevice_t device, c
* @return COMPANION_PROXY_E_SUCCESS on success, COMPANION_PROXY_E_INVALID_ARG when
* client is NULL, or an COMPANION_PROXY_E_* error code otherwise.
*/
-companion_proxy_error_t companion_proxy_client_free(companion_proxy_client_t client);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_free(companion_proxy_client_t client);
/**
* Sends a plist to the service.
@@ -104,7 +104,7 @@ companion_proxy_error_t companion_proxy_client_free(companion_proxy_client_t cli
* @return COMPANION_PROXY_E_SUCCESS on success,
* COMPANION_PROXY_E_INVALID_ARG when client or plist is NULL
*/
-companion_proxy_error_t companion_proxy_send(companion_proxy_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_send(companion_proxy_client_t client, plist_t plist);
/**
* Receives a plist from the service.
@@ -115,7 +115,7 @@ companion_proxy_error_t companion_proxy_send(companion_proxy_client_t client, pl
* @return COMPANION_PROXY_E_SUCCESS on success,
* COMPANION_PROXY_E_INVALID_ARG when client or plist is NULL
*/
-companion_proxy_error_t companion_proxy_receive(companion_proxy_client_t client, plist_t * plist);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_receive(companion_proxy_client_t client, plist_t * plist);
/**
* Retrieves a list of paired devices.
@@ -129,7 +129,7 @@ companion_proxy_error_t companion_proxy_receive(companion_proxy_client_t client,
* COMPANION_PROXY_E_NO_DEVICES if no devices are paired,
* or a COMPANION_PROXY_E_* error code otherwise.
*/
-companion_proxy_error_t companion_proxy_get_device_registry(companion_proxy_client_t client, plist_t* paired_devices);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_device_registry(companion_proxy_client_t client, plist_t* paired_devices);
/**
* Starts listening for paired devices.
@@ -145,7 +145,7 @@ companion_proxy_error_t companion_proxy_get_device_registry(companion_proxy_clie
* @return COMPANION_PROXY_E_SUCCESS on success,
* or a COMPANION_PROXY_E_* error code otherwise.
*/
-companion_proxy_error_t companion_proxy_start_listening_for_devices(companion_proxy_client_t client, companion_proxy_device_event_cb_t callback, void* userdata);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_listening_for_devices(companion_proxy_client_t client, companion_proxy_device_event_cb_t callback, void* userdata);
/**
* Stops listening for paired devices
@@ -155,7 +155,7 @@ companion_proxy_error_t companion_proxy_start_listening_for_devices(companion_pr
* @return COMPANION_PROXY_E_SUCCESS on success,
* or a COMPANION_PROXY_E_* error code otherwise.
*/
-companion_proxy_error_t companion_proxy_stop_listening_for_devices(companion_proxy_client_t client);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_listening_for_devices(companion_proxy_client_t client);
/**
* Returns a value for the given key.
@@ -173,7 +173,7 @@ companion_proxy_error_t companion_proxy_stop_listening_for_devices(companion_pro
* COMPANION_PROXY_E_UNSUPPORTED_KEY if the companion device doesn't support the given key,
* or a COMPANION_PROXY_E_* error code otherwise.
*/
-companion_proxy_error_t companion_proxy_get_value_from_registry(companion_proxy_client_t client, const char* companion_udid, const char* key, plist_t* value);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_value_from_registry(companion_proxy_client_t client, const char* companion_udid, const char* key, plist_t* value);
/**
* Start forwarding a service port on the companion device to a port on the idevice.
@@ -190,7 +190,7 @@ companion_proxy_error_t companion_proxy_get_value_from_registry(companion_proxy_
* @return COMPANION_PROXY_E_SUCCESS on success,
* or a COMPANION_PROXY_E_* error code otherwise.
*/
-companion_proxy_error_t companion_proxy_start_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options);
/**
* Stop forwarding a service port between companion device and idevice.
@@ -203,7 +203,7 @@ companion_proxy_error_t companion_proxy_start_forwarding_service_port(companion_
* @return COMPANION_PROXY_E_SUCCESS on success,
* or a COMPANION_PROXY_E_* error code otherwise.
*/
-companion_proxy_error_t companion_proxy_stop_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port);
+LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/debugserver.h b/include/libimobiledevice/debugserver.h
index eaa7c48..809b97f 100644
--- a/include/libimobiledevice/debugserver.h
+++ b/include/libimobiledevice/debugserver.h
@@ -66,7 +66,7 @@ typedef debugserver_command_private *debugserver_command_t; /**< The command han
* @return DEBUGSERVER_E_SUCCESS on success, DEBUGSERVER_E_INVALID_ARG when
* client is NULL, or an DEBUGSERVER_E_* error code otherwise.
*/
-debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_descriptor_t service, debugserver_client_t * client);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_descriptor_t service, debugserver_client_t * client);
/**
* Starts a new debugserver service on the specified device and connects to it.
@@ -81,7 +81,7 @@ debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_d
* @return DEBUGSERVER_E_SUCCESS on success, or an DEBUGSERVER_E_* error
* code otherwise.
*/
-debugserver_error_t debugserver_client_start_service(idevice_t device, debugserver_client_t * client, const char* label);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_start_service(idevice_t device, debugserver_client_t * client, const char* label);
/**
* Disconnects a debugserver client from the device and frees up the
@@ -92,7 +92,7 @@ debugserver_error_t debugserver_client_start_service(idevice_t device, debugserv
* @return DEBUGSERVER_E_SUCCESS on success, DEBUGSERVER_E_INVALID_ARG when
* client is NULL, or an DEBUGSERVER_E_* error code otherwise.
*/
-debugserver_error_t debugserver_client_free(debugserver_client_t client);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_free(debugserver_client_t client);
/**
* Sends raw data using the given debugserver service client.
@@ -107,7 +107,7 @@ debugserver_error_t debugserver_client_free(debugserver_client_t client);
* invalid, or DEBUGSERVER_E_UNKNOWN_ERROR when an unspecified
* error occurs.
*/
-debugserver_error_t debugserver_client_send(debugserver_client_t client, const char* data, uint32_t size, uint32_t *sent);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_send(debugserver_client_t client, const char* data, uint32_t size, uint32_t *sent);
/**
* Receives raw data using the given debugserver client with specified timeout.
@@ -125,7 +125,7 @@ debugserver_error_t debugserver_client_send(debugserver_client_t client, const c
* or DEBUGSERVER_E_UNKNOWN_ERROR when an unspecified
* error occurs.
*/
-debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
/**
* Receives raw data from the debugserver service.
@@ -139,7 +139,7 @@ debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t
* @return DEBUGSERVER_E_SUCCESS on success,
* DEBUGSERVER_E_INVALID_ARG when client or plist is NULL
*/
-debugserver_error_t debugserver_client_receive(debugserver_client_t client, char *data, uint32_t size, uint32_t *received);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive(debugserver_client_t client, char *data, uint32_t size, uint32_t *received);
/**
* Sends a command to the debugserver service.
@@ -152,7 +152,7 @@ debugserver_error_t debugserver_client_receive(debugserver_client_t client, char
* @return DEBUGSERVER_E_SUCCESS on success,
* DEBUGSERVER_E_INVALID_ARG when client or command is NULL
*/
-debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response, size_t* response_size);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response, size_t* response_size);
/**
* Receives and parses response of debugserver service.
@@ -164,7 +164,7 @@ debugserver_error_t debugserver_client_send_command(debugserver_client_t client,
* @return DEBUGSERVER_E_SUCCESS on success,
* DEBUGSERVER_E_INVALID_ARG when client is NULL
*/
-debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response, size_t* response_size);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response, size_t* response_size);
/**
* Controls status of ACK mode when sending commands or receiving responses.
@@ -178,7 +178,7 @@ debugserver_error_t debugserver_client_receive_response(debugserver_client_t cli
* @return DEBUGSERVER_E_SUCCESS on success, or an DEBUGSERVER_E_* error
* code otherwise.
*/
-debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client, int enabled);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client, int enabled);
/**
* Sets behavior when awaiting a response from the server.
@@ -197,7 +197,7 @@ debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client,
* @return DEBUGSERVER_E_SUCCESS on success, or an DEBUGSERVER_E_* error
* code otherwise.
*/
-debugserver_error_t debugserver_client_set_receive_params(debugserver_client_t client, int (*cancel_receive)(), int receive_loop_timeout);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_receive_params(debugserver_client_t client, int (*cancel_receive)(), int receive_loop_timeout);
/**
* Sets the argv which launches an app.
@@ -210,7 +210,7 @@ debugserver_error_t debugserver_client_set_receive_params(debugserver_client_t c
* @return DEBUGSERVER_E_SUCCESS on success,
* DEBUGSERVER_E_INVALID_ARG when client is NULL
*/
-debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int argc, char* argv[], char** response);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int argc, char* argv[], char** response);
/**
* Adds or sets an environment variable.
@@ -222,7 +222,7 @@ debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int
* @return DEBUGSERVER_E_SUCCESS on success,
* DEBUGSERVER_E_INVALID_ARG when client is NULL
*/
-debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_client_t client, const char* env, char** response);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_client_t client, const char* env, char** response);
/**
* Creates and initializes a new command object.
@@ -235,7 +235,7 @@ debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_c
* @return DEBUGSERVER_E_SUCCESS on success,
* DEBUGSERVER_E_INVALID_ARG when name or command is NULL
*/
-debugserver_error_t debugserver_command_new(const char* name, int argc, char* argv[], debugserver_command_t* command);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_command_new(const char* name, int argc, char* argv[], debugserver_command_t* command);
/**
* Frees memory of command object.
@@ -245,7 +245,7 @@ debugserver_error_t debugserver_command_new(const char* name, int argc, char* ar
* @return DEBUGSERVER_E_SUCCESS on success,
* DEBUGSERVER_E_INVALID_ARG when command is NULL
*/
-debugserver_error_t debugserver_command_free(debugserver_command_t command);
+LIBIMOBILEDEVICE_API debugserver_error_t debugserver_command_free(debugserver_command_t command);
/**
* Encodes a string into hex notation.
@@ -254,7 +254,7 @@ debugserver_error_t debugserver_command_free(debugserver_command_t command);
* @param encoded_buffer The buffer receives a hex encoded string
* @param encoded_length Length of the hex encoded string
*/
-void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32_t* encoded_length);
+LIBIMOBILEDEVICE_API void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32_t* encoded_length);
/**
* Decodes a hex encoded string.
@@ -263,7 +263,7 @@ void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32
* @param encoded_length Length of the encoded buffer
* @param buffer Decoded string to be freed by the caller
*/
-void debugserver_decode_string(const char *encoded_buffer, size_t encoded_length, char** buffer);
+LIBIMOBILEDEVICE_API void debugserver_decode_string(const char *encoded_buffer, size_t encoded_length, char** buffer);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/diagnostics_relay.h b/include/libimobiledevice/diagnostics_relay.h
index f80a86b..6ab47a9 100644
--- a/include/libimobiledevice/diagnostics_relay.h
+++ b/include/libimobiledevice/diagnostics_relay.h
@@ -70,7 +70,7 @@ typedef diagnostics_relay_client_private *diagnostics_relay_client_t; /**< The c
* DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid,
* or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed.
*/
-diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client);
/**
* Starts a new diagnostics_relay service on the specified device and connects to it.
@@ -85,7 +85,7 @@ diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdow
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success, or an DIAGNOSTICS_RELAY_E_* error
* code otherwise.
*/
-diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t* client, const char* label);
/**
* Disconnects a diagnostics_relay client from the device and frees up the
@@ -98,7 +98,7 @@ diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t devic
* is invalid, or DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR when the was an
* error freeing the parent property_list_service client.
*/
-diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client);
/**
@@ -111,7 +111,7 @@ diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client);
/**
* Puts the device into deep sleep mode and disconnects from host.
@@ -123,7 +123,7 @@ diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t c
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client);
/**
* Restart the device and optionally show a user notification.
@@ -140,7 +140,7 @@ diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t cli
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, diagnostics_relay_action_t flags);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, diagnostics_relay_action_t flags);
/**
* Shutdown of the device and optionally show a user notification.
@@ -157,7 +157,7 @@ diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t c
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, diagnostics_relay_action_t flags);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, diagnostics_relay_action_t flags);
/**
* Request diagnostics information for a given type.
@@ -173,7 +173,7 @@ diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics);
/**
* Query one or multiple MobileGestalt keys.
@@ -188,7 +188,7 @@ diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_rela
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result);
/**
* Query an IORegistry entry of a given class.
@@ -204,7 +204,7 @@ diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_rela
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* entry_name, const char* entry_class, plist_t* result);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* entry_name, const char* entry_class, plist_t* result);
/**
* Query an IORegistry plane.
@@ -219,7 +219,7 @@ diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_r
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result);
+LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/file_relay.h b/include/libimobiledevice/file_relay.h
index 6b30e65..00773b8 100644
--- a/include/libimobiledevice/file_relay.h
+++ b/include/libimobiledevice/file_relay.h
@@ -62,7 +62,7 @@ typedef file_relay_client_private *file_relay_client_t; /**< The client handle.
* FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid,
* or FILE_RELAY_E_MUX_ERROR when the connection failed.
*/
-file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client);
+LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client);
/**
* Starts a new file_relay service on the specified device and connects to it.
@@ -77,7 +77,7 @@ file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_des
* @return FILE_RELAY_E_SUCCESS on success, or an FILE_RELAY_E_* error
* code otherwise.
*/
-file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t* client, const char* label);
/**
* Disconnects a file_relay client from the device and frees up the file_relay
@@ -90,7 +90,7 @@ file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_
* is invalid, or FILE_RELAY_E_UNKNOWN_ERROR when the was an error
* freeing the parent property_list_service client.
*/
-file_relay_error_t file_relay_client_free(file_relay_client_t client);
+LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_free(file_relay_client_t client);
/**
@@ -123,7 +123,7 @@ file_relay_error_t file_relay_client_free(file_relay_client_t client);
* sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
* for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
*/
-file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection);
+LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection);
/**
* Request data for the given sources. Calls file_relay_request_sources_timeout() with
@@ -157,7 +157,7 @@ file_relay_error_t file_relay_request_sources(file_relay_client_t client, const
* sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
* for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
*/
-file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout);
+LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/heartbeat.h b/include/libimobiledevice/heartbeat.h
index 42b318d..4074b8b 100644
--- a/include/libimobiledevice/heartbeat.h
+++ b/include/libimobiledevice/heartbeat.h
@@ -60,7 +60,7 @@ typedef heartbeat_client_private *heartbeat_client_t; /**< The client handle. */
* @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
* client is NULL, or an HEARTBEAT_E_* error code otherwise.
*/
-heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client);
+LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client);
/**
* Starts a new heartbeat service on the specified device and connects to it.
@@ -75,7 +75,7 @@ heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descr
* @return HEARTBEAT_E_SUCCESS on success, or an HEARTBEAT_E_* error
* code otherwise.
*/
-heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label);
+LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label);
/**
* Disconnects a heartbeat client from the device and frees up the
@@ -86,7 +86,7 @@ heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_cli
* @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
* client is NULL, or an HEARTBEAT_E_* error code otherwise.
*/
-heartbeat_error_t heartbeat_client_free(heartbeat_client_t client);
+LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_free(heartbeat_client_t client);
/**
@@ -98,7 +98,7 @@ heartbeat_error_t heartbeat_client_free(heartbeat_client_t client);
* @return HEARTBEAT_E_SUCCESS on success,
* HEARTBEAT_E_INVALID_ARG when client or plist is NULL
*/
-heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist);
/**
* Receives a plist from the service.
@@ -109,7 +109,7 @@ heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist);
* @return HEARTBEAT_E_SUCCESS on success,
* HEARTBEAT_E_INVALID_ARG when client or plist is NULL
*/
-heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist);
+LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist);
/**
* Receives a plist using the given heartbeat client.
@@ -128,7 +128,7 @@ heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist);
* communication error occurs, or HEARTBEAT_E_UNKNOWN_ERROR
* when an unspecified error occurs.
*/
-heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms);
+LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/house_arrest.h b/include/libimobiledevice/house_arrest.h
index 3785847..f9ba68a 100644
--- a/include/libimobiledevice/house_arrest.h
+++ b/include/libimobiledevice/house_arrest.h
@@ -61,7 +61,7 @@ typedef house_arrest_client_private *house_arrest_client_t; /**< The client hand
* @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
* client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
*/
-house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client);
+LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client);
/**
* Starts a new house_arrest service on the specified device and connects to it.
@@ -76,7 +76,7 @@ house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service
* @return HOUSE_ARREST_E_SUCCESS on success, or an HOUSE_ARREST_E_* error
* code otherwise.
*/
-house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t* client, const char* label);
/**
* Disconnects an house_arrest client from the device and frees up the
@@ -92,7 +92,7 @@ house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_a
* @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
* client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
*/
-house_arrest_error_t house_arrest_client_free(house_arrest_client_t client);
+LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_free(house_arrest_client_t client);
/**
@@ -112,7 +112,7 @@ house_arrest_error_t house_arrest_client_free(house_arrest_client_t client);
* HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
* or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred.
*/
-house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict);
+LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict);
/**
* Send a command to the connected house_arrest service.
@@ -133,7 +133,7 @@ house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, pli
* HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
* or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred.
*/
-house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid);
+LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid);
/**
* Retrieves the result of a previously sent house_arrest_request_* request.
@@ -149,7 +149,7 @@ house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, con
* HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
* or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred.
*/
-house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict);
+LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict);
/**
@@ -171,7 +171,7 @@ house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist
* an afc client, or an AFC_E_* error code returned by
* afc_client_new_with_service_client().
*/
-afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client);
+LIBIMOBILEDEVICE_API afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/installation_proxy.h b/include/libimobiledevice/installation_proxy.h
index 87132b9..44331aa 100644
--- a/include/libimobiledevice/installation_proxy.h
+++ b/include/libimobiledevice/installation_proxy.h
@@ -127,7 +127,7 @@ typedef void (*instproxy_status_cb_t) (plist_t command, plist_t status, void *us
* @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value
* when an error occurred.
*/
-instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client);
/**
* Starts a new installation_proxy service on the specified device and connects to it.
@@ -142,7 +142,7 @@ instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descr
* @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error
* code otherwise.
*/
-instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label);
/**
* Disconnects an installation_proxy client from the device and frees up the
@@ -153,7 +153,7 @@ instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_cli
* @return INSTPROXY_E_SUCCESS on success
* or INSTPROXY_E_INVALID_ARG if client is NULL.
*/
-instproxy_error_t instproxy_client_free(instproxy_client_t client);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_free(instproxy_client_t client);
/**
* List installed applications. This function runs synchronously.
@@ -171,7 +171,7 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client);
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
* an error occurred.
*/
-instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result);
/**
* List pages of installed applications in a callback.
@@ -190,7 +190,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_opt
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
* an error occurred.
*/
-instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
/**
* Lookup information about specific applications from the device.
@@ -206,7 +206,7 @@ instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plis
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
* an error occurred.
*/
-instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result);
/**
* Install an application on the device.
@@ -232,7 +232,7 @@ instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appid
* created successfully; any error occurring during the command has to be
* handled inside the specified callback function.
*/
-instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
/**
* Upgrade an application on the device. This function is nearly the same as
@@ -260,7 +260,7 @@ instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_p
* created successfully; any error occurring during the command has to be
* handled inside the specified callback function.
*/
-instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
/**
* Uninstall an application from the device.
@@ -281,7 +281,7 @@ instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_p
* created successfully; any error occurring during the command has to be
* handled inside the specified callback function.
*/
-instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
/**
* List archived applications. This function runs synchronously.
@@ -297,7 +297,7 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
* an error occurred.
*/
-instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result);
/**
* Archive an application on the device.
@@ -323,7 +323,7 @@ instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t c
* created successfully; any error occurring during the command has to be
* handled inside the specified callback function.
*/
-instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
/**
* Restore a previously archived application on the device.
@@ -347,7 +347,7 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid
* created successfully; any error occurring during the command has to be
* handled inside the specified callback function.
*/
-instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
/**
* Removes a previously archived application from the device.
@@ -370,7 +370,7 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid
* created successfully; any error occurring during the command has to be
* handled inside the specified callback function.
*/
-instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
/**
* Checks a device for certain capabilities.
@@ -386,7 +386,7 @@ instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
* an error occurred.
*/
-instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client, const char** capabilities, plist_t client_options, plist_t *result);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client, const char** capabilities, plist_t client_options, plist_t *result);
/* Helper */
@@ -396,7 +396,7 @@ instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client,
* @param command The dictionary describing the command.
* @param name Pointer to store the name of the command.
*/
-void instproxy_command_get_name(plist_t command, char** name);
+LIBIMOBILEDEVICE_API void instproxy_command_get_name(plist_t command, char** name);
/**
* Gets the name of a status.
@@ -404,7 +404,7 @@ void instproxy_command_get_name(plist_t command, char** name);
* @param status The dictionary status response to use.
* @param name Pointer to store the name of the status.
*/
-void instproxy_status_get_name(plist_t status, char **name);
+LIBIMOBILEDEVICE_API void instproxy_status_get_name(plist_t status, char **name);
/**
* Gets error name, code and description from a response if available.
@@ -420,7 +420,7 @@ void instproxy_status_get_name(plist_t status, char **name);
* @return INSTPROXY_E_SUCCESS if no error is found or an INSTPROXY_E_* error
* value matching the error that ẃas found in the status.
*/
-instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char** description, uint64_t* code);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char** description, uint64_t* code);
/**
* Gets total and current item information from a browse response if available.
@@ -435,7 +435,7 @@ instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char**
* If NULL is passed no list will be returned. If NULL is returned no
* list was found in the status.
*/
-void instproxy_status_get_current_list(plist_t status, uint64_t* total, uint64_t* current_index, uint64_t* current_amount, plist_t* list);
+LIBIMOBILEDEVICE_API void instproxy_status_get_current_list(plist_t status, uint64_t* total, uint64_t* current_index, uint64_t* current_amount, plist_t* list);
/**
@@ -445,14 +445,14 @@ void instproxy_status_get_current_list(plist_t status, uint64_t* total, uint64_t
* @param percent Pointer to an int to store the progress in percent (0-100)
* or -1 if no progress was found in the status.
*/
-void instproxy_status_get_percent_complete(plist_t status, int *percent);
+LIBIMOBILEDEVICE_API void instproxy_status_get_percent_complete(plist_t status, int *percent);
/**
* Creates a new client_options plist.
*
* @return A new plist_t of type PLIST_DICT.
*/
-plist_t instproxy_client_options_new(void);
+LIBIMOBILEDEVICE_API plist_t instproxy_client_options_new(void);
/**
* Adds one or more new key:value pairs to the given client_options.
@@ -464,7 +464,7 @@ plist_t instproxy_client_options_new(void);
* keys "ApplicationSINF", "iTunesMetadata", "ReturnAttributes" which are
* expecting a plist_t node as value and "SkipUninstall" expects int.
*/
-void instproxy_client_options_add(plist_t client_options, ...);
+LIBIMOBILEDEVICE_API void instproxy_client_options_add(plist_t client_options, ...);
/**
* Adds attributes to the given client_options to filter browse results.
@@ -474,7 +474,7 @@ void instproxy_client_options_add(plist_t client_options, ...);
*
* @note The values passed are expected to be strings.
*/
-void instproxy_client_options_set_return_attributes(plist_t client_options, ...);
+LIBIMOBILEDEVICE_API void instproxy_client_options_set_return_attributes(plist_t client_options, ...);
/**
* Frees client_options plist.
@@ -482,7 +482,7 @@ void instproxy_client_options_set_return_attributes(plist_t client_options, ...)
* @param client_options The client options plist to free. Does nothing if NULL
* is passed.
*/
-void instproxy_client_options_free(plist_t client_options);
+LIBIMOBILEDEVICE_API void instproxy_client_options_free(plist_t client_options);
/**
* Queries the device for the path of an application.
@@ -496,7 +496,7 @@ void instproxy_client_options_free(plist_t client_options);
* the path could not be determined or an INSTPROXY_E_* error
* value if an error occurred.
*/
-instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path);
+LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/libimobiledevice.h b/include/libimobiledevice/libimobiledevice.h
index 6851145..a9d270b 100644
--- a/include/libimobiledevice/libimobiledevice.h
+++ b/include/libimobiledevice/libimobiledevice.h
@@ -35,6 +35,16 @@ extern "C" {
#include <sys/stat.h>
#include <plist/plist.h>
+#ifndef LIBIMOBILEDEVICE_API
+ #ifdef LIBIMOBILEDEVICE_STATIC
+ #define LIBIMOBILEDEVICE_API
+ #elif defined(_WIN32)
+ #define LIBIMOBILEDEVICE_API __declspec(dllimport)
+ #else
+ #define LIBIMOBILEDEVICE_API
+ #endif
+#endif
+
/** Error Codes */
typedef enum {
IDEVICE_E_SUCCESS = 0,
@@ -104,7 +114,7 @@ typedef struct idevice_subscription_context* idevice_subscription_context_t;
*
* @param level Set to 0 for no debug output or 1 to enable debug output.
*/
-void idevice_set_debug_level(int level);
+LIBIMOBILEDEVICE_API void idevice_set_debug_level(int level);
/**
* Subscribe a callback function that will be called when device add/remove
@@ -119,7 +129,7 @@ void idevice_set_debug_level(int level);
*
* @return IDEVICE_E_SUCCESS on success or an error value when an error occurred.
*/
-idevice_error_t idevice_events_subscribe(idevice_subscription_context_t *context, idevice_event_cb_t callback, void *user_data);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_events_subscribe(idevice_subscription_context_t *context, idevice_event_cb_t callback, void *user_data);
/**
* Unsubscribe the event callback function that has been registered with
@@ -129,7 +139,7 @@ idevice_error_t idevice_events_subscribe(idevice_subscription_context_t *context
*
* @return IDEVICE_E_SUCCESS on success or an error value when an error occurred.
*/
-idevice_error_t idevice_events_unsubscribe(idevice_subscription_context_t context);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_events_unsubscribe(idevice_subscription_context_t context);
/**
* (DEPRECATED) Register a callback function that will be called when device add/remove
@@ -143,7 +153,7 @@ idevice_error_t idevice_events_unsubscribe(idevice_subscription_context_t contex
*
* @return IDEVICE_E_SUCCESS on success or an error value when an error occurred.
*/
-idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data);
/**
* (DEPRECATED) Release the event callback function that has been registered with
@@ -153,7 +163,7 @@ idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_
*
* @return IDEVICE_E_SUCCESS on success or an error value when an error occurred.
*/
-idevice_error_t idevice_event_unsubscribe(void);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_event_unsubscribe(void);
/* discovery (synchronous) */
@@ -170,7 +180,7 @@ idevice_error_t idevice_event_unsubscribe(void);
* network devices in the list, use idevice_get_device_list_extended().
* @see idevice_get_device_list_extended
*/
-idevice_error_t idevice_get_device_list(char ***devices, int *count);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list(char ***devices, int *count);
/**
* Free a list of device UDIDs.
@@ -179,7 +189,7 @@ idevice_error_t idevice_get_device_list(char ***devices, int *count);
*
* @return Always returnes IDEVICE_E_SUCCESS.
*/
-idevice_error_t idevice_device_list_free(char **devices);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_free(char **devices);
/**
* Get a list of currently available devices
@@ -190,7 +200,7 @@ idevice_error_t idevice_device_list_free(char **devices);
*
* @return IDEVICE_E_SUCCESS on success or an error value when an error occurred.
*/
-idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *count);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *count);
/**
* Free an extended device list retrieved through idevice_get_device_list_extended().
@@ -199,7 +209,7 @@ idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *
*
* @return IDEVICE_E_SUCCESS on success or an error value when an error occurred.
*/
-idevice_error_t idevice_device_list_extended_free(idevice_info_t *devices);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_extended_free(idevice_info_t *devices);
/* device structure creation and destruction */
@@ -220,7 +230,7 @@ idevice_error_t idevice_device_list_extended_free(idevice_info_t *devices);
*
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
*/
-idevice_error_t idevice_new(idevice_t *device, const char *udid);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t *device, const char *udid);
/**
* Creates an idevice_t structure for the device specified by UDID,
@@ -243,14 +253,14 @@ idevice_error_t idevice_new(idevice_t *device, const char *udid);
*
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
*/
-idevice_error_t idevice_new_with_options(idevice_t *device, const char *udid, enum idevice_options options);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_new_with_options(idevice_t *device, const char *udid, enum idevice_options options);
/**
* Cleans up an idevice structure, then frees the structure itself.
*
* @param device idevice_t to free.
*/
-idevice_error_t idevice_free(idevice_t device);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_free(idevice_t device);
/* connection/disconnection */
@@ -264,7 +274,7 @@ idevice_error_t idevice_free(idevice_t device);
*
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
*/
-idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection);
/**
* Disconnect from the device and clean up the connection structure.
@@ -273,7 +283,7 @@ idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connect
*
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
*/
-idevice_error_t idevice_disconnect(idevice_connection_t connection);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_disconnect(idevice_connection_t connection);
/* communication */
@@ -288,7 +298,7 @@ idevice_error_t idevice_disconnect(idevice_connection_t connection);
*
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
*/
-idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes);
/**
* Receive data from a device via the given connection.
@@ -305,7 +315,7 @@ idevice_error_t idevice_connection_send(idevice_connection_t connection, const c
*
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
*/
-idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout);
/**
* Receive data from a device via the given connection.
@@ -320,7 +330,7 @@ idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connecti
*
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
*/
-idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes);
/**
* Enables SSL for the given connection.
@@ -331,7 +341,7 @@ idevice_error_t idevice_connection_receive(idevice_connection_t connection, char
* is NULL or connection->ssl_data is non-NULL, or IDEVICE_E_SSL_ERROR when
* SSL initialization, setup, or handshake fails.
*/
-idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection);
/**
* Disable SSL for the given connection.
@@ -342,7 +352,7 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection);
* is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not
* enabled and does no further error checking on cleanup.
*/
-idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection);
/**
* Disable bypass SSL for the given connection without sending out terminate messages.
@@ -355,7 +365,7 @@ idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection);
* is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not
* enabled and does no further error checking on cleanup.
*/
-idevice_error_t idevice_connection_disable_bypass_ssl(idevice_connection_t connection, uint8_t sslBypass);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_bypass_ssl(idevice_connection_t connection, uint8_t sslBypass);
/**
@@ -366,7 +376,7 @@ idevice_error_t idevice_connection_disable_bypass_ssl(idevice_connection_t conne
*
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
*/
-idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd);
/* misc */
@@ -378,7 +388,7 @@ idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *
*
* @return IDEVICE_E_SUCCESS on success, otherwise an error code.
*/
-idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle);
/**
* Gets the Unique Device ID for the device.
@@ -388,7 +398,14 @@ idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle);
*
* @return IDEVICE_E_SUCCESS on success, otherwise an error code.
*/
-idevice_error_t idevice_get_udid(idevice_t device, char **udid);
+LIBIMOBILEDEVICE_API idevice_error_t idevice_get_udid(idevice_t device, char **udid);
+
+/**
+ * Returns a static string of the libimobiledevice version.
+ *
+ * @return The libimobiledevice version as static ascii string
+ */
+LIBIMOBILEDEVICE_API const char* libimobiledevice_version();
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/lockdown.h b/include/libimobiledevice/lockdown.h
index 6d390fd..21669ef 100644
--- a/include/libimobiledevice/lockdown.h
+++ b/include/libimobiledevice/lockdown.h
@@ -130,7 +130,7 @@ typedef void (*lockdownd_cu_pairing_cb_t) (lockdownd_cu_pairing_cb_type_t cb_typ
*
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
*/
-lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label);
/**
* Creates a new lockdownd client for the device and starts initial handshake.
@@ -149,7 +149,7 @@ lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *cli
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL,
* LOCKDOWN_E_INVALID_CONF if configuration data is wrong
*/
-lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label);
/**
* Closes the lockdownd client session if one is running and frees up the
@@ -159,7 +159,7 @@ lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdown
*
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
*/
-lockdownd_error_t lockdownd_client_free(lockdownd_client_t client);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_free(lockdownd_client_t client);
/**
@@ -171,7 +171,7 @@ lockdownd_error_t lockdownd_client_free(lockdownd_client_t client);
*
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
*/
-lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type);
/**
* Retrieves a preferences plist using an optional domain and/or key name.
@@ -183,7 +183,7 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type);
*
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
*/
-lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value);
/**
* Sets a preferences value using a plist and optional by domain and/or key name.
@@ -196,7 +196,7 @@ lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *dom
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or
* value is NULL
*/
-lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value);
/**
* Removes a preference node by domain and/or key name.
@@ -209,7 +209,7 @@ lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *dom
*
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
*/
-lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key);
/**
* Requests to start a service and retrieve it's port on success.
@@ -223,7 +223,7 @@ lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *
* by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not be
* started by the device
*/
-lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service);
/**
* Requests to start a service and retrieve it's port on success.
@@ -239,7 +239,7 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
* started by the device, LOCKDOWN_E_INVALID_CONF if the host id or escrow bag are
* missing from the device record.
*/
-lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service);
/**
* Opens a session with lockdownd and switches to SSL mode if device wants it.
@@ -254,7 +254,7 @@ lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t cli
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the supplied HostID,
* LOCKDOWN_E_SSL_ERROR if enabling SSL communication failed
*/
-lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled);
/**
* Closes the lockdownd session by sending the StopSession request.
@@ -266,7 +266,7 @@ lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char
*
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
*/
-lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id);
/**
* Sends a plist to lockdownd.
@@ -280,7 +280,7 @@ lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or
* plist is NULL
*/
-lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist);
/**
* Receives a plist from lockdownd.
@@ -291,7 +291,7 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist);
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or
* plist is NULL
*/
-lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist);
/**
* Pairs the device using the supplied pair record.
@@ -307,7 +307,7 @@ lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist);
* LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
*/
-lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
/**
* Pairs the device using the supplied pair record and passing the given options.
@@ -326,7 +326,7 @@ lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_recor
* LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
*/
-lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response);
/**
* Validates if the device is paired with the given HostID. If successful the
@@ -345,7 +345,7 @@ lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdow
* LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
*/
-lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
/**
* Unpairs the device with the given HostID and removes the pairing records
@@ -361,7 +361,7 @@ lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_p
* LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
*/
-lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
/**
* Activates the device. Only works within an open session.
@@ -378,7 +378,7 @@ lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_rec
* LOCKDOWN_E_INVALID_ACTIVATION_RECORD if the device reports that the
* activation_record is invalid
*/
-lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record);
/**
* Deactivates the device, returning it to the locked “Activate with iTunes”
@@ -390,7 +390,7 @@ lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activati
* LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
* LOCKDOWN_E_PLIST_ERROR if the received plist is broken
*/
-lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client);
/**
* Tells the device to immediately enter recovery mode.
@@ -399,7 +399,7 @@ lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client);
*
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
*/
-lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client);
/**
* Sends the Goodbye request to lockdownd signaling the end of communication.
@@ -410,7 +410,7 @@ lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client);
* is NULL, LOCKDOWN_E_PLIST_ERROR if the device did not acknowledge the
* request
*/
-lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client);
/**
* Creates a CU pairing session for the current lockdown client.
@@ -439,7 +439,7 @@ lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client);
* parameters is invalid, LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
* or a LOCKDOWN_E_* error code otherwise.
*/
-lockdownd_error_t lockdownd_cu_pairing_create(lockdownd_client_t client, lockdownd_cu_pairing_cb_t pairing_callback, void* cb_user_data, plist_t host_info, plist_t acl);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_pairing_create(lockdownd_client_t client, lockdownd_cu_pairing_cb_t pairing_callback, void* cb_user_data, plist_t host_info, plist_t acl);
/**
* Sends a request via lockdown client with established CU pairing session
@@ -459,7 +459,7 @@ lockdownd_error_t lockdownd_cu_pairing_create(lockdownd_client_t client, lockdow
* lockdown client does not have an established CU pairing session,
* or a LOCKDOWN_E_* error code otherwise.
*/
-lockdownd_error_t lockdownd_cu_send_request_and_get_reply(lockdownd_client_t client, const char* request, plist_t request_payload, plist_t* reply);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_send_request_and_get_reply(lockdownd_client_t client, const char* request, plist_t request_payload, plist_t* reply);
/**
* Retrieves a value using an optional domain and/or key name from a lockdown
@@ -479,7 +479,7 @@ lockdownd_error_t lockdownd_cu_send_request_and_get_reply(lockdownd_client_t cli
* lockdown client does not have an established CU pairing session,
* or a LOCKDOWN_E_* error code otherwise.
*/
-lockdownd_error_t lockdownd_get_value_cu(lockdownd_client_t client, const char* domain, const char* key, plist_t* value);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_value_cu(lockdownd_client_t client, const char* domain, const char* key, plist_t* value);
/**
* Perform a device pairing with a lockdown client that has an established
@@ -492,7 +492,7 @@ lockdownd_error_t lockdownd_get_value_cu(lockdownd_client_t client, const char*
* does not have an established CU pairing session, or a LOCKDOWN_E_* error
* code otherwise.
*/
-lockdownd_error_t lockdownd_pair_cu(lockdownd_client_t client);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair_cu(lockdownd_client_t client);
/* Helper */
@@ -504,7 +504,7 @@ lockdownd_error_t lockdownd_pair_cu(lockdownd_client_t client);
* @param label The label to set or NULL to disable sending a label
*
*/
-void lockdownd_client_set_label(lockdownd_client_t client, const char *label);
+LIBIMOBILEDEVICE_API void lockdownd_client_set_label(lockdownd_client_t client, const char *label);
/**
* Returns the unique id of the device from lockdownd.
@@ -515,7 +515,7 @@ void lockdownd_client_set_label(lockdownd_client_t client, const char *label);
*
* @return LOCKDOWN_E_SUCCESS on success
*/
-lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid);
/**
* Retrieves the name of the device from lockdownd set by the user.
@@ -526,7 +526,7 @@ lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **ud
*
* @return LOCKDOWN_E_SUCCESS on success
*/
-lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name);
/**
* Calculates and returns the data classes the device supports from lockdownd.
@@ -541,7 +541,7 @@ lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **de
* LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
* LOCKDOWN_E_PLIST_ERROR if the received plist is broken
*/
-lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count);
/**
* Frees memory of an allocated array of data classes as returned by lockdownd_get_sync_data_classes()
@@ -550,7 +550,7 @@ lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, cha
*
* @return LOCKDOWN_E_SUCCESS on success
*/
-lockdownd_error_t lockdownd_data_classes_free(char **classes);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_data_classes_free(char **classes);
/**
* Frees memory of a service descriptor as returned by lockdownd_start_service()
@@ -559,7 +559,7 @@ lockdownd_error_t lockdownd_data_classes_free(char **classes);
*
* @return LOCKDOWN_E_SUCCESS on success
*/
-lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service);
+LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service);
/**
* Gets a readable error string for a given lockdown error code.
@@ -568,7 +568,7 @@ lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor
*
* @returns A readable error string
*/
-const char* lockdownd_strerror(lockdownd_error_t err);
+LIBIMOBILEDEVICE_API const char* lockdownd_strerror(lockdownd_error_t err);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/misagent.h b/include/libimobiledevice/misagent.h
index 394f5ce..7981a8b 100644
--- a/include/libimobiledevice/misagent.h
+++ b/include/libimobiledevice/misagent.h
@@ -60,7 +60,7 @@ typedef misagent_client_private *misagent_client_t; /**< The client handle. */
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
* client is NULL, or an MISAGENT_E_* error code otherwise.
*/
-misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client);
+LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client);
/**
* Starts a new misagent service on the specified device and connects to it.
@@ -75,7 +75,7 @@ misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descrip
* @return MISAGENT_E_SUCCESS on success, or an MISAGENT_E_* error
* code otherwise.
*/
-misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t* client, const char* label);
/**
* Disconnects an misagent client from the device and frees up the
@@ -86,7 +86,7 @@ misagent_error_t misagent_client_start_service(idevice_t device, misagent_client
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
* client is NULL, or an MISAGENT_E_* error code otherwise.
*/
-misagent_error_t misagent_client_free(misagent_client_t client);
+LIBIMOBILEDEVICE_API misagent_error_t misagent_client_free(misagent_client_t client);
/**
@@ -99,7 +99,7 @@ misagent_error_t misagent_client_free(misagent_client_t client);
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
* client is invalid, or an MISAGENT_E_* error code otherwise.
*/
-misagent_error_t misagent_install(misagent_client_t client, plist_t profile);
+LIBIMOBILEDEVICE_API misagent_error_t misagent_install(misagent_client_t client, plist_t profile);
/**
* Retrieves all installed provisioning profiles (iOS 9.2.1 or below).
@@ -118,7 +118,7 @@ misagent_error_t misagent_install(misagent_client_t client, plist_t profile);
* still returns MISAGENT_E_SUCCESS and profiles will just point to an
* empty array.
*/
-misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles);
+LIBIMOBILEDEVICE_API misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles);
/**
* Retrieves all installed provisioning profiles (iOS 9.3 or higher).
@@ -137,7 +137,7 @@ misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles);
* still returns MISAGENT_E_SUCCESS and profiles will just point to an
* empty array.
*/
-misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles);
+LIBIMOBILEDEVICE_API misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles);
/**
* Removes a given provisioning profile.
@@ -150,7 +150,7 @@ misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles);
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
* client is invalid, or an MISAGENT_E_* error code otherwise.
*/
-misagent_error_t misagent_remove(misagent_client_t client, const char* profileID);
+LIBIMOBILEDEVICE_API misagent_error_t misagent_remove(misagent_client_t client, const char* profileID);
/**
* Retrieves the status code from the last operation.
@@ -159,7 +159,7 @@ misagent_error_t misagent_remove(misagent_client_t client, const char* profileID
*
* @return -1 if client is invalid, or the status code from the last operation
*/
-int misagent_get_status_code(misagent_client_t client);
+LIBIMOBILEDEVICE_API int misagent_get_status_code(misagent_client_t client);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/mobile_image_mounter.h b/include/libimobiledevice/mobile_image_mounter.h
index 891df40..d4fc3f4 100644
--- a/include/libimobiledevice/mobile_image_mounter.h
+++ b/include/libimobiledevice/mobile_image_mounter.h
@@ -66,7 +66,7 @@ typedef ssize_t (*mobile_image_mounter_upload_cb_t) (void* buffer, size_t length
* or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the
* device could not be established.
*/
-mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client);
+LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client);
/**
* Starts a new mobile_image_mounter service on the specified device and connects to it.
@@ -81,7 +81,7 @@ mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdown
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an MOBILE_IMAGE_MOUNTER_E_* error
* code otherwise.
*/
-mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t* client, const char* label);
/**
* Disconnects a mobile_image_mounter client from the device and frees up the
@@ -92,7 +92,7 @@ mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
* or MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is NULL.
*/
-mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client);
+LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client);
/**
@@ -108,7 +108,7 @@ mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_clie
*
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an error code on error
*/
-mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result);
+LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result);
/**
* Uploads an image with an optional signature to the device.
@@ -127,7 +127,7 @@ mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_moun
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a
* MOBILE_IMAGE_MOUNTER_E_* error code otherwise.
*/
-mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata);
+LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata);
/**
* Mounts an image on the device.
@@ -150,7 +150,7 @@ mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_moun
* MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are
* invalid, or another error code otherwise.
*/
-mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result);
+LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result);
/**
* Hangs up the connection to the mobile_image_mounter service.
@@ -163,7 +163,7 @@ mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mount
* MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is invalid,
* or another error code otherwise.
*/
-mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client);
+LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/mobileactivation.h b/include/libimobiledevice/mobileactivation.h
index 774c116..8e036a8 100644
--- a/include/libimobiledevice/mobileactivation.h
+++ b/include/libimobiledevice/mobileactivation.h
@@ -59,7 +59,7 @@ typedef mobileactivation_client_private *mobileactivation_client_t; /**< The cli
* MOBILEACTIVATION_E_INVALID_ARG when one of the parameters is invalid,
* or MOBILEACTIVATION_E_MUX_ERROR when the connection failed.
*/
-mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobileactivation_client_t *client);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobileactivation_client_t *client);
/**
* Starts a new mobileactivation service on the specified device and connects to it.
@@ -74,7 +74,7 @@ mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd
* @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
* error code otherwise.
*/
-mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, mobileactivation_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, mobileactivation_client_t* client, const char* label);
/**
* Disconnects a mobileactivation client from the device and frees up the
@@ -87,7 +87,7 @@ mobileactivation_error_t mobileactivation_client_start_service(idevice_t device,
* is invalid, or MOBILEACTIVATION_E_UNKNOWN_ERROR when the was an
* error freeing the parent property_list_service client.
*/
-mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t client);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t client);
/**
@@ -102,7 +102,7 @@ mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t
* @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
* error code otherwise.
*/
-mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_client_t client, plist_t *state);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_client_t client, plist_t *state);
/**
* Retrieves a session blob required for 'drmHandshake' via albert.apple.com.
@@ -116,7 +116,7 @@ mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_
* @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
* error code otherwise.
*/
-mobileactivation_error_t mobileactivation_create_activation_session_info(mobileactivation_client_t client, plist_t *blob);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_session_info(mobileactivation_client_t client, plist_t *blob);
/**
* Retrieves the activation info required for device activation.
@@ -130,7 +130,7 @@ mobileactivation_error_t mobileactivation_create_activation_session_info(mobilea
* @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
* error code otherwise.
*/
-mobileactivation_error_t mobileactivation_create_activation_info(mobileactivation_client_t client, plist_t *info);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_info(mobileactivation_client_t client, plist_t *info);
/**
* Retrieves the activation info required for device activation in 'session'
@@ -148,7 +148,7 @@ mobileactivation_error_t mobileactivation_create_activation_info(mobileactivatio
* @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
* error code otherwise.
*/
-mobileactivation_error_t mobileactivation_create_activation_info_with_session(mobileactivation_client_t client, plist_t handshake_response, plist_t *info);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_info_with_session(mobileactivation_client_t client, plist_t handshake_response, plist_t *info);
/**
* Activates the device with the given activation record.
@@ -161,7 +161,7 @@ mobileactivation_error_t mobileactivation_create_activation_info_with_session(mo
* @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
* error code otherwise.
*/
-mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t client, plist_t activation_record);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t client, plist_t activation_record);
/**
* Activates the device with the given activation record in 'session' mode.
@@ -176,14 +176,14 @@ mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t cli
* @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_*
* error code otherwise.
*/
-mobileactivation_error_t mobileactivation_activate_with_session(mobileactivation_client_t client, plist_t activation_record, plist_t headers);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate_with_session(mobileactivation_client_t client, plist_t activation_record, plist_t headers);
/**
* Deactivates the device.
*
* @param client The mobileactivation client
*/
-mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client);
+LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/mobilebackup.h b/include/libimobiledevice/mobilebackup.h
index d4c042e..2ecb60c 100644
--- a/include/libimobiledevice/mobilebackup.h
+++ b/include/libimobiledevice/mobilebackup.h
@@ -69,7 +69,7 @@ typedef enum {
* or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if
* the mobilebackup version on the device is newer.
*/
-mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client);
/**
* Starts a new mobilebackup service on the specified device and connects to it.
@@ -84,7 +84,7 @@ mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service
* @return MOBILEBACKUP_E_SUCCESS on success, or an MOBILEBACKUP_E_* error
* code otherwise.
*/
-mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t* client, const char* label);
/**
* Disconnects a mobilebackup client from the device and frees up the
@@ -95,7 +95,7 @@ mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobileb
* @return MOBILEBACKUP_E_SUCCESS on success, or MOBILEBACKUP_E_INVALID_ARG
* if client is NULL.
*/
-mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client);
/**
@@ -106,7 +106,7 @@ mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client);
*
* @return an error code
*/
-mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t *plist);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t *plist);
/**
* Sends mobilebackup data to the device
@@ -119,7 +119,7 @@ mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t
*
* @return an error code
*/
-mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist);
/**
* Request a backup from the connected device.
@@ -138,7 +138,7 @@ mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t pli
* backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
* if a communication error occurs, MOBILEBACKUP_E_REPLY_NOT_OK
*/
-mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version);
/**
* Sends a confirmation to the device that a backup file has been received.
@@ -149,7 +149,7 @@ mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, p
* client is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication error
* occurs.
*/
-mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client);
/**
* Request that a backup should be restored to the connected device.
@@ -172,7 +172,7 @@ mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_
* if a communication error occurs, or MOBILEBACKUP_E_REPLY_NOT_OK
* if the device did not accept the request.
*/
-mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version);
/**
* Receive a confirmation from the device that it successfully received
@@ -192,7 +192,7 @@ mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client,
* message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
* occurs.
*/
-mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result);
/**
* Receive a confirmation from the device that it successfully received
@@ -212,7 +212,7 @@ mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_cli
* message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
* occurs.
*/
-mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result);
/**
* Tells the device that the restore process is complete and waits for the
@@ -225,7 +225,7 @@ mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebac
* message plist is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication
* error occurs.
*/
-mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client);
/**
* Sends a backup error message to the device.
@@ -237,7 +237,7 @@ mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t cl
* one of the parameters is invalid, or MOBILEBACKUP_E_MUX_ERROR if a
* communication error occurs.
*/
-mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason);
+LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/mobilebackup2.h b/include/libimobiledevice/mobilebackup2.h
index 1af4141..2e9222d 100644
--- a/include/libimobiledevice/mobilebackup2.h
+++ b/include/libimobiledevice/mobilebackup2.h
@@ -64,7 +64,7 @@ typedef mobilebackup2_client_private *mobilebackup2_client_t; /**< The client ha
* if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION
* if the mobilebackup2 version on the device is newer.
*/
-mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup2_client_t * client);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup2_client_t * client);
/**
* Starts a new mobilebackup2 service on the specified device and connects to it.
@@ -79,7 +79,7 @@ mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_servi
* @return MOBILEBACKUP2_E_SUCCESS on success, or an MOBILEBACKUP2_E_* error
* code otherwise.
*/
-mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t* client, const char* label);
/**
* Disconnects a mobilebackup2 client from the device and frees up the
@@ -90,7 +90,7 @@ mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobil
* @return MOBILEBACKUP2_E_SUCCESS on success, or MOBILEBACKUP2_E_INVALID_ARG
* if client is NULL.
*/
-mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client);
/**
@@ -105,7 +105,7 @@ mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client);
* will be inserted into this plist before sending it. This parameter
* can be NULL if message is not NULL.
*/
-mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options);
/**
* Receives a DL* message plist from the device.
@@ -125,7 +125,7 @@ mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client,
* or is not a DL* message plist, or MOBILEBACKUP2_E_MUX_ERROR if
* receiving from the device failed.
*/
-mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage);
/**
* Send binary data to the device.
@@ -143,7 +143,7 @@ mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t clien
* MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
* or MOBILEBACKUP2_E_MUX_ERROR if sending of the data failed.
*/
-mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes);
/**
* Receive binary from the device.
@@ -163,7 +163,7 @@ mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, cons
* MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
* or MOBILEBACKUP2_E_MUX_ERROR if receiving the data failed.
*/
-mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes);
/**
* Performs the mobilebackup2 protocol version exchange.
@@ -176,7 +176,7 @@ mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, c
* @return MOBILEBACKUP2_E_SUCCESS on success, or a MOBILEBACKUP2_E_* error
* code otherwise.
*/
-mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version);
/**
* Send a request to the connected mobilebackup2 service.
@@ -191,7 +191,7 @@ mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t clie
* @return MOBILEBACKUP2_E_SUCCESS if the request was successfully sent,
* or a MOBILEBACKUP2_E_* error value otherwise.
*/
-mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options);
/**
* Sends a DLMessageStatusResponse to the device.
@@ -205,7 +205,7 @@ mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client,
* @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID_ARG
* if client is invalid, or another MOBILEBACKUP2_E_* otherwise.
*/
-mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2);
+LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/mobilesync.h b/include/libimobiledevice/mobilesync.h
index 6b1af18..c3bc53d 100644
--- a/include/libimobiledevice/mobilesync.h
+++ b/include/libimobiledevice/mobilesync.h
@@ -86,7 +86,7 @@ typedef mobilesync_anchors *mobilesync_anchors_t;
* @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on
* the device is newer.
*/
-mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client);
/**
* Starts a new mobilesync service on the specified device and connects to it.
@@ -101,7 +101,7 @@ mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_des
* @return MOBILESYNC_E_SUCCESS on success, or an MOBILESYNC_E_* error
* code otherwise.
*/
-mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label);
/**
* Disconnects a mobilesync client from the device and frees up the
@@ -112,7 +112,7 @@ mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_
* @retval MOBILESYNC_E_SUCCESS on success
* @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL.
*/
-mobilesync_error_t mobilesync_client_free(mobilesync_client_t client);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_free(mobilesync_client_t client);
/**
@@ -123,7 +123,7 @@ mobilesync_error_t mobilesync_client_free(mobilesync_client_t client);
*
* @return an error code
*/
-mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist);
/**
* Sends mobilesync data to the device
@@ -136,7 +136,7 @@ mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist
*
* @return an error code
*/
-mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist);
/**
@@ -159,7 +159,7 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist);
* @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
* sync request
*/
-mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description);
/**
* Cancels a running synchronization session with a device at any time.
@@ -170,7 +170,7 @@ mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data
* @retval MOBILESYNC_E_SUCCESS on success
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
*/
-mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason);
/**
* Finish a synchronization session of a data class on the device.
@@ -183,7 +183,7 @@ mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* rea
* @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
* form
*/
-mobilesync_error_t mobilesync_finish(mobilesync_client_t client);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_finish(mobilesync_client_t client);
/**
@@ -196,7 +196,7 @@ mobilesync_error_t mobilesync_finish(mobilesync_client_t client);
* @retval MOBILESYNC_E_SUCCESS on success
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
*/
-mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client);
/**
* Requests to receive only changed records of the currently set data class from the device.
@@ -208,7 +208,7 @@ mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t cl
* @retval MOBILESYNC_E_SUCCESS on success
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
*/
-mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client);
/**
* Requests the device to delete all records of the current data class
@@ -221,7 +221,7 @@ mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
* @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
*/
-mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client);
/**
@@ -237,7 +237,7 @@ mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t cl
* @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
* session
*/
-mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions);
/**
* Acknowledges to the device that the changes have been merged on the computer
@@ -247,7 +247,7 @@ mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_
* @retval MOBILESYNC_E_SUCCESS on success
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
*/
-mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client);
/**
@@ -267,7 +267,7 @@ mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_
* @retval MOBILESYNC_E_NOT_READY if the device is not ready to start
* receiving any changes
*/
-mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client);
/**
@@ -284,7 +284,7 @@ mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_cli
* @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
* not permit this call
*/
-mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions);
/**
* Receives any remapped identifiers reported after the device merged submitted changes.
@@ -301,7 +301,7 @@ mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t e
* @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
* session
*/
-mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping);
+LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping);
/* Helper */
@@ -314,14 +314,14 @@ mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plis
*
* @return A new #mobilesync_anchors_t struct. Must be freed using mobilesync_anchors_free().
*/
-mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor);
+LIBIMOBILEDEVICE_API mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor);
/**
* Free memory used by anchors.
*
* @param anchors The anchors to free.
*/
-void mobilesync_anchors_free(mobilesync_anchors_t anchors);
+LIBIMOBILEDEVICE_API void mobilesync_anchors_free(mobilesync_anchors_t anchors);
/**
@@ -329,7 +329,7 @@ void mobilesync_anchors_free(mobilesync_anchors_t anchors);
*
* @return A new plist_t of type PLIST_DICT.
*/
-plist_t mobilesync_actions_new(void);
+LIBIMOBILEDEVICE_API plist_t mobilesync_actions_new(void);
/**
* Add one or more new key:value pairs to the given actions plist.
@@ -343,14 +343,14 @@ plist_t mobilesync_actions_new(void);
* integer to use as a boolean value indicating that the device should
* link submitted changes and report remapped identifiers.
*/
-void mobilesync_actions_add(plist_t actions, ...);
+LIBIMOBILEDEVICE_API void mobilesync_actions_add(plist_t actions, ...);
/**
* Free actions plist.
*
* @param actions The actions plist to free. Does nothing if NULL is passed.
*/
-void mobilesync_actions_free(plist_t actions);
+LIBIMOBILEDEVICE_API void mobilesync_actions_free(plist_t actions);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/notification_proxy.h b/include/libimobiledevice/notification_proxy.h
index 4eccf20..f4f090b 100644
--- a/include/libimobiledevice/notification_proxy.h
+++ b/include/libimobiledevice/notification_proxy.h
@@ -109,7 +109,7 @@ typedef void (*np_notify_cb_t) (const char *notification, void *user_data);
* or NP_E_CONN_FAILED when the connection to the device could not be
* established.
*/
-np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client);
+LIBIMOBILEDEVICE_API np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client);
/**
* Starts a new notification proxy service on the specified device and connects to it.
@@ -124,7 +124,7 @@ np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t servic
* @return NP_E_SUCCESS on success, or an NP_E_* error
* code otherwise.
*/
-np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label);
/**
* Disconnects a notification_proxy client from the device and frees up the
@@ -134,7 +134,7 @@ np_error_t np_client_start_service(idevice_t device, np_client_t* client, const
*
* @return NP_E_SUCCESS on success, or NP_E_INVALID_ARG when client is NULL.
*/
-np_error_t np_client_free(np_client_t client);
+LIBIMOBILEDEVICE_API np_error_t np_client_free(np_client_t client);
/**
@@ -145,7 +145,7 @@ np_error_t np_client_free(np_client_t client);
*
* @return NP_E_SUCCESS on success, or an error returned by np_plist_send
*/
-np_error_t np_post_notification(np_client_t client, const char *notification);
+LIBIMOBILEDEVICE_API np_error_t np_post_notification(np_client_t client, const char *notification);
/**
* Tells the device to send a notification on the specified event.
@@ -156,7 +156,7 @@ np_error_t np_post_notification(np_client_t client, const char *notification);
* @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or
* notification are NULL, or an error returned by np_plist_send.
*/
-np_error_t np_observe_notification(np_client_t client, const char *notification);
+LIBIMOBILEDEVICE_API np_error_t np_observe_notification(np_client_t client, const char *notification);
/**
* Tells the device to send a notification on specified events.
@@ -169,7 +169,7 @@ np_error_t np_observe_notification(np_client_t client, const char *notification)
* @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client is null,
* or an error returned by np_observe_notification.
*/
-np_error_t np_observe_notifications(np_client_t client, const char **notification_spec);
+LIBIMOBILEDEVICE_API np_error_t np_observe_notifications(np_client_t client, const char **notification_spec);
/**
* This function allows an application to define a callback function that will
@@ -193,7 +193,7 @@ np_error_t np_observe_notifications(np_client_t client, const char **notificatio
* NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when
* the callback thread could no be created.
*/
-np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *user_data);
+LIBIMOBILEDEVICE_API np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *user_data);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/preboard.h b/include/libimobiledevice/preboard.h
index 88e9806..0d89eb4 100644
--- a/include/libimobiledevice/preboard.h
+++ b/include/libimobiledevice/preboard.h
@@ -64,7 +64,7 @@ typedef void (*preboard_status_cb_t) (plist_t message, void *user_data);
* @return PREBOARD_E_SUCCESS on success, PREBOARD_E_INVALID_ARG when
* client is NULL, or an PREBOARD_E_* error code otherwise.
*/
-preboard_error_t preboard_client_new(idevice_t device, lockdownd_service_descriptor_t service, preboard_client_t * client);
+LIBIMOBILEDEVICE_API preboard_error_t preboard_client_new(idevice_t device, lockdownd_service_descriptor_t service, preboard_client_t * client);
/**
* Starts a new preboard service on the specified device and connects to it.
@@ -79,7 +79,7 @@ preboard_error_t preboard_client_new(idevice_t device, lockdownd_service_descrip
* @return PREBOARD_E_SUCCESS on success, or a PREBOARD_E_* error
* code otherwise.
*/
-preboard_error_t preboard_client_start_service(idevice_t device, preboard_client_t * client, const char* label);
+LIBIMOBILEDEVICE_API preboard_error_t preboard_client_start_service(idevice_t device, preboard_client_t * client, const char* label);
/**
* Disconnects a preboard client from the device and frees up the
@@ -90,7 +90,7 @@ preboard_error_t preboard_client_start_service(idevice_t device, preboard_client
* @return PREBOARD_E_SUCCESS on success, PREBOARD_E_INVALID_ARG when
* client is NULL, or a PREBOARD_E_* error code otherwise.
*/
-preboard_error_t preboard_client_free(preboard_client_t client);
+LIBIMOBILEDEVICE_API preboard_error_t preboard_client_free(preboard_client_t client);
/**
* Sends a plist to the service.
@@ -102,7 +102,7 @@ preboard_error_t preboard_client_free(preboard_client_t client);
* PREBOARD_E_INVALID_ARG when client or plist is NULL,
* or a PREBOARD_E_* error code on error
*/
-preboard_error_t preboard_send(preboard_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API preboard_error_t preboard_send(preboard_client_t client, plist_t plist);
/**
* Receives a plist from the service.
@@ -115,7 +115,7 @@ preboard_error_t preboard_send(preboard_client_t client, plist_t plist);
* PREBOARD_E_TIMEOUT when no data was received after 5 seconds,
* or a PREBOARD_E_* error code on error
*/
-preboard_error_t preboard_receive(preboard_client_t client, plist_t * plist);
+LIBIMOBILEDEVICE_API preboard_error_t preboard_receive(preboard_client_t client, plist_t * plist);
/**
* Receives a plist from the service with the specified timeout.
@@ -129,7 +129,7 @@ preboard_error_t preboard_receive(preboard_client_t client, plist_t * plist);
* PREBOARD_E_TIMEOUT when no data was received after the given timeout,
* or a PREBOARD_E_* error code on error.
*/
-preboard_error_t preboard_receive_with_timeout(preboard_client_t client, plist_t * plist, uint32_t timeout_ms);
+LIBIMOBILEDEVICE_API preboard_error_t preboard_receive_with_timeout(preboard_client_t client, plist_t * plist, uint32_t timeout_ms);
/**
* Tells the preboard service to create a stashbag. This will make the device
@@ -157,7 +157,7 @@ preboard_error_t preboard_receive_with_timeout(preboard_client_t client, plist_t
* PREBOARD_E_INVALID_ARG when client is invalid,
* or a PREBOARD_E_* error code on error.
*/
-preboard_error_t preboard_create_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API preboard_error_t preboard_create_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data);
/**
* Instructs the preboard service to commit a previously created stashbag.
@@ -178,7 +178,7 @@ preboard_error_t preboard_create_stashbag(preboard_client_t client, plist_t mani
* PREBOARD_E_INVALID_ARG when client is invalid,
* or a PREBOARD_E_* error code on error.
*/
-preboard_error_t preboard_commit_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data);
+LIBIMOBILEDEVICE_API preboard_error_t preboard_commit_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/property_list_service.h b/include/libimobiledevice/property_list_service.h
index 3f6ebad..e6b26a3 100644
--- a/include/libimobiledevice/property_list_service.h
+++ b/include/libimobiledevice/property_list_service.h
@@ -60,7 +60,7 @@ typedef property_list_service_private* property_list_service_client_t; /**< The
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid,
* or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed.
*/
-property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client);
/**
* Frees a PropertyList service.
@@ -71,7 +71,7 @@ property_list_service_error_t property_list_service_client_new(idevice_t device,
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when client is invalid, or a
* PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when another error occurred.
*/
-property_list_service_error_t property_list_service_client_free(property_list_service_client_t client);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_free(property_list_service_client_t client);
/**
* Sends an XML plist.
@@ -84,7 +84,7 @@ property_list_service_error_t property_list_service_client_free(property_list_se
* PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist,
* or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs.
*/
-property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist);
/**
* Sends a binary plist.
@@ -97,7 +97,7 @@ property_list_service_error_t property_list_service_send_xml_plist(property_list
* PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist,
* or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs.
*/
-property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist);
/**
* Receives a plist using the given property list service client with specified
@@ -116,7 +116,7 @@ property_list_service_error_t property_list_service_send_binary_plist(property_l
* communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when
* an unspecified error occurs.
*/
-property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout);
/**
* Receives a plist using the given property list service client.
@@ -139,7 +139,7 @@ property_list_service_error_t property_list_service_receive_plist_with_timeout(p
* communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when
* an unspecified error occurs.
*/
-property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist);
/**
* Enable SSL for the given property list service client.
@@ -152,7 +152,7 @@ property_list_service_error_t property_list_service_receive_plist(property_list_
* PROPERTY_LIST_SERVICE_E_SSL_ERROR when SSL could not be enabled,
* or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise.
*/
-property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client);
/**
* Disable SSL for the given property list service client.
@@ -164,7 +164,7 @@ property_list_service_error_t property_list_service_enable_ssl(property_list_ser
* PROPERTY_LIST_SERVICE_E_INVALID_ARG if one or more of the arguments are invalid,
* or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise.
*/
-property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client);
/**
* Return a handle to the parent #service_client_t of the given property list service client.
@@ -175,7 +175,7 @@ property_list_service_error_t property_list_service_disable_ssl(property_list_se
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
* PROPERTY_LIST_SERVICE_E_INVALID_ARG if one or more of the arguments are invalid.
*/
-property_list_service_error_t property_list_service_get_service_client(property_list_service_client_t client, service_client_t *service_client);
+LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_get_service_client(property_list_service_client_t client, service_client_t *service_client);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/restore.h b/include/libimobiledevice/restore.h
index 0017cfd..859dc98 100644
--- a/include/libimobiledevice/restore.h
+++ b/include/libimobiledevice/restore.h
@@ -56,7 +56,7 @@ typedef restored_client_private *restored_client_t; /**< The client handle. */
*
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL
*/
-restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label);
+LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label);
/**
* Closes the restored client session if one is running and frees up the
@@ -66,7 +66,7 @@ restored_error_t restored_client_new(idevice_t device, restored_client_t *client
*
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL
*/
-restored_error_t restored_client_free(restored_client_t client);
+LIBIMOBILEDEVICE_API restored_error_t restored_client_free(restored_client_t client);
/**
@@ -79,7 +79,7 @@ restored_error_t restored_client_free(restored_client_t client);
*
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL
*/
-restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version);
+LIBIMOBILEDEVICE_API restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version);
/**
* Queries a value from the device specified by a key.
@@ -90,7 +90,7 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint
*
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
*/
-restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value);
+LIBIMOBILEDEVICE_API restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value);
/**
* Retrieves a value from information plist specified by a key.
@@ -101,7 +101,7 @@ restored_error_t restored_query_value(restored_client_t client, const char *key,
*
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
*/
-restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ;
+LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ;
/**
* Sends a plist to restored.
@@ -115,7 +115,7 @@ restored_error_t restored_get_value(restored_client_t client, const char *key, p
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client or
* plist is NULL
*/
-restored_error_t restored_send(restored_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API restored_error_t restored_send(restored_client_t client, plist_t plist);
/**
* Receives a plist from restored.
@@ -126,7 +126,7 @@ restored_error_t restored_send(restored_client_t client, plist_t plist);
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client or
* plist is NULL
*/
-restored_error_t restored_receive(restored_client_t client, plist_t *plist);
+LIBIMOBILEDEVICE_API restored_error_t restored_receive(restored_client_t client, plist_t *plist);
/**
* Sends the Goodbye request to restored signaling the end of communication.
@@ -136,7 +136,7 @@ restored_error_t restored_receive(restored_client_t client, plist_t *plist);
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL,
* RESTORE_E_PLIST_ERROR if the device did not acknowledge the request
*/
-restored_error_t restored_goodbye(restored_client_t client);
+LIBIMOBILEDEVICE_API restored_error_t restored_goodbye(restored_client_t client);
/**
@@ -149,7 +149,7 @@ restored_error_t restored_goodbye(restored_client_t client);
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG if a parameter
* is NULL, RESTORE_E_START_RESTORE_FAILED if the request fails
*/
-restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version);
+LIBIMOBILEDEVICE_API restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version);
/**
* Requests device to reboot.
@@ -159,7 +159,7 @@ restored_error_t restored_start_restore(restored_client_t client, plist_t option
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG if a parameter
* is NULL
*/
-restored_error_t restored_reboot(restored_client_t client);
+LIBIMOBILEDEVICE_API restored_error_t restored_reboot(restored_client_t client);
/* Helper */
@@ -170,7 +170,7 @@ restored_error_t restored_reboot(restored_client_t client);
* @param label The label to set or NULL to disable sending a label
*
*/
-void restored_client_set_label(restored_client_t client, const char *label);
+LIBIMOBILEDEVICE_API void restored_client_set_label(restored_client_t client, const char *label);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/reverse_proxy.h b/include/libimobiledevice/reverse_proxy.h
index b7a93ff..5e2f54b 100644
--- a/include/libimobiledevice/reverse_proxy.h
+++ b/include/libimobiledevice/reverse_proxy.h
@@ -118,7 +118,7 @@ typedef void (*reverse_proxy_status_cb_t) (reverse_proxy_client_t client, revers
* @return REVERSE_PROXY_E_SUCCESS on success,
* or a REVERSE_PROXY_E_* error code otherwise.
*/
-reverse_proxy_error_t reverse_proxy_client_create_with_service(idevice_t device, reverse_proxy_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_service(idevice_t device, reverse_proxy_client_t* client, const char* label);
/**
* Create a reverse proxy client using an open port on the device. This is
@@ -136,14 +136,14 @@ reverse_proxy_error_t reverse_proxy_client_create_with_service(idevice_t device,
* @return REVERSE_PROXY_E_SUCCESS on success,
* or a REVERSE_PROXY_E_* error code otherwise.
*/
-reverse_proxy_error_t reverse_proxy_client_create_with_port(idevice_t device, reverse_proxy_client_t* client, uint16_t device_port);
+LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_port(idevice_t device, reverse_proxy_client_t* client, uint16_t device_port);
/**
* Disconnects a reverse proxy client and frees up the client data.
*
* @param client The reverse proxy client to disconnect and free.
*/
-reverse_proxy_error_t reverse_proxy_client_free(reverse_proxy_client_t client);
+LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_free(reverse_proxy_client_t client);
/**
* Make an initialized reverse proxy client operational, i.e. start the actual proxy.
@@ -155,7 +155,7 @@ reverse_proxy_error_t reverse_proxy_client_free(reverse_proxy_client_t client);
* @return REVERSE_PROXY_E_SUCCESS on success,
* or a REVERSE_PROXY_E_* error code otherwise.
*/
-reverse_proxy_error_t reverse_proxy_client_start_proxy(reverse_proxy_client_t client, int control_protocol_version);
+LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_start_proxy(reverse_proxy_client_t client, int control_protocol_version);
/**
* Set a status callback function. This allows to report the status of the
@@ -168,7 +168,7 @@ reverse_proxy_error_t reverse_proxy_client_start_proxy(reverse_proxy_client_t cl
* when the status of the reverse proxy changes.
* @param user_data A pointer that will be passed to the callback function.
*/
-void reverse_proxy_client_set_status_callback(reverse_proxy_client_t client, reverse_proxy_status_cb_t callback, void* user_data);
+LIBIMOBILEDEVICE_API void reverse_proxy_client_set_status_callback(reverse_proxy_client_t client, reverse_proxy_status_cb_t callback, void* user_data);
/**
* Set a log callback function. Useful for debugging or verbosity.
@@ -180,7 +180,7 @@ void reverse_proxy_client_set_status_callback(reverse_proxy_client_t client, rev
* when the reverse proxy logs something.
* @param user_data A pointer that will be passed to the callback function.
*/
-void reverse_proxy_client_set_log_callback(reverse_proxy_client_t client, reverse_proxy_log_cb_t callback, void* user_data);
+LIBIMOBILEDEVICE_API void reverse_proxy_client_set_log_callback(reverse_proxy_client_t client, reverse_proxy_log_cb_t callback, void* user_data);
/**
* Set a data callback function. Useful for debugging or extra verbosity.
@@ -193,7 +193,7 @@ void reverse_proxy_client_set_log_callback(reverse_proxy_client_t client, revers
* @param user_data A pointer that will be passed to the callback function.
*/
-void reverse_proxy_client_set_data_callback(reverse_proxy_client_t client, reverse_proxy_data_cb_t callback, void* user_data);
+LIBIMOBILEDEVICE_API void reverse_proxy_client_set_data_callback(reverse_proxy_client_t client, reverse_proxy_data_cb_t callback, void* user_data);
/**
* Helper function to return the type of a given reverse proxy client, which
@@ -204,7 +204,7 @@ void reverse_proxy_client_set_data_callback(reverse_proxy_client_t client, rever
*
* @return The type of the rerverse proxy client
*/
-reverse_proxy_client_type_t reverse_proxy_get_type(reverse_proxy_client_t client);
+LIBIMOBILEDEVICE_API reverse_proxy_client_type_t reverse_proxy_get_type(reverse_proxy_client_t client);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/sbservices.h b/include/libimobiledevice/sbservices.h
index 509d5b9..7435947 100644
--- a/include/libimobiledevice/sbservices.h
+++ b/include/libimobiledevice/sbservices.h
@@ -68,7 +68,7 @@ typedef sbservices_client_private *sbservices_client_t; /**< The client handle.
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
* client is NULL, or an SBSERVICES_E_* error code otherwise.
*/
-sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client);
+LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client);
/**
* Starts a new sbservices service on the specified device and connects to it.
@@ -83,7 +83,7 @@ sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_des
* @return SBSERVICES_E_SUCCESS on success, or an SBSERVICES_E_* error
* code otherwise.
*/
-sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t* client, const char* label);
/**
* Disconnects an sbservices client from the device and frees up the
@@ -94,7 +94,7 @@ sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
* client is NULL, or an SBSERVICES_E_* error code otherwise.
*/
-sbservices_error_t sbservices_client_free(sbservices_client_t client);
+LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_free(sbservices_client_t client);
/**
@@ -111,7 +111,7 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client);
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
* client or state is invalid, or an SBSERVICES_E_* error code otherwise.
*/
-sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version);
+LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version);
/**
* Sets the icon state of the connected device.
@@ -122,7 +122,7 @@ sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
* client or newstate is NULL, or an SBSERVICES_E_* error code otherwise.
*/
-sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate);
+LIBIMOBILEDEVICE_API sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate);
/**
* Get the icon of the specified app as PNG data.
@@ -139,7 +139,7 @@ sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t
* client, bundleId, or pngdata are invalid, or an SBSERVICES_E_* error
* code otherwise.
*/
-sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize);
+LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize);
/**
* Gets the interface orientation of the device.
@@ -150,7 +150,7 @@ sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
* client or state is invalid, or an SBSERVICES_E_* error code otherwise.
*/
-sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation);
+LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation);
/**
* Get the home screen wallpaper as PNG data.
@@ -166,7 +166,7 @@ sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t clie
* client or pngdata are invalid, or an SBSERVICES_E_* error
* code otherwise.
*/
-sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize);
+LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/screenshotr.h b/include/libimobiledevice/screenshotr.h
index ecbbdbe..db3c969 100644
--- a/include/libimobiledevice/screenshotr.h
+++ b/include/libimobiledevice/screenshotr.h
@@ -66,7 +66,7 @@ typedef screenshotr_client_private *screenshotr_client_t; /**< The client handle
* or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the
* connection to the device could not be established.
*/
-screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, screenshotr_client_t * client);
+LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, screenshotr_client_t * client);
/**
* Starts a new screenshotr service on the specified device and connects to it.
@@ -81,7 +81,7 @@ screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_d
* @return SCREENSHOTR_E_SUCCESS on success, or an SCREENSHOTR_E_* error
* code otherwise.
*/
-screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t* client, const char* label);
+LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t* client, const char* label);
/**
* Disconnects a screenshotr client from the device and frees up the
@@ -92,7 +92,7 @@ screenshotr_error_t screenshotr_client_start_service(idevice_t device, screensho
* @return SCREENSHOTR_E_SUCCESS on success, or SCREENSHOTR_E_INVALID_ARG
* if client is NULL.
*/
-screenshotr_error_t screenshotr_client_free(screenshotr_client_t client);
+LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_free(screenshotr_client_t client);
/**
@@ -109,7 +109,7 @@ screenshotr_error_t screenshotr_client_free(screenshotr_client_t client);
* one or more parameters are invalid, or another error code if an
* error occurred.
*/
-screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize);
+LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/service.h b/include/libimobiledevice/service.h
index 28b6db6..f31ada4 100644
--- a/include/libimobiledevice/service.h
+++ b/include/libimobiledevice/service.h
@@ -62,7 +62,7 @@ typedef service_client_private* service_client_t; /**< The client handle. */
* SERVICE_E_INVALID_ARG when one of the arguments is invalid,
* or SERVICE_E_MUX_ERROR when connecting to the device failed.
*/
-service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client);
+LIBIMOBILEDEVICE_API service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client);
/**
* Starts a new service on the specified device with given name and
@@ -81,7 +81,7 @@ service_error_t service_client_new(idevice_t device, lockdownd_service_descripto
* @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code
* otherwise.
*/
-service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code);
+LIBIMOBILEDEVICE_API service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code);
/**
* Frees a service instance.
@@ -92,7 +92,7 @@ service_error_t service_client_factory_start_service(idevice_t device, const cha
* SERVICE_E_INVALID_ARG when client is invalid, or a
* SERVICE_E_UNKNOWN_ERROR when another error occurred.
*/
-service_error_t service_client_free(service_client_t client);
+LIBIMOBILEDEVICE_API service_error_t service_client_free(service_client_t client);
/**
@@ -108,7 +108,7 @@ service_error_t service_client_free(service_client_t client);
* invalid, or SERVICE_E_UNKNOWN_ERROR when an unspecified
* error occurs.
*/
-service_error_t service_send(service_client_t client, const char *data, uint32_t size, uint32_t *sent);
+LIBIMOBILEDEVICE_API service_error_t service_send(service_client_t client, const char *data, uint32_t size, uint32_t *sent);
/**
* Receives data using the given service client with specified timeout.
@@ -125,7 +125,7 @@ service_error_t service_send(service_client_t client, const char *data, uint32_t
* occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
* error occurs.
*/
-service_error_t service_receive_with_timeout(service_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
+LIBIMOBILEDEVICE_API service_error_t service_receive_with_timeout(service_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
/**
* Receives data using the given service client.
@@ -143,7 +143,7 @@ service_error_t service_receive_with_timeout(service_client_t client, char *data
* occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
* error occurs.
*/
-service_error_t service_receive(service_client_t client, char *data, uint32_t size, uint32_t *received);
+LIBIMOBILEDEVICE_API service_error_t service_receive(service_client_t client, char *data, uint32_t size, uint32_t *received);
/**
@@ -158,7 +158,7 @@ service_error_t service_receive(service_client_t client, char *data, uint32_t si
* SERVICE_E_SSL_ERROR when SSL could not be enabled,
* or SERVICE_E_UNKNOWN_ERROR otherwise.
*/
-service_error_t service_enable_ssl(service_client_t client);
+LIBIMOBILEDEVICE_API service_error_t service_enable_ssl(service_client_t client);
/**
* Disable SSL for the given service client.
@@ -169,7 +169,7 @@ service_error_t service_enable_ssl(service_client_t client);
* SERVICE_E_INVALID_ARG if client or client->connection is
* NULL, or SERVICE_E_UNKNOWN_ERROR otherwise.
*/
-service_error_t service_disable_ssl(service_client_t client);
+LIBIMOBILEDEVICE_API service_error_t service_disable_ssl(service_client_t client);
/**
* Disable SSL for the given service client, optionally without sending SSL terminate messages.
@@ -182,7 +182,7 @@ service_error_t service_disable_ssl(service_client_t client);
* SERVICE_E_INVALID_ARG if client or client->connection is
* NULL, or SERVICE_E_UNKNOWN_ERROR otherwise.
*/
-service_error_t service_disable_bypass_ssl(service_client_t client, uint8_t sslBypass);
+LIBIMOBILEDEVICE_API service_error_t service_disable_bypass_ssl(service_client_t client, uint8_t sslBypass);
/**
* Return a handle to the parent #idevice_connection_t of the given service client.
@@ -193,7 +193,8 @@ service_error_t service_disable_bypass_ssl(service_client_t client, uint8_t sslB
* @return SERVICE_E_SUCCESS on success,
* SERVICE_E_INVALID_ARG if one or more of the arguments are invalid.
*/
-service_error_t service_get_connection(service_client_t client, idevice_connection_t *connection);
+LIBIMOBILEDEVICE_API service_error_t service_get_connection(service_client_t client, idevice_connection_t *connection);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/libimobiledevice/syslog_relay.h b/include/libimobiledevice/syslog_relay.h
index aae5d11..0f6487a 100644
--- a/include/libimobiledevice/syslog_relay.h
+++ b/include/libimobiledevice/syslog_relay.h
@@ -65,7 +65,7 @@ typedef void (*syslog_relay_receive_cb_t)(char c, void *user_data);
* @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
* client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
*/
-syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client);
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client);
/**
* Starts a new syslog_relay service on the specified device and connects to it.
@@ -80,7 +80,7 @@ syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service
* @return SYSLOG_RELAY_E_SUCCESS on success, or an SYSLOG_RELAY_E_* error
* code otherwise.
*/
-syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label);
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label);
/**
* Disconnects a syslog_relay client from the device and frees up the
@@ -91,7 +91,7 @@ syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_
* @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
* client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
*/
-syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client);
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client);
/**
@@ -108,7 +108,7 @@ syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client);
* invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
* error occurs or a syslog capture has already been started.
*/
-syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data);
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data);
/**
* Starts capturing the *raw* syslog of the device using a callback.
@@ -129,7 +129,7 @@ syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, sy
* invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
* error occurs or a syslog capture has already been started.
*/
-syslog_relay_error_t syslog_relay_start_capture_raw(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data);
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture_raw(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data);
/**
* Stops capturing the syslog of the device.
@@ -143,7 +143,7 @@ syslog_relay_error_t syslog_relay_start_capture_raw(syslog_relay_client_t client
* invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
* error occurs or a syslog capture has already been started.
*/
-syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client);
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client);
/* Receiving */
@@ -162,7 +162,7 @@ syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client);
* occurs, or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
* error occurs.
*/
-syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
/**
* Receives data from the service.
@@ -175,7 +175,7 @@ syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t cli
* @return SYSLOG_RELAY_E_SUCCESS on success,
* SYSLOG_RELAY_E_INVALID_ARG when client or plist is NULL
*/
-syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received);
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received);
#ifdef __cplusplus
}
diff --git a/include/libimobiledevice/webinspector.h b/include/libimobiledevice/webinspector.h
index 064ba91..16d2ca2 100644
--- a/include/libimobiledevice/webinspector.h
+++ b/include/libimobiledevice/webinspector.h
@@ -62,7 +62,7 @@ typedef webinspector_client_private *webinspector_client_t; /**< The client hand
* @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
* client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
*/
-webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client);
+LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client);
/**
* Starts a new webinspector service on the specified device and connects to it.
@@ -77,7 +77,7 @@ webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service
* @return WEBINSPECTOR_E_SUCCESS on success, or an WEBINSPECTOR_E_* error
* code otherwise.
*/
-webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label);
+LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label);
/**
* Disconnects a webinspector client from the device and frees up the
@@ -88,7 +88,7 @@ webinspector_error_t webinspector_client_start_service(idevice_t device, webinsp
* @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
* client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
*/
-webinspector_error_t webinspector_client_free(webinspector_client_t client);
+LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_free(webinspector_client_t client);
/**
@@ -100,7 +100,7 @@ webinspector_error_t webinspector_client_free(webinspector_client_t client);
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
*/
-webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist);
+LIBIMOBILEDEVICE_API webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist);
/**
* Receives a plist from the service.
@@ -111,7 +111,7 @@ webinspector_error_t webinspector_send(webinspector_client_t client, plist_t pli
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
*/
-webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist);
+LIBIMOBILEDEVICE_API webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist);
/**
* Receives a plist using the given webinspector client.
@@ -128,7 +128,7 @@ webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t
* communication error occurs, or WEBINSPECTOR_E_UNKNOWN_ERROR
* when an unspecified error occurs.
*/
-webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms);
+LIBIMOBILEDEVICE_API webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms);
#ifdef __cplusplus
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 1c80ed6..58cf07c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,19 +6,19 @@ AM_CPPFLAGS = \
AM_CFLAGS = \
$(GLOBAL_CFLAGS) \
- $(libusbmuxd_CFLAGS) \
- $(libplist_CFLAGS) \
- $(limd_glue_CFLAGS) \
$(ssl_lib_CFLAGS) \
$(LFS_CFLAGS) \
- $(PTHREAD_CFLAGS)
+ $(PTHREAD_CFLAGS) \
+ $(libusbmuxd_CFLAGS) \
+ $(libplist_CFLAGS) \
+ $(limd_glue_CFLAGS)
AM_LDFLAGS = \
+ $(ssl_lib_LIBS) \
+ $(PTHREAD_LIBS) \
$(libusbmuxd_LIBS) \
$(libplist_LIBS) \
- $(limd_glue_LIBS) \
- $(ssl_lib_LIBS) \
- $(PTHREAD_LIBS)
+ $(limd_glue_LIBS)
lib_LTLIBRARIES = libimobiledevice-1.0.la
libimobiledevice_1_0_la_LIBADD = $(top_builddir)/common/libinternalcommon.la
diff --git a/src/afc.c b/src/afc.c
index d8c3db0..1b4070b 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -29,8 +29,8 @@
#include <unistd.h>
#include <string.h>
-#include "afc.h"
#include "idevice.h"
+#include "afc.h"
#include "common/debug.h"
#include "endianness.h"
@@ -68,7 +68,7 @@ static void afc_unlock(afc_client_t client)
* invalid, or AFC_E_NO_MEM if there is a memory allocation problem.
*/
-LIBIMOBILEDEVICE_API afc_error_t afc_client_new_with_service_client(service_client_t service_client, afc_client_t *client)
+afc_error_t afc_client_new_with_service_client(service_client_t service_client, afc_client_t *client)
{
if (!service_client)
return AFC_E_INVALID_ARG;
@@ -94,7 +94,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_client_new_with_service_client(service_clie
return AFC_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client)
+afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client)
{
if (!device || !service || service->port == 0)
return AFC_E_INVALID_ARG;
@@ -113,14 +113,14 @@ LIBIMOBILEDEVICE_API afc_error_t afc_client_new(idevice_t device, lockdownd_serv
return err;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, const char* label)
+afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, const char* label)
{
afc_error_t err = AFC_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, AFC_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(afc_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_client_free(afc_client_t client)
+afc_error_t afc_client_free(afc_client_t client)
{
if (!client || !client->afc_packet)
return AFC_E_INVALID_ARG;
@@ -414,7 +414,7 @@ static int _afc_check_packet_buffer(afc_client_t client, uint32_t data_len)
#define AFC_PACKET_DATA_PTR ((char*)client->afc_packet + sizeof(AFCPacket))
-LIBIMOBILEDEVICE_API afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***directory_information)
+afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***directory_information)
{
uint32_t bytes = 0;
char *data = NULL, **list_loc = NULL;
@@ -458,7 +458,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_read_directory(afc_client_t client, const c
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_get_device_info(afc_client_t client, char ***device_information)
+afc_error_t afc_get_device_info(afc_client_t client, char ***device_information)
{
uint32_t bytes = 0;
char *data = NULL, **list = NULL;
@@ -495,7 +495,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_get_device_info(afc_client_t client, char *
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value)
+afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value)
{
afc_error_t ret = AFC_E_INTERNAL_ERROR;
char **kvps, **ptr;
@@ -522,7 +522,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_get_device_info_key(afc_client_t client, co
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_remove_path(afc_client_t client, const char *path)
+afc_error_t afc_remove_path(afc_client_t client, const char *path)
{
uint32_t bytes = 0;
afc_error_t ret = AFC_E_UNKNOWN_ERROR;
@@ -558,7 +558,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_remove_path(afc_client_t client, const char
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to)
+afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to)
{
if (!client || !from || !to || !client->afc_packet || !client->parent)
return AFC_E_INVALID_ARG;
@@ -594,7 +594,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_rename_path(afc_client_t client, const char
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_make_directory(afc_client_t client, const char *path)
+afc_error_t afc_make_directory(afc_client_t client, const char *path)
{
uint32_t bytes = 0;
afc_error_t ret = AFC_E_UNKNOWN_ERROR;
@@ -626,7 +626,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_make_directory(afc_client_t client, const c
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***file_information)
+afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***file_information)
{
char *received = NULL;
uint32_t bytes = 0;
@@ -666,7 +666,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_get_file_info(afc_client_t client, const ch
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle)
+afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle)
{
if (!client || !client->parent || !client->afc_packet)
return AFC_E_INVALID_ARG;
@@ -718,7 +718,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_open(afc_client_t client, const char *
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read)
+afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read)
{
char *input = NULL;
uint32_t current_count = 0, bytes_loc = 0;
@@ -774,7 +774,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_read(afc_client_t client, uint64_t han
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written)
+afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written)
{
uint32_t current_count = 0;
uint32_t bytes_loc = 0;
@@ -809,7 +809,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_write(afc_client_t client, uint64_t ha
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
+afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
{
uint32_t bytes = 0;
afc_error_t ret = AFC_E_UNKNOWN_ERROR;
@@ -840,7 +840,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_close(afc_client_t client, uint64_t ha
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation)
+afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation)
{
uint32_t bytes = 0;
struct lockinfo {
@@ -874,7 +874,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_lock(afc_client_t client, uint64_t han
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence)
+afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence)
{
uint32_t bytes = 0;
struct seekinfo {
@@ -908,7 +908,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_seek(afc_client_t client, uint64_t han
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position)
+afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position)
{
char *buffer = NULL;
uint32_t bytes = 0;
@@ -943,7 +943,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_tell(afc_client_t client, uint64_t han
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize)
+afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize)
{
uint32_t bytes = 0;
struct truncinfo {
@@ -975,7 +975,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_truncate(afc_client_t client, uint64_t
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize)
+afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize)
{
if (!client || !path || !client->afc_packet || !client->parent)
return AFC_E_INVALID_ARG;
@@ -1008,7 +1008,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_truncate(afc_client_t client, const char *p
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname)
+afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname)
{
if (!client || !target || !linkname || !client->afc_packet || !client->parent)
return AFC_E_INVALID_ARG;
@@ -1049,7 +1049,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_make_link(afc_client_t client, afc_link_typ
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime)
+afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime)
{
if (!client || !path || !client->afc_packet || !client->parent)
return AFC_E_INVALID_ARG;
@@ -1082,7 +1082,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_set_file_time(afc_client_t client, const ch
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path)
+afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path)
{
uint32_t bytes = 0;
afc_error_t ret = AFC_E_UNKNOWN_ERROR;
@@ -1114,7 +1114,7 @@ LIBIMOBILEDEVICE_API afc_error_t afc_remove_path_and_contents(afc_client_t clien
return ret;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_dictionary_free(char **dictionary)
+afc_error_t afc_dictionary_free(char **dictionary)
{
int i = 0;
@@ -1128,3 +1128,70 @@ LIBIMOBILEDEVICE_API afc_error_t afc_dictionary_free(char **dictionary)
return AFC_E_SUCCESS;
}
+
+const char* afc_strerror(afc_error_t err)
+{
+ switch (err) {
+ case AFC_E_SUCCESS:
+ return "Success";
+ case AFC_E_UNKNOWN_ERROR:
+ return "Unknown Error";
+ case AFC_E_OP_HEADER_INVALID:
+ return "Operation header invalid";
+ case AFC_E_NO_RESOURCES:
+ return "No resources";
+ case AFC_E_READ_ERROR:
+ return "Read error";
+ case AFC_E_WRITE_ERROR:
+ return "Write error";
+ case AFC_E_UNKNOWN_PACKET_TYPE:
+ return "Unknown packet type";
+ case AFC_E_INVALID_ARG:
+ return "Invalid argument";
+ case AFC_E_OBJECT_NOT_FOUND:
+ return "Not found";
+ case AFC_E_OBJECT_IS_DIR:
+ return "Object is a directory";
+ case AFC_E_PERM_DENIED:
+ return "Permission denied";
+ case AFC_E_SERVICE_NOT_CONNECTED:
+ return "Service not connected";
+ case AFC_E_OP_TIMEOUT:
+ return "Timeout";
+ case AFC_E_TOO_MUCH_DATA:
+ return "Too much data";
+ case AFC_E_END_OF_DATA:
+ return "End of data";
+ case AFC_E_OP_NOT_SUPPORTED:
+ return "Operation not supported";
+ case AFC_E_OBJECT_EXISTS:
+ return "Object exists";
+ case AFC_E_OBJECT_BUSY:
+ return "Object busy";
+ case AFC_E_NO_SPACE_LEFT:
+ return "No space left on device";
+ case AFC_E_OP_WOULD_BLOCK:
+ return "Operation would block";
+ case AFC_E_IO_ERROR:
+ return "I/O error";
+ case AFC_E_OP_INTERRUPTED:
+ return "Operation interrupted";
+ case AFC_E_OP_IN_PROGRESS:
+ return "Operation on progress";
+ case AFC_E_INTERNAL_ERROR:
+ return "Internal error";
+ case AFC_E_MUX_ERROR:
+ return "MUX error";
+ case AFC_E_NO_MEM:
+ return "Out of memory";
+ case AFC_E_NOT_ENOUGH_DATA:
+ return "Not enough data";
+ case AFC_E_DIR_NOT_EMPTY:
+ return "Directory not empty";
+ case AFC_E_FORCE_SIGNED_TYPE:
+ return "Force signed type";
+ default:
+ break;
+ }
+ return "Unknown Error";
+}
diff --git a/src/bt_packet_logger.c b/src/bt_packet_logger.c
index 5f7bdeb..937747c 100644
--- a/src/bt_packet_logger.c
+++ b/src/bt_packet_logger.c
@@ -69,7 +69,7 @@ static bt_packet_logger_error_t bt_packet_logger_error(service_error_t err)
return BT_PACKET_LOGGER_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_new(idevice_t device, lockdownd_service_descriptor_t service, bt_packet_logger_client_t * client)
+bt_packet_logger_error_t bt_packet_logger_client_new(idevice_t device, lockdownd_service_descriptor_t service, bt_packet_logger_client_t * client)
{
if (!device || !service || service->port == 0 || !client || *client) {
debug_info("Incorrect parameter passed to bt_packet_logger_client_new.");
@@ -95,14 +95,14 @@ LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_new(idevic
return 0;
}
-LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_start_service(idevice_t device, bt_packet_logger_client_t * client, const char* label)
+bt_packet_logger_error_t bt_packet_logger_client_start_service(idevice_t device, bt_packet_logger_client_t * client, const char* label)
{
bt_packet_logger_error_t err = BT_PACKET_LOGGER_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, BT_PACKETLOGGER_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(bt_packet_logger_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_free(bt_packet_logger_client_t client)
+bt_packet_logger_error_t bt_packet_logger_client_free(bt_packet_logger_client_t client)
{
if (!client)
return BT_PACKET_LOGGER_E_INVALID_ARG;
@@ -113,7 +113,7 @@ LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_free(bt_pa
return err;
}
-LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_receive_with_timeout(bt_packet_logger_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
+bt_packet_logger_error_t bt_packet_logger_receive_with_timeout(bt_packet_logger_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
{
bt_packet_logger_error_t res = BT_PACKET_LOGGER_E_UNKNOWN_ERROR;
int bytes = 0;
@@ -186,7 +186,7 @@ void *bt_packet_logger_worker(void *arg)
return NULL;
}
-LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_start_capture(bt_packet_logger_client_t client, bt_packet_logger_receive_cb_t callback, void* user_data)
+bt_packet_logger_error_t bt_packet_logger_start_capture(bt_packet_logger_client_t client, bt_packet_logger_receive_cb_t callback, void* user_data)
{
if (!client || !callback)
return BT_PACKET_LOGGER_E_INVALID_ARG;
@@ -214,7 +214,7 @@ LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_start_capture(bt_
}
-LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t client)
+bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t client)
{
if (client->worker) {
/* notify thread to finish */
diff --git a/src/bt_packet_logger.h b/src/bt_packet_logger.h
index 95990d5..620555e 100644
--- a/src/bt_packet_logger.h
+++ b/src/bt_packet_logger.h
@@ -22,6 +22,7 @@
#ifndef _BR_PACKET_LOGGER_H
#define _BR_PACKET_LOGGER_H
+#include "idevice.h"
#include "libimobiledevice/bt_packet_logger.h"
#include "service.h"
#include <libimobiledevice-glue/thread.h>
diff --git a/src/companion_proxy.c b/src/companion_proxy.c
index 5852904..421fa9a 100644
--- a/src/companion_proxy.c
+++ b/src/companion_proxy.c
@@ -62,7 +62,7 @@ static companion_proxy_error_t companion_proxy_error(property_list_service_error
return COMPANION_PROXY_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, companion_proxy_client_t * client)
+companion_proxy_error_t companion_proxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, companion_proxy_client_t * client)
{
*client = NULL;
@@ -90,14 +90,14 @@ LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_new(idevice_
return COMPANION_PROXY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_start_service(idevice_t device, companion_proxy_client_t * client, const char* label)
+companion_proxy_error_t companion_proxy_client_start_service(idevice_t device, companion_proxy_client_t * client, const char* label)
{
companion_proxy_error_t err = COMPANION_PROXY_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, COMPANION_PROXY_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(companion_proxy_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_free(companion_proxy_client_t client)
+companion_proxy_error_t companion_proxy_client_free(companion_proxy_client_t client)
{
if (!client)
return COMPANION_PROXY_E_INVALID_ARG;
@@ -116,7 +116,7 @@ LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_free(compani
return err;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_send(companion_proxy_client_t client, plist_t plist)
+companion_proxy_error_t companion_proxy_send(companion_proxy_client_t client, plist_t plist)
{
companion_proxy_error_t res = COMPANION_PROXY_E_UNKNOWN_ERROR;
@@ -129,7 +129,7 @@ LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_send(companion_prox
return res;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_receive(companion_proxy_client_t client, plist_t * plist)
+companion_proxy_error_t companion_proxy_receive(companion_proxy_client_t client, plist_t * plist)
{
companion_proxy_error_t res = COMPANION_PROXY_E_UNKNOWN_ERROR;
plist_t outplist = NULL;
@@ -143,7 +143,7 @@ LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_receive(companion_p
return res;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_device_registry(companion_proxy_client_t client, plist_t* paired_devices)
+companion_proxy_error_t companion_proxy_get_device_registry(companion_proxy_client_t client, plist_t* paired_devices)
{
if (!client || !paired_devices) {
return COMPANION_PROXY_E_INVALID_ARG;
@@ -226,7 +226,7 @@ static void* companion_proxy_event_thread(void* arg)
return NULL;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_listening_for_devices(companion_proxy_client_t client, companion_proxy_device_event_cb_t callback, void* userdata)
+companion_proxy_error_t companion_proxy_start_listening_for_devices(companion_proxy_client_t client, companion_proxy_device_event_cb_t callback, void* userdata)
{
if (!client || !client->parent || !callback) {
return COMPANION_PROXY_E_INVALID_ARG;
@@ -252,7 +252,7 @@ LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_listening_for
return res;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_listening_for_devices(companion_proxy_client_t client)
+companion_proxy_error_t companion_proxy_stop_listening_for_devices(companion_proxy_client_t client)
{
property_list_service_client_t parent = client->parent;
client->parent = NULL;
@@ -266,7 +266,7 @@ LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_listening_for_
return COMPANION_PROXY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_value_from_registry(companion_proxy_client_t client, const char* companion_udid, const char* key, plist_t* value)
+companion_proxy_error_t companion_proxy_get_value_from_registry(companion_proxy_client_t client, const char* companion_udid, const char* key, plist_t* value)
{
if (!client || !companion_udid || !key || !value) {
return COMPANION_PROXY_E_INVALID_ARG;
@@ -310,7 +310,7 @@ LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_value_from_regi
return res;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options)
+companion_proxy_error_t companion_proxy_start_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options)
{
if (!client) {
return COMPANION_PROXY_E_INVALID_ARG;
@@ -353,7 +353,7 @@ LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_forwarding_se
return res;
}
-LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port)
+companion_proxy_error_t companion_proxy_stop_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port)
{
if (!client) {
return COMPANION_PROXY_E_INVALID_ARG;
diff --git a/src/companion_proxy.h b/src/companion_proxy.h
index 0226640..e36932a 100644
--- a/src/companion_proxy.h
+++ b/src/companion_proxy.h
@@ -22,6 +22,7 @@
#ifndef __COMPANION_PROXY_H
#define __COMPANION_PROXY_H
+#include "idevice.h"
#include "libimobiledevice/companion_proxy.h"
#include "property_list_service.h"
#include <libimobiledevice-glue/thread.h>
diff --git a/src/debugserver.c b/src/debugserver.c
index 39c1bdc..74ade8a 100644
--- a/src/debugserver.c
+++ b/src/debugserver.c
@@ -64,7 +64,7 @@ static debugserver_error_t debugserver_error(service_error_t err)
return DEBUGSERVER_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_descriptor_t service, debugserver_client_t* client)
+debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_descriptor_t service, debugserver_client_t* client)
{
*client = NULL;
@@ -98,7 +98,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_new(idevice_t device
return DEBUGSERVER_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_start_service(idevice_t device, debugserver_client_t * client, const char* label)
+debugserver_error_t debugserver_client_start_service(idevice_t device, debugserver_client_t * client, const char* label)
{
debugserver_error_t err = DEBUGSERVER_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, DEBUGSERVER_SECURE_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(debugserver_client_new), &err);
@@ -109,7 +109,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_start_service(idevic
return err;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_free(debugserver_client_t client)
+debugserver_error_t debugserver_client_free(debugserver_client_t client)
{
if (!client)
return DEBUGSERVER_E_INVALID_ARG;
@@ -121,7 +121,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_free(debugserver_cli
return err;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_send(debugserver_client_t client, const char* data, uint32_t size, uint32_t *sent)
+debugserver_error_t debugserver_client_send(debugserver_client_t client, const char* data, uint32_t size, uint32_t *sent)
{
debugserver_error_t res = DEBUGSERVER_E_UNKNOWN_ERROR;
int bytes = 0;
@@ -142,7 +142,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_send(debugserver_cli
return res;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
+debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
{
debugserver_error_t res = DEBUGSERVER_E_UNKNOWN_ERROR;
int bytes = 0;
@@ -162,7 +162,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive_with_timeout
return (bytes > 0) ? DEBUGSERVER_E_SUCCESS : res;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive(debugserver_client_t client, char* data, uint32_t size, uint32_t *received)
+debugserver_error_t debugserver_client_receive(debugserver_client_t client, char* data, uint32_t size, uint32_t *received)
{
debugserver_error_t res = DEBUGSERVER_E_UNKNOWN_ERROR;
do {
@@ -172,7 +172,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive(debugserver_
return res;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_command_new(const char* name, int argc, char* argv[], debugserver_command_t* command)
+debugserver_error_t debugserver_command_new(const char* name, int argc, char* argv[], debugserver_command_t* command)
{
int i;
debugserver_command_t tmp = (debugserver_command_t) malloc(sizeof(struct debugserver_command_private));
@@ -197,7 +197,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_command_new(const char* nam
return DEBUGSERVER_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_command_free(debugserver_command_t command)
+debugserver_error_t debugserver_command_free(debugserver_command_t command)
{
int i;
debugserver_error_t res = DEBUGSERVER_E_UNKNOWN_ERROR;
@@ -275,7 +275,7 @@ static int debugserver_response_is_checksum_valid(const char* response, uint32_t
return 1;
}
-LIBIMOBILEDEVICE_API void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32_t* encoded_length)
+void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32_t* encoded_length)
{
uint32_t position;
uint32_t index;
@@ -291,7 +291,7 @@ LIBIMOBILEDEVICE_API void debugserver_encode_string(const char* buffer, char** e
}
}
-LIBIMOBILEDEVICE_API void debugserver_decode_string(const char *encoded_buffer, size_t encoded_length, char** buffer)
+void debugserver_decode_string(const char *encoded_buffer, size_t encoded_length, char** buffer)
{
*buffer = malloc(sizeof(char) * ((encoded_length / 2)+1));
char* t = *buffer;
@@ -350,7 +350,7 @@ static debugserver_error_t debugserver_client_send_noack(debugserver_client_t cl
return debugserver_client_send(client, "-", sizeof(char), NULL);
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client, int enabled)
+debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client, int enabled)
{
if (!client)
return DEBUGSERVER_E_INVALID_ARG;
@@ -362,7 +362,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_ack_mode(debugse
return DEBUGSERVER_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_receive_params(debugserver_client_t client, int (*cancel_receive)(), int receive_loop_timeout)
+debugserver_error_t debugserver_client_set_receive_params(debugserver_client_t client, int (*cancel_receive)(), int receive_loop_timeout)
{
if (!client)
return DEBUGSERVER_E_INVALID_ARG;
@@ -392,7 +392,7 @@ static debugserver_error_t debugserver_client_receive_internal_char(debugserver_
return res;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response, size_t* response_size)
+debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response, size_t* response_size)
{
debugserver_error_t res = DEBUGSERVER_E_SUCCESS;
@@ -503,7 +503,7 @@ cleanup:
return res;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response, size_t* response_size)
+debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response, size_t* response_size)
{
debugserver_error_t res = DEBUGSERVER_E_SUCCESS;
int i;
@@ -559,7 +559,7 @@ cleanup:
return res;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_client_t client, const char* env, char** response)
+debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_client_t client, const char* env, char** response)
{
if (!client || !env)
return DEBUGSERVER_E_INVALID_ARG;
@@ -578,7 +578,7 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_environment_hex_
return result;
}
-LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int argc, char* argv[], char** response)
+debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int argc, char* argv[], char** response)
{
if (!client || !argc)
return DEBUGSERVER_E_INVALID_ARG;
diff --git a/src/debugserver.h b/src/debugserver.h
index ee3ba62..ce9c255 100644
--- a/src/debugserver.h
+++ b/src/debugserver.h
@@ -22,6 +22,7 @@
#ifndef _DEBUGSERVER_H
#define _DEBUGSERVER_H
+#include "idevice.h"
#include "libimobiledevice/debugserver.h"
#include "service.h"
diff --git a/src/device_link_service.h b/src/device_link_service.h
index eae912a..0255b21 100644
--- a/src/device_link_service.h
+++ b/src/device_link_service.h
@@ -22,6 +22,7 @@
#ifndef __DEVICE_LINK_SERVICE_H
#define __DEVICE_LINK_SERVICE_H
+#include "idevice.h"
#include "property_list_service.h"
/* Error Codes */
diff --git a/src/diagnostics_relay.c b/src/diagnostics_relay.c
index 5444fcc..6ee3150 100644
--- a/src/diagnostics_relay.c
+++ b/src/diagnostics_relay.c
@@ -73,7 +73,7 @@ static int diagnostics_relay_check_result(plist_t dict)
return ret;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client)
+diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client)
{
if (!device || !service || service->port == 0 || !client || *client) {
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
@@ -93,14 +93,14 @@ LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_new(idev
return DIAGNOSTICS_RELAY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t * client, const char* label)
+diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t * client, const char* label)
{
diagnostics_relay_error_t err = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, DIAGNOSTICS_RELAY_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(diagnostics_relay_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client)
+diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client)
{
if (!client)
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
@@ -167,7 +167,7 @@ static diagnostics_relay_error_t diagnostics_relay_send(diagnostics_relay_client
return ret;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client)
+diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client)
{
if (!client)
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
@@ -201,7 +201,7 @@ LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_goodbye(diagnos
return ret;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client)
+diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client)
{
if (!client)
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
@@ -277,17 +277,17 @@ static diagnostics_relay_error_t internal_diagnostics_relay_action(diagnostics_r
return ret;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, diagnostics_relay_action_t flags)
+diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, diagnostics_relay_action_t flags)
{
return internal_diagnostics_relay_action(client, "Restart", flags);
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, diagnostics_relay_action_t flags)
+diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, diagnostics_relay_action_t flags)
{
return internal_diagnostics_relay_action(client, "Shutdown", flags);
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics)
+diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics)
{
if (!client || diagnostics == NULL)
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
@@ -331,7 +331,7 @@ LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_request_diagnos
return ret;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result)
+diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result)
{
if (!client || plist_get_node_type(keys) != PLIST_ARRAY || result == NULL)
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
@@ -376,7 +376,7 @@ LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_mobileges
return ret;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* entry_name, const char* entry_class, plist_t* result)
+diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* entry_name, const char* entry_class, plist_t* result)
{
if (!client || (entry_name == NULL && entry_class == NULL) || result == NULL)
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
@@ -424,7 +424,7 @@ LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistr
return ret;
}
-LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result)
+diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result)
{
if (!client || plane == NULL || result == NULL)
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
diff --git a/src/diagnostics_relay.h b/src/diagnostics_relay.h
index 6d11ea1..3bb543a 100644
--- a/src/diagnostics_relay.h
+++ b/src/diagnostics_relay.h
@@ -22,6 +22,7 @@
#ifndef __DIAGNOSTICS_RELAY_H
#define __DIAGNOSTICS_RELAY_H
+#include "idevice.h"
#include "libimobiledevice/diagnostics_relay.h"
#include "property_list_service.h"
diff --git a/src/file_relay.c b/src/file_relay.c
index aa77ae6..fbe7cbf 100644
--- a/src/file_relay.c
+++ b/src/file_relay.c
@@ -28,7 +28,7 @@
#include "property_list_service.h"
#include "common/debug.h"
-LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client)
+file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client)
{
if (!device || !service || service->port == 0 || !client || *client) {
return FILE_RELAY_E_INVALID_ARG;
@@ -48,14 +48,14 @@ LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_new(idevice_t device,
return FILE_RELAY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t * client, const char* label)
+file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t * client, const char* label)
{
file_relay_error_t err = FILE_RELAY_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, FILE_RELAY_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(file_relay_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_free(file_relay_client_t client)
+file_relay_error_t file_relay_client_free(file_relay_client_t client)
{
if (!client)
return FILE_RELAY_E_INVALID_ARG;
@@ -67,7 +67,7 @@ LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_free(file_relay_client
return FILE_RELAY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout)
+file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout)
{
if (!client || !client->parent || !sources || !sources[0]) {
return FILE_RELAY_E_INVALID_ARG;
@@ -159,7 +159,7 @@ leave:
return err;
}
-LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection)
+file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection)
{
return file_relay_request_sources_timeout(client, sources, connection, 60000);
}
diff --git a/src/file_relay.h b/src/file_relay.h
index 626fab8..65bf460 100644
--- a/src/file_relay.h
+++ b/src/file_relay.h
@@ -22,6 +22,7 @@
#ifndef __FILE_RELAY_H
#define __FILE_RELAY_H
+#include "idevice.h"
#include "libimobiledevice/file_relay.h"
#include "property_list_service.h"
diff --git a/src/heartbeat.c b/src/heartbeat.c
index 9a527cc..3945d73 100644
--- a/src/heartbeat.c
+++ b/src/heartbeat.c
@@ -62,7 +62,7 @@ static heartbeat_error_t heartbeat_error(property_list_service_error_t err)
return HEARTBEAT_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client)
+heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client)
{
*client = NULL;
@@ -89,14 +89,14 @@ LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_new(idevice_t device, lo
return 0;
}
-LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label)
+heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label)
{
heartbeat_error_t err = HEARTBEAT_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, HEARTBEAT_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(heartbeat_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_free(heartbeat_client_t client)
+heartbeat_error_t heartbeat_client_free(heartbeat_client_t client)
{
if (!client)
return HEARTBEAT_E_INVALID_ARG;
@@ -107,7 +107,7 @@ LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_free(heartbeat_client_t
return err;
}
-LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist)
+heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist)
{
heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR;
@@ -122,12 +122,12 @@ LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_send(heartbeat_client_t client,
return res;
}
-LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist)
+heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist)
{
return heartbeat_receive_with_timeout(client, plist, 1000);
}
-LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms)
+heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms)
{
heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR;
plist_t outplist = NULL;
diff --git a/src/heartbeat.h b/src/heartbeat.h
index f648681..379ecc1 100644
--- a/src/heartbeat.h
+++ b/src/heartbeat.h
@@ -22,6 +22,7 @@
#ifndef __HEARTBEAT_H
#define __HEARTBEAT_H
+#include "idevice.h"
#include "libimobiledevice/heartbeat.h"
#include "property_list_service.h"
diff --git a/src/house_arrest.c b/src/house_arrest.c
index ac92130..caad731 100644
--- a/src/house_arrest.c
+++ b/src/house_arrest.c
@@ -58,7 +58,7 @@ static house_arrest_error_t house_arrest_error(property_list_service_error_t err
return HOUSE_ARREST_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client)
+house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client)
{
property_list_service_client_t plistclient = NULL;
house_arrest_error_t err = house_arrest_error(property_list_service_client_new(device, service, &plistclient));
@@ -74,14 +74,14 @@ LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_new(idevice_t devi
return HOUSE_ARREST_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t * client, const char* label)
+house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t * client, const char* label)
{
house_arrest_error_t err = HOUSE_ARREST_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, HOUSE_ARREST_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(house_arrest_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_free(house_arrest_client_t client)
+house_arrest_error_t house_arrest_client_free(house_arrest_client_t client)
{
if (!client)
return HOUSE_ARREST_E_INVALID_ARG;
@@ -96,7 +96,7 @@ LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_free(house_arrest_
return err;
}
-LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict)
+house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict)
{
if (!client || !client->parent || !dict)
return HOUSE_ARREST_E_INVALID_ARG;
@@ -112,7 +112,7 @@ LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_request(house_arrest
return res;
}
-LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid)
+house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid)
{
if (!client || !client->parent || !command || !appid)
return HOUSE_ARREST_E_INVALID_ARG;
@@ -132,7 +132,7 @@ LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_command(house_arrest
return res;
}
-LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict)
+house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict)
{
if (!client || !client->parent)
return HOUSE_ARREST_E_INVALID_ARG;
@@ -150,7 +150,7 @@ LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_get_result(house_arrest_c
return res;
}
-LIBIMOBILEDEVICE_API afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client)
+afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client)
{
if (!client || !client->parent || (client->mode == HOUSE_ARREST_CLIENT_MODE_AFC)) {
return AFC_E_INVALID_ARG;
diff --git a/src/house_arrest.h b/src/house_arrest.h
index 387594f..5612a29 100644
--- a/src/house_arrest.h
+++ b/src/house_arrest.h
@@ -22,6 +22,7 @@
#ifndef __HOUSE_ARREST_H
#define __HOUSE_ARREST_H
+#include "idevice.h"
#include "libimobiledevice/house_arrest.h"
#include "property_list_service.h"
diff --git a/src/idevice.c b/src/idevice.c
index 3984583..b9bbb1f 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -32,7 +32,11 @@
#ifdef WIN32
#include <winsock2.h>
+#include <ws2tcpip.h>
#include <windows.h>
+#else
+#include <sys/socket.h>
+#include <netinet/in.h>
#endif
#include <usbmuxd.h>
@@ -215,6 +219,14 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved)
#warning No compiler support for constructor/destructor attributes, some features might not be available.
#endif
+const char* libimobiledevice_version()
+{
+#ifndef PACKAGE_VERSION
+#error PACKAGE_VERSION is not defined!
+#endif
+ return PACKAGE_VERSION;
+}
+
struct idevice_subscription_context {
idevice_event_cb_t callback;
void *user_data;
@@ -244,7 +256,7 @@ static void usbmux_event_cb(const usbmuxd_event_t *event, void *user_data)
}
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_events_subscribe(idevice_subscription_context_t *context, idevice_event_cb_t callback, void *user_data)
+idevice_error_t idevice_events_subscribe(idevice_subscription_context_t *context, idevice_event_cb_t callback, void *user_data)
{
if (!context || !callback) {
return IDEVICE_E_INVALID_ARG;
@@ -266,7 +278,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_events_subscribe(idevice_subscripti
return IDEVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_events_unsubscribe(idevice_subscription_context_t context)
+idevice_error_t idevice_events_unsubscribe(idevice_subscription_context_t context)
{
if (!context) {
return IDEVICE_E_INVALID_ARG;
@@ -283,7 +295,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_events_unsubscribe(idevice_subscrip
return IDEVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data)
+idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data)
{
if (event_ctx) {
idevice_events_unsubscribe(event_ctx);
@@ -291,7 +303,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_event_subscribe(idevice_event_cb_t
return idevice_events_subscribe(&event_ctx, callback, user_data);
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_event_unsubscribe(void)
+idevice_error_t idevice_event_unsubscribe(void)
{
if (!event_ctx) {
return IDEVICE_E_SUCCESS;
@@ -300,7 +312,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_event_unsubscribe(void)
return idevice_events_unsubscribe(event_ctx);
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *count)
+idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *count)
{
usbmuxd_device_info_t *dev_list;
@@ -324,7 +336,21 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list_extended(idevice_in
newlist[newcount]->conn_data = NULL;
} else if (dev_list[i].conn_type == CONNECTION_TYPE_NETWORK) {
newlist[newcount]->conn_type = CONNECTION_NETWORK;
- size_t addrlen = ((uint8_t*)dev_list[i].conn_data)[0];
+ struct sockaddr* saddr = (struct sockaddr*)(dev_list[i].conn_data);
+ size_t addrlen = 0;
+ switch (saddr->sa_family) {
+ case AF_INET:
+ addrlen = sizeof(struct sockaddr_in);
+ break;
+#ifdef AF_INET6
+ case AF_INET6:
+ addrlen = sizeof(struct sockaddr_in6);
+ break;
+#endif
+ default:
+ debug_info("Unsupported address family 0x%02x\n", saddr->sa_family);
+ continue;
+ }
newlist[newcount]->conn_data = malloc(addrlen);
memcpy(newlist[newcount]->conn_data, dev_list[i].conn_data, addrlen);
}
@@ -341,7 +367,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list_extended(idevice_in
return IDEVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_extended_free(idevice_info_t *devices)
+idevice_error_t idevice_device_list_extended_free(idevice_info_t *devices)
{
if (devices) {
int i = 0;
@@ -356,7 +382,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_extended_free(idevice_i
return IDEVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list(char ***devices, int *count)
+idevice_error_t idevice_get_device_list(char ***devices, int *count)
{
usbmuxd_device_info_t *dev_list;
@@ -388,7 +414,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list(char ***devices, in
return IDEVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_free(char **devices)
+idevice_error_t idevice_device_list_free(char **devices)
{
if (devices) {
int i = 0;
@@ -401,7 +427,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_free(char **devices)
return IDEVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API void idevice_set_debug_level(int level)
+void idevice_set_debug_level(int level)
{
internal_set_debug_level(level);
}
@@ -426,9 +452,25 @@ static idevice_t idevice_from_mux_device(usbmuxd_device_info_t *muxdev)
break;
case CONNECTION_TYPE_NETWORK:
device->conn_type = CONNECTION_NETWORK;
- size_t len = ((uint8_t*)muxdev->conn_data)[0];
- device->conn_data = malloc(len);
- memcpy(device->conn_data, muxdev->conn_data, len);
+ struct sockaddr* saddr = (struct sockaddr*)(muxdev->conn_data);
+ size_t addrlen = 0;
+ switch (saddr->sa_family) {
+ case AF_INET:
+ addrlen = sizeof(struct sockaddr_in);
+ break;
+#ifdef AF_INET6
+ case AF_INET6:
+ addrlen = sizeof(struct sockaddr_in6);
+ break;
+#endif
+ default:
+ debug_info("Unsupported address family 0x%02x\n", saddr->sa_family);
+ free(device->udid);
+ free(device);
+ return NULL;
+ }
+ device->conn_data = malloc(addrlen);
+ memcpy(device->conn_data, muxdev->conn_data, addrlen);
break;
default:
device->conn_type = 0;
@@ -438,7 +480,7 @@ static idevice_t idevice_from_mux_device(usbmuxd_device_info_t *muxdev)
return device;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_new_with_options(idevice_t * device, const char *udid, enum idevice_options options)
+idevice_error_t idevice_new_with_options(idevice_t * device, const char *udid, enum idevice_options options)
{
usbmuxd_device_info_t muxdev;
int usbmux_options = 0;
@@ -462,12 +504,12 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_new_with_options(idevice_t * device
return IDEVICE_E_NO_DEVICE;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t * device, const char *udid)
+idevice_error_t idevice_new(idevice_t * device, const char *udid)
{
return idevice_new_with_options(device, udid, 0);
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_free(idevice_t device)
+idevice_error_t idevice_free(idevice_t device)
{
if (!device)
return IDEVICE_E_INVALID_ARG;
@@ -484,7 +526,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_free(idevice_t device)
return ret;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection)
+idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection)
{
if (!device) {
return IDEVICE_E_INVALID_ARG;
@@ -515,27 +557,16 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t
return IDEVICE_E_SUCCESS;
}
if (device->conn_type == CONNECTION_NETWORK) {
- struct sockaddr_storage saddr_storage;
- struct sockaddr* saddr = (struct sockaddr*)&saddr_storage;
-
- /* FIXME: Improve handling of this platform/host dependent connection data */
- if (((char*)device->conn_data)[1] == 0x02) { // AF_INET
- saddr->sa_family = AF_INET;
- memcpy(&saddr->sa_data[0], (char*)device->conn_data + 2, 14);
- }
- else if (((char*)device->conn_data)[1] == 0x1E) { // AF_INET6 (bsd)
+ struct sockaddr* saddr = (struct sockaddr*)(device->conn_data);
+ switch (saddr->sa_family) {
+ case AF_INET:
#ifdef AF_INET6
- saddr->sa_family = AF_INET6;
- /* copy the address and the host dependent scope id */
- memcpy(&saddr->sa_data[0], (char*)device->conn_data + 2, 26);
-#else
- debug_info("ERROR: Got an IPv6 address but this system doesn't support IPv6");
- return IDEVICE_E_UNKNOWN_ERROR;
+ case AF_INET6:
#endif
- }
- else {
- debug_info("Unsupported address family 0x%02x", ((char*)device->conn_data)[1]);
- return IDEVICE_E_UNKNOWN_ERROR;
+ break;
+ default:
+ debug_info("Unsupported address family 0x%02x", saddr->sa_family);
+ return IDEVICE_E_UNKNOWN_ERROR;
}
char addrtxt[48];
@@ -576,7 +607,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t
return IDEVICE_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_disconnect(idevice_connection_t connection)
+idevice_error_t idevice_disconnect(idevice_connection_t connection)
{
if (!connection) {
return IDEVICE_E_INVALID_ARG;
@@ -639,7 +670,7 @@ static idevice_error_t internal_connection_send(idevice_connection_t connection,
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes)
+idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes)
{
if (!connection || !data
#if defined(HAVE_OPENSSL) || defined(HAVE_GNUTLS)
@@ -754,7 +785,7 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t
return IDEVICE_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout)
+idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout)
{
if (!connection
#if defined(HAVE_OPENSSL) || defined(HAVE_GNUTLS)
@@ -785,6 +816,10 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive_timeout(idevice_
int sslerr = SSL_get_error(connection->ssl_data->session, r);
if (sslerr == SSL_ERROR_WANT_READ) {
continue;
+ } else if (sslerr == SSL_ERROR_ZERO_RETURN) {
+ if (connection->status == IDEVICE_E_TIMEOUT) {
+ SSL_set_shutdown(connection->ssl_data->session, 0);
+ }
}
break;
}
@@ -849,7 +884,7 @@ static idevice_error_t internal_connection_receive(idevice_connection_t connecti
return IDEVICE_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes)
+idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes)
{
if (!connection
#if defined(HAVE_OPENSSL) || defined(HAVE_GNUTLS)
@@ -882,7 +917,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive(idevice_connecti
return internal_connection_receive(connection, data, len, recv_bytes);
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd)
+idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd)
{
if (!connection || !fd) {
return IDEVICE_E_INVALID_ARG;
@@ -901,7 +936,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connectio
return IDEVICE_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
+idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
{
if (!device || !handle)
return IDEVICE_E_INVALID_ARG;
@@ -910,7 +945,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32
return IDEVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_get_udid(idevice_t device, char **udid)
+idevice_error_t idevice_get_udid(idevice_t device, char **udid)
{
if (!device || !udid)
return IDEVICE_E_INVALID_ARG;
@@ -1030,18 +1065,33 @@ static void internal_ssl_cleanup(ssl_data_t ssl_data)
}
#ifdef HAVE_OPENSSL
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+static long ssl_idevice_bio_callback(BIO *b, int oper, const char *argp, size_t len, int argi, long argl, int retvalue, size_t *processed)
+#else
static long ssl_idevice_bio_callback(BIO *b, int oper, const char *argp, int argi, long argl, long retvalue)
+#endif
{
+ ssize_t bytes = 0;
idevice_connection_t conn = (idevice_connection_t)BIO_get_callback_arg(b);
+#if OPENSSL_VERSION_NUMBER < 0x30000000L
size_t len = (size_t)argi;
+ size_t *processed = (size_t*)&bytes;
+#endif
switch (oper) {
case (BIO_CB_READ|BIO_CB_RETURN):
- return argp ? (long)internal_ssl_read(conn, (char *)argp, len) : 0;
+ if (argp) {
+ bytes = internal_ssl_read(conn, (char *)argp, len);
+ *processed = bytes;
+ return (long)bytes;
+ }
+ return 0;
case (BIO_CB_PUTS|BIO_CB_RETURN):
len = strlen(argp);
// fallthrough
case (BIO_CB_WRITE|BIO_CB_RETURN):
- return (long)internal_ssl_write(conn, argp, len);
+ bytes = internal_ssl_write(conn, argp, len);
+ *processed = bytes;
+ return (long)bytes;
default:
return retvalue;
}
@@ -1052,7 +1102,11 @@ static BIO *ssl_idevice_bio_new(idevice_connection_t conn)
BIO *b = BIO_new(BIO_s_null());
if (!b) return NULL;
BIO_set_callback_arg(b, (char *)conn);
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ BIO_set_callback_ex(b, ssl_idevice_bio_callback);
+#else
BIO_set_callback(b, ssl_idevice_bio_callback);
+#endif
return b;
}
@@ -1140,7 +1194,7 @@ static int _mbedtls_f_rng(void* p_rng, unsigned char* buf, size_t len)
}
#endif
-LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection)
+idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection)
{
if (!connection || connection->ssl_data)
return IDEVICE_E_INVALID_ARG;
@@ -1177,7 +1231,8 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
return ret;
}
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) || \
+ (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER >= 0x3060000fL))
SSL_CTX_set_security_level(ssl_ctx, 0);
#endif
@@ -1186,23 +1241,52 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
/* force use of TLSv1 for older devices */
if (connection->device->version < DEVICE_VERSION(10,0,0)) {
#ifdef SSL_OP_NO_TLSv1_1
- long opts = SSL_CTX_get_options(ssl_ctx);
- opts |= SSL_OP_NO_TLSv1_1;
+ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1_1);
+#endif
#ifdef SSL_OP_NO_TLSv1_2
- opts |= SSL_OP_NO_TLSv1_2;
+ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1_2);
#endif
#ifdef SSL_OP_NO_TLSv1_3
- opts |= SSL_OP_NO_TLSv1_3;
-#endif
- SSL_CTX_set_options(ssl_ctx, opts);
+ SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1_3);
#endif
}
#else
SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION);
if (connection->device->version < DEVICE_VERSION(10,0,0)) {
SSL_CTX_set_max_proto_version(ssl_ctx, TLS1_VERSION);
+ if (connection->device->version == 0) {
+ /*
+ iOS 1 doesn't understand TLS1_VERSION, it can only speak SSL3_VERSION.
+ However, modern OpenSSL is usually compiled without SSLv3 support.
+ So if we set min_proto_version to SSL3_VERSION on an OpenSSL instance which doesn't support it,
+ it will just ignore min_proto_version altogether and fall back to an even higher version.
+ To avoid accidentally breaking iOS 2.0+, we set min version to 0 instead.
+ Here is what documentation says:
+ Setting the minimum or maximum version to 0,
+ will enable protocol versions down to the lowest version,
+ or up to the highest version supported by the library, respectively.
+ */
+ SSL_CTX_set_min_proto_version(ssl_ctx, 0);
+ }
}
#endif
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+#if defined(SSL_OP_IGNORE_UNEXPECTED_EOF)
+ /*
+ * For OpenSSL 3 and later, mark close_notify alerts as optional.
+ * For prior versions of OpenSSL we check for SSL_ERROR_SYSCALL when
+ * reading instead (this error changes to SSL_ERROR_SSL in OpenSSL 3).
+ */
+ SSL_CTX_set_options(ssl_ctx, SSL_OP_IGNORE_UNEXPECTED_EOF);
+#endif
+#if defined(SSL_OP_LEGACY_SERVER_CONNECT)
+ /*
+ * Without setting SSL_OP_LEGACY_SERVER_CONNECT, OpenSSL 3 fails with
+ * error "unsafe legacy renegotiation disabled" when talking to iOS 5
+ */
+ SSL_CTX_set_options(ssl_ctx, SSL_OP_LEGACY_SERVER_CONNECT);
+#endif
+#endif
BIO* membp;
X509* rootCert = NULL;
@@ -1215,6 +1299,16 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
X509_free(rootCert);
free(root_cert.data);
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ EVP_PKEY* rootPrivKey = NULL;
+ membp = BIO_new_mem_buf(root_privkey.data, root_privkey.size);
+ PEM_read_bio_PrivateKey(membp, &rootPrivKey, NULL, NULL);
+ BIO_free(membp);
+ if (SSL_CTX_use_PrivateKey(ssl_ctx, rootPrivKey) != 1) {
+ debug_info("WARNING: Could not load RootPrivateKey");
+ }
+ EVP_PKEY_free(rootPrivKey);
+#else
RSA* rootPrivKey = NULL;
membp = BIO_new_mem_buf(root_privkey.data, root_privkey.size);
PEM_read_bio_RSAPrivateKey(membp, &rootPrivKey, NULL, NULL);
@@ -1223,6 +1317,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
debug_info("WARNING: Could not load RootPrivateKey");
}
RSA_free(rootPrivKey);
+#endif
free(root_privkey.data);
SSL *ssl = SSL_new(ssl_ctx);
@@ -1402,12 +1497,12 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
return ret;
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection)
+idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection)
{
return idevice_connection_disable_bypass_ssl(connection, 0);
}
-LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_bypass_ssl(idevice_connection_t connection, uint8_t sslBypass)
+idevice_error_t idevice_connection_disable_bypass_ssl(idevice_connection_t connection, uint8_t sslBypass)
{
if (!connection)
return IDEVICE_E_INVALID_ARG;
diff --git a/src/idevice.h b/src/idevice.h
index 2509e48..dd72f9d 100644
--- a/src/idevice.h
+++ b/src/idevice.h
@@ -37,14 +37,16 @@
#include <mbedtls/ctr_drbg.h>
#endif
-#ifdef WIN32
-#define LIBIMOBILEDEVICE_API __declspec( dllexport )
+#ifdef LIBIMOBILEDEVICE_STATIC
+ #define LIBIMOBILEDEVICE_API
+#elif defined(_WIN32)
+ #define LIBIMOBILEDEVICE_API __declspec( dllexport )
#else
-#ifdef HAVE_FVISIBILITY
-#define LIBIMOBILEDEVICE_API __attribute__((visibility("default")))
-#else
-#define LIBIMOBILEDEVICE_API
-#endif
+ #if __GNUC__ >= 4
+ #define LIBIMOBILEDEVICE_API __attribute__((visibility("default")))
+ #else
+ #define LIBIMOBILEDEVICE_API
+ #endif
#endif
#include "common/userpref.h"
diff --git a/src/installation_proxy.c b/src/installation_proxy.c
index b13abf9..ec19da0 100644
--- a/src/installation_proxy.c
+++ b/src/installation_proxy.c
@@ -232,7 +232,7 @@ static instproxy_error_t instproxy_error(property_list_service_error_t err)
return INSTPROXY_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client)
+instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client)
{
property_list_service_client_t plistclient = NULL;
instproxy_error_t err = instproxy_error(property_list_service_client_new(device, service, &plistclient));
@@ -249,14 +249,14 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_new(idevice_t device, lo
return INSTPROXY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label)
+instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label)
{
instproxy_error_t err = INSTPROXY_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, INSTPROXY_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(instproxy_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_free(instproxy_client_t client)
+instproxy_error_t instproxy_client_free(instproxy_client_t client)
{
if (!client)
return INSTPROXY_E_INVALID_ARG;
@@ -525,7 +525,7 @@ static instproxy_error_t instproxy_perform_command(instproxy_client_t client, pl
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
+instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
{
if (!client || !client->parent || !status_cb)
return INSTPROXY_E_INVALID_ARG;
@@ -566,7 +566,7 @@ static void instproxy_append_current_list_to_result_cb(plist_t command, plist_t
plist_free(current_list);
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result)
+instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result)
{
if (!client || !client->parent || !result)
return INSTPROXY_E_INVALID_ARG;
@@ -603,7 +603,7 @@ static void instproxy_copy_lookup_result_cb(plist_t command, plist_t status, voi
}
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result)
+instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
int i = 0;
@@ -650,7 +650,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup(instproxy_client_t clien
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
+instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -667,7 +667,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_install(instproxy_client_t clie
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
+instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -684,7 +684,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_upgrade(instproxy_client_t clie
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
+instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -701,7 +701,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_uninstall(instproxy_client_t cl
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result)
+instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -717,7 +717,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup_archives(instproxy_clien
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
+instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -734,7 +734,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_archive(instproxy_client_t clie
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
+instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -751,7 +751,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_restore(instproxy_client_t clie
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
+instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -768,7 +768,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_remove_archive(instproxy_client
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client, const char** capabilities, plist_t client_options, plist_t *result)
+instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client, const char** capabilities, plist_t client_options, plist_t *result)
{
if (!client || !capabilities || !result)
return INSTPROXY_E_INVALID_ARG;
@@ -805,7 +805,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_check_capabilities_match(instpr
return res;
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char** description, uint64_t* code)
+instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char** description, uint64_t* code)
{
instproxy_error_t res = INSTPROXY_E_UNKNOWN_ERROR;
@@ -843,7 +843,7 @@ LIBIMOBILEDEVICE_API instproxy_error_t instproxy_status_get_error(plist_t status
return res;
}
-LIBIMOBILEDEVICE_API void instproxy_status_get_name(plist_t status, char **name)
+void instproxy_status_get_name(plist_t status, char **name)
{
if (name) {
plist_t node = plist_dict_get_item(status, "Status");
@@ -855,7 +855,7 @@ LIBIMOBILEDEVICE_API void instproxy_status_get_name(plist_t status, char **name)
}
}
-LIBIMOBILEDEVICE_API void instproxy_status_get_percent_complete(plist_t status, int *percent)
+void instproxy_status_get_percent_complete(plist_t status, int *percent)
{
uint64_t val = 0;
if (percent) {
@@ -867,7 +867,7 @@ LIBIMOBILEDEVICE_API void instproxy_status_get_percent_complete(plist_t status,
}
}
-LIBIMOBILEDEVICE_API void instproxy_status_get_current_list(plist_t status, uint64_t* total, uint64_t* current_index, uint64_t* current_amount, plist_t* list)
+void instproxy_status_get_current_list(plist_t status, uint64_t* total, uint64_t* current_index, uint64_t* current_amount, plist_t* list)
{
plist_t node = NULL;
@@ -904,7 +904,7 @@ LIBIMOBILEDEVICE_API void instproxy_status_get_current_list(plist_t status, uint
}
}
-LIBIMOBILEDEVICE_API void instproxy_command_get_name(plist_t command, char** name)
+void instproxy_command_get_name(plist_t command, char** name)
{
if (name) {
plist_t node = plist_dict_get_item(command, "Command");
@@ -916,12 +916,12 @@ LIBIMOBILEDEVICE_API void instproxy_command_get_name(plist_t command, char** nam
}
}
-LIBIMOBILEDEVICE_API plist_t instproxy_client_options_new(void)
+plist_t instproxy_client_options_new(void)
{
return plist_new_dict();
}
-LIBIMOBILEDEVICE_API void instproxy_client_options_add(plist_t client_options, ...)
+void instproxy_client_options_add(plist_t client_options, ...)
{
if (!client_options)
return;
@@ -934,7 +934,7 @@ LIBIMOBILEDEVICE_API void instproxy_client_options_add(plist_t client_options, .
if (!strcmp(key, "SkipUninstall")) {
int intval = va_arg(args, int);
plist_dict_set_item(client_options, key, plist_new_bool(intval));
- } else if (!strcmp(key, "ApplicationSINF") || !strcmp(key, "iTunesMetadata") || !strcmp(key, "ReturnAttributes")) {
+ } else if (!strcmp(key, "ApplicationSINF") || !strcmp(key, "iTunesMetadata") || !strcmp(key, "ReturnAttributes") || !strcmp(key, "BundleIDs")) {
plist_t plistval = va_arg(args, plist_t);
if (!plistval) {
free(key);
@@ -955,7 +955,7 @@ LIBIMOBILEDEVICE_API void instproxy_client_options_add(plist_t client_options, .
va_end(args);
}
-LIBIMOBILEDEVICE_API void instproxy_client_options_set_return_attributes(plist_t client_options, ...)
+void instproxy_client_options_set_return_attributes(plist_t client_options, ...)
{
if (!client_options)
return;
@@ -976,14 +976,14 @@ LIBIMOBILEDEVICE_API void instproxy_client_options_set_return_attributes(plist_t
plist_dict_set_item(client_options, "ReturnAttributes", return_attributes);
}
-LIBIMOBILEDEVICE_API void instproxy_client_options_free(plist_t client_options)
+void instproxy_client_options_free(plist_t client_options)
{
if (client_options) {
plist_free(client_options);
}
}
-LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path)
+instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path)
{
if (!client || !client->parent || !bundle_id)
return INSTPROXY_E_INVALID_ARG;
diff --git a/src/installation_proxy.h b/src/installation_proxy.h
index 033bdef..5bdbb71 100644
--- a/src/installation_proxy.h
+++ b/src/installation_proxy.h
@@ -23,6 +23,7 @@
#ifndef __INSTALLATION_PROXY_H
#define __INSTALLATION_PROXY_H
+#include "idevice.h"
#include "libimobiledevice/installation_proxy.h"
#include "property_list_service.h"
#include <libimobiledevice-glue/thread.h>
diff --git a/src/lockdown-cu.c b/src/lockdown-cu.c
index cdaf02c..1afc2c5 100644
--- a/src/lockdown-cu.c
+++ b/src/lockdown-cu.c
@@ -62,6 +62,7 @@
#include <sys/sysctl.h>
#include <SystemConfiguration/SystemConfiguration.h>
#include <CoreFoundation/CoreFoundation.h>
+#include <TargetConditionals.h>
#endif
#include "property_list_service.h"
@@ -293,7 +294,7 @@ poly1305_update_with_pad16(poly1305_state *poly1305,
static void chacha20_poly1305_encrypt_96(unsigned char* key, unsigned char* nonce, unsigned char* ad, size_t ad_len, unsigned char* in, size_t in_len, unsigned char* out, size_t* out_len)
{
#if defined(HAVE_OPENSSL)
-#if defined(LIBRESSL_VERSION_NUMBER)
+#if defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x3050000fL)
#if (LIBRESSL_VERSION_NUMBER >= 0x2040000fL)
const EVP_AEAD *aead = EVP_aead_chacha20_poly1305();
EVP_AEAD_CTX ctx;
@@ -377,7 +378,7 @@ static void chacha20_poly1305_encrypt_64(unsigned char* key, unsigned char* nonc
static void chacha20_poly1305_decrypt_96(unsigned char* key, unsigned char* nonce, unsigned char* ad, size_t ad_len, unsigned char* in, size_t in_len, unsigned char* out, size_t* out_len)
{
#if defined(HAVE_OPENSSL)
-#if defined(LIBRESSL_VERSION_NUMBER)
+#if defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x3050000fL)
#if (LIBRESSL_VERSION_NUMBER >= 0x2040000fL)
const EVP_AEAD *aead = EVP_aead_chacha20_poly1305();
EVP_AEAD_CTX ctx;
@@ -489,7 +490,7 @@ static void chacha20_poly1305_decrypt_64(unsigned char* key, unsigned char* nonc
#endif /* HAVE_WIRELESS_PAIRING */
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_pairing_create(lockdownd_client_t client, lockdownd_cu_pairing_cb_t pairing_callback, void* cb_user_data, plist_t host_info, plist_t acl)
+lockdownd_error_t lockdownd_cu_pairing_create(lockdownd_client_t client, lockdownd_cu_pairing_cb_t pairing_callback, void* cb_user_data, plist_t host_info, plist_t acl)
{
#ifdef HAVE_WIRELESS_PAIRING
if (!client || !pairing_callback || (host_info && plist_get_node_type(host_info) != PLIST_DICT) || (acl && plist_get_node_type(acl) != PLIST_DICT))
@@ -647,7 +648,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_pairing_create(lockdownd_cli
/* HOST INFORMATION */
char hostname[256];
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(TARGET_OS_IPHONE)
CFStringRef cname = SCDynamicStoreCopyComputerName(NULL, NULL);
CFStringGetCString(cname, hostname, sizeof(hostname), kCFStringEncodingUTF8);
CFRelease(cname);
@@ -931,7 +932,7 @@ debug_buffer(data, data_len);
#endif
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_send_request_and_get_reply(lockdownd_client_t client, const char* request, plist_t request_payload, plist_t* reply)
+lockdownd_error_t lockdownd_cu_send_request_and_get_reply(lockdownd_client_t client, const char* request, plist_t request_payload, plist_t* reply)
{
#ifdef HAVE_WIRELESS_PAIRING
if (!client || !request)
@@ -1031,7 +1032,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_send_request_and_get_reply(l
plist_free(dict);
dict = NULL;
- plist_from_memory((const char*)decrypted, decrypted_len, &dict);
+ plist_from_memory((const char*)decrypted, decrypted_len, &dict, NULL);
if (!dict) {
ret = LOCKDOWN_E_PLIST_ERROR;
debug_info("Failed to parse PLIST from decrypted payload:");
@@ -1056,7 +1057,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_send_request_and_get_reply(l
#endif
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_value_cu(lockdownd_client_t client, const char* domain, const char* key, plist_t* value)
+lockdownd_error_t lockdownd_get_value_cu(lockdownd_client_t client, const char* domain, const char* key, plist_t* value)
{
#ifdef HAVE_WIRELESS_PAIRING
if (!client)
@@ -1096,7 +1097,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_value_cu(lockdownd_client_t
#endif
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair_cu(lockdownd_client_t client)
+lockdownd_error_t lockdownd_pair_cu(lockdownd_client_t client)
{
#ifdef HAVE_WIRELESS_PAIRING
if (!client)
diff --git a/src/lockdown.c b/src/lockdown.c
index 505b13e..256bff0 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -165,51 +165,38 @@ lockdownd_error_t lockdown_check_result(plist_t dict, const char *query_match)
return ret;
}
- char *query_value = NULL;
-
- plist_get_string_val(query_node, &query_value);
+ const char *query_value = plist_get_string_ptr(query_node, NULL);
if (!query_value) {
return ret;
}
if (query_match && (strcmp(query_value, query_match) != 0)) {
- free(query_value);
return ret;
}
- free(query_value);
-
- plist_t result_node = plist_dict_get_item(dict, "Result");
- if (!result_node) {
- /* iOS 5: the 'Result' key is not present anymore.
- But we need to check for the 'Error' key. */
- plist_t err_node = plist_dict_get_item(dict, "Error");
- if (err_node) {
- if (plist_get_node_type(err_node) == PLIST_STRING) {
- char *err_value = NULL;
-
- plist_get_string_val(err_node, &err_value);
- if (err_value) {
- debug_info("ERROR: %s", err_value);
- ret = lockdownd_strtoerr(err_value);
- free(err_value);
- } else {
- debug_info("ERROR: unknown error occurred");
- }
+ /* Check for 'Error' in reply */
+ plist_t err_node = plist_dict_get_item(dict, "Error");
+ if (err_node) {
+ if (plist_get_node_type(err_node) == PLIST_STRING) {
+ const char *err_value = plist_get_string_ptr(err_node, NULL);
+ if (err_value) {
+ debug_info("ERROR: %s", err_value);
+ ret = lockdownd_strtoerr(err_value);
+ } else {
+ debug_info("ERROR: unknown error occurred");
}
- return ret;
}
-
- ret = LOCKDOWN_E_SUCCESS;
-
return ret;
}
- plist_type result_type = plist_get_node_type(result_node);
- if (result_type == PLIST_STRING) {
- char *result_value = NULL;
-
- plist_get_string_val(result_node, &result_value);
+ plist_t result_node = plist_dict_get_item(dict, "Result");
+ if (!result_node) {
+ /* With iOS 5+ 'Result' is not present anymore.
+ If there is no 'Error', we can just assume success. */
+ return LOCKDOWN_E_SUCCESS;
+ }
+ if (plist_get_node_type(result_node) == PLIST_STRING) {
+ const char *result_value = plist_get_string_ptr(result_node, NULL);
if (result_value) {
if (!strcmp(result_value, "Success")) {
ret = LOCKDOWN_E_SUCCESS;
@@ -219,9 +206,6 @@ lockdownd_error_t lockdown_check_result(plist_t dict, const char *query_match)
debug_info("ERROR: unknown result value '%s'", result_value);
}
}
-
- if (result_value)
- free(result_value);
}
return ret;
@@ -242,7 +226,7 @@ static void plist_dict_add_label(plist_t plist, const char *label)
}
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id)
+lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -325,7 +309,7 @@ static lockdownd_error_t lockdownd_client_free_simple(lockdownd_client_t client)
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_free(lockdownd_client_t client)
+lockdownd_error_t lockdownd_client_free(lockdownd_client_t client)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -341,7 +325,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_free(lockdownd_client_t
return ret;
}
-LIBIMOBILEDEVICE_API void lockdownd_client_set_label(lockdownd_client_t client, const char *label)
+void lockdownd_client_set_label(lockdownd_client_t client, const char *label)
{
if (client) {
if (client->label)
@@ -351,7 +335,7 @@ LIBIMOBILEDEVICE_API void lockdownd_client_set_label(lockdownd_client_t client,
}
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist)
+lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist)
{
if (!client || !plist || (plist && *plist))
return LOCKDOWN_E_INVALID_ARG;
@@ -359,7 +343,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_receive(lockdownd_client_t clie
return lockdownd_error(property_list_service_receive_plist(client->parent, plist));
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
+lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
{
if (!client || !plist)
return LOCKDOWN_E_INVALID_ARG;
@@ -367,7 +351,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_send(lockdownd_client_t client,
return lockdownd_error(property_list_service_send_xml_plist(client->parent, plist));
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
+lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -412,7 +396,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_query_type(lockdownd_client_t c
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value)
+lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -466,7 +450,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_value(lockdownd_client_t cl
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value)
+lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value)
{
if (!client || !value)
return LOCKDOWN_E_INVALID_ARG;
@@ -514,7 +498,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_set_value(lockdownd_client_t cl
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key)
+lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -561,7 +545,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_remove_value(lockdownd_client_t
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid)
+lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid)
{
lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
plist_t value = NULL;
@@ -607,7 +591,7 @@ static lockdownd_error_t lockdownd_get_device_public_key_as_key_data(lockdownd_c
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name)
+lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name)
{
lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
plist_t value = NULL;
@@ -624,7 +608,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_device_name(lockdownd_clien
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label)
+lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label)
{
if (!device || !client)
return LOCKDOWN_E_INVALID_ARG;
@@ -659,7 +643,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new(idevice_t device, lo
return LOCKDOWN_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label)
+lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -1072,7 +1056,7 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
+lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
{
plist_t options = plist_new_dict();
@@ -1085,22 +1069,22 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair(lockdownd_client_t client,
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response)
+lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response)
{
return lockdownd_do_pair(client, pair_record, "Pair", options, response);
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
+lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
{
return lockdownd_do_pair(client, pair_record, "ValidatePair", NULL, NULL);
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
+lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
{
return lockdownd_do_pair(client, pair_record, "Unpair", NULL, NULL);
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
+lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -1130,7 +1114,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_enter_recovery(lockdownd_client
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
+lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -1164,7 +1148,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_goodbye(lockdownd_client_t clie
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled)
+lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled)
{
lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
plist_t dict = NULL;
@@ -1408,17 +1392,17 @@ static lockdownd_error_t lockdownd_do_start_service(lockdownd_client_t client, c
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service)
+lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service)
{
return lockdownd_do_start_service(client, identifier, 0, service);
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service)
+lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service)
{
return lockdownd_do_start_service(client, identifier, 1, service);
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record)
+lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -1457,7 +1441,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_activate(lockdownd_client_t cli
return ret;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client)
+lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -1504,7 +1488,7 @@ static void str_remove_spaces(char *source)
*dest = 0;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count)
+lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -1559,7 +1543,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd
return LOCKDOWN_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_data_classes_free(char **classes)
+lockdownd_error_t lockdownd_data_classes_free(char **classes)
{
if (classes) {
int i = 0;
@@ -1571,7 +1555,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_data_classes_free(char **classe
return LOCKDOWN_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service)
+lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service)
{
if (service) {
free(service->identifier);
@@ -1581,7 +1565,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_service_descriptor_free(lockdow
return LOCKDOWN_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API const char* lockdownd_strerror(lockdownd_error_t err)
+const char* lockdownd_strerror(lockdownd_error_t err)
{
switch (err) {
case LOCKDOWN_E_SUCCESS:
diff --git a/src/lockdown.h b/src/lockdown.h
index bcd4717..ba291ec 100644
--- a/src/lockdown.h
+++ b/src/lockdown.h
@@ -23,6 +23,7 @@
#ifndef __LOCKDOWND_H
#define __LOCKDOWND_H
+#include "idevice.h"
#include "libimobiledevice/lockdown.h"
#include "property_list_service.h"
diff --git a/src/misagent.c b/src/misagent.c
index af925f9..e3da997 100644
--- a/src/misagent.c
+++ b/src/misagent.c
@@ -89,7 +89,7 @@ static misagent_error_t misagent_check_result(plist_t response, int* status_code
return MISAGENT_E_REQUEST_FAILED;
}
-LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client)
+misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client)
{
property_list_service_client_t plistclient = NULL;
misagent_error_t err = misagent_error(property_list_service_client_new(device, service, &plistclient));
@@ -105,14 +105,14 @@ LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lock
return MISAGENT_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t * client, const char* label)
+misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t * client, const char* label)
{
misagent_error_t err = MISAGENT_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, MISAGENT_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(misagent_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API misagent_error_t misagent_client_free(misagent_client_t client)
+misagent_error_t misagent_client_free(misagent_client_t client)
{
if (!client)
return MISAGENT_E_INVALID_ARG;
@@ -127,7 +127,7 @@ LIBIMOBILEDEVICE_API misagent_error_t misagent_client_free(misagent_client_t cli
return err;
}
-LIBIMOBILEDEVICE_API misagent_error_t misagent_install(misagent_client_t client, plist_t profile)
+misagent_error_t misagent_install(misagent_client_t client, plist_t profile)
{
if (!client || !client->parent || !profile || (plist_get_node_type(profile) != PLIST_DATA))
return MISAGENT_E_INVALID_ARG;
@@ -164,7 +164,7 @@ LIBIMOBILEDEVICE_API misagent_error_t misagent_install(misagent_client_t client,
return res;
}
-LIBIMOBILEDEVICE_API misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles)
+misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles)
{
if (!client || !client->parent || !profiles)
return MISAGENT_E_INVALID_ARG;
@@ -204,7 +204,7 @@ LIBIMOBILEDEVICE_API misagent_error_t misagent_copy(misagent_client_t client, pl
}
-LIBIMOBILEDEVICE_API misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles)
+misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles)
{
if (!client || !client->parent || !profiles)
return MISAGENT_E_INVALID_ARG;
@@ -244,7 +244,7 @@ LIBIMOBILEDEVICE_API misagent_error_t misagent_copy_all(misagent_client_t client
}
-LIBIMOBILEDEVICE_API misagent_error_t misagent_remove(misagent_client_t client, const char* profileID)
+misagent_error_t misagent_remove(misagent_client_t client, const char* profileID)
{
if (!client || !client->parent || !profileID)
return MISAGENT_E_INVALID_ARG;
@@ -281,7 +281,7 @@ LIBIMOBILEDEVICE_API misagent_error_t misagent_remove(misagent_client_t client,
return res;
}
-LIBIMOBILEDEVICE_API int misagent_get_status_code(misagent_client_t client)
+int misagent_get_status_code(misagent_client_t client)
{
if (!client) {
return -1;
diff --git a/src/misagent.h b/src/misagent.h
index 08ad063..e394087 100644
--- a/src/misagent.h
+++ b/src/misagent.h
@@ -22,6 +22,7 @@
#ifndef __MISAGENT_H
#define __MISAGENT_H
+#include "idevice.h"
#include "libimobiledevice/misagent.h"
#include "property_list_service.h"
diff --git a/src/mobile_image_mounter.c b/src/mobile_image_mounter.c
index 9ccfd85..5df8e86 100644
--- a/src/mobile_image_mounter.c
+++ b/src/mobile_image_mounter.c
@@ -78,7 +78,7 @@ static mobile_image_mounter_error_t mobile_image_mounter_error(property_list_ser
return MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client)
+mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client)
{
property_list_service_client_t plistclient = NULL;
mobile_image_mounter_error_t err = mobile_image_mounter_error(property_list_service_client_new(device, service, &plistclient));
@@ -95,14 +95,14 @@ LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_new(idevi
return MOBILE_IMAGE_MOUNTER_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t * client, const char* label)
+mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t * client, const char* label)
{
mobile_image_mounter_error_t err = MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, MOBILE_IMAGE_MOUNTER_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(mobile_image_mounter_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client)
+mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client)
{
if (!client)
return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG;
@@ -115,7 +115,7 @@ LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_free(mobi
return MOBILE_IMAGE_MOUNTER_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result)
+mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result)
{
if (!client || !image_type || !result) {
return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG;
@@ -181,7 +181,7 @@ static mobile_image_mounter_error_t process_result(plist_t result, const char *e
return res;
}
-LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata)
+mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata)
{
if (!client || !image_type || (image_size == 0) || !upload_cb) {
return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG;
@@ -260,7 +260,7 @@ leave_unlock:
}
-LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result)
+mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result)
{
if (!client || !image_path || !image_type || !result) {
return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG;
@@ -292,7 +292,7 @@ leave_unlock:
return res;
}
-LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client)
+mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client)
{
if (!client) {
return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG;
diff --git a/src/mobile_image_mounter.h b/src/mobile_image_mounter.h
index 55c9cf2..9a8fcdd 100644
--- a/src/mobile_image_mounter.h
+++ b/src/mobile_image_mounter.h
@@ -22,6 +22,7 @@
#ifndef __MOBILE_IMAGE_MOUNTER_H
#define __MOBILE_IMAGE_MOUNTER_H
+#include "idevice.h"
#include "libimobiledevice/mobile_image_mounter.h"
#include "property_list_service.h"
#include <libimobiledevice-glue/thread.h>
diff --git a/src/mobileactivation.c b/src/mobileactivation.c
index 79c7003..fce5f16 100644
--- a/src/mobileactivation.c
+++ b/src/mobileactivation.c
@@ -54,7 +54,7 @@ static mobileactivation_error_t mobileactivation_error(property_list_service_err
return MOBILEACTIVATION_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobileactivation_client_t *client)
+mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobileactivation_client_t *client)
{
if (!device || !service || service->port == 0 || !client || *client) {
return MOBILEACTIVATION_E_INVALID_ARG;
@@ -74,14 +74,14 @@ LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_new(idevic
return MOBILEACTIVATION_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, mobileactivation_client_t * client, const char* label)
+mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, mobileactivation_client_t * client, const char* label)
{
mobileactivation_error_t err = MOBILEACTIVATION_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, MOBILEACTIVATION_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(mobileactivation_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t client)
+mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t client)
{
if (!client)
return MOBILEACTIVATION_E_INVALID_ARG;
@@ -176,7 +176,7 @@ static mobileactivation_error_t mobileactivation_send_command(mobileactivation_c
return ret;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_client_t client, plist_t *state)
+mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_client_t client, plist_t *state)
{
if (!client || !state)
return MOBILEACTIVATION_E_INVALID_ARG;
@@ -198,7 +198,7 @@ LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_get_activation_st
return ret;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_session_info(mobileactivation_client_t client, plist_t *blob)
+mobileactivation_error_t mobileactivation_create_activation_session_info(mobileactivation_client_t client, plist_t *blob)
{
if (!client || !blob)
return MOBILEACTIVATION_E_INVALID_ARG;
@@ -218,7 +218,7 @@ LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation
return ret;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_info(mobileactivation_client_t client, plist_t *info)
+mobileactivation_error_t mobileactivation_create_activation_info(mobileactivation_client_t client, plist_t *info)
{
if (!client || !info)
return MOBILEACTIVATION_E_INVALID_ARG;
@@ -240,7 +240,7 @@ LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation
return ret;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_info_with_session(mobileactivation_client_t client, plist_t handshake_response, plist_t *info)
+mobileactivation_error_t mobileactivation_create_activation_info_with_session(mobileactivation_client_t client, plist_t handshake_response, plist_t *info)
{
if (!client || !info)
return MOBILEACTIVATION_E_INVALID_ARG;
@@ -264,7 +264,7 @@ LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation
return ret;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t client, plist_t activation_record)
+mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t client, plist_t activation_record)
{
if (!client || !activation_record)
return MOBILEACTIVATION_E_INVALID_ARG;
@@ -277,7 +277,7 @@ LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate(mobileac
return ret;
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate_with_session(mobileactivation_client_t client, plist_t activation_record, plist_t headers)
+mobileactivation_error_t mobileactivation_activate_with_session(mobileactivation_client_t client, plist_t activation_record, plist_t headers)
{
if (!client || !activation_record)
return MOBILEACTIVATION_E_INVALID_ARG;
@@ -300,7 +300,7 @@ LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate_with_ses
}
-LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client)
+mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client)
{
if (!client)
return MOBILEACTIVATION_E_INVALID_ARG;
diff --git a/src/mobileactivation.h b/src/mobileactivation.h
index 49b9ebc..a8dff5d 100644
--- a/src/mobileactivation.h
+++ b/src/mobileactivation.h
@@ -22,6 +22,7 @@
#ifndef __MOBILEACTIVATION_H
#define __MOBILEACTIVATION_H
+#include "idevice.h"
#include "libimobiledevice/mobileactivation.h"
#include "property_list_service.h"
diff --git a/src/mobilebackup.c b/src/mobilebackup.c
index aa29277..36986a4 100644
--- a/src/mobilebackup.c
+++ b/src/mobilebackup.c
@@ -26,6 +26,7 @@
#include <plist/plist.h>
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include "mobilebackup.h"
#include "device_link_service.h"
@@ -68,7 +69,7 @@ static mobilebackup_error_t mobilebackup_error(device_link_service_error_t err)
return MOBILEBACKUP_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client)
+mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client)
{
if (!device || !service || service->port == 0 || !client || *client)
return MOBILEBACKUP_E_INVALID_ARG;
@@ -95,14 +96,14 @@ LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_new(idevice_t devi
return ret;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t * client, const char* label)
+mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t * client, const char* label)
{
mobilebackup_error_t err = MOBILEBACKUP_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, MOBILEBACKUP_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(mobilebackup_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client)
+mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client)
{
if (!client)
return MOBILEBACKUP_E_INVALID_ARG;
@@ -115,7 +116,7 @@ LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_free(mobilebackup_
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * plist)
+mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * plist)
{
if (!client)
return MOBILEBACKUP_E_INVALID_ARG;
@@ -123,7 +124,7 @@ LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive(mobilebackup_clie
return ret;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist)
+mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist)
{
if (!client || !plist)
return MOBILEBACKUP_E_INVALID_ARG;
@@ -240,7 +241,7 @@ leave:
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version)
+mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version)
{
if (!client || !client->parent || !base_path || !proto_version)
return MOBILEBACKUP_E_INVALID_ARG;
@@ -279,7 +280,15 @@ LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_backup(mobileback
char *str = NULL;
plist_get_string_val(node, &str);
if (str) {
- if (strcmp(str, proto_version) != 0) {
+ int maj = 0;
+ int min = 0;
+ sscanf(str, "%u.%u", &maj, &min);
+ uint32_t this_ver = ((maj & 0xFF) << 8) | (min & 0xFF);
+ maj = 0;
+ min = 0;
+ sscanf(proto_version, "%u.%u", &maj, &min);
+ uint32_t proto_ver = ((maj & 0xFF) << 8) | (min & 0xFF);
+ if (this_ver > proto_ver) {
err = MOBILEBACKUP_E_BAD_VERSION;
}
free(str);
@@ -300,12 +309,12 @@ leave:
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client)
+mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client)
{
return mobilebackup_send_message(client, "kBackupMessageBackupFileReceived", NULL);
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version)
+mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version)
{
if (!client || !client->parent || !backup_manifest || !proto_version)
return MOBILEBACKUP_E_INVALID_ARG;
@@ -346,7 +355,15 @@ LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_restore(mobilebac
char *str = NULL;
plist_get_string_val(node, &str);
if (str) {
- if (strcmp(str, proto_version) != 0) {
+ int maj = 0;
+ int min = 0;
+ sscanf(str, "%u.%u", &maj, &min);
+ uint32_t this_ver = ((maj & 0xFF) << 8) | (min & 0xFF);
+ maj = 0;
+ min = 0;
+ sscanf(proto_version, "%u.%u", &maj, &min);
+ uint32_t proto_ver = ((maj & 0xFF) << 8) | (min & 0xFF);
+ if (this_ver > proto_ver) {
err = MOBILEBACKUP_E_BAD_VERSION;
}
free(str);
@@ -359,17 +376,17 @@ leave:
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result)
+mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result)
{
return mobilebackup_receive_message(client, "BackupMessageRestoreFileReceived", result);
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result)
+mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result)
{
return mobilebackup_receive_message(client, "BackupMessageRestoreApplicationReceived", result);
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client)
+mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client)
{
mobilebackup_error_t err = mobilebackup_send_message(client, "BackupMessageRestoreComplete", NULL);
if (err != MOBILEBACKUP_E_SUCCESS) {
@@ -414,7 +431,7 @@ LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_restore_complete(mob
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason)
+mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason)
{
if (!client || !client->parent || !reason)
return MOBILEBACKUP_E_INVALID_ARG;
diff --git a/src/mobilebackup.h b/src/mobilebackup.h
index edda70f..04ec479 100644
--- a/src/mobilebackup.h
+++ b/src/mobilebackup.h
@@ -23,6 +23,7 @@
#ifndef __MOBILEBACKUP_H
#define __MOBILEBACKUP_H
+#include "idevice.h"
#include "libimobiledevice/mobilebackup.h"
#include "device_link_service.h"
diff --git a/src/mobilebackup2.c b/src/mobilebackup2.c
index 3726065..a8d673f 100644
--- a/src/mobilebackup2.c
+++ b/src/mobilebackup2.c
@@ -68,7 +68,7 @@ static mobilebackup2_error_t mobilebackup2_error(device_link_service_error_t err
return MOBILEBACKUP2_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service,
+mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service,
mobilebackup2_client_t * client)
{
if (!device || !service || service->port == 0 || !client || *client)
@@ -96,14 +96,14 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_new(idevice_t de
return ret;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t * client, const char* label)
+mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t * client, const char* label)
{
mobilebackup2_error_t err = MOBILEBACKUP2_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, MOBILEBACKUP2_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(mobilebackup2_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client)
+mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client)
{
if (!client)
return MOBILEBACKUP2_E_INVALID_ARG;
@@ -116,7 +116,7 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_free(mobilebacku
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options)
+mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options)
{
if (!client || !client->parent || (!message && !options))
return MOBILEBACKUP2_E_INVALID_ARG;
@@ -214,12 +214,12 @@ leave:
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage)
+mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage)
{
return mobilebackup2_error(device_link_service_receive_message(client->parent, msg_plist, dlmessage));
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes)
+mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes)
{
if (!client || !client->parent || !data || (length == 0) || !bytes)
return MOBILEBACKUP2_E_INVALID_ARG;
@@ -244,7 +244,7 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_
return MOBILEBACKUP2_E_MUX_ERROR;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes)
+mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes)
{
if (!client || !client->parent || !data || (length == 0) || !bytes)
return MOBILEBACKUP2_E_INVALID_ARG;
@@ -271,7 +271,7 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebacku
return MOBILEBACKUP2_E_MUX_ERROR;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version)
+mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version)
{
int i;
@@ -329,7 +329,7 @@ leave:
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options)
+mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options)
{
if (!client || !client->parent || !request || !target_identifier)
return MOBILEBACKUP2_E_INVALID_ARG;
@@ -360,7 +360,7 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_request(mobileback
return err;
}
-LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2)
+mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2)
{
if (!client || !client->parent)
return MOBILEBACKUP2_E_INVALID_ARG;
diff --git a/src/mobilebackup2.h b/src/mobilebackup2.h
index 025b6bf..e232b97 100644
--- a/src/mobilebackup2.h
+++ b/src/mobilebackup2.h
@@ -22,6 +22,7 @@
#ifndef __MOBILEBACKUP2_H
#define __MOBILEBACKUP2_H
+#include "idevice.h"
#include "libimobiledevice/mobilebackup2.h"
#include "device_link_service.h"
diff --git a/src/mobilesync.c b/src/mobilesync.c
index e50226c..9b81a49 100644
--- a/src/mobilesync.c
+++ b/src/mobilesync.c
@@ -71,7 +71,7 @@ static mobilesync_error_t mobilesync_error(device_link_service_error_t err)
return MOBILESYNC_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service,
+mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service,
mobilesync_client_t * client)
{
if (!device || !service || service->port == 0 || !client || *client)
@@ -101,14 +101,14 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_new(idevice_t device,
return ret;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t * client, const char* label)
+mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t * client, const char* label)
{
mobilesync_error_t err = MOBILESYNC_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, MOBILESYNC_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(mobilesync_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
+mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
{
if (!client)
return MOBILESYNC_E_INVALID_ARG;
@@ -118,7 +118,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_free(mobilesync_client
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plist)
+mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plist)
{
if (!client)
return MOBILESYNC_E_INVALID_ARG;
@@ -126,14 +126,14 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_receive(mobilesync_client_t c
return ret;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
+mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
{
if (!client || !plist)
return MOBILESYNC_E_INVALID_ARG;
return mobilesync_error(device_link_service_send(client->parent, plist));
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description)
+mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description)
{
if (!client || client->data_class || !data_class ||
!anchors || !anchors->computer_anchor) {
@@ -259,7 +259,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_start(mobilesync_client_t cli
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_finish(mobilesync_client_t client)
+mobilesync_error_t mobilesync_finish(mobilesync_client_t client)
{
if (!client || !client->data_class) {
return MOBILESYNC_E_INVALID_ARG;
@@ -344,17 +344,17 @@ static mobilesync_error_t mobilesync_get_records(mobilesync_client_t client, con
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client)
+mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client)
{
return mobilesync_get_records(client, "SDMessageGetAllRecordsFromDevice");
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client)
+mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client)
{
return mobilesync_get_records(client, "SDMessageGetChangesFromDevice");
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions)
+mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions)
{
if (!client || !client->data_class) {
return MOBILESYNC_E_INVALID_ARG;
@@ -421,7 +421,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_receive_changes(mobilesync_cl
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client)
+mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client)
{
if (!client || !client->data_class) {
return MOBILESYNC_E_INVALID_ARG;
@@ -490,7 +490,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_clear_all_records_on_device(m
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client)
+mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client)
{
if (!client || !client->data_class) {
return MOBILESYNC_E_INVALID_ARG;
@@ -524,7 +524,7 @@ static plist_t create_process_changes_message(const char *data_class, plist_t en
return msg;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client)
+mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client)
{
if (!client || !client->data_class) {
return MOBILESYNC_E_INVALID_ARG;
@@ -591,7 +591,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_ready_to_send_changes_from_co
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions)
+mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions)
{
if (!client || !client->data_class || !entities) {
return MOBILESYNC_E_INVALID_ARG;
@@ -619,7 +619,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_send_changes(mobilesync_clien
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping)
+mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping)
{
if (!client || !client->data_class) {
return MOBILESYNC_E_INVALID_ARG;
@@ -688,7 +688,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_remap_identifiers(mobilesync_
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason)
+mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason)
{
if (!client || !client->data_class || !reason) {
return MOBILESYNC_E_INVALID_ARG;
@@ -714,7 +714,7 @@ LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_cancel(mobilesync_client_t cl
return err;
}
-LIBIMOBILEDEVICE_API mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor)
+mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor)
{
mobilesync_anchors_t anchors = (mobilesync_anchors_t) malloc(sizeof(mobilesync_anchors));
if (device_anchor != NULL) {
@@ -731,7 +731,7 @@ LIBIMOBILEDEVICE_API mobilesync_anchors_t mobilesync_anchors_new(const char *dev
return anchors;
}
-LIBIMOBILEDEVICE_API void mobilesync_anchors_free(mobilesync_anchors_t anchors)
+void mobilesync_anchors_free(mobilesync_anchors_t anchors)
{
if (anchors->device_anchor != NULL) {
free(anchors->device_anchor);
@@ -745,12 +745,12 @@ LIBIMOBILEDEVICE_API void mobilesync_anchors_free(mobilesync_anchors_t anchors)
anchors = NULL;
}
-LIBIMOBILEDEVICE_API plist_t mobilesync_actions_new(void)
+plist_t mobilesync_actions_new(void)
{
return plist_new_dict();
}
-LIBIMOBILEDEVICE_API void mobilesync_actions_add(plist_t actions, ...)
+void mobilesync_actions_add(plist_t actions, ...)
{
if (!actions)
return;
@@ -782,7 +782,7 @@ LIBIMOBILEDEVICE_API void mobilesync_actions_add(plist_t actions, ...)
va_end(args);
}
-LIBIMOBILEDEVICE_API void mobilesync_actions_free(plist_t actions)
+void mobilesync_actions_free(plist_t actions)
{
if (actions) {
plist_free(actions);
diff --git a/src/mobilesync.h b/src/mobilesync.h
index f672252..3b5ece9 100644
--- a/src/mobilesync.h
+++ b/src/mobilesync.h
@@ -23,6 +23,7 @@
#ifndef __MOBILESYNC_H
#define __MOBILESYNC_H
+#include "idevice.h"
#include "libimobiledevice/mobilesync.h"
#include "device_link_service.h"
diff --git a/src/notification_proxy.c b/src/notification_proxy.c
index e17e2fe..60b2e03 100644
--- a/src/notification_proxy.c
+++ b/src/notification_proxy.c
@@ -89,7 +89,7 @@ static np_error_t np_error(property_list_service_error_t err)
return NP_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client)
+np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client)
{
property_list_service_client_t plistclient = NULL;
np_error_t err = np_error(property_list_service_client_new(device, service, &plistclient));
@@ -107,14 +107,14 @@ LIBIMOBILEDEVICE_API np_error_t np_client_new(idevice_t device, lockdownd_servic
return NP_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label)
+np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label)
{
np_error_t err = NP_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, NP_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(np_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API np_error_t np_client_free(np_client_t client)
+np_error_t np_client_free(np_client_t client)
{
plist_t dict;
property_list_service_client_t parent;
@@ -168,7 +168,7 @@ LIBIMOBILEDEVICE_API np_error_t np_client_free(np_client_t client)
return NP_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API np_error_t np_post_notification(np_client_t client, const char *notification)
+np_error_t np_post_notification(np_client_t client, const char *notification)
{
if (!client || !notification) {
return NP_E_INVALID_ARG;
@@ -204,7 +204,7 @@ static np_error_t internal_np_observe_notification(np_client_t client, const cha
return res;
}
-LIBIMOBILEDEVICE_API np_error_t np_observe_notification( np_client_t client, const char *notification )
+np_error_t np_observe_notification( np_client_t client, const char *notification )
{
if (!client || !notification) {
return NP_E_INVALID_ARG;
@@ -215,7 +215,7 @@ LIBIMOBILEDEVICE_API np_error_t np_observe_notification( np_client_t client, con
return res;
}
-LIBIMOBILEDEVICE_API np_error_t np_observe_notifications(np_client_t client, const char **notification_spec)
+np_error_t np_observe_notifications(np_client_t client, const char **notification_spec)
{
int i = 0;
np_error_t res = NP_E_UNKNOWN_ERROR;
@@ -346,7 +346,7 @@ void* np_notifier( void* arg )
return NULL;
}
-LIBIMOBILEDEVICE_API np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb, void *user_data )
+np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb, void *user_data )
{
if (!client)
return NP_E_INVALID_ARG;
diff --git a/src/notification_proxy.h b/src/notification_proxy.h
index ea85149..595cb01 100644
--- a/src/notification_proxy.h
+++ b/src/notification_proxy.h
@@ -22,6 +22,7 @@
#ifndef __NOTIFICATION_PROXY_H
#define __NOTIFICATION_PROXY_H
+#include "idevice.h"
#include "libimobiledevice/notification_proxy.h"
#include "property_list_service.h"
#include <libimobiledevice-glue/thread.h>
diff --git a/src/preboard.c b/src/preboard.c
index 4b3b444..c3eff02 100644
--- a/src/preboard.c
+++ b/src/preboard.c
@@ -62,7 +62,7 @@ static preboard_error_t preboard_error(property_list_service_error_t err)
return PREBOARD_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API preboard_error_t preboard_client_new(idevice_t device, lockdownd_service_descriptor_t service, preboard_client_t * client)
+preboard_error_t preboard_client_new(idevice_t device, lockdownd_service_descriptor_t service, preboard_client_t * client)
{
*client = NULL;
@@ -90,14 +90,14 @@ LIBIMOBILEDEVICE_API preboard_error_t preboard_client_new(idevice_t device, lock
return 0;
}
-LIBIMOBILEDEVICE_API preboard_error_t preboard_client_start_service(idevice_t device, preboard_client_t * client, const char* label)
+preboard_error_t preboard_client_start_service(idevice_t device, preboard_client_t * client, const char* label)
{
preboard_error_t err = PREBOARD_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, PREBOARD_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(preboard_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API preboard_error_t preboard_client_free(preboard_client_t client)
+preboard_error_t preboard_client_free(preboard_client_t client)
{
if (!client)
return PREBOARD_E_INVALID_ARG;
@@ -116,7 +116,7 @@ LIBIMOBILEDEVICE_API preboard_error_t preboard_client_free(preboard_client_t cli
return err;
}
-LIBIMOBILEDEVICE_API preboard_error_t preboard_send(preboard_client_t client, plist_t plist)
+preboard_error_t preboard_send(preboard_client_t client, plist_t plist)
{
preboard_error_t res = PREBOARD_E_UNKNOWN_ERROR;
res = preboard_error(property_list_service_send_binary_plist(client->parent, plist));
@@ -127,7 +127,7 @@ LIBIMOBILEDEVICE_API preboard_error_t preboard_send(preboard_client_t client, pl
return res;
}
-LIBIMOBILEDEVICE_API preboard_error_t preboard_receive_with_timeout(preboard_client_t client, plist_t * plist, uint32_t timeout_ms)
+preboard_error_t preboard_receive_with_timeout(preboard_client_t client, plist_t * plist, uint32_t timeout_ms)
{
preboard_error_t res = PREBOARD_E_UNKNOWN_ERROR;
plist_t outplist = NULL;
@@ -141,7 +141,7 @@ LIBIMOBILEDEVICE_API preboard_error_t preboard_receive_with_timeout(preboard_cli
return res;
}
-LIBIMOBILEDEVICE_API preboard_error_t preboard_receive(preboard_client_t client, plist_t * plist)
+preboard_error_t preboard_receive(preboard_client_t client, plist_t * plist)
{
return preboard_receive_with_timeout(client, plist, 5000);
}
@@ -209,7 +209,7 @@ static preboard_error_t preboard_receive_status_loop_with_callback(preboard_clie
return res;
}
-LIBIMOBILEDEVICE_API preboard_error_t preboard_create_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data)
+preboard_error_t preboard_create_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data)
{
if (!client) {
return PREBOARD_E_INVALID_ARG;
@@ -232,7 +232,7 @@ LIBIMOBILEDEVICE_API preboard_error_t preboard_create_stashbag(preboard_client_t
return preboard_receive_status_loop_with_callback(client, status_cb, user_data);
}
-LIBIMOBILEDEVICE_API preboard_error_t preboard_commit_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data)
+preboard_error_t preboard_commit_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data)
{
if (!client) {
return PREBOARD_E_INVALID_ARG;
diff --git a/src/preboard.h b/src/preboard.h
index 61263fc..f8164eb 100644
--- a/src/preboard.h
+++ b/src/preboard.h
@@ -22,6 +22,7 @@
#ifndef __PREBOARD_H
#define __PREBOARD_H
+#include "idevice.h"
#include "libimobiledevice/preboard.h"
#include "property_list_service.h"
#include <libimobiledevice-glue/thread.h>
diff --git a/src/property_list_service.c b/src/property_list_service.c
index 4654b6e..2fca4e7 100644
--- a/src/property_list_service.c
+++ b/src/property_list_service.c
@@ -58,7 +58,7 @@ static property_list_service_error_t service_to_property_list_service_error(serv
return PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client)
+property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client)
{
if (!device || !service || service->port == 0 || !client || *client)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
@@ -78,7 +78,7 @@ LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_
return PROPERTY_LIST_SERVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_free(property_list_service_client_t client)
+property_list_service_error_t property_list_service_client_free(property_list_service_client_t client)
{
if (!client)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
@@ -152,12 +152,12 @@ static property_list_service_error_t internal_plist_send(property_list_service_c
return res;
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist)
+property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist)
{
return internal_plist_send(client, plist, 0);
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist)
+property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist)
{
return internal_plist_send(client, plist, 1);
}
@@ -262,31 +262,31 @@ static property_list_service_error_t internal_plist_receive_timeout(property_lis
return res;
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout)
+property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout)
{
return internal_plist_receive_timeout(client, plist, timeout);
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist)
+property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist)
{
return internal_plist_receive_timeout(client, plist, 30000);
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client)
+property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client)
{
if (!client || !client->parent)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
return service_to_property_list_service_error(service_enable_ssl(client->parent));
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client)
+property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client)
{
if (!client || !client->parent)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
return service_to_property_list_service_error(service_disable_ssl(client->parent));
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_get_service_client(property_list_service_client_t client, service_client_t *service_client)
+property_list_service_error_t property_list_service_get_service_client(property_list_service_client_t client, service_client_t *service_client)
{
if (!client || !client->parent || !service_client)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
diff --git a/src/property_list_service.h b/src/property_list_service.h
index 3c9e14d..0e9e948 100644
--- a/src/property_list_service.h
+++ b/src/property_list_service.h
@@ -22,6 +22,7 @@
#ifndef __PROPERTY_LIST_SERVICE_H
#define __PROPERTY_LIST_SERVICE_H
+#include "idevice.h"
#include "libimobiledevice/property_list_service.h"
#include "service.h"
diff --git a/src/restore.c b/src/restore.c
index 591fd16..d13a28a 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -111,7 +111,7 @@ static restored_error_t restored_error(property_list_service_error_t err)
return RESTORE_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API restored_error_t restored_client_free(restored_client_t client)
+restored_error_t restored_client_free(restored_client_t client)
{
if (!client)
return RESTORE_E_INVALID_ARG;
@@ -139,7 +139,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_client_free(restored_client_t cli
return ret;
}
-LIBIMOBILEDEVICE_API void restored_client_set_label(restored_client_t client, const char *label)
+void restored_client_set_label(restored_client_t client, const char *label)
{
if (client) {
if (client->label)
@@ -149,7 +149,7 @@ LIBIMOBILEDEVICE_API void restored_client_set_label(restored_client_t client, co
}
}
-LIBIMOBILEDEVICE_API restored_error_t restored_receive(restored_client_t client, plist_t *plist)
+restored_error_t restored_receive(restored_client_t client, plist_t *plist)
{
if (!client || !plist || (plist && *plist))
return RESTORE_E_INVALID_ARG;
@@ -157,7 +157,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_receive(restored_client_t client,
return restored_error(property_list_service_receive_plist(client->parent, plist));
}
-LIBIMOBILEDEVICE_API restored_error_t restored_send(restored_client_t client, plist_t plist)
+restored_error_t restored_send(restored_client_t client, plist_t plist)
{
if (!client || !plist)
return RESTORE_E_INVALID_ARG;
@@ -165,7 +165,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_send(restored_client_t client, pl
return restored_error(property_list_service_send_xml_plist(client->parent, plist));
}
-LIBIMOBILEDEVICE_API restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version)
+restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version)
{
if (!client)
return RESTORE_E_INVALID_ARG;
@@ -224,7 +224,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_query_type(restored_client_t clie
return ret;
}
-LIBIMOBILEDEVICE_API restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value)
+restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value)
{
if (!client || !key)
return RESTORE_E_INVALID_ARG;
@@ -266,7 +266,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_query_value(restored_client_t cli
return ret;
}
-LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value)
+restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value)
{
plist_t item;
@@ -287,11 +287,11 @@ LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t clien
}
*value = plist_copy(item);
- free(item);
+
return RESTORE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label)
+restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label)
{
if (!client)
return RESTORE_E_INVALID_ARG;
@@ -335,7 +335,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, rest
return ret;
}
-LIBIMOBILEDEVICE_API restored_error_t restored_goodbye(restored_client_t client)
+restored_error_t restored_goodbye(restored_client_t client)
{
if (!client)
return RESTORE_E_INVALID_ARG;
@@ -367,7 +367,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_goodbye(restored_client_t client)
return ret;
}
-LIBIMOBILEDEVICE_API restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version)
+restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version)
{
if (!client)
return RESTORE_E_INVALID_ARG;
@@ -391,7 +391,7 @@ LIBIMOBILEDEVICE_API restored_error_t restored_start_restore(restored_client_t c
return ret;
}
-LIBIMOBILEDEVICE_API restored_error_t restored_reboot(restored_client_t client)
+restored_error_t restored_reboot(restored_client_t client)
{
if (!client)
return RESTORE_E_INVALID_ARG;
diff --git a/src/restore.h b/src/restore.h
index 646d1d1..ec6fa04 100644
--- a/src/restore.h
+++ b/src/restore.h
@@ -24,6 +24,7 @@
#include <string.h>
+#include "idevice.h"
#include "libimobiledevice/restore.h"
#include "property_list_service.h"
diff --git a/src/reverse_proxy.c b/src/reverse_proxy.c
index 3f0a839..2fcfdd1 100644
--- a/src/reverse_proxy.c
+++ b/src/reverse_proxy.c
@@ -25,6 +25,9 @@
#endif
#include <string.h>
#include <stdlib.h>
+#define _GNU_SOURCE 1
+#define __USE_GNU 1
+#include <stdio.h>
#include <errno.h>
#include <plist/plist.h>
@@ -91,7 +94,7 @@ static void _reverse_proxy_log(reverse_proxy_client_t client, const char* format
va_list args;
va_start(args, format);
char* buffer = NULL;
- (void)vasprintf(&buffer, format, args);
+ if(vasprintf(&buffer, format, args)<0){}
va_end(args);
client->log_cb(client, buffer, client->log_cb_user_data);
free(buffer);
@@ -113,7 +116,7 @@ static void _reverse_proxy_status(reverse_proxy_client_t client, int status, con
va_list args;
va_start(args, format);
char* buffer = NULL;
- (void)vasprintf(&buffer, format, args);
+ if(vasprintf(&buffer, format, args)<0){}
va_end(args);
client->status_cb(client, status, buffer, client->status_cb_user_data);
free(buffer);
@@ -186,10 +189,10 @@ static int _reverse_proxy_handle_proxy_cmd(reverse_proxy_client_t client)
/* else wait for messages and forward them */
int sockfd = socket_connect(host, port);
- free(host);
if (sockfd < 0) {
free(buf);
_reverse_proxy_log(client, "ERROR: Connection to %s:%u failed: %s", host, port, strerror(errno));
+ free(host);
return -1;
}
@@ -259,6 +262,7 @@ static int _reverse_proxy_handle_proxy_cmd(reverse_proxy_client_t client)
}
}
socket_close(sockfd);
+ free(host);
free(buf);
_reverse_proxy_status(client, RP_STATUS_DISCONNECTED, "Disconnected (out: %u / in: %u)", sent_total, recv_total);
@@ -524,7 +528,7 @@ static void* _reverse_proxy_control_thread(void *cdata)
return NULL;
}
-LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_start_proxy(reverse_proxy_client_t client, int control_protocol_version)
+reverse_proxy_error_t reverse_proxy_client_start_proxy(reverse_proxy_client_t client, int control_protocol_version)
{
char buf[16] = {0, };
uint32_t bytes = 0;
@@ -603,7 +607,7 @@ LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_start_proxy(reve
return err;
}
-LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_service(idevice_t device, reverse_proxy_client_t* client, const char* label)
+reverse_proxy_error_t reverse_proxy_client_create_with_service(idevice_t device, reverse_proxy_client_t* client, const char* label)
{
reverse_proxy_error_t err = REVERSE_PROXY_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, "com.apple.PurpleReverseProxy.Ctrl", (void**)client, label, SERVICE_CONSTRUCTOR(reverse_proxy_client_new), &err);
@@ -616,7 +620,7 @@ LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_serv
return REVERSE_PROXY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_port(idevice_t device, reverse_proxy_client_t* client, uint16_t device_port)
+reverse_proxy_error_t reverse_proxy_client_create_with_port(idevice_t device, reverse_proxy_client_t* client, uint16_t device_port)
{
reverse_proxy_client_t client_loc = NULL;
reverse_proxy_error_t err;
@@ -637,7 +641,7 @@ LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_port
return REVERSE_PROXY_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_free(reverse_proxy_client_t client)
+reverse_proxy_error_t reverse_proxy_client_free(reverse_proxy_client_t client)
{
if (!client)
return REVERSE_PROXY_E_INVALID_ARG;
@@ -656,14 +660,14 @@ LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_free(reverse_pro
return err;
}
-LIBIMOBILEDEVICE_API reverse_proxy_client_type_t reverse_proxy_get_type(reverse_proxy_client_t client)
+reverse_proxy_client_type_t reverse_proxy_get_type(reverse_proxy_client_t client)
{
if (!client)
return 0;
return client->type;
}
-LIBIMOBILEDEVICE_API void reverse_proxy_client_set_status_callback(reverse_proxy_client_t client, reverse_proxy_status_cb_t status_callback, void* user_data)
+void reverse_proxy_client_set_status_callback(reverse_proxy_client_t client, reverse_proxy_status_cb_t status_callback, void* user_data)
{
if (!client) {
return;
@@ -672,7 +676,7 @@ LIBIMOBILEDEVICE_API void reverse_proxy_client_set_status_callback(reverse_proxy
client->status_cb_user_data = user_data;
}
-LIBIMOBILEDEVICE_API void reverse_proxy_client_set_log_callback(reverse_proxy_client_t client, reverse_proxy_log_cb_t log_callback, void* user_data)
+void reverse_proxy_client_set_log_callback(reverse_proxy_client_t client, reverse_proxy_log_cb_t log_callback, void* user_data)
{
if (!client) {
return;
@@ -681,7 +685,7 @@ LIBIMOBILEDEVICE_API void reverse_proxy_client_set_log_callback(reverse_proxy_cl
client->log_cb_user_data = user_data;
}
-LIBIMOBILEDEVICE_API void reverse_proxy_client_set_data_callback(reverse_proxy_client_t client, reverse_proxy_data_cb_t data_callback, void* user_data)
+void reverse_proxy_client_set_data_callback(reverse_proxy_client_t client, reverse_proxy_data_cb_t data_callback, void* user_data)
{
if (!client) {
return;
diff --git a/src/reverse_proxy.h b/src/reverse_proxy.h
index 17eabac..7f441bd 100644
--- a/src/reverse_proxy.h
+++ b/src/reverse_proxy.h
@@ -22,6 +22,7 @@
#ifndef __REVERSE_PROXY_H
#define __REVERSE_PROXY_H
+#include "idevice.h"
#include "libimobiledevice/reverse_proxy.h"
#include "service.h"
diff --git a/src/sbservices.c b/src/sbservices.c
index ccb7c4b..365e130 100644
--- a/src/sbservices.c
+++ b/src/sbservices.c
@@ -79,7 +79,7 @@ static sbservices_error_t sbservices_error(property_list_service_error_t err)
return SBSERVICES_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client)
+sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client)
{
property_list_service_client_t plistclient = NULL;
sbservices_error_t err = sbservices_error(property_list_service_client_new(device, service, &plistclient));
@@ -95,14 +95,14 @@ LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_new(idevice_t device,
return SBSERVICES_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t * client, const char* label)
+sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t * client, const char* label)
{
sbservices_error_t err = SBSERVICES_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, SBSERVICES_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(sbservices_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_free(sbservices_client_t client)
+sbservices_error_t sbservices_client_free(sbservices_client_t client)
{
if (!client)
return SBSERVICES_E_INVALID_ARG;
@@ -115,7 +115,7 @@ LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_free(sbservices_client
return err;
}
-LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version)
+sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version)
{
if (!client || !client->parent || !state)
return SBSERVICES_E_INVALID_ARG;
@@ -155,7 +155,7 @@ leave_unlock:
return res;
}
-LIBIMOBILEDEVICE_API sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate)
+sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate)
{
if (!client || !client->parent || !newstate)
return SBSERVICES_E_INVALID_ARG;
@@ -172,7 +172,10 @@ LIBIMOBILEDEVICE_API sbservices_error_t sbservices_set_icon_state(sbservices_cli
if (res != SBSERVICES_E_SUCCESS) {
debug_info("could not send plist, error %d", res);
}
- /* NO RESPONSE */
+
+ uint32_t bytes = 0;
+ service_receive_with_timeout(client->parent->parent, malloc(4), 4, &bytes, 2000);
+ debug_info("setIconState response: %u", bytes);
if (dict) {
plist_free(dict);
@@ -181,7 +184,7 @@ LIBIMOBILEDEVICE_API sbservices_error_t sbservices_set_icon_state(sbservices_cli
return res;
}
-LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize)
+sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize)
{
if (!client || !client->parent || !bundleId || !pngdata)
return SBSERVICES_E_INVALID_ARG;
@@ -218,7 +221,7 @@ leave_unlock:
return res;
}
-LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation)
+sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation)
{
if (!client || !client->parent || !interface_orientation)
return SBSERVICES_E_INVALID_ARG;
@@ -256,7 +259,7 @@ leave_unlock:
return res;
}
-LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize)
+sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize)
{
if (!client || !client->parent || !pngdata)
return SBSERVICES_E_INVALID_ARG;
diff --git a/src/sbservices.h b/src/sbservices.h
index 39d822c..b67281e 100644
--- a/src/sbservices.h
+++ b/src/sbservices.h
@@ -22,6 +22,7 @@
#ifndef __SBSERVICES_H
#define __SBSERVICES_H
+#include "idevice.h"
#include "libimobiledevice/sbservices.h"
#include "property_list_service.h"
#include <libimobiledevice-glue/thread.h>
diff --git a/src/screenshotr.c b/src/screenshotr.c
index 77835da..c3cc9ba 100644
--- a/src/screenshotr.c
+++ b/src/screenshotr.c
@@ -65,7 +65,7 @@ static screenshotr_error_t screenshotr_error(device_link_service_error_t err)
return SCREENSHOTR_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service,
+screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service,
screenshotr_client_t * client)
{
if (!device || !service || service->port == 0 || !client || *client)
@@ -93,14 +93,14 @@ LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_new(idevice_t device
return ret;
}
-LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t * client, const char* label)
+screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t * client, const char* label)
{
screenshotr_error_t err = SCREENSHOTR_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, SCREENSHOTR_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(screenshotr_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_free(screenshotr_client_t client)
+screenshotr_error_t screenshotr_client_free(screenshotr_client_t client)
{
if (!client)
return SCREENSHOTR_E_INVALID_ARG;
@@ -110,7 +110,7 @@ LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_free(screenshotr_cli
return err;
}
-LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize)
+screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize)
{
if (!client || !client->parent || !imgdata)
return SCREENSHOTR_E_INVALID_ARG;
diff --git a/src/screenshotr.h b/src/screenshotr.h
index 47d4e42..1319ec0 100644
--- a/src/screenshotr.h
+++ b/src/screenshotr.h
@@ -22,6 +22,7 @@
#ifndef __SCREENSHOTR_H
#define __SCREENSHOTR_H
+#include "idevice.h"
#include "libimobiledevice/screenshotr.h"
#include "device_link_service.h"
diff --git a/src/service.c b/src/service.c
index 6c9d109..9474021 100644
--- a/src/service.c
+++ b/src/service.c
@@ -56,7 +56,7 @@ static service_error_t idevice_to_service_error(idevice_error_t err)
return SERVICE_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client)
+service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client)
{
if (!device || !service || service->port == 0 || !client || *client)
return SERVICE_E_INVALID_ARG;
@@ -80,7 +80,7 @@ LIBIMOBILEDEVICE_API service_error_t service_client_new(idevice_t device, lockdo
return SERVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code)
+service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code)
{
*client = NULL;
@@ -119,7 +119,7 @@ LIBIMOBILEDEVICE_API service_error_t service_client_factory_start_service(idevic
return (ec == SERVICE_E_SUCCESS) ? SERVICE_E_SUCCESS : SERVICE_E_START_SERVICE_ERROR;
}
-LIBIMOBILEDEVICE_API service_error_t service_client_free(service_client_t client)
+service_error_t service_client_free(service_client_t client)
{
if (!client)
return SERVICE_E_INVALID_ARG;
@@ -132,7 +132,7 @@ LIBIMOBILEDEVICE_API service_error_t service_client_free(service_client_t client
return err;
}
-LIBIMOBILEDEVICE_API service_error_t service_send(service_client_t client, const char* data, uint32_t size, uint32_t *sent)
+service_error_t service_send(service_client_t client, const char* data, uint32_t size, uint32_t *sent)
{
service_error_t res = SERVICE_E_UNKNOWN_ERROR;
uint32_t bytes = 0;
@@ -153,7 +153,7 @@ LIBIMOBILEDEVICE_API service_error_t service_send(service_client_t client, const
return res;
}
-LIBIMOBILEDEVICE_API service_error_t service_receive_with_timeout(service_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
+service_error_t service_receive_with_timeout(service_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
{
service_error_t res = SERVICE_E_UNKNOWN_ERROR;
uint32_t bytes = 0;
@@ -174,31 +174,31 @@ LIBIMOBILEDEVICE_API service_error_t service_receive_with_timeout(service_client
return res;
}
-LIBIMOBILEDEVICE_API service_error_t service_receive(service_client_t client, char* data, uint32_t size, uint32_t *received)
+service_error_t service_receive(service_client_t client, char* data, uint32_t size, uint32_t *received)
{
return service_receive_with_timeout(client, data, size, received, 30000);
}
-LIBIMOBILEDEVICE_API service_error_t service_enable_ssl(service_client_t client)
+service_error_t service_enable_ssl(service_client_t client)
{
if (!client || !client->connection)
return SERVICE_E_INVALID_ARG;
return idevice_to_service_error(idevice_connection_enable_ssl(client->connection));
}
-LIBIMOBILEDEVICE_API service_error_t service_disable_ssl(service_client_t client)
+service_error_t service_disable_ssl(service_client_t client)
{
return service_disable_bypass_ssl(client, 0);
}
-LIBIMOBILEDEVICE_API service_error_t service_disable_bypass_ssl(service_client_t client, uint8_t sslBypass)
+service_error_t service_disable_bypass_ssl(service_client_t client, uint8_t sslBypass)
{
if (!client || !client->connection)
return SERVICE_E_INVALID_ARG;
return idevice_to_service_error(idevice_connection_disable_bypass_ssl(client->connection, sslBypass));
}
-LIBIMOBILEDEVICE_API service_error_t service_get_connection(service_client_t client, idevice_connection_t *connection)
+service_error_t service_get_connection(service_client_t client, idevice_connection_t *connection)
{
if (!client || !client->connection || !connection)
return SERVICE_E_INVALID_ARG;
diff --git a/src/service.h b/src/service.h
index 3fc3077..071fe3f 100644
--- a/src/service.h
+++ b/src/service.h
@@ -21,9 +21,9 @@
#ifndef SERVICE_H
#define SERVICE_H
+#include "idevice.h"
#include "libimobiledevice/service.h"
#include "libimobiledevice/lockdown.h"
-#include "idevice.h"
struct service_client_private {
idevice_connection_t connection;
diff --git a/src/syslog_relay.c b/src/syslog_relay.c
index ec9eca5..9f4296e 100644
--- a/src/syslog_relay.c
+++ b/src/syslog_relay.c
@@ -67,7 +67,7 @@ static syslog_relay_error_t syslog_relay_error(service_error_t err)
return SYSLOG_RELAY_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client)
+syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client)
{
*client = NULL;
@@ -95,14 +95,14 @@ LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_new(idevice_t devi
return 0;
}
-LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label)
+syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label)
{
syslog_relay_error_t err = SYSLOG_RELAY_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, SYSLOG_RELAY_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(syslog_relay_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client)
+syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client)
{
if (!client)
return SYSLOG_RELAY_E_INVALID_ARG;
@@ -113,12 +113,12 @@ LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_free(syslog_relay_
return err;
}
-LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received)
+syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received)
{
return syslog_relay_receive_with_timeout(client, data, size, received, 1000);
}
-LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
+syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
{
syslog_relay_error_t res = SYSLOG_RELAY_E_UNKNOWN_ERROR;
int bytes = 0;
@@ -175,7 +175,7 @@ void *syslog_relay_worker(void *arg)
return NULL;
}
-LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data)
+syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data)
{
if (!client || !callback)
return SYSLOG_RELAY_E_INVALID_ARG;
@@ -203,7 +203,7 @@ LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture(syslog_rela
return res;
}
-LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture_raw(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data)
+syslog_relay_error_t syslog_relay_start_capture_raw(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data)
{
if (!client || !callback)
return SYSLOG_RELAY_E_INVALID_ARG;
@@ -231,7 +231,7 @@ LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture_raw(syslog_
return res;
}
-LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client)
+syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client)
{
if (client->worker) {
/* notify thread to finish */
diff --git a/src/syslog_relay.h b/src/syslog_relay.h
index 86d798e..d5263e2 100644
--- a/src/syslog_relay.h
+++ b/src/syslog_relay.h
@@ -22,6 +22,7 @@
#ifndef _SYSLOG_RELAY_H
#define _SYSLOG_RELAY_H
+#include "idevice.h"
#include "libimobiledevice/syslog_relay.h"
#include "service.h"
#include <libimobiledevice-glue/thread.h>
diff --git a/src/webinspector.c b/src/webinspector.c
index 3360597..f960fcc 100644
--- a/src/webinspector.c
+++ b/src/webinspector.c
@@ -62,7 +62,7 @@ static webinspector_error_t webinspector_error(property_list_service_error_t err
return WEBINSPECTOR_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client)
+webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client)
{
*client = NULL;
@@ -89,14 +89,14 @@ LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_new(idevice_t devi
return 0;
}
-LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label)
+webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label)
{
webinspector_error_t err = WEBINSPECTOR_E_UNKNOWN_ERROR;
service_client_factory_start_service(device, WEBINSPECTOR_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(webinspector_client_new), &err);
return err;
}
-LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_free(webinspector_client_t client)
+webinspector_error_t webinspector_client_free(webinspector_client_t client)
{
if (!client)
return WEBINSPECTOR_E_INVALID_ARG;
@@ -107,7 +107,7 @@ LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_free(webinspector_
return err;
}
-LIBIMOBILEDEVICE_API webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist)
+webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist)
{
webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR;
@@ -164,12 +164,12 @@ LIBIMOBILEDEVICE_API webinspector_error_t webinspector_send(webinspector_client_
return res;
}
-LIBIMOBILEDEVICE_API webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist)
+webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist)
{
return webinspector_receive_with_timeout(client, plist, 5000);
}
-LIBIMOBILEDEVICE_API webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms)
+webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms)
{
webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR;
plist_t message = NULL;
diff --git a/src/webinspector.h b/src/webinspector.h
index 67421bc..d249c58 100644
--- a/src/webinspector.h
+++ b/src/webinspector.h
@@ -22,6 +22,7 @@
#ifndef __WEBINSPECTOR_H
#define __WEBINSPECTOR_H
+#include "idevice.h"
#include "libimobiledevice/webinspector.h"
#include "property_list_service.h"
diff --git a/tools/Makefile.am b/tools/Makefile.am
index e8ef3ab..4cac1fc 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -4,6 +4,7 @@ AM_CPPFLAGS = \
AM_CFLAGS = \
$(GLOBAL_CFLAGS) \
+ $(ssl_lib_CFLAGS) \
$(libplist_CFLAGS) \
$(LFS_CFLAGS)
@@ -27,9 +28,11 @@ bin_PROGRAMS = \
idevicedebugserverproxy \
idevicediagnostics \
idevicedebug \
+ idevicedevmodectl \
idevicenotificationproxy \
idevicecrashreport \
- idevicesetlocation
+ idevicesetlocation \
+ afcclient
idevicebtlogger_SOURCES = idevicebtlogger.c
iidevicebtlogger_CFLAGS = $(AM_CFLAGS)
@@ -47,7 +50,7 @@ idevicename_LDFLAGS = $(AM_LDFLAGS)
idevicename_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la
idevicepair_SOURCES = idevicepair.c
-idevicepair_CFLAGS = $(AM_CFLAGS) $(ssl_lib_CFLAGS)
+idevicepair_CFLAGS = $(AM_CFLAGS)
idevicepair_LDFLAGS = $(AM_LDFLAGS) $(libusbmuxd_LIBS) $(ssl_lib_LIBS)
idevicepair_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la $(limd_glue_LIBS)
@@ -62,7 +65,7 @@ idevice_id_LDFLAGS = $(AM_LDFLAGS)
idevice_id_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la
idevicebackup_SOURCES = idevicebackup.c
-idevicebackup_CFLAGS = $(AM_CFLAGS) $(ssl_lib_CFLAGS) $(limd_glue_CFLAGS)
+idevicebackup_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS)
idevicebackup_LDFLAGS = $(AM_LDFLAGS) $(ssl_lib_LIBS) $(limd_glue_LIBS)
idevicebackup_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la
@@ -111,6 +114,11 @@ idevicedebug_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS)
idevicedebug_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS)
idevicedebug_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la
+idevicedevmodectl_SOURCES = idevicedevmodectl.c
+idevicedevmodectl_CFLAGS = $(AM_CFLAGS) $(limd_glue_CFLAGS)
+idevicedevmodectl_LDFLAGS = $(AM_LDFLAGS) $(limd_glue_LIBS)
+idevicedevmodectl_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(top_builddir)/common/libinternalcommon.la
+
idevicenotificationproxy_SOURCES = idevicenotificationproxy.c
idevicenotificationproxy_CFLAGS = $(AM_CFLAGS)
idevicenotificationproxy_LDFLAGS = $(AM_LDFLAGS)
@@ -125,3 +133,12 @@ idevicesetlocation_SOURCES = idevicesetlocation.c
idevicesetlocation_CFLAGS = $(AM_CFLAGS)
idevicesetlocation_LDFLAGS = $(AM_LDFLAGS)
idevicesetlocation_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la
+
+afcclient_SOURCES = afcclient.c
+afcclient_CFLAGS = $(AM_CFLAGS)
+afcclient_LDFLAGS = $(AM_LDFLAGS)
+if HAVE_READLINE
+ afcclient_CFLAGS += $(readline_CFLAGS)
+ afcclient_LDFLAGS += $(readline_LIBS)
+endif
+afcclient_LDADD = $(top_builddir)/src/libimobiledevice-1.0.la $(limd_glue_LIBS)
diff --git a/tools/afcclient.c b/tools/afcclient.c
new file mode 100644
index 0000000..9bcd77b
--- /dev/null
+++ b/tools/afcclient.c
@@ -0,0 +1,1346 @@
+/*
+ * afcclient.c
+ * Utility to interact with AFC/HoustArrest service on the device
+ *
+ * Inspired by https://github.com/emonti/afcclient
+ * But entirely rewritten from scratch.
+ *
+ * Copyright (c) 2023 Nikias Bassen, All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define TOOL_NAME "afcclient"
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <signal.h>
+#include <ctype.h>
+#include <unistd.h>
+
+#ifdef WIN32
+#include <windows.h>
+#include <sys/time.h>
+#include <conio.h>
+#define sleep(x) Sleep(x*1000)
+#define S_IFMT 0170000 /* [XSI] type of file mask */
+#define S_IFIFO 0010000 /* [XSI] named pipe (fifo) */
+#define S_IFCHR 0020000 /* [XSI] character special */
+#define S_IFBLK 0060000 /* [XSI] block special */
+#define S_IFLNK 0120000 /* [XSI] symbolic link */
+#define S_IFSOCK 0140000 /* [XSI] socket */
+#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) /* block special */
+#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* char special */
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* fifo or socket */
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* symbolic link */
+#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) /* socket */
+#else
+#include <sys/time.h>
+#include <termios.h>
+#endif
+
+#ifdef HAVE_READLINE
+#include <readline/readline.h>
+#include <readline/history.h>
+#endif
+
+#include <libimobiledevice/libimobiledevice.h>
+#include <libimobiledevice/lockdown.h>
+#include <libimobiledevice/house_arrest.h>
+#include <libimobiledevice/afc.h>
+#include <plist/plist.h>
+
+#include <libimobiledevice-glue/termcolors.h>
+
+#undef st_mtime
+#undef st_birthtime
+struct afc_file_stat {
+ uint16_t st_mode;
+ uint16_t st_nlink;
+ uint64_t st_size;
+ uint64_t st_mtime;
+ uint64_t st_birthtime;
+ uint32_t st_blocks;
+};
+
+static char* udid = NULL;
+static int connected = 0;
+static int use_network = 0;
+static idevice_subscription_context_t context = NULL;
+static char* curdir = NULL;
+static size_t curdir_len = 0;
+
+static void print_usage(int argc, char **argv, int is_error)
+{
+ char *name = strrchr(argv[0], '/');
+ fprintf(is_error ? stderr : stdout, "Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0]));
+ fprintf(is_error ? stderr : stdout,
+ "\n"
+ "Interact with AFC/HouseArrest service on a connected device.\n"
+ "\n"
+ "OPTIONS:\n"
+ " -u, --udid UDID target specific device by UDID\n"
+ " -n, --network connect to network device (not recommended!)\n"
+ " --container <appid> Access container of given app\n"
+ " --documents <appid> Access Documents directory of given app\n"
+ " -h, --help prints usage information\n" \
+ " -d, --debug enable communication debugging\n" \
+ " -v, --version prints version information\n" \
+ "\n"
+ );
+ fprintf(is_error ? stderr : stdout,
+ "\n" \
+ "Homepage: <" PACKAGE_URL ">\n"
+ "Bug Reports: <" PACKAGE_BUGREPORT ">\n"
+ );
+}
+
+#ifndef HAVE_READLINE
+#ifdef WIN32
+#define BS_CC '\b'
+#else
+#define BS_CC 0x7f
+#define getch getchar
+#endif
+static void get_input(char *buf, int maxlen)
+{
+ int len = 0;
+ int c;
+
+ while ((c = getch())) {
+ if ((c == '\r') || (c == '\n')) {
+ break;
+ }
+ if (isprint(c)) {
+ if (len < maxlen-1)
+ buf[len++] = c;
+ } else if (c == BS_CC) {
+ if (len > 0) {
+ fputs("\b \b", stdout);
+ len--;
+ }
+ }
+ }
+ buf[len] = 0;
+}
+#endif
+
+#define OPT_DOCUMENTS 1
+#define OPT_CONTAINER 2
+
+int stop_requested = 0;
+
+static void handle_signal(int sig)
+{
+ stop_requested++;
+#ifdef WIN32
+ GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
+#else
+ kill(getpid(), SIGINT);
+#endif
+}
+
+static void handle_help(afc_client_t afc, int argc, char** argv)
+{
+ printf("Available commands:\n");
+ printf("help - print list of available commands\n");
+ printf("devinfo - print device information\n");
+ printf("info PATH - print file attributes of file at PATH\n");
+ printf("ls [-l] PATH - print directory contents of PATH\n");
+ printf("mv OLD NEW - rename file OLD to NEW\n");
+ printf("mkdir PATH - create directory at PATH\n");
+ printf("ln [-s] FILE [LINK] - create a (symbolic) link to file named LINKNAME\n");
+ printf(" NOTE: This feature has been disabled in newer versions of iOS.\n");
+ printf("rm PATH - remove item at PATH\n");
+ printf("get PATH [LOCALPATH] - transfer file at PATH from device to LOCALPATH\n");
+ printf("put LOCALPATH [PATH] - transfer local file at LOCALPATH to device at PATH\n");
+ printf("\n");
+}
+
+static const char* path_get_basename(const char* path)
+{
+ const char *p = strrchr(path, '/');
+ return p ? p + 1 : path;
+}
+
+static int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
+{
+ /* Perform the carry for the later subtraction by updating y. */
+ if (x->tv_usec < y->tv_usec) {
+ int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
+ y->tv_usec -= 1000000 * nsec;
+ y->tv_sec += nsec;
+ }
+ if (x->tv_usec - y->tv_usec > 1000000) {
+ int nsec = (x->tv_usec - y->tv_usec) / 1000000;
+ y->tv_usec += 1000000 * nsec;
+ y->tv_sec -= nsec;
+ }
+ /* Compute the time remaining to wait.
+ tv_usec is certainly positive. */
+ result->tv_sec = x->tv_sec - y->tv_sec;
+ result->tv_usec = x->tv_usec - y->tv_usec;
+ /* Return 1 if result is negative. */
+ return x->tv_sec < y->tv_sec;
+}
+
+struct str_item {
+ size_t len;
+ char* str;
+};
+
+static char* get_absolute_path(const char *path)
+{
+ if (*path == '/') {
+ return strdup(path);
+ } else {
+ size_t len = curdir_len + 1 + strlen(path) + 1;
+ char* result = (char*)malloc(len);
+ if (!strcmp(curdir, "/")) {
+ snprintf(result, len, "/%s", path);
+ } else {
+ snprintf(result, len, "%s/%s", curdir, path);
+ }
+ return result;
+ }
+}
+
+static char* get_realpath(const char* path)
+{
+ if (!path) return NULL;
+
+ int is_absolute = 0;
+ if (*path == '/') {
+ is_absolute = 1;
+ }
+
+ const char* p = path;
+ if (is_absolute) {
+ while (*p == '/') p++;
+ }
+ if (*p == '\0') {
+ return strdup("/");
+ }
+
+ int c_count = 1;
+ const char* start = p;
+ const char* end = p;
+ struct str_item* comps = NULL;
+
+ while (*p) {
+ if (*p == '/') {
+ p++;
+ end = p-1;
+ while (*p == '/') p++;
+ if (*p == '\0') break;
+ struct str_item* newcomps = (struct str_item*)realloc(comps, sizeof(struct str_item)*c_count);
+ if (!newcomps) {
+ free(comps);
+ printf("%s: out of memory?!\n", __func__);
+ return NULL;
+ }
+ comps = newcomps;
+ char *comp = (char*)malloc(end-start+1);
+ strncpy(comp, start, end-start);
+ comp[end-start] = '\0';
+ comps[c_count-1].len = end-start;
+ comps[c_count-1].str = comp;
+ c_count++;
+ start = p;
+ end = p;
+ }
+ p++;
+ }
+ if (p > start) {
+ if (start == end) {
+ end = p;
+ }
+ struct str_item* newcomps = (struct str_item*)realloc(comps, sizeof(struct str_item)*c_count);
+ if (!newcomps) {
+ free(comps);
+ printf("%s: out of memory?!\n", __func__);
+ return NULL;
+ }
+ comps = newcomps;
+ char *comp = (char*)malloc(end-start+1);
+ strncpy(comp, start, end-start);
+ comp[end-start] = '\0';
+ comps[c_count-1].len = end-start;
+ comps[c_count-1].str = comp;
+ }
+
+ struct str_item* comps_final = (struct str_item*)malloc(sizeof(struct str_item)*(c_count+1));
+ int o = 1;
+ if (is_absolute) {
+ comps_final[0].len = 1;
+ comps_final[0].str = (char*)"/";
+ } else {
+ comps_final[0].len = curdir_len;
+ comps_final[0].str = curdir;
+ }
+ size_t o_len = comps_final[0].len;
+
+ for (int i = 0; i < c_count; i++) {
+ if (!strcmp(comps[i].str, "..")) {
+ o--;
+ continue;
+ } else if (!strcmp(comps[i].str, ".")) {
+ continue;
+ }
+ o_len += comps[i].len;
+ comps_final[o].str = comps[i].str;
+ comps_final[o].len = comps[i].len;
+ o++;
+ }
+
+ o_len += o;
+ char* result = (char*)malloc(o_len);
+ char* presult = result;
+ for (int i = 0; i < o; i++) {
+ if (i > 0 && strcmp(comps_final[i-1].str, "/") != 0) {
+ *presult = '/';
+ presult++;
+ }
+ strncpy(presult, comps_final[i].str, comps_final[i].len);
+ presult+=comps_final[i].len;
+ *presult = '\0';
+ }
+ if (presult == result) {
+ *presult = '/';
+ presult++;
+ *presult = 0;
+ }
+
+ for (int i = 0; i < c_count; i++) {
+ free(comps[i].str);
+ }
+ free(comps);
+ free(comps_final);
+
+ return result;
+}
+
+static void handle_devinfo(afc_client_t afc, int argc, char** argv)
+{
+ char **info = NULL;
+ afc_error_t err = afc_get_device_info(afc, &info);
+ if (err == AFC_E_SUCCESS && info) {
+ int i;
+ for (i = 0; info[i]; i += 2) {
+ printf("%s: %s\n", info[i], info[i+1]);
+ }
+ } else {
+ printf("Error: Failed to get device info: %s (%d)\n", afc_strerror(err), err);
+ }
+ afc_dictionary_free(info);
+}
+
+static int get_file_info_stat(afc_client_t afc, const char* path, struct afc_file_stat *stbuf)
+{
+ char **info = NULL;
+ afc_error_t ret = afc_get_file_info(afc, path, &info);
+ memset(stbuf, 0, sizeof(struct afc_file_stat));
+ if (ret != AFC_E_SUCCESS) {
+ return -1;
+ } else if (!info) {
+ return -1;
+ } else {
+ // get file attributes from info list
+ int i;
+ for (i = 0; info[i]; i += 2) {
+ if (!strcmp(info[i], "st_size")) {
+ stbuf->st_size = atoll(info[i+1]);
+ } else if (!strcmp(info[i], "st_blocks")) {
+ stbuf->st_blocks = atoi(info[i+1]);
+ } else if (!strcmp(info[i], "st_ifmt")) {
+ if (!strcmp(info[i+1], "S_IFREG")) {
+ stbuf->st_mode = S_IFREG;
+ } else if (!strcmp(info[i+1], "S_IFDIR")) {
+ stbuf->st_mode = S_IFDIR;
+ } else if (!strcmp(info[i+1], "S_IFLNK")) {
+ stbuf->st_mode = S_IFLNK;
+ } else if (!strcmp(info[i+1], "S_IFBLK")) {
+ stbuf->st_mode = S_IFBLK;
+ } else if (!strcmp(info[i+1], "S_IFCHR")) {
+ stbuf->st_mode = S_IFCHR;
+ } else if (!strcmp(info[i+1], "S_IFIFO")) {
+ stbuf->st_mode = S_IFIFO;
+ } else if (!strcmp(info[i+1], "S_IFSOCK")) {
+ stbuf->st_mode = S_IFSOCK;
+ }
+ } else if (!strcmp(info[i], "st_nlink")) {
+ stbuf->st_nlink = atoi(info[i+1]);
+ } else if (!strcmp(info[i], "st_mtime")) {
+ stbuf->st_mtime = (time_t)(atoll(info[i+1]) / 1000000000);
+ } else if (!strcmp(info[i], "st_birthtime")) { /* available on iOS 7+ */
+ stbuf->st_birthtime = (time_t)(atoll(info[i+1]) / 1000000000);
+ }
+ }
+ afc_dictionary_free(info);
+ }
+ return 0;
+}
+
+static void handle_file_info(afc_client_t afc, int argc, char** argv)
+{
+ if (argc < 1) {
+ printf("Error: Missing PATH.\n");
+ return;
+ }
+
+ char **info = NULL;
+ char* abspath = get_absolute_path(argv[0]);
+ if (!abspath) {
+ printf("Error: Invalid argument\n");
+ return;
+ }
+ afc_error_t err = afc_get_file_info(afc, abspath, &info);
+ if (err == AFC_E_SUCCESS && info) {
+ int i;
+ for (i = 0; info[i]; i += 2) {
+ printf("%s: %s\n", info[i], info[i+1]);
+ }
+ } else {
+ printf("Error: Failed to get file info for %s: %s (%d)\n", argv[0], afc_strerror(err), err);
+ }
+ afc_dictionary_free(info);
+ free(abspath);
+}
+
+static void print_file_info(afc_client_t afc, const char* path, int list_verbose)
+{
+ struct afc_file_stat st;
+ get_file_info_stat(afc, path, &st);
+ if (list_verbose) {
+ char timebuf[64];
+ time_t t = st.st_mtime;
+ if (S_ISDIR(st.st_mode)) {
+ printf("drwxr-xr-x");
+ } else if (S_ISLNK(st.st_mode)) {
+ printf("lrwxrwxrwx");
+ } else {
+ if (S_ISFIFO(st.st_mode)) {
+ printf("f");
+ } else if (S_ISBLK(st.st_mode)) {
+ printf("b");
+ } else if (S_ISCHR(st.st_mode)) {
+ printf("c");
+ } else if (S_ISSOCK(st.st_mode)) {
+ printf("s");
+ } else {
+ printf("-");
+ }
+ printf("rw-r--r--");
+ }
+ printf(" ");
+ printf("%4d", st.st_nlink);
+ printf(" ");
+ printf("mobile");
+ printf(" ");
+ printf("mobile");
+ printf(" ");
+ printf("%10lld", (long long)st.st_size);
+ printf(" ");
+#ifdef WIN32
+ strftime(timebuf, 64, "%d %b %Y %H:%M:%S", localtime(&t));
+#else
+ strftime(timebuf, 64, "%d %h %Y %H:%M:%S", localtime(&t));
+#endif
+ printf("%s", timebuf);
+ printf(" ");
+ }
+ if (S_ISDIR(st.st_mode)) {
+ cprintf(FG_CYAN);
+ } else if (S_ISLNK(st.st_mode)) {
+ cprintf(FG_MAGENTA);
+ } else if (S_ISREG(st.st_mode)) {
+ cprintf(FG_DEFAULT);
+ } else {
+ cprintf(FG_YELLOW);
+ }
+ cprintf("%s" COLOR_RESET "\n", path_get_basename(path));
+}
+
+static void handle_list(afc_client_t afc, int argc, char** argv)
+{
+ const char* path = NULL;
+ int list_verbose = 0;
+ if (argc < 1) {
+ path = curdir;
+ } else {
+ if (!strcmp(argv[0], "-l")) {
+ list_verbose = 1;
+ if (argc == 2) {
+ path = argv[1];
+ } else {
+ path = curdir;
+ }
+ } else {
+ path = argv[0];
+ }
+ }
+ char* abspath = get_absolute_path(path);
+ if (!abspath) {
+ printf("Error: Invalid argument\n");
+ return;
+ }
+ int abspath_is_root = strcmp(abspath, "/") == 0;
+ size_t abspath_len = (abspath_is_root) ? 0 : strlen(abspath);
+ char** entries = NULL;
+ afc_error_t err = afc_read_directory(afc, abspath, &entries);
+ if (err == AFC_E_READ_ERROR) {
+ print_file_info(afc, abspath, list_verbose);
+ return;
+ } else if (err != AFC_E_SUCCESS) {
+ printf("Error: Failed to list '%s': %s (%d)\n", path, afc_strerror(err), err);
+ free(abspath);
+ return;
+ }
+
+ char** p = entries;
+ while (p && *p) {
+ if (strcmp(".", *p) == 0 || strcmp("..", *p) == 0) {
+ p++;
+ continue;
+ }
+ size_t len = abspath_len + 1 + strlen(*p) + 1;
+ char* testpath = (char*)malloc(len);
+ if (abspath_is_root) {
+ snprintf(testpath, len, "/%s", *p);
+ } else {
+ snprintf(testpath, len, "%s/%s", abspath, *p);
+ }
+ print_file_info(afc, testpath, list_verbose);
+ free(testpath);
+ p++;
+ }
+ afc_dictionary_free(entries);
+ free(abspath);
+}
+
+static void handle_rename(afc_client_t afc, int argc, char** argv)
+{
+ if (argc != 2) {
+ printf("Error: Invalid number of arguments\n");
+ return;
+ }
+ char* srcpath = get_absolute_path(argv[0]);
+ if (!srcpath) {
+ printf("Error: Invalid argument\n");
+ return;
+ }
+ char* dstpath = get_absolute_path(argv[1]);
+ if (!dstpath) {
+ free(srcpath);
+ printf("Error: Invalid argument\n");
+ return;
+ }
+ afc_error_t err = afc_rename_path(afc, srcpath, dstpath);
+ if (err != AFC_E_SUCCESS) {
+ printf("Error: Failed to rename '%s' -> '%s': %s (%d)\n", argv[0], argv[1], afc_strerror(err), err);
+ }
+ free(srcpath);
+ free(dstpath);
+}
+
+static void handle_mkdir(afc_client_t afc, int argc, char** argv)
+{
+ for (int i = 0; i < argc; i++) {
+ char* abspath = get_absolute_path(argv[i]);
+ if (!abspath) {
+ printf("Error: Invalid argument '%s'\n", argv[i]);
+ continue;
+ }
+ afc_error_t err = afc_make_directory(afc, abspath);
+ if (err != AFC_E_SUCCESS) {
+ printf("Error: Failed to create directory '%s': %s (%d)\n", argv[i], afc_strerror(err), err);
+ }
+ free(abspath);
+ }
+}
+
+static void handle_link(afc_client_t afc, int argc, char** argv)
+{
+ if (argc < 2) {
+ printf("Error: Invalid number of arguments\n");
+ return;
+ }
+ afc_link_type_t link_type = AFC_HARDLINK;
+ if (!strcmp(argv[0], "-s")) {
+ argc--;
+ argv++;
+ link_type = AFC_SYMLINK;
+ }
+ if (argc < 1 || argc > 2) {
+ printf("Error: Invalid number of arguments\n");
+ return;
+ }
+ const char *link_name = (argc == 1) ? path_get_basename(argv[0]) : argv[1];
+ char* abs_link_name = get_absolute_path(link_name);
+ if (!abs_link_name) {
+ printf("Error: Invalid argument\n");
+ return;
+ }
+ afc_error_t err = afc_make_link(afc, link_type, argv[0], link_name);
+ if (err != AFC_E_SUCCESS) {
+ printf("Error: Failed to create %s link for '%s' at '%s': %s (%d)\n", (link_type == AFC_HARDLINK) ? "hard" : "symbolic", argv[0], link_name, afc_strerror(err), err);
+ }
+}
+
+static int ask_yesno(const char* prompt)
+{
+ int ret = 0;
+#ifdef HAVE_READLINE
+ char* result = readline(prompt);
+ if (result && result[0] == 'y') {
+ ret = 1;
+ }
+#else
+ char cmdbuf[2] = {0, };
+ printf("%s", prompt);
+ fflush(stdout);
+ get_input(cmdbuf, sizeof(cmdbuf));
+ if (cmdbuf[0] == 'y') {
+ ret = 1;
+ }
+#endif
+#ifdef HAVE_READLINE
+ free(result);
+#endif
+ return ret;
+}
+
+static void handle_remove(afc_client_t afc, int argc, char** argv)
+{
+ int recursive = 0;
+ int force = 0;
+ int i = 0;
+ for (i = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "--")) {
+ i++;
+ break;
+ } else if (!strcmp(argv[i], "-r")) {
+ recursive = 1;
+ } else if (!strcmp(argv[i], "-f")) {
+ force = 1;
+ } else if (!strcmp(argv[i], "-rf") || !strcmp(argv[i], "-fr")) {
+ recursive = 1;
+ force = 1;
+ } else {
+ break;
+ }
+ }
+ if (recursive && !force) {
+ if (!ask_yesno("WARNING: This operation will remove all contents of the given path(s). Continue? [y/N] ")) {
+ printf("Aborted.\n");
+ return;
+ }
+ }
+ for ( ; i < argc; i++) {
+ char* abspath = get_absolute_path(argv[i]);
+ if (!abspath) {
+ printf("Error: Invalid argument '%s'\n", argv[i]);
+ continue;
+ }
+ afc_error_t err;
+ if (recursive) {
+ err = afc_remove_path_and_contents(afc, abspath);
+ } else {
+ err = afc_remove_path(afc, abspath);
+ }
+ if (err != AFC_E_SUCCESS) {
+ printf("Error: Failed to remove '%s': %s (%d)\n", argv[i], afc_strerror(err), err);
+ }
+ free(abspath);
+ }
+}
+
+static void handle_get(afc_client_t afc, int argc, char** argv)
+{
+ if (argc < 1 || argc > 2) {
+ printf("Error: Invalid number of arguments\n");
+ return;
+ }
+ char *srcpath = NULL;
+ char* dstpath = NULL;
+ if (argc == 1) {
+ srcpath = get_absolute_path(argv[0]);
+ dstpath = strdup(path_get_basename(argv[0]));
+ } else {
+ srcpath = get_absolute_path(argv[0]);
+ dstpath = strdup(argv[1]);
+ }
+
+ char **info = NULL;
+ uint64_t file_size = 0;
+ afc_get_file_info(afc, srcpath, &info);
+ if (info) {
+ char **p = info;
+ while (p && *p) {
+ if (!strcmp(*p, "st_size")) {
+ p++;
+ file_size = (uint64_t)strtoull(*p, NULL, 10);
+ break;
+ }
+ p++;
+ }
+ }
+ uint64_t fh = 0;
+ afc_error_t err = afc_file_open(afc, srcpath, AFC_FOPEN_RDONLY, &fh);
+ if (err != AFC_E_SUCCESS) {
+ free(srcpath);
+ free(dstpath);
+ printf("Error: Failed to open file '%s': %s (%d)\n", argv[0], afc_strerror(err), err);
+ return;
+ }
+ FILE *f = fopen(dstpath, "wb");
+ if (!f && errno == EISDIR) {
+ const char* basen = path_get_basename(argv[0]);
+ size_t len = strlen(dstpath) + 1 + strlen(basen) + 1;
+ char* newdst = (char*)malloc(len);
+ snprintf(newdst, len, "%s/%s", dstpath, basen);
+ f = fopen(newdst, "wb");
+ free(newdst);
+ }
+ if (f) {
+ struct timeval t1;
+ struct timeval t2;
+ struct timeval tdiff;
+ size_t bufsize = 0x100000;
+ char* buf = malloc(bufsize);
+ size_t total = 0;
+ int progress = 0;
+ int lastprog = 0;
+ if (file_size > 0x400000) {
+ progress = 1;
+ gettimeofday(&t1, NULL);
+ }
+ while (err == AFC_E_SUCCESS) {
+ uint32_t bytes_read = 0;
+ size_t chunk = 0;
+ err = afc_file_read(afc, fh, buf, bufsize, &bytes_read);
+ if (bytes_read == 0) {
+ break;
+ }
+ while (chunk < bytes_read) {
+ size_t wr = fwrite(buf+chunk, 1, bytes_read-chunk, f);
+ if (wr == 0) {
+ if (progress) {
+ printf("\n");
+ }
+ printf("Error: Failed to write to local file\n");
+ break;
+ }
+ chunk += wr;
+ }
+ total += chunk;
+ if (progress) {
+ int prog = (int)((double)total / (double)file_size * 100.0f);
+ if (prog > lastprog) {
+ gettimeofday(&t2, NULL);
+ timeval_subtract(&tdiff, &t2, &t1);
+ double time_in_sec = (double)tdiff.tv_sec + (double)tdiff.tv_usec/1000000;
+ printf("\r%d%% (%0.1f MB/s) ", prog, (double)total/1048576.0f / time_in_sec);
+ fflush(stdout);
+ lastprog = prog;
+ }
+ }
+ }
+ if (progress) {
+ printf("\n");
+ }
+ if (err != AFC_E_SUCCESS) {
+ printf("Error: Failed to read from file '%s': %s (%d)\n", argv[0], afc_strerror(err), err);
+ }
+ free(buf);
+ fclose(f);
+ } else {
+ printf("Error: Failed to open local file '%s': %s\n", dstpath, strerror(errno));
+ }
+ afc_file_close(afc, fh);
+ free(srcpath);
+}
+
+static void handle_put(afc_client_t afc, int argc, char** argv)
+{
+ if (argc < 1 || argc > 2) {
+ printf("Error: Invalid number of arguments\n");
+ return;
+ }
+
+ char *dstpath = NULL;
+ if (argc == 1) {
+ dstpath = get_absolute_path(path_get_basename(argv[0]));
+ } else {
+ dstpath = get_absolute_path(argv[1]);
+ }
+
+ uint64_t fh = 0;
+ FILE *f = fopen(argv[0], "rb");
+ if (f) {
+ afc_error_t err = afc_file_open(afc, dstpath, AFC_FOPEN_RW, &fh);
+ if (err == AFC_E_OBJECT_IS_DIR) {
+ const char* basen = path_get_basename(argv[0]);
+ size_t len = strlen(dstpath) + 1 + strlen(basen) + 1;
+ char* newdst = (char*)malloc(len);
+ snprintf(newdst, len, "%s/%s", dstpath, basen);
+ free(dstpath);
+ dstpath = get_absolute_path(newdst);
+ free(newdst);
+ err = afc_file_open(afc, dstpath, AFC_FOPEN_RW, &fh);
+ }
+ if (err != AFC_E_SUCCESS) {
+ printf("Error: Failed to open file '%s' on device: %s (%d)\n", argv[1], afc_strerror(err), err);
+ } else {
+ struct timeval t1;
+ struct timeval t2;
+ struct timeval tdiff;
+ struct stat fst;
+ int progress = 0;
+ size_t bufsize = 0x100000;
+ char* buf = malloc(bufsize);
+
+ fstat(fileno(f), &fst);
+ if (fst.st_size >= 0x400000) {
+ progress = 1;
+ gettimeofday(&t1, NULL);
+ }
+ size_t total = 0;
+ int lastprog = 0;
+ while (err == AFC_E_SUCCESS) {
+ uint32_t bytes_read = fread(buf, 1, bufsize, f);
+ if (bytes_read == 0) {
+ if (!feof(f)) {
+ if (progress) {
+ printf("\n");
+ }
+ printf("Error: Failed to read from local file\n");
+ }
+ break;
+ }
+ uint32_t chunk = 0;
+ while (chunk < bytes_read) {
+ uint32_t bytes_written = 0;
+ err = afc_file_write(afc, fh, buf+chunk, bytes_read-chunk, &bytes_written);
+ if (err != AFC_E_SUCCESS) {
+ if (progress) {
+ printf("\n");
+ }
+ printf("Error: Failed to write to device file\n");
+ break;
+ }
+ chunk += bytes_written;
+ }
+ total += chunk;
+ if (progress) {
+ int prog = (int)((double)total / (double)fst.st_size * 100.0f);
+ if (prog > lastprog) {
+ gettimeofday(&t2, NULL);
+ timeval_subtract(&tdiff, &t2, &t1);
+ double time_in_sec = (double)tdiff.tv_sec + (double)tdiff.tv_usec/1000000;
+ printf("\r%d%% (%0.1f MB/s) ", prog, (double)total/1048576.0f / time_in_sec);
+ fflush(stdout);
+ lastprog = prog;
+ }
+ }
+ }
+ printf("\n");
+ free(buf);
+ afc_file_close(afc, fh);
+ }
+ fclose(f);
+ } else {
+ printf("Error: Failed to open local file '%s': %s\n", argv[0], strerror(errno));
+ }
+ free(dstpath);
+}
+
+static void handle_pwd(afc_client_t afc, int argc, char** argv)
+{
+ printf("%s\n", curdir);
+}
+
+static void handle_cd(afc_client_t afc, int argc, char** argv)
+{
+ if (argc != 1) {
+ printf("Error: Invalid number of arguments\n");
+ return;
+ }
+
+ if (!strcmp(argv[0], ".")) {
+ return;
+ }
+
+ if (!strcmp(argv[0], "..")) {
+ if (!strcmp(curdir, "/")) {
+ return;
+ }
+ char *p = strrchr(curdir, '/');
+ if (!p) {
+ strcpy(curdir, "/");
+ return;
+ }
+ if (p == curdir) {
+ *(p+1) = '\0';
+ } else {
+ *p = '\0';
+ }
+ return;
+ }
+
+ char* path = get_realpath(argv[0]);
+ int is_dir = 0;
+ char **info = NULL;
+ afc_error_t err = afc_get_file_info(afc, path, &info);
+ if (err == AFC_E_SUCCESS && info) {
+ int i;
+ for (i = 0; info[i]; i += 2) {
+ if (!strcmp(info[i], "st_ifmt")) {
+ if (!strcmp(info[i+1], "S_IFDIR")) {
+ is_dir = 1;
+ }
+ break;
+ }
+ }
+ afc_dictionary_free(info);
+ } else {
+ printf("Error: Failed to get file info for %s: %s (%d)\n", path, afc_strerror(err), err);
+ free(path);
+ return;
+ }
+
+ if (!is_dir) {
+ printf("Error: '%s' is not a valid directory\n", path);
+ free(path);
+ return;
+ }
+
+ free(curdir);
+ curdir = path;
+ curdir_len = strlen(curdir);
+}
+
+static void parse_cmdline(int* p_argc, char*** p_argv, const char* cmdline)
+{
+ char **argv = NULL;
+ int argc = 0;
+ size_t maxlen = strlen(cmdline);
+ const char* pos = cmdline;
+ const char* qpos = NULL;
+ char *tmpbuf = NULL;
+ int tmplen = 0;
+ int is_error = 0;
+
+ /* skip initial whitespace */
+ while (isspace(*pos)) pos++;
+ maxlen -= (pos - cmdline);
+
+ tmpbuf = (char*)malloc(maxlen+1);
+
+ while (!is_error) {
+ if (*pos == '\\') {
+ pos++;
+ switch (*pos) {
+ case '"':
+ case '\'':
+ case '\\':
+ case ' ':
+ tmpbuf[tmplen++] = *pos;
+ pos++;
+ break;
+ default:
+ printf("Error: Invalid escape sequence\n");
+ is_error++;
+ break;
+ }
+ } else if (*pos == '"' || *pos == '\'') {
+ if (!qpos) {
+ qpos = pos;
+ } else {
+ qpos = NULL;
+ }
+ pos++;
+ } else if (*pos == '\0' || (!qpos && isspace(*pos))) {
+ tmpbuf[tmplen] = '\0';
+ if (*pos == '\0' && qpos) {
+ printf("Error: Unmatched `%c`\n", *qpos);
+ is_error++;
+ break;
+ }
+ char** new_argv = (char**)realloc(argv, (argc+1)*sizeof(char*));
+ if (new_argv == NULL) {
+ printf("Error: Out of memory?!\n");
+ is_error++;
+ break;
+ }
+ argv = new_argv;
+ /* shrink buffer to actual argument size */
+ argv[argc] = (char*)realloc(tmpbuf, tmplen+1);
+ if (!argv[argc]) {
+ printf("Error: Out of memory?!\n");
+ is_error++;
+ break;
+ }
+ argc++;
+ tmpbuf = NULL;
+ if (*pos == '\0') {
+ break;
+ }
+ maxlen -= tmplen;
+ tmpbuf = (char*)malloc(maxlen+1);
+ tmplen = 0;
+ while (isspace(*pos)) pos++;
+ } else {
+ tmpbuf[tmplen++] = *pos;
+ pos++;
+ }
+ }
+ if (tmpbuf) {
+ free(tmpbuf);
+ }
+ if (is_error) {
+ int i;
+ for (i = 0; argv && i < argc; i++) free(argv[i]);
+ free(argv);
+ return;
+ }
+
+ *p_argv = argv;
+ *p_argc = argc;
+}
+
+static int process_args(afc_client_t afc, int argc, char** argv)
+{
+ if (!strcmp(argv[0], "q") || !strcmp(argv[0], "quit") || !strcmp(argv[0], "exit")) {
+ return -1;
+ }
+ else if (!strcmp(argv[0], "help")) {
+ handle_help(afc, argc, argv);
+ }
+ else if (!strcmp(argv[0], "devinfo") || !strcmp(argv[0], "deviceinfo")) {
+ handle_devinfo(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "info")) {
+ handle_file_info(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "ls") || !strcmp(argv[0], "list")) {
+ handle_list(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "mv") || !strcmp(argv[0], "rename")) {
+ handle_rename(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "mkdir")) {
+ handle_mkdir(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "ln")) {
+ handle_link(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "rm") || !strcmp(argv[0], "remove")) {
+ handle_remove(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "get")) {
+ handle_get(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "put")) {
+ handle_put(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "pwd")) {
+ handle_pwd(afc, argc-1, argv+1);
+ }
+ else if (!strcmp(argv[0], "cd")) {
+ handle_cd(afc, argc-1, argv+1);
+ }
+ else {
+ printf("Unknown command '%s'. Type 'help' to get a list of available commands.\n", argv[0]);
+ }
+ return 0;
+}
+
+static void start_cmdline(afc_client_t afc)
+{
+ while (!stop_requested) {
+ int argc = 0;
+ char **argv = NULL;
+ char prompt[128];
+ int plen = curdir_len;
+ char *ppath = curdir;
+ int plim = (int)(sizeof(prompt)/2)-8;
+ if (plen > plim) {
+ ppath = curdir + (plen - plim);
+ plen = plim;
+ }
+ snprintf(prompt, 128, FG_BLACK BG_LIGHT_GRAY "afc:" COLOR_RESET FG_BRIGHT_YELLOW BG_BLUE "%.*s" COLOR_RESET " > ", plen, ppath);
+#ifdef HAVE_READLINE
+ char* cmd = readline(prompt);
+ if (!cmd || !*cmd) {
+ free(cmd);
+ continue;
+ }
+ add_history(cmd);
+ parse_cmdline(&argc, &argv, cmd);
+#else
+ char cmdbuf[4096];
+ printf("%s", prompt);
+ fflush(stdout);
+ get_input(cmdbuf, sizeof(cmdbuf));
+ parse_cmdline(&argc, &argv, cmdbuf);
+#endif
+#ifdef HAVE_READLINE
+ free(cmd);
+#endif
+ /* process arguments */
+ if (argv && argv[0]) {
+ if (process_args(afc, argc, argv) < 0) {
+ break;
+ }
+ }
+ }
+}
+
+static void device_event_cb(const idevice_event_t* event, void* userdata)
+{
+ if (use_network && event->conn_type != CONNECTION_NETWORK) {
+ return;
+ } else if (!use_network && event->conn_type != CONNECTION_USBMUXD) {
+ return;
+ }
+ if (event->event == IDEVICE_DEVICE_ADD) {
+ if (!udid) {
+ udid = strdup(event->udid);
+ }
+ if (strcmp(udid, event->udid) == 0) {
+ connected = 1;
+ }
+ } else if (event->event == IDEVICE_DEVICE_REMOVE) {
+ if (strcmp(udid, event->udid) == 0) {
+ connected = 0;
+ printf("\n[disconnected]\n");
+ handle_signal(SIGINT);
+ }
+ }
+}
+
+int main(int argc, char** argv)
+{
+ const char* appid = NULL;
+ int ret = 0;
+ idevice_t device = NULL;
+ lockdownd_client_t lockdown = NULL;
+ lockdownd_error_t ldret = LOCKDOWN_E_UNKNOWN_ERROR;
+ lockdownd_service_descriptor_t service = NULL;
+ afc_client_t afc = NULL;
+ house_arrest_client_t house_arrest = NULL;
+ const char* service_name = AFC_SERVICE_NAME;
+ int use_container = 0;
+
+ int c = 0;
+ const struct option longopts[] = {
+ { "udid", required_argument, NULL, 'u' },
+ { "network", no_argument, NULL, 'n' },
+ { "help", no_argument, NULL, 'h' },
+ { "debug", no_argument, NULL, 'd' },
+ { "version", no_argument, NULL, 'v' },
+ { "documents", required_argument, NULL, OPT_DOCUMENTS },
+ { "container", required_argument, NULL, OPT_CONTAINER },
+ { NULL, 0, NULL, 0}
+ };
+
+ signal(SIGTERM, handle_signal);
+#ifndef WIN32
+ signal(SIGQUIT, handle_signal);
+ signal(SIGPIPE, SIG_IGN);
+#endif
+
+ while ((c = getopt_long(argc, argv, "du:nhv", longopts, NULL)) != -1) {
+ switch (c) {
+ case 'd':
+ idevice_set_debug_level(1);
+ break;
+ case 'u':
+ if (!*optarg) {
+ fprintf(stderr, "ERROR: UDID must not be empty!\n");
+ print_usage(argc, argv, 1);
+ return 2;
+ }
+ udid = strdup(optarg);
+ break;
+ case 'n':
+ use_network = 1;
+ break;
+ case 'h':
+ print_usage(argc, argv, 0);
+ return 0;
+ case 'v':
+ printf("%s %s", TOOL_NAME, PACKAGE_VERSION);
+#ifdef HAVE_READLINE
+ printf(" (readline)");
+#endif
+ printf("\n");
+ return 0;
+ case OPT_DOCUMENTS:
+ if (!*optarg) {
+ fprintf(stderr, "ERROR: '--documents' requires a non-empty app ID!\n");
+ print_usage(argc, argv, 1);
+ return 2;
+ }
+ appid = optarg;
+ use_container = 0;
+ break;
+ case OPT_CONTAINER:
+ if (!*optarg) {
+ fprintf(stderr, "ERROR: '--container' requires a not-empty app ID!\n");
+ print_usage(argc, argv, 1);
+ return 2;
+ }
+ appid = optarg;
+ use_container = 1;
+ break;
+ default:
+ print_usage(argc, argv, 1);
+ return 2;
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ int num = 0;
+ idevice_info_t *devices = NULL;
+ idevice_get_device_list_extended(&devices, &num);
+ int count = 0;
+ for (int i = 0; i < num; i++) {
+ if (devices[i]->conn_type == CONNECTION_NETWORK && use_network) {
+ count++;
+ } else if (devices[i]->conn_type == CONNECTION_USBMUXD) {
+ count++;
+ }
+ }
+ idevice_device_list_extended_free(devices);
+ if (count == 0) {
+ fprintf(stderr, "No device found. Plug in a device or pass UDID with -u to wait for device to be available.\n");
+ return 1;
+ }
+
+ idevice_events_subscribe(&context, device_event_cb, NULL);
+
+ while (!connected && !stop_requested) {
+#ifdef WIN32
+ Sleep(100);
+#else
+ usleep(100000);
+#endif
+ }
+ if (stop_requested) {
+ return 0;
+ }
+
+ ret = idevice_new_with_options(&device, udid, (use_network) ? IDEVICE_LOOKUP_NETWORK : IDEVICE_LOOKUP_USBMUX);
+ if (ret != IDEVICE_E_SUCCESS) {
+ if (udid) {
+ fprintf(stderr, "ERROR: Device %s not found!\n", udid);
+ } else {
+ fprintf(stderr, "ERROR: No device found!\n");
+ }
+ return 1;
+ }
+
+ do {
+ if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME))) {
+ fprintf(stderr, "ERROR: Could not connect to lockdownd: %s (%d)\n", lockdownd_strerror(ldret), ldret);
+ ret = 1;
+ break;
+ }
+
+ if (appid) {
+ service_name = HOUSE_ARREST_SERVICE_NAME;
+ }
+
+ ldret = lockdownd_start_service(lockdown, service_name, &service);
+ if (ldret != LOCKDOWN_E_SUCCESS) {
+ fprintf(stderr, "ERROR: Failed to start service %s: %s (%d)\n", service_name, lockdownd_strerror(ldret), ldret);
+ ret = 1;
+ break;
+ }
+
+ if (appid) {
+ house_arrest_client_new(device, service, &house_arrest);
+ if (!house_arrest) {
+ fprintf(stderr, "Could not start document sharing service!\n");
+ ret = 1;
+ break;
+ }
+
+ if (house_arrest_send_command(house_arrest, use_container ? "VendContainer": "VendDocuments", appid) != HOUSE_ARREST_E_SUCCESS) {
+ fprintf(stderr, "Could not send house_arrest command!\n");
+ ret = 1;
+ break;
+ }
+
+ plist_t dict = NULL;
+ if (house_arrest_get_result(house_arrest, &dict) != HOUSE_ARREST_E_SUCCESS) {
+ fprintf(stderr, "Could not get result from document sharing service!\n");
+ break;
+ }
+ plist_t node = plist_dict_get_item(dict, "Error");
+ if (node) {
+ char *str = NULL;
+ plist_get_string_val(node, &str);
+ fprintf(stderr, "ERROR: %s\n", str);
+ if (str && !strcmp(str, "InstallationLookupFailed")) {
+ fprintf(stderr, "The App '%s' is either not present on the device, or the 'UIFileSharingEnabled' key is not set in its Info.plist. Starting with iOS 8.3 this key is mandatory to allow access to an app's Documents folder.\n", appid);
+ }
+ free(str);
+ plist_free(dict);
+ break;
+ }
+ plist_free(dict);
+ afc_client_new_from_house_arrest_client(house_arrest, &afc);
+ } else {
+ afc_client_new(device, service, &afc);
+ }
+ lockdownd_service_descriptor_free(service);
+ lockdownd_client_free(lockdown);
+ lockdown = NULL;
+
+ curdir = strdup("/");
+ curdir_len = 1;
+
+ if (argc > 0) {
+ // command line mode
+ process_args(afc, argc, argv);
+ } else {
+ // interactive mode
+ start_cmdline(afc);
+ }
+
+ } while (0);
+
+ if (afc) {
+ afc_client_free(afc);
+ }
+ if (lockdown) {
+ lockdownd_client_free(lockdown);
+ }
+ idevice_free(device);
+
+ return ret;
+}
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c
index 2856fda..5694c12 100644
--- a/tools/idevicebackup.c
+++ b/tools/idevicebackup.c
@@ -34,6 +34,9 @@
#include <getopt.h>
#if defined(HAVE_OPENSSL)
#include <openssl/sha.h>
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+#include <openssl/evp.h>
+#endif
#elif defined(HAVE_GNUTLS)
#include <gcrypt.h>
#elif defined(HAVE_MBEDTLS)
@@ -57,6 +60,7 @@
#include <libimobiledevice/notification_proxy.h>
#include <libimobiledevice/afc.h>
#include <libimobiledevice-glue/utils.h>
+#include <plist/plist.h>
#define MOBILEBACKUP_SERVICE_NAME "com.apple.mobilebackup"
#define NP_SERVICE_NAME "com.apple.mobile.notification_proxy"
@@ -112,7 +116,11 @@ static int compare_hash(const unsigned char *hash1, const unsigned char *hash2,
static void _sha1_update(void* context, const char* data, size_t len)
{
#if defined(HAVE_OPENSSL)
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ EVP_DigestUpdate(context, data, len);
+#else
SHA1_Update(context, data, len);
+#endif
#elif defined(HAVE_GNUTLS)
gcry_md_write(context, data, len);
#elif defined(HAVE_MBEDTLS)
@@ -123,9 +131,15 @@ static void _sha1_update(void* context, const char* data, size_t len)
static void compute_datahash(const char *path, const char *destpath, uint8_t greylist, const char *domain, const char *appid, const char *version, unsigned char *hash_out)
{
#if defined(HAVE_OPENSSL)
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ EVP_MD_CTX* sha1 = EVP_MD_CTX_new();
+ EVP_DigestInit(sha1, EVP_sha1());
+ void* psha1 = sha1;
+#else
SHA_CTX sha1;
SHA1_Init(&sha1);
void* psha1 = &sha1;
+#endif
#elif defined(HAVE_GNUTLS)
gcry_md_hd_t hd = NULL;
gcry_md_open(&hd, GCRY_MD_SHA1, 0);
@@ -179,7 +193,12 @@ static void compute_datahash(const char *path, const char *destpath, uint8_t gre
_sha1_update(psha1, "(null)", 6);
}
#if defined(HAVE_OPENSSL)
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ EVP_DigestFinal(sha1, hash_out, NULL);
+ EVP_MD_CTX_destroy(sha1);
+#else
SHA1_Final(hash_out, &sha1);
+#endif
#elif defined(HAVE_GNUTLS)
unsigned char *newhash = gcry_md_read(hd, GCRY_MD_SHA1);
memcpy(hash_out, newhash, 20);
@@ -317,7 +336,7 @@ static void mobilebackup_write_status(const char *path, int status)
if (stat(file_path, &st) == 0)
remove(file_path);
- plist_write_to_filename(status_plist, file_path, PLIST_FORMAT_XML);
+ plist_write_to_file(status_plist, file_path, PLIST_FORMAT_XML, 0);
plist_free(status_plist);
status_plist = NULL;
@@ -331,7 +350,7 @@ static int mobilebackup_read_status(const char *path)
plist_t status_plist = NULL;
char *file_path = mobilebackup_build_path(path, "Status", ".plist");
- plist_read_from_filename(&status_plist, file_path);
+ plist_read_from_file(file_path, &status_plist, NULL);
free(file_path);
if (!status_plist) {
printf("Could not read Status.plist!\n");
@@ -454,7 +473,7 @@ static int mobilebackup_check_file_integrity(const char *backup_directory, const
}
infopath = mobilebackup_build_path(backup_directory, hash, ".mdinfo");
- plist_read_from_filename(&mdinfo, infopath);
+ plist_read_from_file(infopath, &mdinfo, NULL);
free(infopath);
if (!mdinfo) {
printf("\r\n");
@@ -882,7 +901,7 @@ int main(int argc, char *argv[])
/* verify existing Info.plist */
if (stat(info_path, &st) == 0) {
printf("Reading Info.plist from backup.\n");
- plist_read_from_filename(&info_plist, info_path);
+ plist_read_from_file(info_path, &info_plist, NULL);
if (!info_plist) {
printf("Could not read Info.plist\n");
@@ -893,7 +912,7 @@ int main(int argc, char *argv[])
/* update the last backup time within Info.plist */
mobilebackup_info_update_last_backup_date(info_plist);
remove(info_path);
- plist_write_to_filename(info_plist, info_path, PLIST_FORMAT_XML);
+ plist_write_to_file(info_plist, info_path, PLIST_FORMAT_XML, 0);
} else {
printf("Aborting backup. Backup is not compatible with the current device.\n");
cmd = CMD_LEAVE;
@@ -959,7 +978,7 @@ int main(int argc, char *argv[])
/* read the last Manifest.plist */
if (!is_full_backup) {
printf("Reading existing Manifest.\n");
- plist_read_from_filename(&manifest_plist, manifest_path);
+ plist_read_from_file(manifest_path, &manifest_plist, NULL);
if (!manifest_plist) {
printf("Could not read Manifest.plist, switching to full backup mode.\n");
is_full_backup = 1;
@@ -977,7 +996,7 @@ int main(int argc, char *argv[])
remove(info_path);
printf("Creating Info.plist for new backup.\n");
info_plist = mobilebackup_factory_info_plist_new(udid);
- plist_write_to_filename(info_plist, info_path, PLIST_FORMAT_XML);
+ plist_write_to_file(info_plist, info_path, PLIST_FORMAT_XML, 0);
}
free(info_path);
@@ -1116,7 +1135,7 @@ int main(int argc, char *argv[])
remove(filename_mdinfo);
node = plist_dict_get_item(node_tmp, "BackupFileInfo");
- plist_write_to_filename(node, filename_mdinfo, PLIST_FORMAT_BINARY);
+ plist_write_to_file(node, filename_mdinfo, PLIST_FORMAT_BINARY, 0);
free(filename_mdinfo);
}
@@ -1228,7 +1247,7 @@ files_out:
if (manifest_plist) {
remove(manifest_path);
printf("Storing Manifest.plist...\n");
- plist_write_to_filename(manifest_plist, manifest_path, PLIST_FORMAT_XML);
+ plist_write_to_file(manifest_plist, manifest_path, PLIST_FORMAT_XML, 0);
}
backup_ok = 1;
@@ -1259,7 +1278,7 @@ files_out:
}
/* now make sure backup integrity is ok! verify all files */
printf("Reading existing Manifest.\n");
- plist_read_from_filename(&manifest_plist, manifest_path);
+ plist_read_from_file(manifest_path, &manifest_plist, NULL);
if (!manifest_plist) {
printf("Could not read Manifest.plist. Aborting.\n");
break;
@@ -1386,7 +1405,7 @@ files_out:
while (node) {
/* TODO: read mddata/mdinfo files and send to device using DLSendFile */
file_info_path = mobilebackup_build_path(backup_directory, hash, ".mdinfo");
- plist_read_from_filename(&file_info, file_info_path);
+ plist_read_from_file(file_info_path, &file_info, NULL);
/* get encryption state */
tmp_node = plist_dict_get_item(file_info, "IsEncrypted");
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index be7a132..c73b269 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -47,6 +47,7 @@
#include <libimobiledevice/sbservices.h>
#include <libimobiledevice/diagnostics_relay.h>
#include <libimobiledevice-glue/utils.h>
+#include <plist/plist.h>
#include <endianness.h>
@@ -606,7 +607,7 @@ static int mb2_status_check_snapshot_state(const char *path, const char *udid, c
plist_t status_plist = NULL;
char *file_path = string_build_path(path, udid, "Status.plist", NULL);
- plist_read_from_filename(&status_plist, file_path);
+ plist_read_from_file(file_path, &status_plist, NULL);
free(file_path);
if (!status_plist) {
printf("Could not read Status.plist!\n");
@@ -1521,7 +1522,7 @@ int main(int argc, char *argv[])
{ "settings", no_argument, NULL, OPT_SETTINGS },
{ "remove", no_argument, NULL, OPT_REMOVE },
{ "skip-apps", no_argument, NULL, OPT_SKIP_APPS },
- { "password", no_argument, NULL, OPT_PASSWORD },
+ { "password", required_argument, NULL, OPT_PASSWORD },
{ "full", no_argument, NULL, OPT_FULL },
{ NULL, 0, NULL, 0}
};
@@ -1555,6 +1556,7 @@ int main(int argc, char *argv[])
return 2;
}
source_udid = strdup(optarg);
+ break;
case 'i':
interactive_mode = 1;
break;
@@ -1779,7 +1781,7 @@ int main(int argc, char *argv[])
free(info_path);
}
plist_t manifest_plist = NULL;
- plist_read_from_filename(&manifest_plist, manifest_path);
+ plist_read_from_file(manifest_path, &manifest_plist, NULL);
if (!manifest_plist) {
idevice_free(device);
free(info_path);
@@ -1935,7 +1937,7 @@ int main(int argc, char *argv[])
/* verify existing Info.plist */
if (info_path && (stat(info_path, &st) == 0) && cmd != CMD_CLOUD) {
PRINT_VERBOSE(1, "Reading Info.plist from backup.\n");
- plist_read_from_filename(&info_plist, info_path);
+ plist_read_from_file(info_path, &info_plist, NULL);
if (!info_plist) {
printf("Could not read Info.plist\n");
@@ -2029,7 +2031,7 @@ checkpoint:
cmd = CMD_LEAVE;
}
remove_file(info_path);
- plist_write_to_filename(info_plist, info_path, PLIST_FORMAT_XML);
+ plist_write_to_file(info_plist, info_path, PLIST_FORMAT_XML, 0);
free(info_path);
plist_free(info_plist);
diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c
index d0d2147..09bd537 100644
--- a/tools/idevicecrashreport.c
+++ b/tools/idevicecrashreport.c
@@ -81,7 +81,7 @@ static int extract_raw_crash_report(const char* filename)
strcpy(p, ".crash");
/* read plist crash report */
- if (plist_read_from_filename(&report, filename)) {
+ if (plist_read_from_file(filename, &report, NULL)) {
plist_t description_node = plist_dict_get_item(report, "description");
if (description_node && plist_get_node_type(description_node) == PLIST_STRING) {
plist_get_string_val(description_node, &raw);
@@ -163,7 +163,7 @@ static int afc_client_copy_and_remove_crash_reports(afc_client_t afc, const char
char* p = strrchr(list[k], '.');
if (p != NULL && !strncmp(p, ".synced", 7)) {
/* make sure to strip ".synced" extension as seen on iOS 5 */
- int newlen = strlen(list[k]) - 7;
+ size_t newlen = p - list[k];
strncpy(((char*)target_filename) + host_directory_length, list[k], newlen);
target_filename[host_directory_length + newlen] = '\0';
} else {
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c
index fbb6c3e..36c594e 100644
--- a/tools/idevicedebug.c
+++ b/tools/idevicedebug.c
@@ -291,6 +291,11 @@ int main(int argc, char *argv[])
res = 0;
goto cleanup;
break;
+ default:
+ print_usage(argc, argv, 1);
+ res = 2;
+ goto cleanup;
+ break;
}
}
argc -= optind;
diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c
index 8a3b4ff..9fe7051 100644
--- a/tools/idevicedebugserverproxy.c
+++ b/tools/idevicedebugserverproxy.c
@@ -52,8 +52,10 @@
#define info(...) fprintf(stdout, __VA_ARGS__); fflush(stdout)
#define debug(...) if(debug_mode) fprintf(stdout, __VA_ARGS__)
+static int support_lldb = 0;
static int debug_mode = 0;
static int quit_flag = 0;
+static uint16_t local_port = 0;
typedef struct {
int client_fd;
@@ -90,6 +92,7 @@ static void print_usage(int argc, char **argv, int is_error)
" -u, --udid UDID target specific device by UDID\n"
" -n, --network connect to network device\n"
" -d, --debug enable communication debugging\n"
+ " -l, --lldb enable lldb support\n"
" -h, --help prints usage information\n"
" -v, --version prints version information\n"
"\n"
@@ -98,6 +101,26 @@ static void print_usage(int argc, char **argv, int is_error)
);
}
+static int intercept_packet(char *packet, ssize_t *packet_len) {
+ static const char kReqLaunchServer[] = "$qLaunchGDBServer;#4b";
+
+ char buffer[64] = {0};
+ if (*packet_len == (ssize_t)(sizeof(kReqLaunchServer) - 1)
+ && memcmp(packet, kReqLaunchServer, sizeof(kReqLaunchServer) - 1) == 0) {
+ sprintf(buffer, "port:%d;", local_port);
+ } else {
+ return 0;
+ }
+ int sum = 0;
+ for (size_t i = 0; i < strlen(buffer); i++) {
+ sum += buffer[i];
+ }
+ sum = sum & 255;
+ sprintf(packet, "$%s#%02x", buffer, sum);
+ *packet_len = strlen(packet);
+ return 1;
+}
+
static void* connection_handler(void* data)
{
debugserver_error_t derr = DEBUGSERVER_E_SUCCESS;
@@ -137,7 +160,10 @@ static void* connection_handler(void* data)
fprintf(stderr, "connection closed\n");
break;
}
-
+ if (support_lldb && intercept_packet(buf, &n)) {
+ socket_send(client_fd, buf, n);
+ continue;
+ }
uint32_t sent = 0;
debugserver_client_send(socket_info->debugserver_client, buf, n, &sent);
}
@@ -180,7 +206,6 @@ int main(int argc, char *argv[])
thread_info_t *thread_list = NULL;
const char* udid = NULL;
int use_network = 0;
- uint16_t local_port = 0;
int server_fd;
int result = EXIT_SUCCESS;
int c = 0;
@@ -189,6 +214,7 @@ int main(int argc, char *argv[])
{ "help", no_argument, NULL, 'h' },
{ "udid", required_argument, NULL, 'u' },
{ "network", no_argument, NULL, 'n' },
+ { "lldb", no_argument, NULL, 'l' },
{ "version", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0}
};
@@ -234,6 +260,9 @@ int main(int argc, char *argv[])
case 'n':
use_network = 1;
break;
+ case 'l':
+ support_lldb = 1;
+ break;
case 'h':
print_usage(argc, argv, 0);
return 0;
diff --git a/tools/idevicedevmodectl.c b/tools/idevicedevmodectl.c
new file mode 100644
index 0000000..bd1de6a
--- /dev/null
+++ b/tools/idevicedevmodectl.c
@@ -0,0 +1,462 @@
+/*
+ * idevicedevmodectl.c
+ * List or enable Developer Mode on iOS 16+ devices
+ *
+ * Copyright (c) 2022 Nikias Bassen, All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define TOOL_NAME "idevicedevmodectl"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#ifndef WIN32
+#include <signal.h>
+#endif
+
+#ifdef WIN32
+#include <windows.h>
+#define __usleep(x) Sleep(x/1000)
+#else
+#include <arpa/inet.h>
+#include <unistd.h>
+#define __usleep(x) usleep(x)
+#endif
+
+#include <libimobiledevice/libimobiledevice.h>
+#include <libimobiledevice/lockdown.h>
+#include <libimobiledevice/property_list_service.h>
+#include <libimobiledevice-glue/utils.h>
+
+#define AMFI_LOCKDOWN_SERVICE_NAME "com.apple.amfi.lockdown"
+
+static char* udid = NULL;
+static int use_network = 0;
+
+static void print_usage(int argc, char **argv, int is_error)
+{
+ char *name = strrchr(argv[0], '/');
+ fprintf(is_error ? stderr : stdout, "Usage: %s [OPTIONS] COMMAND\n", (name ? name + 1: argv[0]));
+ fprintf(is_error ? stderr : stdout,
+ "\n"
+ "Enable Developer Mode on iOS 16+ devices or print the current status.\n"
+ "\n"
+ "Where COMMAND is one of:\n"
+ " list Print the Developer Mode status of all connected devices\n"
+ " or for a specific one if --udid is given.\n"
+ " enable Enable Developer Mode (device will reboot),\n"
+ " and confirm it after device booted up again.\n"
+ "\n"
+ " arm Arm the Developer Mode (device will reboot)\n"
+ " confirm Confirm enabling of Developer Mode\n"
+ " reveal Reveal the Developer Mode menu on the device\n"
+ "\n"
+ "The following OPTIONS are accepted:\n"
+ " -u, --udid UDID target specific device by UDID\n"
+ " -n, --network connect to network device\n"
+ " -d, --debug enable communication debugging\n"
+ " -h, --help print usage information\n"
+ " -v, --version print version information\n"
+ "\n"
+ "Homepage: <" PACKAGE_URL ">\n"
+ "Bug Reports: <" PACKAGE_BUGREPORT ">\n"
+ );
+}
+
+enum {
+ OP_LIST,
+ OP_ENABLE,
+ OP_ARM,
+ OP_CONFIRM,
+ OP_REVEAL,
+ NUM_OPS
+};
+#define DEV_MODE_REVEAL 0
+#define DEV_MODE_ARM 1
+#define DEV_MODE_ENABLE 2
+
+static int get_developer_mode_status(const char* device_udid, int _use_network)
+{
+ idevice_error_t ret;
+ idevice_t device = NULL;
+ lockdownd_client_t lockdown = NULL;
+ lockdownd_error_t lerr = LOCKDOWN_E_UNKNOWN_ERROR;
+ plist_t val = NULL;
+
+ ret = idevice_new_with_options(&device, device_udid, (_use_network) ? IDEVICE_LOOKUP_NETWORK : IDEVICE_LOOKUP_USBMUX);
+ if (ret != IDEVICE_E_SUCCESS) {
+ return -1;
+ }
+
+ if (LOCKDOWN_E_SUCCESS != (lerr = lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME))) {
+ idevice_free(device);
+ return -1;
+ }
+
+ lerr = lockdownd_get_value(lockdown, "com.apple.security.mac.amfi", "DeveloperModeStatus", &val);
+ if (lerr != LOCKDOWN_E_SUCCESS) {
+ fprintf(stderr, "ERROR: Could not get DeveloperModeStatus: %s\nPlease note that this feature is only available on iOS 16+.\n", lockdownd_strerror(lerr));
+ lockdownd_client_free(lockdown);
+ idevice_free(device);
+ return -2;
+ }
+
+ uint8_t dev_mode_status = 0;
+ plist_get_bool_val(val, &dev_mode_status);
+ plist_free(val);
+
+ lockdownd_client_free(lockdown);
+ idevice_free(device);
+
+ return dev_mode_status;
+}
+
+static int amfi_service_send_msg(property_list_service_client_t amfi, plist_t msg)
+{
+ int res;
+ property_list_service_error_t perr;
+
+ perr = property_list_service_send_xml_plist(amfi, plist_copy(msg));
+ if (perr != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ fprintf(stderr, "Could not send request to device: %d\n", perr);
+ res = 2;
+ } else {
+ plist_t reply = NULL;
+ perr = property_list_service_receive_plist(amfi, &reply);
+ if (perr == PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ plist_t val = plist_dict_get_item(reply, "Error");
+ if (val) {
+ const char* err = plist_get_string_ptr(val, NULL);
+ fprintf(stderr, "Request failed: %s\n", err);
+ if (strstr(err, "passcode")) {
+ res = 2;
+ } else {
+ res = 1;
+ }
+ } else {
+ res = plist_dict_get_item(reply, "success") ? 0 : 1;
+ }
+ } else {
+ fprintf(stderr, "Could not receive reply from device: %d\n", perr);
+ res = 2;
+ }
+ plist_free(reply);
+ }
+ return res;
+}
+
+static int amfi_send_action(idevice_t device, unsigned int action)
+{
+ lockdownd_client_t lockdown = NULL;
+ lockdownd_service_descriptor_t service = NULL;
+ lockdownd_error_t lerr;
+
+ if (LOCKDOWN_E_SUCCESS != (lerr = lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME))) {
+ fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", lerr);
+ return 1;
+ }
+
+ lerr = lockdownd_start_service(lockdown, AMFI_LOCKDOWN_SERVICE_NAME, &service);
+ if (lerr != LOCKDOWN_E_SUCCESS) {
+ fprintf(stderr, "Could not start service %s: %s\nPlease note that this feature is only available on iOS 16+.\n", AMFI_LOCKDOWN_SERVICE_NAME, lockdownd_strerror(lerr));
+ lockdownd_client_free(lockdown);
+ return 1;
+ }
+ lockdownd_client_free(lockdown);
+ lockdown = NULL;
+
+ property_list_service_client_t amfi = NULL;
+ if (property_list_service_client_new(device, service, &amfi) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ fprintf(stderr, "Could not connect to %s on device\n", AMFI_LOCKDOWN_SERVICE_NAME);
+ if (service)
+ lockdownd_service_descriptor_free(service);
+ idevice_free(device);
+ return 1;
+ }
+ lockdownd_service_descriptor_free(service);
+
+ plist_t dict = plist_new_dict();
+ plist_dict_set_item(dict, "action", plist_new_uint(action));
+
+ int result = amfi_service_send_msg(amfi, dict);
+ plist_free(dict);
+
+ property_list_service_client_free(amfi);
+ amfi = NULL;
+
+ return result;
+}
+
+static int device_connected = 0;
+
+static void device_event_cb(const idevice_event_t* event, void* userdata)
+{
+ if (use_network && event->conn_type != CONNECTION_NETWORK) {
+ return;
+ }
+ if (!use_network && event->conn_type != CONNECTION_USBMUXD) {
+ return;
+ }
+ if (event->event == IDEVICE_DEVICE_ADD) {
+ if (!udid) {
+ udid = strdup(event->udid);
+ }
+ if (strcmp(udid, event->udid) == 0) {
+ device_connected = 1;
+ }
+ } else if (event->event == IDEVICE_DEVICE_REMOVE) {
+ if (strcmp(udid, event->udid) == 0) {
+ device_connected = 0;
+ }
+ }
+}
+
+
+#define WAIT_INTERVAL 200000
+#define WAIT_MAX(x) (x * (1000000 / WAIT_INTERVAL))
+#define WAIT_FOR(cond, timeout) { int __repeat = WAIT_MAX(timeout); while (!(cond) && __repeat-- > 0) { __usleep(WAIT_INTERVAL); } }
+
+int main(int argc, char *argv[])
+{
+ idevice_t device = NULL;
+ idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
+ lockdownd_client_t lockdown = NULL;
+ lockdownd_error_t lerr = LOCKDOWN_E_UNKNOWN_ERROR;
+ int res = 0;
+ int i;
+ int op = -1;
+ plist_t val = NULL;
+
+ int c = 0;
+ const struct option longopts[] = {
+ { "debug", no_argument, NULL, 'd' },
+ { "help", no_argument, NULL, 'h' },
+ { "udid", required_argument, NULL, 'u' },
+ { "network", no_argument, NULL, 'n' },
+ { "version", no_argument, NULL, 'v' },
+ { NULL, 0, NULL, 0}
+ };
+
+#ifndef WIN32
+ signal(SIGPIPE, SIG_IGN);
+#endif
+ /* parse cmdline args */
+ while ((c = getopt_long(argc, argv, "dhu:nv", longopts, NULL)) != -1) {
+ switch (c) {
+ case 'd':
+ idevice_set_debug_level(1);
+ break;
+ case 'u':
+ if (!*optarg) {
+ fprintf(stderr, "ERROR: UDID argument must not be empty!\n");
+ print_usage(argc, argv, 1);
+ return 2;
+ }
+ udid = optarg;
+ break;
+ case 'n':
+ use_network = 1;
+ break;
+ case 'h':
+ print_usage(argc, argv, 0);
+ return 0;
+ case 'v':
+ printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
+ return 0;
+ default:
+ print_usage(argc, argv, 1);
+ return 2;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (!argv[0]) {
+ fprintf(stderr, "ERROR: Missing command.\n");
+ print_usage(argc+optind, argv-optind, 1);
+ return 2;
+ }
+
+ i = 0;
+ if (!strcmp(argv[i], "list")) {
+ op = OP_LIST;
+ }
+ else if (!strcmp(argv[i], "enable")) {
+ op = OP_ENABLE;
+ }
+ else if (!strcmp(argv[i], "arm")) {
+ op = OP_ARM;
+ }
+ else if (!strcmp(argv[i], "confirm")) {
+ op = OP_CONFIRM;
+ }
+ else if (!strcmp(argv[i], "reveal")) {
+ op = OP_REVEAL;
+ }
+
+ if ((op == -1) || (op >= NUM_OPS)) {
+ fprintf(stderr, "ERROR: Unsupported command '%s'\n", argv[i]);
+ print_usage(argc+optind, argv-optind, 1);
+ return 2;
+ }
+
+ if (op == OP_LIST) {
+ idevice_info_t *dev_list = NULL;
+
+ if (idevice_get_device_list_extended(&dev_list, &i) < 0) {
+ fprintf(stderr, "ERROR: Unable to retrieve device list!\n");
+ return -1;
+ }
+ if (i > 0) {
+ printf("%-40s %s\n", "Device", "DeveloperMode");
+ }
+ for (i = 0; dev_list[i] != NULL; i++) {
+ if (dev_list[i]->conn_type == CONNECTION_USBMUXD && use_network) continue;
+ if (dev_list[i]->conn_type == CONNECTION_NETWORK && !use_network) continue;
+ if (udid && (strcmp(dev_list[i]->udid, udid) != 0)) continue;
+ int mode = get_developer_mode_status(dev_list[i]->udid, use_network);
+ const char *mode_str = "N/A";
+ if (mode == 1) {
+ mode_str = "enabled";
+ } else if (mode == 0) {
+ mode_str = "disabled";
+ }
+ printf("%-40s %s\n", dev_list[i]->udid, mode_str);
+ }
+ idevice_device_list_extended_free(dev_list);
+
+ return 0;
+ }
+
+ idevice_subscription_context_t context = NULL;
+ idevice_events_subscribe(&context, device_event_cb, NULL);
+
+ WAIT_FOR(device_connected, 10);
+
+ ret = idevice_new_with_options(&device, udid, (use_network) ? IDEVICE_LOOKUP_NETWORK : IDEVICE_LOOKUP_USBMUX);
+ if (ret != IDEVICE_E_SUCCESS) {
+ if (udid) {
+ printf("No device found with udid %s.\n", udid);
+ } else {
+ printf("No device found.\n");
+ }
+ return 1;
+ }
+
+ if (!udid) {
+ idevice_get_udid(device, &udid);
+ }
+
+ if (LOCKDOWN_E_SUCCESS != (lerr = lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME))) {
+ fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", lerr);
+ idevice_free(device);
+ return 1;
+ }
+
+ lerr = lockdownd_get_value(lockdown, "com.apple.security.mac.amfi", "DeveloperModeStatus", &val);
+ lockdownd_client_free(lockdown);
+ lockdown = NULL;
+ if (lerr != LOCKDOWN_E_SUCCESS) {
+ fprintf(stderr, "ERROR: Could not get DeveloperModeStatus: %s\nPlease note that this feature is only available on iOS 16+.\n", lockdownd_strerror(lerr));
+ idevice_free(device);
+ return 1;
+ }
+
+ uint8_t dev_mode_status = 0;
+ plist_get_bool_val(val, &dev_mode_status);
+
+ if ((op == OP_ENABLE || op == OP_ARM) && dev_mode_status) {
+ if (dev_mode_status) {
+ idevice_free(device);
+ printf("DeveloperMode is already enabled.\n");
+ return 0;
+ }
+ res = 0;
+ } else {
+ if (op == OP_ENABLE || op == OP_ARM) {
+ res = amfi_send_action(device, DEV_MODE_ARM);
+ if (res == 0) {
+ if (op == OP_ARM) {
+ printf("%s: Developer Mode armed, device will reboot now.\n", udid);
+ } else {
+ printf("%s: Developer Mode armed, waiting for reboot...\n", udid);
+
+ do {
+ // waiting for device to disconnect...
+ idevice_free(device);
+ device = NULL;
+ WAIT_FOR(!device_connected, 40);
+ if (device_connected) {
+ printf("%s: ERROR: Device didn't reboot?!\n", udid);
+ res = 2;
+ break;
+ }
+ printf("disconnected\n");
+
+ // waiting for device to reconnect...
+ WAIT_FOR(device_connected, 60);
+ if (!device_connected) {
+ printf("%s: ERROR: Device didn't re-connect?!\n", udid);
+ res = 2;
+ break;
+ }
+ printf("connected\n");
+
+ idevice_new(&device, udid);
+ res = amfi_send_action(device, DEV_MODE_ENABLE);
+ } while (0);
+ if (res == 0) {
+ printf("%s: Developer Mode successfully enabled.\n", udid);
+ } else {
+ printf("%s: Failed to enable developer mode (%d)\n", udid, res);
+ }
+ }
+ } else if (res == 2) {
+ amfi_send_action(device, DEV_MODE_REVEAL);
+ printf("%s: Developer Mode could not be enabled because the device has a passcode set. You have to enable it on the device itself under Settings -> Privacy & Security -> Developer Mode.\n", udid);
+ } else {
+ printf("%s: Failed to arm Developer Mode (%d)\n", udid, res);
+ }
+ } else if (op == OP_CONFIRM) {
+ res = amfi_send_action(device, DEV_MODE_ENABLE);
+ if (res == 0) {
+ printf("%s: Developer Mode successfully enabled.\n", udid);
+ } else {
+ printf("%s: Failed to enable Developer Mode (%d)\n", udid, res);
+ }
+ } else if (op == OP_REVEAL) {
+ res = amfi_send_action(device, DEV_MODE_REVEAL);
+ if (res == 0) {
+ printf("%s: Developer Mode menu revealed successfully.\n", udid);
+ } else {
+ printf("%s: Failed to reveal Developer Mode menu (%d)\n", udid, res);
+ }
+ }
+ }
+
+ idevice_free(device);
+
+ return res;
+}
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c
index b854d5d..f551b6c 100644
--- a/tools/ideviceimagemounter.c
+++ b/tools/ideviceimagemounter.c
@@ -46,7 +46,7 @@
#include <libimobiledevice/notification_proxy.h>
#include <libimobiledevice/mobile_image_mounter.h>
#include <asprintf.h>
-#include <libimobiledevice-glue/utils.h>
+#include <plist/plist.h>
static int list_mode = 0;
static int use_network = 0;
@@ -143,15 +143,6 @@ static void parse_opts(int argc, char **argv)
}
}
-static void print_xml(plist_t node)
-{
- char *xml = NULL;
- uint32_t len = 0;
- plist_to_xml(node, &xml, &len);
- if (xml)
- puts(xml);
-}
-
static ssize_t mim_upload_cb(void* buf, size_t size, void* userdata)
{
return fread(buf, 1, size, (FILE*)userdata);
@@ -224,6 +215,20 @@ int main(int argc, char **argv)
}
}
+ if (product_version_major == 16) {
+ uint8_t dev_mode_status = 0;
+ plist_t val = NULL;
+ ldret = lockdownd_get_value(lckd, "com.apple.security.mac.amfi", "DeveloperModeStatus", &val);
+ if (ldret == LOCKDOWN_E_SUCCESS) {
+ plist_get_bool_val(val, &dev_mode_status);
+ plist_free(val);
+ }
+ if (!dev_mode_status) {
+ printf("ERROR: You have to enable Developer Mode on the given device in order to allowing mounting a developer disk image.\n");
+ goto leave;
+ }
+ }
+
lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &service);
if (!service || service->port == 0) {
@@ -283,11 +288,7 @@ int main(int argc, char **argv)
err = mobile_image_mounter_lookup_image(mim, imagetype, &result);
if (err == MOBILE_IMAGE_MOUNTER_E_SUCCESS) {
res = 0;
- if (xml_mode) {
- print_xml(result);
- } else {
- plist_print_to_stream(result, stdout);
- }
+ plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0);
} else {
printf("Error: lookup_image returned %d\n", err);
}
@@ -415,20 +416,12 @@ int main(int argc, char **argv)
res = 0;
} else {
printf("unexpected status value:\n");
- if (xml_mode) {
- print_xml(result);
- } else {
- plist_print_to_stream(result, stdout);
- }
+ plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0);
}
free(status);
} else {
printf("unexpected result:\n");
- if (xml_mode) {
- print_xml(result);
- } else {
- plist_print_to_stream(result, stdout);
- }
+ plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0);
}
}
node = plist_dict_get_item(result, "Error");
@@ -440,19 +433,11 @@ int main(int argc, char **argv)
free(error);
} else {
printf("unexpected result:\n");
- if (xml_mode) {
- print_xml(result);
- } else {
- plist_print_to_stream(result, stdout);
- }
+ plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0);
}
} else {
- if (xml_mode) {
- print_xml(result);
- } else {
- plist_print_to_stream(result, stdout);
- }
+ plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0);
}
}
} else {
diff --git a/tools/ideviceinfo.c b/tools/ideviceinfo.c
index fc0527d..fd45763 100644
--- a/tools/ideviceinfo.c
+++ b/tools/ideviceinfo.c
@@ -37,7 +37,7 @@
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
-#include <libimobiledevice-glue/utils.h>
+#include <plist/plist.h>
#define FORMAT_KEY_VALUE 1
#define FORMAT_XML 2
@@ -241,11 +241,11 @@ int main(int argc, char *argv[])
free(xml_doc);
break;
case FORMAT_KEY_VALUE:
- plist_print_to_stream(node, stdout);
+ plist_write_to_stream(node, stdout, PLIST_FORMAT_LIMD, 0);
break;
default:
if (key != NULL)
- plist_print_to_stream(node, stdout);
+ plist_write_to_stream(node, stdout, PLIST_FORMAT_LIMD, 0);
break;
}
plist_free(node);
diff --git a/tools/idevicepair.c b/tools/idevicepair.c
index dda02ec..94d3f04 100644
--- a/tools/idevicepair.c
+++ b/tools/idevicepair.c
@@ -41,7 +41,6 @@
#endif
#include "common/userpref.h"
-#include <libimobiledevice-glue/utils.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
@@ -104,7 +103,7 @@ static void pairing_cb(lockdownd_cu_pairing_cb_type_t cb_type, void *user_data,
printf("\n");
} else if (cb_type == LOCKDOWN_CU_PAIRING_DEVICE_INFO) {
printf("Device info:\n");
- plist_print_to_stream_with_indentation((plist_t)data_ptr, stdout, 2);
+ plist_write_to_stream((plist_t)data_ptr, stdout, PLIST_FORMAT_LIMD, PLIST_OPT_INDENT | PLIST_OPT_INDENT_BY(2));
} else if (cb_type == LOCKDOWN_CU_PAIRING_ERROR) {
printf("ERROR: %s\n", (data_ptr) ? (char*)data_ptr : "(unknown)");
}
@@ -257,7 +256,7 @@ int main(int argc, char **argv)
goto leave;
}
if (*optarg == '@') {
- plist_read_from_filename(&host_info_plist, optarg+1);
+ plist_read_from_file(optarg+1, &host_info_plist, NULL);
if (!host_info_plist) {
fprintf(stderr, "ERROR: Could not read from file '%s'\n", optarg+1);
result = EXIT_FAILURE;
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c
index 7cd4f3f..4080a28 100644
--- a/tools/ideviceprovision.c
+++ b/tools/ideviceprovision.c
@@ -45,7 +45,7 @@
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include <libimobiledevice/misagent.h>
-#include <libimobiledevice-glue/utils.h>
+#include <plist/plist.h>
static void print_usage(int argc, char **argv, int is_error)
{
@@ -436,7 +436,7 @@ int main(int argc, char *argv[])
}
} else {
if (pl && (plist_get_node_type(pl) == PLIST_DICT)) {
- plist_print_to_stream(pl, stdout);
+ plist_write_to_stream(pl, stdout, PLIST_FORMAT_LIMD, 0);
} else {
fprintf(stderr, "ERROR: unexpected node type in profile plist (not PLIST_DICT)\n");
res = -1;
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index 5600be2..a0e641d 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -480,7 +480,10 @@ static void print_usage(int argc, char **argv, int is_error)
" -h, --help prints usage information\n"
" -d, --debug enable communication debugging\n"
" -v, --version prints version information\n"
- " --no-colors disable colored output\n"
+ " --no-colors disable colored output\n"
+ " -o, --output FILE write to FILE instead of stdout\n"
+ " (existing FILE will be overwritten)\n"
+ " --colors force writing colored output, e.g. for --output\n"
"\n"
"FILTER OPTIONS:\n"
" -m, --match STRING only print messages that contain STRING\n"
@@ -508,6 +511,7 @@ int main(int argc, char *argv[])
int exclude_filter = 0;
int include_kernel = 0;
int exclude_kernel = 0;
+ int force_colors = 0;
int c = 0;
const struct option longopts[] = {
{ "debug", no_argument, NULL, 'd' },
@@ -525,6 +529,8 @@ int main(int argc, char *argv[])
{ "no-kernel", no_argument, NULL, 'K' },
{ "quiet-list", no_argument, NULL, 1 },
{ "no-colors", no_argument, NULL, 2 },
+ { "colors", no_argument, NULL, 3 },
+ { "output", required_argument, NULL, 'o' },
{ "version", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0}
};
@@ -536,7 +542,7 @@ int main(int argc, char *argv[])
signal(SIGPIPE, SIG_IGN);
#endif
- while ((c = getopt_long(argc, argv, "dhu:nxt:T:m:e:p:qkKv", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "dhu:nxt:T:m:e:p:qkKo:v", longopts, NULL)) != -1) {
switch (c) {
case 'd':
idevice_set_debug_level(1);
@@ -638,6 +644,22 @@ int main(int argc, char *argv[])
case 2:
term_colors_set_enabled(0);
break;
+ case 3:
+ force_colors = 1;
+ break;
+ case 'o':
+ if (!*optarg) {
+ fprintf(stderr, "ERROR: --output option requires an argument!\n");
+ print_usage(argc, argv, 1);
+ return 2;
+ } else {
+ if (freopen(optarg, "w", stdout) == NULL) {
+ fprintf(stderr, "ERROR: Failed to open output file '%s' for writing: %s\n", optarg, strerror(errno));
+ return 1;
+ }
+ term_colors_set_enabled(0);
+ }
+ break;
case 'v':
printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
return 0;
@@ -647,6 +669,10 @@ int main(int argc, char *argv[])
}
}
+ if (force_colors) {
+ term_colors_set_enabled(1);
+ }
+
if (include_kernel > 0 && exclude_kernel > 0) {
fprintf(stderr, "ERROR: -k and -K cannot be used together.\n");
print_usage(argc, argv, 1);