summaryrefslogtreecommitdiffstats
path: root/src/iphone.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-12 19:09:36 +0100
committerGravatar Martin Szulecki2010-01-12 19:09:36 +0100
commit342f4e929888c0aaa088e39fb98a74957bf45fa7 (patch)
tree905bafb1b353b8ac21e3fb1f9c773d218a5c878e /src/iphone.c
parentbf3dc421b2b5ccfe2fcd3cd4ec1ef90f39599600 (diff)
downloadlibimobiledevice-342f4e929888c0aaa088e39fb98a74957bf45fa7.tar.gz
libimobiledevice-342f4e929888c0aaa088e39fb98a74957bf45fa7.tar.bz2
Refactor and unify internal debug system for ease of use and verbosity
This introduces a new debug_info macro which automatically prints the calling function, file and line number information instead of having that information passed to every old log_debug_msg call.
Diffstat (limited to 'src/iphone.c')
-rw-r--r--src/iphone.c26
1 files changed, 13 insertions, 13 deletions
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}