diff options
author | Pete Batard <pbatard@gmail.com> | 2010-01-14 01:37:47 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-01-14 01:37:47 +0000 |
commit | e026f61422cd5439eac40a66fd41f7659061e60a (patch) | |
tree | 963770defd4894319516614919f2c0906d3f4718 /libusb/libusbi.h | |
parent | 29ed28f769cf0985c89c739117cd19094c8871c8 (diff) | |
download | libusb-e026f61422cd5439eac40a66fd41f7659061e60a.tar.gz |
svn r59: - MSVC6 fixes for variadic log macros (Michael Plante)
Diffstat (limited to 'libusb/libusbi.h')
-rw-r--r-- | libusb/libusbi.h | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/libusb/libusbi.h b/libusb/libusbi.h index 6b501ae..462e864 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -121,9 +121,13 @@ enum usbi_log_level { LOG_LEVEL_ERROR, }; -void usbi_log(struct libusb_context *ctx, enum usbi_log_level, +void usbi_log(struct libusb_context *ctx, enum usbi_log_level level, const char *function, const char *format, ...); + +#if !defined(_MSC_VER) || _MSC_VER > 1200 + + #ifdef ENABLE_LOGGING #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__) #else @@ -140,6 +144,44 @@ void usbi_log(struct libusb_context *ctx, enum usbi_log_level, #define usbi_warn(ctx, ...) _usbi_log(ctx, LOG_LEVEL_WARNING, __VA_ARGS__) #define usbi_err(ctx, ...) _usbi_log(ctx, LOG_LEVEL_ERROR, __VA_ARGS__) + +#else + + +void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level, + const char *function, const char *format, va_list args); + +#ifdef ENABLE_LOGGING +#define LOG_BODY(ctxt, level) \ +{ \ + va_list args; \ + va_start (args, format); \ + usbi_log_v(ctxt, level, "", format, args); \ + va_end(args); \ +} +#else +#define LOG_BODY(ctxt, level) { } +#endif + +void inline usbi_info(struct libusb_context *ctx, const char *format, ...) + LOG_BODY(ctx,LOG_LEVEL_INFO) +void inline usbi_warn(struct libusb_context *ctx, const char *format, ...) + LOG_BODY(ctx,LOG_LEVEL_WARNING) +void inline usbi_err( struct libusb_context *ctx, const char *format, ...) + LOG_BODY(ctx,LOG_LEVEL_ERROR) + +void inline usbi_dbg(const char *format, ...) +#ifdef ENABLE_DEBUG_LOGGING + LOG_BODY(NULL,LOG_LEVEL_DEBUG) +#else +{ } +#endif + + +#endif + + + #define USBI_GET_CONTEXT(ctx) if (!(ctx)) (ctx) = usbi_default_context #define DEVICE_CTX(dev) ((dev)->ctx) #define HANDLE_CTX(handle) (DEVICE_CTX((handle)->dev)) @@ -817,4 +859,3 @@ extern const struct usbi_os_backend darwin_backend; extern const struct usbi_os_backend windows_backend; #endif - |