summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/AFC.c109
-rw-r--r--src/InstallationProxy.c40
-rw-r--r--src/MobileSync.c6
-rw-r--r--src/NotificationProxy.c24
-rw-r--r--src/SBServices.c12
-rw-r--r--src/debug.c70
-rw-r--r--src/debug.h20
-rw-r--r--src/device_link_service.c16
-rw-r--r--src/iphone.c26
-rw-r--r--src/lockdown.c106
-rw-r--r--src/property_list_service.c20
-rw-r--r--src/userpref.c4
12 files changed, 247 insertions, 206 deletions
diff --git a/src/AFC.c b/src/AFC.c
index fe8e1af..d430e08 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -36,7 +36,7 @@ static const int MAXIMUM_PACKET_SIZE = (2 << 15);
36 */ 36 */
37static void afc_lock(afc_client_t client) 37static void afc_lock(afc_client_t client)
38{ 38{
39 log_debug_msg("%s: Locked\n", __func__); 39 debug_info("Locked");
40 g_mutex_lock(client->mutex); 40 g_mutex_lock(client->mutex);
41} 41}
42 42
@@ -46,7 +46,7 @@ static void afc_lock(afc_client_t client)
46 */ 46 */
47static void afc_unlock(afc_client_t client) 47static void afc_unlock(afc_client_t client)
48{ 48{
49 log_debug_msg("%s: Unlocked\n", __func__); 49 debug_info("Unlocked");
50 g_mutex_unlock(client->mutex); 50 g_mutex_unlock(client->mutex);
51} 51}
52 52
@@ -155,12 +155,11 @@ static afc_error_t afc_dispatch_packet(afc_client_t client, const char *data, ui
155 if (client->afc_packet->this_length != client->afc_packet->entire_length) { 155 if (client->afc_packet->this_length != client->afc_packet->entire_length) {
156 offset = client->afc_packet->this_length - sizeof(AFCPacket); 156 offset = client->afc_packet->this_length - sizeof(AFCPacket);
157 157
158 log_debug_msg("%s: Offset: %i\n", __func__, offset); 158 debug_info("Offset: %i", offset);
159 if ((length) < (client->afc_packet->entire_length - client->afc_packet->this_length)) { 159 if ((length) < (client->afc_packet->entire_length - client->afc_packet->this_length)) {
160 log_debug_msg("%s: Length did not resemble what it was supposed", __func__); 160 debug_info("Length did not resemble what it was supposed to based on packet");
161 log_debug_msg("to based on the packet.\n"); 161 debug_info("length minus offset: %i", length - offset);
162 log_debug_msg("%s: length minus offset: %i\n", __func__, length - offset); 162 debug_info("rest of packet: %i\n", client->afc_packet->entire_length - client->afc_packet->this_length);
163 log_debug_msg("%s: rest of packet: %i\n", __func__, client->afc_packet->entire_length - client->afc_packet->this_length);
164 return AFC_E_INTERNAL_ERROR; 163 return AFC_E_INTERNAL_ERROR;
165 } 164 }
166 165
@@ -182,10 +181,10 @@ static afc_error_t afc_dispatch_packet(afc_client_t client, const char *data, ui
182 } 181 }
183 *bytes_sent += sent; 182 *bytes_sent += sent;
184 183
185 log_debug_msg("%s: sent the first now go with the second\n", __func__); 184 debug_info("sent the first now go with the second");
186 log_debug_msg("%s: Length: %i\n", __func__, length - offset); 185 debug_info("Length: %i", length - offset);
187 log_debug_msg("%s: Buffer: \n", __func__); 186 debug_info("Buffer: ");
188 log_debug_buffer(data + offset, length - offset); 187 debug_buffer(data + offset, length - offset);
189 188
190 sent = 0; 189 sent = 0;
191 iphone_device_send(client->connection, data + offset, length - offset, &sent); 190 iphone_device_send(client->connection, data + offset, length - offset, &sent);
@@ -193,11 +192,10 @@ static afc_error_t afc_dispatch_packet(afc_client_t client, const char *data, ui
193 *bytes_sent = sent; 192 *bytes_sent = sent;
194 return AFC_E_SUCCESS; 193 return AFC_E_SUCCESS;
195 } else { 194 } else {
196 log_debug_msg("%s: doin things the old way\n", __func__); 195 debug_info("doin things the old way");
197 log_debug_msg("%s: packet length = %i\n", __func__, client->afc_packet->this_length); 196 debug_info("packet length = %i", client->afc_packet->this_length);
198 197
199 log_debug_buffer((char*)client->afc_packet, sizeof(AFCPacket)); 198 debug_buffer((char*)client->afc_packet, sizeof(AFCPacket));
200 log_debug_msg("\n");
201 199
202 /* send AFC packet header */ 200 /* send AFC packet header */
203 AFCPacket_to_LE(client->afc_packet); 201 AFCPacket_to_LE(client->afc_packet);
@@ -209,10 +207,9 @@ static afc_error_t afc_dispatch_packet(afc_client_t client, const char *data, ui
209 *bytes_sent += sent; 207 *bytes_sent += sent;
210 /* send AFC packet data (if there's data to send) */ 208 /* send AFC packet data (if there's data to send) */
211 if (length > 0) { 209 if (length > 0) {
212 log_debug_msg("%s: packet data follows\n", __func__); 210 debug_info("packet data follows");
213 211
214 log_debug_buffer(data, length); 212 debug_buffer(data, length);
215 log_debug_msg("\n");
216 iphone_device_send(client->connection, data, length, &sent); 213 iphone_device_send(client->connection, data, length, &sent);
217 *bytes_sent += sent; 214 *bytes_sent += sent;
218 } 215 }
@@ -244,36 +241,36 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3
244 iphone_device_recv(client->connection, (char*)&header, sizeof(AFCPacket), bytes_recv); 241 iphone_device_recv(client->connection, (char*)&header, sizeof(AFCPacket), bytes_recv);
245 AFCPacket_from_LE(&header); 242 AFCPacket_from_LE(&header);
246 if (*bytes_recv == 0) { 243 if (*bytes_recv == 0) {
247 log_debug_msg("%s: Just didn't get enough.\n", __func__); 244 debug_info("Just didn't get enough.");
248 *dump_here = NULL; 245 *dump_here = NULL;
249 return AFC_E_MUX_ERROR; 246 return AFC_E_MUX_ERROR;
250 } else if (*bytes_recv < sizeof(AFCPacket)) { 247 } else if (*bytes_recv < sizeof(AFCPacket)) {
251 log_debug_msg("%s: Did not even get the AFCPacket header\n", __func__); 248 debug_info("Did not even get the AFCPacket header");
252 *dump_here = NULL; 249 *dump_here = NULL;
253 return AFC_E_MUX_ERROR; 250 return AFC_E_MUX_ERROR;
254 } 251 }
255 252
256 /* check if it's a valid AFC header */ 253 /* check if it's a valid AFC header */
257 if (strncmp(header.magic, AFC_MAGIC, AFC_MAGIC_LEN)) { 254 if (strncmp(header.magic, AFC_MAGIC, AFC_MAGIC_LEN)) {
258 log_debug_msg("%s: Invalid AFC packet received (magic != " AFC_MAGIC ")!\n", __func__); 255 debug_info("Invalid AFC packet received (magic != " AFC_MAGIC ")!");
259 } 256 }
260 257
261 /* check if it has the correct packet number */ 258 /* check if it has the correct packet number */
262 if (header.packet_num != client->afc_packet->packet_num) { 259 if (header.packet_num != client->afc_packet->packet_num) {
263 /* otherwise print a warning but do not abort */ 260 /* otherwise print a warning but do not abort */
264 log_debug_msg("%s: ERROR: Unexpected packet number (%lld != %lld) aborting.\n", __func__, header.packet_num, client->afc_packet->packet_num); 261 debug_info("ERROR: Unexpected packet number (%lld != %lld) aborting.", header.packet_num, client->afc_packet->packet_num);
265 *dump_here = NULL; 262 *dump_here = NULL;
266 return AFC_E_OP_HEADER_INVALID; 263 return AFC_E_OP_HEADER_INVALID;
267 } 264 }
268 265
269 /* then, read the attached packet */ 266 /* then, read the attached packet */
270 if (header.this_length < sizeof(AFCPacket)) { 267 if (header.this_length < sizeof(AFCPacket)) {
271 log_debug_msg("%s: Invalid AFCPacket header received!\n", __func__); 268 debug_info("Invalid AFCPacket header received!");
272 *dump_here = NULL; 269 *dump_here = NULL;
273 return AFC_E_OP_HEADER_INVALID; 270 return AFC_E_OP_HEADER_INVALID;
274 } else if ((header.this_length == header.entire_length) 271 } else if ((header.this_length == header.entire_length)
275 && header.entire_length == sizeof(AFCPacket)) { 272 && header.entire_length == sizeof(AFCPacket)) {
276 log_debug_msg("%s: Empty AFCPacket received!\n", __func__); 273 debug_info("Empty AFCPacket received!");
277 *dump_here = NULL; 274 *dump_here = NULL;
278 *bytes_recv = 0; 275 *bytes_recv = 0;
279 if (header.operation == AFC_OP_DATA) { 276 if (header.operation == AFC_OP_DATA) {
@@ -283,14 +280,14 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3
283 } 280 }
284 } 281 }
285 282
286 log_debug_msg("%s: received AFC packet, full len=%lld, this len=%lld, operation=0x%llx\n", __func__, header.entire_length, header.this_length, header.operation); 283 debug_info("received AFC packet, full len=%lld, this len=%lld, operation=0x%llx", header.entire_length, header.this_length, header.operation);
287 284
288 entire_len = (uint32_t)header.entire_length - sizeof(AFCPacket); 285 entire_len = (uint32_t)header.entire_length - sizeof(AFCPacket);
289 this_len = (uint32_t)header.this_length - sizeof(AFCPacket); 286 this_len = (uint32_t)header.this_length - sizeof(AFCPacket);
290 287
291 /* this is here as a check (perhaps a different upper limit is good?) */ 288 /* this is here as a check (perhaps a different upper limit is good?) */
292 if (entire_len > (uint32_t)MAXIMUM_PACKET_SIZE) { 289 if (entire_len > (uint32_t)MAXIMUM_PACKET_SIZE) {
293 fprintf(stderr, "%s: entire_len is larger than MAXIMUM_PACKET_SIZE, (%d > %d)!\n", __func__, entire_len, MAXIMUM_PACKET_SIZE); 290 fprintf(stderr, "%s: entire_len is larger than MAXIMUM_PACKET_SIZE, (%d > %d)!", __func__, entire_len, MAXIMUM_PACKET_SIZE);
294 } 291 }
295 292
296 *dump_here = (char*)malloc(entire_len); 293 *dump_here = (char*)malloc(entire_len);
@@ -299,12 +296,12 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3
299 if (*bytes_recv <= 0) { 296 if (*bytes_recv <= 0) {
300 free(*dump_here); 297 free(*dump_here);
301 *dump_here = NULL; 298 *dump_here = NULL;
302 log_debug_msg("%s: Did not get packet contents!\n", __func__); 299 debug_info("Did not get packet contents!");
303 return AFC_E_NOT_ENOUGH_DATA; 300 return AFC_E_NOT_ENOUGH_DATA;
304 } else if (*bytes_recv < this_len) { 301 } else if (*bytes_recv < this_len) {
305 free(*dump_here); 302 free(*dump_here);
306 *dump_here = NULL; 303 *dump_here = NULL;
307 log_debug_msg("%s: Could not receive this_len=%d bytes\n", __func__, this_len); 304 debug_info("Could not receive this_len=%d bytes", this_len);
308 return AFC_E_NOT_ENOUGH_DATA; 305 return AFC_E_NOT_ENOUGH_DATA;
309 } 306 }
310 } 307 }
@@ -315,13 +312,13 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3
315 while (current_count < entire_len) { 312 while (current_count < entire_len) {
316 iphone_device_recv(client->connection, (*dump_here)+current_count, entire_len - current_count, bytes_recv); 313 iphone_device_recv(client->connection, (*dump_here)+current_count, entire_len - current_count, bytes_recv);
317 if (*bytes_recv <= 0) { 314 if (*bytes_recv <= 0) {
318 log_debug_msg("%s: Error receiving data (recv returned %d)\n", __func__, *bytes_recv); 315 debug_info("Error receiving data (recv returned %d)", *bytes_recv);
319 break; 316 break;
320 } 317 }
321 current_count += *bytes_recv; 318 current_count += *bytes_recv;
322 } 319 }
323 if (current_count < entire_len) { 320 if (current_count < entire_len) {
324 log_debug_msg("%s: WARNING: could not receive full packet (read %s, size %d)\n", __func__, current_count, entire_len); 321 debug_info("WARNING: could not receive full packet (read %s, size %d)", current_count, entire_len);
325 } 322 }
326 } 323 }
327 324
@@ -329,14 +326,14 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3
329 param1 = *(uint64_t*)(*dump_here); 326 param1 = *(uint64_t*)(*dump_here);
330 } 327 }
331 328
332 log_debug_msg("%s: packet data size = %i\n", __func__, current_count); 329 debug_info("packet data size = %i", current_count);
333 log_debug_msg("%s: packet data follows\n", __func__); 330 debug_info("packet data follows");
334 log_debug_buffer(*dump_here, current_count); 331 debug_buffer(*dump_here, current_count);
335 332
336 /* check operation types */ 333 /* check operation types */
337 if (header.operation == AFC_OP_STATUS) { 334 if (header.operation == AFC_OP_STATUS) {
338 /* status response */ 335 /* status response */
339 log_debug_msg("%s: got a status response, code=%lld\n", __func__, param1); 336 debug_info("got a status response, code=%lld", param1);
340 337
341 if (param1 != AFC_E_SUCCESS) { 338 if (param1 != AFC_E_SUCCESS) {
342 /* error status */ 339 /* error status */
@@ -347,21 +344,21 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3
347 } 344 }
348 } else if (header.operation == AFC_OP_DATA) { 345 } else if (header.operation == AFC_OP_DATA) {
349 /* data response */ 346 /* data response */
350 log_debug_msg("%s: got a data response\n", __func__); 347 debug_info("got a data response");
351 } else if (header.operation == AFC_OP_FILE_OPEN_RES) { 348 } else if (header.operation == AFC_OP_FILE_OPEN_RES) {
352 /* file handle response */ 349 /* file handle response */
353 log_debug_msg("%s: got a file handle response, handle=%lld\n", __func__, param1); 350 debug_info("got a file handle response, handle=%lld", param1);
354 } else if (header.operation == AFC_OP_FILE_TELL_RES) { 351 } else if (header.operation == AFC_OP_FILE_TELL_RES) {
355 /* tell response */ 352 /* tell response */
356 log_debug_msg("%s: got a tell response, position=%lld\n", __func__, param1); 353 debug_info("got a tell response, position=%lld", param1);
357 } else { 354 } else {
358 /* unknown operation code received */ 355 /* unknown operation code received */
359 free(*dump_here); 356 free(*dump_here);
360 *dump_here = NULL; 357 *dump_here = NULL;
361 *bytes_recv = 0; 358 *bytes_recv = 0;
362 359
363 log_debug_msg("%s: WARNING: Unknown operation code received 0x%llx param1=%lld\n", __func__, header.operation, param1); 360 debug_info("WARNING: Unknown operation code received 0x%llx param1=%lld", header.operation, param1);
364 fprintf(stderr, "%s: WARNING: Unknown operation code received 0x%llx param1=%lld\n", __func__, (long long)header.operation, (long long)param1); 361 fprintf(stderr, "%s: WARNING: Unknown operation code received 0x%llx param1=%lld", __func__, (long long)header.operation, (long long)param1);
365 362
366 return AFC_E_OP_NOT_SUPPORTED; 363 return AFC_E_OP_NOT_SUPPORTED;
367 } 364 }
@@ -728,7 +725,7 @@ afc_file_open(afc_client_t client, const char *filename,
728 free(data); 725 free(data);
729 726
730 if (ret != AFC_E_SUCCESS) { 727 if (ret != AFC_E_SUCCESS) {
731 log_debug_msg("%s: Didn't receive a response to the command\n", __func__); 728 debug_info("Didn't receive a response to the command");
732 afc_unlock(client); 729 afc_unlock(client);
733 return AFC_E_NOT_ENOUGH_DATA; 730 return AFC_E_NOT_ENOUGH_DATA;
734 } 731 }
@@ -743,7 +740,7 @@ afc_file_open(afc_client_t client, const char *filename,
743 return ret; 740 return ret;
744 } 741 }
745 742
746 log_debug_msg("%s: Didn't get any further data\n", __func__); 743 debug_info("Didn't get any further data");
747 744
748 afc_unlock(client); 745 afc_unlock(client);
749 746
@@ -770,14 +767,14 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length,
770 767
771 if (!client || !client->afc_packet || !client->connection || handle == 0) 768 if (!client || !client->afc_packet || !client->connection || handle == 0)
772 return AFC_E_INVALID_ARGUMENT; 769 return AFC_E_INVALID_ARGUMENT;
773 log_debug_msg("%s: called for length %i\n", __func__, length); 770 debug_info("called for length %i", length);
774 771
775 afc_lock(client); 772 afc_lock(client);
776 773
777 // Looping here to get around the maximum amount of data that 774 // Looping here to get around the maximum amount of data that
778 // afc_receive_data can handle 775 // afc_receive_data can handle
779 while (current_count < length) { 776 while (current_count < length) {
780 log_debug_msg("%s: current count is %i but length is %i\n", __func__, current_count, length); 777 debug_info("current count is %i but length is %i", current_count, length);
781 778
782 // Send the read command 779 // Send the read command
783 AFCFilePacket *packet = (AFCFilePacket *) malloc(sizeof(AFCFilePacket)); 780 AFCFilePacket *packet = (AFCFilePacket *) malloc(sizeof(AFCFilePacket));
@@ -794,8 +791,8 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length,
794 } 791 }
795 // Receive the data 792 // Receive the data
796 ret = afc_receive_data(client, &input, &bytes_loc); 793 ret = afc_receive_data(client, &input, &bytes_loc);
797 log_debug_msg("%s: afc_receive_data returned error: %d\n", __func__, ret); 794 debug_info("afc_receive_data returned error: %d", ret);
798 log_debug_msg("%s: bytes returned: %i\n", __func__, bytes_loc); 795 debug_info("bytes returned: %i", bytes_loc);
799 if (ret != AFC_E_SUCCESS) { 796 if (ret != AFC_E_SUCCESS) {
800 afc_unlock(client); 797 afc_unlock(client);
801 return ret; 798 return ret;
@@ -808,7 +805,7 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length,
808 return ret; 805 return ret;
809 } else { 806 } else {
810 if (input) { 807 if (input) {
811 log_debug_msg("%s: %d\n", __func__, bytes_loc); 808 debug_info("%d", bytes_loc);
812 memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc); 809 memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc);
813 free(input); 810 free(input);
814 input = NULL; 811 input = NULL;
@@ -816,7 +813,7 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length,
816 } 813 }
817 } 814 }
818 } 815 }
819 log_debug_msg("%s: returning current_count as %i\n", __func__, current_count); 816 debug_info("returning current_count as %i", current_count);
820 817
821 afc_unlock(client); 818 afc_unlock(client);
822 *bytes_read = current_count; 819 *bytes_read = current_count;
@@ -849,7 +846,7 @@ afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t
849 846
850 afc_lock(client); 847 afc_lock(client);
851 848
852 log_debug_msg("%s: Write length: %i\n", __func__, length); 849 debug_info("Write length: %i", length);
853 850
854 // Divide the file into segments. 851 // Divide the file into segments.
855 for (i = 0; i < segments; i++) { 852 for (i = 0; i < segments; i++) {
@@ -909,7 +906,7 @@ afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t
909 ret = afc_receive_data(client, &acknowledgement, &bytes_loc); 906 ret = afc_receive_data(client, &acknowledgement, &bytes_loc);
910 afc_unlock(client); 907 afc_unlock(client);
911 if (ret != AFC_E_SUCCESS) { 908 if (ret != AFC_E_SUCCESS) {
912 log_debug_msg("%s: uh oh?\n", __func__); 909 debug_info("uh oh?");
913 } else { 910 } else {
914 free(acknowledgement); 911 free(acknowledgement);
915 } 912 }
@@ -933,7 +930,7 @@ afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
933 930
934 afc_lock(client); 931 afc_lock(client);
935 932
936 log_debug_msg("%s: File handle %i\n", __func__, handle); 933 debug_info("File handle %i", handle);
937 934
938 // Send command 935 // Send command
939 memcpy(buffer, &handle, sizeof(uint64_t)); 936 memcpy(buffer, &handle, sizeof(uint64_t));
@@ -981,7 +978,7 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op
981 978
982 afc_lock(client); 979 afc_lock(client);
983 980
984 log_debug_msg("%s: file handle %i\n", __func__, handle); 981 debug_info("file handle %i", handle);
985 982
986 // Send command 983 // Send command
987 memcpy(buffer, &handle, sizeof(uint64_t)); 984 memcpy(buffer, &handle, sizeof(uint64_t));
@@ -995,13 +992,13 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op
995 992
996 if (ret != AFC_E_SUCCESS) { 993 if (ret != AFC_E_SUCCESS) {
997 afc_unlock(client); 994 afc_unlock(client);
998 log_debug_msg("%s: could not send lock command\n", __func__); 995 debug_info("could not send lock command");
999 return AFC_E_UNKNOWN_ERROR; 996 return AFC_E_UNKNOWN_ERROR;
1000 } 997 }
1001 // Receive the response 998 // Receive the response
1002 ret = afc_receive_data(client, &buffer, &bytes); 999 ret = afc_receive_data(client, &buffer, &bytes);
1003 if (buffer) { 1000 if (buffer) {
1004 log_debug_buffer(buffer, bytes); 1001 debug_buffer(buffer, bytes);
1005 free(buffer); 1002 free(buffer);
1006 } 1003 }
1007 afc_unlock(client); 1004 afc_unlock(client);
@@ -1214,9 +1211,9 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c
1214 1211
1215 afc_lock(client); 1212 afc_lock(client);
1216 1213
1217 log_debug_msg("%s: link type: %lld\n", __func__, type); 1214 debug_info("link type: %lld", type);
1218 log_debug_msg("%s: target: %s, length:%d\n", __func__, target, strlen(target)); 1215 debug_info("target: %s, length:%d", target, strlen(target));
1219 log_debug_msg("%s: linkname: %s, length:%d\n", __func__, linkname, strlen(linkname)); 1216 debug_info("linkname: %s, length:%d", linkname, strlen(linkname));
1220 1217
1221 // Send command 1218 // Send command
1222 memcpy(send, &type, 8); 1219 memcpy(send, &type, 8);
diff --git a/src/InstallationProxy.c b/src/InstallationProxy.c
index 6b267c4..8b53a2d 100644
--- a/src/InstallationProxy.c
+++ b/src/InstallationProxy.c
@@ -41,7 +41,7 @@ struct instproxy_status_data {
41 */ 41 */
42static void instproxy_lock(instproxy_client_t client) 42static void instproxy_lock(instproxy_client_t client)
43{ 43{
44 log_debug_msg("InstallationProxy: Locked\n"); 44 debug_info("InstallationProxy: Locked");
45 g_mutex_lock(client->mutex); 45 g_mutex_lock(client->mutex);
46} 46}
47 47
@@ -51,7 +51,7 @@ static void instproxy_lock(instproxy_client_t client)
51 */ 51 */
52static void instproxy_unlock(instproxy_client_t client) 52static void instproxy_unlock(instproxy_client_t client)
53{ 53{
54 log_debug_msg("InstallationProxy: Unlocked\n"); 54 debug_info("InstallationProxy: Unlocked");
55 g_mutex_unlock(client->mutex); 55 g_mutex_unlock(client->mutex);
56} 56}
57 57
@@ -131,7 +131,7 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client)
131 property_list_service_client_free(client->parent); 131 property_list_service_client_free(client->parent);
132 client->parent = NULL; 132 client->parent = NULL;
133 if (client->status_updater) { 133 if (client->status_updater) {
134 log_debug_msg("joining status_updater"); 134 debug_info("joining status_updater");
135 g_thread_join(client->status_updater); 135 g_thread_join(client->status_updater);
136 } 136 }
137 if (client->mutex) { 137 if (client->mutex) {
@@ -174,7 +174,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_
174 p_apptype = plist_new_string("User"); 174 p_apptype = plist_new_string("User");
175 break; 175 break;
176 default: 176 default:
177 log_debug_msg("%s: unknown apptype %d given, using INSTPROXY_APPTYPE_USER instead\n", __func__, apptype); 177 debug_info("unknown apptype %d given, using INSTPROXY_APPTYPE_USER instead", apptype);
178 p_apptype = plist_new_string("User"); 178 p_apptype = plist_new_string("User");
179 break; 179 break;
180 } 180 }
@@ -187,7 +187,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_
187 res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict)); 187 res = instproxy_error(property_list_service_send_xml_plist(client->parent, dict));
188 plist_free(dict); 188 plist_free(dict);
189 if (res != INSTPROXY_E_SUCCESS) { 189 if (res != INSTPROXY_E_SUCCESS) {
190 log_debug_msg("%s: could not send plist\n", __func__); 190 debug_info("could not send plist");
191 goto leave_unlock; 191 goto leave_unlock;
192 } 192 }
193 193
@@ -223,7 +223,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, instproxy_apptype_
223 if (!strcmp(status, "BrowsingApplications")) { 223 if (!strcmp(status, "BrowsingApplications")) {
224 browsing = 1; 224 browsing = 1;
225 } else if (!strcmp(status, "Complete")) { 225 } else if (!strcmp(status, "Complete")) {
226 log_debug_msg("%s: Browsing applications completed\n"); 226 debug_info("Browsing applications completed");
227 res = INSTPROXY_E_SUCCESS; 227 res = INSTPROXY_E_SUCCESS;
228 } 228 }
229 free(status); 229 free(status);
@@ -264,7 +264,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
264 res = instproxy_error(property_list_service_receive_plist_with_timeout(client->parent, &dict, 30000)); 264 res = instproxy_error(property_list_service_receive_plist_with_timeout(client->parent, &dict, 30000));
265 instproxy_unlock(client); 265 instproxy_unlock(client);
266 if (res != INSTPROXY_E_SUCCESS) { 266 if (res != INSTPROXY_E_SUCCESS) {
267 log_debug_msg("%s: could not receive plist, error %d\n", __func__, res); 267 debug_info("could not receive plist, error %d", res);
268 break; 268 break;
269 } 269 }
270 if (dict) { 270 if (dict) {
@@ -279,7 +279,7 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
279 char *err_msg = NULL; 279 char *err_msg = NULL;
280 plist_get_string_val(err, &err_msg); 280 plist_get_string_val(err, &err_msg);
281 if (err_msg) { 281 if (err_msg) {
282 log_debug_msg("%s(%s): ERROR: %s\n", __func__, operation, err_msg); 282 debug_info("(%s): ERROR: %s", operation, err_msg);
283 free(err_msg); 283 free(err_msg);
284 } 284 }
285#endif 285#endif
@@ -303,9 +303,9 @@ static instproxy_error_t instproxy_perform_operation(instproxy_client_t client,
303 int percent; 303 int percent;
304 plist_get_uint_val(npercent, &val); 304 plist_get_uint_val(npercent, &val);
305 percent = val; 305 percent = val;
306 log_debug_msg("%s(%s): %s (%d%%)\n", __func__, operation, status_msg, percent); 306 debug_info("(%s): %s (%d%%)", operation, status_msg, percent);
307 } else { 307 } else {
308 log_debug_msg("%s(%s): %s\n", __func__, operation, status_msg); 308 debug_info("(%s): %s", operation, status_msg);
309 } 309 }
310#endif 310#endif
311 free(status_msg); 311 free(status_msg);
@@ -338,7 +338,7 @@ static gpointer instproxy_status_updater(gpointer arg)
338 338
339 /* cleanup */ 339 /* cleanup */
340 instproxy_lock(data->client); 340 instproxy_lock(data->client);
341 log_debug_msg("%s: done, cleaning up.\n", __func__); 341 debug_info("done, cleaning up.");
342 if (data->operation) { 342 if (data->operation) {
343 free(data->operation); 343 free(data->operation);
344 } 344 }
@@ -408,11 +408,11 @@ static instproxy_error_t instproxy_install_or_upgrade(instproxy_client_t client,
408 return INSTPROXY_E_INVALID_ARG; 408 return INSTPROXY_E_INVALID_ARG;
409 } 409 }
410 if (sinf && (plist_get_node_type(sinf) != PLIST_DATA)) { 410 if (sinf && (plist_get_node_type(sinf) != PLIST_DATA)) {
411 log_debug_msg("%s(%s): ERROR: sinf data is not a PLIST_DATA node!\n", __func__, command); 411 debug_info("(%s): ERROR: sinf data is not a PLIST_DATA node!", command);
412 return INSTPROXY_E_INVALID_ARG; 412 return INSTPROXY_E_INVALID_ARG;
413 } 413 }
414 if (metadata && (plist_get_node_type(metadata) != PLIST_DATA)) { 414 if (metadata && (plist_get_node_type(metadata) != PLIST_DATA)) {
415 log_debug_msg("%s(%s): ERROR: metadata is not a PLIST_DATA node!\n", __func__, command); 415 debug_info("(%s): ERROR: metadata is not a PLIST_DATA node!", command);
416 return INSTPROXY_E_INVALID_ARG; 416 return INSTPROXY_E_INVALID_ARG;
417 } 417 }
418 418
@@ -439,7 +439,7 @@ static instproxy_error_t instproxy_install_or_upgrade(instproxy_client_t client,
439 plist_free(dict); 439 plist_free(dict);
440 440
441 if (res != INSTPROXY_E_SUCCESS) { 441 if (res != INSTPROXY_E_SUCCESS) {
442 log_debug_msg("%s: could not send plist, error %d\n", __func__, res); 442 debug_info("could not send plist, error %d", res);
443 return res; 443 return res;
444 } 444 }
445 445
@@ -532,7 +532,7 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app
532 plist_free(dict); 532 plist_free(dict);
533 533
534 if (res != INSTPROXY_E_SUCCESS) { 534 if (res != INSTPROXY_E_SUCCESS) {
535 log_debug_msg("%s: could not send plist, error %d\n", __func__, res); 535 debug_info("could not send plist, error %d", res);
536 return res; 536 return res;
537 } 537 }
538 538
@@ -567,13 +567,13 @@ instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t *
567 plist_free(dict); 567 plist_free(dict);
568 568
569 if (res != INSTPROXY_E_SUCCESS) { 569 if (res != INSTPROXY_E_SUCCESS) {
570 log_debug_msg("%s: could not send plist, error %d\n", __func__, res); 570 debug_info("could not send plist, error %d", res);
571 goto leave_unlock; 571 goto leave_unlock;
572 } 572 }
573 573
574 res = instproxy_error(property_list_service_receive_plist(client->parent, result)); 574 res = instproxy_error(property_list_service_receive_plist(client->parent, result));
575 if (res != INSTPROXY_E_SUCCESS) { 575 if (res != INSTPROXY_E_SUCCESS) {
576 log_debug_msg("%s: could not receive plist, error %d\n", __func__, res); 576 debug_info("could not receive plist, error %d", res);
577 goto leave_unlock; 577 goto leave_unlock;
578 } 578 }
579 579
@@ -640,7 +640,7 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid
640 plist_free(dict); 640 plist_free(dict);
641 641
642 if (res != INSTPROXY_E_SUCCESS) { 642 if (res != INSTPROXY_E_SUCCESS) {
643 log_debug_msg("%s: could not send plist, error %d\n", __func__, res); 643 debug_info("could not send plist, error %d", res);
644 return res; 644 return res;
645 } 645 }
646 return instproxy_create_status_updater(client, status_cb, "Archive"); 646 return instproxy_create_status_updater(client, status_cb, "Archive");
@@ -686,7 +686,7 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid
686 plist_free(dict); 686 plist_free(dict);
687 687
688 if (res != INSTPROXY_E_SUCCESS) { 688 if (res != INSTPROXY_E_SUCCESS) {
689 log_debug_msg("%s: could not send plist, error %d\n", __func__, res); 689 debug_info("could not send plist, error %d", res);
690 return res; 690 return res;
691 } 691 }
692 return instproxy_create_status_updater(client, status_cb, "Restore"); 692 return instproxy_create_status_updater(client, status_cb, "Restore");
@@ -732,7 +732,7 @@ instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char
732 plist_free(dict); 732 plist_free(dict);
733 733
734 if (res != INSTPROXY_E_SUCCESS) { 734 if (res != INSTPROXY_E_SUCCESS) {
735 log_debug_msg("%s: could not send plist, error %d\n", __func__, res); 735 debug_info("could not send plist, error %d", res);
736 return res; 736 return res;
737 } 737 }
738 return instproxy_create_status_updater(client, status_cb, "RemoveArchive"); 738 return instproxy_create_status_updater(client, status_cb, "RemoveArchive");
diff --git a/src/MobileSync.c b/src/MobileSync.c
index ef3571a..97a1320 100644
--- a/src/MobileSync.c
+++ b/src/MobileSync.c
@@ -77,7 +77,7 @@ mobilesync_error_t mobilesync_client_new(iphone_device_t device, int dst_port,
77 /* perform handshake */ 77 /* perform handshake */
78 ret = mobilesync_error(device_link_service_version_exchange(dlclient, MSYNC_VERSION_INT1, MSYNC_VERSION_INT2)); 78 ret = mobilesync_error(device_link_service_version_exchange(dlclient, MSYNC_VERSION_INT1, MSYNC_VERSION_INT2));
79 if (ret != MOBILESYNC_E_SUCCESS) { 79 if (ret != MOBILESYNC_E_SUCCESS) {
80 log_debug_msg("%s: version exchange failed, error %d\n", __func__, ret); 80 debug_info("version exchange failed, error %d", ret);
81 mobilesync_client_free(client_loc); 81 mobilesync_client_free(client_loc);
82 return ret; 82 return ret;
83 } 83 }
@@ -116,7 +116,7 @@ mobilesync_error_t mobilesync_recv(mobilesync_client_t client, plist_t * plist)
116 char *XMLContent = NULL; 116 char *XMLContent = NULL;
117 uint32_t length = 0; 117 uint32_t length = 0;
118 plist_to_xml(*plist, &XMLContent, &length); 118 plist_to_xml(*plist, &XMLContent, &length);
119 log_debug_msg("%s: plist size: %i\nbuffer :\n%s\n", __func__, length, XMLContent); 119 debug_info("plist size: %i\nbuffer :\n%s", length, XMLContent);
120 free(XMLContent); 120 free(XMLContent);
121#endif 121#endif
122 return ret; 122 return ret;
@@ -141,7 +141,7 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
141 char *XMLContent = NULL; 141 char *XMLContent = NULL;
142 uint32_t length = 0; 142 uint32_t length = 0;
143 plist_to_xml(plist, &XMLContent, &length); 143 plist_to_xml(plist, &XMLContent, &length);
144 log_debug_msg("%s: plist size: %i\nbuffer :\n%s\n", __func__, length, XMLContent); 144 debug_info("plist size: %i\nbuffer :\n%s", length, XMLContent);
145 free(XMLContent); 145 free(XMLContent);
146#endif 146#endif
147 return mobilesync_error(device_link_service_send(client->parent, plist)); 147 return mobilesync_error(device_link_service_send(client->parent, plist));
diff --git a/src/NotificationProxy.c b/src/NotificationProxy.c
index 1b13a29..f526f70 100644
--- a/src/NotificationProxy.c
+++ b/src/NotificationProxy.c
@@ -41,7 +41,7 @@ struct np_thread {
41 */ 41 */
42static void np_lock(np_client_t client) 42static void np_lock(np_client_t client)
43{ 43{
44 log_debug_msg("NP: Locked\n"); 44 debug_info("NP: Locked");
45 g_mutex_lock(client->mutex); 45 g_mutex_lock(client->mutex);
46} 46}
47 47
@@ -51,7 +51,7 @@ static void np_lock(np_client_t client)
51 */ 51 */
52static void np_unlock(np_client_t client) 52static void np_unlock(np_client_t client)
53{ 53{
54 log_debug_msg("NP: Unlocked\n"); 54 debug_info("NP: Unlocked");
55 g_mutex_unlock(client->mutex); 55 g_mutex_unlock(client->mutex);
56} 56}
57 57
@@ -131,7 +131,7 @@ np_error_t np_client_free(np_client_t client)
131 property_list_service_client_free(client->parent); 131 property_list_service_client_free(client->parent);
132 client->parent = NULL; 132 client->parent = NULL;
133 if (client->notifier) { 133 if (client->notifier) {
134 log_debug_msg("joining np callback\n"); 134 debug_info("joining np callback");
135 g_thread_join(client->notifier); 135 g_thread_join(client->notifier);
136 } 136 }
137 if (client->mutex) { 137 if (client->mutex) {
@@ -170,7 +170,7 @@ np_error_t np_post_notification(np_client_t client, const char *notification)
170 plist_free(dict); 170 plist_free(dict);
171 171
172 if (res != NP_E_SUCCESS) { 172 if (res != NP_E_SUCCESS) {
173 log_debug_msg("%s: Error sending XML plist to device!\n", __func__); 173 debug_info("Error sending XML plist to device!");
174 } 174 }
175 175
176 np_unlock(client); 176 np_unlock(client);
@@ -198,7 +198,7 @@ np_error_t np_observe_notification( np_client_t client, const char *notification
198 198
199 np_error_t res = np_error(property_list_service_send_xml_plist(client->parent, dict)); 199 np_error_t res = np_error(property_list_service_send_xml_plist(client->parent, dict));
200 if (res != NP_E_SUCCESS) { 200 if (res != NP_E_SUCCESS) {
201 log_debug_msg("%s: Error sending XML plist to device!\n", __func__); 201 debug_info("Error sending XML plist to device!");
202 } 202 }
203 plist_free(dict); 203 plist_free(dict);
204 204
@@ -266,7 +266,7 @@ static int np_get_notification(np_client_t client, char **notification)
266 266
267 property_list_service_receive_plist_with_timeout(client->parent, &dict, 500); 267 property_list_service_receive_plist_with_timeout(client->parent, &dict, 500);
268 if (!dict) { 268 if (!dict) {
269 log_debug_msg("NotificationProxy: no notification received!\n"); 269 debug_info("NotificationProxy: no notification received!");
270 res = 0; 270 res = 0;
271 } else { 271 } else {
272 char *cmd_value = NULL; 272 char *cmd_value = NULL;
@@ -287,14 +287,14 @@ static int np_get_notification(np_client_t client, char **notification)
287 res = -2; 287 res = -2;
288 if (name_value_node && name_value) { 288 if (name_value_node && name_value) {
289 *notification = name_value; 289 *notification = name_value;
290 log_debug_msg("%s: got notification %s\n", __func__, name_value); 290 debug_info("got notification %s\n", __func__, name_value);
291 res = 0; 291 res = 0;
292 } 292 }
293 } else if (cmd_value && !strcmp(cmd_value, "ProxyDeath")) { 293 } else if (cmd_value && !strcmp(cmd_value, "ProxyDeath")) {
294 log_debug_msg("%s: ERROR: NotificationProxy died!\n", __func__); 294 debug_info("ERROR: NotificationProxy died!");
295 res = -1; 295 res = -1;
296 } else if (cmd_value) { 296 } else if (cmd_value) {
297 log_debug_msg("%d: unknown NotificationProxy command '%s' received!\n", __func__); 297 debug_info("unknown NotificationProxy command '%s' received!", cmd_value);
298 res = -1; 298 res = -1;
299 } else { 299 } else {
300 res = -2; 300 res = -2;
@@ -321,7 +321,7 @@ gpointer np_notifier( gpointer arg )
321 321
322 if (!npt) return NULL; 322 if (!npt) return NULL;
323 323
324 log_debug_msg("%s: starting callback.\n", __func__); 324 debug_info("starting callback.");
325 while (npt->client->parent) { 325 while (npt->client->parent) {
326 np_get_notification(npt->client, &notification); 326 np_get_notification(npt->client, &notification);
327 if (notification) { 327 if (notification) {
@@ -364,7 +364,7 @@ np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb
364 364
365 np_lock(client); 365 np_lock(client);
366 if (client->notifier) { 366 if (client->notifier) {
367 log_debug_msg("%s: callback already set, removing\n"); 367 debug_info("callback already set, removing\n");
368 property_list_service_client_t parent = client->parent; 368 property_list_service_client_t parent = client->parent;
369 client->parent = NULL; 369 client->parent = NULL;
370 g_thread_join(client->notifier); 370 g_thread_join(client->notifier);
@@ -384,7 +384,7 @@ np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb
384 } 384 }
385 } 385 }
386 } else { 386 } else {
387 log_debug_msg("%s: no callback set\n", __func__); 387 debug_info("no callback set");
388 } 388 }
389 np_unlock(client); 389 np_unlock(client);
390 390
diff --git a/src/SBServices.c b/src/SBServices.c
index 2b65785..9589ec2 100644
--- a/src/SBServices.c
+++ b/src/SBServices.c
@@ -35,7 +35,7 @@
35 */ 35 */
36static void sbs_lock(sbservices_client_t client) 36static void sbs_lock(sbservices_client_t client)
37{ 37{
38 log_debug_msg("SBServices: Locked\n"); 38 debug_info("SBServices: Locked");
39 g_mutex_lock(client->mutex); 39 g_mutex_lock(client->mutex);
40} 40}
41 41
@@ -45,7 +45,7 @@ static void sbs_lock(sbservices_client_t client)
45 */ 45 */
46static void sbs_unlock(sbservices_client_t client) 46static void sbs_unlock(sbservices_client_t client)
47{ 47{
48 log_debug_msg("SBServices: Unlocked\n"); 48 debug_info("SBServices: Unlocked");
49 g_mutex_unlock(client->mutex); 49 g_mutex_unlock(client->mutex);
50} 50}
51 51
@@ -99,7 +99,7 @@ sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t
99 sbs_lock(client); 99 sbs_lock(client);
100 100
101 if (property_list_service_send_binary_plist(client->parent, dict) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 101 if (property_list_service_send_binary_plist(client->parent, dict) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
102 log_debug_msg("%s: could not send plist\n", __func__); 102 debug_info("could not send plist");
103 goto leave_unlock; 103 goto leave_unlock;
104 } 104 }
105 plist_free(dict); 105 plist_free(dict);
@@ -108,7 +108,7 @@ sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t
108 if (property_list_service_receive_plist(client->parent, state) == PROPERTY_LIST_SERVICE_E_SUCCESS) { 108 if (property_list_service_receive_plist(client->parent, state) == PROPERTY_LIST_SERVICE_E_SUCCESS) {
109 res = SBSERVICES_E_SUCCESS; 109 res = SBSERVICES_E_SUCCESS;
110 } else { 110 } else {
111 log_debug_msg("%s: could not get icon state!\n", __func__); 111 debug_info("could not get icon state!");
112 if (*state) { 112 if (*state) {
113 plist_free(*state); 113 plist_free(*state);
114 *state = NULL; 114 *state = NULL;
@@ -137,7 +137,7 @@ sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t
137 sbs_lock(client); 137 sbs_lock(client);
138 138
139 if (property_list_service_send_binary_plist(client->parent, dict) != IPHONE_E_SUCCESS) { 139 if (property_list_service_send_binary_plist(client->parent, dict) != IPHONE_E_SUCCESS) {
140 log_debug_msg("%s: could not send plist\n", __func__); 140 debug_info("could not send plist");
141 goto leave_unlock; 141 goto leave_unlock;
142 } 142 }
143 // NO RESPONSE 143 // NO RESPONSE
@@ -164,7 +164,7 @@ sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const
164 sbs_lock(client); 164 sbs_lock(client);
165 165
166 if (property_list_service_send_binary_plist(client->parent, dict) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 166 if (property_list_service_send_binary_plist(client->parent, dict) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
167 log_debug_msg("%s: could not send plist\n", __func__); 167 debug_info("could not send plist");
168 goto leave_unlock; 168 goto leave_unlock;
169 } 169 }
170 plist_free(dict); 170 plist_free(dict);
diff --git a/src/debug.c b/src/debug.c
index 78f3a17..1f9aff1 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * debug.c 2 * debug.c
3 * contains utilitary methos for logging and debugging 3 * contains utilitary functions for debugging
4 * 4 *
5 * Copyright (c) 2008 Jonathan Beck All Rights Reserved. 5 * Copyright (c) 2008 Jonathan Beck All Rights Reserved.
6 * 6 *
@@ -18,14 +18,18 @@
18 * License along with this library; if not, write to the Free Software 18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 20 */
21
21#include <stdarg.h> 22#include <stdarg.h>
23#define _GNU_SOURCE 1
24#define __USE_GNU 1
22#include <stdio.h> 25#include <stdio.h>
23#include <stdint.h> 26#include <stdint.h>
27#include <stdlib.h>
24 28
25#include "debug.h" 29#include "debug.h"
26#include "libiphone/libiphone.h" 30#include "libiphone/libiphone.h"
27 31
28int toto_debug = 0; 32int debug_level = 0;
29 33
30/** 34/**
31 * Sets the level of debugging. Currently the only acceptable values are 0 and 35 * Sets the level of debugging. Currently the only acceptable values are 0 and
@@ -35,33 +39,63 @@ int toto_debug = 0;
35 */ 39 */
36void iphone_set_debug_level(int level) 40void iphone_set_debug_level(int level)
37{ 41{
38 toto_debug = level; 42 debug_level = level;
39} 43}
40 44
41void log_debug_msg(const char *format, ...) 45static void debug_print_line(const char *func, const char *file, int line, const char *buffer)
42{ 46{
43#ifndef STRIP_DEBUG_CODE 47 char *str_time = NULL;
48 char *header = NULL;
49 time_t the_time;
50
51 time(&the_time);
52 str_time = g_new0 (gchar, 255);
53 strftime(str_time, 254, "%H:%M:%S", localtime (&the_time));
54
55 /* generate header text */
56 asprintf(&header, "%s %s %s:%d", str_time, file, func, line);
57 free (str_time);
58
59 /* always in light green */
60 printf ("%s\n", header);
61
62 /* different colors according to the severity */
63 printf ("%s\n", buffer);
64
65 /* flush this output, as we need to debug */
66 fflush (stdout);
67
68 free (header);
69}
44 70
71inline void debug_info_real(const char *func, const char *file, int line, const char *format, ...)
72{
73#ifndef STRIP_DEBUG_CODE
45 va_list args; 74 va_list args;
46 /* run the real fprintf */ 75 char *buffer = NULL;
47 va_start(args, format);
48 76
49 if (toto_debug) 77 if (!debug_level)
50 vfprintf(stderr, format, args); 78 return;
51 79
80 /* run the real fprintf */
81 va_start(args, format);
82 vasprintf(&buffer, format, args);
52 va_end(args); 83 va_end(args);
53 84
85 debug_print_line(func, file, line, buffer);
86
87 free(buffer);
54#endif 88#endif
55} 89}
56 90
57inline void log_debug_buffer(const char *data, const int length) 91inline void debug_buffer(const char *data, const int length)
58{ 92{
59#ifndef STRIP_DEBUG_CODE 93#ifndef STRIP_DEBUG_CODE
60 int i; 94 int i;
61 int j; 95 int j;
62 unsigned char c; 96 unsigned char c;
63 97
64 if (toto_debug) { 98 if (debug_level) {
65 for (i = 0; i < length; i += 16) { 99 for (i = 0; i < length; i += 16) {
66 fprintf(stderr, "%04x: ", i); 100 fprintf(stderr, "%04x: ", i);
67 for (j = 0; j < 16; j++) { 101 for (j = 0; j < 16; j++) {
@@ -89,16 +123,14 @@ inline void log_debug_buffer(const char *data, const int length)
89#endif 123#endif
90} 124}
91 125
92inline void dump_debug_buffer(const char *file, const char *data, const int length) 126inline void debug_buffer_to_file(const char *file, const char *data, const int length)
93{ 127{
94#ifndef STRIP_DEBUG_CODE 128#ifndef STRIP_DEBUG_CODE
95 /* run the real fprintf */ 129 if (debug_level) {
96 if (toto_debug) { 130 FILE *f = fopen(file, "w+");
97 FILE *my_ssl_packet = fopen(file, "w+"); 131 fwrite(data, 1, length, f);
98 fwrite(data, 1, length, my_ssl_packet); 132 fflush(f);
99 fflush(my_ssl_packet); 133 fclose(f);
100 fprintf(stderr, "%s: Wrote SSL packet to drive, too.\n", __func__);
101 fclose(my_ssl_packet);
102 } 134 }
103#endif 135#endif
104} 136}
diff --git a/src/debug.h b/src/debug.h
index 398508e..f99089d 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * debug.h 2 * debug.h
3 * contains utilitary methos for logging and debugging 3 * contains utilitary functions for debugging
4 * 4 *
5 * Copyright (c) 2008 Jonathan Beck All Rights Reserved. 5 * Copyright (c) 2008 Jonathan Beck All Rights Reserved.
6 * 6 *
@@ -24,8 +24,20 @@
24 24
25#include <glib.h> 25#include <glib.h>
26 26
27G_GNUC_INTERNAL inline void log_debug_msg(const char *format, ...); 27#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && !defined(STRIP_DEBUG_CODE)
28G_GNUC_INTERNAL inline void log_debug_buffer(const char *data, const int length); 28#define debug_info(...) debug_info_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
29G_GNUC_INTERNAL inline void dump_debug_buffer(const char *file, const char *data, const int length); 29#elif defined(__GNUC__) && __GNUC__ >= 3 && !defined(STRIP_DEBUG_CODE)
30#define debug_info(...) debug_info_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
31#else
32#define debug_info(...)
33#endif
34
35G_GNUC_INTERNAL inline void debug_info_real(const char *func,
36 const char *file,
37 int line,
38 const char *format, ...);
39
40G_GNUC_INTERNAL inline void debug_buffer(const char *data, const int length);
41G_GNUC_INTERNAL inline void debug_buffer_to_file(const char *file, const char *data, const int length);
30 42
31#endif 43#endif
diff --git a/src/device_link_service.c b/src/device_link_service.c
index b1106fe..e1155a5 100644
--- a/src/device_link_service.c
+++ b/src/device_link_service.c
@@ -149,13 +149,13 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser
149 149
150 /* receive DLMessageVersionExchange from device */ 150 /* receive DLMessageVersionExchange from device */
151 if (property_list_service_receive_plist(client->parent, &array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 151 if (property_list_service_receive_plist(client->parent, &array) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
152 log_debug_msg("%s: Did not receive initial message from device!\n", __func__); 152 debug_info("Did not receive initial message from device!");
153 err = DEVICE_LINK_SERVICE_E_MUX_ERROR; 153 err = DEVICE_LINK_SERVICE_E_MUX_ERROR;
154 goto leave; 154 goto leave;
155 } 155 }
156 msg = device_link_service_get_message(array); 156 msg = device_link_service_get_message(array);
157 if (!msg || strcmp(msg, "DLMessageVersionExchange")) { 157 if (!msg || strcmp(msg, "DLMessageVersionExchange")) {
158 log_debug_msg("%s: Did not receive DLMessageVersionExchange from device!\n", __func__); 158 debug_info("Did not receive DLMessageVersionExchange from device!");
159 err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; 159 err = DEVICE_LINK_SERVICE_E_PLIST_ERROR;
160 goto leave; 160 goto leave;
161 } 161 }
@@ -164,7 +164,7 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser
164 164
165 /* get major and minor version number */ 165 /* get major and minor version number */
166 if (plist_array_get_size(array) < 3) { 166 if (plist_array_get_size(array) < 3) {
167 log_debug_msg("%s: DLMessageVersionExchange has unexpected format!\n", __func__); 167 debug_info("DLMessageVersionExchange has unexpected format!");
168 err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; 168 err = DEVICE_LINK_SERVICE_E_PLIST_ERROR;
169 goto leave; 169 goto leave;
170 } 170 }
@@ -179,11 +179,11 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser
179 plist_get_uint_val(min, &vminor); 179 plist_get_uint_val(min, &vminor);
180 } 180 }
181 if (vmajor > version_major) { 181 if (vmajor > version_major) {
182 log_debug_msg("%s: Version mismatch: device=(%lld,%lld) > expected=(%lld,%lld)\n", __func__, vmajor, vminor, version_major, version_minor); 182 debug_info("Version mismatch: device=(%lld,%lld) > expected=(%lld,%lld)", vmajor, vminor, version_major, version_minor);
183 err = DEVICE_LINK_SERVICE_E_BAD_VERSION; 183 err = DEVICE_LINK_SERVICE_E_BAD_VERSION;
184 goto leave; 184 goto leave;
185 } else if ((vmajor == version_major) && (vminor > version_minor)) { 185 } else if ((vmajor == version_major) && (vminor > version_minor)) {
186 log_debug_msg("%s: WARNING: Version mismatch: device=(%lld,%lld) > expected=(%lld,%lld)\n", __func__, vmajor, vminor, version_major, version_minor); 186 debug_info("WARNING: Version mismatch: device=(%lld,%lld) > expected=(%lld,%lld)", vmajor, vminor, version_major, version_minor);
187 err = DEVICE_LINK_SERVICE_E_BAD_VERSION; 187 err = DEVICE_LINK_SERVICE_E_BAD_VERSION;
188 goto leave; 188 goto leave;
189 } 189 }
@@ -194,7 +194,7 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser
194 plist_array_append_item(array, plist_new_string("DLMessageVersionExchange")); 194 plist_array_append_item(array, plist_new_string("DLMessageVersionExchange"));
195 plist_array_append_item(array, plist_new_string("DLVersionsOk")); 195 plist_array_append_item(array, plist_new_string("DLVersionsOk"));
196 if (property_list_service_send_binary_plist(client->parent, array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 196 if (property_list_service_send_binary_plist(client->parent, array) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
197 log_debug_msg("%s: Error when sending DLVersionsOk", __func__); 197 debug_info("Error when sending DLVersionsOk");
198 err = DEVICE_LINK_SERVICE_E_MUX_ERROR; 198 err = DEVICE_LINK_SERVICE_E_MUX_ERROR;
199 goto leave; 199 goto leave;
200 } 200 }
@@ -203,13 +203,13 @@ device_link_service_error_t device_link_service_version_exchange(device_link_ser
203 /* receive DeviceReady message */ 203 /* receive DeviceReady message */
204 array = NULL; 204 array = NULL;
205 if (property_list_service_receive_plist(client->parent, &array) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 205 if (property_list_service_receive_plist(client->parent, &array) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
206 log_debug_msg("%s: Error when receiving DLMessageDeviceReady!\n", __func__); 206 debug_info("Error when receiving DLMessageDeviceReady!");
207 err = DEVICE_LINK_SERVICE_E_MUX_ERROR; 207 err = DEVICE_LINK_SERVICE_E_MUX_ERROR;
208 goto leave; 208 goto leave;
209 } 209 }
210 msg = device_link_service_get_message(array); 210 msg = device_link_service_get_message(array);
211 if (!msg || strcmp(msg, "DLMessageDeviceReady")) { 211 if (!msg || strcmp(msg, "DLMessageDeviceReady")) {
212 log_debug_msg("%s: Did not get DLMessageDeviceReady!\n", __func__); 212 debug_info("Did not get DLMessageDeviceReady!");
213 err = DEVICE_LINK_SERVICE_E_PLIST_ERROR; 213 err = DEVICE_LINK_SERVICE_E_PLIST_ERROR;
214 goto leave; 214 goto leave;
215 } 215 }
diff --git a/src/iphone.c b/src/iphone.c
index 7b21bb5..ce90299 100644
--- a/src/iphone.c
+++ b/src/iphone.c
@@ -60,7 +60,7 @@ iphone_error_t iphone_event_subscribe(iphone_event_cb_t callback, void *user_dat
60 int res = usbmuxd_subscribe(usbmux_event_cb, user_data); 60 int res = usbmuxd_subscribe(usbmux_event_cb, user_data);
61 if (res != 0) { 61 if (res != 0) {
62 event_cb = NULL; 62 event_cb = NULL;
63 log_debug_msg("%s: Error %d when subscribing usbmux event callback!\n", __func__, res); 63 debug_info("Error %d when subscribing usbmux event callback!", res);
64 return IPHONE_E_UNKNOWN_ERROR; 64 return IPHONE_E_UNKNOWN_ERROR;
65 } 65 }
66 return IPHONE_E_SUCCESS; 66 return IPHONE_E_SUCCESS;
@@ -77,7 +77,7 @@ iphone_error_t iphone_event_unsubscribe()
77 event_cb = NULL; 77 event_cb = NULL;
78 int res = usbmuxd_unsubscribe(); 78 int res = usbmuxd_unsubscribe();
79 if (res != 0) { 79 if (res != 0) {
80 log_debug_msg("%s: Error %d when unsubscribing usbmux event callback!\n", __func__, res); 80 debug_info("Error %d when unsubscribing usbmux event callback!", res);
81 return IPHONE_E_UNKNOWN_ERROR; 81 return IPHONE_E_UNKNOWN_ERROR;
82 } 82 }
83 return IPHONE_E_SUCCESS; 83 return IPHONE_E_SUCCESS;
@@ -100,7 +100,7 @@ iphone_error_t iphone_get_device_list(char ***devices, int *count)
100 *count = 0; 100 *count = 0;
101 101
102 if (usbmuxd_get_device_list(&dev_list) < 0) { 102 if (usbmuxd_get_device_list(&dev_list) < 0) {
103 log_debug_msg("%s: ERROR: usbmuxd is not running!\n", __func__); 103 debug_info("ERROR: usbmuxd is not running!\n", __func__);
104 return IPHONE_E_NO_DEVICE; 104 return IPHONE_E_NO_DEVICE;
105 } 105 }
106 106
@@ -216,7 +216,7 @@ iphone_error_t iphone_device_connect(iphone_device_t device, uint16_t dst_port,
216 if (device->conn_type == CONNECTION_USBMUXD) { 216 if (device->conn_type == CONNECTION_USBMUXD) {
217 int sfd = usbmuxd_connect((uint32_t)(device->conn_data), dst_port); 217 int sfd = usbmuxd_connect((uint32_t)(device->conn_data), dst_port);
218 if (sfd < 0) { 218 if (sfd < 0) {
219 log_debug_msg("%s: ERROR: Connecting to usbmuxd failed: %d (%s)\n", __func__, sfd, strerror(-sfd)); 219 debug_info("ERROR: Connecting to usbmuxd failed: %d (%s)", sfd, strerror(-sfd));
220 return IPHONE_E_UNKNOWN_ERROR; 220 return IPHONE_E_UNKNOWN_ERROR;
221 } 221 }
222 iphone_connection_t new_connection = (iphone_connection_t)malloc(sizeof(struct iphone_connection_int)); 222 iphone_connection_t new_connection = (iphone_connection_t)malloc(sizeof(struct iphone_connection_int));
@@ -225,7 +225,7 @@ iphone_error_t iphone_device_connect(iphone_device_t device, uint16_t dst_port,
225 *connection = new_connection; 225 *connection = new_connection;
226 return IPHONE_E_SUCCESS; 226 return IPHONE_E_SUCCESS;
227 } else { 227 } else {
228 log_debug_msg("%s: Unknown connection type %d\n", __func__, device->conn_type); 228 debug_info("Unknown connection type %d", device->conn_type);
229 } 229 }
230 230
231 return IPHONE_E_UNKNOWN_ERROR; 231 return IPHONE_E_UNKNOWN_ERROR;
@@ -248,7 +248,7 @@ iphone_error_t iphone_device_disconnect(iphone_connection_t connection)
248 usbmuxd_disconnect((int)(connection->data)); 248 usbmuxd_disconnect((int)(connection->data));
249 result = IPHONE_E_SUCCESS; 249 result = IPHONE_E_SUCCESS;
250 } else { 250 } else {
251 log_debug_msg("%s: Unknown connection type %d\n", __func__, connection->type); 251 debug_info("Unknown connection type %d", connection->type);
252 } 252 }
253 free(connection); 253 free(connection);
254 return result; 254 return result;
@@ -274,12 +274,12 @@ iphone_error_t iphone_device_send(iphone_connection_t connection, const char *da
274 if (connection->type == CONNECTION_USBMUXD) { 274 if (connection->type == CONNECTION_USBMUXD) {
275 int res = usbmuxd_send((int)(connection->data), data, len, sent_bytes); 275 int res = usbmuxd_send((int)(connection->data), data, len, sent_bytes);
276 if (res < 0) { 276 if (res < 0) {
277 log_debug_msg("%s: ERROR: usbmuxd_send returned %d (%s)\n", __func__, res, strerror(-res)); 277 debug_info("ERROR: usbmuxd_send returned %d (%s)", res, strerror(-res));
278 return IPHONE_E_UNKNOWN_ERROR; 278 return IPHONE_E_UNKNOWN_ERROR;
279 } 279 }
280 return IPHONE_E_SUCCESS; 280 return IPHONE_E_SUCCESS;
281 } else { 281 } else {
282 log_debug_msg("%s: Unknown connection type %d\n", __func__, connection->type); 282 debug_info("Unknown connection type %d", connection->type);
283 } 283 }
284 return IPHONE_E_UNKNOWN_ERROR; 284 return IPHONE_E_UNKNOWN_ERROR;
285} 285}
@@ -308,12 +308,12 @@ iphone_error_t iphone_device_recv_timeout(iphone_connection_t connection, char *
308 if (connection->type == CONNECTION_USBMUXD) { 308 if (connection->type == CONNECTION_USBMUXD) {
309 int res = usbmuxd_recv_timeout((int)(connection->data), data, len, recv_bytes, timeout); 309 int res = usbmuxd_recv_timeout((int)(connection->data), data, len, recv_bytes, timeout);
310 if (res < 0) { 310 if (res < 0) {
311 log_debug_msg("%s: ERROR: usbmuxd_recv_timeout returned %d (%s)\n", __func__, res, strerror(-res)); 311 debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", res, strerror(-res));
312 return IPHONE_E_UNKNOWN_ERROR; 312 return IPHONE_E_UNKNOWN_ERROR;
313 } 313 }
314 return IPHONE_E_SUCCESS; 314 return IPHONE_E_SUCCESS;
315 } else { 315 } else {
316 log_debug_msg("%s: Unknown connection type %d\n", __func__, connection->type); 316 debug_info("Unknown connection type %d", connection->type);
317 } 317 }
318 return IPHONE_E_UNKNOWN_ERROR; 318 return IPHONE_E_UNKNOWN_ERROR;
319} 319}
@@ -340,13 +340,13 @@ iphone_error_t iphone_device_recv(iphone_connection_t connection, char *data, ui
340 if (connection->type == CONNECTION_USBMUXD) { 340 if (connection->type == CONNECTION_USBMUXD) {
341 int res = usbmuxd_recv((int)(connection->data), data, len, recv_bytes); 341 int res = usbmuxd_recv((int)(connection->data), data, len, recv_bytes);
342 if (res < 0) { 342 if (res < 0) {
343 log_debug_msg("%s: ERROR: usbmuxd_recv returned %d (%s)\n", __func__, res, strerror(-res)); 343 debug_info("ERROR: usbmuxd_recv returned %d (%s)", res, strerror(-res));
344 return IPHONE_E_UNKNOWN_ERROR; 344 return IPHONE_E_UNKNOWN_ERROR;
345 } 345 }
346 346
347 return IPHONE_E_SUCCESS; 347 return IPHONE_E_SUCCESS;
348 } else { 348 } else {
349 log_debug_msg("%s: Unknown connection type %d\n", __func__, connection->type); 349 debug_info("Unknown connection type %d", connection->type);
350 } 350 }
351 return IPHONE_E_UNKNOWN_ERROR; 351 return IPHONE_E_UNKNOWN_ERROR;
352} 352}
@@ -360,7 +360,7 @@ iphone_error_t iphone_device_get_handle(iphone_device_t device, uint32_t *handle
360 *handle = (uint32_t)device->conn_data; 360 *handle = (uint32_t)device->conn_data;
361 return IPHONE_E_SUCCESS; 361 return IPHONE_E_SUCCESS;
362 } else { 362 } else {
363 log_debug_msg("%s: Unknown connection type %d\n", __func__, device->conn_type); 363 debug_info("Unknown connection type %d", device->conn_type);
364 } 364 }
365 return IPHONE_E_UNKNOWN_ERROR; 365 return IPHONE_E_UNKNOWN_ERROR;
366} 366}
diff --git a/src/lockdown.c b/src/lockdown.c
index 5e0f579..7609426 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -99,7 +99,7 @@ static int lockdown_check_result(plist_t dict, const char *query_match)
99 } else if (!strcmp(result_value, "Failure")) { 99 } else if (!strcmp(result_value, "Failure")) {
100 ret = RESULT_FAILURE; 100 ret = RESULT_FAILURE;
101 } else { 101 } else {
102 log_debug_msg("%s: ERROR: unknown result value '%s'\n", __func__, result_value); 102 debug_info("ERROR: unknown result value '%s'", result_value);
103 } 103 }
104 } 104 }
105 if (result_value) 105 if (result_value)
@@ -136,9 +136,9 @@ static ssize_t lockdownd_ssl_write(gnutls_transport_ptr_t transport, char *buffe
136 uint32_t bytes = 0; 136 uint32_t bytes = 0;
137 lockdownd_client_t client; 137 lockdownd_client_t client;
138 client = (lockdownd_client_t) transport; 138 client = (lockdownd_client_t) transport;
139 log_debug_msg("%s: pre-send length = %zi\n", __func__, length); 139 debug_info("pre-send length = %zi", length);
140 iphone_device_send(property_list_service_get_connection(client->parent), buffer, length, &bytes); 140 iphone_device_send(property_list_service_get_connection(client->parent), buffer, length, &bytes);
141 log_debug_msg("%s: post-send sent %i bytes\n", __func__, bytes); 141 debug_info("post-send sent %i bytes", bytes);
142 return bytes; 142 return bytes;
143} 143}
144 144
@@ -160,17 +160,17 @@ static ssize_t lockdownd_ssl_read(gnutls_transport_ptr_t transport, char *buffer
160 client = (lockdownd_client_t) transport; 160 client = (lockdownd_client_t) transport;
161 char *recv_buffer; 161 char *recv_buffer;
162 162
163 log_debug_msg("%s: pre-read client wants %zi bytes\n", __func__, length); 163 debug_info("pre-read client wants %zi bytes", length);
164 164
165 recv_buffer = (char *) malloc(sizeof(char) * this_len); 165 recv_buffer = (char *) malloc(sizeof(char) * this_len);
166 166
167 /* repeat until we have the full data or an error occurs */ 167 /* repeat until we have the full data or an error occurs */
168 do { 168 do {
169 if ((res = iphone_device_recv(property_list_service_get_connection(client->parent), recv_buffer, this_len, (uint32_t*)&bytes)) != LOCKDOWN_E_SUCCESS) { 169 if ((res = iphone_device_recv(property_list_service_get_connection(client->parent), recv_buffer, this_len, (uint32_t*)&bytes)) != LOCKDOWN_E_SUCCESS) {
170 log_debug_msg("%s: ERROR: iphone_device_recv returned %d\n", __func__, res); 170 debug_info("ERROR: iphone_device_recv returned %d", res);
171 return res; 171 return res;
172 } 172 }
173 log_debug_msg("%s: post-read we got %i bytes\n", __func__, bytes); 173 debug_info("post-read we got %i bytes", bytes);
174 174
175 // increase read count 175 // increase read count
176 tbytes += bytes; 176 tbytes += bytes;
@@ -184,7 +184,7 @@ static ssize_t lockdownd_ssl_read(gnutls_transport_ptr_t transport, char *buffer
184 } 184 }
185 185
186 this_len = length - tbytes; 186 this_len = length - tbytes;
187 log_debug_msg("%s: re-read trying to read missing %i bytes\n", __func__, this_len); 187 debug_info("re-read trying to read missing %i bytes", this_len);
188 } while (tbytes < length); 188 } while (tbytes < length);
189 189
190 if (recv_buffer) { 190 if (recv_buffer) {
@@ -207,7 +207,7 @@ static lockdownd_error_t lockdownd_ssl_start_session(lockdownd_client_t client)
207 uint32_t return_me = 0; 207 uint32_t return_me = 0;
208 208
209 // Set up GnuTLS... 209 // Set up GnuTLS...
210 log_debug_msg("%s: enabling SSL mode\n", __func__); 210 debug_info("enabling SSL mode");
211 errno = 0; 211 errno = 0;
212 gnutls_global_init(); 212 gnutls_global_init();
213 gnutls_certificate_allocate_credentials(&client->ssl_certificate); 213 gnutls_certificate_allocate_credentials(&client->ssl_certificate);
@@ -228,26 +228,26 @@ static lockdownd_error_t lockdownd_ssl_start_session(lockdownd_client_t client)
228 } 228 }
229 gnutls_credentials_set(client->ssl_session, GNUTLS_CRD_CERTIFICATE, client->ssl_certificate); // this part is killing me. 229 gnutls_credentials_set(client->ssl_session, GNUTLS_CRD_CERTIFICATE, client->ssl_certificate); // this part is killing me.
230 230
231 log_debug_msg("%s: GnuTLS step 1...\n", __func__); 231 debug_info("GnuTLS step 1...");
232 gnutls_transport_set_ptr(client->ssl_session, (gnutls_transport_ptr_t) client); 232 gnutls_transport_set_ptr(client->ssl_session, (gnutls_transport_ptr_t) client);
233 log_debug_msg("%s: GnuTLS step 2...\n", __func__); 233 debug_info("GnuTLS step 2...");
234 gnutls_transport_set_push_function(client->ssl_session, (gnutls_push_func) & lockdownd_ssl_write); 234 gnutls_transport_set_push_function(client->ssl_session, (gnutls_push_func) & lockdownd_ssl_write);
235 log_debug_msg("%s: GnuTLS step 3...\n", __func__); 235 debug_info("GnuTLS step 3...");
236 gnutls_transport_set_pull_function(client->ssl_session, (gnutls_pull_func) & lockdownd_ssl_read); 236 gnutls_transport_set_pull_function(client->ssl_session, (gnutls_pull_func) & lockdownd_ssl_read);
237 log_debug_msg("%s: GnuTLS step 4 -- now handshaking...\n", __func__); 237 debug_info("GnuTLS step 4 -- now handshaking...");
238 if (errno) 238 if (errno)
239 log_debug_msg("%s: WARN: errno says %s before handshake!\n", __func__, strerror(errno)); 239 debug_info("WARN: errno says %s before handshake!", strerror(errno));
240 return_me = gnutls_handshake(client->ssl_session); 240 return_me = gnutls_handshake(client->ssl_session);
241 log_debug_msg("%s: GnuTLS handshake done...\n", __func__); 241 debug_info("GnuTLS handshake done...");
242 242
243 if (return_me != GNUTLS_E_SUCCESS) { 243 if (return_me != GNUTLS_E_SUCCESS) {
244 log_debug_msg("%s: GnuTLS reported something wrong.\n", __func__); 244 debug_info("GnuTLS reported something wrong.");
245 gnutls_perror(return_me); 245 gnutls_perror(return_me);
246 log_debug_msg("%s: oh.. errno says %s\n", __func__, strerror(errno)); 246 debug_info("oh.. errno says %s", strerror(errno));
247 } else { 247 } else {
248 client->ssl_enabled = 1; 248 client->ssl_enabled = 1;
249 ret = LOCKDOWN_E_SUCCESS; 249 ret = LOCKDOWN_E_SUCCESS;
250 log_debug_msg("%s: SSL mode enabled\n", __func__); 250 debug_info("SSL mode enabled");
251 } 251 }
252 252
253 return ret; 253 return ret;
@@ -264,13 +264,13 @@ static lockdownd_error_t lockdownd_ssl_start_session(lockdownd_client_t client)
264static lockdownd_error_t lockdownd_ssl_stop_session(lockdownd_client_t client) 264static lockdownd_error_t lockdownd_ssl_stop_session(lockdownd_client_t client)
265{ 265{
266 if (!client) { 266 if (!client) {
267 log_debug_msg("%s: invalid argument!\n", __func__); 267 debug_info("invalid argument!");
268 return LOCKDOWN_E_INVALID_ARG; 268 return LOCKDOWN_E_INVALID_ARG;
269 } 269 }
270 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; 270 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
271 271
272 if (client->ssl_enabled) { 272 if (client->ssl_enabled) {
273 log_debug_msg("%s: sending SSL close notify\n", __func__); 273 debug_info("sending SSL close notify");
274 gnutls_bye(client->ssl_session, GNUTLS_SHUT_RDWR); 274 gnutls_bye(client->ssl_session, GNUTLS_SHUT_RDWR);
275 } 275 }
276 if (client->ssl_session) { 276 if (client->ssl_session) {
@@ -285,7 +285,7 @@ static lockdownd_error_t lockdownd_ssl_stop_session(lockdownd_client_t client)
285 free(client->session_id); 285 free(client->session_id);
286 client->session_id = NULL; 286 client->session_id = NULL;
287 287
288 log_debug_msg("%s: SSL mode disabled\n", __func__); 288 debug_info("SSL mode disabled");
289 289
290 return ret; 290 return ret;
291} 291}
@@ -307,7 +307,7 @@ lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *
307 return LOCKDOWN_E_INVALID_ARG; 307 return LOCKDOWN_E_INVALID_ARG;
308 308
309 if (!session_id) { 309 if (!session_id) {
310 log_debug_msg("%s: no session_id given, cannot stop session\n", __func__); 310 debug_info("no session_id given, cannot stop session");
311 return LOCKDOWN_E_INVALID_ARG; 311 return LOCKDOWN_E_INVALID_ARG;
312 } 312 }
313 313
@@ -318,7 +318,7 @@ lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *
318 plist_dict_insert_item(dict,"Request", plist_new_string("StopSession")); 318 plist_dict_insert_item(dict,"Request", plist_new_string("StopSession"));
319 plist_dict_insert_item(dict,"SessionID", plist_new_string(session_id)); 319 plist_dict_insert_item(dict,"SessionID", plist_new_string(session_id));
320 320
321 log_debug_msg("%s: stopping session %s\n", __func__, session_id); 321 debug_info("stopping session %s", session_id);
322 322
323 ret = lockdownd_send(client, dict); 323 ret = lockdownd_send(client, dict);
324 324
@@ -328,13 +328,13 @@ lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *
328 ret = lockdownd_recv(client, &dict); 328 ret = lockdownd_recv(client, &dict);
329 329
330 if (!dict) { 330 if (!dict) {
331 log_debug_msg("%s: LOCKDOWN_E_PLIST_ERROR\n", __func__); 331 debug_info("LOCKDOWN_E_PLIST_ERROR");
332 return LOCKDOWN_E_PLIST_ERROR; 332 return LOCKDOWN_E_PLIST_ERROR;
333 } 333 }
334 334
335 ret = LOCKDOWN_E_UNKNOWN_ERROR; 335 ret = LOCKDOWN_E_UNKNOWN_ERROR;
336 if (lockdown_check_result(dict, "StopSession") == RESULT_SUCCESS) { 336 if (lockdown_check_result(dict, "StopSession") == RESULT_SUCCESS) {
337 log_debug_msg("%s: success\n", __func__); 337 debug_info("success");
338 ret = LOCKDOWN_E_SUCCESS; 338 ret = LOCKDOWN_E_SUCCESS;
339 } 339 }
340 plist_free(dict); 340 plist_free(dict);
@@ -480,7 +480,7 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
480 plist_dict_add_label(dict, client->label); 480 plist_dict_add_label(dict, client->label);
481 plist_dict_insert_item(dict,"Request", plist_new_string("QueryType")); 481 plist_dict_insert_item(dict,"Request", plist_new_string("QueryType"));
482 482
483 log_debug_msg("%s: called\n", __func__); 483 debug_info("called");
484 ret = lockdownd_send(client, dict); 484 ret = lockdownd_send(client, dict);
485 485
486 plist_free(dict); 486 plist_free(dict);
@@ -498,7 +498,7 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
498 plist_t type_node = plist_dict_get_item(dict, "Type"); 498 plist_t type_node = plist_dict_get_item(dict, "Type");
499 plist_get_string_val(type_node, type); 499 plist_get_string_val(type_node, type);
500 } 500 }
501 log_debug_msg("%s: success with type %s\n", __func__, *type); 501 debug_info("success with type %s", *type);
502 ret = LOCKDOWN_E_SUCCESS; 502 ret = LOCKDOWN_E_SUCCESS;
503 } 503 }
504 plist_free(dict); 504 plist_free(dict);
@@ -550,7 +550,7 @@ lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *dom
550 return ret; 550 return ret;
551 551
552 if (lockdown_check_result(dict, "GetValue") == RESULT_SUCCESS) { 552 if (lockdown_check_result(dict, "GetValue") == RESULT_SUCCESS) {
553 log_debug_msg("%s: success\n", __func__); 553 debug_info("success");
554 ret = LOCKDOWN_E_SUCCESS; 554 ret = LOCKDOWN_E_SUCCESS;
555 } 555 }
556 if (ret != LOCKDOWN_E_SUCCESS) { 556 if (ret != LOCKDOWN_E_SUCCESS) {
@@ -561,7 +561,7 @@ lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *dom
561 plist_t value_node = plist_dict_get_item(dict, "Value"); 561 plist_t value_node = plist_dict_get_item(dict, "Value");
562 562
563 if (value_node) { 563 if (value_node) {
564 log_debug_msg("%s: has a value\n", __func__); 564 debug_info("has a value");
565 *value = plist_copy(value_node); 565 *value = plist_copy(value_node);
566 } 566 }
567 567
@@ -613,7 +613,7 @@ lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *dom
613 return ret; 613 return ret;
614 614
615 if (lockdown_check_result(dict, "SetValue") == RESULT_SUCCESS) { 615 if (lockdown_check_result(dict, "SetValue") == RESULT_SUCCESS) {
616 log_debug_msg("%s: success\n", __func__); 616 debug_info("success");
617 ret = LOCKDOWN_E_SUCCESS; 617 ret = LOCKDOWN_E_SUCCESS;
618 } 618 }
619 619
@@ -670,7 +670,7 @@ lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *
670 return ret; 670 return ret;
671 671
672 if (lockdown_check_result(dict, "RemoveValue") == RESULT_SUCCESS) { 672 if (lockdown_check_result(dict, "RemoveValue") == RESULT_SUCCESS) {
673 log_debug_msg("%s: success\n", __func__); 673 debug_info("success");
674 ret = LOCKDOWN_E_SUCCESS; 674 ret = LOCKDOWN_E_SUCCESS;
675 } 675 }
676 676
@@ -769,7 +769,7 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
769 769
770 property_list_service_client_t plistclient = NULL; 770 property_list_service_client_t plistclient = NULL;
771 if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 771 if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
772 log_debug_msg("%s: could not connect to lockdownd (device %s)\n", __func__, device->uuid); 772 debug_info("could not connect to lockdownd (device %s)", device->uuid);
773 return LOCKDOWN_E_MUX_ERROR; 773 return LOCKDOWN_E_MUX_ERROR;
774 } 774 }
775 775
@@ -818,11 +818,11 @@ lockdownd_error_t lockdownd_client_new_with_handshake(iphone_device_t device, lo
818 818
819 /* perform handshake */ 819 /* perform handshake */
820 if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) { 820 if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) {
821 log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__); 821 debug_info("QueryType failed in the lockdownd client.");
822 ret = LOCKDOWN_E_NOT_ENOUGH_DATA; 822 ret = LOCKDOWN_E_NOT_ENOUGH_DATA;
823 } else { 823 } else {
824 if (strcmp("com.apple.mobile.lockdown", type)) { 824 if (strcmp("com.apple.mobile.lockdown", type)) {
825 log_debug_msg("%s: Warning QueryType request returned \"%s\".\n", __func__, type); 825 debug_info("Warning QueryType request returned \"%s\".", type);
826 } 826 }
827 if (type) 827 if (type)
828 free(type); 828 free(type);
@@ -830,9 +830,9 @@ lockdownd_error_t lockdownd_client_new_with_handshake(iphone_device_t device, lo
830 830
831 ret = iphone_device_get_uuid(device, &client_loc->uuid); 831 ret = iphone_device_get_uuid(device, &client_loc->uuid);
832 if (LOCKDOWN_E_SUCCESS != ret) { 832 if (LOCKDOWN_E_SUCCESS != ret) {
833 log_debug_msg("%s: failed to get device uuid.\n", __func__); 833 debug_info("failed to get device uuid.");
834 } 834 }
835 log_debug_msg("%s: device uuid: %s\n", __func__, client_loc->uuid); 835 debug_info("device uuid: %s", client_loc->uuid);
836 836
837 userpref_get_host_id(&host_id); 837 userpref_get_host_id(&host_id);
838 if (LOCKDOWN_E_SUCCESS == ret && !host_id) { 838 if (LOCKDOWN_E_SUCCESS == ret && !host_id) {
@@ -849,7 +849,7 @@ lockdownd_error_t lockdownd_client_new_with_handshake(iphone_device_t device, lo
849 ret = lockdownd_start_session(client_loc, host_id, NULL, NULL); 849 ret = lockdownd_start_session(client_loc, host_id, NULL, NULL);
850 if (LOCKDOWN_E_SUCCESS != ret) { 850 if (LOCKDOWN_E_SUCCESS != ret) {
851 ret = LOCKDOWN_E_SSL_ERROR; 851 ret = LOCKDOWN_E_SSL_ERROR;
852 log_debug_msg("%s: SSL Session opening failed.\n", __func__); 852 debug_info("SSL Session opening failed.");
853 } 853 }
854 854
855 if (host_id) { 855 if (host_id) {
@@ -892,10 +892,10 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, char *host
892 892
893 ret = lockdownd_get_device_public_key(client, &public_key); 893 ret = lockdownd_get_device_public_key(client, &public_key);
894 if (ret != LOCKDOWN_E_SUCCESS) { 894 if (ret != LOCKDOWN_E_SUCCESS) {
895 log_debug_msg("%s: device refused to send public key.\n", __func__); 895 debug_info("device refused to send public key.");
896 return ret; 896 return ret;
897 } 897 }
898 log_debug_msg("%s: device public key follows:\n%s\n", __func__, public_key.data); 898 debug_info("device public key follows:\n%s", public_key.data);
899 899
900 ret = lockdownd_gen_pair_cert(public_key, &device_cert, &host_cert, &root_cert); 900 ret = lockdownd_gen_pair_cert(public_key, &device_cert, &host_cert, &root_cert);
901 if (ret != LOCKDOWN_E_SUCCESS) { 901 if (ret != LOCKDOWN_E_SUCCESS) {
@@ -944,7 +944,7 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, char *host
944 944
945 /* if pairing succeeded */ 945 /* if pairing succeeded */
946 if (ret == LOCKDOWN_E_SUCCESS) { 946 if (ret == LOCKDOWN_E_SUCCESS) {
947 log_debug_msg("%s: %s success\n", __func__, verb); 947 debug_info("%s success", verb);
948 if (!strcmp("Unpair", verb)) { 948 if (!strcmp("Unpair", verb)) {
949 /* remove public key from config */ 949 /* remove public key from config */
950 userpref_remove_device_public_key(client->uuid); 950 userpref_remove_device_public_key(client->uuid);
@@ -953,7 +953,7 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, char *host
953 userpref_set_device_public_key(client->uuid, public_key); 953 userpref_set_device_public_key(client->uuid, public_key);
954 } 954 }
955 } else { 955 } else {
956 log_debug_msg("%s: %s failure\n", __func__, verb); 956 debug_info("%s failure", verb);
957 plist_t error_node = NULL; 957 plist_t error_node = NULL;
958 /* verify error condition */ 958 /* verify error condition */
959 error_node = plist_dict_get_item(dict, "Error"); 959 error_node = plist_dict_get_item(dict, "Error");
@@ -1041,7 +1041,7 @@ lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
1041 plist_dict_add_label(dict, client->label); 1041 plist_dict_add_label(dict, client->label);
1042 plist_dict_insert_item(dict,"Request", plist_new_string("EnterRecovery")); 1042 plist_dict_insert_item(dict,"Request", plist_new_string("EnterRecovery"));
1043 1043
1044 log_debug_msg("%s: telling device to enter recovery mode\n", __func__); 1044 debug_info("telling device to enter recovery mode");
1045 1045
1046 ret = lockdownd_send(client, dict); 1046 ret = lockdownd_send(client, dict);
1047 plist_free(dict); 1047 plist_free(dict);
@@ -1050,7 +1050,7 @@ lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
1050 ret = lockdownd_recv(client, &dict); 1050 ret = lockdownd_recv(client, &dict);
1051 1051
1052 if (lockdown_check_result(dict, "EnterRecovery") == RESULT_SUCCESS) { 1052 if (lockdown_check_result(dict, "EnterRecovery") == RESULT_SUCCESS) {
1053 log_debug_msg("%s: success\n", __func__); 1053 debug_info("success");
1054 ret = LOCKDOWN_E_SUCCESS; 1054 ret = LOCKDOWN_E_SUCCESS;
1055 } 1055 }
1056 plist_free(dict); 1056 plist_free(dict);
@@ -1077,7 +1077,7 @@ lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
1077 plist_dict_add_label(dict, client->label); 1077 plist_dict_add_label(dict, client->label);
1078 plist_dict_insert_item(dict,"Request", plist_new_string("Goodbye")); 1078 plist_dict_insert_item(dict,"Request", plist_new_string("Goodbye"));
1079 1079
1080 log_debug_msg("%s: called\n", __func__); 1080 debug_info("called");
1081 1081
1082 ret = lockdownd_send(client, dict); 1082 ret = lockdownd_send(client, dict);
1083 plist_free(dict); 1083 plist_free(dict);
@@ -1085,12 +1085,12 @@ lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
1085 1085
1086 ret = lockdownd_recv(client, &dict); 1086 ret = lockdownd_recv(client, &dict);
1087 if (!dict) { 1087 if (!dict) {
1088 log_debug_msg("%s: did not get goodbye response back\n", __func__); 1088 debug_info("did not get goodbye response back");
1089 return LOCKDOWN_E_PLIST_ERROR; 1089 return LOCKDOWN_E_PLIST_ERROR;
1090 } 1090 }
1091 1091
1092 if (lockdown_check_result(dict, "Goodbye") == RESULT_SUCCESS) { 1092 if (lockdown_check_result(dict, "Goodbye") == RESULT_SUCCESS) {
1093 log_debug_msg("%s: success\n", __func__); 1093 debug_info("success");
1094 ret = LOCKDOWN_E_SUCCESS; 1094 ret = LOCKDOWN_E_SUCCESS;
1095 } 1095 }
1096 plist_free(dict); 1096 plist_free(dict);
@@ -1294,7 +1294,7 @@ lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char
1294 if (enable_ssl && (plist_get_node_type(enable_ssl) == PLIST_BOOLEAN)) { 1294 if (enable_ssl && (plist_get_node_type(enable_ssl) == PLIST_BOOLEAN)) {
1295 plist_get_bool_val(enable_ssl, &use_ssl); 1295 plist_get_bool_val(enable_ssl, &use_ssl);
1296 } 1296 }
1297 log_debug_msg("%s: Session startup OK\n", __func__); 1297 debug_info("Session startup OK");
1298 1298
1299 if (ssl_enabled != NULL) 1299 if (ssl_enabled != NULL)
1300 *ssl_enabled = use_ssl; 1300 *ssl_enabled = use_ssl;
@@ -1305,13 +1305,13 @@ lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char
1305 plist_get_string_val(session_node, &client->session_id); 1305 plist_get_string_val(session_node, &client->session_id);
1306 } 1306 }
1307 if (client->session_id) { 1307 if (client->session_id) {
1308 log_debug_msg("%s: SessionID: %s\n", __func__, client->session_id); 1308 debug_info("SessionID: %s", client->session_id);
1309 if (session_id != NULL) 1309 if (session_id != NULL)
1310 *session_id = strdup(client->session_id); 1310 *session_id = strdup(client->session_id);
1311 } else { 1311 } else {
1312 log_debug_msg("%s: Failed to get SessionID!\n", __func__); 1312 debug_info("Failed to get SessionID!");
1313 } 1313 }
1314 log_debug_msg("%s: Enable SSL Session: %s\n", __func__, (use_ssl?"true":"false")); 1314 debug_info("Enable SSL Session: %s", (use_ssl?"true":"false"));
1315 if (use_ssl) { 1315 if (use_ssl) {
1316 ret = lockdownd_ssl_start_session(client); 1316 ret = lockdownd_ssl_start_session(client);
1317 } else { 1317 } else {
@@ -1434,13 +1434,13 @@ lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activati
1434 1434
1435 ret = lockdownd_recv(client, &dict); 1435 ret = lockdownd_recv(client, &dict);
1436 if (!dict) { 1436 if (!dict) {
1437 log_debug_msg("%s: LOCKDOWN_E_PLIST_ERROR\n", __func__); 1437 debug_info("LOCKDOWN_E_PLIST_ERROR");
1438 return LOCKDOWN_E_PLIST_ERROR; 1438 return LOCKDOWN_E_PLIST_ERROR;
1439 } 1439 }
1440 1440
1441 ret = LOCKDOWN_E_ACTIVATION_FAILED; 1441 ret = LOCKDOWN_E_ACTIVATION_FAILED;
1442 if (lockdown_check_result(dict, "Activate") == RESULT_SUCCESS) { 1442 if (lockdown_check_result(dict, "Activate") == RESULT_SUCCESS) {
1443 log_debug_msg("%s: success\n", __func__); 1443 debug_info("success");
1444 ret = LOCKDOWN_E_SUCCESS; 1444 ret = LOCKDOWN_E_SUCCESS;
1445 } 1445 }
1446 plist_free(dict); 1446 plist_free(dict);
@@ -1477,13 +1477,13 @@ lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client)
1477 1477
1478 ret = lockdownd_recv(client, &dict); 1478 ret = lockdownd_recv(client, &dict);
1479 if (!dict) { 1479 if (!dict) {
1480 log_debug_msg("%s: LOCKDOWN_E_PLIST_ERROR\n", __func__); 1480 debug_info("LOCKDOWN_E_PLIST_ERROR");
1481 return LOCKDOWN_E_PLIST_ERROR; 1481 return LOCKDOWN_E_PLIST_ERROR;
1482 } 1482 }
1483 1483
1484 ret = LOCKDOWN_E_UNKNOWN_ERROR; 1484 ret = LOCKDOWN_E_UNKNOWN_ERROR;
1485 if (lockdown_check_result(dict, "Deactivate") == RESULT_SUCCESS) { 1485 if (lockdown_check_result(dict, "Deactivate") == RESULT_SUCCESS) {
1486 log_debug_msg("%s: success\n", __func__); 1486 debug_info("success");
1487 ret = LOCKDOWN_E_SUCCESS; 1487 ret = LOCKDOWN_E_SUCCESS;
1488 } 1488 }
1489 plist_free(dict); 1489 plist_free(dict);
diff --git a/src/property_list_service.c b/src/property_list_service.c
index b549cb4..e39c7bb 100644
--- a/src/property_list_service.c
+++ b/src/property_list_service.c
@@ -142,7 +142,7 @@ static property_list_service_error_t internal_plist_send(property_list_service_c
142 } 142 }
143 143
144 nlen = htonl(length); 144 nlen = htonl(length);
145 log_debug_msg("%s: sending %d bytes\n", __func__, length); 145 debug_info("sending %d bytes", length);
146 if (ssl_session) { 146 if (ssl_session) {
147 bytes = gnutls_record_send(ssl_session, (const char*)&nlen, sizeof(nlen)); 147 bytes = gnutls_record_send(ssl_session, (const char*)&nlen, sizeof(nlen));
148 } else { 148 } else {
@@ -155,17 +155,17 @@ static property_list_service_error_t internal_plist_send(property_list_service_c
155 iphone_device_send(client->connection, content, length, (uint32_t*)&bytes); 155 iphone_device_send(client->connection, content, length, (uint32_t*)&bytes);
156 } 156 }
157 if (bytes > 0) { 157 if (bytes > 0) {
158 log_debug_msg("%s: sent %d bytes\n", __func__, bytes); 158 debug_info("sent %d bytes", bytes);
159 log_debug_buffer(content, bytes); 159 debug_buffer(content, bytes);
160 if ((uint32_t)bytes == length) { 160 if ((uint32_t)bytes == length) {
161 res = PROPERTY_LIST_SERVICE_E_SUCCESS; 161 res = PROPERTY_LIST_SERVICE_E_SUCCESS;
162 } else { 162 } else {
163 log_debug_msg("%s: ERROR: Could not send all data (%d of %d)!\n", __func__, bytes, length); 163 debug_info("ERROR: Could not send all data (%d of %d)!", bytes, length);
164 } 164 }
165 } 165 }
166 } 166 }
167 if (bytes <= 0) { 167 if (bytes <= 0) {
168 log_debug_msg("%s: ERROR: sending to device failed.\n", __func__); 168 debug_info("ERROR: sending to device failed.");
169 } 169 }
170 170
171 free(content); 171 free(content);
@@ -274,16 +274,16 @@ static property_list_service_error_t internal_plist_recv_timeout(property_list_s
274 } else { 274 } else {
275 iphone_device_recv_timeout(client->connection, (char*)&pktlen, sizeof(pktlen), &bytes, timeout); 275 iphone_device_recv_timeout(client->connection, (char*)&pktlen, sizeof(pktlen), &bytes, timeout);
276 } 276 }
277 log_debug_msg("%s: initial read=%i\n", __func__, bytes); 277 debug_info("initial read=%i", bytes);
278 if (bytes < 4) { 278 if (bytes < 4) {
279 log_debug_msg("%s: initial read failed!\n", __func__); 279 debug_info("initial read failed!");
280 return PROPERTY_LIST_SERVICE_E_MUX_ERROR; 280 return PROPERTY_LIST_SERVICE_E_MUX_ERROR;
281 } else { 281 } else {
282 if ((char)pktlen == 0) { /* prevent huge buffers */ 282 if ((char)pktlen == 0) { /* prevent huge buffers */
283 uint32_t curlen = 0; 283 uint32_t curlen = 0;
284 char *content = NULL; 284 char *content = NULL;
285 pktlen = ntohl(pktlen); 285 pktlen = ntohl(pktlen);
286 log_debug_msg("%s: %d bytes following\n", __func__, pktlen); 286 debug_info("%d bytes following", pktlen);
287 content = (char*)malloc(pktlen); 287 content = (char*)malloc(pktlen);
288 288
289 while (curlen < pktlen) { 289 while (curlen < pktlen) {
@@ -296,10 +296,10 @@ static property_list_service_error_t internal_plist_recv_timeout(property_list_s
296 res = PROPERTY_LIST_SERVICE_E_MUX_ERROR; 296 res = PROPERTY_LIST_SERVICE_E_MUX_ERROR;
297 break; 297 break;
298 } 298 }
299 log_debug_msg("%s: received %d bytes\n", __func__, bytes); 299 debug_info("received %d bytes", bytes);
300 curlen += bytes; 300 curlen += bytes;
301 } 301 }
302 log_debug_buffer(content, pktlen); 302 debug_buffer(content, pktlen);
303 if (!memcmp(content, "bplist00", 8)) { 303 if (!memcmp(content, "bplist00", 8)) {
304 plist_from_bin(content, pktlen, plist); 304 plist_from_bin(content, pktlen, plist);
305 } else { 305 } else {
diff --git a/src/userpref.c b/src/userpref.c
index c677fda..6eff534 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -106,7 +106,7 @@ static int userpref_set_host_id(const char *host_id)
106 key_file = g_key_file_new(); 106 key_file = g_key_file_new();
107 107
108 /* Store in config file */ 108 /* Store in config file */
109 log_debug_msg("%s: setting hostID to %s\n", __func__, host_id); 109 debug_info("setting hostID to %s", host_id);
110 g_key_file_set_value(key_file, "Global", "HostID", host_id); 110 g_key_file_set_value(key_file, "Global", "HostID", host_id);
111 111
112 /* Write config file on disk */ 112 /* Write config file on disk */
@@ -155,7 +155,7 @@ void userpref_get_host_id(char **host_id)
155 userpref_set_host_id(*host_id); 155 userpref_set_host_id(*host_id);
156 } 156 }
157 157
158 log_debug_msg("%s: Using %s as HostID\n", __func__, *host_id); 158 debug_info("Using %s as HostID", *host_id);
159} 159}
160 160
161/** Determines whether this iPhone has been connected to this system before. 161/** Determines whether this iPhone has been connected to this system before.