diff options
Diffstat (limited to 'dev/filerelaytest.c')
| -rw-r--r-- | dev/filerelaytest.c | 108 | 
1 files changed, 0 insertions, 108 deletions
| diff --git a/dev/filerelaytest.c b/dev/filerelaytest.c deleted file mode 100644 index 6e611c0..0000000 --- a/dev/filerelaytest.c +++ /dev/null | |||
| @@ -1,108 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * filerelaytest.c | ||
| 3 | * Simple Test program showing the usage of the file_relay interface. | ||
| 4 | * | ||
| 5 | * Copyright (c) 2010 Nikias Bassen 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 | #include <stdio.h> | ||
| 22 | #include <libimobiledevice/libimobiledevice.h> | ||
| 23 | #include <libimobiledevice/lockdown.h> | ||
| 24 | #include <libimobiledevice/file_relay.h> | ||
| 25 | |||
| 26 | int main(int argc, char **argv) | ||
| 27 | { | ||
| 28 | idevice_t dev = NULL; | ||
| 29 | lockdownd_client_t client = NULL; | ||
| 30 | file_relay_client_t frc = NULL; | ||
| 31 | |||
| 32 | if (idevice_new(&dev, NULL) != IDEVICE_E_SUCCESS) { | ||
| 33 | printf("no device connected?!\n"); | ||
| 34 | goto leave_cleanup; | ||
| 35 | } | ||
| 36 | |||
| 37 | printf("connecting...\n"); | ||
| 38 | if (lockdownd_client_new_with_handshake(dev, &client, NULL) != LOCKDOWN_E_SUCCESS) { | ||
| 39 | printf("could not connect to lockdownd!\n"); | ||
| 40 | goto leave_cleanup; | ||
| 41 | } | ||
| 42 | |||
| 43 | uint16_t port = 0; | ||
| 44 | if (lockdownd_start_service(client, "com.apple.mobile.file_relay", &port) != LOCKDOWN_E_SUCCESS) { | ||
| 45 | printf("could not start file_relay service!\n"); | ||
| 46 | goto leave_cleanup; | ||
| 47 | } | ||
| 48 | |||
| 49 | if (client) { | ||
| 50 | lockdownd_client_free(client); | ||
| 51 | client = NULL; | ||
| 52 | } | ||
| 53 | |||
| 54 | if (file_relay_client_new(dev, port, &frc) != FILE_RELAY_E_SUCCESS) { | ||
| 55 | printf("could not connect to file_relay service!\n"); | ||
| 56 | goto leave_cleanup; | ||
| 57 | } | ||
| 58 | |||
| 59 | idevice_connection_t dump = NULL; | ||
| 60 | const char *sources[] = {"AppleSupport", "Network", "VPN", "WiFi", "UserDatabases", "CrashReporter", "tmp", "SystemConfiguration", NULL}; | ||
| 61 | |||
| 62 | printf("Requesting"); | ||
| 63 | int i = 0; | ||
| 64 | while (sources[i]) { | ||
| 65 | printf(" %s", sources[i]); | ||
| 66 | i++; | ||
| 67 | } | ||
| 68 | printf("\n"); | ||
| 69 | |||
| 70 | if (file_relay_request_sources(frc, sources, &dump) != FILE_RELAY_E_SUCCESS) { | ||
| 71 | printf("could not get sources\n"); | ||
| 72 | goto leave_cleanup; | ||
| 73 | } | ||
| 74 | |||
| 75 | if (!dump) { | ||
| 76 | printf("did not get connection!\n"); | ||
| 77 | goto leave_cleanup; | ||
| 78 | } | ||
| 79 | |||
| 80 | uint32_t cnt = 0; | ||
| 81 | uint32_t len = 0; | ||
| 82 | char buf[4096]; | ||
| 83 | FILE *f = fopen("dump.cpio.gz", "w"); | ||
| 84 | setbuf(stdout, NULL); | ||
| 85 | printf("receiving "); | ||
| 86 | while (idevice_connection_receive(dump, buf, 4096, &len) == IDEVICE_E_SUCCESS) { | ||
| 87 | fwrite(buf, 1, len, f); | ||
| 88 | cnt += len; | ||
| 89 | printf("."); | ||
| 90 | len = 0; | ||
| 91 | } | ||
| 92 | printf("\n"); | ||
| 93 | fclose(f); | ||
| 94 | printf("total size received: %d\n", cnt); | ||
| 95 | |||
| 96 | leave_cleanup: | ||
| 97 | if (frc) { | ||
| 98 | file_relay_client_free(frc); | ||
| 99 | } | ||
| 100 | if (client) { | ||
| 101 | lockdownd_client_free(client); | ||
| 102 | } | ||
| 103 | if (dev) { | ||
| 104 | idevice_free(dev); | ||
| 105 | } | ||
| 106 | |||
| 107 | return 0; | ||
| 108 | } | ||
