summaryrefslogtreecommitdiffstats
path: root/src/afc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/afc.c')
-rw-r--r--src/afc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/afc.c b/src/afc.c
index 4d6293c..5ae9e38 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -42,7 +42,11 @@ static const int MAXIMUM_PACKET_SIZE = (2 << 15);
42static void afc_lock(afc_client_t client) 42static void afc_lock(afc_client_t client)
43{ 43{
44 debug_info("Locked"); 44 debug_info("Locked");
45#ifdef WIN32
46 EnterCriticalSection(&client->mutex);
47#else
45 pthread_mutex_lock(&client->mutex); 48 pthread_mutex_lock(&client->mutex);
49#endif
46} 50}
47 51
48/** 52/**
@@ -53,7 +57,11 @@ static void afc_lock(afc_client_t client)
53static void afc_unlock(afc_client_t client) 57static void afc_unlock(afc_client_t client)
54{ 58{
55 debug_info("Unlocked"); 59 debug_info("Unlocked");
60#ifdef WIN32
61 LeaveCriticalSection(&client->mutex);
62#else
56 pthread_mutex_unlock(&client->mutex); 63 pthread_mutex_unlock(&client->mutex);
64#endif
57} 65}
58 66
59/** 67/**
@@ -92,7 +100,11 @@ afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_
92 memcpy(client_loc->afc_packet->magic, AFC_MAGIC, AFC_MAGIC_LEN); 100 memcpy(client_loc->afc_packet->magic, AFC_MAGIC, AFC_MAGIC_LEN);
93 client_loc->file_handle = 0; 101 client_loc->file_handle = 0;
94 client_loc->lock = 0; 102 client_loc->lock = 0;
103#ifdef WIN32
104 InitializeCriticalSection(&client_loc->mutex);
105#else
95 pthread_mutex_init(&client_loc->mutex, NULL); 106 pthread_mutex_init(&client_loc->mutex, NULL);
107#endif
96 108
97 *client = client_loc; 109 *client = client_loc;
98 return AFC_E_SUCCESS; 110 return AFC_E_SUCCESS;
@@ -150,7 +162,11 @@ afc_error_t afc_client_free(afc_client_t client)
150 client->connection = NULL; 162 client->connection = NULL;
151 } 163 }
152 free(client->afc_packet); 164 free(client->afc_packet);
165#ifdef WIN32
166 DeleteCriticalSection(&client->mutex);
167#else
153 pthread_mutex_destroy(&client->mutex); 168 pthread_mutex_destroy(&client->mutex);
169#endif
154 free(client); 170 free(client);
155 return AFC_E_SUCCESS; 171 return AFC_E_SUCCESS;
156} 172}
@@ -402,7 +418,9 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3
402 *bytes_recv = 0; 418 *bytes_recv = 0;
403 419
404 debug_info("WARNING: Unknown operation code received 0x%llx param1=%lld", header.operation, param1); 420 debug_info("WARNING: Unknown operation code received 0x%llx param1=%lld", header.operation, param1);
421#ifndef WIN32
405 fprintf(stderr, "%s: WARNING: Unknown operation code received 0x%llx param1=%lld", __func__, (long long)header.operation, (long long)param1); 422 fprintf(stderr, "%s: WARNING: Unknown operation code received 0x%llx param1=%lld", __func__, (long long)header.operation, (long long)param1);
423#endif
406 424
407 return AFC_E_OP_NOT_SUPPORTED; 425 return AFC_E_OP_NOT_SUPPORTED;
408 } 426 }