summaryrefslogtreecommitdiffstats
path: root/dev
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2009-07-25 03:26:39 +0200
committerGravatar Martin Szulecki2009-07-25 03:26:39 +0200
commit50be30047dbb0d38fd8d61763c13ec75d2b52543 (patch)
tree87e021b478c6db6197294e4ef56c47cdad0f5992 /dev
parent1cfc2748d38eb97100cabced3b282108898099c2 (diff)
downloadlibimobiledevice-50be30047dbb0d38fd8d61763c13ec75d2b52543.tar.gz
libimobiledevice-50be30047dbb0d38fd8d61763c13ec75d2b52543.tar.bz2
Update AFC API and use error codes from the STATUS operation response
Diffstat (limited to 'dev')
-rw-r--r--dev/afccheck.c16
-rw-r--r--dev/main.c46
2 files changed, 31 insertions, 31 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c
index 067dd5b..d06a147 100644
--- a/dev/afccheck.c
+++ b/dev/afccheck.c
@@ -55,18 +55,18 @@ void check_afc(gpointer data)
uint64_t file = 0;
char path[50];
sprintf(path, "/Buf%i", ((param *) data)->id);
- afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file);
- afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes);
- afc_close_file(((param *) data)->afc, file);
+ afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RW, &file);
+ afc_file_write(((param *) data)->afc, file, (char *) buf, buffersize, &bytes);
+ afc_file_close(((param *) data)->afc, file);
file = 0;
if (bytes != buffersize)
printf("Write operation failed\n");
//now read it
bytes = 0;
- afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file);
- afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes);
- afc_close_file(((param *) data)->afc, file);
+ afc_file_open(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file);
+ afc_file_read(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes);
+ afc_file_close(((param *) data)->afc, file);
if (bytes != buffersize)
printf("Read operation failed\n");
@@ -79,7 +79,7 @@ void check_afc(gpointer data)
}
//cleanup
- afc_delete_file(((param *) data)->afc, path);
+ afc_remove_path(((param *) data)->afc, path);
g_thread_exit(0);
}
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
return 1;
}
- afc_new_client(phone, port, &afc);
+ afc_client_new(phone, port, &afc);
//makes sure thread environment is available
if (!g_thread_supported())
diff --git a/dev/main.c b/dev/main.c
index 5551ed9..3e5860e 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
if (port) {
afc_client_t afc = NULL;
- afc_new_client(phone, port, &afc);
+ afc_client_new(phone, port, &afc);
if (afc) {
lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp);
if (npp) {
@@ -126,18 +126,18 @@ int main(int argc, char *argv[])
perform_notification(phone, client, NP_SYNC_WILL_START);
- afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile);
+ afc_file_open(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile);
if (lockfile) {
printf("locking file\n");
- afc_lock_file(afc, lockfile, AFC_LOCK_EX);
+ afc_file_lock(afc, lockfile, AFC_LOCK_EX);
perform_notification(phone, client, NP_SYNC_DID_START);
}
char **dirs = NULL;
- afc_get_dir_list(afc, "/eafaedf", &dirs);
+ afc_read_directory(afc, "/eafaedf", &dirs);
if (!dirs)
- afc_get_dir_list(afc, "/", &dirs);
+ afc_read_directory(afc, "/", &dirs);
printf("Directory time.\n");
for (i = 0; dirs[i]; i++) {
printf("/%s\n", dirs[i]);
@@ -146,7 +146,7 @@ int main(int argc, char *argv[])
g_strfreev(dirs);
dirs = NULL;
- afc_get_devinfo(afc, &dirs);
+ afc_get_device_info(afc, &dirs);
if (dirs) {
for (i = 0; dirs[i]; i += 2) {
printf("%s: %s\n", dirs[i], dirs[i + 1]);
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
uint64_t my_file = 0;
char **info = NULL;
uint64_t fsize = 0;
- if (IPHONE_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) {
+ if (AFC_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) {
for (i = 0; info[i]; i += 2) {
printf("%s: %s\n", info[i], info[i+1]);
if (!strcmp(info[i], "st_size")) {
@@ -166,59 +166,59 @@ int main(int argc, char *argv[])
}
}
- if (IPHONE_E_SUCCESS ==
- afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) {
+ if (AFC_E_SUCCESS ==
+ afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) {
printf("A file size: %llu\n", fsize);
char *file_data = (char *) malloc(sizeof(char) * fsize);
- afc_read_file(afc, my_file, file_data, fsize, &bytes);
+ afc_file_read(afc, my_file, file_data, fsize, &bytes);
if (bytes > 0) {
printf("The file's data:\n");
fwrite(file_data, 1, bytes, stdout);
}
printf("\nClosing my file.\n");
- afc_close_file(afc, my_file);
+ afc_file_close(afc, my_file);
free(file_data);
} else
printf("couldn't open a file\n");
- afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file);
+ afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file);
if (my_file) {
char *outdatafile = strdup("this is a bitchin text file\n");
- afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes);
+ afc_file_write(afc, my_file, outdatafile, strlen(outdatafile), &bytes);
free(outdatafile);
if (bytes > 0)
printf("Wrote a surprise. ;)\n");
else
printf("I wanted to write a surprise, but... :(\n");
- afc_close_file(afc, my_file);
+ afc_file_close(afc, my_file);
}
printf("Deleting a file...\n");
- bytes = afc_delete_file(afc, "/delme");
+ bytes = afc_remove_path(afc, "/delme");
if (bytes)
printf("Success.\n");
else
printf("Failure. (expected unless you have a /delme file on your phone)\n");
printf("Renaming a file...\n");
- bytes = afc_rename_file(afc, "/renme", "/renme2");
+ bytes = afc_rename_path(afc, "/renme", "/renme2");
if (bytes > 0)
printf("Success.\n");
else
printf("Failure. (expected unless you have a /renme file on your phone)\n");
printf("Seek & read\n");
- afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file);
- if (IPHONE_E_SUCCESS != afc_seek_file(afc, my_file, 5, SEEK_CUR))
+ afc_file_open(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file);
+ if (AFC_E_SUCCESS != afc_file_seek(afc, my_file, 5, SEEK_CUR))
printf("WARN: SEEK DID NOT WORK\n");
char *threeletterword = (char *) malloc(sizeof(char) * 5);
- afc_read_file(afc, my_file, threeletterword, 3, &bytes);
+ afc_file_read(afc, my_file, threeletterword, 3, &bytes);
threeletterword[3] = '\0';
if (bytes > 0)
printf("Result: %s\n", threeletterword);
else
printf("Couldn't read!\n");
free(threeletterword);
- afc_close_file(afc, my_file);
+ afc_file_close(afc, my_file);
}
if (gnp && lockfile) {
@@ -226,10 +226,10 @@ int main(int argc, char *argv[])
sleep(5);
printf("XXX unlocking file\n");
- afc_lock_file(afc, lockfile, AFC_LOCK_UN);
+ afc_file_lock(afc, lockfile, AFC_LOCK_UN);
printf("XXX closing file\n");
- afc_close_file(afc, lockfile);
+ afc_file_close(afc, lockfile);
printf("XXX sleeping\n");
sleep(5);
@@ -241,7 +241,7 @@ int main(int argc, char *argv[])
gnp = NULL;
}
- afc_free_client(afc);
+ afc_client_free(afc);
} else {
printf("Start service failure.\n");
}