diff options
| author | 2008-08-31 18:31:21 +0200 | |
|---|---|---|
| committer | 2008-08-31 19:33:19 +0200 | |
| commit | 8333ca944cc56b4da1ab418c0b890f96f5135210 (patch) | |
| tree | 63792ef9d2786d23b53e47dd8af9f9055c1a6bef /src/main.c | |
| parent | 86f61988990daa30c8564e2b26666dd442bd6e65 (diff) | |
| download | libimobiledevice-8333ca944cc56b4da1ab418c0b890f96f5135210.tar.gz libimobiledevice-8333ca944cc56b4da1ab418c0b890f96f5135210.tar.bz2 | |
use new function signature and few bugfixes.
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 21 |
1 files changed, 10 insertions, 11 deletions
| @@ -56,27 +56,27 @@ int main(int argc, char *argv[]) { | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | char *uid = NULL; | 58 | char *uid = NULL; |
| 59 | if (lockdownd_get_device_uid(control, &uid)) { | 59 | if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(control, &uid)) { |
| 60 | printf("DeviceUniqueID : %s\n", uid); | 60 | printf("DeviceUniqueID : %s\n", uid); |
| 61 | free(uid); | 61 | free(uid); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | port = iphone_lckd_start_service(control, "com.apple.afc"); | 64 | iphone_lckd_start_service(control, "com.apple.afc", &port); |
| 65 | 65 | ||
| 66 | if (port) { | 66 | if (port) { |
| 67 | iphone_afc_client_t afc = NULL; | 67 | iphone_afc_client_t afc = NULL; |
| 68 | iphone_afc_new_client(phone, 3432, port, &afc); | 68 | iphone_afc_new_client(phone, 3432, port, &afc); |
| 69 | if (afc) { | 69 | if (afc) { |
| 70 | char **dirs; | 70 | char **dirs = NULL; |
| 71 | dirs = iphone_afc_get_dir_list(afc, "/eafaedf"); | 71 | iphone_afc_get_dir_list(afc, "/eafaedf", &dirs); |
| 72 | if (!dirs) dirs = iphone_afc_get_dir_list(afc, "/"); | 72 | if (!dirs) iphone_afc_get_dir_list(afc, "/", &dirs); |
| 73 | printf("Directory time.\n"); | 73 | printf("Directory time.\n"); |
| 74 | for (i = 0; dirs[i]; i++) { | 74 | for (i = 0; dirs[i]; i++) { |
| 75 | printf("/%s\n", dirs[i]); | 75 | printf("/%s\n", dirs[i]); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | g_strfreev(dirs); | 78 | g_strfreev(dirs); |
| 79 | dirs = iphone_afc_get_devinfo(afc); | 79 | iphone_afc_get_devinfo(afc, &dirs); |
| 80 | if (dirs) { | 80 | if (dirs) { |
| 81 | for (i = 0; dirs[i]; i+=2) { | 81 | for (i = 0; dirs[i]; i+=2) { |
| 82 | printf("%s: %s\n", dirs[i], dirs[i+1]); | 82 | printf("%s: %s\n", dirs[i], dirs[i+1]); |
| @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) { | |||
| 90 | if (IPHONE_E_SUCCESS == iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", AFC_FILE_READ, &my_file) && my_file) { | 90 | if (IPHONE_E_SUCCESS == iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", AFC_FILE_READ, &my_file) && my_file) { |
| 91 | printf("A file size: %i\n", stbuf.st_size); | 91 | printf("A file size: %i\n", stbuf.st_size); |
| 92 | char *file_data = (char*)malloc(sizeof(char) * stbuf.st_size); | 92 | char *file_data = (char*)malloc(sizeof(char) * stbuf.st_size); |
| 93 | bytes = iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size); | 93 | iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); |
| 94 | if (bytes >= 0) { | 94 | if (bytes >= 0) { |
| 95 | printf("The file's data:\n"); | 95 | printf("The file's data:\n"); |
| 96 | fwrite(file_data, 1, bytes, stdout); | 96 | fwrite(file_data, 1, bytes, stdout); |
| @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) { | |||
| 103 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FILE_WRITE, &my_file); | 103 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FILE_WRITE, &my_file); |
| 104 | if (my_file) { | 104 | if (my_file) { |
| 105 | char *outdatafile = strdup("this is a bitchin text file\n"); | 105 | char *outdatafile = strdup("this is a bitchin text file\n"); |
| 106 | bytes = iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile)); | 106 | iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes); |
| 107 | free(outdatafile); | 107 | free(outdatafile); |
| 108 | if (bytes > 0) printf("Wrote a surprise. ;)\n"); | 108 | if (bytes > 0) printf("Wrote a surprise. ;)\n"); |
| 109 | else printf("I wanted to write a surprise, but... :(\n"); | 109 | else printf("I wanted to write a surprise, but... :(\n"); |
| @@ -121,10 +121,9 @@ int main(int argc, char *argv[]) { | |||
| 121 | 121 | ||
| 122 | printf("Seek & read\n"); | 122 | printf("Seek & read\n"); |
| 123 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FILE_READ, &my_file); | 123 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FILE_READ, &my_file); |
| 124 | bytes = iphone_afc_seek_file(afc, my_file, 5); | 124 | if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5)) printf("WARN: SEEK DID NOT WORK\n"); |
| 125 | if (bytes) printf("WARN: SEEK DID NOT WORK\n"); | ||
| 126 | char *threeletterword = (char*)malloc(sizeof(char) * 5); | 125 | char *threeletterword = (char*)malloc(sizeof(char) * 5); |
| 127 | bytes = iphone_afc_read_file(afc, my_file, threeletterword, 3); | 126 | iphone_afc_read_file(afc, my_file, threeletterword, 3, &bytes); |
| 128 | threeletterword[3] = '\0'; | 127 | threeletterword[3] = '\0'; |
| 129 | if (bytes > 0) printf("Result: %s\n", threeletterword); | 128 | if (bytes > 0) printf("Result: %s\n", threeletterword); |
| 130 | else printf("Couldn't read!\n"); | 129 | else printf("Couldn't read!\n"); |
