summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2020-06-08 02:51:40 +0200
committerGravatar Martin Szulecki2020-06-08 02:51:40 +0200
commit6bbe87b6f6c5ef388839ebf64a7d38fcd91468bf (patch)
tree9eda07bb8e765a704f5b8c7dd741fa8549490fa2 /src
parent794e1ec89a61fff4e5ebc9eb522933a5fdbbe676 (diff)
downloadusbmuxd-6bbe87b6f6c5ef388839ebf64a7d38fcd91468bf.tar.gz
usbmuxd-6bbe87b6f6c5ef388839ebf64a7d38fcd91468bf.tar.bz2
Use libusb_set_option() to set debug level depending on libusb version
Diffstat (limited to 'src')
-rw-r--r--src/usb.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/usb.c b/src/usb.c
index 845ac62..de09256 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -3,7 +3,7 @@
*
* Copyright (C) 2009 Hector Martin <hector@marcansoft.com>
* Copyright (C) 2009 Nikias Bassen <nikias@gmx.li>
- * Copyright (C) 2009 Martin Szulecki <opensuse@sukimashita.com>
+ * Copyright (C) 2009-2020 Martin Szulecki <martin.szulecki@libimobiledevice.org>
* Copyright (C) 2014 Mikkel Kamstrup Erlandsen <mikkel.kamstrup@xamarin.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -801,7 +801,11 @@ int usb_init(void)
device_polling = 1;
res = libusb_init(NULL);
+#if LIBUSB_API_VERSION >= 0x01000106
+ libusb_set_option(NULL, LIBUSB_OPTION_LOG_LEVEL, (log_level >= LL_DEBUG ? LIBUSB_LOG_LEVEL_DEBUG: (log_level >= LL_WARNING ? LIBUSB_LOG_LEVEL_WARNING: LIBUSB_LOG_LEVEL_NONE)));
+#else
libusb_set_debug(NULL, (log_level >= LL_DEBUG ? LIBUSB_LOG_LEVEL_DEBUG: (log_level >= LL_WARNING ? LIBUSB_LOG_LEVEL_WARNING: LIBUSB_LOG_LEVEL_NONE)));
+#endif
if(res != 0) {
usbmuxd_log(LL_FATAL, "libusb_init failed: %s", libusb_error_name(res));