summaryrefslogtreecommitdiffstats
path: root/dev
diff options
context:
space:
mode:
authorGravatar Matt Colyer2009-08-04 09:08:34 -0700
committerGravatar Matt Colyer2009-08-04 09:08:34 -0700
commit93a7ce48cd08100677ecad14d685b1efd610362d (patch)
tree9a9f3b4112121c3c1e82b36cda542f390b49984d /dev
parent04dc8e66956ff66f6438fd3ca151d58f528a03ea (diff)
parenta2644dc696951435f05bba6219085fad333ef076 (diff)
downloadlibimobiledevice-93a7ce48cd08100677ecad14d685b1efd610362d.tar.gz
libimobiledevice-93a7ce48cd08100677ecad14d685b1efd610362d.tar.bz2
Merge branch 'recovery'
Diffstat (limited to 'dev')
-rw-r--r--dev/Makefile.am7
-rw-r--r--dev/iphoneenterrecovery.c94
2 files changed, 100 insertions, 1 deletions
diff --git a/dev/Makefile.am b/dev/Makefile.am
index cd43623..27b3380 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 = iphoneclient lckd-client afccheck msyncclient 7noinst_PROGRAMS = iphoneclient lckd-client afccheck msyncclient iphoneenterrecovery
8 8
9iphoneclient_SOURCES = iphoneclient.c 9iphoneclient_SOURCES = iphoneclient.c
10iphoneclient_LDADD = ../src/libiphone.la 10iphoneclient_LDADD = ../src/libiphone.la
@@ -24,6 +24,11 @@ msyncclient_CFLAGS = $(AM_CFLAGS)
24msyncclient_LDFLAGS = $(AM_LDFLAGS) 24msyncclient_LDFLAGS = $(AM_LDFLAGS)
25msyncclient_LDADD = ../src/libiphone.la 25msyncclient_LDADD = ../src/libiphone.la
26 26
27iphoneenterrecovery_SOURCES = iphoneenterrecovery.c
28iphoneenterrecovery_CFLAGS = $(AM_CFLAGS)
29iphoneenterrecovery_LDFLAGS = $(AM_LDFLAGS)
30iphoneenterrecovery_LDADD = ../src/libiphone.la
31
27endif # ENABLE_DEVTOOLS 32endif # ENABLE_DEVTOOLS
28 33
29EXTRA_DIST = iphoneclient.c lckdclient.c afccheck.c msyncclient.c 34EXTRA_DIST = iphoneclient.c lckdclient.c afccheck.c msyncclient.c
diff --git a/dev/iphoneenterrecovery.c b/dev/iphoneenterrecovery.c
new file mode 100644
index 0000000..2f7891c
--- /dev/null
+++ b/dev/iphoneenterrecovery.c
@@ -0,0 +1,94 @@
1/*
2 * iphoneenterrecovery.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 <libiphone/libiphone.h>
28#include <libiphone/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 iphone_device_t phone = NULL;
46 iphone_error_t ret = IPHONE_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 iphone_set_debug_mask(DBGMASK_ALL);
55 iphone_set_debug_level(1);
56 continue;
57 }
58 else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
59 print_usage(argc, argv);
60 return 0;
61 }
62 }
63
64 i--;
65 if (!argv[i] || (strlen(argv[i]) != 40)) {
66 print_usage(argc, argv);
67 return 0;
68 }
69 strcpy(uuid, argv[i]);
70
71 ret = iphone_get_device_by_uuid(&phone, uuid);
72 if (ret != IPHONE_E_SUCCESS) {
73 printf("No device found with uuid %s, is it plugged in?\n", uuid);
74 return -1;
75 }
76
77 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
78 iphone_device_free(phone);
79 return -1;
80 }
81
82 /* run query and output information */
83 printf("Telling device with uuid %s to enter recovery mode.}\n", uuid);
84 if(lockdownd_enter_recovery(client) != LOCKDOWN_E_SUCCESS)
85 {
86 printf("Failed to enter recovery mode.\n");
87 }
88 printf("Device is successfully switching to recovery mode.\n");
89
90 lockdownd_client_free(client);
91 iphone_device_free(phone);
92
93 return 0;
94}