diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/afccheck.c | 4 | ||||
| -rw-r--r-- | dev/main.c | 27 |
2 files changed, 20 insertions, 11 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c index 2f7d92c..965981b 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c | |||
| @@ -50,13 +50,13 @@ void check_afc(gpointer data) | |||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | //now writes buffer on iphone | 52 | //now writes buffer on iphone |
| 53 | iphone_afc_file_t file = NULL; | 53 | uint64_t file = 0; |
| 54 | char path[50]; | 54 | char path[50]; |
| 55 | sprintf(path, "/Buf%i", ((param *) data)->id); | 55 | sprintf(path, "/Buf%i", ((param *) data)->id); |
| 56 | iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); | 56 | iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file); |
| 57 | iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); | 57 | iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes); |
| 58 | iphone_afc_close_file(((param *) data)->afc, file); | 58 | iphone_afc_close_file(((param *) data)->afc, file); |
| 59 | file = NULL; | 59 | file = 0; |
| 60 | if (bytes != buffersize) | 60 | if (bytes != buffersize) |
| 61 | printf("Write operation failed\n"); | 61 | printf("Write operation failed\n"); |
| 62 | 62 | ||
| @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) | |||
| 59 | int npp; | 59 | int npp; |
| 60 | iphone_lckd_client_t control = NULL; | 60 | iphone_lckd_client_t control = NULL; |
| 61 | iphone_device_t phone = NULL; | 61 | iphone_device_t phone = NULL; |
| 62 | iphone_afc_file_t lockfile = NULL; | 62 | uint64_t lockfile = 0; |
| 63 | iphone_np_client_t gnp = NULL; | 63 | iphone_np_client_t gnp = NULL; |
| 64 | 64 | ||
| 65 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | 65 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { |
| @@ -148,14 +148,23 @@ int main(int argc, char *argv[]) | |||
| 148 | } | 148 | } |
| 149 | g_strfreev(dirs); | 149 | g_strfreev(dirs); |
| 150 | 150 | ||
| 151 | iphone_afc_file_t my_file = NULL; | 151 | uint64_t my_file = 0; |
| 152 | struct stat stbuf; | 152 | char **info = NULL; |
| 153 | iphone_afc_get_file_attr(afc, "/iTunesOnTheGoPlaylist.plist", &stbuf); | 153 | uint64_t fsize = 0; |
| 154 | if (IPHONE_E_SUCCESS == iphone_afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) { | ||
| 155 | for (i = 0; info[i]; i += 2) { | ||
| 156 | printf("%s: %s\n", info[i], info[i+1]); | ||
| 157 | if (!strcmp(info[i], "st_size")) { | ||
| 158 | fsize = atoll(info[i+1]); | ||
| 159 | } | ||
| 160 | } | ||
| 161 | } | ||
| 162 | |||
| 154 | if (IPHONE_E_SUCCESS == | 163 | if (IPHONE_E_SUCCESS == |
| 155 | iphone_afc_open_file(afc, "/iTunesOnTheGoPlaylist.plist", AFC_FOPEN_RDONLY, &my_file) && my_file) { | 164 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) { |
| 156 | printf("A file size: %i\n", (int) stbuf.st_size); | 165 | printf("A file size: %i\n", fsize); |
| 157 | char *file_data = (char *) malloc(sizeof(char) * stbuf.st_size); | 166 | char *file_data = (char *) malloc(sizeof(char) * fsize); |
| 158 | iphone_afc_read_file(afc, my_file, file_data, stbuf.st_size, &bytes); | 167 | iphone_afc_read_file(afc, my_file, file_data, fsize, &bytes); |
| 159 | if (bytes >= 0) { | 168 | if (bytes >= 0) { |
| 160 | printf("The file's data:\n"); | 169 | printf("The file's data:\n"); |
| 161 | fwrite(file_data, 1, bytes, stdout); | 170 | fwrite(file_data, 1, bytes, stdout); |
| @@ -193,7 +202,7 @@ int main(int argc, char *argv[]) | |||
| 193 | 202 | ||
| 194 | printf("Seek & read\n"); | 203 | printf("Seek & read\n"); |
| 195 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); | 204 | iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file); |
| 196 | if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5)) | 205 | if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5, SEEK_CUR)) |
| 197 | printf("WARN: SEEK DID NOT WORK\n"); | 206 | printf("WARN: SEEK DID NOT WORK\n"); |
| 198 | char *threeletterword = (char *) malloc(sizeof(char) * 5); | 207 | char *threeletterword = (char *) malloc(sizeof(char) * 5); |
| 199 | iphone_afc_read_file(afc, my_file, threeletterword, 3, &bytes); | 208 | iphone_afc_read_file(afc, my_file, threeletterword, 3, &bytes); |
