summaryrefslogtreecommitdiff
path: root/libusb/strerror.c
Commit message (Collapse)AuthorAgeFilesLines
* Doxygen: Add references to LIBUSB_ERROR codesLudovic Rousseau2022-06-261-3/+3
| | | | Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
* core: Fix some minor inconsistencies in API and codingChris Dickens2020-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | All of the API functions should take the typedef'ed versions of the opaque libusb structures, but some recent additions to the API did not follow this convention. Fix this by making the changes to the declarations and definitions of the functions. Make the placement of the asterisk in pointer variable declarations consistent (always with the variable name, not the type). Remove some unnecessary casts and initializations relating to dynamically allocated memory. While at it, make casts within the core library consistent in style with no space after the closing parenthesis of the cast. Most of the core already used this style. When using the 'sizeof' operator, dereference the pointer instead of using the type. Most of the core was already doing this, so fix up the few places that weren't. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* automake: Add extra Makefile to handle unknown automake targetsChris Dickens2020-04-011-0/+0
| | | | | | | | | | | | Automake does not know how to compile Windows Resource files, so we have manually told automake how to do this. One particular short-coming is that dependencies are not automatically generated and tracked as they are with other known automake targets. Address this by creating an extra makefile that contains the automake rules needed for building source for Windows targets. This also includes outputting more accurate tags during compilation instead of using the generic "GEN" tag. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* strerror: Micro-optimize implementation and remove use of strncasecmp()Chris Dickens2020-03-261-24/+18
| | | | | | | | | | | | | | | | | When comparing the user-provided locale string in libusb_setlocale(), we only care about the first two characters. The lookup strings within libusb are always lowercase, so simplify the comparison by directly comparing the result of tolower(). This removes the need for strncasecmp() which was not able to be cleanly included in the first place. Rather than storing an index into the array of localized strings, store a pointer to the selected sub-array instead. This trims the generated code of libusb_strerror() by nearly half as loads can be dropped. Also constify the arrays of strings as they should not be mutable. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Trim and consolidate header file usageChris Dickens2020-01-241-7/+3
| | | | | | | | | | | | | Refactor libusbi.h to include the set of common header files needed by every main source file in the library and change these source files to include libusbi.h first, followed by any non-common headers. Including libusbi.h first ensures that the config definitions are pulled in and will eliminate redundant includes in the individual sources files. Also clean up some whitespace errors and remove unnecessary definitions in the manually generated config.h files. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Change the errcode argument in libusb_strerror to be of type intVladimirTechMan2020-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It would be more convenient in practice if the type of error code argument in libusb_strerror was declared as "int", rather than enum libusb_error: In practice, the value for the argument almost always comes from a value returned by libusb function, thus its type is "int" at that point. In which case, depending on the checks enabled when compiling the C or C++ code of applications using libusb's API, every call to libusb_strerror often requires explicit type casting – while not a biggie, it gets inconvenient as the number of logging calls using libusb_strerror grows. It is worth of noting that the "peer" function libusb_error_name already takes the int-type argument, thus eliminating the need in extra value casting. Aligning the signature of libusb_strerror to be the same would also improve the consistency between those two parts of the libusb API. Given that libusb_strerror does a range validation of its argument value, there should not be any real drawbacks or negative effects from "relaxing" the type declaration from enumeration to integer. The existing application code that already does explicit casting to enum, will keep compiling and running like before. Closes #606 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Hungarian translationBence Cs2018-12-051-1/+16
| | | | | | Closes #493 Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
* Fixed typo in the documentationsaur0n2018-12-051-1/+1
| | | | | | Closes #496 Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
* Add German translationAlexander Schlarb2018-10-221-1/+17
| | | | | | | | Most strings were copied from the german `strerror` output on equivallent `errno` values and then adapted as necessary. Closes #446 Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
* Misc: Prefix doxygen references in order to namespace libusbChris Dickens2016-02-241-3/+3
| | | | | | | | | | | This change add "libusb_" to every group and page definition (and updates all references accordingly) so that generated man pages are namespaced for libusb, thus avoiding possible conflict with other packages. Closes #131 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* haiku: Add Haiku supportAkshay Jaggi2014-09-251-0/+3
|
* core: Make use of headers consistent across all filesChris Dickens2014-09-061-2/+2
| | | | | | | | * Include config.h before anything else in all files * Remove unnecessary inclusion of libusb.h * Use angle brackets for system headers and quotes for local headers Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* strerrror.c: Add Russian translationЛарионов Даниил2014-05-191-2/+17
| | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Misc: Revert all references to libusb/libusb.infohjelmn@cs.unm.edu2014-01-081-2/+2
|
* fixed some clang -Wdocumentation warnings from bad doxygen markupSean McBride2013-07-301-1/+1
|
* Core: fix another compiler warning in libusb_setlocale()Pete Batard2013-06-191-1/+1
| | | | | * VS2012 (64 bit) produces the following in strerror.c(156): warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
* Core: fix compiler warning in libusb_setlocale()Ludovic Rousseau2013-06-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Hello, A small patch for: strerror.c: In function 'libusb_setlocale': strerror.c:148: warning: comparison between signed and unsigned strerror.c:152: warning: comparison between signed and unsigned -- Dr. Ludovic Rousseau From a4144845845cd0a06fb9074ba2d6669ece3a5b1a Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau <ludovic.rousseau+github@gmail.com> Date: Wed, 19 Jun 2013 13:16:31 +0200 Subject: [PATCH] Core: fix compiler warning in libusb_setlocale() strerror.c: In function 'libusb_setlocale': strerror.c:148: warning: comparison between signed and unsigned strerror.c:152: warning: comparison between signed and unsigned Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Core: Add a libusb_strerror() functionHans de Goede2013-06-101-0/+184
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