From abb74bcae219c25cffb7e30db6a34c69dcd92f0a Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 6 Jul 2009 19:38:00 +0200 Subject: API cleanup for AFC Signed-off-by: Martin Szulecki --- dev/afccheck.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'dev/afccheck.c') diff --git a/dev/afccheck.c b/dev/afccheck.c index 965981b..b107437 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -25,13 +25,14 @@ #include #include +#include #define BUFFER_SIZE 20000 #define NB_THREADS 10 typedef struct { - iphone_afc_client_t afc; + afc_client_t afc; int id; } param; @@ -53,18 +54,18 @@ void check_afc(gpointer data) uint64_t file = 0; char path[50]; sprintf(path, "/Buf%i", ((param *) data)->id); - iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); - iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); - iphone_afc_close_file(((param *) data)->afc, file); + afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); + afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); + afc_close_file(((param *) data)->afc, file); file = 0; if (bytes != buffersize) printf("Write operation failed\n"); //now read it bytes = 0; - iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); - iphone_afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); - iphone_afc_close_file(((param *) data)->afc, file); + afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); + afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); + afc_close_file(((param *) data)->afc, file); if (bytes != buffersize) printf("Read operation failed\n"); @@ -77,7 +78,7 @@ void check_afc(gpointer data) } //cleanup - iphone_afc_delete_file(((param *) data)->afc, path); + afc_delete_file(((param *) data)->afc, path); g_thread_exit(0); } @@ -87,7 +88,7 @@ int main(int argc, char *argv[]) iphone_device_t phone = NULL; GError *err; int port = 0; - iphone_afc_client_t afc = NULL; + afc_client_t afc = NULL; if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { printf("No iPhone found, is it plugged in?\n"); @@ -106,7 +107,7 @@ int main(int argc, char *argv[]) return 1; } - iphone_afc_new_client(phone, port, &afc); + afc_new_client(phone, port, &afc); //makes sure thread environment is available if (!g_thread_supported()) -- cgit v1.1-32-gdbae From 62a6f558ac7ca7a9b83c2ed810929732c02bbc9d Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 7 Jul 2009 21:02:00 +0200 Subject: Cleanup lockdown request API and fix docs, tools, bindings and exports --- dev/afccheck.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'dev/afccheck.c') diff --git a/dev/afccheck.c b/dev/afccheck.c index b107437..9174e32 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -25,6 +25,7 @@ #include #include +#include #include #define BUFFER_SIZE 20000 @@ -40,10 +41,10 @@ typedef struct { void check_afc(gpointer data) { //prepare a buffer - int buffersize = BUFFER_SIZE * sizeof(int); + unsigned int buffersize = BUFFER_SIZE * sizeof(unsigned int); int *buf = (int *) malloc(buffersize); int *buf2 = (int *) malloc(buffersize); - int bytes = 0; + unsigned int bytes = 0; //fill buffer int i = 0; for (i = 0; i < BUFFER_SIZE; i++) { @@ -84,7 +85,7 @@ void check_afc(gpointer data) int main(int argc, char *argv[]) { - iphone_lckd_client_t control = NULL; + lockdownd_client_t client = NULL; iphone_device_t phone = NULL; GError *err; int port = 0; @@ -95,13 +96,13 @@ int main(int argc, char *argv[]) return 1; } - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { iphone_free_device(phone); return 1; } - if (IPHONE_E_SUCCESS == iphone_lckd_start_service(control, "com.apple.afc", &port) && !port) { - iphone_lckd_free_client(control); + if (IPHONE_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { + lockdownd_free_client(client); iphone_free_device(phone); fprintf(stderr, "Something went wrong when starting AFC."); return 1; @@ -128,7 +129,7 @@ int main(int argc, char *argv[]) } - iphone_lckd_free_client(control); + lockdownd_free_client(client); iphone_free_device(phone); return 0; -- cgit v1.1-32-gdbae From cd1aa1c8107c1609746c12a6cd6777bd053167df Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 24 Jul 2009 16:21:37 +0200 Subject: Add --debug option to afccheck --- dev/afccheck.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'dev/afccheck.c') diff --git a/dev/afccheck.c b/dev/afccheck.c index 9174e32..0525417 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -91,6 +91,14 @@ int main(int argc, char *argv[]) int port = 0; afc_client_t afc = NULL; + if (argc > 1 && !strcasecmp(argv[1], "--debug")) { + iphone_set_debug_level(1); + iphone_set_debug_mask(DBGMASK_ALL); + } else { + iphone_set_debug_level(0); + iphone_set_debug_mask(DBGMASK_NONE); + } + if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { printf("No iPhone found, is it plugged in?\n"); return 1; -- cgit v1.1-32-gdbae From f5e9d76ebd74999512ab73f44fabba86879b1c1f Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 02:40:25 +0200 Subject: Update lockdown API and introduce new error codes --- dev/afccheck.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'dev/afccheck.c') diff --git a/dev/afccheck.c b/dev/afccheck.c index 0525417..370742b 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -104,13 +104,13 @@ int main(int argc, char *argv[]) return 1; } - if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { iphone_free_device(phone); return 1; } - if (IPHONE_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { - lockdownd_free_client(client); + if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { + lockdownd_client_free(client); iphone_free_device(phone); fprintf(stderr, "Something went wrong when starting AFC."); return 1; @@ -136,8 +136,7 @@ int main(int argc, char *argv[]) g_thread_join(threads[i]); } - - lockdownd_free_client(client); + lockdownd_client_free(client); iphone_free_device(phone); return 0; -- cgit v1.1-32-gdbae From 5cb9ecc85240102402082c442d561d7350732027 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 02:54:40 +0200 Subject: Follow glib style and rename iphone_free_device to iphone_device_free --- dev/afccheck.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'dev/afccheck.c') diff --git a/dev/afccheck.c b/dev/afccheck.c index 370742b..067dd5b 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -105,13 +105,13 @@ int main(int argc, char *argv[]) } if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { - iphone_free_device(phone); + iphone_device_free(phone); return 1; } if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); fprintf(stderr, "Something went wrong when starting AFC."); return 1; } @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) } lockdownd_client_free(client); - iphone_free_device(phone); + iphone_device_free(phone); return 0; } -- cgit v1.1-32-gdbae From 50be30047dbb0d38fd8d61763c13ec75d2b52543 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 03:26:39 +0200 Subject: Update AFC API and use error codes from the STATUS operation response --- dev/afccheck.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'dev/afccheck.c') diff --git a/dev/afccheck.c b/dev/afccheck.c index 067dd5b..d06a147 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -55,18 +55,18 @@ void check_afc(gpointer data) uint64_t file = 0; char path[50]; sprintf(path, "/Buf%i", ((param *) data)->id); - afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); - afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); - afc_close_file(((param *) data)->afc, file); + afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RW, &file); + afc_file_write(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); + afc_file_close(((param *) data)->afc, file); file = 0; if (bytes != buffersize) printf("Write operation failed\n"); //now read it bytes = 0; - afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); - afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); - afc_close_file(((param *) data)->afc, file); + afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); + afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); + afc_file_close(((param *) data)->afc, file); if (bytes != buffersize) printf("Read operation failed\n"); @@ -79,7 +79,7 @@ void check_afc(gpointer data) } //cleanup - afc_delete_file(((param *) data)->afc, path); + afc_remove_path(((param *) data)->afc, path); g_thread_exit(0); } @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) return 1; } - afc_new_client(phone, port, &afc); + afc_client_new(phone, port, &afc); //makes sure thread environment is available if (!g_thread_supported()) -- cgit v1.1-32-gdbae From 0e255cfe381caedf0375e6834021333d971f8050 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 03:46:54 +0200 Subject: Implement afc_file_tell() and adjust afc_receive_data() to handle it --- dev/afccheck.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'dev/afccheck.c') diff --git a/dev/afccheck.c b/dev/afccheck.c index d06a147..a9b666e 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -45,6 +45,8 @@ void check_afc(gpointer data) int *buf = (int *) malloc(buffersize); int *buf2 = (int *) malloc(buffersize); unsigned int bytes = 0; + uint64_t position = 0; + //fill buffer int i = 0; for (i = 0; i < BUFFER_SIZE; i++) { @@ -65,9 +67,12 @@ void check_afc(gpointer data) //now read it bytes = 0; afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); - afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); + afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize/2, &bytes); + afc_file_read(((param *) data)->afc, file, (char *) buf2 + (buffersize/2), buffersize/2, &bytes); + if(AFC_E_SUCCESS != afc_file_tell(((param *) data)->afc, file, &position)) + printf("Tell operation failed\n"); afc_file_close(((param *) data)->afc, file); - if (bytes != buffersize) + if (position != buffersize) printf("Read operation failed\n"); //compare buffers -- cgit v1.1-32-gdbae