diff options
| author | 2009-07-06 19:38:00 +0200 | |
|---|---|---|
| committer | 2009-07-18 10:39:41 -0700 | |
| commit | 4105af17e9f2df5405afa6a74a02a304ed6bacff (patch) | |
| tree | daf79b623def5a66810466842197f3bc696c8c28 | |
| parent | 6de08b1e12946b85a595f82c1c04391d70d8b828 (diff) | |
| download | libimobiledevice-4105af17e9f2df5405afa6a74a02a304ed6bacff.tar.gz libimobiledevice-4105af17e9f2df5405afa6a74a02a304ed6bacff.tar.bz2 | |
API cleanup for AFC
| -rw-r--r-- | dev/afccheck.c | 21 | ||||
| -rw-r--r-- | dev/main.c | 47 | ||||
| -rw-r--r-- | include/Makefile.am | 2 | ||||
| -rw-r--r-- | include/libiphone/afc.h | 54 | ||||
| -rw-r--r-- | include/libiphone/libiphone.h | 40 | ||||
| -rw-r--r-- | src/AFC.c | 57 | ||||
| -rw-r--r-- | src/AFC.h | 5 |
7 files changed, 121 insertions, 105 deletions
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 @@ | |||
| 25 | #include <glib.h> | 25 | #include <glib.h> |
| 26 | 26 | ||
| 27 | #include <libiphone/libiphone.h> | 27 | #include <libiphone/libiphone.h> |
| 28 | #include <libiphone/afc.h> | ||
| 28 | 29 | ||
| 29 | #define BUFFER_SIZE 20000 | 30 | #define BUFFER_SIZE 20000 |
| 30 | #define NB_THREADS 10 | 31 | #define NB_THREADS 10 |
| 31 | 32 | ||
| 32 | 33 | ||
| 33 | typedef struct { | 34 | typedef struct { |
| 34 | iphone_afc_client_t afc; | 35 | afc_client_t afc; |
| 35 | int id; | 36 | int id; |
| 36 | } param; | 37 | } param; |
| 37 | 38 | ||
| @@ -53,18 +54,18 @@ void check_afc(gpointer data) | |||
| 53 | uint64_t file = 0; | 54 | uint64_t file = 0; |
| 54 | char path[50]; | 55 | char path[50]; |
| 55 | sprintf(path, "/Buf%i", ((param *) data)->id); | 56 | sprintf(path, "/Buf%i", ((param *) data)->id); |
| 56 | iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); | 57 | afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); |
| 57 | iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); | 58 | afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); |
| 58 | iphone_afc_close_file(((param *) data)->afc, file); | 59 | afc_close_file(((param *) data)->afc, file); |
| 59 | file = 0; | 60 | file = 0; |
| 60 | if (bytes != buffersize) | 61 | if (bytes != buffersize) |
| 61 | printf("Write operation failed\n"); | 62 | printf("Write operation failed\n"); |
| 62 | 63 | ||
| 63 | //now read it | 64 | //now read it |
| 64 | bytes = 0; | 65 | bytes = 0; |
| 65 | iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); | 66 | afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file); |
| 66 | iphone_afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); | 67 | afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes); |
| 67 | iphone_afc_close_file(((param *) data)->afc, file); | 68 | afc_close_file(((param *) data)->afc, file); |
| 68 | if (bytes != buffersize) | 69 | if (bytes != buffersize) |
| 69 | printf("Read operation failed\n"); | 70 | printf("Read operation failed\n"); |
| 70 | 71 | ||
| @@ -77,7 +78,7 @@ void check_afc(gpointer data) | |||
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | //cleanup | 80 | //cleanup |
| 80 | iphone_afc_delete_file(((param *) data)->afc, path); | 81 | afc_delete_file(((param *) data)->afc, path); |
| 81 | g_thread_exit(0); | 82 | g_thread_exit(0); |
| 82 | } | 83 | } |
| 83 | 84 | ||
| @@ -87,7 +88,7 @@ int main(int argc, char *argv[]) | |||
| 87 | iphone_device_t phone = NULL; | 88 | iphone_device_t phone = NULL; |
| 88 | GError *err; | 89 | GError *err; |
| 89 | int port = 0; | 90 | int port = 0; |
| 90 | iphone_afc_client_t afc = NULL; | 91 | afc_client_t afc = NULL; |
| 91 | 92 | ||
| 92 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { | 93 | if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) { |
| 93 | printf("No iPhone found, is it plugged in?\n"); | 94 | printf("No iPhone found, is it plugged in?\n"); |
| @@ -106,7 +107,7 @@ int main(int argc, char *argv[]) | |||
| 106 | return 1; | 107 | return 1; |
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | iphone_afc_new_client(phone, port, &afc); | 110 | afc_new_client(phone, port, &afc); |
| 110 | 111 | ||
| 111 | //makes sure thread environment is available | 112 | //makes sure thread environment is available |
| 112 | if (!g_thread_supported()) | 113 | if (!g_thread_supported()) |
| @@ -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 | ||
| 30 | void notifier(const char *notification) | 31 | void 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 | } |
diff --git a/include/Makefile.am b/include/Makefile.am index a5f8766..4c17261 100644 --- a/include/Makefile.am +++ b/include/Makefile.am | |||
| @@ -1 +1 @@ | |||
| nobase_include_HEADERS = libiphone/libiphone.h | nobase_include_HEADERS = libiphone/libiphone.h libiphone/afc.h | ||
diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h new file mode 100644 index 0000000..2a0bbad --- /dev/null +++ b/include/libiphone/afc.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | #ifndef AFC_H | ||
| 2 | #define AFC_H | ||
| 3 | |||
| 4 | #ifdef __cplusplus | ||
| 5 | extern "C" { | ||
| 6 | #endif | ||
| 7 | |||
| 8 | #include <libiphone/libiphone.h> | ||
| 9 | |||
| 10 | typedef enum { | ||
| 11 | AFC_FOPEN_RDONLY = 0x00000001, // r O_RDONLY | ||
| 12 | AFC_FOPEN_RW = 0x00000002, // r+ O_RDWR | O_CREAT | ||
| 13 | AFC_FOPEN_WRONLY = 0x00000003, // w O_WRONLY | O_CREAT | O_TRUNC | ||
| 14 | AFC_FOPEN_WR = 0x00000004, // w+ O_RDWR | O_CREAT | O_TRUNC | ||
| 15 | AFC_FOPEN_APPEND = 0x00000005, // a O_WRONLY | O_APPEND | O_CREAT | ||
| 16 | AFC_FOPEN_RDAPPEND = 0x00000006 // a+ O_RDWR | O_APPEND | O_CREAT | ||
| 17 | } afc_file_mode_t; | ||
| 18 | |||
| 19 | typedef enum { | ||
| 20 | AFC_HARDLINK = 1, | ||
| 21 | AFC_SYMLINK = 2 | ||
| 22 | } afc_link_type_t; | ||
| 23 | |||
| 24 | struct afc_client_int; | ||
| 25 | typedef struct afc_client_int *afc_client_t; | ||
| 26 | |||
| 27 | //afc related functions | ||
| 28 | iphone_error_t afc_new_client ( iphone_device_t device, int dst_port, afc_client_t *client ); | ||
| 29 | iphone_error_t afc_free_client ( afc_client_t client ); | ||
| 30 | int afc_get_afcerror ( afc_client_t client ); | ||
| 31 | int afc_get_errno ( afc_client_t client ); | ||
| 32 | |||
| 33 | iphone_error_t afc_get_devinfo ( afc_client_t client, char ***infos ); | ||
| 34 | iphone_error_t afc_get_dir_list ( afc_client_t client, const char *dir, char ***list); | ||
| 35 | |||
| 36 | iphone_error_t afc_get_file_info ( afc_client_t client, const char *filename, char ***infolist ); | ||
| 37 | iphone_error_t afc_open_file ( afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle ); | ||
| 38 | iphone_error_t afc_close_file ( afc_client_t client, uint64_t handle); | ||
| 39 | iphone_error_t afc_lock_file ( afc_client_t client, uint64_t handle, int operation); | ||
| 40 | iphone_error_t afc_read_file ( afc_client_t client, uint64_t handle, char *data, int length, uint32_t *bytes); | ||
| 41 | iphone_error_t afc_write_file ( afc_client_t client, uint64_t handle, const char *data, int length, uint32_t *bytes); | ||
| 42 | iphone_error_t afc_seek_file ( afc_client_t client, uint64_t handle, int64_t offset, int whence); | ||
| 43 | iphone_error_t afc_truncate_file ( afc_client_t client, uint64_t handle, uint64_t newsize); | ||
| 44 | iphone_error_t afc_delete_file ( afc_client_t client, const char *path); | ||
| 45 | iphone_error_t afc_rename_file ( afc_client_t client, const char *from, const char *to); | ||
| 46 | iphone_error_t afc_mkdir ( afc_client_t client, const char *dir); | ||
| 47 | iphone_error_t afc_truncate ( afc_client_t client, const char *path, off_t newsize); | ||
| 48 | iphone_error_t afc_make_link ( afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); | ||
| 49 | |||
| 50 | #ifdef __cplusplus | ||
| 51 | } | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #endif | ||
diff --git a/include/libiphone/libiphone.h b/include/libiphone/libiphone.h index 463efa7..3f5d86c 100644 --- a/include/libiphone/libiphone.h +++ b/include/libiphone/libiphone.h | |||
| @@ -54,29 +54,12 @@ extern "C" { | |||
| 54 | 54 | ||
| 55 | typedef int16_t iphone_error_t; | 55 | typedef int16_t iphone_error_t; |
| 56 | 56 | ||
| 57 | typedef enum { | ||
| 58 | AFC_FOPEN_RDONLY = 0x00000001, // r O_RDONLY | ||
| 59 | AFC_FOPEN_RW = 0x00000002, // r+ O_RDWR | O_CREAT | ||
| 60 | AFC_FOPEN_WRONLY = 0x00000003, // w O_WRONLY | O_CREAT | O_TRUNC | ||
| 61 | AFC_FOPEN_WR = 0x00000004, // w+ O_RDWR | O_CREAT | O_TRUNC | ||
| 62 | AFC_FOPEN_APPEND = 0x00000005, // a O_WRONLY | O_APPEND | O_CREAT | ||
| 63 | AFC_FOPEN_RDAPPEND = 0x00000006 // a+ O_RDWR | O_APPEND | O_CREAT | ||
| 64 | } iphone_afc_file_mode_t; | ||
| 65 | |||
| 66 | typedef enum { | ||
| 67 | IPHONE_AFC_HARDLINK = 1, | ||
| 68 | IPHONE_AFC_SYMLINK = 2 | ||
| 69 | } iphone_afc_link_type_t; | ||
| 70 | |||
| 71 | struct iphone_device_int; | 57 | struct iphone_device_int; |
| 72 | typedef struct iphone_device_int *iphone_device_t; | 58 | typedef struct iphone_device_int *iphone_device_t; |
| 73 | 59 | ||
| 74 | struct iphone_lckd_client_int; | 60 | struct iphone_lckd_client_int; |
| 75 | typedef struct iphone_lckd_client_int *iphone_lckd_client_t; | 61 | typedef struct iphone_lckd_client_int *iphone_lckd_client_t; |
| 76 | 62 | ||
| 77 | struct iphone_afc_client_int; | ||
| 78 | typedef struct iphone_afc_client_int *iphone_afc_client_t; | ||
| 79 | |||
| 80 | struct iphone_msync_client_int; | 63 | struct iphone_msync_client_int; |
| 81 | typedef struct iphone_msync_client_int *iphone_msync_client_t; | 64 | typedef struct iphone_msync_client_int *iphone_msync_client_t; |
| 82 | 65 | ||
| @@ -111,29 +94,6 @@ iphone_error_t iphone_lckd_recv ( iphone_lckd_client_t client, plist_t* plist); | |||
| 111 | iphone_error_t iphone_lckd_send ( iphone_lckd_client_t client, plist_t plist); | 94 | iphone_error_t iphone_lckd_send ( iphone_lckd_client_t client, plist_t plist); |
| 112 | 95 | ||
| 113 | 96 | ||
| 114 | //afc related functions | ||
| 115 | iphone_error_t iphone_afc_new_client ( iphone_device_t device, int dst_port, iphone_afc_client_t *client ); | ||
| 116 | iphone_error_t iphone_afc_free_client ( iphone_afc_client_t client ); | ||
| 117 | int iphone_afc_get_afcerror ( iphone_afc_client_t client ); | ||
| 118 | int iphone_afc_get_errno ( iphone_afc_client_t client ); | ||
| 119 | |||
| 120 | iphone_error_t iphone_afc_get_devinfo ( iphone_afc_client_t client, char ***infos ); | ||
| 121 | iphone_error_t iphone_afc_get_dir_list ( iphone_afc_client_t client, const char *dir, char ***list); | ||
| 122 | |||
| 123 | iphone_error_t iphone_afc_get_file_info ( iphone_afc_client_t client, const char *filename, char ***infolist ); | ||
| 124 | iphone_error_t iphone_afc_open_file ( iphone_afc_client_t client, const char *filename, iphone_afc_file_mode_t file_mode, uint64_t *handle ); | ||
| 125 | iphone_error_t iphone_afc_close_file ( iphone_afc_client_t client, uint64_t handle); | ||
| 126 | iphone_error_t iphone_afc_lock_file ( iphone_afc_client_t client, uint64_t handle, int operation); | ||
| 127 | iphone_error_t iphone_afc_read_file ( iphone_afc_client_t client, uint64_t handle, char *data, int length, uint32_t *bytes); | ||
| 128 | iphone_error_t iphone_afc_write_file ( iphone_afc_client_t client, uint64_t handle, const char *data, int length, uint32_t *bytes); | ||
| 129 | iphone_error_t iphone_afc_seek_file ( iphone_afc_client_t client, uint64_t handle, int64_t offset, int whence); | ||
| 130 | iphone_error_t iphone_afc_truncate_file ( iphone_afc_client_t client, uint64_t handle, uint64_t newsize); | ||
| 131 | iphone_error_t iphone_afc_delete_file ( iphone_afc_client_t client, const char *path); | ||
| 132 | iphone_error_t iphone_afc_rename_file ( iphone_afc_client_t client, const char *from, const char *to); | ||
| 133 | iphone_error_t iphone_afc_mkdir ( iphone_afc_client_t client, const char *dir); | ||
| 134 | iphone_error_t iphone_afc_truncate(iphone_afc_client_t client, const char *path, off_t newsize); | ||
| 135 | iphone_error_t iphone_afc_make_link ( iphone_afc_client_t client, iphone_afc_link_type_t linktype, const char *target, const char *linkname); | ||
| 136 | |||
| 137 | 97 | ||
| 138 | iphone_error_t iphone_msync_new_client(iphone_device_t device, int dst_port, | 98 | iphone_error_t iphone_msync_new_client(iphone_device_t device, int dst_port, |
| 139 | iphone_msync_client_t * client); | 99 | iphone_msync_client_t * client); |
| @@ -24,8 +24,11 @@ | |||
| 24 | #include <errno.h> | 24 | #include <errno.h> |
| 25 | #include <unistd.h> | 25 | #include <unistd.h> |
| 26 | #include "AFC.h" | 26 | #include "AFC.h" |
| 27 | #include "iphone.h" | ||
| 27 | #include "utils.h" | 28 | #include "utils.h" |
| 28 | 29 | ||
| 30 | #include <libiphone/afc.h> | ||
| 31 | |||
| 29 | 32 | ||
| 30 | // This is the maximum size an AFC data packet can be | 33 | // This is the maximum size an AFC data packet can be |
| 31 | const int MAXIMUM_PACKET_SIZE = (2 << 15); | 34 | const int MAXIMUM_PACKET_SIZE = (2 << 15); |
| @@ -34,7 +37,7 @@ const int MAXIMUM_PACKET_SIZE = (2 << 15); | |||
| 34 | * | 37 | * |
| 35 | * @param client The AFC client connection to lock | 38 | * @param client The AFC client connection to lock |
| 36 | */ | 39 | */ |
| 37 | static void afc_lock(iphone_afc_client_t client) | 40 | static void afc_lock(afc_client_t client) |
| 38 | { | 41 | { |
| 39 | log_debug_msg("Locked\n"); | 42 | log_debug_msg("Locked\n"); |
| 40 | /*while (client->lock) { | 43 | /*while (client->lock) { |
| @@ -48,7 +51,7 @@ static void afc_lock(iphone_afc_client_t client) | |||
| 48 | * | 51 | * |
| 49 | * @param client The AFC | 52 | * @param client The AFC |
| 50 | */ | 53 | */ |
| 51 | static void afc_unlock(iphone_afc_client_t client) | 54 | static void afc_unlock(afc_client_t client) |
| 52 | { // just to be pretty | 55 | { // just to be pretty |
| 53 | log_debug_msg("Unlocked\n"); | 56 | log_debug_msg("Unlocked\n"); |
| 54 | //client->lock = 0; | 57 | //client->lock = 0; |
| @@ -63,7 +66,7 @@ static void afc_unlock(iphone_afc_client_t client) | |||
| 63 | * | 66 | * |
| 64 | * @return A handle to the newly-connected client or NULL upon error. | 67 | * @return A handle to the newly-connected client or NULL upon error. |
| 65 | */ | 68 | */ |
| 66 | iphone_error_t iphone_afc_new_client(iphone_device_t device, int dst_port, iphone_afc_client_t * client) | 69 | iphone_error_t afc_new_client(iphone_device_t device, int dst_port, afc_client_t * client) |
| 67 | { | 70 | { |
| 68 | //makes sure thread environment is available | 71 | //makes sure thread environment is available |
| 69 | if (!g_thread_supported()) | 72 | if (!g_thread_supported()) |
| @@ -78,7 +81,7 @@ iphone_error_t iphone_afc_new_client(iphone_device_t device, int dst_port, iphon | |||
| 78 | return IPHONE_E_UNKNOWN_ERROR; // ret; | 81 | return IPHONE_E_UNKNOWN_ERROR; // ret; |
| 79 | } | 82 | } |
| 80 | 83 | ||
| 81 | iphone_afc_client_t client_loc = (iphone_afc_client_t) malloc(sizeof(struct iphone_afc_client_int)); | 84 | afc_client_t client_loc = (afc_client_t) malloc(sizeof(struct afc_client_int)); |
| 82 | client_loc->sfd = sfd; | 85 | client_loc->sfd = sfd; |
| 83 | 86 | ||
| 84 | // Allocate a packet | 87 | // Allocate a packet |
| @@ -105,7 +108,7 @@ iphone_error_t iphone_afc_new_client(iphone_device_t device, int dst_port, iphon | |||
| 105 | * | 108 | * |
| 106 | * @param client The client to disconnect. | 109 | * @param client The client to disconnect. |
| 107 | */ | 110 | */ |
| 108 | iphone_error_t iphone_afc_free_client(iphone_afc_client_t client) | 111 | iphone_error_t afc_free_client(afc_client_t client) |
| 109 | { | 112 | { |
| 110 | if (!client || client->sfd < 0 || !client->afc_packet) | 113 | if (!client || client->sfd < 0 || !client->afc_packet) |
| 111 | return IPHONE_E_INVALID_ARG; | 114 | return IPHONE_E_INVALID_ARG; |
| @@ -127,7 +130,7 @@ iphone_error_t iphone_afc_free_client(iphone_afc_client_t client) | |||
| 127 | * | 130 | * |
| 128 | * @return AFC error code or -1 on error. | 131 | * @return AFC error code or -1 on error. |
| 129 | */ | 132 | */ |
| 130 | int iphone_afc_get_afcerror(iphone_afc_client_t client) | 133 | int afc_get_afcerror(afc_client_t client) |
| 131 | { | 134 | { |
| 132 | int res = -1; | 135 | int res = -1; |
| 133 | if (client) { | 136 | if (client) { |
| @@ -140,13 +143,13 @@ int iphone_afc_get_afcerror(iphone_afc_client_t client) | |||
| 140 | 143 | ||
| 141 | /** | 144 | /** |
| 142 | * Tries to convert the AFC error value into a meaningful errno value. | 145 | * Tries to convert the AFC error value into a meaningful errno value. |
| 143 | * Internally used by iphone_afc_get_errno. | 146 | * Internally used by afc_get_errno. |
| 144 | * | 147 | * |
| 145 | * @param afcerror AFC error value to convert | 148 | * @param afcerror AFC error value to convert |
| 146 | * | 149 | * |
| 147 | * @return errno value or -1 if the errno could not be determined. | 150 | * @return errno value or -1 if the errno could not be determined. |
| 148 | * | 151 | * |
| 149 | * @see iphone_afc_get_errno | 152 | * @see afc_get_errno |
| 150 | */ | 153 | */ |
| 151 | static int afcerror_to_errno(int afcerror) | 154 | static int afcerror_to_errno(int afcerror) |
| 152 | { | 155 | { |
| @@ -189,7 +192,7 @@ static int afcerror_to_errno(int afcerror) | |||
| 189 | * | 192 | * |
| 190 | * @return errno value or -1 on error. | 193 | * @return errno value or -1 on error. |
| 191 | */ | 194 | */ |
| 192 | int iphone_afc_get_errno(iphone_afc_client_t client) | 195 | int afc_get_errno(afc_client_t client) |
| 193 | { | 196 | { |
| 194 | int res = -1; | 197 | int res = -1; |
| 195 | if (client) { | 198 | if (client) { |
| @@ -213,7 +216,7 @@ int iphone_afc_get_errno(iphone_afc_client_t client) | |||
| 213 | * reason is that if you set them to different values, it indicates | 216 | * reason is that if you set them to different values, it indicates |
| 214 | * you want to send the data as two packets. | 217 | * you want to send the data as two packets. |
| 215 | */ | 218 | */ |
| 216 | static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, uint64_t length) | 219 | static int dispatch_AFC_packet(afc_client_t client, const char *data, uint64_t length) |
| 217 | { | 220 | { |
| 218 | int bytes = 0, offset = 0; | 221 | int bytes = 0, offset = 0; |
| 219 | char *buffer; | 222 | char *buffer; |
| @@ -294,7 +297,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, uin | |||
| 294 | * received raised a non-trivial error condition (i.e. non-zero with | 297 | * received raised a non-trivial error condition (i.e. non-zero with |
| 295 | * AFC_ERROR operation) | 298 | * AFC_ERROR operation) |
| 296 | */ | 299 | */ |
| 297 | static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) | 300 | static int receive_AFC_data(afc_client_t client, char **dump_here) |
| 298 | { | 301 | { |
| 299 | AFCPacket header; | 302 | AFCPacket header; |
| 300 | int bytes = 0; | 303 | int bytes = 0; |
| @@ -468,7 +471,7 @@ static char **make_strings_list(char *tokens, int true_length) | |||
| 468 | * @return A char ** list of files in that directory, terminated by an empty | 471 | * @return A char ** list of files in that directory, terminated by an empty |
| 469 | * string for now or NULL if there was an error. | 472 | * string for now or NULL if there was an error. |
| 470 | */ | 473 | */ |
| 471 | iphone_error_t iphone_afc_get_dir_list(iphone_afc_client_t client, const char *dir, char ***list) | 474 | iphone_error_t afc_get_dir_list(afc_client_t client, const char *dir, char ***list) |
| 472 | { | 475 | { |
| 473 | int bytes = 0; | 476 | int bytes = 0; |
| 474 | char *data = NULL, **list_loc = NULL; | 477 | char *data = NULL, **list_loc = NULL; |
| @@ -514,7 +517,7 @@ iphone_error_t iphone_afc_get_dir_list(iphone_afc_client_t client, const char *d | |||
| 514 | * @return A char ** list of parameters as given by AFC or NULL if there was an | 517 | * @return A char ** list of parameters as given by AFC or NULL if there was an |
| 515 | * error. | 518 | * error. |
| 516 | */ | 519 | */ |
| 517 | iphone_error_t iphone_afc_get_devinfo(iphone_afc_client_t client, char ***infos) | 520 | iphone_error_t afc_get_devinfo(afc_client_t client, char ***infos) |
| 518 | { | 521 | { |
| 519 | int bytes = 0; | 522 | int bytes = 0; |
| 520 | char *data = NULL, **list = NULL; | 523 | char *data = NULL, **list = NULL; |
| @@ -556,7 +559,7 @@ iphone_error_t iphone_afc_get_devinfo(iphone_afc_client_t client, char ***infos) | |||
| 556 | * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG | 559 | * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG |
| 557 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. | 560 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. |
| 558 | */ | 561 | */ |
| 559 | iphone_error_t iphone_afc_delete_file(iphone_afc_client_t client, const char *path) | 562 | iphone_error_t afc_delete_file(afc_client_t client, const char *path) |
| 560 | { | 563 | { |
| 561 | char *response = NULL; | 564 | char *response = NULL; |
| 562 | int bytes; | 565 | int bytes; |
| @@ -596,7 +599,7 @@ iphone_error_t iphone_afc_delete_file(iphone_afc_client_t client, const char *pa | |||
| 596 | * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG | 599 | * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG |
| 597 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. | 600 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. |
| 598 | */ | 601 | */ |
| 599 | iphone_error_t iphone_afc_rename_file(iphone_afc_client_t client, const char *from, const char *to) | 602 | iphone_error_t afc_rename_file(afc_client_t client, const char *from, const char *to) |
| 600 | { | 603 | { |
| 601 | char *response = NULL; | 604 | char *response = NULL; |
| 602 | char *send = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); | 605 | char *send = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); |
| @@ -640,7 +643,7 @@ iphone_error_t iphone_afc_rename_file(iphone_afc_client_t client, const char *fr | |||
| 640 | * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG | 643 | * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG |
| 641 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. | 644 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. |
| 642 | */ | 645 | */ |
| 643 | iphone_error_t iphone_afc_mkdir(iphone_afc_client_t client, const char *dir) | 646 | iphone_error_t afc_mkdir(afc_client_t client, const char *dir) |
| 644 | { | 647 | { |
| 645 | int bytes = 0; | 648 | int bytes = 0; |
| 646 | char *response = NULL; | 649 | char *response = NULL; |
| @@ -682,7 +685,7 @@ iphone_error_t iphone_afc_mkdir(iphone_afc_client_t client, const char *dir) | |||
| 682 | * @return IPHONE_E_SUCCESS on success or an IPHONE_E_* error value | 685 | * @return IPHONE_E_SUCCESS on success or an IPHONE_E_* error value |
| 683 | * when something went wrong. | 686 | * when something went wrong. |
| 684 | */ | 687 | */ |
| 685 | iphone_error_t iphone_afc_get_file_info(iphone_afc_client_t client, const char *path, char ***infolist) | 688 | iphone_error_t afc_get_file_info(afc_client_t client, const char *path, char ***infolist) |
| 686 | { | 689 | { |
| 687 | char *received = NULL; | 690 | char *received = NULL; |
| 688 | int length; | 691 | int length; |
| @@ -726,8 +729,8 @@ iphone_error_t iphone_afc_get_file_info(iphone_afc_client_t client, const char * | |||
| 726 | * @return IPHONE_E_SUCCESS on success or an IPHONE_E_* error on failure. | 729 | * @return IPHONE_E_SUCCESS on success or an IPHONE_E_* error on failure. |
| 727 | */ | 730 | */ |
| 728 | iphone_error_t | 731 | iphone_error_t |
| 729 | iphone_afc_open_file(iphone_afc_client_t client, const char *filename, | 732 | afc_open_file(afc_client_t client, const char *filename, |
| 730 | iphone_afc_file_mode_t file_mode, uint64_t *handle) | 733 | afc_file_mode_t file_mode, uint64_t *handle) |
| 731 | { | 734 | { |
| 732 | uint32_t ag = 0; | 735 | uint32_t ag = 0; |
| 733 | int bytes = 0, length = 0; | 736 | int bytes = 0, length = 0; |
| @@ -786,7 +789,7 @@ iphone_afc_open_file(iphone_afc_client_t client, const char *filename, | |||
| 786 | * @return The number of bytes read if successful. If there was an error -1. | 789 | * @return The number of bytes read if successful. If there was an error -1. |
| 787 | */ | 790 | */ |
| 788 | iphone_error_t | 791 | iphone_error_t |
| 789 | iphone_afc_read_file(iphone_afc_client_t client, uint64_t handle, char *data, int length, uint32_t * bytes) | 792 | afc_read_file(afc_client_t client, uint64_t handle, char *data, int length, uint32_t * bytes) |
| 790 | { | 793 | { |
| 791 | char *input = NULL; | 794 | char *input = NULL; |
| 792 | int current_count = 0, bytes_loc = 0; | 795 | int current_count = 0, bytes_loc = 0; |
| @@ -857,7 +860,7 @@ iphone_afc_read_file(iphone_afc_client_t client, uint64_t handle, char *data, in | |||
| 857 | * none were written... | 860 | * none were written... |
| 858 | */ | 861 | */ |
| 859 | iphone_error_t | 862 | iphone_error_t |
| 860 | iphone_afc_write_file(iphone_afc_client_t client, uint64_t handle, | 863 | afc_write_file(afc_client_t client, uint64_t handle, |
| 861 | const char *data, int length, uint32_t * bytes) | 864 | const char *data, int length, uint32_t * bytes) |
| 862 | { | 865 | { |
| 863 | char *acknowledgement = NULL; | 866 | char *acknowledgement = NULL; |
| @@ -946,7 +949,7 @@ iphone_afc_write_file(iphone_afc_client_t client, uint64_t handle, | |||
| 946 | * @param client The client to close the file with. | 949 | * @param client The client to close the file with. |
| 947 | * @param handle File handle of a previously opened file. | 950 | * @param handle File handle of a previously opened file. |
| 948 | */ | 951 | */ |
| 949 | iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, uint64_t handle) | 952 | iphone_error_t afc_close_file(afc_client_t client, uint64_t handle) |
| 950 | { | 953 | { |
| 951 | if (!client || (handle == 0)) | 954 | if (!client || (handle == 0)) |
| 952 | return IPHONE_E_INVALID_ARG; | 955 | return IPHONE_E_INVALID_ARG; |
| @@ -997,7 +1000,7 @@ iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, uint64_t handle | |||
| 997 | * @param handle File handle of a previously opened file. | 1000 | * @param handle File handle of a previously opened file. |
| 998 | * @operation the lock or unlock operation to perform. | 1001 | * @operation the lock or unlock operation to perform. |
| 999 | */ | 1002 | */ |
| 1000 | iphone_error_t iphone_afc_lock_file(iphone_afc_client_t client, uint64_t handle, int operation) | 1003 | iphone_error_t afc_lock_file(afc_client_t client, uint64_t handle, int operation) |
| 1001 | { | 1004 | { |
| 1002 | if (!client || (handle == 0)) | 1005 | if (!client || (handle == 0)) |
| 1003 | return IPHONE_E_INVALID_ARG; | 1006 | return IPHONE_E_INVALID_ARG; |
| @@ -1046,7 +1049,7 @@ iphone_error_t iphone_afc_lock_file(iphone_afc_client_t client, uint64_t handle, | |||
| 1046 | * | 1049 | * |
| 1047 | * @return IPHONE_E_SUCCESS on success, IPHONE_E_NOT_ENOUGH_DATA on failure. | 1050 | * @return IPHONE_E_SUCCESS on success, IPHONE_E_NOT_ENOUGH_DATA on failure. |
| 1048 | */ | 1051 | */ |
| 1049 | iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, uint64_t handle, int64_t offset, int whence) | 1052 | iphone_error_t afc_seek_file(afc_client_t client, uint64_t handle, int64_t offset, int whence) |
| 1050 | { | 1053 | { |
| 1051 | char *buffer = (char *) malloc(sizeof(char) * 24); | 1054 | char *buffer = (char *) malloc(sizeof(char) * 24); |
| 1052 | uint32_t zero = 0; | 1055 | uint32_t zero = 0; |
| @@ -1093,7 +1096,7 @@ iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, uint64_t handle, | |||
| 1093 | * @note This function is more akin to ftruncate than truncate, and truncate | 1096 | * @note This function is more akin to ftruncate than truncate, and truncate |
| 1094 | * calls would have to open the file before calling this, sadly. | 1097 | * calls would have to open the file before calling this, sadly. |
| 1095 | */ | 1098 | */ |
| 1096 | iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, uint64_t handle, uint64_t newsize) | 1099 | iphone_error_t afc_truncate_file(afc_client_t client, uint64_t handle, uint64_t newsize) |
| 1097 | { | 1100 | { |
| 1098 | char *buffer = (char *) malloc(sizeof(char) * 16); | 1101 | char *buffer = (char *) malloc(sizeof(char) * 16); |
| 1099 | int bytes = 0; | 1102 | int bytes = 0; |
| @@ -1135,7 +1138,7 @@ iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, uint64_t han | |||
| 1135 | * @return IPHONE_E_SUCCESS if everything went well, IPHONE_E_INVALID_ARG | 1138 | * @return IPHONE_E_SUCCESS if everything went well, IPHONE_E_INVALID_ARG |
| 1136 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. | 1139 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. |
| 1137 | */ | 1140 | */ |
| 1138 | iphone_error_t iphone_afc_truncate(iphone_afc_client_t client, const char *path, off_t newsize) | 1141 | iphone_error_t afc_truncate(afc_client_t client, const char *path, off_t newsize) |
| 1139 | { | 1142 | { |
| 1140 | char *response = NULL; | 1143 | char *response = NULL; |
| 1141 | char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); | 1144 | char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); |
| @@ -1181,7 +1184,7 @@ iphone_error_t iphone_afc_truncate(iphone_afc_client_t client, const char *path, | |||
| 1181 | * @return IPHONE_E_SUCCESS if everything went well, IPHONE_E_INVALID_ARG | 1184 | * @return IPHONE_E_SUCCESS if everything went well, IPHONE_E_INVALID_ARG |
| 1182 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. | 1185 | * if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise. |
| 1183 | */ | 1186 | */ |
| 1184 | iphone_error_t iphone_afc_make_link(iphone_afc_client_t client, iphone_afc_link_type_t linktype, const char *target, const char *linkname) | 1187 | iphone_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname) |
| 1185 | { | 1188 | { |
| 1186 | char *response = NULL; | 1189 | char *response = NULL; |
| 1187 | char *send = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); | 1190 | char *send = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); |
| @@ -19,9 +19,6 @@ | |||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include "libiphone/libiphone.h" | ||
| 23 | #include "iphone.h" | ||
| 24 | |||
| 25 | #include <string.h> | 22 | #include <string.h> |
| 26 | #include <stdio.h> | 23 | #include <stdio.h> |
| 27 | #include <stdlib.h> | 24 | #include <stdlib.h> |
| @@ -46,7 +43,7 @@ typedef struct __AFCToken { | |||
| 46 | char *token; | 43 | char *token; |
| 47 | } AFCToken; | 44 | } AFCToken; |
| 48 | 45 | ||
| 49 | struct iphone_afc_client_int { | 46 | struct afc_client_int { |
| 50 | int sfd; | 47 | int sfd; |
| 51 | AFCPacket *afc_packet; | 48 | AFCPacket *afc_packet; |
| 52 | int file_handle; | 49 | int file_handle; |
