diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-06-07 19:07:16 +0100 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2013-06-10 00:16:36 +0100 |
commit | 511ed18228dd097dfe6d5c6fd926eaea24435f64 (patch) | |
tree | feac0f60d3f98ef91aa7413d227fe144cd3f2207 /libusb/libusb.h | |
parent | 3604998dbec67ec098c802416d19cc7e1e93ee02 (diff) | |
download | android_external_libusbx-511ed18228dd097dfe6d5c6fd926eaea24435f64.tar.gz android_external_libusbx-511ed18228dd097dfe6d5c6fd926eaea24435f64.tar.bz2 android_external_libusbx-511ed18228dd097dfe6d5c6fd926eaea24435f64.zip |
Core: Add a libusb_strerror() function
This patch adds the much requested libusb_strerror() function, taking into
account all issues people raised wrt previous attempts.
Criteria / Decisions underlying this implementation:
- Must support translated messages
- Must not use gettext as that does not work well in combination with Windows
(when building with Visual C, or for Windows CE)
- API compatible with FreeBSD and various patched libusb-s floating around
- KISS:
- Do not add any (other) library dependencies
- Do not try to deal with message encodings (iconv), simply always return UTF-8
making encoding the problem of the application using libusb_strerror.
- Defaults to English, so apps which don't want translated messages,
don't need to do anything special
- Defaults to English (with pure ASCII messages), so apps which don't
call libusb_setlocale() don't need to worry about encoding
Diffstat (limited to 'libusb/libusb.h')
-rw-r--r-- | libusb/libusb.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libusb/libusb.h b/libusb/libusb.h index d733c46..a56a687 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -1044,8 +1044,9 @@ enum libusb_bos_type { /** \ingroup misc * Error codes. Most libusbx functions return 0 on success or one of these * codes on failure. - * You can call \ref libusb_error_name() to retrieve a string representation - * of an error code. + * You can call libusb_error_name() to retrieve a string representation of an + * error code or libusb_strerror() to get an end-user suitable description of + * an error code. */ enum libusb_error { /** Success (no error) */ @@ -1087,13 +1088,16 @@ enum libusb_error { /** Operation not supported or unimplemented on this platform */ LIBUSB_ERROR_NOT_SUPPORTED = -12, - /* NB! Remember to update libusb_error_name() - when adding new error codes here. */ + /* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the + message strings in strerror.c when adding new error codes here. */ /** Other error */ LIBUSB_ERROR_OTHER = -99, }; +/* Total number of error codes in enum libusb_error */ +#define LIBUSB_ERROR_COUNT 14 + /** \ingroup asyncio * Transfer status codes */ enum libusb_transfer_status { @@ -1299,6 +1303,8 @@ void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level); const struct libusb_version * LIBUSB_CALL libusb_get_version(void); int LIBUSB_CALL libusb_has_capability(uint32_t capability); const char * LIBUSB_CALL libusb_error_name(int errcode); +int LIBUSB_CALL libusb_setlocale(const char *locale); +const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode); ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx, libusb_device ***list); |