summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2014-10-27 02:40:14 +0100
committerGravatar Martin Szulecki2014-10-27 02:40:14 +0100
commite229e28cb37bc6e938a0410d13d1afe94af57319 (patch)
tree45b1356d2880501888d9fbf46e1c944a94f6ad81
parent1e86eab358edcd647b2d3544570e4f6988cc2aa5 (diff)
downloadlibimobiledevice-e229e28cb37bc6e938a0410d13d1afe94af57319.tar.gz
libimobiledevice-e229e28cb37bc6e938a0410d13d1afe94af57319.tar.bz2
debug: Fix linking failure on OS X by keeping debug level symbol internal
This change keeps the debug level symbol within the internal convenience library and makes it accessible using an internal helper. This fixes linking, prevents new exported symbols and finally allows proper control of enabling debug messages.
-rw-r--r--common/debug.c13
-rw-r--r--common/debug.h2
-rw-r--r--src/idevice.c2
-rw-r--r--src/idevice.h2
4 files changed, 13 insertions, 6 deletions
diff --git a/common/debug.c b/common/debug.c
index c4d3897..82e3c2f 100644
--- a/common/debug.c
+++ b/common/debug.c
@@ -39,6 +39,13 @@
#include "asprintf.h"
#endif
+static int debug_level;
+
+void internal_set_debug_level(int level)
+{
+ debug_level = level;
+}
+
#define MAX_PRINT_LEN 16*1024
#ifndef STRIP_DEBUG_CODE
@@ -77,7 +84,7 @@ void debug_info_real(const char *func, const char *file, int line, const char *f
va_list args;
char *buffer = NULL;
- if (!idevice_debug_level)
+ if (!debug_level)
return;
/* run the real fprintf */
@@ -98,7 +105,7 @@ void debug_buffer(const char *data, const int length)
int j;
unsigned char c;
- if (idevice_debug_level) {
+ if (debug_level) {
for (i = 0; i < length; i += 16) {
fprintf(stderr, "%04x: ", i);
for (j = 0; j < 16; j++) {
@@ -129,7 +136,7 @@ void debug_buffer(const char *data, const int length)
void debug_buffer_to_file(const char *file, const char *data, const int length)
{
#ifndef STRIP_DEBUG_CODE
- if (idevice_debug_level) {
+ if (debug_level) {
FILE *f = fopen(file, "wb");
fwrite(data, 1, length, f);
fflush(f);
diff --git a/common/debug.h b/common/debug.h
index 99a94b7..4c264c7 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -48,4 +48,6 @@ void debug_plist_real(const char *func,
int line,
plist_t plist);
+void internal_set_debug_level(int level);
+
#endif
diff --git a/src/idevice.c b/src/idevice.c
index c40c59a..367eb0f 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -224,7 +224,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_free(char **devices)
LIBIMOBILEDEVICE_API void idevice_set_debug_level(int level)
{
- idevice_debug_level = level;
+ internal_set_debug_level(level);
}
LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t * device, const char *udid)
diff --git a/src/idevice.h b/src/idevice.h
index 1a52480..08e24e6 100644
--- a/src/idevice.h
+++ b/src/idevice.h
@@ -46,8 +46,6 @@
#include "common/userpref.h"
#include "libimobiledevice/libimobiledevice.h"
-int idevice_debug_level;
-
enum connection_type {
CONNECTION_USBMUXD = 1
};