diff options
| author | 2009-07-26 19:34:22 -0700 | |
|---|---|---|
| committer | 2009-07-26 19:34:22 -0700 | |
| commit | eea538c94f01f8054f69f059614f19400187a472 (patch) | |
| tree | 209a12dc8c8eaece15b8153d15e689c8c2147ab6 /dev/afccheck.c | |
| parent | 8ebfd7d8eea89bb27e4e6dbb1f37fd90d98b439c (diff) | |
| parent | 19c9750d670435ce430f0fc85a55faf127bdfbf9 (diff) | |
| download | libimobiledevice-eea538c94f01f8054f69f059614f19400187a472.tar.gz libimobiledevice-eea538c94f01f8054f69f059614f19400187a472.tar.bz2 | |
Merge commit 'martin-s/martin'
[#46 state:resolved]
Diffstat (limited to 'dev/afccheck.c')
| -rw-r--r-- | dev/afccheck.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c index cf75e71..b3fa102 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c | |||
| @@ -45,6 +45,8 @@ static void check_afc(gpointer data) | |||
| 45 | int *buf = (int *) malloc(buffersize); | 45 | int *buf = (int *) malloc(buffersize); |
| 46 | int *buf2 = (int *) malloc(buffersize); | 46 | int *buf2 = (int *) malloc(buffersize); |
| 47 | unsigned int bytes = 0; | 47 | unsigned int bytes = 0; |
| 48 | uint64_t position = 0; | ||
| 49 | |||
| 48 | //fill buffer | 50 | //fill buffer |
| 49 | int i = 0; | 51 | int i = 0; |
| 50 | for (i = 0; i < BUFFER_SIZE; i++) { | 52 | for (i = 0; i < BUFFER_SIZE; i++) { |
| @@ -55,19 +57,22 @@ static void check_afc(gpointer data) | |||
| 55 | uint64_t file = 0; | 57 | uint64_t file = 0; |
| 56 | char path[50]; | 58 | char path[50]; |
| 57 | sprintf(path, "/Buf%i", ((param *) data)->id); | 59 | sprintf(path, "/Buf%i", ((param *) data)->id); |
| 58 | afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); | 60 | afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RW, &file); |
| 59 | afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); | 61 | afc_file_write(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); |
| 60 | afc_close_file(((param *) data)->afc, file); | 62 | afc_file_close(((param *) data)->afc, file); |
| 61 | file = 0; | 63 | file = 0; |
| 62 | if (bytes != buffersize) | 64 | if (bytes != buffersize) |
| 63 | printf("Write operation failed\n"); | 65 | printf("Write operation failed\n"); |
| 64 | 66 | ||
| 65 | //now read it | 67 | //now read it |
| 66 | bytes = 0; | 68 | bytes = 0; |
| 67 | afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); | 69 | afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); |
| 68 | afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); | 70 | afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize/2, &bytes); |
| 69 | afc_close_file(((param *) data)->afc, file); | 71 | afc_file_read(((param *) data)->afc, file, (char *) buf2 + (buffersize/2), buffersize/2, &bytes); |
| 70 | if (bytes != buffersize) | 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) | ||
| 71 | printf("Read operation failed\n"); | 76 | printf("Read operation failed\n"); |
| 72 | 77 | ||
| 73 | //compare buffers | 78 | //compare buffers |
| @@ -79,7 +84,7 @@ static void check_afc(gpointer data) | |||
| 79 | } | 84 | } |
| 80 | 85 | ||
| 81 | //cleanup | 86 | //cleanup |
| 82 | afc_delete_file(((param *) data)->afc, path); | 87 | afc_remove_path(((param *) data)->afc, path); |
| 83 | g_thread_exit(0); | 88 | g_thread_exit(0); |
| 84 | } | 89 | } |
| 85 | 90 | ||
| @@ -91,24 +96,32 @@ int main(int argc, char *argv[]) | |||
| 91 | int port = 0; | 96 | int port = 0; |
| 92 | afc_client_t afc = NULL; | 97 | afc_client_t afc = NULL; |
| 93 | 98 | ||
| 99 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | ||
| 100 | iphone_set_debug_level(1); | ||
| 101 | iphone_set_debug_mask(DBGMASK_ALL); | ||
| 102 | } else { | ||
| 103 | iphone_set_debug_level(0); | ||
| 104 | iphone_set_debug_mask(DBGMASK_NONE); | ||
| 105 | } | ||
| 106 | |||
| 94 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { | 107 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { |
| 95 | printf("No iPhone found, is it plugged in?\n"); | 108 | printf("No iPhone found, is it plugged in?\n"); |
| 96 | return 1; | 109 | return 1; |
| 97 | } | 110 | } |
| 98 | 111 | ||
| 99 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 112 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { |
| 100 | iphone_free_device(phone); | 113 | iphone_device_free(phone); |
| 101 | return 1; | 114 | return 1; |
| 102 | } | 115 | } |
| 103 | 116 | ||
| 104 | if (IPHONE_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { | 117 | if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { |
| 105 | lockdownd_free_client(client); | 118 | lockdownd_client_free(client); |
| 106 | iphone_free_device(phone); | 119 | iphone_device_free(phone); |
| 107 | fprintf(stderr, "Something went wrong when starting AFC."); | 120 | fprintf(stderr, "Something went wrong when starting AFC."); |
| 108 | return 1; | 121 | return 1; |
| 109 | } | 122 | } |
| 110 | 123 | ||
| 111 | afc_new_client(phone, port, &afc); | 124 | afc_client_new(phone, port, &afc); |
| 112 | 125 | ||
| 113 | //makes sure thread environment is available | 126 | //makes sure thread environment is available |
| 114 | if (!g_thread_supported()) | 127 | if (!g_thread_supported()) |
| @@ -128,9 +141,8 @@ int main(int argc, char *argv[]) | |||
| 128 | g_thread_join(threads[i]); | 141 | g_thread_join(threads[i]); |
| 129 | } | 142 | } |
| 130 | 143 | ||
| 131 | 144 | lockdownd_client_free(client); | |
| 132 | lockdownd_free_client(client); | 145 | iphone_device_free(phone); |
| 133 | iphone_free_device(phone); | ||
| 134 | 146 | ||
| 135 | return 0; | 147 | return 0; |
| 136 | } | 148 | } |
