On Mac, `snprintf` function is not easily available
if source is compiled with `_POSIX_C_SOURCE=199309L`.
We only used `snprintf` in 2 places with well known buffer length,
so using `sprintf` instead of `snprintf` should not make it any less secure,
but it allows to enable `_POSIX_C_SOURCE`.
This should unblock https://github.com/mvp/uhubctl/pull/15.
Furthermore add the Lenovo ThinkPad EU Ultra Dockingstation (40A20090EU)
as a supported device.
Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
Since libusb version 1.0.16 the libusb_get_port_path function is
deprecated. As we need to support also older version of libusb we
replace it with libusb_get_port_numbers when possible. This is done by
checking the LIBUSB_API_VERSION (as recommended by libusb).
Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
Add an include for the unistd.h. This fixes following
implicit-function-declaration gcc warnings for (u)sleep:
uhubctl.c: In function 'main':
uhubctl.c:543:33: warning: implicit declaration of function 'usleep'
[-Wimplicit-function-declaration]
usleep(opt_wait * 1000);
^
uhubctl.c:549:21: warning: implicit declaration of function 'sleep'
[-Wimplicit-function-declaration]
sleep(opt_delay);
^
Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
Add cross-compile functionality to the Makefile and add an "install"
target. This makes uhubctl "Yocto Project Compatible".
Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
Apparently, even some modern Linux systems (e.g. Centos 7)
still have very old libusb versions installed (e.g. 1.0.15).
To solve this, instead of libusb_get_port_numbers()
use equivalent deprecated API libusb_get_port_path()
which was introduced in libusb 1.0.12.