summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2012-07-02 23:39:19 +0100
committerPete Batard <pete@akeo.ie>2012-07-03 11:01:41 +0100
commit7ec94a45ed8155e7a1d4d5d75575099b09c78834 (patch)
treeac57151fceac382b0e80567f2563bb44efb88e91
parent63f569be66a40a720bb797a87c3589f3e4de925a (diff)
downloadlibusb-7ec94a45ed8155e7a1d4d5d75575099b09c78834.tar.gz
Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflicts
* The LOG_LEVEL_ enums, that were moved to the public API in 933a319469bcccc962031c989e39d9d1f44f2885 may conflict with applications/headers that also define their own LOG_LEVEL_ values internally. * As a matter of fact, as per Trac #31, this produces a conflict with libusb-compat, as it defines its own levels.
-rw-r--r--examples/xusb.c2
-rw-r--r--libusb/core.c28
-rw-r--r--libusb/libusb.h22
-rw-r--r--libusb/libusbi.h20
-rw-r--r--libusb/version_nano.h2
5 files changed, 37 insertions, 37 deletions
diff --git a/examples/xusb.c b/examples/xusb.c
index 0eafd8c..3e8d262 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -1021,7 +1021,7 @@ int main(int argc, char** argv)
if (r < 0)
return r;
- libusb_set_debug(NULL, debug_mode?LOG_LEVEL_DEBUG:LOG_LEVEL_INFO);
+ libusb_set_debug(NULL, debug_mode?LIBUSB_LOG_LEVEL_DEBUG:LIBUSB_LOG_LEVEL_INFO);
test_device(VID, PID);
diff --git a/libusb/core.c b/libusb/core.c
index 8845909..e10d808 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -1567,11 +1567,11 @@ int API_EXPORTED libusb_attach_kernel_driver(libusb_device_handle *dev,
/** \ingroup lib
* Set log message verbosity.
*
- * The default level is \ref LOG_LEVEL_NONE, which means no messages are ever
+ * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
* printed. If you choose to increase the message verbosity level, ensure
* that your application does not close the stdout/stderr file descriptors.
*
- * You are advised to use level \ref LOG_LEVEL_WARNING. libusbx is conservative
+ * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusbx is conservative
* with its message logging and most of the time, will only log messages that
* explain error conditions and other oddities. This will help you debug
* your software.
@@ -1636,7 +1636,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
memset(ctx, 0, sizeof(*ctx));
#ifdef ENABLE_DEBUG_LOGGING
- ctx->debug = LOG_LEVEL_DEBUG;
+ ctx->debug = LIBUSB_LOG_LEVEL_DEBUG;
#endif
dbg = getenv("LIBUSB_DEBUG");
@@ -1793,7 +1793,7 @@ int usbi_gettimeofday(struct timeval *tp, void *tzp)
}
#endif
-void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, va_list args)
{
const char *prefix = "";
@@ -1807,14 +1807,14 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
USBI_GET_CONTEXT(ctx);
if (ctx == NULL)
return;
- global_debug = (ctx->debug == LOG_LEVEL_DEBUG);
+ global_debug = (ctx->debug == LIBUSB_LOG_LEVEL_DEBUG);
if (!ctx->debug)
return;
- if (level == LOG_LEVEL_WARNING && ctx->debug < LOG_LEVEL_WARNING)
+ if (level == LIBUSB_LOG_LEVEL_WARNING && ctx->debug < LIBUSB_LOG_LEVEL_WARNING)
return;
- if (level == LOG_LEVEL_INFO && ctx->debug < LOG_LEVEL_INFO)
+ if (level == LIBUSB_LOG_LEVEL_INFO && ctx->debug < LIBUSB_LOG_LEVEL_INFO)
return;
- if (level == LOG_LEVEL_DEBUG && ctx->debug < LOG_LEVEL_DEBUG)
+ if (level == LIBUSB_LOG_LEVEL_DEBUG && ctx->debug < LIBUSB_LOG_LEVEL_DEBUG)
return;
#endif
@@ -1832,19 +1832,19 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
now.tv_usec -= timestamp_origin.tv_usec;
switch (level) {
- case LOG_LEVEL_INFO:
+ case LIBUSB_LOG_LEVEL_INFO:
prefix = "info";
break;
- case LOG_LEVEL_WARNING:
+ case LIBUSB_LOG_LEVEL_WARNING:
prefix = "warning";
break;
- case LOG_LEVEL_ERROR:
+ case LIBUSB_LOG_LEVEL_ERROR:
prefix = "error";
break;
- case LOG_LEVEL_DEBUG:
+ case LIBUSB_LOG_LEVEL_DEBUG:
prefix = "debug";
break;
- case LOG_LEVEL_NONE:
+ case LIBUSB_LOG_LEVEL_NONE:
break;
default:
prefix = "unknown";
@@ -1863,7 +1863,7 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
fprintf(stderr, "\n");
}
-void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, ...)
{
va_list args;
diff --git a/libusb/libusb.h b/libusb/libusb.h
index fd231ea..1dc12f8 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -951,20 +951,20 @@ enum libusb_capability {
/** \ingroup lib
* Log message levels.
- * - LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
- * - LOG_LEVEL_ERROR (1) : error messages are printed to stderr
- * - LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
- * - LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
+ * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
+ * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
+ * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
+ * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
* and error messages are printed to stderr
- * - LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
+ * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
* warnings and errors to stderr
*/
-enum usbi_log_level {
- LOG_LEVEL_NONE = 0,
- LOG_LEVEL_ERROR,
- LOG_LEVEL_WARNING,
- LOG_LEVEL_INFO,
- LOG_LEVEL_DEBUG,
+enum libusb_log_level {
+ LIBUSB_LOG_LEVEL_NONE = 0,
+ LIBUSB_LOG_LEVEL_ERROR,
+ LIBUSB_LOG_LEVEL_WARNING,
+ LIBUSB_LOG_LEVEL_INFO,
+ LIBUSB_LOG_LEVEL_DEBUG,
};
int LIBUSB_CALL libusb_init(libusb_context **ctx);
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
index 27362f7..3c4a059 100644
--- a/libusb/libusbi.h
+++ b/libusb/libusbi.h
@@ -130,25 +130,25 @@ static inline void *usbi_reallocf(void *ptr, size_t size)
#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
-void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, ...);
-void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, va_list args);
#if !defined(_MSC_VER) || _MSC_VER >= 1400
#ifdef ENABLE_LOGGING
#define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
-#define usbi_dbg(...) _usbi_log(NULL, LOG_LEVEL_DEBUG, __VA_ARGS__)
+#define usbi_dbg(...) _usbi_log(NULL, LIBUSB_LOG_LEVEL_DEBUG, __VA_ARGS__)
#else
#define _usbi_log(ctx, level, ...) do { (void)(ctx); } while(0)
#define usbi_dbg(...) do {} while(0)
#endif
-#define usbi_info(ctx, ...) _usbi_log(ctx, LOG_LEVEL_INFO, __VA_ARGS__)
-#define usbi_warn(ctx, ...) _usbi_log(ctx, LOG_LEVEL_WARNING, __VA_ARGS__)
-#define usbi_err(ctx, ...) _usbi_log(ctx, LOG_LEVEL_ERROR, __VA_ARGS__)
+#define usbi_info(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_INFO, __VA_ARGS__)
+#define usbi_warn(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_WARNING, __VA_ARGS__)
+#define usbi_err(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_ERROR, __VA_ARGS__)
#else /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
@@ -166,16 +166,16 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
static inline void usbi_info(struct libusb_context *ctx, const char *format,
...)
- LOG_BODY(ctx,LOG_LEVEL_INFO)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_INFO)
static inline void usbi_warn(struct libusb_context *ctx, const char *format,
...)
- LOG_BODY(ctx,LOG_LEVEL_WARNING)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_WARNING)
static inline void usbi_err( struct libusb_context *ctx, const char *format,
...)
- LOG_BODY(ctx,LOG_LEVEL_ERROR)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_ERROR)
static inline void usbi_dbg(const char *format, ...)
- LOG_BODY(NULL,LOG_LEVEL_DEBUG)
+ LOG_BODY(NULL,LIBUSB_LOG_LEVEL_DEBUG)
#endif /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 6df4602..6fc6748 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10536
+#define LIBUSB_NANO 10537