3
* Rudimentary command line interface to the Lockdown protocol
5
* Copyright (c) 2008 Jonathan Beck All Rights Reserved.
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.
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.
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
26
#include <readline/readline.h>
27
#include <readline/history.h>
29
#include <libimobiledevice/libimobiledevice.h>
30
#include <libimobiledevice/lockdown.h>
32
int main(int argc, char *argv[])
34
lockdownd_client_t client = NULL;
35
idevice_t phone = NULL;
37
idevice_set_debug_level(1);
39
if (IDEVICE_E_SUCCESS != idevice_new(&phone, NULL)) {
40
printf("No device found, is it plugged in?\n");
45
if (IDEVICE_E_SUCCESS == idevice_get_uuid(phone, &uuid)) {
46
printf("DeviceUniqueID : %s\n", uuid);
51
if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "lckdclient")) {
59
char *cmd = readline("> ");
62
gchar **args = g_strsplit(cmd, " ", 0);
66
while (*(args + len)) {
67
g_strstrip(*(args + len));
74
if (!strcmp(*args, "quit"))
77
if (!strcmp(*args, "get") && len >= 2) {
79
if (LOCKDOWN_E_SUCCESS == lockdownd_get_value(client, len == 3 ? *(args + 1):NULL, len == 3 ? *(args + 2):*(args + 1), &value))
83
plist_to_xml(value, &xml, &length);
84
printf("Success : value = %s\n", xml);
94
if (!strcmp(*args, "start") && len == 2) {
96
if(LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, *(args + 1), &port)) {
97
printf("started service %s on port %i\n", *(args + 1), port);
101
printf("failed to start service %s on device.\n", *(args + 1));
111
lockdownd_client_free(client);