diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/afccheck.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c index b4d8910..2dab6db 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
| 23 | #include <stdio.h> | 23 | #include <stdio.h> |
| 24 | #include <string.h> | 24 | #include <string.h> |
| 25 | #include <glib.h> | 25 | #include <pthread.h> |
| 26 | 26 | ||
| 27 | #include <libimobiledevice/libimobiledevice.h> | 27 | #include <libimobiledevice/libimobiledevice.h> |
| 28 | #include <libimobiledevice/lockdown.h> | 28 | #include <libimobiledevice/lockdown.h> |
| @@ -38,7 +38,7 @@ typedef struct { | |||
| 38 | } param; | 38 | } param; |
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | static void check_afc(gpointer data) | 41 | static void* check_afc(void *data) |
| 42 | { | 42 | { |
| 43 | //prepare a buffer | 43 | //prepare a buffer |
| 44 | unsigned int buffersize = BUFFER_SIZE * sizeof(unsigned int); | 44 | unsigned int buffersize = BUFFER_SIZE * sizeof(unsigned int); |
| @@ -85,14 +85,13 @@ static void check_afc(gpointer data) | |||
| 85 | 85 | ||
| 86 | //cleanup | 86 | //cleanup |
| 87 | afc_remove_path(((param *) data)->afc, path); | 87 | afc_remove_path(((param *) data)->afc, path); |
| 88 | g_thread_exit(0); | 88 | pthread_exit(0); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | int main(int argc, char *argv[]) | 91 | int main(int argc, char *argv[]) |
| 92 | { | 92 | { |
| 93 | lockdownd_client_t client = NULL; | 93 | lockdownd_client_t client = NULL; |
| 94 | idevice_t phone = NULL; | 94 | idevice_t phone = NULL; |
| 95 | GError *err; | ||
| 96 | uint16_t port = 0; | 95 | uint16_t port = 0; |
| 97 | afc_client_t afc = NULL; | 96 | afc_client_t afc = NULL; |
| 98 | 97 | ||
| @@ -121,22 +120,18 @@ int main(int argc, char *argv[]) | |||
| 121 | 120 | ||
| 122 | afc_client_new(phone, port, &afc); | 121 | afc_client_new(phone, port, &afc); |
| 123 | 122 | ||
| 124 | //makes sure thread environment is available | 123 | pthread_t threads[NB_THREADS]; |
| 125 | if (!g_thread_supported()) | ||
| 126 | g_thread_init(NULL); | ||
| 127 | |||
| 128 | GThread *threads[NB_THREADS]; | ||
| 129 | param data[NB_THREADS]; | 124 | param data[NB_THREADS]; |
| 130 | 125 | ||
| 131 | int i = 0; | 126 | int i = 0; |
| 132 | for (i = 0; i < NB_THREADS; i++) { | 127 | for (i = 0; i < NB_THREADS; i++) { |
| 133 | data[i].afc = afc; | 128 | data[i].afc = afc; |
| 134 | data[i].id = i + 1; | 129 | data[i].id = i + 1; |
| 135 | threads[i] = g_thread_create((GThreadFunc) check_afc, data + i, TRUE, &err); | 130 | pthread_create(&threads[i], NULL, check_afc, data + i); |
| 136 | } | 131 | } |
| 137 | 132 | ||
| 138 | for (i = 0; i < NB_THREADS; i++) { | 133 | for (i = 0; i < NB_THREADS; i++) { |
| 139 | g_thread_join(threads[i]); | 134 | pthread_join(threads[i], NULL); |
| 140 | } | 135 | } |
| 141 | 136 | ||
| 142 | lockdownd_client_free(client); | 137 | lockdownd_client_free(client); |
