diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2014-07-20 21:12:21 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2014-07-20 21:12:21 +0000 |
commit | ed04b2a783f6a54f7fcdf410a1b5397ab7bed128 (patch) | |
tree | da02328c3ef75e05aec97d439c7329229bd3a282 /libgphoto2_port/libusb1 | |
parent | 543f536273c1d78d2166591b3b747e96e92154a5 (diff) | |
download | libgphoto2-ed04b2a783f6a54f7fcdf410a1b5397ab7bed128.tar.gz |
if we do not have libusb_strerror, implement it ourselves
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15092 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2_port/libusb1')
-rw-r--r-- | libgphoto2_port/libusb1/libusb1.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c index 3e9194afc..0daba628a 100644 --- a/libgphoto2_port/libusb1/libusb1.c +++ b/libgphoto2_port/libusb1/libusb1.c @@ -78,13 +78,32 @@ }\ } while(0) +#ifndef HAVE_LIBUSB_STRERROR +static const char *libusb_strerror(int r) +{ + switch (r) { + case LIBUSB_SUCCESS: return "success"; + case LIBUSB_ERROR_INVALID_PARAM: return "invalid parameter"; + case LIBUSB_ERROR_NO_DEVICE: return "no device"; + case LIBUSB_ERROR_TIMEOUT: return "timeout"; + case LIBUSB_ERROR_NO_MEM: return "no memory"; + case LIBUSB_ERROR_NOT_SUPPORTED: return "not supported"; + case LIBUSB_ERROR_IO: return "io error"; + case LIBUSB_ERROR_BUSY: return "busy"; + case LIBUSB_ERROR_NOT_FOUND: return "not found"; + case LIBUSB_ERROR_ACCESS: return "access"; + case LIBUSB_ERROR_OVERFLOW: return "overflow"; + case LIBUSB_ERROR_PIPE: return "pipe"; + case LIBUSB_ERROR_INTERRUPTED: return "interrupted"; + default: return "unknown, fix libusb1.c"; + } +} + +#endif + static int log_on_libusb_error_helper( int _r, const char* func ) { if (_r < LIBUSB_SUCCESS) -#ifdef HAVE_LIBUSB_STRERROR GP_LOG_E ("'%s' failed: %s (%d)", func, libusb_strerror(_r), _r); -#else - GP_LOG_E ("'%s' failed: %d", func, _r); -#endif return _r; } #define LOG_ON_LIBUSB_E( RESULT ) log_on_libusb_error_helper( (RESULT), #RESULT ) |