summaryrefslogtreecommitdiffstats
path: root/dev/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/main.c')
-rw-r--r--dev/main.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/dev/main.c b/dev/main.c
index c8c9dfa..fe340ff 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -25,6 +25,7 @@
25#include <usb.h> 25#include <usb.h>
26 26
27#include <libiphone/libiphone.h> 27#include <libiphone/libiphone.h>
28#include <libiphone/afc.h>
28#include "../src/utils.h" 29#include "../src/utils.h"
29 30
30void notifier(const char *notification) 31void notifier(const char *notification)
@@ -97,8 +98,8 @@ int main(int argc, char *argv[])
97 iphone_lckd_start_service(control, "com.apple.afc", &port); 98 iphone_lckd_start_service(control, "com.apple.afc", &port);
98 99
99 if (port) { 100 if (port) {
100 iphone_afc_client_t afc = NULL; 101 afc_client_t afc = NULL;
101 iphone_afc_new_client(phone, port, &afc); 102 afc_new_client(phone, port, &afc);
102 if (afc) { 103 if (afc) {
103 iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp); 104 iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp);
104 if (npp) { 105 if (npp) {
@@ -120,18 +121,18 @@ int main(int argc, char *argv[])
120 121
121 perform_notification(phone, control, NP_SYNC_WILL_START); 122 perform_notification(phone, control, NP_SYNC_WILL_START);
122 123
123 iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); 124 afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile);
124 if (lockfile) { 125 if (lockfile) {
125 printf("locking file\n"); 126 printf("locking file\n");
126 iphone_afc_lock_file(afc, lockfile, 2 | 4); 127 afc_lock_file(afc, lockfile, 2 | 4);
127 128
128 perform_notification(phone, control, NP_SYNC_DID_START); 129 perform_notification(phone, control, NP_SYNC_DID_START);
129 } 130 }
130 131
131 char **dirs = NULL; 132 char **dirs = NULL;
132 iphone_afc_get_dir_list(afc, "/eafaedf", &dirs); 133 afc_get_dir_list(afc, "/eafaedf", &dirs);
133 if (!dirs) 134 if (!dirs)
134 iphone_afc_get_dir_list(afc, "/", &dirs); 135 afc_get_dir_list(afc, "/", &dirs);
135 printf("Directory time.\n"); 136 printf("Directory time.\n");
136 for (i = 0; dirs[i]; i++) { 137 for (i = 0; dirs[i]; i++) {
137 printf("/%s\n", dirs[i]); 138 printf("/%s\n", dirs[i]);
@@ -140,7 +141,7 @@ int main(int argc, char *argv[])
140 g_strfreev(dirs); 141 g_strfreev(dirs);
141 142
142 dirs = NULL; 143 dirs = NULL;
143 iphone_afc_get_devinfo(afc, &dirs); 144 afc_get_devinfo(afc, &dirs);
144 if (dirs) { 145 if (dirs) {
145 for (i = 0; dirs[i]; i += 2) { 146 for (i = 0; dirs[i]; i += 2) {
146 printf("%s: %s\n", dirs[i], dirs[i + 1]); 147 printf("%s: %s\n", dirs[i], dirs[i + 1]);
@@ -151,7 +152,7 @@ int main(int argc, char *argv[])
151 uint64_t my_file = 0; 152 uint64_t my_file = 0;
152 char **info = NULL; 153 char **info = NULL;
153 uint64_t fsize = 0; 154 uint64_t fsize = 0;
154 if (IPHONE_E_SUCCESS == iphone_afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) { 155 if (IPHONE_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) {
155 for (i = 0; info[i]; i += 2) { 156 for (i = 0; info[i]; i += 2) {
156 printf("%s: %s\n", info[i], info[i+1]); 157 printf("%s: %s\n", info[i], info[i+1]);
157 if (!strcmp(info[i], "st_size")) { 158 if (!strcmp(info[i], "st_size")) {
@@ -161,58 +162,58 @@ int main(int argc, char *argv[])
161 } 162 }
162 163
163 if (IPHONE_E_SUCCESS == 164 if (IPHONE_E_SUCCESS ==
164 iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { 165 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) {
165 printf("A file size: %i\n", fsize); 166 printf("A file size: %i\n", fsize);
166 char *file_data = (char *) malloc(sizeof(char) * fsize); 167 char *file_data = (char *) malloc(sizeof(char) * fsize);
167 iphone_afc_read_file(afc, my_file, file_data, fsize, &bytes); 168 afc_read_file(afc, my_file, file_data, fsize, &bytes);
168 if (bytes >= 0) { 169 if (bytes >= 0) {
169 printf("The file's data:\n"); 170 printf("The file's data:\n");
170 fwrite(file_data, 1, bytes, stdout); 171 fwrite(file_data, 1, bytes, stdout);
171 } 172 }
172 printf("\nClosing my file.\n"); 173 printf("\nClosing my file.\n");
173 iphone_afc_close_file(afc, my_file); 174 afc_close_file(afc, my_file);
174 free(file_data); 175 free(file_data);
175 } else 176 } else
176 printf("couldn't open a file\n"); 177 printf("couldn't open a file\n");
177 178
178 iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); 179 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file);
179 if (my_file) { 180 if (my_file) {
180 char *outdatafile = strdup("this is a bitchin text file\n"); 181 char *outdatafile = strdup("this is a bitchin text file\n");
181 iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); 182 afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes);
182 free(outdatafile); 183 free(outdatafile);
183 if (bytes > 0) 184 if (bytes > 0)
184 printf("Wrote a surprise. ;)\n"); 185 printf("Wrote a surprise. ;)\n");
185 else 186 else
186 printf("I wanted to write a surprise, but... :(\n"); 187 printf("I wanted to write a surprise, but... :(\n");
187 iphone_afc_close_file(afc, my_file); 188 afc_close_file(afc, my_file);
188 } 189 }
189 printf("Deleting a file...\n"); 190 printf("Deleting a file...\n");
190 bytes = iphone_afc_delete_file(afc, "/delme"); 191 bytes = afc_delete_file(afc, "/delme");
191 if (bytes) 192 if (bytes)
192 printf("Success.\n"); 193 printf("Success.\n");
193 else 194 else
194 printf("Failure. (expected unless you have a /delme file on your phone)\n"); 195 printf("Failure. (expected unless you have a /delme file on your phone)\n");
195 196
196 printf("Renaming a file...\n"); 197 printf("Renaming a file...\n");
197 bytes = iphone_afc_rename_file(afc, "/renme", "/renme2"); 198 bytes = afc_rename_file(afc, "/renme", "/renme2");
198 if (bytes > 0) 199 if (bytes > 0)
199 printf("Success.\n"); 200 printf("Success.\n");
200 else 201 else
201 printf("Failure. (expected unless you have a /renme file on your phone)\n"); 202 printf("Failure. (expected unless you have a /renme file on your phone)\n");
202 203
203 printf("Seek & read\n"); 204 printf("Seek & read\n");
204 iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); 205 afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file);
205 if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5, SEEK_CUR)) 206 if (IPHONE_E_SUCCESS != afc_seek_file(afc, my_file, 5, SEEK_CUR))
206 printf("WARN: SEEK DID NOT WORK\n"); 207 printf("WARN: SEEK DID NOT WORK\n");
207 char *threeletterword = (char *) malloc(sizeof(char) * 5); 208 char *threeletterword = (char *) malloc(sizeof(char) * 5);
208 iphone_afc_read_file(afc, my_file, threeletterword, 3, &bytes); 209 afc_read_file(afc, my_file, threeletterword, 3, &bytes);
209 threeletterword[3] = '\0'; 210 threeletterword[3] = '\0';
210 if (bytes > 0) 211 if (bytes > 0)
211 printf("Result: %s\n", threeletterword); 212 printf("Result: %s\n", threeletterword);
212 else 213 else
213 printf("Couldn't read!\n"); 214 printf("Couldn't read!\n");
214 free(threeletterword); 215 free(threeletterword);
215 iphone_afc_close_file(afc, my_file); 216 afc_close_file(afc, my_file);
216 } 217 }
217 218
218 if (gnp && lockfile) { 219 if (gnp && lockfile) {
@@ -245,10 +246,10 @@ int main(int argc, char *argv[])
245 //perform_notification(phone, control, NP_SYNC_DID_FINISH); 246 //perform_notification(phone, control, NP_SYNC_DID_FINISH);
246 247
247 printf("XXX unlocking file\n"); 248 printf("XXX unlocking file\n");
248 iphone_afc_lock_file(afc, lockfile, 8 | 4); 249 afc_lock_file(afc, lockfile, 8 | 4);
249 250
250 printf("XXX closing file\n"); 251 printf("XXX closing file\n");
251 iphone_afc_close_file(afc, lockfile); 252 afc_close_file(afc, lockfile);
252 } 253 }
253 254
254 if (gnp) { 255 if (gnp) {
@@ -256,7 +257,7 @@ int main(int argc, char *argv[])
256 gnp = NULL; 257 gnp = NULL;
257 } 258 }
258 259
259 iphone_afc_free_client(afc); 260 afc_free_client(afc);
260 } else { 261 } else {
261 printf("Start service failure.\n"); 262 printf("Start service failure.\n");
262 } 263 }