summaryrefslogtreecommitdiffstats
path: root/dev/lckdclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/lckdclient.c')
-rw-r--r--dev/lckdclient.c101
1 files changed, 0 insertions, 101 deletions
diff --git a/dev/lckdclient.c b/dev/lckdclient.c
deleted file mode 100644
index c96f052..0000000
--- a/dev/lckdclient.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * lckdclient.c
3 * Rudimentary command line interface to the Lockdown protocol
4 *
5 * Copyright (c) 2008 Jonathan Beck 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 <stdlib.h>
24#include <string.h>
25#include <glib.h>
26#include <readline/readline.h>
27#include <readline/history.h>
28
29#include <libiphone/libiphone.h>
30
31
32int main(int argc, char *argv[])
33{
34 int bytes = 0, port = 0, i = 0;
35 iphone_lckd_client_t control = NULL;
36 iphone_device_t phone = NULL;
37
38 iphone_set_debug(1);
39
40 if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) {
41 printf("No iPhone found, is it plugged in?\n");
42 return -1;
43 }
44
45 if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) {
46 iphone_free_device(phone);
47 return -1;
48 }
49
50 char *uid = NULL;
51 if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(control, &uid)) {
52 printf("DeviceUniqueID : %s\n", uid);
53 free(uid);
54 }
55
56 using_history();
57 int loop = TRUE;
58 while (loop) {
59 char *cmd = readline("> ");
60 if (cmd) {
61
62 gchar **args = g_strsplit(cmd, " ", 0);
63
64 int len = 0;
65 if (args) {
66 while (*(args + len)) {
67 g_strstrip(*(args + len));
68 len++;
69 }
70 }
71
72 if (len > 0) {
73 add_history(cmd);
74 if (!strcmp(*args, "quit"))
75 loop = FALSE;
76
77 if (!strcmp(*args, "get") && len == 3) {
78 char *value = NULL;
79 if (IPHONE_E_SUCCESS == lockdownd_generic_get_value(control, *(args + 1), *(args + 2), &value))
80 printf("Success : value = %s\n", value);
81 else
82 printf("Error\n");
83 }
84
85 if (!strcmp(*args, "start") && len == 2) {
86 int port = 0;
87 iphone_lckd_start_service(control, *(args + 1), &port);
88 printf("%i\n", port);
89 }
90 }
91 g_strfreev(args);
92 }
93 free(cmd);
94 cmd = NULL;
95 }
96 clear_history();
97 iphone_lckd_free_client(control);
98 iphone_free_device(phone);
99
100 return 0;
101}