diff options
| -rw-r--r-- | common/debug.c | 19 | ||||
| -rw-r--r-- | include/libimobiledevice/libimobiledevice.h | 10 | ||||
| -rw-r--r-- | src/idevice.c | 6 | ||||
| -rw-r--r-- | src/idevice.h | 3 |
4 files changed, 18 insertions, 20 deletions
diff --git a/common/debug.c b/common/debug.c index 8ad0f08..c4d3897 100644 --- a/common/debug.c +++ b/common/debug.c | |||
| @@ -41,19 +41,6 @@ | |||
| 41 | 41 | ||
| 42 | #define MAX_PRINT_LEN 16*1024 | 42 | #define MAX_PRINT_LEN 16*1024 |
| 43 | 43 | ||
| 44 | int debug_level = 0; | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Sets the level of debugging. Currently the only acceptable values are 0 and | ||
| 48 | * 1. | ||
| 49 | * | ||
| 50 | * @param level Set to 0 for no debugging or 1 for debugging. | ||
| 51 | */ | ||
| 52 | LIBIMOBILEDEVICE_API void idevice_set_debug_level(int level) | ||
| 53 | { | ||
| 54 | debug_level = level; | ||
| 55 | } | ||
| 56 | |||
| 57 | #ifndef STRIP_DEBUG_CODE | 44 | #ifndef STRIP_DEBUG_CODE |
| 58 | static void debug_print_line(const char *func, const char *file, int line, const char *buffer) | 45 | static void debug_print_line(const char *func, const char *file, int line, const char *buffer) |
| 59 | { | 46 | { |
| @@ -90,7 +77,7 @@ void debug_info_real(const char *func, const char *file, int line, const char *f | |||
| 90 | va_list args; | 77 | va_list args; |
| 91 | char *buffer = NULL; | 78 | char *buffer = NULL; |
| 92 | 79 | ||
| 93 | if (!debug_level) | 80 | if (!idevice_debug_level) |
| 94 | return; | 81 | return; |
| 95 | 82 | ||
| 96 | /* run the real fprintf */ | 83 | /* run the real fprintf */ |
| @@ -111,7 +98,7 @@ void debug_buffer(const char *data, const int length) | |||
| 111 | int j; | 98 | int j; |
| 112 | unsigned char c; | 99 | unsigned char c; |
| 113 | 100 | ||
| 114 | if (debug_level) { | 101 | if (idevice_debug_level) { |
| 115 | for (i = 0; i < length; i += 16) { | 102 | for (i = 0; i < length; i += 16) { |
| 116 | fprintf(stderr, "%04x: ", i); | 103 | fprintf(stderr, "%04x: ", i); |
| 117 | for (j = 0; j < 16; j++) { | 104 | for (j = 0; j < 16; j++) { |
| @@ -142,7 +129,7 @@ void debug_buffer(const char *data, const int length) | |||
| 142 | void debug_buffer_to_file(const char *file, const char *data, const int length) | 129 | void debug_buffer_to_file(const char *file, const char *data, const int length) |
| 143 | { | 130 | { |
| 144 | #ifndef STRIP_DEBUG_CODE | 131 | #ifndef STRIP_DEBUG_CODE |
| 145 | if (debug_level) { | 132 | if (idevice_debug_level) { |
| 146 | FILE *f = fopen(file, "wb"); | 133 | FILE *f = fopen(file, "wb"); |
| 147 | fwrite(data, 1, length, f); | 134 | fwrite(data, 1, length, f); |
| 148 | fflush(f); | 135 | fflush(f); |
diff --git a/include/libimobiledevice/libimobiledevice.h b/include/libimobiledevice/libimobiledevice.h index c91ec83..b7a20d8 100644 --- a/include/libimobiledevice/libimobiledevice.h +++ b/include/libimobiledevice/libimobiledevice.h | |||
| @@ -49,9 +49,6 @@ typedef idevice_private *idevice_t; /**< The device handle. */ | |||
| 49 | typedef struct idevice_connection_private idevice_connection_private; | 49 | typedef struct idevice_connection_private idevice_connection_private; |
| 50 | typedef idevice_connection_private *idevice_connection_t; /**< The connection handle. */ | 50 | typedef idevice_connection_private *idevice_connection_t; /**< The connection handle. */ |
| 51 | 51 | ||
| 52 | /* generic */ | ||
| 53 | void idevice_set_debug_level(int level); | ||
| 54 | |||
| 55 | /* discovery (events/asynchronous) */ | 52 | /* discovery (events/asynchronous) */ |
| 56 | /** The event type for device add or removal */ | 53 | /** The event type for device add or removal */ |
| 57 | enum idevice_event_type { | 54 | enum idevice_event_type { |
| @@ -74,6 +71,13 @@ typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_dat | |||
| 74 | /* functions */ | 71 | /* functions */ |
| 75 | 72 | ||
| 76 | /** | 73 | /** |
| 74 | * Set the level of debugging. | ||
| 75 | * | ||
| 76 | * @param level Set to 0 for no debug output or 1 to enable debug output. | ||
| 77 | */ | ||
| 78 | void idevice_set_debug_level(int level); | ||
| 79 | |||
| 80 | /** | ||
| 77 | * Register a callback function that will be called when device add/remove | 81 | * Register a callback function that will be called when device add/remove |
| 78 | * events occur. | 82 | * events occur. |
| 79 | * | 83 | * |
diff --git a/src/idevice.c b/src/idevice.c index 7ec46ed..c40c59a 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #else | 44 | #else |
| 45 | #include <gnutls/gnutls.h> | 45 | #include <gnutls/gnutls.h> |
| 46 | #endif | 46 | #endif |
| 47 | |||
| 47 | #include "idevice.h" | 48 | #include "idevice.h" |
| 48 | #include "common/userpref.h" | 49 | #include "common/userpref.h" |
| 49 | #include "common/thread.h" | 50 | #include "common/thread.h" |
| @@ -221,6 +222,11 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_free(char **devices) | |||
| 221 | return IDEVICE_E_SUCCESS; | 222 | return IDEVICE_E_SUCCESS; |
| 222 | } | 223 | } |
| 223 | 224 | ||
| 225 | LIBIMOBILEDEVICE_API void idevice_set_debug_level(int level) | ||
| 226 | { | ||
| 227 | idevice_debug_level = level; | ||
| 228 | } | ||
| 229 | |||
| 224 | LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t * device, const char *udid) | 230 | LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t * device, const char *udid) |
| 225 | { | 231 | { |
| 226 | usbmuxd_device_info_t muxdev; | 232 | usbmuxd_device_info_t muxdev; |
diff --git a/src/idevice.h b/src/idevice.h index 575e313..1a52480 100644 --- a/src/idevice.h +++ b/src/idevice.h | |||
| @@ -44,9 +44,10 @@ | |||
| 44 | #endif | 44 | #endif |
| 45 | 45 | ||
| 46 | #include "common/userpref.h" | 46 | #include "common/userpref.h" |
| 47 | |||
| 48 | #include "libimobiledevice/libimobiledevice.h" | 47 | #include "libimobiledevice/libimobiledevice.h" |
| 49 | 48 | ||
| 49 | int idevice_debug_level; | ||
| 50 | |||
| 50 | enum connection_type { | 51 | enum connection_type { |
| 51 | CONNECTION_USBMUXD = 1 | 52 | CONNECTION_USBMUXD = 1 |
| 52 | }; | 53 | }; |
