summaryrefslogtreecommitdiffstats
path: root/dev/afccheck.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-07-06 19:38:00 +0200
committerGravatar Matt Colyer2009-07-18 10:39:41 -0700
commit4105af17e9f2df5405afa6a74a02a304ed6bacff (patch)
treedaf79b623def5a66810466842197f3bc696c8c28 /dev/afccheck.c
parent6de08b1e12946b85a595f82c1c04391d70d8b828 (diff)
downloadlibimobiledevice-4105af17e9f2df5405afa6a74a02a304ed6bacff.tar.gz
libimobiledevice-4105af17e9f2df5405afa6a74a02a304ed6bacff.tar.bz2
API cleanup for AFC
Diffstat (limited to 'dev/afccheck.c')
-rw-r--r--dev/afccheck.c21
1 files changed, 11 insertions, 10 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
33typedef struct { 34typedef 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())