1
commit 7ec94a45ed8155e7a1d4d5d75575099b09c78834
2
Author: Pete Batard <pete@akeo.ie>
3
Date: Mon Jul 2 23:39:19 2012 +0100
5
Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflicts
7
* The LOG_LEVEL_ enums, that were moved to the public API
8
in 933a319469bcccc962031c989e39d9d1f44f2885 may conflict
9
with applications/headers that also define their own
10
LOG_LEVEL_ values internally.
11
* As a matter of fact, as per Trac #31, this produces a
12
conflict with libusb-compat, as it defines its own levels.
14
diff --git a/examples/xusb.c b/examples/xusb.c
15
index 0eafd8c..3e8d262 100644
18
@@ -1021,7 +1021,7 @@ int main(int argc, char** argv)
22
- libusb_set_debug(NULL, debug_mode?LOG_LEVEL_DEBUG:LOG_LEVEL_INFO);
23
+ libusb_set_debug(NULL, debug_mode?LIBUSB_LOG_LEVEL_DEBUG:LIBUSB_LOG_LEVEL_INFO);
25
test_device(VID, PID);
27
diff --git a/libusb/core.c b/libusb/core.c
28
index 8845909..e10d808 100644
31
@@ -1567,11 +1567,11 @@ int API_EXPORTED libusb_attach_kernel_driver(libusb_device_handle *dev,
33
* Set log message verbosity.
35
- * The default level is \ref LOG_LEVEL_NONE, which means no messages are ever
36
+ * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
37
* printed. If you choose to increase the message verbosity level, ensure
38
* that your application does not close the stdout/stderr file descriptors.
40
- * You are advised to use level \ref LOG_LEVEL_WARNING. libusbx is conservative
41
+ * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusbx is conservative
42
* with its message logging and most of the time, will only log messages that
43
* explain error conditions and other oddities. This will help you debug
45
@@ -1636,7 +1636,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
46
memset(ctx, 0, sizeof(*ctx));
48
#ifdef ENABLE_DEBUG_LOGGING
49
- ctx->debug = LOG_LEVEL_DEBUG;
50
+ ctx->debug = LIBUSB_LOG_LEVEL_DEBUG;
54
@@ -1793,7 +1793,7 @@ int usbi_gettimeofday(struct timeval *tp, void *tzp)
58
-void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
59
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
60
const char *function, const char *format, va_list args)
62
const char *prefix = "";
63
@@ -1807,14 +1807,14 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
64
USBI_GET_CONTEXT(ctx);
67
- global_debug = (ctx->debug == LOG_LEVEL_DEBUG);
68
+ global_debug = (ctx->debug == LIBUSB_LOG_LEVEL_DEBUG);
71
- if (level == LOG_LEVEL_WARNING && ctx->debug < LOG_LEVEL_WARNING)
72
+ if (level == LIBUSB_LOG_LEVEL_WARNING && ctx->debug < LIBUSB_LOG_LEVEL_WARNING)
74
- if (level == LOG_LEVEL_INFO && ctx->debug < LOG_LEVEL_INFO)
75
+ if (level == LIBUSB_LOG_LEVEL_INFO && ctx->debug < LIBUSB_LOG_LEVEL_INFO)
77
- if (level == LOG_LEVEL_DEBUG && ctx->debug < LOG_LEVEL_DEBUG)
78
+ if (level == LIBUSB_LOG_LEVEL_DEBUG && ctx->debug < LIBUSB_LOG_LEVEL_DEBUG)
82
@@ -1832,19 +1832,19 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
83
now.tv_usec -= timestamp_origin.tv_usec;
86
- case LOG_LEVEL_INFO:
87
+ case LIBUSB_LOG_LEVEL_INFO:
90
- case LOG_LEVEL_WARNING:
91
+ case LIBUSB_LOG_LEVEL_WARNING:
94
- case LOG_LEVEL_ERROR:
95
+ case LIBUSB_LOG_LEVEL_ERROR:
98
- case LOG_LEVEL_DEBUG:
99
+ case LIBUSB_LOG_LEVEL_DEBUG:
102
- case LOG_LEVEL_NONE:
103
+ case LIBUSB_LOG_LEVEL_NONE:
107
@@ -1863,7 +1863,7 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
108
fprintf(stderr, "\n");
111
-void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
112
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
113
const char *function, const char *format, ...)
116
diff --git a/libusb/libusb.h b/libusb/libusb.h
117
index fd231ea..1dc12f8 100644
118
--- a/libusb/libusb.h
119
+++ b/libusb/libusb.h
120
@@ -951,20 +951,20 @@ enum libusb_capability {
123
* Log message levels.
124
- * - LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
125
- * - LOG_LEVEL_ERROR (1) : error messages are printed to stderr
126
- * - LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
127
- * - LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
128
+ * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
129
+ * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
130
+ * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
131
+ * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
132
* and error messages are printed to stderr
133
- * - LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
134
+ * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
135
* warnings and errors to stderr
137
-enum usbi_log_level {
138
- LOG_LEVEL_NONE = 0,
143
+enum libusb_log_level {
144
+ LIBUSB_LOG_LEVEL_NONE = 0,
145
+ LIBUSB_LOG_LEVEL_ERROR,
146
+ LIBUSB_LOG_LEVEL_WARNING,
147
+ LIBUSB_LOG_LEVEL_INFO,
148
+ LIBUSB_LOG_LEVEL_DEBUG,
151
int LIBUSB_CALL libusb_init(libusb_context **ctx);
152
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
153
index 27362f7..3c4a059 100644
154
--- a/libusb/libusbi.h
155
+++ b/libusb/libusbi.h
156
@@ -130,25 +130,25 @@ static inline void *usbi_reallocf(void *ptr, size_t size)
158
#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
160
-void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
161
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
162
const char *function, const char *format, ...);
164
-void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
165
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
166
const char *function, const char *format, va_list args);
168
#if !defined(_MSC_VER) || _MSC_VER >= 1400
170
#ifdef ENABLE_LOGGING
171
#define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
172
-#define usbi_dbg(...) _usbi_log(NULL, LOG_LEVEL_DEBUG, __VA_ARGS__)
173
+#define usbi_dbg(...) _usbi_log(NULL, LIBUSB_LOG_LEVEL_DEBUG, __VA_ARGS__)
175
#define _usbi_log(ctx, level, ...) do { (void)(ctx); } while(0)
176
#define usbi_dbg(...) do {} while(0)
179
-#define usbi_info(ctx, ...) _usbi_log(ctx, LOG_LEVEL_INFO, __VA_ARGS__)
180
-#define usbi_warn(ctx, ...) _usbi_log(ctx, LOG_LEVEL_WARNING, __VA_ARGS__)
181
-#define usbi_err(ctx, ...) _usbi_log(ctx, LOG_LEVEL_ERROR, __VA_ARGS__)
182
+#define usbi_info(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_INFO, __VA_ARGS__)
183
+#define usbi_warn(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_WARNING, __VA_ARGS__)
184
+#define usbi_err(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_ERROR, __VA_ARGS__)
186
#else /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
188
@@ -166,16 +166,16 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
190
static inline void usbi_info(struct libusb_context *ctx, const char *format,
192
- LOG_BODY(ctx,LOG_LEVEL_INFO)
193
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_INFO)
194
static inline void usbi_warn(struct libusb_context *ctx, const char *format,
196
- LOG_BODY(ctx,LOG_LEVEL_WARNING)
197
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_WARNING)
198
static inline void usbi_err( struct libusb_context *ctx, const char *format,
200
- LOG_BODY(ctx,LOG_LEVEL_ERROR)
201
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_ERROR)
203
static inline void usbi_dbg(const char *format, ...)
204
- LOG_BODY(NULL,LOG_LEVEL_DEBUG)
205
+ LOG_BODY(NULL,LIBUSB_LOG_LEVEL_DEBUG)
207
#endif /* !defined(_MSC_VER) || _MSC_VER >= 1400 */