summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/AFC.c40
-rw-r--r--src/AFC.h4
2 files changed, 20 insertions, 24 deletions
diff --git a/src/AFC.c b/src/AFC.c
index 055f59f..18e7cf9 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -28,7 +28,7 @@ extern int debug;
28 28
29 29
30/* Locking, for thread-safety (well... kind of, hehe) */ 30/* Locking, for thread-safety (well... kind of, hehe) */
31void afc_lock(AFClient *client) { 31static void afc_lock(AFClient *client) {
32 if (debug) printf("In the midst of a lock...\n"); 32 if (debug) printf("In the midst of a lock...\n");
33 while (client->lock) { 33 while (client->lock) {
34 usleep(500); // they say it's obsolete, but whatever 34 usleep(500); // they say it's obsolete, but whatever
@@ -36,7 +36,7 @@ void afc_lock(AFClient *client) {
36 client->lock = 1; 36 client->lock = 1;
37} 37}
38 38
39void afc_unlock(AFClient *client) { // just to be pretty 39static void afc_unlock(AFClient *client) { // just to be pretty
40 if (debug) printf("Unlock!\n"); 40 if (debug) printf("Unlock!\n");
41 client->lock = 0; 41 client->lock = 0;
42} 42}
@@ -76,7 +76,7 @@ void afc_disconnect(AFClient *client) {
76 free(client); 76 free(client);
77} 77}
78 78
79int count_nullspaces(char *string, int number) { 79static int count_nullspaces(char *string, int number) {
80 int i = 0, nulls = 0; 80 int i = 0, nulls = 0;
81 for (i = 0; i < number; i++) { 81 for (i = 0; i < number; i++) {
82 if (string[i] == '\0') nulls++; 82 if (string[i] == '\0') nulls++;
@@ -84,7 +84,7 @@ int count_nullspaces(char *string, int number) {
84 return nulls; 84 return nulls;
85} 85}
86 86
87int dispatch_AFC_packet(AFClient *client, const char *data, int length) { 87static int dispatch_AFC_packet(AFClient *client, const char *data, int length) {
88 int bytes = 0, offset = 0; 88 int bytes = 0, offset = 0;
89 if (!client || !client->connection || !client->afc_packet) return 0; 89 if (!client || !client->connection || !client->afc_packet) return 0;
90 if (!data || !length) length = 0; 90 if (!data || !length) length = 0;
@@ -135,7 +135,7 @@ int dispatch_AFC_packet(AFClient *client, const char *data, int length) {
135 return -1; 135 return -1;
136} 136}
137 137
138int receive_AFC_data(AFClient *client, char **dump_here) { 138static int receive_AFC_data(AFClient *client, char **dump_here) {
139 AFCPacket *r_packet; 139 AFCPacket *r_packet;
140 char *buffer = (char*)malloc(sizeof(AFCPacket) * 4); 140 char *buffer = (char*)malloc(sizeof(AFCPacket) * 4);
141 char *final_buffer = NULL; 141 char *final_buffer = NULL;
@@ -232,6 +232,21 @@ int receive_AFC_data(AFClient *client, char **dump_here) {
232 return current_count; 232 return current_count;
233} 233}
234 234
235static char **make_strings_list(char *tokens, int true_length) {
236 if (!tokens || !true_length) return NULL;
237 int nulls = 0, i = 0, j = 0;
238 char **list = NULL;
239
240 nulls = count_nullspaces(tokens, true_length);
241 list = (char**)malloc(sizeof(char*) * (nulls + 1));
242 for (i = 0; i < nulls; i++) {
243 list[i] = strdup(tokens+j);
244 j += strlen(list[i]) + 1;
245 }
246 list[i] = strdup("");
247 return list;
248}
249
235char **afc_get_dir_list(AFClient *client, const char *dir) { 250char **afc_get_dir_list(AFClient *client, const char *dir) {
236 afc_lock(client); 251 afc_lock(client);
237 client->afc_packet->operation = AFC_LIST_DIR; 252 client->afc_packet->operation = AFC_LIST_DIR;
@@ -269,21 +284,6 @@ char **afc_get_devinfo(AFClient *client) {
269} 284}
270 285
271 286
272char **make_strings_list(char *tokens, int true_length) {
273 if (!tokens || !true_length) return NULL;
274 int nulls = 0, i = 0, j = 0;
275 char **list = NULL;
276
277 nulls = count_nullspaces(tokens, true_length);
278 list = (char**)malloc(sizeof(char*) * (nulls + 1));
279 for (i = 0; i < nulls; i++) {
280 list[i] = strdup(tokens+j);
281 j += strlen(list[i]) + 1;
282 }
283 list[i] = strdup("");
284 return list;
285}
286
287int afc_delete_file(AFClient *client, const char *path) { 287int afc_delete_file(AFClient *client, const char *path) {
288 if (!client || !path || !client->afc_packet || !client->connection) return 0; 288 if (!client || !path || !client->afc_packet || !client->connection) return 0;
289 afc_lock(client); 289 afc_lock(client);
diff --git a/src/AFC.h b/src/AFC.h
index 39ada91..8d2fea4 100644
--- a/src/AFC.h
+++ b/src/AFC.h
@@ -86,10 +86,6 @@ enum {
86 86
87AFClient *afc_connect(iPhone *phone, int s_port, int d_port); 87AFClient *afc_connect(iPhone *phone, int s_port, int d_port);
88void afc_disconnect(AFClient *client); 88void afc_disconnect(AFClient *client);
89int count_nullspaces(char *string, int number);
90char **make_strings_list(char *tokens, int true_length);
91int dispatch_AFC_packet(AFClient *client, const char *data, int length);
92int receive_AFC_data(AFClient *client, char **dump_here);
93 89
94char **afc_get_dir_list(AFClient *client, const char *dir); 90char **afc_get_dir_list(AFClient *client, const char *dir);
95AFCFile *afc_get_file_info(AFClient *client, const char *path); 91AFCFile *afc_get_file_info(AFClient *client, const char *path);