diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/afccheck.c | 46 | ||||
| -rw-r--r-- | dev/iphone_id.c | 12 | ||||
| -rw-r--r-- | dev/iphoneinfo.c | 105 | ||||
| -rw-r--r-- | dev/lckdclient.c | 32 | ||||
| -rw-r--r-- | dev/main.c | 89 | ||||
| -rw-r--r-- | dev/msyncclient.c | 20 | ||||
| -rw-r--r-- | dev/syslog_relay.c | 17 |
7 files changed, 150 insertions, 171 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 | } |
diff --git a/dev/iphone_id.c b/dev/iphone_id.c index 15081f0..f68fc8b 100644 --- a/dev/iphone_id.c +++ b/dev/iphone_id.c | |||
| @@ -60,7 +60,7 @@ int main(int argc, char **argv) | |||
| 60 | return 0; | 60 | return 0; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | iphone_set_debug(0); | 63 | iphone_set_debug_level(0); |
| 64 | 64 | ||
| 65 | iphone_get_device_by_uuid(&phone, argv[0]); | 65 | iphone_get_device_by_uuid(&phone, argv[0]); |
| 66 | if (!phone) { | 66 | if (!phone) { |
| @@ -68,19 +68,19 @@ int main(int argc, char **argv) | |||
| 68 | return -2; | 68 | return -2; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 71 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { |
| 72 | iphone_free_device(phone); | 72 | iphone_device_free(phone); |
| 73 | fprintf(stderr, "ERROR: Connecting to device failed!\n"); | 73 | fprintf(stderr, "ERROR: Connecting to device failed!\n"); |
| 74 | return -2; | 74 | return -2; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | if ((IPHONE_E_SUCCESS != lockdownd_get_device_name(client, &devname)) || !devname) { | 77 | if ((LOCKDOWN_E_SUCCESS != lockdownd_get_device_name(client, &devname)) || !devname) { |
| 78 | fprintf(stderr, "ERROR: Could not get device name!\n"); | 78 | fprintf(stderr, "ERROR: Could not get device name!\n"); |
| 79 | ret = -2; | 79 | ret = -2; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | lockdownd_free_client(client); | 82 | lockdownd_client_free(client); |
| 83 | iphone_free_device(phone); | 83 | iphone_device_free(phone); |
| 84 | 84 | ||
| 85 | if (ret == 0) { | 85 | if (ret == 0) { |
| 86 | printf("%s\n", devname); | 86 | printf("%s\n", devname); |
diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c index 9d690f9..7e275b2 100644 --- a/dev/iphoneinfo.c +++ b/dev/iphoneinfo.c | |||
| @@ -51,7 +51,6 @@ static const char *domains[] = { | |||
| 51 | 51 | ||
| 52 | int is_domain_known(char *domain); | 52 | int is_domain_known(char *domain); |
| 53 | void print_usage(int argc, char **argv); | 53 | void print_usage(int argc, char **argv); |
| 54 | void print_lckd_request_result(lockdownd_client_t client, const char *domain, const char *request, const char *key, int format); | ||
| 55 | void plist_node_to_string(plist_t *node); | 54 | void plist_node_to_string(plist_t *node); |
| 56 | void plist_children_to_string(plist_t *node); | 55 | void plist_children_to_string(plist_t *node); |
| 57 | 56 | ||
| @@ -65,13 +64,16 @@ int main(int argc, char *argv[]) | |||
| 65 | char uuid[41]; | 64 | char uuid[41]; |
| 66 | char *domain = NULL; | 65 | char *domain = NULL; |
| 67 | char *key = NULL; | 66 | char *key = NULL; |
| 67 | char *xml_doc = NULL; | ||
| 68 | uint32_t xml_length; | ||
| 69 | plist_t node = NULL; | ||
| 68 | uuid[0] = 0; | 70 | uuid[0] = 0; |
| 69 | 71 | ||
| 70 | /* parse cmdline args */ | 72 | /* parse cmdline args */ |
| 71 | for (i = 1; i < argc; i++) { | 73 | for (i = 1; i < argc; i++) { |
| 72 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { | 74 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { |
| 73 | iphone_set_debug_mask(DBGMASK_ALL); | 75 | iphone_set_debug_mask(DBGMASK_ALL); |
| 74 | iphone_set_debug(1); | 76 | iphone_set_debug_level(1); |
| 75 | continue; | 77 | continue; |
| 76 | } | 78 | } |
| 77 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { | 79 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { |
| @@ -134,18 +136,41 @@ int main(int argc, char *argv[]) | |||
| 134 | } | 136 | } |
| 135 | } | 137 | } |
| 136 | 138 | ||
| 137 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 139 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { |
| 138 | iphone_free_device(phone); | 140 | iphone_device_free(phone); |
| 139 | return -1; | 141 | return -1; |
| 140 | } | 142 | } |
| 141 | 143 | ||
| 142 | /* run query and output information */ | 144 | /* run query and output information */ |
| 143 | print_lckd_request_result(client, domain, "GetValue", key, format); | 145 | if(lockdownd_get_value(client, domain, key, &node) == LOCKDOWN_E_SUCCESS) |
| 146 | { | ||
| 147 | if (plist_get_node_type(node) == PLIST_DICT) { | ||
| 148 | if (plist_get_first_child(node)) | ||
| 149 | { | ||
| 150 | switch (format) { | ||
| 151 | case FORMAT_XML: | ||
| 152 | plist_to_xml(node, &xml_doc, &xml_length); | ||
| 153 | printf(xml_doc); | ||
| 154 | free(xml_doc); | ||
| 155 | break; | ||
| 156 | case FORMAT_KEY_VALUE: | ||
| 157 | default: | ||
| 158 | plist_children_to_string(node); | ||
| 159 | break; | ||
| 160 | } | ||
| 161 | } | ||
| 162 | } | ||
| 163 | else if(node && (key != NULL)) | ||
| 164 | plist_node_to_string(node); | ||
| 165 | if (node) | ||
| 166 | plist_free(node); | ||
| 167 | node = NULL; | ||
| 168 | } | ||
| 144 | 169 | ||
| 145 | if (domain != NULL) | 170 | if (domain != NULL) |
| 146 | free(domain); | 171 | free(domain); |
| 147 | lockdownd_free_client(client); | 172 | lockdownd_client_free(client); |
| 148 | iphone_free_device(phone); | 173 | iphone_device_free(phone); |
| 149 | 174 | ||
| 150 | return 0; | 175 | return 0; |
| 151 | } | 176 | } |
| @@ -254,69 +279,3 @@ void plist_children_to_string(plist_t *node) | |||
| 254 | } | 279 | } |
| 255 | } | 280 | } |
| 256 | 281 | ||
| 257 | void print_lckd_request_result(lockdownd_client_t client, const char *domain, const char *request, const char *key, int format) { | ||
| 258 | char *xml_doc = NULL; | ||
| 259 | char *s = NULL; | ||
| 260 | uint32_t xml_length = 0; | ||
| 261 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; | ||
| 262 | |||
| 263 | plist_t node = plist_new_dict(); | ||
| 264 | if (domain) { | ||
| 265 | plist_add_sub_key_el(node, "Domain"); | ||
| 266 | plist_add_sub_string_el(node, domain); | ||
| 267 | } | ||
| 268 | if (key) { | ||
| 269 | plist_add_sub_key_el(node, "Key"); | ||
| 270 | plist_add_sub_string_el(node, key); | ||
| 271 | } | ||
| 272 | plist_add_sub_key_el(node, "Request"); | ||
| 273 | plist_add_sub_string_el(node, request); | ||
| 274 | |||
| 275 | ret = lockdownd_send(client, node); | ||
| 276 | if (ret == IPHONE_E_SUCCESS) { | ||
| 277 | plist_free(node); | ||
| 278 | node = NULL; | ||
| 279 | ret = lockdownd_recv(client, &node); | ||
| 280 | if (ret == IPHONE_E_SUCCESS) { | ||
| 281 | /* seek to value node */ | ||
| 282 | for ( | ||
| 283 | node = plist_get_first_child(node); | ||
| 284 | node != NULL; | ||
| 285 | node = plist_get_next_sibling(node) | ||
| 286 | ) { | ||
| 287 | if(plist_get_node_type(node) == PLIST_KEY) | ||
| 288 | { | ||
| 289 | plist_get_key_val(node, &s); | ||
| 290 | |||
| 291 | if (strcmp("Value", s)) | ||
| 292 | continue; | ||
| 293 | |||
| 294 | node = plist_get_next_sibling(node); | ||
| 295 | |||
| 296 | if (plist_get_node_type(node) == PLIST_DICT) { | ||
| 297 | if (plist_get_first_child(node)) | ||
| 298 | { | ||
| 299 | switch (format) { | ||
| 300 | case FORMAT_XML: | ||
| 301 | plist_to_xml(node, &xml_doc, &xml_length); | ||
| 302 | printf(xml_doc); | ||
| 303 | free(xml_doc); | ||
| 304 | break; | ||
| 305 | case FORMAT_KEY_VALUE: | ||
| 306 | default: | ||
| 307 | plist_children_to_string(node); | ||
| 308 | break; | ||
| 309 | } | ||
| 310 | } | ||
| 311 | } | ||
| 312 | else if(node && (key != NULL)) | ||
| 313 | plist_node_to_string(node); | ||
| 314 | } | ||
| 315 | } | ||
| 316 | } | ||
| 317 | } | ||
| 318 | if (node) | ||
| 319 | plist_free(node); | ||
| 320 | node = NULL; | ||
| 321 | } | ||
| 322 | |||
diff --git a/dev/lckdclient.c b/dev/lckdclient.c index e7ad962..b880253 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c | |||
| @@ -34,22 +34,23 @@ int main(int argc, char *argv[]) | |||
| 34 | lockdownd_client_t client = NULL; | 34 | lockdownd_client_t client = NULL; |
| 35 | iphone_device_t phone = NULL; | 35 | iphone_device_t phone = NULL; |
| 36 | 36 | ||
| 37 | iphone_set_debug(1); | 37 | iphone_set_debug_level(1); |
| 38 | 38 | ||
| 39 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { | 39 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { |
| 40 | printf("No iPhone found, is it plugged in?\n"); | 40 | printf("No iPhone found, is it plugged in?\n"); |
| 41 | return -1; | 41 | return -1; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 44 | char *uuid = NULL; |
| 45 | iphone_free_device(phone); | 45 | if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) { |
| 46 | return -1; | 46 | printf("DeviceUniqueID : %s\n", uuid); |
| 47 | } | 47 | } |
| 48 | if (uuid) | ||
| 49 | free(uuid); | ||
| 48 | 50 | ||
| 49 | char *uid = NULL; | 51 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { |
| 50 | if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { | 52 | iphone_device_free(phone); |
| 51 | printf("DeviceUniqueID : %s\n", uid); | 53 | return -1; |
| 52 | free(uid); | ||
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | using_history(); | 56 | using_history(); |
| @@ -75,7 +76,7 @@ int main(int argc, char *argv[]) | |||
| 75 | 76 | ||
| 76 | if (!strcmp(*args, "get") && len >= 2) { | 77 | if (!strcmp(*args, "get") && len >= 2) { |
| 77 | plist_t value = NULL; | 78 | plist_t value = NULL; |
| 78 | if (IPHONE_E_SUCCESS == lockdownd_get_value(client, len == 3 ? *(args + 1):NULL, len == 3 ? *(args + 2):*(args + 1), &value)) | 79 | if (LOCKDOWN_E_SUCCESS == lockdownd_get_value(client, len == 3 ? *(args + 1):NULL, len == 3 ? *(args + 2):*(args + 1), &value)) |
| 79 | { | 80 | { |
| 80 | char *xml = NULL; | 81 | char *xml = NULL; |
| 81 | uint32_t length; | 82 | uint32_t length; |
| @@ -92,8 +93,13 @@ int main(int argc, char *argv[]) | |||
| 92 | 93 | ||
| 93 | if (!strcmp(*args, "start") && len == 2) { | 94 | if (!strcmp(*args, "start") && len == 2) { |
| 94 | int port = 0; | 95 | int port = 0; |
| 95 | lockdownd_start_service(client, *(args + 1), &port); | 96 | if(LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, *(args + 1), &port)) { |
| 96 | printf("%i\n", port); | 97 | printf("started service %s on port %i\n", *(args + 1), port); |
| 98 | } | ||
| 99 | else | ||
| 100 | { | ||
| 101 | printf("failed to start service %s on device.\n", *(args + 1)); | ||
| 102 | } | ||
| 97 | } | 103 | } |
| 98 | } | 104 | } |
| 99 | g_strfreev(args); | 105 | g_strfreev(args); |
| @@ -102,8 +108,8 @@ int main(int argc, char *argv[]) | |||
| 102 | cmd = NULL; | 108 | cmd = NULL; |
| 103 | } | 109 | } |
| 104 | clear_history(); | 110 | clear_history(); |
| 105 | lockdownd_free_client(client); | 111 | lockdownd_client_free(client); |
| 106 | iphone_free_device(phone); | 112 | iphone_device_free(phone); |
| 107 | 113 | ||
| 108 | return 0; | 114 | return 0; |
| 109 | } | 115 | } |
| @@ -46,11 +46,11 @@ static void perform_notification(iphone_device_t phone, lockdownd_client_t clien | |||
| 46 | lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); | 46 | lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); |
| 47 | if (nport) { | 47 | if (nport) { |
| 48 | printf("::::::::::::::: np was started ::::::::::::\n"); | 48 | printf("::::::::::::::: np was started ::::::::::::\n"); |
| 49 | np_new_client(phone, nport, &np); | 49 | np_client_new(phone, nport, &np); |
| 50 | if (np) { | 50 | if (np) { |
| 51 | printf("::::::::: PostNotification %s\n", notification); | 51 | printf("::::::::: PostNotification %s\n", notification); |
| 52 | np_post_notification(np, notification); | 52 | np_post_notification(np, notification); |
| 53 | np_free_client(np); | 53 | np_client_free(np); |
| 54 | } | 54 | } |
| 55 | } else { | 55 | } else { |
| 56 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); | 56 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); |
| @@ -68,10 +68,10 @@ int main(int argc, char *argv[]) | |||
| 68 | np_client_t gnp = NULL; | 68 | np_client_t gnp = NULL; |
| 69 | 69 | ||
| 70 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | 70 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { |
| 71 | iphone_set_debug(1); | 71 | iphone_set_debug_level(1); |
| 72 | iphone_set_debug_mask(DBGMASK_ALL); | 72 | iphone_set_debug_mask(DBGMASK_ALL); |
| 73 | } else { | 73 | } else { |
| 74 | iphone_set_debug(0); | 74 | iphone_set_debug_level(0); |
| 75 | iphone_set_debug_mask(DBGMASK_NONE); | 75 | iphone_set_debug_mask(DBGMASK_NONE); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| @@ -80,21 +80,21 @@ int main(int argc, char *argv[]) | |||
| 80 | return -1; | 80 | return -1; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 83 | char *uuid = NULL; |
| 84 | iphone_free_device(phone); | 84 | if (IPHONE_E_SUCCESS == iphone_device_get_uuid(phone, &uuid)) { |
| 85 | printf("Exiting.\n"); | 85 | printf("DeviceUniqueID : %s\n", uuid); |
| 86 | return -1; | ||
| 87 | } | 86 | } |
| 87 | if (uuid) | ||
| 88 | free(uuid); | ||
| 88 | 89 | ||
| 89 | char *uid = NULL; | 90 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { |
| 90 | if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(client, &uid)) { | 91 | iphone_device_free(phone); |
| 91 | printf("DeviceUniqueID : %s\n", uid); | 92 | printf("Exiting.\n"); |
| 92 | free(uid); | 93 | return -1; |
| 93 | } | 94 | } |
| 94 | 95 | ||
| 95 | |||
| 96 | char *nnn = NULL; | 96 | char *nnn = NULL; |
| 97 | if (IPHONE_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { | 97 | if (LOCKDOWN_E_SUCCESS == lockdownd_get_device_name(client, &nnn)) { |
| 98 | printf("DeviceName : %s\n", nnn); | 98 | printf("DeviceName : %s\n", nnn); |
| 99 | free(nnn); | 99 | free(nnn); |
| 100 | } | 100 | } |
| @@ -103,20 +103,21 @@ int main(int argc, char *argv[]) | |||
| 103 | 103 | ||
| 104 | if (port) { | 104 | if (port) { |
| 105 | afc_client_t afc = NULL; | 105 | afc_client_t afc = NULL; |
| 106 | afc_new_client(phone, port, &afc); | 106 | afc_client_new(phone, port, &afc); |
| 107 | if (afc) { | 107 | if (afc) { |
| 108 | lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); | 108 | lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); |
| 109 | if (npp) { | 109 | if (npp) { |
| 110 | printf("Notification Proxy started.\n"); | 110 | printf("Notification Proxy started.\n"); |
| 111 | np_new_client(phone, npp, &gnp); | 111 | np_client_new(phone, npp, &gnp); |
| 112 | } else { | 112 | } else { |
| 113 | printf("ERROR: Notification proxy could not be started.\n"); | 113 | printf("ERROR: Notification proxy could not be started.\n"); |
| 114 | } | 114 | } |
| 115 | if (gnp) { | 115 | if (gnp) { |
| 116 | const char *nspec[4] = { | 116 | const char *nspec[5] = { |
| 117 | NP_SYNC_CANCEL_REQUEST, | 117 | NP_SYNC_CANCEL_REQUEST, |
| 118 | NP_SYNC_SUSPEND_REQUEST, | 118 | NP_SYNC_SUSPEND_REQUEST, |
| 119 | NP_SYNC_RESUME_REQUEST, | 119 | NP_SYNC_RESUME_REQUEST, |
| 120 | NP_ITDBPREP_DID_END, | ||
| 120 | NULL | 121 | NULL |
| 121 | }; | 122 | }; |
| 122 | np_observe_notifications(gnp, nspec); | 123 | np_observe_notifications(gnp, nspec); |
| @@ -125,18 +126,18 @@ int main(int argc, char *argv[]) | |||
| 125 | 126 | ||
| 126 | perform_notification(phone, client, NP_SYNC_WILL_START); | 127 | perform_notification(phone, client, NP_SYNC_WILL_START); |
| 127 | 128 | ||
| 128 | afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); | 129 | afc_file_open(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile); |
| 129 | if (lockfile) { | 130 | if (lockfile) { |
| 130 | printf("locking file\n"); | 131 | printf("locking file\n"); |
| 131 | afc_lock_file(afc, lockfile, 2 | 4); | 132 | afc_file_lock(afc, lockfile, AFC_LOCK_EX); |
| 132 | 133 | ||
| 133 | perform_notification(phone, client, NP_SYNC_DID_START); | 134 | perform_notification(phone, client, NP_SYNC_DID_START); |
| 134 | } | 135 | } |
| 135 | 136 | ||
| 136 | char **dirs = NULL; | 137 | char **dirs = NULL; |
| 137 | afc_get_dir_list(afc, "/eafaedf", &dirs); | 138 | afc_read_directory(afc, "/eafaedf", &dirs); |
| 138 | if (!dirs) | 139 | if (!dirs) |
| 139 | afc_get_dir_list(afc, "/", &dirs); | 140 | afc_read_directory(afc, "/", &dirs); |
| 140 | printf("Directory time.\n"); | 141 | printf("Directory time.\n"); |
| 141 | for (i = 0; dirs[i]; i++) { | 142 | for (i = 0; dirs[i]; i++) { |
| 142 | printf("/%s\n", dirs[i]); | 143 | printf("/%s\n", dirs[i]); |
| @@ -145,7 +146,7 @@ int main(int argc, char *argv[]) | |||
| 145 | g_strfreev(dirs); | 146 | g_strfreev(dirs); |
| 146 | 147 | ||
| 147 | dirs = NULL; | 148 | dirs = NULL; |
| 148 | afc_get_devinfo(afc, &dirs); | 149 | afc_get_device_info(afc, &dirs); |
| 149 | if (dirs) { | 150 | if (dirs) { |
| 150 | for (i = 0; dirs[i]; i += 2) { | 151 | for (i = 0; dirs[i]; i += 2) { |
| 151 | printf("%s: %s\n", dirs[i], dirs[i + 1]); | 152 | printf("%s: %s\n", dirs[i], dirs[i + 1]); |
| @@ -156,7 +157,7 @@ int main(int argc, char *argv[]) | |||
| 156 | uint64_t my_file = 0; | 157 | uint64_t my_file = 0; |
| 157 | char **info = NULL; | 158 | char **info = NULL; |
| 158 | uint64_t fsize = 0; | 159 | uint64_t fsize = 0; |
| 159 | if (IPHONE_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) { | 160 | if (AFC_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) { |
| 160 | for (i = 0; info[i]; i += 2) { | 161 | for (i = 0; info[i]; i += 2) { |
| 161 | printf("%s: %s\n", info[i], info[i+1]); | 162 | printf("%s: %s\n", info[i], info[i+1]); |
| 162 | if (!strcmp(info[i], "st_size")) { | 163 | if (!strcmp(info[i], "st_size")) { |
| @@ -165,88 +166,90 @@ int main(int argc, char *argv[]) | |||
| 165 | } | 166 | } |
| 166 | } | 167 | } |
| 167 | 168 | ||
| 168 | if (IPHONE_E_SUCCESS == | 169 | if (AFC_E_SUCCESS == |
| 169 | afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { | 170 | afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { |
| 170 | printf("A file size: %llu\n", (long long)fsize); | 171 | printf("A file size: %llu\n", (long long)fsize); |
| 171 | char *file_data = (char *) malloc(sizeof(char) * fsize); | 172 | char *file_data = (char *) malloc(sizeof(char) * fsize); |
| 172 | afc_read_file(afc, my_file, file_data, fsize, &bytes); | 173 | afc_file_read(afc, my_file, file_data, fsize, &bytes); |
| 173 | if (bytes > 0) { | 174 | if (bytes > 0) { |
| 174 | printf("The file's data:\n"); | 175 | printf("The file's data:\n"); |
| 175 | fwrite(file_data, 1, bytes, stdout); | 176 | fwrite(file_data, 1, bytes, stdout); |
| 176 | } | 177 | } |
| 177 | printf("\nClosing my file.\n"); | 178 | printf("\nClosing my file.\n"); |
| 178 | afc_close_file(afc, my_file); | 179 | afc_file_close(afc, my_file); |
| 179 | free(file_data); | 180 | free(file_data); |
| 180 | } else | 181 | } else |
| 181 | printf("couldn't open a file\n"); | 182 | printf("couldn't open a file\n"); |
| 182 | 183 | ||
| 183 | afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); | 184 | afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file); |
| 184 | if (my_file) { | 185 | if (my_file) { |
| 185 | char *outdatafile = strdup("this is a bitchin text file\n"); | 186 | char *outdatafile = strdup("this is a bitchin text file\n"); |
| 186 | afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); | 187 | afc_file_write(afc, my_file, outdatafile, strlen(outdatafile), &bytes); |
| 187 | free(outdatafile); | 188 | free(outdatafile); |
| 188 | if (bytes > 0) | 189 | if (bytes > 0) |
| 189 | printf("Wrote a surprise. ;)\n"); | 190 | printf("Wrote a surprise. ;)\n"); |
| 190 | else | 191 | else |
| 191 | printf("I wanted to write a surprise, but... :(\n"); | 192 | printf("I wanted to write a surprise, but... :(\n"); |
| 192 | afc_close_file(afc, my_file); | 193 | afc_file_close(afc, my_file); |
| 193 | } | 194 | } |
| 194 | printf("Deleting a file...\n"); | 195 | printf("Deleting a file...\n"); |
| 195 | bytes = afc_delete_file(afc, "/delme"); | 196 | bytes = afc_remove_path(afc, "/delme"); |
| 196 | if (bytes) | 197 | if (bytes) |
| 197 | printf("Success.\n"); | 198 | printf("Success.\n"); |
| 198 | else | 199 | else |
| 199 | printf("Failure. (expected unless you have a /delme file on your phone)\n"); | 200 | printf("Failure. (expected unless you have a /delme file on your phone)\n"); |
| 200 | 201 | ||
| 201 | printf("Renaming a file...\n"); | 202 | printf("Renaming a file...\n"); |
| 202 | bytes = afc_rename_file(afc, "/renme", "/renme2"); | 203 | bytes = afc_rename_path(afc, "/renme", "/renme2"); |
| 203 | if (bytes > 0) | 204 | if (bytes > 0) |
| 204 | printf("Success.\n"); | 205 | printf("Success.\n"); |
| 205 | else | 206 | else |
| 206 | printf("Failure. (expected unless you have a /renme file on your phone)\n"); | 207 | printf("Failure. (expected unless you have a /renme file on your phone)\n"); |
| 207 | 208 | ||
| 208 | printf("Seek & read\n"); | 209 | printf("Seek & read\n"); |
| 209 | afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); | 210 | afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); |
| 210 | if (IPHONE_E_SUCCESS != afc_seek_file(afc, my_file, 5, SEEK_CUR)) | 211 | if (AFC_E_SUCCESS != afc_file_seek(afc, my_file, 5, SEEK_CUR)) |
| 211 | printf("WARN: SEEK DID NOT WORK\n"); | 212 | printf("WARN: SEEK DID NOT WORK\n"); |
| 212 | char *threeletterword = (char *) malloc(sizeof(char) * 5); | 213 | char *threeletterword = (char *) malloc(sizeof(char) * 5); |
| 213 | afc_read_file(afc, my_file, threeletterword, 3, &bytes); | 214 | afc_file_read(afc, my_file, threeletterword, 3, &bytes); |
| 214 | threeletterword[3] = '\0'; | 215 | threeletterword[3] = '\0'; |
| 215 | if (bytes > 0) | 216 | if (bytes > 0) |
| 216 | printf("Result: %s\n", threeletterword); | 217 | printf("Result: %s\n", threeletterword); |
| 217 | else | 218 | else |
| 218 | printf("Couldn't read!\n"); | 219 | printf("Couldn't read!\n"); |
| 219 | free(threeletterword); | 220 | free(threeletterword); |
| 220 | afc_close_file(afc, my_file); | 221 | afc_file_close(afc, my_file); |
| 221 | } | 222 | } |
| 222 | 223 | ||
| 223 | if (gnp && lockfile) { | 224 | if (gnp && lockfile) { |
| 224 | printf("XXX sleeping\n"); | 225 | printf("XXX sleeping\n"); |
| 225 | sleep(5); | 226 | sleep(5); |
| 226 | 227 | ||
| 227 | //perform_notification(phone, control, NP_SYNC_DID_FINISH); | ||
| 228 | |||
| 229 | printf("XXX unlocking file\n"); | 228 | printf("XXX unlocking file\n"); |
| 230 | afc_lock_file(afc, lockfile, 8 | 4); | 229 | afc_file_lock(afc, lockfile, AFC_LOCK_UN); |
| 231 | 230 | ||
| 232 | printf("XXX closing file\n"); | 231 | printf("XXX closing file\n"); |
| 233 | afc_close_file(afc, lockfile); | 232 | afc_file_close(afc, lockfile); |
| 233 | |||
| 234 | printf("XXX sleeping\n"); | ||
| 235 | sleep(5); | ||
| 236 | //perform_notification(phone, client, NP_SYNC_DID_FINISH); | ||
| 234 | } | 237 | } |
| 235 | 238 | ||
| 236 | if (gnp) { | 239 | if (gnp) { |
| 237 | np_free_client(gnp); | 240 | np_client_free(gnp); |
| 238 | gnp = NULL; | 241 | gnp = NULL; |
| 239 | } | 242 | } |
| 240 | 243 | ||
| 241 | afc_free_client(afc); | 244 | afc_client_free(afc); |
| 242 | } else { | 245 | } else { |
| 243 | printf("Start service failure.\n"); | 246 | printf("Start service failure.\n"); |
| 244 | } | 247 | } |
| 245 | 248 | ||
| 246 | printf("All done.\n"); | 249 | printf("All done.\n"); |
| 247 | 250 | ||
| 248 | lockdownd_free_client(client); | 251 | lockdownd_client_free(client); |
| 249 | iphone_free_device(phone); | 252 | iphone_device_free(phone); |
| 250 | 253 | ||
| 251 | return 0; | 254 | return 0; |
| 252 | } | 255 | } |
diff --git a/dev/msyncclient.c b/dev/msyncclient.c index 5eb105d..5fffe7a 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c | |||
| @@ -28,12 +28,12 @@ | |||
| 28 | #include <libiphone/lockdown.h> | 28 | #include <libiphone/lockdown.h> |
| 29 | #include <libiphone/mobilesync.h> | 29 | #include <libiphone/mobilesync.h> |
| 30 | 30 | ||
| 31 | static iphone_error_t mobilesync_get_all_contacts(mobilesync_client_t client) | 31 | static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client) |
| 32 | { | 32 | { |
| 33 | if (!client) | 33 | if (!client) |
| 34 | return IPHONE_E_INVALID_ARG; | 34 | return MOBILESYNC_E_INVALID_ARG; |
| 35 | 35 | ||
| 36 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; | 36 | mobilesync_error_t ret = MOBILESYNC_E_UNKNOWN_ERROR; |
| 37 | plist_t array = NULL; | 37 | plist_t array = NULL; |
| 38 | 38 | ||
| 39 | array = plist_new_array(); | 39 | array = plist_new_array(); |
| @@ -124,7 +124,6 @@ static iphone_error_t mobilesync_get_all_contacts(mobilesync_client_t client) | |||
| 124 | plist_free(array); | 124 | plist_free(array); |
| 125 | array = NULL; | 125 | array = NULL; |
| 126 | 126 | ||
| 127 | |||
| 128 | return ret; | 127 | return ret; |
| 129 | } | 128 | } |
| 130 | 129 | ||
| @@ -137,14 +136,13 @@ int main(int argc, char *argv[]) | |||
| 137 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) | 136 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) |
| 138 | iphone_set_debug_mask(DBGMASK_MOBILESYNC); | 137 | iphone_set_debug_mask(DBGMASK_MOBILESYNC); |
| 139 | 138 | ||
| 140 | |||
| 141 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { | 139 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { |
| 142 | printf("No iPhone found, is it plugged in?\n"); | 140 | printf("No iPhone found, is it plugged in?\n"); |
| 143 | return -1; | 141 | return -1; |
| 144 | } | 142 | } |
| 145 | 143 | ||
| 146 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 144 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { |
| 147 | iphone_free_device(phone); | 145 | iphone_device_free(phone); |
| 148 | return -1; | 146 | return -1; |
| 149 | } | 147 | } |
| 150 | 148 | ||
| @@ -152,10 +150,10 @@ int main(int argc, char *argv[]) | |||
| 152 | 150 | ||
| 153 | if (port) { | 151 | if (port) { |
| 154 | mobilesync_client_t msync = NULL; | 152 | mobilesync_client_t msync = NULL; |
| 155 | mobilesync_new_client(phone, port, &msync); | 153 | mobilesync_client_new(phone, port, &msync); |
| 156 | if (msync) { | 154 | if (msync) { |
| 157 | mobilesync_get_all_contacts(msync); | 155 | mobilesync_get_all_contacts(msync); |
| 158 | mobilesync_free_client(msync); | 156 | mobilesync_client_free(msync); |
| 159 | } | 157 | } |
| 160 | } else { | 158 | } else { |
| 161 | printf("Start service failure.\n"); | 159 | printf("Start service failure.\n"); |
| @@ -163,8 +161,8 @@ int main(int argc, char *argv[]) | |||
| 163 | 161 | ||
| 164 | printf("All done.\n"); | 162 | printf("All done.\n"); |
| 165 | 163 | ||
| 166 | lockdownd_free_client(client); | 164 | lockdownd_client_free(client); |
| 167 | iphone_free_device(phone); | 165 | iphone_device_free(phone); |
| 168 | 166 | ||
| 169 | return 0; | 167 | return 0; |
| 170 | } | 168 | } |
diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index a93e85b..a096101 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c | |||
| @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) | |||
| 52 | char uuid[41]; | 52 | char uuid[41]; |
| 53 | int port = 0; | 53 | int port = 0; |
| 54 | uuid[0] = 0; | 54 | uuid[0] = 0; |
| 55 | uint32_t handle = 0; | ||
| 55 | 56 | ||
| 56 | signal(SIGINT, clean_exit); | 57 | signal(SIGINT, clean_exit); |
| 57 | signal(SIGQUIT, clean_exit); | 58 | signal(SIGQUIT, clean_exit); |
| @@ -62,7 +63,7 @@ int main(int argc, char *argv[]) | |||
| 62 | for (i = 1; i < argc; i++) { | 63 | for (i = 1; i < argc; i++) { |
| 63 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { | 64 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { |
| 64 | iphone_set_debug_mask(DBGMASK_ALL); | 65 | iphone_set_debug_mask(DBGMASK_ALL); |
| 65 | iphone_set_debug(1); | 66 | iphone_set_debug_level(1); |
| 66 | continue; | 67 | continue; |
| 67 | } | 68 | } |
| 68 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { | 69 | else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { |
| @@ -100,19 +101,19 @@ int main(int argc, char *argv[]) | |||
| 100 | } | 101 | } |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | if (IPHONE_E_SUCCESS != lockdownd_new_client(phone, &client)) { | 104 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { |
| 104 | iphone_free_device(phone); | 105 | iphone_device_free(phone); |
| 105 | return -1; | 106 | return -1; |
| 106 | } | 107 | } |
| 107 | 108 | ||
| 108 | /* start syslog_relay service and retrieve port */ | 109 | /* start syslog_relay service and retrieve port */ |
| 109 | ret = lockdownd_start_service(client, "com.apple.syslog_relay", &port); | 110 | ret = lockdownd_start_service(client, "com.apple.syslog_relay", &port); |
| 110 | if ((ret == IPHONE_E_SUCCESS) && port) { | 111 | if ((ret == LOCKDOWN_E_SUCCESS) && port) { |
| 111 | lockdownd_free_client(client); | 112 | lockdownd_client_free(client); |
| 112 | 113 | ||
| 113 | /* connect to socket relay messages */ | 114 | /* connect to socket relay messages */ |
| 114 | 115 | iphone_device_get_handle(phone, &handle); | |
| 115 | int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port); | 116 | int sfd = usbmuxd_connect(handle, port); |
| 116 | if (sfd < 0) { | 117 | if (sfd < 0) { |
| 117 | printf("ERROR: Could not open usbmux connection.\n"); | 118 | printf("ERROR: Could not open usbmux connection.\n"); |
| 118 | } else { | 119 | } else { |
| @@ -148,7 +149,7 @@ int main(int argc, char *argv[]) | |||
| 148 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); | 149 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); |
| 149 | } | 150 | } |
| 150 | 151 | ||
| 151 | iphone_free_device(phone); | 152 | iphone_device_free(phone); |
| 152 | 153 | ||
| 153 | return 0; | 154 | return 0; |
| 154 | } | 155 | } |
