summaryrefslogtreecommitdiffstats
path: root/dev/main.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-07-03 22:11:01 +0200
committerGravatar Matt Colyer2009-07-07 08:31:25 -0700
commit9990d53ba2ff4e92b1844beb001dcc9c47d30f3e (patch)
tree1ac137519294fc2be6eed870811a8047bf8ed1e4 /dev/main.c
parent52d1beb6e43cc12ff57e648f1e5bdfadc4d36929 (diff)
downloadlibimobiledevice-9990d53ba2ff4e92b1844beb001dcc9c47d30f3e.tar.gz
libimobiledevice-9990d53ba2ff4e92b1844beb001dcc9c47d30f3e.tar.bz2
AFC cleanup: remove iphone_afc_file_* and use handles instead. Removed afc_get_file_attr because this function has to go into the program (like ifuse); afc_get_file_info has to be used instead. Modified dispatch_AFC_Packet so that the real buffer size has to be specified (instead of length-1).
Diffstat (limited to 'dev/main.c')
-rw-r--r--dev/main.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/dev/main.c b/dev/main.c
index 5c9a5a7..c8c9dfa 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -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);