summaryrefslogtreecommitdiffstats
path: root/dev
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-05-28 12:21:11 +0200
committerGravatar Martin Szulecki2010-05-28 12:21:11 +0200
commit448e860d7b99377a5f0c8786c7e60afb2f9dc0bd (patch)
tree821997ce7fae07761d1c31c928c81b64734a9d38 /dev
parent98ffc8a3aa1c16726bb278238dc284e79e63b68e (diff)
downloadlibimobiledevice-448e860d7b99377a5f0c8786c7e60afb2f9dc0bd.tar.gz
libimobiledevice-448e860d7b99377a5f0c8786c7e60afb2f9dc0bd.tar.bz2
Promote ideviceenterrecovery into tools as it is quite useful
Diffstat (limited to 'dev')
-rw-r--r--dev/Makefile.am9
-rw-r--r--dev/ideviceenterrecovery.c93
2 files changed, 2 insertions, 100 deletions
diff --git a/dev/Makefile.am b/dev/Makefile.am
index 17b67db..0790c80 100644
--- a/dev/Makefile.am
+++ b/dev/Makefile.am
@@ -4,7 +4,7 @@ AM_CFLAGS = $(GLOBAL_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_C
4AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) 4AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS)
5 5
6if ENABLE_DEVTOOLS 6if ENABLE_DEVTOOLS
7noinst_PROGRAMS = ideviceclient lckd-client afccheck msyncclient ideviceenterrecovery filerelaytest 7noinst_PROGRAMS = ideviceclient lckd-client afccheck msyncclient filerelaytest
8 8
9ideviceclient_SOURCES = ideviceclient.c 9ideviceclient_SOURCES = ideviceclient.c
10ideviceclient_LDADD = ../src/libimobiledevice.la 10ideviceclient_LDADD = ../src/libimobiledevice.la
@@ -24,11 +24,6 @@ msyncclient_CFLAGS = $(AM_CFLAGS)
24msyncclient_LDFLAGS = $(AM_LDFLAGS) 24msyncclient_LDFLAGS = $(AM_LDFLAGS)
25msyncclient_LDADD = ../src/libimobiledevice.la 25msyncclient_LDADD = ../src/libimobiledevice.la
26 26
27ideviceenterrecovery_SOURCES = ideviceenterrecovery.c
28ideviceenterrecovery_CFLAGS = $(AM_CFLAGS)
29ideviceenterrecovery_LDFLAGS = $(AM_LDFLAGS)
30ideviceenterrecovery_LDADD = ../src/libimobiledevice.la
31
32filerelaytest_SOURCES = filerelaytest.c 27filerelaytest_SOURCES = filerelaytest.c
33filerelaytest_CFLAGS = $(AM_CFLAGS) 28filerelaytest_CFLAGS = $(AM_CFLAGS)
34filerelaytest_LDFLAGS = $(AM_LDFLAGS) 29filerelaytest_LDFLAGS = $(AM_LDFLAGS)
@@ -36,4 +31,4 @@ filerelaytest_LDADD = ../src/libimobiledevice.la
36 31
37endif # ENABLE_DEVTOOLS 32endif # ENABLE_DEVTOOLS
38 33
39EXTRA_DIST = ideviceclient.c lckdclient.c afccheck.c msyncclient.c ideviceenterrecovery.c 34EXTRA_DIST = ideviceclient.c lckdclient.c afccheck.c msyncclient.c
diff --git a/dev/ideviceenterrecovery.c b/dev/ideviceenterrecovery.c
deleted file mode 100644
index a5cc48a..0000000
--- a/dev/ideviceenterrecovery.c
+++ /dev/null
@@ -1,93 +0,0 @@
1/*
2 * ideviceenterrecovery.c
3 * Simple utility to make a device in normal mode enter recovery mode.
4 *
5 * Copyright (c) 2009 Martin Szulecki All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <stdio.h>
23#include <string.h>
24#include <errno.h>
25#include <stdlib.h>
26
27#include <libimobiledevice/libimobiledevice.h>
28#include <libimobiledevice/lockdown.h>
29
30static void print_usage(int argc, char **argv)
31{
32 char *name = NULL;
33
34 name = strrchr(argv[0], '/');
35 printf("Usage: %s [OPTIONS] UUID\n", (name ? name + 1: argv[0]));
36 printf("Makes a device with the supplied 40-digit UUID enter recovery mode immediately.\n\n");
37 printf(" -d, --debug\t\tenable communication debugging\n");
38 printf(" -h, --help\t\tprints usage information\n");
39 printf("\n");
40}
41
42int main(int argc, char *argv[])
43{
44 lockdownd_client_t client = NULL;
45 idevice_t phone = NULL;
46 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
47 int i;
48 char uuid[41];
49 uuid[0] = 0;
50
51 /* parse cmdline args */
52 for (i = 1; i < argc; i++) {
53 if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) {
54 idevice_set_debug_level(1);
55 continue;
56 }
57 else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
58 print_usage(argc, argv);
59 return 0;
60 }
61 }
62
63 i--;
64 if (!argv[i] || (strlen(argv[i]) != 40)) {
65 print_usage(argc, argv);
66 return 0;
67 }
68 strcpy(uuid, argv[i]);
69
70 ret = idevice_new(&phone, uuid);
71 if (ret != IDEVICE_E_SUCCESS) {
72 printf("No device found with uuid %s, is it plugged in?\n", uuid);
73 return -1;
74 }
75
76 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "ideviceenterrecovery")) {
77 idevice_free(phone);
78 return -1;
79 }
80
81 /* run query and output information */
82 printf("Telling device with uuid %s to enter recovery mode.}\n", uuid);
83 if(lockdownd_enter_recovery(client) != LOCKDOWN_E_SUCCESS)
84 {
85 printf("Failed to enter recovery mode.\n");
86 }
87 printf("Device is successfully switching to recovery mode.\n");
88
89 lockdownd_client_free(client);
90 idevice_free(phone);
91
92 return 0;
93}