summaryrefslogtreecommitdiffstats
path: root/dev/afccheck.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2015-01-28 01:32:54 +0100
committerGravatar Martin Szulecki2015-01-28 01:32:54 +0100
commit64b1b1aa1eb53e47e3826f08f0cdc29d43a972b5 (patch)
tree79beea61702d5ee22ada725a7f76327dd19801cf /dev/afccheck.c
parentbf3223b972d60a82f394e8a2482f1b75c6caf0e4 (diff)
downloadlibimobiledevice-64b1b1aa1eb53e47e3826f08f0cdc29d43a972b5.tar.gz
libimobiledevice-64b1b1aa1eb53e47e3826f08f0cdc29d43a972b5.tar.bz2
Remove dev tools which are not installed and unmaintained anyways
Some might return as proper tools or be used as examples within the website documentation sooner or later.
Diffstat (limited to 'dev/afccheck.c')
-rw-r--r--dev/afccheck.c147
1 files changed, 0 insertions, 147 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c
deleted file mode 100644
index fed8538..0000000
--- a/dev/afccheck.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 * afccheck.c
3 * creates threads and check communication through AFC is done rigth
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 <stdlib.h>
23#include <stdio.h>
24#include <string.h>
25
26#include <libimobiledevice/libimobiledevice.h>
27#include <libimobiledevice/lockdown.h>
28#include <libimobiledevice/afc.h>
29#include "common/thread.h"
30
31#define BUFFER_SIZE 20000
32#define NB_THREADS 10
33
34
35typedef struct {
36 afc_client_t afc;
37 int id;
38} param;
39
40
41static void* check_afc(void *data)
42{
43 //prepare a buffer
44 unsigned int buffersize = BUFFER_SIZE * sizeof(unsigned int);
45 int *buf = (int *) malloc(buffersize);
46 int *buf2 = (int *) malloc(buffersize);
47 unsigned int bytes = 0;
48 uint64_t position = 0;
49
50 //fill buffer
51 int i = 0;
52 for (i = 0; i < BUFFER_SIZE; i++) {
53 buf[i] = ((param *) data)->id * i;
54 }
55
56 //now writes buffer on device
57 uint64_t file = 0;
58 char path[50];
59 sprintf(path, "/Buf%i", ((param *) data)->id);
60 afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RW, &file);
61 afc_file_write(((param *) data)->afc, file, (char *) buf, buffersize, &bytes);
62 afc_file_close(((param *) data)->afc, file);
63 file = 0;
64 if (bytes != buffersize)
65 printf("Write operation failed\n");
66
67 //now read it
68 bytes = 0;
69 afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file);
70 afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize/2, &bytes);
71 afc_file_read(((param *) data)->afc, file, (char *) buf2 + (buffersize/2), buffersize/2, &bytes);
72 if(AFC_E_SUCCESS != afc_file_tell(((param *) data)->afc, file, &position))
73 printf("Tell operation failed\n");
74 afc_file_close(((param *) data)->afc, file);
75 if (position != buffersize)
76 printf("Read operation failed\n");
77
78 //compare buffers
79 for (i = 0; i < BUFFER_SIZE; i++) {
80 if (buf[i] != buf2[i]) {
81 printf("Buffers are differents, stream corrupted\n");
82 break;
83 }
84 }
85
86 //cleanup
87 afc_remove_path(((param *) data)->afc, path);
88 return NULL;
89}
90
91int main(int argc, char *argv[])
92{
93 lockdownd_client_t client = NULL;
94 idevice_t phone = NULL;
95 lockdownd_service_descriptor_t service = NULL;
96 afc_client_t afc = NULL;
97
98 if (argc > 1 && !strcasecmp(argv[1], "--debug")) {
99 idevice_set_debug_level(1);
100 } else {
101 idevice_set_debug_level(0);
102 }
103
104 if (IDEVICE_E_SUCCESS != idevice_new(&phone, NULL)) {
105 printf("No device found, is it plugged in?\n");
106 return 1;
107 }
108
109 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "afccheck")) {
110 idevice_free(phone);
111 return 1;
112 }
113
114 if (LOCKDOWN_E_SUCCESS != lockdownd_start_service(client, "com.apple.afc", &service) || !service || !service->port) {
115 lockdownd_client_free(client);
116 idevice_free(phone);
117 fprintf(stderr, "Something went wrong when starting AFC.");
118 return 1;
119 }
120
121 afc_client_new(phone, service, &afc);
122
123 if (service) {
124 lockdownd_service_descriptor_free(service);
125 service = NULL;
126 }
127
128 thread_t threads[NB_THREADS];
129 param data[NB_THREADS];
130
131 int i = 0;
132 for (i = 0; i < NB_THREADS; i++) {
133 data[i].afc = afc;
134 data[i].id = i + 1;
135 thread_new(&threads[i], check_afc, data + i);
136 }
137
138 for (i = 0; i < NB_THREADS; i++) {
139 thread_join(threads[i]);
140 thread_free(threads[i]);
141 }
142
143 lockdownd_client_free(client);
144 idevice_free(phone);
145
146 return 0;
147}