summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils.c26
-rw-r--r--src/utils.h8
2 files changed, 34 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index fb98471..988cb03 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -23,6 +23,7 @@
23#include "utils.h" 23#include "utils.h"
24 24
25int toto_debug = 0; 25int toto_debug = 0;
26uint16_t dbg_mask = 0;
26 27
27/** 28/**
28 * Sets the level of debugging. Currently the only acceptable values are 0 and 29 * Sets the level of debugging. Currently the only acceptable values are 0 and
@@ -36,6 +37,15 @@ void iphone_set_debug(int level)
36} 37}
37 38
38 39
40/**
41 * Set debug ids to display. Values can be OR-ed
42 *
43 * @param level Set to 0 for no debugging or 1 for debugging.
44 */
45void iphone_set_debug_mask(uint16_t mask)
46{
47 dbg_mask = mask;
48}
39 49
40void log_debug_msg(const char *format, ...) 50void log_debug_msg(const char *format, ...)
41{ 51{
@@ -53,6 +63,22 @@ void log_debug_msg(const char *format, ...)
53#endif 63#endif
54} 64}
55 65
66void log_dbg_msg(uint16_t id, const char *format, ...)
67{
68#ifndef STRIP_DEBUG_CODE
69
70 if (id & dbg_mask) {
71 va_list args;
72 /* run the real fprintf */
73 va_start(args, format);
74
75 vfprintf(stderr, format, args);
76
77 va_end(args);
78 }
79#endif
80}
81
56inline void log_debug_buffer(const char *data, const int length) 82inline void log_debug_buffer(const char *data, const int length)
57{ 83{
58#ifndef STRIP_DEBUG_CODE 84#ifndef STRIP_DEBUG_CODE
diff --git a/src/utils.h b/src/utils.h
index 489f610..c1a8e54 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -24,7 +24,15 @@
24 24
25#include "libiphone/libiphone.h" 25#include "libiphone/libiphone.h"
26 26
27#define DBGMASK_USBMUX (1 << 1)
28#define DBGMASK_LOCKDOWND (1 << 2)
29#define DBGMASK_MOBILESYNC (1 << 3)
30
31void iphone_set_debug_mask(uint16_t mask);
32
27inline void log_debug_msg(const char *format, ...); 33inline void log_debug_msg(const char *format, ...);
34inline void log_dbg_msg(uint16_t id, const char *format, ...);
35
28inline void log_debug_buffer(const char *data, const int length); 36inline void log_debug_buffer(const char *data, const int length);
29inline void dump_debug_buffer(const char *file, const char *data, const int length); 37inline void dump_debug_buffer(const char *file, const char *data, const int length);
30#endif 38#endif