From a5245005b41cbae1ccee805fbef8d3e343c9b312 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 14 Apr 2009 13:15:10 +0200 Subject: Logging and debugging refined. --- iphone.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'iphone.c') diff --git a/iphone.c b/iphone.c index 662432b..db68349 100644 --- a/iphone.c +++ b/iphone.c @@ -143,7 +143,8 @@ void log_debug_msg(const char *format, ...) */ static void print_buffer(const char *data, const int length) { - int i; + if (toto_debug > 0) { + int i; int j; unsigned char c; @@ -170,6 +171,7 @@ static void print_buffer(const char *data, const int length) printf("\n"); } printf("\n"); + } } #endif @@ -356,7 +358,7 @@ iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t // Check for correct version if (ntohl(version->major) == 1 && ntohl(version->minor) == 0) { // We're all ready to roll. - fprintf(stderr, "get_iPhone() success\n"); + log_debug_msg("get_iPhone() success\n"); free(version); *device = phone; return IPHONE_E_SUCCESS; @@ -513,10 +515,12 @@ int send_to_phone(iphone_device_t phone, char *data, int datalen) #ifdef DEBUG if (bytes > 0) { + if (toto_debug > 0) { printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); printf("%s: sent to phone\n", __func__); print_buffer(data, bytes); printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); + } } #endif return bytes; @@ -553,10 +557,12 @@ int recv_from_phone_timeout(iphone_device_t phone, char *data, int datalen, int #ifdef DEBUG if (bytes > 0) { + if (toto_debug > 0) { printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); printf("%s: received from phone:\n", __func__); print_buffer(data, bytes); printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); + } } #endif -- cgit v1.1-32-gdbae