├── .private ├── README.txt ├── bd.cmd ├── bm.sh ├── post-rewrite.sh ├── pre-commit.sh └── wbs.txt ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── INSTALL_WIN.txt ├── Makefile.am ├── NEWS ├── PORTING ├── README ├── README.git ├── THANKS ├── TODO ├── autogen.sh ├── bootstrap.sh ├── configure.ac ├── doc ├── Makefile.am ├── doxygen.cfg.in └── libusbx.png ├── examples ├── Makefile.am ├── dpfp.c ├── dpfp_threaded.c ├── ezusb.c ├── ezusb.h ├── fxload.c ├── getopt │ ├── getopt.c │ ├── getopt.h │ └── getopt1.c ├── listdevs.c └── xusb.c ├── libusb-1.0.pc.in ├── libusb ├── Makefile.am ├── core.c ├── descriptor.c ├── io.c ├── libusb-1.0.def ├── libusb-1.0.rc ├── libusb.h ├── libusbi.h ├── os │ ├── darwin_usb.c │ ├── darwin_usb.h │ ├── linux_usbfs.c │ ├── linux_usbfs.h │ ├── openbsd_usb.c │ ├── poll_posix.h │ ├── poll_windows.c │ ├── poll_windows.h │ ├── threads_posix.c │ ├── threads_posix.h │ ├── threads_windows.c │ ├── threads_windows.h │ ├── windows_usb.c │ └── windows_usb.h ├── sync.c ├── version.h └── version_nano.h ├── msvc ├── config.h ├── ddk_build.cmd ├── fxload_2010.vcxproj ├── fxload_2010.vcxproj.filters ├── fxload_2012.vcxproj ├── fxload_2012.vcxproj.filters ├── fxload_sources ├── getopt_2005.vcproj ├── getopt_2010.vcxproj ├── getopt_2010.vcxproj.filters ├── getopt_2012.vcxproj ├── getopt_2012.vcxproj.filters ├── getopt_sources ├── inttypes.h ├── libusb_dll.dsp ├── libusb_dll_2005.vcproj ├── libusb_dll_2010.vcxproj ├── libusb_dll_2010.vcxproj.filters ├── libusb_dll_2012.vcxproj ├── libusb_dll_2012.vcxproj.filters ├── libusb_sources ├── libusb_static.dsp ├── libusb_static_2005.vcproj ├── libusb_static_2010.vcxproj ├── libusb_static_2010.vcxproj.filters ├── libusb_static_2012.vcxproj ├── libusb_static_2012.vcxproj.filters ├── libusbx.dsw ├── libusbx_2005.sln ├── libusbx_2010.sln ├── libusbx_2012.sln ├── listdevs.dsp ├── listdevs_2005.vcproj ├── listdevs_2010.vcxproj ├── listdevs_2010.vcxproj.filters ├── listdevs_2012.vcxproj ├── listdevs_2012.vcxproj.filters ├── listdevs_sources ├── stdint.h ├── stress_2005.vcproj ├── stress_2010.vcxproj ├── stress_2010.vcxproj.filters ├── stress_2012.vcxproj ├── stress_2012.vcxproj.filters ├── xusb.dsp ├── xusb_2005.vcproj ├── xusb_2010.vcxproj ├── xusb_2010.vcxproj.filters ├── xusb_2012.vcxproj ├── xusb_2012.vcxproj.filters └── xusb_sources └── tests ├── Makefile.am ├── libusbx_testlib.h ├── stress.c └── testlib.c /.private/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains private internal scripts used by the libusbx 2 | project maintainers. 3 | 4 | These scripts are not intended for general usage and will not be 5 | exported when producing release archives. 6 | -------------------------------------------------------------------------------- /.private/bd.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem produce the DDK binary files for snapshots 3 | rem !!!THIS SCRIPT IS FOR INTERNAL DEVELOPER USE ONLY!!! 4 | 5 | if NOT x%DDK_TARGET_OS%==xWinXP goto usage 6 | 7 | set PWD=%~dp0 8 | cd .. 9 | mkdir E:\dailies\%DATE% 10 | for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A 11 | for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A\static 12 | for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A\dll 13 | for %%A in (source bin32 bin64) do mkdir E:\dailies\%DATE%\examples\%%A 14 | copy examples\listdevs.c E:\dailies\%DATE%\examples\source 15 | copy examples\xusb.c E:\dailies\%DATE%\examples\source 16 | copy examples\ezusb.? E:\dailies\%DATE%\examples\source 17 | copy examples\fxload.c E:\dailies\%DATE%\examples\source 18 | copy msvc\stdint.h E:\dailies\%DATE%\examples\source 19 | copy .private\wbs.txt E:\dailies\%DATE%\README.txt 20 | 21 | set ORG_BUILD_ALT_DIR=%BUILD_ALT_DIR% 22 | set ORG_BUILDARCH=%_BUILDARCH% 23 | set ORG_PATH=%PATH% 24 | set ORG_BUILD_DEFAULT_TARGETS=%BUILD_DEFAULT_TARGETS% 25 | 26 | set 386=1 27 | set AMD64= 28 | set BUILD_DEFAULT_TARGETS=-386 29 | set _AMD64bit= 30 | set _BUILDARCH=x86 31 | set PATH=%BASEDIR%\bin\x86;%BASEDIR%\bin\x86\x86 32 | 33 | cd msvc 34 | call ddk_build 35 | cd .. 36 | 37 | @echo off 38 | copy Win32\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS32\static 39 | copy Win32\Release\examples\listdevs.exe E:\dailies\%DATE%\examples\bin32 40 | copy Win32\Release\examples\xusb.exe E:\dailies\%DATE%\examples\bin32 41 | copy Win32\Release\examples\fxload.exe E:\dailies\%DATE%\examples\bin32 42 | 43 | cd msvc 44 | call ddk_build DLL 45 | cd .. 46 | 47 | @echo off 48 | copy Win32\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS32\dll 49 | copy Win32\Release\dll\libusb-1.0.dll E:\dailies\%DATE%\MS32\dll 50 | 51 | set 386= 52 | set AMD64=1 53 | set BUILD_DEFAULT_TARGETS=-amd64 54 | set _AMD64bit=true 55 | set _BUILDARCH=AMD64 56 | set PATH=%BASEDIR%\bin\x86\amd64;%BASEDIR%\bin\x86 57 | 58 | cd msvc 59 | call ddk_build 60 | cd .. 61 | 62 | @echo off 63 | copy x64\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS64\static 64 | copy x64\Release\examples\listdevs.exe E:\dailies\%DATE%\examples\bin64 65 | copy x64\Release\examples\xusb.exe E:\dailies\%DATE%\examples\bin64 66 | copy x64\Release\examples\fxload.exe E:\dailies\%DATE%\examples\bin64 67 | 68 | cd msvc 69 | call ddk_build DLL 70 | cd .. 71 | 72 | @echo off 73 | copy x64\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS64\dll 74 | copy x64\Release\dll\libusb-1.0.dll E:\dailies\%DATE%\MS64\dll 75 | 76 | set BUILD_ALT_DIR=%ORG_BUILD_ALT_DIR% 77 | set _BUILDARCH=%ORG_BUILDARCH% 78 | set PATH=%ORG_PATH% 79 | set BUILD_DEFAULT_TARGETS=%ORG_BUILD_DEFAULT_TARGETS% 80 | 81 | goto done 82 | 83 | :usage 84 | echo must be run in a WXP build environment! 85 | 86 | :done 87 | cd %PWD% -------------------------------------------------------------------------------- /.private/bm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # produce the MinGW binary files for snapshots 3 | # !!!THIS SCRIPT IS FOR INTERNAL DEVELOPER USE ONLY!!! 4 | 5 | PWD=`pwd` 6 | cd .. 7 | date=`date +%Y.%m.%d` 8 | target=e:/dailies/$date 9 | mkdir -p $target/include/libusbx-1.0 10 | cp -v libusb/libusb-1.0.def $target 11 | cp -v libusb/libusb.h $target/include/libusbx-1.0 12 | 13 | # 14 | # 32 bit binaries 15 | # 16 | target=e:/dailies/$date/MinGW32 17 | git clean -fdx 18 | # Not using debug (-g) in CFLAGS DRAMATICALLY reduces the size of the binaries 19 | export CFLAGS="-O2 -m32" 20 | export LDFLAGS="-m32" 21 | export RCFLAGS="--target=pe-i386" 22 | export DLLTOOLFLAGS="-m i386 -f --32" 23 | echo `pwd` 24 | (glibtoolize --version) < /dev/null > /dev/null 2>&1 && LIBTOOLIZE=glibtoolize || LIBTOOLIZE=libtoolize 25 | $LIBTOOLIZE --copy --force || exit 1 26 | aclocal || exit 1 27 | autoheader || exit 1 28 | autoconf || exit 1 29 | automake -a -c || exit 1 30 | ./configure 31 | make -j2 32 | mkdir -p $target/static 33 | mkdir -p $target/dll 34 | cp -v libusb/.libs/libusb-1.0.a $target/static 35 | cp -v libusb/.libs/libusb-1.0.dll $target/dll 36 | cp -v libusb/.libs/libusb-1.0.dll.a $target/dll 37 | make clean -j2 38 | 39 | # 40 | # 64 bit binaries 41 | # 42 | target=e:/dailies/$date/MinGW64 43 | export CFLAGS="-O2" 44 | export LDFLAGS="" 45 | export RCFLAGS="" 46 | export DLLTOOLFLAGS="" 47 | ./configure 48 | make -j2 49 | mkdir -p $target/static 50 | mkdir -p $target/dll 51 | cp -v libusb/.libs/libusb-1.0.a $target/static 52 | cp -v libusb/.libs/libusb-1.0.dll $target/dll 53 | cp -v libusb/.libs/libusb-1.0.dll.a $target/dll 54 | cd $PWD -------------------------------------------------------------------------------- /.private/post-rewrite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Detect amended commits and warn user if .amend is missing 4 | # 5 | # To have git run this script on commit, create a "post-rewrite" text file in 6 | # .git/hooks/ with the following content: 7 | # #!/bin/sh 8 | # if [ -x .private/post-rewrite.sh ]; then 9 | # source .private/post-rewrite.sh 10 | # fi 11 | # 12 | # NOTE: These versioning hooks are intended to be used *INTERNALLY* by the 13 | # libusbx development team and are NOT intended to solve versioning for any 14 | # derivative branch, such as one you would create for private development. 15 | # 16 | 17 | case "$1" in 18 | amend) 19 | # Check if a .amend exists. If none, create one and warn user to re-commit. 20 | if [ -f .amend ]; then 21 | rm .amend 22 | else 23 | echo "Amend commit detected, but no .amend file - One has now been created." 24 | echo "Please re-commit as is (amend), so that the version number is correct." 25 | touch .amend 26 | fi ;; 27 | *) ;; 28 | esac 29 | -------------------------------------------------------------------------------- /.private/pre-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Sets the nano version according to the number of commits on this branch, as 4 | # well as the branch offset. 5 | # 6 | # To have git run this script on commit, first make sure you change 7 | # BRANCH_OFFSET to 60000 or higher, then create a "pre-commit" text file in 8 | # .git/hooks/ with the following content: 9 | # #!/bin/sh 10 | # if [ -x .private/pre-commit.sh ]; then 11 | # source .private/pre-commit.sh 12 | # fi 13 | # 14 | # NOTE: These versioning hooks are intended to be used *INTERNALLY* by the 15 | # libusbx development team and are NOT intended to solve versioning for any 16 | # derivative branch, such as one you would create for private development. 17 | # 18 | # Should you wish to reuse these scripts for your own versioning, in your own 19 | # private branch, we kindly ask you to first set BRANCH_OFFSET to 60000, or 20 | # higher, as any offset below below 60000 is *RESERVED* for libusbx official 21 | # usage. 22 | 23 | ################################################################################ 24 | ## YOU *MUST* SET THE FOLLOWING TO 60000 OR HIGHER IF YOU REUSE THIS SCRIPT ## 25 | ################################################################################ 26 | BRANCH_OFFSET=10000 27 | ################################################################################ 28 | 29 | type -P git &>/dev/null || { echo "git command not found. Aborting." >&2; exit 1; } 30 | 31 | NANO=`git log --oneline | wc -l` 32 | NANO=`expr $NANO + $BRANCH_OFFSET` 33 | # Amended commits need to have the nano corrected. Current versions of git hooks 34 | # only allow detection of amending post commit, so we require a .amend file, 35 | # which will be created post commit with a user warning if none exists when an 36 | # amend is detected. 37 | if [ -f .amend ]; then 38 | NANO=`expr $NANO - 1` 39 | fi 40 | echo "setting nano to $NANO" 41 | echo "#define LIBUSB_NANO $NANO" > libusb/version_nano.h 42 | git add libusb/version_nano.h 43 | -------------------------------------------------------------------------------- /.private/wbs.txt: -------------------------------------------------------------------------------- 1 | libusbx 1.0 Windows binary snapshot - README 2 | 3 | ********************************************************************* 4 | * The latest version of this snapshot can always be downloaded at: * 5 | * https://sourceforge.net/projects/libusbx/files/ * 6 | ********************************************************************* 7 | 8 | o Visual Studio: 9 | - Open existing or create a new project for your application 10 | - Copy libusb.h, from the include\libusbx-1.0\ directory, into your project and 11 | make sure that the location where the file reside appears in the 'Additional 12 | Include Directories' section (Configuration Properties -> C/C++ -> General). 13 | - Copy the relevant .lib file from MS32\ or MS64\ and add 'libusb-1.0.lib' to 14 | your 'Additional Dependencies' (Configuration Properties -> Linker -> Input) 15 | Also make sure that the directory where libusb-1.0.lib resides is added to 16 | 'Additional Library Directories' (Configuration Properties -> Linker 17 | -> General) 18 | - If you use the static version of the libusbx library, make sure that 19 | 'Runtime Library' is set to 'Multi-threaded DLL (/MD)' (Configuration 20 | Properties -> C/C++ -> Code Generation). 21 | NB: If your application requires /MT (Multi-threaded/libCMT), you need to 22 | recompile a static libusbx 1.0 library from source. 23 | - Compile and run your application. If you use the DLL version of libusb-1.0, 24 | remember that you need to have a copy of the DLL either in the runtime 25 | directory or in system32 26 | 27 | o WDK/DDK: 28 | - The following is an example of a sources files that you can use to compile 29 | a libusbx 1.0 based console application. In this sample ..\libusbx\ is the 30 | directory where you would have copied libusb.h as well as the relevant 31 | libusb-1.0.lib 32 | 33 | TARGETNAME=your_app 34 | TARGETTYPE=PROGRAM 35 | USE_MSVCRT=1 36 | UMTYPE=console 37 | INCLUDES=..\libusbx;$(DDK_INC_PATH) 38 | TARGETLIBS=..\libusbx\libusb-1.0.lib 39 | SOURCES=your_app.c 40 | 41 | - Note that if you plan to use libCMT instead of MSVCRT (USE_LIBCMT=1 instead 42 | of USE_MSVCRT=1), you will need to recompile libusbx to use libCMT. This can 43 | easily be achieved, in the DDK environment, by running 'ddk_build /MT' 44 | 45 | o MinGW/cygwin 46 | - Copy libusb.h, from include/libusbx-1.0/ to your default include directory, 47 | and copy the MinGW32/ or MinGW64/ .a files to your default library directory. 48 | Or, if you don't want to use the default locations, make sure that you feed 49 | the relevant -I and -L options to the compiler. 50 | - Add the '-lusb-1.0' linker option when compiling. 51 | 52 | o Additional information: 53 | - The libusbx 1.0 API documentation can be accessed at: 54 | http://api.libusbx.org 55 | - For some libusb samples (including source), please have a look in examples/ 56 | - For additional information on the libusbx 1.0 Windows backend please visit: 57 | http://windows.libusbx.org 58 | - The MinGW and MS generated DLLs are fully interchangeable, provided that you 59 | use the import libs provided or generate one from the .def also provided. 60 | - If you find any issue, please visit http://libusbx.org/ and check the 61 | Support section 62 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Copyright © 2001 Johannes Erdfelt 2 | Copyright © 2007-2009 Daniel Drake 3 | Copyright © 2010-2012 Peter Stuge 4 | Copyright © 2008-2011 Nathan Hjelm 5 | Copyright © 2009-2012 Pete Batard 6 | Copyright © 2009-2012 Ludovic Rousseau 7 | Copyright © 2010-2012 Michael Plante 8 | Copyright © 2011-2012 Hans de Goede 9 | Copyright © 2012 Martin Pieuchot 10 | 11 | Other contributors: 12 | Alan Ott 13 | Alan Stern 14 | Alex Vatchenko 15 | Anthony Clay 16 | Artem Egorkine 17 | Aurelien Jarno 18 | Bastien Nocera 19 | Dave Camarillo 20 | David Engraf 21 | David Moore 22 | Davidlohr Bueso 23 | Felipe Balbi 24 | Francesco Montorsi 25 | Graeme Gill 26 | Hans Ulrich Niedermann 27 | Hector Martin 28 | Hoi-Ho Chan 29 | James Hanko 30 | Konrad Rzepecki 31 | Lars Wirzenius 32 | Martin Koegler 33 | Matthias Bolte 34 | Mike Frysinger 35 | Mikhail Gusarov 36 | Nicholas Corgan 37 | Orin Eman 38 | Pekka Nikander 39 | Rob Walker 40 | Sean McBride 41 | Sebastian Pipping 42 | Simon Haggett 43 | Thomas Röfer 44 | Toby Gray 45 | Toby Peterson 46 | Trygve Laugstøl 47 | Uri Lublin 48 | Vasily Khoruzhick 49 | Vitali Lovich 50 | Xiaofan Chen 51 | Роман Донченко 52 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | For detailed information about the changes below, please see the git log or 2 | visit: http://log.libusbx.org 3 | 4 | 2012-09-26: v1.0.14 5 | * Reverts the previous API change with regards to bMaxPower. 6 | If this doesn't matter to you, you are encouraged to keep using v1.0.13, 7 | as it will use the same attribute as v2.0, to be released soon. 8 | * Note that LIBUSBX_API_VERSION is *decreased* to 0x010000FF and the previous 9 | guidelines with regards to concurent use of MaxPower/bMaxPower still apply. 10 | 11 | 2012-09-20: v1.0.13 12 | * [MAJOR] Fix a typo in the API with struct libusb_config_descriptor where 13 | MaxPower was used instead of bMaxPower, as defined in the specs. If your 14 | application was accessing the MaxPower attribute, and you need to maintain 15 | compatibility with libusb or older versions, see APPENDIX A below. 16 | * Fix broken support for the 0.1 -> 1.0 libusb-compat layer 17 | * Fix unwanted cancellation of pending timeouts as well as major timeout related bugs 18 | * Fix handling of HID and composite devices on Windows 19 | * Introduce LIBUSBX_API_VERSION macro 20 | * Add Cypress FX/FX2 firmware upload sample, based on fxload from 21 | http://linux-hotplug.sourceforge.net 22 | * Add libusb0 (libusb-win32) and libusbK driver support on Windows. Note that while 23 | the drivers allow it, isochronous transfers are not supported yet in libusbx. Also 24 | not supported yet is the use of libusb-win32 filter drivers on composite interfaces 25 | * Add support for the new get_capabilities ioctl on Linux and avoid unnecessary 26 | splitting of bulk transfers 27 | * Improve support for newer Intel and Renesas USB 3.0 controllers on Windows 28 | * Harmonize the device number for root hubs across platforms 29 | * Other bug fixes and improvements 30 | 31 | 2012-06-15: v1.0.12 32 | * Fix a potential major regression with pthread on Linux 33 | * Fix missing thread ID from debug log output on cygwin 34 | * Fix possible crash when using longjmp and MinGW's gcc 4.6 35 | * Add topology calls: libusb_get_port_number(), libusb_get_parent() & libusb_get_port_path() 36 | * Add toggleable debug, using libusb_set_debug() or the LIBUSB_DEBUG environment variable 37 | * Define log levels in libusb.h and set timestamp origin to first libusb_init() call 38 | * All logging is now sent to to stderr (info was sent to stdout previously) 39 | * Update log messages severity and avoid polluting log output on OS-X 40 | * Add HID driver support on Windows 41 | * Enable interchangeability of MSVC and MinGW DLLs 42 | * Additional bug fixes and improvements 43 | 44 | 2012-05-08: v1.0.11 45 | * Revert removal of critical Windows event handling that was introduced in 1.0.10 46 | * Fix a possible deadlock in Windows when submitting transfers 47 | * Add timestamped logging 48 | * Add NetBSD support (experimental) and BSD libusb_get_device_speed() data 49 | * Add bootstrap.sh alongside autogen.sh (bootstrap.sh doesn't invoke configure) 50 | * Search for device nodes in /dev for Android support 51 | * Other bug fixes 52 | 53 | 2012-04-17: v1.0.10 54 | * Public release 55 | * Add libusb_get_version 56 | * Add Visual Studio 2010 project files 57 | * Some Windows code cleanup 58 | * Fix xusb sample warnings 59 | 60 | 2012-04-02: v1.0.9 61 | * First libusbx release 62 | * Add libusb_get_device_speed (all, except BSD) and libusb_error_name 63 | * Add Windows support (WinUSB driver only) 64 | * Add OpenBSD support 65 | * Add xusb sample 66 | * Tons of bug fixes 67 | 68 | 2010-05-07: v1.0.8 69 | * Bug fixes 70 | 71 | 2010-04-19: v1.0.7 72 | * Bug fixes and documentation tweaks 73 | * Add more interface class definitions 74 | 75 | 2009-11-22: v1.0.6 76 | * Bug fixes 77 | * Increase libusb_handle_events() timeout to 60s for powersaving 78 | 79 | 2009-11-15: v1.0.5 80 | * Use timerfd when available for timer management 81 | * Small fixes/updates 82 | 83 | 2009-11-06: v1.0.4 release 84 | * Bug fixes including transfer locking to fix some potential threading races 85 | * More flexibility with clock types on Linux 86 | * Use new bulk continuation tracking in Linux 2.6.32 for improved handling 87 | of short/failed transfers 88 | 89 | 2009-08-27: v1.0.3 release 90 | * Bug fixes 91 | * Add libusb_get_max_iso_packet_size() 92 | 93 | 2009-06-13: v1.0.2 release 94 | * Bug fixes 95 | 96 | 2009-05-12: v1.0.1 release 97 | * Bug fixes 98 | * Darwin backend 99 | 100 | 2008-12-13: v1.0.0 release 101 | * Bug fixes 102 | 103 | 2008-11-21: v0.9.4 release 104 | * Bug fixes 105 | * Add libusb_attach_kernel_driver() 106 | 107 | 2008-08-23: v0.9.3 release 108 | * Bug fixes 109 | 110 | 2008-07-19: v0.9.2 release 111 | * Bug fixes 112 | 113 | 2008-06-28: v0.9.1 release 114 | * Bug fixes 115 | * Introduce contexts to the API 116 | * Compatibility with new Linux kernel features 117 | 118 | 2008-05-25: v0.9.0 release 119 | * First libusb-1.0 beta release 120 | 121 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 | 123 | APPENDIX A - How to maintain code compatibility with versions of libusb and 124 | libusbx that use MaxPower: 125 | 126 | If you must to maintain compatibility with versions of the library that aren't 127 | using the bMaxPower attribute in struct libusb_config_descriptor, the 128 | recommended way is to use the new LIBUSBX_API_VERSION macro with an #ifdef. 129 | For instance, if your code was written as follows: 130 | 131 | if (dev->config[0].MaxPower < 250) 132 | 133 | Then you should modify it to have: 134 | 135 | #if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x01000100) 136 | if (dev->config[0].bMaxPower < 250) 137 | #else 138 | if (dev->config[0].MaxPower < 250) 139 | #endif 140 | -------------------------------------------------------------------------------- /INSTALL_WIN.txt: -------------------------------------------------------------------------------- 1 | Installation Instructions for Windows 2 | ************************************* 3 | 4 | If you are compiling for MinGW or cygwin, please refer to the INSTALL file. 5 | 6 | If you are using Microsoft Visual Studio: 7 | - Open the relevant solution file in /msvc: 8 | libusb.dsw for MSVC6, libusb_2005.sln for Visual Studio 2005 or 2008 or 9 | libusb_2010.sln for Visual Studio 2010 or later. 10 | - If you want to debug the library, uncomment the ENABLE_DEBUG_LOGGING define 11 | in msvc\config.h 12 | - Select your configuration and compile the project 13 | 14 | Note that if you are using Visual Studio Express, you may have to install the 15 | Windows SDK to be able to compile the 64 bit version of the library. 16 | 17 | If you are using the freely available Windows DDK/WDK (Driver Development Kit) 18 | - If you want to debug the library, uncomment the ENABLE_DEBUG_LOGGING define 19 | in msvc\config.h 20 | - Open one of the relevant Free Build or Checked Build prompt for your target 21 | platform 22 | - Navigate to the msvc\ directory where the ddk_build.cmd file is located, and 23 | run 'ddk_build' 24 | - To produce a DLL rather than a static library, use: 'ddk_build DLL' 25 | - To produce a static library that uses LIBCMT[d] instead of MSVCRT[d] (/MT[d] 26 | vs /MD[d] in Visual Studio) use: 'ddk_build /MT' 27 | 28 | Note that using the Windows DDK, it is possible to compile both the 32 and 64 29 | bit versions of the library. 30 | 31 | 32 | Destination directories 33 | *********************** 34 | 35 | The 32 bit binaries compiled either from Visual Studio or the DDK are placed in 36 | a Win32\ directory at the root of the library 37 | The 64 bit binaries are placed in an x64\ directory 38 | 39 | 40 | Troubleshooting 41 | *************** 42 | 43 | If the compilation process complains about missing libraries, ensure that the 44 | default library paths for your project points to the relevant directories. 45 | If needed, these libraries can be obtained by installing either the latest 46 | Windows SDK or the DDK (Links provided at the end of this file). 47 | 48 | 49 | Links 50 | ***** 51 | 52 | Additional information related to the Windows backend: 53 | http://windows.libusbx.org 54 | 55 | Latest Windows Driver (Development) Kit (WDK): 56 | http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=36a2630f-5d56-43b5-b996-7633f2ec14ff 57 | 58 | Latest Microsoft Windows SDK: 59 | http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505 60 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip 2 | ACLOCAL_AMFLAGS = -I m4 3 | DISTCLEANFILES = libusb-1.0.pc 4 | EXTRA_DIST = TODO PORTING msvc libusb/libusb-1.0.def libusb/version_nano.h \ 5 | examples/getopt/getopt.c examples/getopt/getopt1.c examples/getopt/getopt.h 6 | SUBDIRS = libusb doc 7 | 8 | if BUILD_EXAMPLES 9 | SUBDIRS += examples 10 | endif 11 | 12 | if BUILD_TESTS 13 | SUBDIRS += tests 14 | endif 15 | 16 | pkgconfigdir=$(libdir)/pkgconfig 17 | pkgconfig_DATA=libusb-1.0.pc 18 | 19 | .PHONY: dist-up 20 | 21 | reldir = .release/$(distdir) 22 | dist-up: dist 23 | rm -rf $(reldir) 24 | mkdir -p $(reldir) 25 | cp $(distdir).tar.bz2 $(reldir) 26 | rsync -rv $(reldir) frs.sourceforge.net:/home/frs/project/l/li/libusb/libusb-1.0/ 27 | rm -rf $(reldir) 28 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | For the latest libusbx news, please refer to the ChangeLog file, or visit: 2 | http://libusbx.org 3 | -------------------------------------------------------------------------------- /PORTING: -------------------------------------------------------------------------------- 1 | PORTING LIBUSBX TO OTHER PLATFORMS 2 | 3 | Introduction 4 | ============ 5 | 6 | This document is aimed at developers wishing to port libusbx to unsupported 7 | platforms. I believe the libusbx API is OS-independent, so by supporting 8 | multiple operating systems we pave the way for cross-platform USB device 9 | drivers. 10 | 11 | Implementation-wise, the basic idea is that you provide an interface to 12 | libusbx's internal "backend" API, which performs the appropriate operations on 13 | your target platform. 14 | 15 | In terms of USB I/O, your backend provides functionality to submit 16 | asynchronous transfers (synchronous transfers are implemented in the higher 17 | layers, based on the async interface). Your backend must also provide 18 | functionality to cancel those transfers. 19 | 20 | Your backend must also provide an event handling function to "reap" ongoing 21 | transfers and process their results. 22 | 23 | The backend must also provide standard functions for other USB operations, 24 | e.g. setting configuration, obtaining descriptors, etc. 25 | 26 | 27 | File descriptors for I/O polling 28 | ================================ 29 | 30 | For libusbx to work, your event handling function obviously needs to be called 31 | at various points in time. Your backend must provide a set of file descriptors 32 | which libusbx and its users can pass to poll() or select() to determine when 33 | it is time to call the event handling function. 34 | 35 | On Linux, this is easy: the usbfs kernel interface exposes a file descriptor 36 | which can be passed to poll(). If something similar is not true for your 37 | platform, you can emulate this using an internal library thread to reap I/O as 38 | necessary, and a pipe() with the main library to raise events. The file 39 | descriptor of the pipe can then be provided to libusbx as an event source. 40 | 41 | 42 | Interface semantics and documentation 43 | ===================================== 44 | 45 | Documentation of the backend interface can be found in libusbi.h inside the 46 | usbi_os_backend structure definition. 47 | 48 | Your implementations of these functions will need to call various internal 49 | libusbx functions, prefixed with "usbi_". Documentation for these functions 50 | can be found in the .c files where they are implemented. 51 | 52 | You probably want to skim over *all* the documentation before starting your 53 | implementation. For example, you probably need to allocate and store private 54 | OS-specific data for device handles, but the documentation for the mechanism 55 | for doing so is probably not the first thing you will see. 56 | 57 | The Linux backend acts as a good example - view it as a reference 58 | implementation which you should try to match the behaviour of. 59 | 60 | 61 | Getting started 62 | =============== 63 | 64 | 1. Modify configure.ac to detect your platform appropriately (see the OS_LINUX 65 | stuff for an example). 66 | 67 | 2. Implement your backend in the libusb/os/ directory, modifying 68 | libusb/os/Makefile.am appropriately. 69 | 70 | 3. Add preprocessor logic to the top of libusb/core.c to statically assign the 71 | right usbi_backend for your platform. 72 | 73 | 4. Produce and test your implementation. 74 | 75 | 5. Send your implementation to libusbx-devel mailing list. 76 | 77 | 78 | Implementation difficulties? Questions? 79 | ======================================= 80 | 81 | If you encounter difficulties porting libusbx to your platform, please raise 82 | these issues on the libusbx-devel mailing list. Where possible and sensible, I 83 | am interested in solving problems preventing libusbx from operating on other 84 | platforms. 85 | 86 | The libusbx-devel mailing list is also a good place to ask questions and 87 | make suggestions about the internal API. Hopefully we can produce some 88 | better documentation based on your questions and other input. 89 | 90 | You are encouraged to get involved in the process; if the library needs 91 | some infrastructure additions/modifications to better support your platform, 92 | you are encouraged to make such changes (in cleanly distinct patch 93 | submissions). Even if you do not make such changes yourself, please do raise 94 | the issues on the mailing list at the very minimum. 95 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | libusbx 2 | ======= 3 | 4 | libusbx is a library for USB device access from Linux, Mac OS X, 5 | Windows and OpenBSD/NetBSD userspace, with OpenBSD/NetBSD, and to a 6 | lesser extent some of the newest features of Windows (such as libusbK 7 | and libusb-win32 driver support) being EXPERIMENTAL. 8 | It is written in C and licensed under the GNU Lesser General Public 9 | License version 2.1 or, at your option, any later version (see COPYING). 10 | 11 | libusbx is abstracted internally in such a way that it can hopefully 12 | be ported to other operating systems. Please see the PORTING file 13 | for more information. 14 | 15 | libusbx homepage: 16 | http://libusbx.org/ 17 | 18 | Developers will wish to consult the API documentation: 19 | http://api.libusbx.org 20 | 21 | Use the mailing list for questions, comments, etc: 22 | http://mailing-list.libusbx.org 23 | 24 | - Pete Batard 25 | - Hans de Goede 26 | - Xiaofan Chen 27 | - Ludovic Rousseau 28 | (use the mailing list rather than mailing developers directly) 29 | -------------------------------------------------------------------------------- /README.git: -------------------------------------------------------------------------------- 1 | Notes related to git compilation: 2 | -------------------------------- 3 | 4 | If you retrieved the libusbx repository from git and are using a gcc based 5 | toolchain, be mindful that you should have the autotools installed (autoconf, 6 | automake) and will need to run either ./autogen.sh or ./bootstrap.sh to produce 7 | the configure file. 8 | 9 | The difference between autogen.sh and bootstrap.sh is that the former invokes 10 | configure with a default set of options, and will therefore generate a Makefile, 11 | whereas the latter does not invoke configure at all. If using autogen.sh, note 12 | that you can also append options, that will be passed as is to configure. 13 | 14 | 15 | Notes related to submitting new developments: 16 | -------------------------------------------- 17 | 18 | If you submit a new development to libusbx (eg: new backend), that is unlikely 19 | to fit in a couple of small patches, we would kindly suggest that you create a 20 | public account on github, if you don't have one already, and then fork a new 21 | libusbx repository under this account from https://github.com/libusbx/libusbx. 22 | 23 | Then you can create a git branch for your work, that we will be able to better 24 | reference and test. 25 | 26 | We also suggest that, if you are planning to bring in a large development, you 27 | try to involve the libusbx community early by letting the mailing list know, as 28 | you may find that other people might be eager to help you out. 29 | See http://mailing-list.libusbx.org for details on how to join the mailing list. -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Development contributors are listed in the AUTHORS file. Community members who 2 | have also made significant contributions in other areas are listed below: 3 | 4 | Alan Stern 5 | Ludovic Rousseau 6 | Tim Roberts 7 | Xiaofan Chen 8 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Please see the libusbx roadmap by visiting: 2 | https://github.com/libusbx/libusbx/issues/milestones?direction=asc&sort=due_date -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | ./bootstrap.sh 6 | ./configure --enable-maintainer-mode --enable-examples-build --enable-tests-build "$@" 7 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # use libtoolize if available, otherwise look for glibtoolize (darwin) 6 | if (libtoolize --version) < /dev/null > /dev/null 2>&1; then 7 | LIBTOOLIZE=libtoolize 8 | elif (glibtoolize --version) < /dev/null > /dev/null 2>&1; then 9 | LIBTOOLIZE=glibtoolize 10 | else 11 | echo "libtoolize or glibtoolize was not found! Please install libtool." 1>&2 12 | exit 1 13 | fi 14 | 15 | $LIBTOOLIZE --copy --force || exit 1 16 | aclocal || exit 1 17 | autoheader || exit 1 18 | autoconf || exit 1 19 | automake -a -c || exit 1 20 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = doxygen.cfg.in 2 | 3 | docs: doxygen.cfg 4 | doxygen $^ 5 | 6 | docs-upload: docs 7 | ln -s html api-1.0 8 | scp -r api-1.0 pbatard@web.sourceforge.net:/home/project-web/libusbx/htdocs 9 | rm -f api-1.0 10 | -------------------------------------------------------------------------------- /doc/libusbx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pbatard/libusbx/33ba1231a1b07425eaa83935f84b2e4b7f904f35/doc/libusbx.png -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/libusb 2 | LDADD = ../libusb/libusb-1.0.la 3 | 4 | noinst_PROGRAMS = listdevs xusb fxload 5 | 6 | if HAVE_SIGACTION 7 | noinst_PROGRAMS += dpfp 8 | endif 9 | 10 | if THREADS_POSIX 11 | if HAVE_SIGACTION 12 | dpfp_threaded_CFLAGS = $(AM_CFLAGS) 13 | noinst_PROGRAMS += dpfp_threaded 14 | endif 15 | endif 16 | 17 | fxload_SOURCES = ezusb.c ezusb.h fxload.c 18 | fxload_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS) 19 | -------------------------------------------------------------------------------- /examples/ezusb.h: -------------------------------------------------------------------------------- 1 | #ifndef __ezusb_H 2 | #define __ezusb_H 3 | /* 4 | * Copyright © 2001 Stephen Williams (steve@icarus.com) 5 | * Copyright © 2002 David Brownell (dbrownell@users.sourceforge.net) 6 | * 7 | * This source code is free software; you can redistribute it 8 | * and/or modify it in source code form under the terms of the GNU 9 | * General Public License as published by the Free Software 10 | * Foundation; either version 2 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 21 | */ 22 | #if !defined(_MSC_VER) 23 | #include 24 | #else 25 | #define __attribute__(x) 26 | #if !defined(bool) 27 | #define bool int 28 | #endif 29 | #if !defined(true) 30 | #define true (1 == 1) 31 | #endif 32 | #if !defined(false) 33 | #define false (!true) 34 | #endif 35 | #if defined(_PREFAST_) 36 | #pragma warning(disable:28193) 37 | #endif 38 | #endif 39 | 40 | #define FX_TYPE_UNDEFINED -1 41 | #define FX_TYPE_AN21 0 /* Original AnchorChips parts */ 42 | #define FX_TYPE_FX1 1 /* Updated Cypress versions */ 43 | #define FX_TYPE_FX2 2 /* USB 2.0 versions */ 44 | #define FX_TYPE_FX2LP 3 /* Updated FX2 */ 45 | #define FX_TYPE_MAX 4 46 | #define FX_TYPE_NAMES { "an21", "fx", "fx2", "fx2lp" } 47 | 48 | #define IMG_TYPE_UNDEFINED -1 49 | #define IMG_TYPE_HEX 0 /* Intel HEX */ 50 | #define IMG_TYPE_IIC 1 /* Cypress 8051 IIC */ 51 | #define IMG_TYPE_BIX 2 /* Cypress 8051 BIX */ 52 | #define IMG_TYPE_MAX 3 53 | #define IMG_TYPE_NAMES { "Intel HEX", "Cypress 8051 IIC", "Cypress 8051 BIX" } 54 | 55 | /* 56 | * Automatically identified devices (VID, PID, type, designation). 57 | * TODO: Could use some validation. Also where's the FX2? 58 | */ 59 | typedef struct { 60 | uint16_t vid; 61 | uint16_t pid; 62 | int type; 63 | const char* designation; 64 | } fx_known_device; 65 | 66 | #define FX_KNOWN_DEVICES { \ 67 | { 0x0547, 0x2122, FX_TYPE_AN21, "Cypress EZ-USB (2122S)" },\ 68 | { 0x0547, 0x2125, FX_TYPE_AN21, "Cypress EZ-USB (2121S/2125S)" },\ 69 | { 0x0547, 0x2126, FX_TYPE_AN21, "Cypress EZ-USB (2126S)" },\ 70 | { 0x0547, 0x2131, FX_TYPE_AN21, "Cypress EZ-USB (2131Q/2131S/2135S)" },\ 71 | { 0x0547, 0x2136, FX_TYPE_AN21, "Cypress EZ-USB (2136S)" },\ 72 | { 0x0547, 0x2225, FX_TYPE_AN21, "Cypress EZ-USB (2225)" },\ 73 | { 0x0547, 0x2226, FX_TYPE_AN21, "Cypress EZ-USB (2226)" },\ 74 | { 0x0547, 0x2235, FX_TYPE_AN21, "Cypress EZ-USB (2235)" },\ 75 | { 0x0547, 0x2236, FX_TYPE_AN21, "Cypress EZ-USB (2236)" },\ 76 | { 0x04b4, 0x6473, FX_TYPE_FX1, "Cypress EZ-USB FX1" },\ 77 | { 0x04b4, 0x8613, FX_TYPE_FX2LP, "Cypress EZ-USB FX2LP (68013A/68014A/68015A/68016A)" }, \ 78 | } 79 | 80 | /* 81 | * This function uploads the firmware from the given file into RAM. 82 | * Stage == 0 means this is a single stage load (or the first of 83 | * two stages). Otherwise it's the second of two stages; the 84 | * caller having preloaded the second stage loader. 85 | * 86 | * The target processor is reset at the end of this upload. 87 | */ 88 | extern int ezusb_load_ram(libusb_device_handle *device, 89 | const char *path, int fx_type, int img_type, int stage); 90 | 91 | /* 92 | * This function uploads the firmware from the given file into EEPROM. 93 | * This uses the right CPUCS address to terminate the EEPROM load with 94 | * a reset command where FX parts behave differently than FX2 ones. 95 | * The configuration byte is as provided here (zero for an21xx parts) 96 | * and the EEPROM type is set so that the microcontroller will boot 97 | * from it. 98 | * 99 | * The caller must have preloaded a second stage loader that knows 100 | * how to respond to the EEPROM write request. 101 | */ 102 | extern int ezusb_load_eeprom(libusb_device_handle *device, 103 | const char *path, int fx_type, int img_type, int config); 104 | 105 | /* boolean flag, says whether to write extra messages to stderr */ 106 | extern int verbose; 107 | #endif 108 | -------------------------------------------------------------------------------- /examples/fxload.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2001 Stephen Williams (steve@icarus.com) 3 | * Copyright © 2001-2002 David Brownell (dbrownell@users.sourceforge.net) 4 | * Copyright © 2008 Roger Williams (rawqux@users.sourceforge.net) 5 | * Copyright © 2012 Pete Batard (pete@akeo.ie) 6 | * 7 | * This source code is free software; you can redistribute it 8 | * and/or modify it in source code form under the terms of the GNU 9 | * General Public License as published by the Free Software 10 | * Foundation; either version 2 of the License, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 21 | */ 22 | 23 | /* 24 | * This program supports uploading firmware into a target USB device. 25 | * 26 | * -I -- Upload this firmware 27 | * -t -- uController type: an21, fx, fx2, fx2lp 28 | * 29 | * -D -- Use this device, instead of $DEVICE 30 | * 31 | * -V -- Print version ID for program 32 | */ 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include "libusb.h" 42 | #include "ezusb.h" 43 | 44 | #if !defined(_WIN32) || defined(__CYGWIN__ ) 45 | #include 46 | static bool dosyslog = false; 47 | #include 48 | #define _stricmp strcasecmp 49 | #endif 50 | 51 | #ifndef FXLOAD_VERSION 52 | #define FXLOAD_VERSION (__DATE__ " (development)") 53 | #endif 54 | 55 | #ifndef ARRAYSIZE 56 | #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) 57 | #endif 58 | 59 | void logerror(const char *format, ...) 60 | __attribute__ ((format (__printf__, 1, 2))); 61 | 62 | void logerror(const char *format, ...) 63 | { 64 | va_list ap; 65 | va_start(ap, format); 66 | 67 | #if !defined(_WIN32) || defined(__CYGWIN__ ) 68 | if (dosyslog) 69 | vsyslog(LOG_ERR, format, ap); 70 | else 71 | #endif 72 | vfprintf(stderr, format, ap); 73 | va_end(ap); 74 | } 75 | 76 | #define FIRMWARE 0 77 | #define LOADER 1 78 | int main(int argc, char*argv[]) 79 | { 80 | fx_known_device known_device[] = FX_KNOWN_DEVICES; 81 | const char *path[] = { NULL, NULL }; 82 | const char *device_id = getenv("DEVICE"); 83 | const char *type = NULL; 84 | const char *fx_name[FX_TYPE_MAX] = FX_TYPE_NAMES; 85 | const char *ext, *img_name[] = IMG_TYPE_NAMES; 86 | int fx_type = FX_TYPE_UNDEFINED, img_type[ARRAYSIZE(path)]; 87 | int i, j, opt, status; 88 | unsigned vid = 0, pid = 0; 89 | libusb_device *dev, **devs; 90 | libusb_device_handle *device = NULL; 91 | struct libusb_device_descriptor desc; 92 | 93 | while ((opt = getopt(argc, argv, "vV?D:I:c:s:t:")) != EOF) 94 | switch (opt) { 95 | 96 | case 'D': 97 | device_id = optarg; 98 | break; 99 | 100 | case 'I': 101 | path[FIRMWARE] = optarg; 102 | break; 103 | 104 | case 'V': 105 | puts(FXLOAD_VERSION); 106 | return 0; 107 | 108 | case 't': 109 | type = optarg; 110 | break; 111 | 112 | case 'v': 113 | verbose++; 114 | break; 115 | 116 | case '?': 117 | default: 118 | goto usage; 119 | 120 | } 121 | 122 | if (path[FIRMWARE] == NULL) { 123 | logerror("no firmware specified!\n"); 124 | usage: 125 | fprintf(stderr, "\nusage: %s [-vV] [-t type] [-D vid:pid] -I firmware\n", argv[0]); 126 | fprintf(stderr, " type: one of an21, fx, fx2, fx2lp\n"); 127 | return -1; 128 | } 129 | 130 | if ((device_id != NULL) && (sscanf(device_id, "%x:%x" , &vid, &pid) != 2 )) { 131 | fputs ("please specify VID & PID as \"vid:pid\" in hexadecimal format\n", stderr); 132 | return -1; 133 | } 134 | 135 | /* determine the target type */ 136 | if (type != NULL) { 137 | for (i=0; i= FX_TYPE_MAX) { 144 | logerror("illegal microcontroller type: %s\n", type); 145 | goto usage; 146 | } 147 | } 148 | 149 | /* open the device using libusbx */ 150 | status = libusb_init(NULL); 151 | if (status < 0) { 152 | logerror("libusb_init() failed: %s\n", libusb_error_name(status)); 153 | return -1; 154 | } 155 | libusb_set_debug(NULL, verbose); 156 | 157 | /* try to pick up missing parameters from known devices */ 158 | if ((type == NULL) || (device_id == NULL)) { 159 | if (libusb_get_device_list(NULL, &devs) < 0) { 160 | logerror("libusb_get_device_list() failed: %s\n", libusb_error_name(status)); 161 | goto err; 162 | } 163 | for (i=0; (dev=devs[i]) != NULL; i++) { 164 | status = libusb_get_device_descriptor(dev, &desc); 165 | if (status >= 0) { 166 | if (verbose >= 2) 167 | logerror("trying to match against %04x:%04x\n", desc.idVendor, desc.idProduct); 168 | for (j=0; j, but 29 | that does not exist if we are standalone. So: if __GNU_LIBRARY__ is 30 | not defined, include , which will pull in for us 31 | if it's from glibc. (Why ctype.h? It's guaranteed to exist and it 32 | doesn't flood the namespace with stuff the way some other headers do.) */ 33 | #if !defined __GNU_LIBRARY__ 34 | # include 35 | #endif 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* For communication from `getopt' to the caller. 42 | When `getopt' finds an option that takes an argument, 43 | the argument value is returned here. 44 | Also, when `ordering' is RETURN_IN_ORDER, 45 | each non-option ARGV-element is returned here. */ 46 | 47 | extern char *optarg; 48 | 49 | /* Index in ARGV of the next element to be scanned. 50 | This is used for communication to and from the caller 51 | and for communication between successive calls to `getopt'. 52 | 53 | On entry to `getopt', zero means this is the first call; initialize. 54 | 55 | When `getopt' returns -1, this is the index of the first of the 56 | non-option elements that the caller should itself scan. 57 | 58 | Otherwise, `optind' communicates from one call to the next 59 | how much of ARGV has been scanned so far. */ 60 | 61 | extern int optind; 62 | 63 | /* Callers store zero here to inhibit the error message `getopt' prints 64 | for unrecognized options. */ 65 | 66 | extern int opterr; 67 | 68 | /* Set to an option character which was unrecognized. */ 69 | 70 | extern int optopt; 71 | 72 | #ifndef __need_getopt 73 | /* Describe the long-named options requested by the application. 74 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 75 | of `struct option' terminated by an element containing a name which is 76 | zero. 77 | 78 | The field `has_arg' is: 79 | no_argument (or 0) if the option does not take an argument, 80 | required_argument (or 1) if the option requires an argument, 81 | optional_argument (or 2) if the option takes an optional argument. 82 | 83 | If the field `flag' is not NULL, it points to a variable that is set 84 | to the value given in the field `val' when the option is found, but 85 | left unchanged if the option is not found. 86 | 87 | To have a long-named option do something other than set an `int' to 88 | a compiled-in constant, such as set a value from `optarg', set the 89 | option's `flag' field to zero and its `val' field to a nonzero 90 | value (the equivalent single-letter option character, if there is 91 | one). For long options that have a zero `flag' field, `getopt' 92 | returns the contents of the `val' field. */ 93 | 94 | struct option 95 | { 96 | # if (defined __STDC__ && __STDC__) || defined __cplusplus 97 | const char *name; 98 | # else 99 | char *name; 100 | # endif 101 | /* has_arg can't be an enum because some compilers complain about 102 | type mismatches in all the code that assumes it is an int. */ 103 | int has_arg; 104 | int *flag; 105 | int val; 106 | }; 107 | 108 | /* Names for the values of the `has_arg' field of `struct option'. */ 109 | 110 | # define no_argument 0 111 | # define required_argument 1 112 | # define optional_argument 2 113 | #endif /* need getopt */ 114 | 115 | 116 | /* Get definitions and prototypes for functions to process the 117 | arguments in ARGV (ARGC of them, minus the program name) for 118 | options given in OPTS. 119 | 120 | Return the option character from OPTS just read. Return -1 when 121 | there are no more options. For unrecognized options, or options 122 | missing arguments, `optopt' is set to the option letter, and '?' is 123 | returned. 124 | 125 | The OPTS string is a list of characters which are recognized option 126 | letters, optionally followed by colons, specifying that that letter 127 | takes an argument, to be placed in `optarg'. 128 | 129 | If a letter in OPTS is followed by two colons, its argument is 130 | optional. This behavior is specific to the GNU `getopt'. 131 | 132 | The argument `--' causes premature termination of argument 133 | scanning, explicitly telling `getopt' that there are no more 134 | options. 135 | 136 | If OPTS begins with `--', then non-option arguments are treated as 137 | arguments to the option '\0'. This behavior is specific to the GNU 138 | `getopt'. */ 139 | 140 | #if (defined __STDC__ && __STDC__) || defined __cplusplus 141 | # ifdef __GNU_LIBRARY__ 142 | /* Many other libraries have conflicting prototypes for getopt, with 143 | differences in the consts, in stdlib.h. To avoid compilation 144 | errors, only prototype getopt for the GNU C library. */ 145 | extern int getopt (int __argc, char *const *__argv, const char *__shortopts); 146 | # else /* not __GNU_LIBRARY__ */ 147 | extern int getopt (); 148 | # endif /* __GNU_LIBRARY__ */ 149 | 150 | # ifndef __need_getopt 151 | extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, 152 | const struct option *__longopts, int *__longind); 153 | extern int getopt_long_only (int __argc, char *const *__argv, 154 | const char *__shortopts, 155 | const struct option *__longopts, int *__longind); 156 | 157 | /* Internal only. Users should not call this directly. */ 158 | extern int _getopt_internal (int __argc, char *const *__argv, 159 | const char *__shortopts, 160 | const struct option *__longopts, int *__longind, 161 | int __long_only); 162 | # endif 163 | #else /* not __STDC__ */ 164 | extern int getopt (); 165 | # ifndef __need_getopt 166 | extern int getopt_long (); 167 | extern int getopt_long_only (); 168 | 169 | extern int _getopt_internal (); 170 | # endif 171 | #endif /* __STDC__ */ 172 | 173 | #ifdef __cplusplus 174 | } 175 | #endif 176 | 177 | /* Make sure we later can get all the definitions and declarations. */ 178 | #undef __need_getopt 179 | 180 | #endif /* getopt.h */ 181 | -------------------------------------------------------------------------------- /examples/getopt/getopt1.c: -------------------------------------------------------------------------------- 1 | /* getopt_long and getopt_long_only entry points for GNU getopt. 2 | Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 3 | Free Software Foundation, Inc. 4 | This file is part of the GNU C Library. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include 23 | #endif 24 | 25 | #include "getopt.h" 26 | 27 | #if !defined __STDC__ || !__STDC__ 28 | /* This is a separate conditional since some stdc systems 29 | reject `defined (const)'. */ 30 | #ifndef const 31 | #define const 32 | #endif 33 | #endif 34 | 35 | #include 36 | 37 | /* Comment out all this code if we are using the GNU C Library, and are not 38 | actually compiling the library itself. This code is part of the GNU C 39 | Library, but also included in many other GNU distributions. Compiling 40 | and linking in this code is a waste when using the GNU C library 41 | (especially if it is a shared library). Rather than having every GNU 42 | program understand `configure --with-gnu-libc' and omit the object files, 43 | it is simpler to just do this in the source for each such file. */ 44 | 45 | #define GETOPT_INTERFACE_VERSION 2 46 | #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 47 | #include 48 | #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION 49 | #define ELIDE_CODE 50 | #endif 51 | #endif 52 | 53 | #ifndef ELIDE_CODE 54 | 55 | 56 | /* This needs to come after some library #include 57 | to get __GNU_LIBRARY__ defined. */ 58 | #ifdef __GNU_LIBRARY__ 59 | #include 60 | #endif 61 | 62 | #ifndef NULL 63 | #define NULL 0 64 | #endif 65 | 66 | int 67 | getopt_long (argc, argv, options, long_options, opt_index) 68 | int argc; 69 | char *const *argv; 70 | const char *options; 71 | const struct option *long_options; 72 | int *opt_index; 73 | { 74 | return _getopt_internal (argc, argv, options, long_options, opt_index, 0); 75 | } 76 | 77 | /* Like getopt_long, but '-' as well as '--' can indicate a long option. 78 | If an option that starts with '-' (not '--') doesn't match a long option, 79 | but does match a short option, it is parsed as a short option 80 | instead. */ 81 | 82 | int 83 | getopt_long_only (argc, argv, options, long_options, opt_index) 84 | int argc; 85 | char *const *argv; 86 | const char *options; 87 | const struct option *long_options; 88 | int *opt_index; 89 | { 90 | return _getopt_internal (argc, argv, options, long_options, opt_index, 1); 91 | } 92 | 93 | 94 | #endif /* Not ELIDE_CODE. */ 95 | 96 | #ifdef TEST 97 | 98 | #include 99 | 100 | int 101 | main (argc, argv) 102 | int argc; 103 | char **argv; 104 | { 105 | int c; 106 | int digit_optind = 0; 107 | 108 | while (1) 109 | { 110 | int this_option_optind = optind ? optind : 1; 111 | int option_index = 0; 112 | static struct option long_options[] = 113 | { 114 | {"add", 1, 0, 0}, 115 | {"append", 0, 0, 0}, 116 | {"delete", 1, 0, 0}, 117 | {"verbose", 0, 0, 0}, 118 | {"create", 0, 0, 0}, 119 | {"file", 1, 0, 0}, 120 | {0, 0, 0, 0} 121 | }; 122 | 123 | c = getopt_long (argc, argv, "abc:d:0123456789", 124 | long_options, &option_index); 125 | if (c == -1) 126 | break; 127 | 128 | switch (c) 129 | { 130 | case 0: 131 | printf ("option %s", long_options[option_index].name); 132 | if (optarg) 133 | printf (" with arg %s", optarg); 134 | printf ("\n"); 135 | break; 136 | 137 | case '0': 138 | case '1': 139 | case '2': 140 | case '3': 141 | case '4': 142 | case '5': 143 | case '6': 144 | case '7': 145 | case '8': 146 | case '9': 147 | if (digit_optind != 0 && digit_optind != this_option_optind) 148 | printf ("digits occur in two different argv-elements.\n"); 149 | digit_optind = this_option_optind; 150 | printf ("option %c\n", c); 151 | break; 152 | 153 | case 'a': 154 | printf ("option a\n"); 155 | break; 156 | 157 | case 'b': 158 | printf ("option b\n"); 159 | break; 160 | 161 | case 'c': 162 | printf ("option c with value `%s'\n", optarg); 163 | break; 164 | 165 | case 'd': 166 | printf ("option d with value `%s'\n", optarg); 167 | break; 168 | 169 | case '?': 170 | break; 171 | 172 | default: 173 | printf ("?? getopt returned character code 0%o ??\n", c); 174 | } 175 | } 176 | 177 | if (optind < argc) 178 | { 179 | printf ("non-option ARGV-elements: "); 180 | while (optind < argc) 181 | printf ("%s ", argv[optind++]); 182 | printf ("\n"); 183 | } 184 | 185 | exit (0); 186 | } 187 | 188 | #endif /* TEST */ 189 | -------------------------------------------------------------------------------- /examples/listdevs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libusbx example program to list devices on the bus 3 | * Copyright © 2007 Daniel Drake 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "libusb.h" 24 | 25 | static void print_devs(libusb_device **devs) 26 | { 27 | libusb_device *dev; 28 | int i = 0; 29 | 30 | while ((dev = devs[i++]) != NULL) { 31 | struct libusb_device_descriptor desc; 32 | int r = libusb_get_device_descriptor(dev, &desc); 33 | if (r < 0) { 34 | fprintf(stderr, "failed to get device descriptor"); 35 | return; 36 | } 37 | 38 | printf("%04x:%04x (bus %d, device %d)\n", 39 | desc.idVendor, desc.idProduct, 40 | libusb_get_bus_number(dev), libusb_get_device_address(dev)); 41 | } 42 | } 43 | 44 | int main(void) 45 | { 46 | libusb_device **devs; 47 | int r; 48 | ssize_t cnt; 49 | 50 | r = libusb_init(NULL); 51 | if (r < 0) 52 | return r; 53 | 54 | cnt = libusb_get_device_list(NULL, &devs); 55 | if (cnt < 0) 56 | return (int) cnt; 57 | 58 | print_devs(devs); 59 | libusb_free_device_list(devs, 1); 60 | 61 | libusb_exit(NULL); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /libusb-1.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libusbx-1.0 7 | Description: C API for USB device access from Linux, Mac OS X, Windows and OpenBSD/NetBSD userspace 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lusb-1.0 10 | Libs.private: @LIBS@ 11 | Cflags: -I${includedir}/libusb-1.0 12 | -------------------------------------------------------------------------------- /libusb/Makefile.am: -------------------------------------------------------------------------------- 1 | all: libusb-1.0.la libusb-1.0.dll 2 | 3 | lib_LTLIBRARIES = libusb-1.0.la 4 | 5 | LINUX_USBFS_SRC = os/linux_usbfs.c 6 | DARWIN_USB_SRC = os/darwin_usb.c 7 | OPENBSD_USB_SRC = os/openbsd_usb.c 8 | WINDOWS_USB_SRC = os/poll_windows.c os/windows_usb.c libusb-1.0.rc 9 | 10 | EXTRA_DIST = $(LINUX_USBFS_SRC) $(DARWIN_USB_SRC) $(OPENBSD_USB_SRC) \ 11 | $(WINDOWS_USB_SRC) os/threads_posix.c os/threads_windows.c 12 | 13 | if OS_LINUX 14 | OS_SRC = $(LINUX_USBFS_SRC) 15 | endif 16 | 17 | if OS_DARWIN 18 | OS_SRC = $(DARWIN_USB_SRC) 19 | AM_CFLAGS_EXT = -no-cpp-precomp 20 | endif 21 | 22 | if OS_OPENBSD 23 | OS_SRC = $(OPENBSD_USB_SRC) 24 | endif 25 | 26 | if OS_WINDOWS 27 | OS_SRC = $(WINDOWS_USB_SRC) 28 | 29 | .rc.lo: 30 | $(AM_V_GEN)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) -i $< -o $@ 31 | 32 | libusb-1.0.rc: version.h version_nano.h 33 | endif 34 | 35 | libusb-1.0.dll: libusb-1.0.def 36 | if CREATE_IMPORT_LIB 37 | # Rebuild the import lib from the .def so that MS and MinGW DLLs can be interchanged 38 | $(AM_V_GEN)$(DLLTOOL) $(DLLTOOLFLAGS) --kill-at --input-def $(srcdir)/libusb-1.0.def --dllname $@ --output-lib .libs/$@.a 39 | endif 40 | 41 | 42 | if THREADS_POSIX 43 | THREADS_SRC = os/threads_posix.h os/threads_posix.c 44 | else 45 | THREADS_SRC = os/threads_windows.h os/threads_windows.c 46 | endif 47 | 48 | libusb_1_0_la_CFLAGS = $(AM_CFLAGS) 49 | libusb_1_0_la_LDFLAGS = $(LTLDFLAGS) 50 | libusb_1_0_la_SOURCES = libusbi.h core.c descriptor.c io.c sync.c $(OS_SRC) \ 51 | os/linux_usbfs.h os/darwin_usb.h os/windows_usb.h \ 52 | $(THREADS_SRC) \ 53 | os/poll_posix.h os/poll_windows.h 54 | 55 | hdrdir = $(includedir)/libusb-1.0 56 | hdr_HEADERS = libusb.h 57 | -------------------------------------------------------------------------------- /libusb/libusb-1.0.def: -------------------------------------------------------------------------------- 1 | LIBRARY "libusb-1.0.dll" 2 | EXPORTS 3 | libusb_alloc_transfer 4 | libusb_alloc_transfer@4 = libusb_alloc_transfer 5 | libusb_attach_kernel_driver 6 | libusb_attach_kernel_driver@8 = libusb_attach_kernel_driver 7 | libusb_bulk_transfer 8 | libusb_bulk_transfer@24 = libusb_bulk_transfer 9 | libusb_cancel_transfer 10 | libusb_cancel_transfer@4 = libusb_cancel_transfer 11 | libusb_claim_interface 12 | libusb_claim_interface@8 = libusb_claim_interface 13 | libusb_clear_halt 14 | libusb_clear_halt@8 = libusb_clear_halt 15 | libusb_close 16 | libusb_close@4 = libusb_close 17 | libusb_control_transfer 18 | libusb_control_transfer@32 = libusb_control_transfer 19 | libusb_detach_kernel_driver 20 | libusb_detach_kernel_driver@8 = libusb_detach_kernel_driver 21 | libusb_error_name 22 | libusb_error_name@4 = libusb_error_name 23 | libusb_event_handler_active 24 | libusb_event_handler_active@4 = libusb_event_handler_active 25 | libusb_event_handling_ok 26 | libusb_event_handling_ok@4 = libusb_event_handling_ok 27 | libusb_exit 28 | libusb_exit@4 = libusb_exit 29 | libusb_free_config_descriptor 30 | libusb_free_config_descriptor@4 = libusb_free_config_descriptor 31 | libusb_free_device_list 32 | libusb_free_device_list@8 = libusb_free_device_list 33 | libusb_free_transfer 34 | libusb_free_transfer@4 = libusb_free_transfer 35 | libusb_get_active_config_descriptor 36 | libusb_get_active_config_descriptor@8 = libusb_get_active_config_descriptor 37 | libusb_get_bus_number 38 | libusb_get_bus_number@4 = libusb_get_bus_number 39 | libusb_get_config_descriptor 40 | libusb_get_config_descriptor@12 = libusb_get_config_descriptor 41 | libusb_get_config_descriptor_by_value 42 | libusb_get_config_descriptor_by_value@12 = libusb_get_config_descriptor_by_value 43 | libusb_get_configuration 44 | libusb_get_configuration@8 = libusb_get_configuration 45 | libusb_get_device 46 | libusb_get_device@4 = libusb_get_device 47 | libusb_get_device_address 48 | libusb_get_device_address@4 = libusb_get_device_address 49 | libusb_get_device_descriptor 50 | libusb_get_device_descriptor@8 = libusb_get_device_descriptor 51 | libusb_get_device_list 52 | libusb_get_device_list@8 = libusb_get_device_list 53 | libusb_get_device_speed 54 | libusb_get_device_speed@4 = libusb_get_device_speed 55 | libusb_get_max_iso_packet_size 56 | libusb_get_max_iso_packet_size@8 = libusb_get_max_iso_packet_size 57 | libusb_get_max_packet_size 58 | libusb_get_max_packet_size@8 = libusb_get_max_packet_size 59 | libusb_get_next_timeout 60 | libusb_get_next_timeout@8 = libusb_get_next_timeout 61 | libusb_get_parent 62 | libusb_get_parent@4 = libusb_get_parent 63 | libusb_get_pollfds 64 | libusb_get_pollfds@4 = libusb_get_pollfds 65 | libusb_get_port_number 66 | libusb_get_port_number@4 = libusb_get_port_number 67 | libusb_get_port_path 68 | libusb_get_port_path@16 = libusb_get_port_path 69 | libusb_get_string_descriptor_ascii 70 | libusb_get_string_descriptor_ascii@16 = libusb_get_string_descriptor_ascii 71 | libusb_get_version 72 | libusb_get_version@0 = libusb_get_version 73 | libusb_handle_events 74 | libusb_handle_events@4 = libusb_handle_events 75 | libusb_handle_events_completed 76 | libusb_handle_events_completed@8 = libusb_handle_events_completed 77 | libusb_handle_events_locked 78 | libusb_handle_events_locked@8 = libusb_handle_events_locked 79 | libusb_handle_events_timeout 80 | libusb_handle_events_timeout@8 = libusb_handle_events_timeout 81 | libusb_handle_events_timeout_completed 82 | libusb_handle_events_timeout_completed@12 = libusb_handle_events_timeout_completed 83 | libusb_has_capability 84 | libusb_has_capability@4 = libusb_has_capability 85 | libusb_init 86 | libusb_init@4 = libusb_init 87 | libusb_interrupt_transfer 88 | libusb_interrupt_transfer@24 = libusb_interrupt_transfer 89 | libusb_kernel_driver_active 90 | libusb_kernel_driver_active@8 = libusb_kernel_driver_active 91 | libusb_lock_event_waiters 92 | libusb_lock_event_waiters@4 = libusb_lock_event_waiters 93 | libusb_lock_events 94 | libusb_lock_events@4 = libusb_lock_events 95 | libusb_open 96 | libusb_open@8 = libusb_open 97 | libusb_open_device_with_vid_pid 98 | libusb_open_device_with_vid_pid@12 = libusb_open_device_with_vid_pid 99 | libusb_pollfds_handle_timeouts 100 | libusb_pollfds_handle_timeouts@4 = libusb_pollfds_handle_timeouts 101 | libusb_ref_device 102 | libusb_ref_device@4 = libusb_ref_device 103 | libusb_release_interface 104 | libusb_release_interface@8 = libusb_release_interface 105 | libusb_reset_device 106 | libusb_reset_device@4 = libusb_reset_device 107 | libusb_set_configuration 108 | libusb_set_configuration@8 = libusb_set_configuration 109 | libusb_set_debug 110 | libusb_set_debug@8 = libusb_set_debug 111 | libusb_set_interface_alt_setting 112 | libusb_set_interface_alt_setting@12 = libusb_set_interface_alt_setting 113 | libusb_set_pollfd_notifiers 114 | libusb_set_pollfd_notifiers@16 = libusb_set_pollfd_notifiers 115 | libusb_submit_transfer 116 | libusb_submit_transfer@4 = libusb_submit_transfer 117 | libusb_try_lock_events 118 | libusb_try_lock_events@4 = libusb_try_lock_events 119 | libusb_unlock_event_waiters 120 | libusb_unlock_event_waiters@4 = libusb_unlock_event_waiters 121 | libusb_unlock_events 122 | libusb_unlock_events@4 = libusb_unlock_events 123 | libusb_unref_device 124 | libusb_unref_device@4 = libusb_unref_device 125 | libusb_wait_for_event 126 | libusb_wait_for_event@8 = libusb_wait_for_event 127 | -------------------------------------------------------------------------------- /libusb/libusb-1.0.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * For Windows: input this file to the Resoure Compiler to produce a binary 3 | * .res file. This is then embedded in the resultant library (like any other 4 | * compilation object). 5 | * The information can then be queried using standard APIs and can also be 6 | * viewed with utilities such as Windows Explorer. 7 | */ 8 | #include "winresrc.h" 9 | 10 | #include "version.h" 11 | #ifndef LIBUSB_VERSIONSTRING 12 | #define LU_STR(s) #s 13 | #define LU_XSTR(s) LU_STR(s) 14 | #if LIBUSB_NANO > 0 15 | #define LIBUSB_VERSIONSTRING \ 16 | LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." \ 17 | LU_XSTR(LIBUSB_MICRO) "." LU_XSTR(LIBUSB_NANO) LIBUSB_RC "\0" 18 | #else 19 | #define LIBUSB_VERSIONSTRING \ 20 | LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." \ 21 | LU_XSTR(LIBUSB_MICRO) LIBUSB_RC "\0" 22 | #endif 23 | #endif 24 | 25 | VS_VERSION_INFO VERSIONINFO 26 | FILEVERSION LIBUSB_MAJOR,LIBUSB_MINOR,LIBUSB_MICRO,LIBUSB_NANO 27 | PRODUCTVERSION LIBUSB_MAJOR,LIBUSB_MINOR,LIBUSB_MICRO,LIBUSB_NANO 28 | FILEFLAGSMASK 0x3fL 29 | #ifdef _DEBUG 30 | FILEFLAGS 0x1L 31 | #else 32 | FILEFLAGS 0x0L 33 | #endif 34 | FILEOS 0x40004L 35 | FILETYPE 0x2L 36 | FILESUBTYPE 0x0L 37 | BEGIN 38 | BLOCK "StringFileInfo" 39 | BEGIN 40 | BLOCK "040904b0" 41 | BEGIN 42 | VALUE "CompanyName", "libusbx.org\0" 43 | VALUE "FileDescription", "C library for writing portable USB drivers in userspace\0" 44 | VALUE "FileVersion", LIBUSB_VERSIONSTRING 45 | VALUE "InternalName", "libusb\0" 46 | VALUE "LegalCopyright", "See individual source files, GNU LGPL v2.1 or later.\0" 47 | VALUE "LegalTrademarks", "http://www.gnu.org/licenses/lgpl-2.1.html\0" 48 | VALUE "OriginalFilename", "libusb-1.0.dll\0" 49 | VALUE "PrivateBuild", "\0" 50 | VALUE "ProductName", "libusb-1.0\0" 51 | VALUE "ProductVersion", LIBUSB_VERSIONSTRING 52 | VALUE "SpecialBuild", "\0" 53 | END 54 | END 55 | BLOCK "VarFileInfo" 56 | BEGIN 57 | VALUE "Translation", 0x409, 1200 58 | END 59 | END 60 | -------------------------------------------------------------------------------- /libusb/os/darwin_usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * darwin backend for libusbx 1.0 3 | * Copyright © 2008-2009 Nathan Hjelm 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #if !defined(LIBUSB_DARWIN_H) 21 | #define LIBUSB_DARWIN_H 22 | 23 | #include "libusbi.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | /* IOUSBInterfaceInferface */ 31 | #if defined (kIOUSBInterfaceInterfaceID300) 32 | 33 | #define usb_interface_t IOUSBInterfaceInterface300 34 | #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID300 35 | #define InterfaceVersion 300 36 | 37 | #elif defined (kIOUSBInterfaceInterfaceID245) 38 | 39 | #define usb_interface_t IOUSBInterfaceInterface245 40 | #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID245 41 | #define InterfaceVersion 245 42 | 43 | #elif defined (kIOUSBInterfaceInterfaceID220) 44 | 45 | #define usb_interface_t IOUSBInterfaceInterface220 46 | #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID220 47 | #define InterfaceVersion 220 48 | 49 | #elif defined (kIOUSBInterfaceInterfaceID197) 50 | 51 | #define usb_interface_t IOUSBInterfaceInterface197 52 | #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID197 53 | #define InterfaceVersion 197 54 | 55 | #elif defined (kIOUSBInterfaceInterfaceID190) 56 | 57 | #define usb_interface_t IOUSBInterfaceInterface190 58 | #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID190 59 | #define InterfaceVersion 190 60 | 61 | #elif defined (kIOUSBInterfaceInterfaceID182) 62 | 63 | #define usb_interface_t IOUSBInterfaceInterface182 64 | #define InterfaceInterfaceID kIOUSBInterfaceInterfaceID182 65 | #define InterfaceVersion 182 66 | 67 | #else 68 | 69 | #error "IOUSBFamily is too old. Please upgrade your OS" 70 | 71 | #endif 72 | 73 | /* IOUSBDeviceInterface */ 74 | #if defined (kIOUSBDeviceInterfaceID500) 75 | 76 | #define usb_device_t IOUSBDeviceInterface500 77 | #define DeviceInterfaceID kIOUSBDeviceInterfaceID500 78 | #define DeviceVersion 500 79 | 80 | #elif defined (kIOUSBDeviceInterfaceID320) 81 | 82 | #define usb_device_t IOUSBDeviceInterface320 83 | #define DeviceInterfaceID kIOUSBDeviceInterfaceID320 84 | #define DeviceVersion 320 85 | 86 | #elif defined (kIOUSBDeviceInterfaceID300) 87 | 88 | #define usb_device_t IOUSBDeviceInterface300 89 | #define DeviceInterfaceID kIOUSBDeviceInterfaceID300 90 | #define DeviceVersion 300 91 | 92 | #elif defined (kIOUSBDeviceInterfaceID245) 93 | 94 | #define usb_device_t IOUSBDeviceInterface245 95 | #define DeviceInterfaceID kIOUSBDeviceInterfaceID245 96 | #define DeviceVersion 245 97 | 98 | #elif defined (kIOUSBDeviceInterfaceID197) 99 | 100 | #define usb_device_t IOUSBDeviceInterface197 101 | #define DeviceInterfaceID kIOUSBDeviceInterfaceID197 102 | #define DeviceVersion 197 103 | 104 | #elif defined (kIOUSBDeviceInterfaceID187) 105 | 106 | #define usb_device_t IOUSBDeviceInterface187 107 | #define DeviceInterfaceID kIOUSBDeviceInterfaceID187 108 | #define DeviceVersion 187 109 | 110 | #elif defined (kIOUSBDeviceInterfaceID182) 111 | 112 | #define usb_device_t IOUSBDeviceInterface182 113 | #define DeviceInterfaceID kIOUSBDeviceInterfaceID182 114 | #define DeviceVersion 182 115 | 116 | #else 117 | 118 | #error "IOUSBFamily is too old. Please upgrade your OS" 119 | 120 | #endif 121 | 122 | #if !defined(IO_OBJECT_NULL) 123 | #define IO_OBJECT_NULL ((io_object_t) 0) 124 | #endif 125 | 126 | typedef IOCFPlugInInterface *io_cf_plugin_ref_t; 127 | typedef IONotificationPortRef io_notification_port_t; 128 | 129 | /* private structures */ 130 | struct darwin_device_priv { 131 | IOUSBDeviceDescriptor dev_descriptor; 132 | UInt32 location; 133 | char sys_path[21]; 134 | usb_device_t **device; 135 | int open_count; 136 | UInt8 first_config, active_config; 137 | }; 138 | 139 | struct darwin_device_handle_priv { 140 | int is_open; 141 | CFRunLoopSourceRef cfSource; 142 | int fds[2]; 143 | 144 | struct darwin_interface { 145 | usb_interface_t **interface; 146 | uint8_t num_endpoints; 147 | CFRunLoopSourceRef cfSource; 148 | uint64_t frames[256]; 149 | uint8_t endpoint_addrs[USB_MAXENDPOINTS]; 150 | } interfaces[USB_MAXINTERFACES]; 151 | }; 152 | 153 | struct darwin_transfer_priv { 154 | /* Isoc */ 155 | IOUSBIsocFrame *isoc_framelist; 156 | int num_iso_packets; 157 | 158 | /* Control */ 159 | #if !defined (LIBUSB_NO_TIMEOUT_DEVICE) 160 | IOUSBDevRequestTO req; 161 | #else 162 | IOUSBDevRequest req; 163 | #endif 164 | 165 | /* Bulk */ 166 | }; 167 | 168 | enum { 169 | MESSAGE_DEVICE_GONE, 170 | MESSAGE_ASYNC_IO_COMPLETE 171 | }; 172 | 173 | 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /libusb/os/linux_usbfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * usbfs header structures 3 | * Copyright © 2007 Daniel Drake 4 | * Copyright © 2001 Johannes Erdfelt 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef LIBUSB_USBFS_H 22 | #define LIBUSB_USBFS_H 23 | 24 | #include 25 | 26 | #define SYSFS_DEVICE_PATH "/sys/bus/usb/devices" 27 | 28 | struct usbfs_ctrltransfer { 29 | /* keep in sync with usbdevice_fs.h:usbdevfs_ctrltransfer */ 30 | uint8_t bmRequestType; 31 | uint8_t bRequest; 32 | uint16_t wValue; 33 | uint16_t wIndex; 34 | uint16_t wLength; 35 | 36 | uint32_t timeout; /* in milliseconds */ 37 | 38 | /* pointer to data */ 39 | void *data; 40 | }; 41 | 42 | struct usbfs_bulktransfer { 43 | /* keep in sync with usbdevice_fs.h:usbdevfs_bulktransfer */ 44 | unsigned int ep; 45 | unsigned int len; 46 | unsigned int timeout; /* in milliseconds */ 47 | 48 | /* pointer to data */ 49 | void *data; 50 | }; 51 | 52 | struct usbfs_setinterface { 53 | /* keep in sync with usbdevice_fs.h:usbdevfs_setinterface */ 54 | unsigned int interface; 55 | unsigned int altsetting; 56 | }; 57 | 58 | #define USBFS_MAXDRIVERNAME 255 59 | 60 | struct usbfs_getdriver { 61 | unsigned int interface; 62 | char driver[USBFS_MAXDRIVERNAME + 1]; 63 | }; 64 | 65 | #define USBFS_URB_SHORT_NOT_OK 0x01 66 | #define USBFS_URB_ISO_ASAP 0x02 67 | #define USBFS_URB_BULK_CONTINUATION 0x04 68 | #define USBFS_URB_QUEUE_BULK 0x10 69 | #define USBFS_URB_ZERO_PACKET 0x40 70 | 71 | enum usbfs_urb_type { 72 | USBFS_URB_TYPE_ISO = 0, 73 | USBFS_URB_TYPE_INTERRUPT = 1, 74 | USBFS_URB_TYPE_CONTROL = 2, 75 | USBFS_URB_TYPE_BULK = 3, 76 | }; 77 | 78 | struct usbfs_iso_packet_desc { 79 | unsigned int length; 80 | unsigned int actual_length; 81 | unsigned int status; 82 | }; 83 | 84 | #define MAX_ISO_BUFFER_LENGTH 32768 85 | #define MAX_BULK_BUFFER_LENGTH 16384 86 | #define MAX_CTRL_BUFFER_LENGTH 4096 87 | 88 | struct usbfs_urb { 89 | unsigned char type; 90 | unsigned char endpoint; 91 | int status; 92 | unsigned int flags; 93 | void *buffer; 94 | int buffer_length; 95 | int actual_length; 96 | int start_frame; 97 | int number_of_packets; 98 | int error_count; 99 | unsigned int signr; 100 | void *usercontext; 101 | struct usbfs_iso_packet_desc iso_frame_desc[0]; 102 | }; 103 | 104 | struct usbfs_connectinfo { 105 | unsigned int devnum; 106 | unsigned char slow; 107 | }; 108 | 109 | struct usbfs_ioctl { 110 | int ifno; /* interface 0..N ; negative numbers reserved */ 111 | int ioctl_code; /* MUST encode size + direction of data so the 112 | * macros in give correct values */ 113 | void *data; /* param buffer (in, or out) */ 114 | }; 115 | 116 | struct usbfs_hub_portinfo { 117 | unsigned char numports; 118 | unsigned char port[127]; /* port to device num mapping */ 119 | }; 120 | 121 | #define USBFS_CAP_ZERO_PACKET 0x01 122 | #define USBFS_CAP_BULK_CONTINUATION 0x02 123 | #define USBFS_CAP_NO_PACKET_SIZE_LIM 0x04 124 | #define USBFS_CAP_BULK_SCATTER_GATHER 0x08 125 | 126 | #define IOCTL_USBFS_CONTROL _IOWR('U', 0, struct usbfs_ctrltransfer) 127 | #define IOCTL_USBFS_BULK _IOWR('U', 2, struct usbfs_bulktransfer) 128 | #define IOCTL_USBFS_RESETEP _IOR('U', 3, unsigned int) 129 | #define IOCTL_USBFS_SETINTF _IOR('U', 4, struct usbfs_setinterface) 130 | #define IOCTL_USBFS_SETCONFIG _IOR('U', 5, unsigned int) 131 | #define IOCTL_USBFS_GETDRIVER _IOW('U', 8, struct usbfs_getdriver) 132 | #define IOCTL_USBFS_SUBMITURB _IOR('U', 10, struct usbfs_urb) 133 | #define IOCTL_USBFS_DISCARDURB _IO('U', 11) 134 | #define IOCTL_USBFS_REAPURB _IOW('U', 12, void *) 135 | #define IOCTL_USBFS_REAPURBNDELAY _IOW('U', 13, void *) 136 | #define IOCTL_USBFS_CLAIMINTF _IOR('U', 15, unsigned int) 137 | #define IOCTL_USBFS_RELEASEINTF _IOR('U', 16, unsigned int) 138 | #define IOCTL_USBFS_CONNECTINFO _IOW('U', 17, struct usbfs_connectinfo) 139 | #define IOCTL_USBFS_IOCTL _IOWR('U', 18, struct usbfs_ioctl) 140 | #define IOCTL_USBFS_HUB_PORTINFO _IOR('U', 19, struct usbfs_hub_portinfo) 141 | #define IOCTL_USBFS_RESET _IO('U', 20) 142 | #define IOCTL_USBFS_CLEAR_HALT _IOR('U', 21, unsigned int) 143 | #define IOCTL_USBFS_DISCONNECT _IO('U', 22) 144 | #define IOCTL_USBFS_CONNECT _IO('U', 23) 145 | #define IOCTL_USBFS_CLAIM_PORT _IOR('U', 24, unsigned int) 146 | #define IOCTL_USBFS_RELEASE_PORT _IOR('U', 25, unsigned int) 147 | #define IOCTL_USBFS_GET_CAPABILITIES _IOR('U', 26, __u32) 148 | 149 | #endif 150 | -------------------------------------------------------------------------------- /libusb/os/poll_posix.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUSB_POLL_POSIX_H 2 | #define LIBUSB_POLL_POSIX_H 3 | 4 | #define usbi_write write 5 | #define usbi_read read 6 | #define usbi_close close 7 | #define usbi_pipe pipe 8 | #define usbi_poll poll 9 | 10 | #endif /* LIBUSB_POLL_POSIX_H */ 11 | -------------------------------------------------------------------------------- /libusb/os/poll_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows compat: POSIX compatibility wrapper 3 | * Copyright © 2009-2010 Pete Batard 4 | * With contributions from Michael Plante, Orin Eman et al. 5 | * Parts of poll implementation from libusb-win32, by Stephan Meyer et al. 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | */ 22 | #pragma once 23 | 24 | #if defined(_MSC_VER) 25 | // disable /W4 MSVC warnings that are benign 26 | #pragma warning(disable:4127) // conditional expression is constant 27 | #endif 28 | 29 | // Handle synchronous completion through the overlapped structure 30 | #if !defined(STATUS_REPARSE) // reuse the REPARSE status code 31 | #define STATUS_REPARSE ((LONG)0x00000104L) 32 | #endif 33 | #define STATUS_COMPLETED_SYNCHRONOUSLY STATUS_REPARSE 34 | #define HasOverlappedIoCompletedSync(lpOverlapped) (((DWORD)(lpOverlapped)->Internal) == STATUS_COMPLETED_SYNCHRONOUSLY) 35 | 36 | #define DUMMY_HANDLE ((HANDLE)(LONG_PTR)-2) 37 | 38 | enum windows_version { 39 | WINDOWS_UNSUPPORTED, 40 | WINDOWS_XP, 41 | WINDOWS_2003, // also includes XP 64 42 | WINDOWS_VISTA_AND_LATER, 43 | }; 44 | extern enum windows_version windows_version; 45 | 46 | #define MAX_FDS 256 47 | 48 | #define POLLIN 0x0001 /* There is data to read */ 49 | #define POLLPRI 0x0002 /* There is urgent data to read */ 50 | #define POLLOUT 0x0004 /* Writing now will not block */ 51 | #define POLLERR 0x0008 /* Error condition */ 52 | #define POLLHUP 0x0010 /* Hung up */ 53 | #define POLLNVAL 0x0020 /* Invalid request: fd not open */ 54 | 55 | struct pollfd { 56 | int fd; /* file descriptor */ 57 | short events; /* requested events */ 58 | short revents; /* returned events */ 59 | }; 60 | 61 | // access modes 62 | enum rw_type { 63 | RW_NONE, 64 | RW_READ, 65 | RW_WRITE, 66 | }; 67 | 68 | // fd struct that can be used for polling on Windows 69 | struct winfd { 70 | int fd; // what's exposed to libusb core 71 | HANDLE handle; // what we need to attach overlapped to the I/O op, so we can poll it 72 | OVERLAPPED* overlapped; // what will report our I/O status 73 | enum rw_type rw; // I/O transfer direction: read *XOR* write (NOT BOTH) 74 | }; 75 | extern const struct winfd INVALID_WINFD; 76 | 77 | int usbi_pipe(int pipefd[2]); 78 | int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout); 79 | ssize_t usbi_write(int fd, const void *buf, size_t count); 80 | ssize_t usbi_read(int fd, void *buf, size_t count); 81 | int usbi_close(int fd); 82 | 83 | void init_polling(void); 84 | void exit_polling(void); 85 | struct winfd usbi_create_fd(HANDLE handle, int access_mode); 86 | void usbi_free_fd(int fd); 87 | struct winfd fd_to_winfd(int fd); 88 | struct winfd handle_to_winfd(HANDLE handle); 89 | struct winfd overlapped_to_winfd(OVERLAPPED* overlapped); 90 | 91 | /* 92 | * Timeval operations 93 | */ 94 | #if defined(DDKBUILD) 95 | #include // defines timeval functions on DDK 96 | #endif 97 | 98 | #if !defined(TIMESPEC_TO_TIMEVAL) 99 | #define TIMESPEC_TO_TIMEVAL(tv, ts) { \ 100 | (tv)->tv_sec = (long)(ts)->tv_sec; \ 101 | (tv)->tv_usec = (long)(ts)->tv_nsec / 1000; \ 102 | } 103 | #endif 104 | #if !defined(timersub) 105 | #define timersub(a, b, result) \ 106 | do { \ 107 | (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 108 | (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 109 | if ((result)->tv_usec < 0) { \ 110 | --(result)->tv_sec; \ 111 | (result)->tv_usec += 1000000; \ 112 | } \ 113 | } while (0) 114 | #endif 115 | -------------------------------------------------------------------------------- /libusb/os/threads_posix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libusbx synchronization using POSIX Threads 3 | * 4 | * Copyright © 2011 Vitali Lovich 5 | * Copyright © 2011 Peter Stuge 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #if defined(__linux__) || defined(__OpenBSD__) 23 | # if defined(__linux__) 24 | # define _GNU_SOURCE 25 | # else 26 | # define _BSD_SOURCE 27 | # endif 28 | # include 29 | # include 30 | #elif defined(__APPLE__) 31 | # include 32 | #elif defined(__CYGWIN__) 33 | # include 34 | #endif 35 | 36 | #include "threads_posix.h" 37 | 38 | int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) 39 | { 40 | int err; 41 | pthread_mutexattr_t stack_attr; 42 | if (!attr) { 43 | attr = &stack_attr; 44 | err = pthread_mutexattr_init(&stack_attr); 45 | if (err != 0) 46 | return err; 47 | } 48 | 49 | /* mutexattr_settype requires _GNU_SOURCE or _XOPEN_SOURCE >= 500 on Linux */ 50 | err = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE); 51 | if (err != 0) 52 | goto finish; 53 | 54 | err = pthread_mutex_init(mutex, attr); 55 | 56 | finish: 57 | if (attr == &stack_attr) 58 | pthread_mutexattr_destroy(&stack_attr); 59 | 60 | return err; 61 | } 62 | 63 | int usbi_get_tid(void) 64 | { 65 | int ret = -1; 66 | #if defined(__linux__) 67 | ret = syscall(SYS_gettid); 68 | #elif defined(__OpenBSD__) 69 | /* The following only works with OpenBSD > 5.1 as it requires 70 | real thread support. For 5.1 and earlier, -1 is returned. */ 71 | ret = syscall(SYS_getthrid); 72 | #elif defined(__APPLE__) 73 | ret = mach_thread_self(); 74 | mach_port_deallocate(mach_task_self(), ret); 75 | #elif defined(__CYGWIN__) 76 | ret = GetCurrentThreadId(); 77 | #endif 78 | /* TODO: NetBSD thread ID support */ 79 | return ret; 80 | } 81 | -------------------------------------------------------------------------------- /libusb/os/threads_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libusbx synchronization using POSIX Threads 3 | * 4 | * Copyright © 2010 Peter Stuge 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef LIBUSB_THREADS_POSIX_H 22 | #define LIBUSB_THREADS_POSIX_H 23 | 24 | #include 25 | 26 | #define usbi_mutex_static_t pthread_mutex_t 27 | #define USBI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER 28 | #define usbi_mutex_static_lock pthread_mutex_lock 29 | #define usbi_mutex_static_unlock pthread_mutex_unlock 30 | 31 | #define usbi_mutex_t pthread_mutex_t 32 | #define usbi_mutex_init pthread_mutex_init 33 | #define usbi_mutex_lock pthread_mutex_lock 34 | #define usbi_mutex_unlock pthread_mutex_unlock 35 | #define usbi_mutex_trylock pthread_mutex_trylock 36 | #define usbi_mutex_destroy pthread_mutex_destroy 37 | 38 | #define usbi_cond_t pthread_cond_t 39 | #define usbi_cond_init pthread_cond_init 40 | #define usbi_cond_wait pthread_cond_wait 41 | #define usbi_cond_timedwait pthread_cond_timedwait 42 | #define usbi_cond_broadcast pthread_cond_broadcast 43 | #define usbi_cond_destroy pthread_cond_destroy 44 | #define usbi_cond_signal pthread_cond_signal 45 | 46 | extern int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr); 47 | 48 | int usbi_get_tid(void); 49 | 50 | #endif /* LIBUSB_THREADS_POSIX_H */ 51 | -------------------------------------------------------------------------------- /libusb/os/threads_windows.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libusbx synchronization on Microsoft Windows 3 | * 4 | * Copyright © 2010 Michael Plante 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "libusbi.h" 27 | 28 | 29 | int usbi_mutex_init(usbi_mutex_t *mutex, 30 | const usbi_mutexattr_t *attr) { 31 | UNUSED(attr); 32 | if(! mutex) return ((errno=EINVAL)); 33 | *mutex = CreateMutex(NULL, FALSE, NULL); 34 | if(!*mutex) return ((errno=ENOMEM)); 35 | return 0; 36 | } 37 | int usbi_mutex_destroy(usbi_mutex_t *mutex) { 38 | // It is not clear if CloseHandle failure is due to failure to unlock. 39 | // If so, this should be errno=EBUSY. 40 | if(!mutex || !CloseHandle(*mutex)) return ((errno=EINVAL)); 41 | *mutex = NULL; 42 | return 0; 43 | } 44 | int usbi_mutex_trylock(usbi_mutex_t *mutex) { 45 | DWORD result; 46 | if(!mutex) return ((errno=EINVAL)); 47 | result = WaitForSingleObject(*mutex, 0); 48 | if(result == WAIT_OBJECT_0 || result == WAIT_ABANDONED) 49 | return 0; // acquired (ToDo: check that abandoned is ok) 50 | if(result == WAIT_TIMEOUT) 51 | return ((errno=EBUSY)); 52 | return ((errno=EINVAL)); // don't know how this would happen 53 | // so don't know proper errno 54 | } 55 | int usbi_mutex_lock(usbi_mutex_t *mutex) { 56 | DWORD result; 57 | if(!mutex) return ((errno=EINVAL)); 58 | result = WaitForSingleObject(*mutex, INFINITE); 59 | if(result == WAIT_OBJECT_0 || result == WAIT_ABANDONED) 60 | return 0; // acquired (ToDo: check that abandoned is ok) 61 | return ((errno=EINVAL)); // don't know how this would happen 62 | // so don't know proper errno 63 | } 64 | int usbi_mutex_unlock(usbi_mutex_t *mutex) { 65 | if(!mutex) return ((errno=EINVAL)); 66 | if(!ReleaseMutex(*mutex)) return ((errno=EPERM )); 67 | return 0; 68 | } 69 | 70 | int usbi_mutex_static_lock(usbi_mutex_static_t *mutex) { 71 | if(!mutex) return ((errno=EINVAL)); 72 | while (InterlockedExchange((LONG *)mutex, 1) == 1) { 73 | SleepEx(0, TRUE); 74 | } 75 | return 0; 76 | } 77 | int usbi_mutex_static_unlock(usbi_mutex_static_t *mutex) { 78 | if(!mutex) return ((errno=EINVAL)); 79 | *mutex = 0; 80 | return 0; 81 | } 82 | 83 | 84 | 85 | int usbi_cond_init(usbi_cond_t *cond, 86 | const usbi_condattr_t *attr) { 87 | UNUSED(attr); 88 | if(!cond) return ((errno=EINVAL)); 89 | list_init(&cond->waiters ); 90 | list_init(&cond->not_waiting); 91 | return 0; 92 | } 93 | int usbi_cond_destroy(usbi_cond_t *cond) { 94 | // This assumes no one is using this anymore. The check MAY NOT BE safe. 95 | struct usbi_cond_perthread *pos, *next_pos = NULL; 96 | if(!cond) return ((errno=EINVAL)); 97 | if(!list_empty(&cond->waiters)) return ((errno=EBUSY )); // (!see above!) 98 | list_for_each_entry_safe(pos, next_pos, &cond->not_waiting, list, struct usbi_cond_perthread) { 99 | CloseHandle(pos->event); 100 | list_del(&pos->list); 101 | free(pos); 102 | } 103 | 104 | return 0; 105 | } 106 | 107 | int usbi_cond_broadcast(usbi_cond_t *cond) { 108 | // Assumes mutex is locked; this is not in keeping with POSIX spec, but 109 | // libusb does this anyway, so we simplify by not adding more sync 110 | // primitives to the CV definition! 111 | int fail = 0; 112 | struct usbi_cond_perthread *pos; 113 | if(!cond) return ((errno=EINVAL)); 114 | list_for_each_entry(pos, &cond->waiters, list, struct usbi_cond_perthread) { 115 | if(!SetEvent(pos->event)) 116 | fail = 1; 117 | } 118 | // The wait function will remove its respective item from the list. 119 | return fail ? ((errno=EINVAL)) : 0; 120 | } 121 | int usbi_cond_signal(usbi_cond_t *cond) { 122 | // Assumes mutex is locked; this is not in keeping with POSIX spec, but 123 | // libusb does this anyway, so we simplify by not adding more sync 124 | // primitives to the CV definition! 125 | struct usbi_cond_perthread *pos; 126 | if(!cond) return ((errno=EINVAL)); 127 | if(list_empty(&cond->waiters)) return 0; // no one to wakeup. 128 | pos = list_entry(&cond->waiters.next, struct usbi_cond_perthread, list); 129 | // The wait function will remove its respective item from the list. 130 | return SetEvent(pos->event) ? 0 : ((errno=EINVAL)); 131 | } 132 | static int __inline usbi_cond_intwait(usbi_cond_t *cond, 133 | usbi_mutex_t *mutex, 134 | DWORD timeout_ms) { 135 | struct usbi_cond_perthread *pos; 136 | int found = 0, r; 137 | DWORD r2,tid = GetCurrentThreadId(); 138 | if(!cond || !mutex) return ((errno=EINVAL)); 139 | list_for_each_entry(pos, &cond->not_waiting, list, struct usbi_cond_perthread) { 140 | if(tid == pos->tid) { 141 | found = 1; 142 | break; 143 | } 144 | } 145 | if(!found) { 146 | pos = (struct usbi_cond_perthread*) calloc(1, sizeof(struct usbi_cond_perthread)); 147 | if(!pos) return ((errno=ENOMEM)); // This errno is not POSIX-allowed. 148 | pos->tid = tid; 149 | pos->event = CreateEvent(NULL, FALSE, FALSE, NULL); // auto-reset. 150 | if(!pos->event) { 151 | free(pos); 152 | return ((errno=ENOMEM)); 153 | } 154 | list_add(&pos->list, &cond->not_waiting); 155 | } 156 | 157 | list_del(&pos->list); // remove from not_waiting list. 158 | list_add(&pos->list, &cond->waiters); 159 | 160 | r = usbi_mutex_unlock(mutex); 161 | if(r) return r; 162 | r2 = WaitForSingleObject(pos->event, timeout_ms); 163 | r = usbi_mutex_lock(mutex); 164 | if(r) return r; 165 | 166 | list_del(&pos->list); 167 | list_add(&pos->list, &cond->not_waiting); 168 | 169 | if(r2 == WAIT_TIMEOUT) return ((errno=ETIMEDOUT)); 170 | 171 | return 0; 172 | } 173 | // N.B.: usbi_cond_*wait() can also return ENOMEM, even though pthread_cond_*wait cannot! 174 | int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex) { 175 | return usbi_cond_intwait(cond, mutex, INFINITE); 176 | } 177 | int usbi_cond_timedwait(usbi_cond_t *cond, 178 | usbi_mutex_t *mutex, 179 | const struct timespec *abstime) { 180 | FILETIME filetime; 181 | ULARGE_INTEGER rtime; 182 | struct timeval targ_time, cur_time, delta_time; 183 | struct timespec cur_time_ns; 184 | DWORD millis; 185 | extern const uint64_t epoch_time; 186 | 187 | GetSystemTimeAsFileTime(&filetime); 188 | rtime.LowPart = filetime.dwLowDateTime; 189 | rtime.HighPart = filetime.dwHighDateTime; 190 | rtime.QuadPart -= epoch_time; 191 | cur_time_ns.tv_sec = (long)(rtime.QuadPart / 10000000); 192 | cur_time_ns.tv_nsec = (long)((rtime.QuadPart % 10000000)*100); 193 | TIMESPEC_TO_TIMEVAL(&cur_time, &cur_time_ns); 194 | 195 | TIMESPEC_TO_TIMEVAL(&targ_time, abstime); 196 | timersub(&targ_time, &cur_time, &delta_time); 197 | if(delta_time.tv_sec < 0) // abstime already passed? 198 | millis = 0; 199 | else { 200 | millis = delta_time.tv_usec/1000; 201 | millis += delta_time.tv_sec *1000; 202 | if (delta_time.tv_usec % 1000) // round up to next millisecond 203 | millis++; 204 | } 205 | 206 | return usbi_cond_intwait(cond, mutex, millis); 207 | } 208 | 209 | int usbi_get_tid(void) { 210 | return GetCurrentThreadId(); 211 | } 212 | -------------------------------------------------------------------------------- /libusb/os/threads_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libusbx synchronization on Microsoft Windows 3 | * 4 | * Copyright © 2010 Michael Plante 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef LIBUSB_THREADS_WINDOWS_H 22 | #define LIBUSB_THREADS_WINDOWS_H 23 | 24 | #define usbi_mutex_static_t volatile LONG 25 | #define USBI_MUTEX_INITIALIZER 0 26 | 27 | #define usbi_mutex_t HANDLE 28 | 29 | struct usbi_cond_perthread { 30 | struct list_head list; 31 | DWORD tid; 32 | HANDLE event; 33 | }; 34 | struct usbi_cond_t_ { 35 | // Every time a thread touches the CV, it winds up in one of these lists. 36 | // It stays there until the CV is destroyed, even if the thread 37 | // terminates. 38 | struct list_head waiters; 39 | struct list_head not_waiting; 40 | }; 41 | typedef struct usbi_cond_t_ usbi_cond_t; 42 | 43 | // We *were* getting timespec from pthread.h: 44 | #if (!defined(HAVE_STRUCT_TIMESPEC) && !defined(_TIMESPEC_DEFINED)) 45 | #define HAVE_STRUCT_TIMESPEC 1 46 | #define _TIMESPEC_DEFINED 1 47 | struct timespec { 48 | long tv_sec; 49 | long tv_nsec; 50 | }; 51 | #endif /* HAVE_STRUCT_TIMESPEC | _TIMESPEC_DEFINED */ 52 | 53 | // We *were* getting ETIMEDOUT from pthread.h: 54 | #ifndef ETIMEDOUT 55 | # define ETIMEDOUT 10060 /* This is the value in winsock.h. */ 56 | #endif 57 | 58 | #define usbi_mutexattr_t void 59 | #define usbi_condattr_t void 60 | 61 | // all Windows mutexes are recursive 62 | #define usbi_mutex_init_recursive(mutex, attr) usbi_mutex_init((mutex), (attr)) 63 | 64 | int usbi_mutex_static_lock(usbi_mutex_static_t *mutex); 65 | int usbi_mutex_static_unlock(usbi_mutex_static_t *mutex); 66 | 67 | 68 | int usbi_mutex_init(usbi_mutex_t *mutex, 69 | const usbi_mutexattr_t *attr); 70 | int usbi_mutex_lock(usbi_mutex_t *mutex); 71 | int usbi_mutex_unlock(usbi_mutex_t *mutex); 72 | int usbi_mutex_trylock(usbi_mutex_t *mutex); 73 | int usbi_mutex_destroy(usbi_mutex_t *mutex); 74 | 75 | int usbi_cond_init(usbi_cond_t *cond, 76 | const usbi_condattr_t *attr); 77 | int usbi_cond_destroy(usbi_cond_t *cond); 78 | int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex); 79 | int usbi_cond_timedwait(usbi_cond_t *cond, 80 | usbi_mutex_t *mutex, 81 | const struct timespec *abstime); 82 | int usbi_cond_broadcast(usbi_cond_t *cond); 83 | int usbi_cond_signal(usbi_cond_t *cond); 84 | 85 | int usbi_get_tid(void); 86 | 87 | #endif /* LIBUSB_THREADS_WINDOWS_H */ 88 | -------------------------------------------------------------------------------- /libusb/version.h: -------------------------------------------------------------------------------- 1 | /* This file is parsed by m4 and windres and RC.EXE so please keep it simple. */ 2 | #include "version_nano.h" 3 | #ifndef LIBUSB_MAJOR 4 | #define LIBUSB_MAJOR 1 5 | #endif 6 | #ifndef LIBUSB_MINOR 7 | #define LIBUSB_MINOR 0 8 | #endif 9 | #ifndef LIBUSB_MICRO 10 | #define LIBUSB_MICRO 14 11 | #endif 12 | #ifndef LIBUSB_NANO 13 | #define LIBUSB_NANO 0 14 | #endif 15 | /* LIBUSB_RC is the release candidate suffix. Should normally be empty. */ 16 | #ifndef LIBUSB_RC 17 | #define LIBUSB_RC "" 18 | #endif 19 | -------------------------------------------------------------------------------- /libusb/version_nano.h: -------------------------------------------------------------------------------- 1 | #define LIBUSB_NANO 10592 2 | -------------------------------------------------------------------------------- /msvc/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Manual config for MSVC. */ 2 | 3 | #ifndef _MSC_VER 4 | #warn "msvc/config.h shouldn't be included for your development environment." 5 | #error "Please make sure the msvc/ directory is removed from your build path." 6 | #endif 7 | 8 | /* Disable: warning C4200: nonstandard extension used : zero-sized array in struct/union */ 9 | #pragma warning(disable:4200) 10 | #if defined(_PREFAST_) 11 | /* Disable "Banned API" errors when using the MS's WDK OACR/Prefast */ 12 | #pragma warning(disable:28719) 13 | /* Disable "The function 'InitializeCriticalSection' must be called from within a try/except block" */ 14 | #pragma warning(disable:28125) 15 | #endif 16 | 17 | /* Default visibility */ 18 | #define DEFAULT_VISIBILITY /**/ 19 | 20 | /* Start with debug message logging enabled */ 21 | //#define ENABLE_DEBUG_LOGGING 1 22 | 23 | /* Message logging */ 24 | #define ENABLE_LOGGING 1 25 | 26 | /* Windows backend */ 27 | #define OS_WINDOWS 1 28 | 29 | /* type of second poll() argument */ 30 | #define POLL_NFDS_TYPE unsigned int 31 | -------------------------------------------------------------------------------- /msvc/ddk_build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | ::# default builds static library. 3 | ::# you can pass the following arguments (case insensitive): 4 | ::# - "DLL" to build a DLL instead of a static library 5 | ::# - "/MT" to build a static library compatible with MSVC's /MT option (LIBCMT vs MSVCRT) 6 | 7 | if Test%BUILD_ALT_DIR%==Test goto usage 8 | 9 | ::# process commandline parameters 10 | set TARGET=LIBRARY 11 | set STATIC_LIBC= 12 | set version=1.0 13 | set PWD=%~dp0 14 | set BUILD_CMD=build -bcwgZ -M2 15 | 16 | if "%1" == "" goto no_more_args 17 | ::# /I for case insensitive 18 | if /I Test%1==TestDLL set TARGET=DYNLINK 19 | if /I Test%1==Test/MT set STATIC_LIBC=1 20 | :no_more_args 21 | 22 | cd ..\libusb\os 23 | echo TARGETTYPE=%TARGET% > target 24 | copy target+..\..\msvc\libusb_sources sources >NUL 2>&1 25 | del target 26 | @echo on 27 | %BUILD_CMD% 28 | @echo off 29 | if errorlevel 1 goto builderror 30 | cd ..\.. 31 | 32 | set cpudir=i386 33 | set destType=Win32 34 | if %_BUILDARCH%==x86 goto isI386 35 | set cpudir=amd64 36 | set destType=x64 37 | :isI386 38 | 39 | set srcPath=libusb\os\obj%BUILD_ALT_DIR%\%cpudir% 40 | 41 | set dstPath=%destType%\Debug 42 | if %DDKBUILDENV%==chk goto isDebug 43 | set dstPath=%destType%\Release 44 | :isDebug 45 | 46 | if exist %destType% goto md2 47 | mkdir %destType% 48 | :md2 49 | if exist %dstPath% goto md3 50 | mkdir %dstPath% 51 | :md3 52 | if exist %dstPath%\dll goto md4 53 | mkdir %dstPath%\dll 54 | :md4 55 | if exist %dstPath%\lib goto md5 56 | md %dstPath%\lib 57 | :md5 58 | if exist %dstPath%\examples goto md6 59 | md %dstPath%\examples 60 | :md6 61 | @echo on 62 | 63 | @if /I NOT Test%1==TestDLL goto copylib 64 | copy %srcPath%\libusb-%version%.dll %dstPath%\dll 65 | copy %srcPath%\libusb-%version%.pdb %dstPath%\dll 66 | :copylib 67 | copy %srcPath%\libusb-%version%.lib %dstPath%\lib 68 | 69 | @echo off 70 | 71 | if exist examples\listdevs_ddkbuild goto md7 72 | md examples\listdevs_ddkbuild 73 | :md7 74 | 75 | cd examples\listdevs_ddkbuild 76 | copy ..\..\msvc\listdevs_sources sources >NUL 2>&1 77 | @echo on 78 | %BUILD_CMD% 79 | @echo off 80 | if errorlevel 1 goto builderror 81 | cd ..\.. 82 | 83 | set srcPath=examples\listdevs_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% 84 | @echo on 85 | 86 | copy %srcPath%\listdevs.exe %dstPath%\examples 87 | copy %srcPath%\listdevs.pdb %dstPath%\examples 88 | 89 | @echo off 90 | 91 | if exist examples\xusb_ddkbuild goto md8 92 | md examples\xusb_ddkbuild 93 | :md8 94 | 95 | cd examples\xusb_ddkbuild 96 | copy ..\..\msvc\xusb_sources sources >NUL 2>&1 97 | @echo on 98 | %BUILD_CMD% 99 | @echo off 100 | if errorlevel 1 goto builderror 101 | cd ..\.. 102 | 103 | set srcPath=examples\xusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% 104 | @echo on 105 | 106 | copy %srcPath%\xusb.exe %dstPath%\examples 107 | copy %srcPath%\xusb.pdb %dstPath%\examples 108 | 109 | @echo off 110 | 111 | if exist examples\getopt\getopt_ddkbuild goto md9 112 | md examples\getopt\getopt_ddkbuild 113 | :md9 114 | 115 | cd examples\getopt\getopt_ddkbuild 116 | copy ..\..\..\msvc\getopt_sources sources >NUL 2>&1 117 | @echo on 118 | %BUILD_CMD% 119 | @echo off 120 | if errorlevel 1 goto builderror 121 | cd ..\..\.. 122 | 123 | if exist examples\fxload_ddkbuild goto md8 124 | md examples\fxload_ddkbuild 125 | :md8 126 | 127 | cd examples\fxload_ddkbuild 128 | copy ..\..\msvc\fxload_sources sources >NUL 2>&1 129 | @echo on 130 | %BUILD_CMD% 131 | @echo off 132 | if errorlevel 1 goto builderror 133 | cd ..\.. 134 | 135 | set srcPath=examples\fxload_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% 136 | @echo on 137 | 138 | copy %srcPath%\fxload.exe %dstPath%\examples 139 | copy %srcPath%\fxload.pdb %dstPath%\examples 140 | 141 | @echo off 142 | 143 | cd msvc 144 | goto done 145 | 146 | :usage 147 | echo ddk_build must be run in a WDK build environment 148 | pause 149 | goto done 150 | 151 | :builderror 152 | echo Build failed 153 | 154 | :done 155 | cd %PWD% 156 | -------------------------------------------------------------------------------- /msvc/fxload_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {651ff73d-037b-4903-8dd3-56e9950be25c} 10 | 11 | 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /msvc/fxload_2012.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {651ff73d-037b-4903-8dd3-56e9950be25c} 10 | 11 | 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /msvc/fxload_sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=fxload 2 | TARGETTYPE=PROGRAM 3 | 386_STDCALL=0 4 | 5 | _NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 6 | 7 | !IFNDEF MSC_WARNING_LEVEL 8 | MSC_WARNING_LEVEL=/W3 9 | !ENDIF 10 | 11 | !IFDEF STATIC_LIBC 12 | USE_LIBCMT=1 13 | !ELSE 14 | USE_MSVCRT=1 15 | !ENDIF 16 | 17 | UMTYPE=console 18 | INCLUDES=..\..\msvc;..\..\libusb;..\getopt;$(DDK_INC_PATH) 19 | C_DEFINES=$(C_DEFINES) /D__GNU_LIBRARY__ 20 | UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib \ 21 | ..\getopt\getopt_ddkbuild\obj$(BUILD_ALT_DIR)\*\getopt.lib 22 | SOURCES=..\ezusb.c \ 23 | ..\fxload.c 24 | -------------------------------------------------------------------------------- /msvc/getopt_2005.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 28 | 31 | 34 | 37 | 40 | 43 | 51 | 54 | 57 | 60 | 64 | 67 | 70 | 73 | 76 | 79 | 80 | 87 | 90 | 93 | 96 | 99 | 103 | 110 | 113 | 116 | 119 | 123 | 126 | 129 | 132 | 135 | 138 | 139 | 147 | 150 | 153 | 156 | 159 | 162 | 169 | 172 | 175 | 178 | 182 | 185 | 188 | 191 | 194 | 197 | 198 | 206 | 209 | 212 | 215 | 218 | 222 | 228 | 231 | 234 | 237 | 241 | 244 | 247 | 250 | 253 | 256 | 257 | 258 | 259 | 260 | 261 | 266 | 269 | 270 | 273 | 274 | 275 | 280 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | -------------------------------------------------------------------------------- /msvc/getopt_2010.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E} 23 | getopt 24 | 25 | 26 | 27 | StaticLibrary 28 | Unicode 29 | true 30 | 31 | 32 | StaticLibrary 33 | Unicode 34 | 35 | 36 | StaticLibrary 37 | Unicode 38 | true 39 | 40 | 41 | StaticLibrary 42 | Unicode 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | <_ProjectFileVersion>10.0.30319.1 62 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\ 63 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\getopt\ 64 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\ 65 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\getopt\ 66 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\ 67 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\getopt\ 68 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\ 69 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\getopt\ 70 | 71 | 72 | 73 | HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 74 | true 75 | MultiThreadedDebug 76 | Level3 77 | ProgramDatabase 78 | 79 | 80 | true 81 | 82 | 83 | 84 | 85 | X64 86 | 87 | 88 | HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 89 | MultiThreadedDebug 90 | Level3 91 | ProgramDatabase 92 | 93 | 94 | true 95 | 96 | 97 | 98 | 99 | MaxSpeed 100 | HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 101 | MultiThreaded 102 | Level3 103 | 104 | 105 | true 106 | 107 | 108 | 109 | 110 | X64 111 | 112 | 113 | HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 114 | MultiThreaded 115 | Level3 116 | 117 | 118 | true 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /msvc/getopt_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /msvc/getopt_2012.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E} 23 | getopt 24 | 25 | 26 | 27 | StaticLibrary 28 | Unicode 29 | true 30 | v110 31 | 32 | 33 | StaticLibrary 34 | Unicode 35 | v110 36 | 37 | 38 | StaticLibrary 39 | Unicode 40 | true 41 | v110 42 | 43 | 44 | StaticLibrary 45 | Unicode 46 | v110 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | <_ProjectFileVersion>10.0.30319.1 66 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\ 67 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\getopt\ 68 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\ 69 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\getopt\ 70 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\ 71 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\getopt\ 72 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\ 73 | $(SolutionDir)..\$(Platform)\$(Configuration)\lib\getopt\ 74 | 75 | 76 | 77 | HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 78 | true 79 | MultiThreadedDebug 80 | Level3 81 | ProgramDatabase 82 | 83 | 84 | true 85 | 86 | 87 | 88 | 89 | X64 90 | 91 | 92 | HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 93 | MultiThreadedDebug 94 | Level3 95 | ProgramDatabase 96 | 97 | 98 | true 99 | 100 | 101 | 102 | 103 | MaxSpeed 104 | HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 105 | MultiThreaded 106 | Level3 107 | 108 | 109 | true 110 | 111 | 112 | 113 | 114 | X64 115 | 116 | 117 | HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 118 | MultiThreaded 119 | Level3 120 | 121 | 122 | true 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msvc/getopt_2012.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /msvc/getopt_sources: -------------------------------------------------------------------------------- 1 | TARGETTYPE=LIBRARY 2 | TARGETNAME=getopt 3 | 386_STDCALL=0 4 | 5 | _NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 6 | 7 | !IFNDEF MSC_WARNING_LEVEL 8 | MSC_WARNING_LEVEL=/W3 9 | !ENDIF 10 | 11 | USE_MSVCRT=1 12 | 13 | INCLUDES=$(DDK_INC_PATH) 14 | C_DEFINES = $(C_DEFINES) /DDDKBUILD /DHAVE_STRING_H 15 | 16 | TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ 17 | $(SDK_LIB_PATH)\user32.lib 18 | 19 | SOURCES=..\getopt1.c \ 20 | ..\getopt.c 21 | -------------------------------------------------------------------------------- /msvc/inttypes.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file was original part of the w64 mingw-runtime package. 4 | */ 5 | 6 | /* 7 | * THIS SOFTWARE IS NOT COPYRIGHTED 8 | * 9 | * Modified for libusb/MSVC: Pete Batard 10 | * 11 | * This source code is offered for use in the public domain. You may 12 | * use, modify or distribute it freely. 13 | * 14 | * This code is distributed in the hope that it will be useful but 15 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 16 | * DISCLAIMED. This includes but is not limited to warranties of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | * 19 | * Date: 2010-04-02 20 | */ 21 | 22 | #ifndef _MSC_VER 23 | #error This header should only be used with Microsoft compilers 24 | #endif 25 | 26 | /* 7.8 Format conversion of integer types */ 27 | 28 | #ifndef _INTTYPES_H_ 29 | #define _INTTYPES_H_ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | typedef struct { 38 | intmax_t quot; 39 | intmax_t rem; 40 | } imaxdiv_t; 41 | 42 | 43 | /* 7.8.1 Macros for format specifiers 44 | * 45 | * MS runtime does not yet understand C9x standard "ll" 46 | * length specifier. It appears to treat "ll" as "l". 47 | * The non-standard I64 length specifier causes warning in GCC, 48 | * but understood by MS runtime functions. 49 | */ 50 | 51 | /* fprintf macros for signed types */ 52 | #define PRId8 "d" 53 | #define PRId16 "d" 54 | #define PRId32 "d" 55 | #define PRId64 "I64d" 56 | 57 | #define PRIdLEAST8 "d" 58 | #define PRIdLEAST16 "d" 59 | #define PRIdLEAST32 "d" 60 | #define PRIdLEAST64 "I64d" 61 | 62 | #define PRIdFAST8 "d" 63 | #define PRIdFAST16 "d" 64 | #define PRIdFAST32 "d" 65 | #define PRIdFAST64 "I64d" 66 | 67 | #define PRIdMAX "I64d" 68 | 69 | #define PRIi8 "i" 70 | #define PRIi16 "i" 71 | #define PRIi32 "i" 72 | #define PRIi64 "I64i" 73 | 74 | #define PRIiLEAST8 "i" 75 | #define PRIiLEAST16 "i" 76 | #define PRIiLEAST32 "i" 77 | #define PRIiLEAST64 "I64i" 78 | 79 | #define PRIiFAST8 "i" 80 | #define PRIiFAST16 "i" 81 | #define PRIiFAST32 "i" 82 | #define PRIiFAST64 "I64i" 83 | 84 | #define PRIiMAX "I64i" 85 | 86 | #define PRIo8 "o" 87 | #define PRIo16 "o" 88 | #define PRIo32 "o" 89 | #define PRIo64 "I64o" 90 | 91 | #define PRIoLEAST8 "o" 92 | #define PRIoLEAST16 "o" 93 | #define PRIoLEAST32 "o" 94 | #define PRIoLEAST64 "I64o" 95 | 96 | #define PRIoFAST8 "o" 97 | #define PRIoFAST16 "o" 98 | #define PRIoFAST32 "o" 99 | #define PRIoFAST64 "I64o" 100 | 101 | #define PRIoMAX "I64o" 102 | 103 | /* fprintf macros for unsigned types */ 104 | #define PRIu8 "u" 105 | #define PRIu16 "u" 106 | #define PRIu32 "u" 107 | #define PRIu64 "I64u" 108 | 109 | 110 | #define PRIuLEAST8 "u" 111 | #define PRIuLEAST16 "u" 112 | #define PRIuLEAST32 "u" 113 | #define PRIuLEAST64 "I64u" 114 | 115 | #define PRIuFAST8 "u" 116 | #define PRIuFAST16 "u" 117 | #define PRIuFAST32 "u" 118 | #define PRIuFAST64 "I64u" 119 | 120 | #define PRIuMAX "I64u" 121 | 122 | #define PRIx8 "x" 123 | #define PRIx16 "x" 124 | #define PRIx32 "x" 125 | #define PRIx64 "I64x" 126 | 127 | #define PRIxLEAST8 "x" 128 | #define PRIxLEAST16 "x" 129 | #define PRIxLEAST32 "x" 130 | #define PRIxLEAST64 "I64x" 131 | 132 | #define PRIxFAST8 "x" 133 | #define PRIxFAST16 "x" 134 | #define PRIxFAST32 "x" 135 | #define PRIxFAST64 "I64x" 136 | 137 | #define PRIxMAX "I64x" 138 | 139 | #define PRIX8 "X" 140 | #define PRIX16 "X" 141 | #define PRIX32 "X" 142 | #define PRIX64 "I64X" 143 | 144 | #define PRIXLEAST8 "X" 145 | #define PRIXLEAST16 "X" 146 | #define PRIXLEAST32 "X" 147 | #define PRIXLEAST64 "I64X" 148 | 149 | #define PRIXFAST8 "X" 150 | #define PRIXFAST16 "X" 151 | #define PRIXFAST32 "X" 152 | #define PRIXFAST64 "I64X" 153 | 154 | #define PRIXMAX "I64X" 155 | 156 | /* 157 | * fscanf macros for signed int types 158 | * NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t 159 | * (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have 160 | * no length identifiers 161 | */ 162 | 163 | #define SCNd16 "hd" 164 | #define SCNd32 "d" 165 | #define SCNd64 "I64d" 166 | 167 | #define SCNdLEAST16 "hd" 168 | #define SCNdLEAST32 "d" 169 | #define SCNdLEAST64 "I64d" 170 | 171 | #define SCNdFAST16 "hd" 172 | #define SCNdFAST32 "d" 173 | #define SCNdFAST64 "I64d" 174 | 175 | #define SCNdMAX "I64d" 176 | 177 | #define SCNi16 "hi" 178 | #define SCNi32 "i" 179 | #define SCNi64 "I64i" 180 | 181 | #define SCNiLEAST16 "hi" 182 | #define SCNiLEAST32 "i" 183 | #define SCNiLEAST64 "I64i" 184 | 185 | #define SCNiFAST16 "hi" 186 | #define SCNiFAST32 "i" 187 | #define SCNiFAST64 "I64i" 188 | 189 | #define SCNiMAX "I64i" 190 | 191 | #define SCNo16 "ho" 192 | #define SCNo32 "o" 193 | #define SCNo64 "I64o" 194 | 195 | #define SCNoLEAST16 "ho" 196 | #define SCNoLEAST32 "o" 197 | #define SCNoLEAST64 "I64o" 198 | 199 | #define SCNoFAST16 "ho" 200 | #define SCNoFAST32 "o" 201 | #define SCNoFAST64 "I64o" 202 | 203 | #define SCNoMAX "I64o" 204 | 205 | #define SCNx16 "hx" 206 | #define SCNx32 "x" 207 | #define SCNx64 "I64x" 208 | 209 | #define SCNxLEAST16 "hx" 210 | #define SCNxLEAST32 "x" 211 | #define SCNxLEAST64 "I64x" 212 | 213 | #define SCNxFAST16 "hx" 214 | #define SCNxFAST32 "x" 215 | #define SCNxFAST64 "I64x" 216 | 217 | #define SCNxMAX "I64x" 218 | 219 | /* fscanf macros for unsigned int types */ 220 | 221 | #define SCNu16 "hu" 222 | #define SCNu32 "u" 223 | #define SCNu64 "I64u" 224 | 225 | #define SCNuLEAST16 "hu" 226 | #define SCNuLEAST32 "u" 227 | #define SCNuLEAST64 "I64u" 228 | 229 | #define SCNuFAST16 "hu" 230 | #define SCNuFAST32 "u" 231 | #define SCNuFAST64 "I64u" 232 | 233 | #define SCNuMAX "I64u" 234 | 235 | #ifdef _WIN64 236 | #define PRIdPTR "I64d" 237 | #define PRIiPTR "I64i" 238 | #define PRIoPTR "I64o" 239 | #define PRIuPTR "I64u" 240 | #define PRIxPTR "I64x" 241 | #define PRIXPTR "I64X" 242 | #define SCNdPTR "I64d" 243 | #define SCNiPTR "I64i" 244 | #define SCNoPTR "I64o" 245 | #define SCNxPTR "I64x" 246 | #define SCNuPTR "I64u" 247 | #else 248 | #define PRIdPTR "d" 249 | #define PRIiPTR "i" 250 | #define PRIoPTR "o" 251 | #define PRIuPTR "u" 252 | #define PRIxPTR "x" 253 | #define PRIXPTR "X" 254 | #define SCNdPTR "d" 255 | #define SCNiPTR "i" 256 | #define SCNoPTR "o" 257 | #define SCNxPTR "x" 258 | #define SCNuPTR "u" 259 | #endif 260 | 261 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 262 | /* 263 | * no length modifier for char types prior to C9x 264 | * MS runtime scanf appears to treat "hh" as "h" 265 | */ 266 | 267 | /* signed char */ 268 | #define SCNd8 "hhd" 269 | #define SCNdLEAST8 "hhd" 270 | #define SCNdFAST8 "hhd" 271 | 272 | #define SCNi8 "hhi" 273 | #define SCNiLEAST8 "hhi" 274 | #define SCNiFAST8 "hhi" 275 | 276 | #define SCNo8 "hho" 277 | #define SCNoLEAST8 "hho" 278 | #define SCNoFAST8 "hho" 279 | 280 | #define SCNx8 "hhx" 281 | #define SCNxLEAST8 "hhx" 282 | #define SCNxFAST8 "hhx" 283 | 284 | /* unsigned char */ 285 | #define SCNu8 "hhu" 286 | #define SCNuLEAST8 "hhu" 287 | #define SCNuFAST8 "hhu" 288 | #endif /* __STDC_VERSION__ >= 199901 */ 289 | 290 | 291 | #ifdef __cplusplus 292 | } 293 | #endif 294 | 295 | #endif /* ndef _INTTYPES_H */ 296 | -------------------------------------------------------------------------------- /msvc/libusb_dll.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="libusb_dll" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=libusb_dll - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "libusb_dll.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "libusb_dll.mak" CFG="libusb_dll - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "libusb_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "libusb_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "libusb_dll - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "../Win32/Release/dll" 42 | # PROP Intermediate_Dir "../Win32/Release/dll" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "LIBUSB_DLL_EXPORTS" /YX /FD /c 46 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "../libusb" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /D "_USRDLL" /FR /FD /EHsc /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 50 | # ADD RSC /l 0x409 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Win32/Release/dll/libusb-1.0.dll" 57 | 58 | !ELSEIF "$(CFG)" == "libusb_dll - Win32 Debug" 59 | 60 | # PROP BASE Use_MFC 0 61 | # PROP BASE Use_Debug_Libraries 1 62 | # PROP BASE Output_Dir "Debug" 63 | # PROP BASE Intermediate_Dir "Debug" 64 | # PROP BASE Target_Dir "" 65 | # PROP Use_MFC 0 66 | # PROP Use_Debug_Libraries 1 67 | # PROP Output_Dir "../Win32/Debug/dll" 68 | # PROP Intermediate_Dir "../Win32/Debug/dll" 69 | # PROP Ignore_Export_Lib 0 70 | # PROP Target_Dir "" 71 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "LIBUSB_DLL_EXPORTS" /YX /FD /GZ /c 72 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "../libusb" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /D "_USRDLL" /FR /FD /EHsc /c 73 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 75 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 76 | # ADD RSC /l 0x409 /d "_DEBUG" 77 | BSC32=bscmake.exe 78 | # ADD BASE BSC32 /nologo 79 | # ADD BSC32 /nologo /n 80 | LINK32=link.exe 81 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept 82 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Win32/Debug/dll/libusb-1.0.dll" 83 | # SUBTRACT LINK32 /pdb:none /incremental:no 84 | 85 | !ENDIF 86 | 87 | # Begin Target 88 | 89 | # Name "libusb_dll - Win32 Release" 90 | # Name "libusb_dll - Win32 Debug" 91 | # Begin Group "Source Files" 92 | 93 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 94 | # Begin Source File 95 | 96 | SOURCE=..\libusb\core.c 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=..\libusb\os\darwin_usb.c 101 | # PROP Exclude_From_Build 1 102 | # End Source File 103 | # Begin Source File 104 | 105 | SOURCE=..\libusb\descriptor.c 106 | # End Source File 107 | # Begin Source File 108 | 109 | SOURCE=..\libusb\io.c 110 | # End Source File 111 | # Begin Source File 112 | 113 | SOURCE="..\libusb\libusb-1.0.rc" 114 | # End Source File 115 | # Begin Source File 116 | 117 | SOURCE="..\libusb\libusb-1.0.def" 118 | # End Source File 119 | # Begin Source File 120 | 121 | SOURCE=..\libusb\os\linux_usbfs.c 122 | # PROP Exclude_From_Build 1 123 | # End Source File 124 | # Begin Source File 125 | 126 | SOURCE=..\libusb\os\poll_windows.c 127 | # End Source File 128 | # Begin Source File 129 | 130 | SOURCE=..\libusb\sync.c 131 | # End Source File 132 | # Begin Source File 133 | 134 | SOURCE=..\libusb\os\threads_windows.c 135 | # End Source File 136 | # Begin Source File 137 | 138 | SOURCE=..\libusb\os\windows_usb.c 139 | # End Source File 140 | # End Group 141 | # Begin Group "Header Files" 142 | 143 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 144 | # Begin Source File 145 | 146 | SOURCE=.\config.h 147 | # End Source File 148 | # Begin Source File 149 | 150 | SOURCE=..\libusb\os\darwin_usb.h 151 | # End Source File 152 | # Begin Source File 153 | 154 | SOURCE=..\libusb\libusb.h 155 | # End Source File 156 | # Begin Source File 157 | 158 | SOURCE=..\libusb\libusbi.h 159 | # End Source File 160 | # Begin Source File 161 | 162 | SOURCE=..\libusb\os\linux_usbfs.h 163 | # End Source File 164 | # Begin Source File 165 | 166 | SOURCE=..\libusb\os\poll_posix.h 167 | # End Source File 168 | # Begin Source File 169 | 170 | SOURCE=..\libusb\os\poll_windows.h 171 | # End Source File 172 | # Begin Source File 173 | 174 | SOURCE=..\libusb\os\threads_posix.h 175 | # End Source File 176 | # Begin Source File 177 | 178 | SOURCE=..\libusb\os\threads_windows.h 179 | # End Source File 180 | # Begin Source File 181 | 182 | SOURCE=..\libusb\os\windows_usb.h 183 | # End Source File 184 | # End Group 185 | # Begin Group "Resource Files" 186 | 187 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 188 | # End Group 189 | # End Target 190 | # End Project 191 | -------------------------------------------------------------------------------- /msvc/libusb_dll_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {d81e81ca-b13e-4a15-b54b-b12b41361e6b} 14 | 15 | 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Header Files 42 | 43 | 44 | Header Files 45 | 46 | 47 | Header Files 48 | 49 | 50 | Header Files 51 | 52 | 53 | Header Files 54 | 55 | 56 | Header Files 57 | 58 | 59 | 60 | 61 | Resource Files 62 | 63 | 64 | 65 | 66 | Resource Files 67 | 68 | 69 | -------------------------------------------------------------------------------- /msvc/libusb_dll_2012.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {d81e81ca-b13e-4a15-b54b-b12b41361e6b} 14 | 15 | 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Header Files 42 | 43 | 44 | Header Files 45 | 46 | 47 | Header Files 48 | 49 | 50 | Header Files 51 | 52 | 53 | Header Files 54 | 55 | 56 | Header Files 57 | 58 | 59 | 60 | 61 | Resource Files 62 | 63 | 64 | 65 | 66 | Resource Files 67 | 68 | 69 | -------------------------------------------------------------------------------- /msvc/libusb_sources: -------------------------------------------------------------------------------- 1 | #TARGETTYPE is not defined, to allow selection between static lib or DLL with ddk_build 2 | TARGETNAME=libusb-1.0 3 | DLLDEF=..\libusb-1.0.def 4 | 5 | !IFNDEF MSC_WARNING_LEVEL 6 | MSC_WARNING_LEVEL=/W3 7 | !ENDIF 8 | 9 | !IFDEF STATIC_LIBC 10 | USE_LIBCMT=1 11 | !ELSE 12 | USE_MSVCRT=1 13 | !ENDIF 14 | 15 | INCLUDES=..;..\..\msvc;$(DDK_INC_PATH) 16 | C_DEFINES= $(C_DEFINES) $(LIBUSB_DEFINES) /DDDKBUILD 17 | 18 | # http://jpassing.com/2009/10/21/ltcg-issues-with-the-win7amd64-environment-of-wdk-7600/ 19 | # prevents the following error when using the 64 bit static lib with Visual Studio 2010: 20 | # "fatal error C1001: An internal error has occurred in the compiler. 21 | # (compiler file 'f:\dd\vctools\compiler\utc\src\p2\p2symtab.c', line 1823)" 22 | # and the following with Visual Studio 2010: 23 | # "fatal error C1047: The object or library file 'libusb-1.0.lib' was created with 24 | # an older compiler than other objects; rebuild old objects and libraries" 25 | USER_C_FLAGS=/GL- 26 | 27 | TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib 28 | 29 | SOURCES=..\core.c \ 30 | ..\descriptor.c \ 31 | ..\io.c \ 32 | ..\sync.c \ 33 | threads_windows.c \ 34 | poll_windows.c \ 35 | windows_usb.c \ 36 | ..\libusb-1.0.rc 37 | -------------------------------------------------------------------------------- /msvc/libusb_static.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="libusb_static" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=libusb_static - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "libusb_static.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "libusb_static.mak" CFG="libusb_static - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "libusb_static - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "libusb_static - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "libusb_static - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "../Win32/Release/lib" 41 | # PROP Intermediate_Dir "../Win32/Release/lib" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "../libusb" /D "WIN32" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /D "_LIB" /FR /FD /EHsc /c 45 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 | # ADD RSC /l 0x409 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo /out:"../Win32/Release/lib/libusb-1.0.lib" 53 | 54 | !ELSEIF "$(CFG)" == "libusb_static - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "../Win32/Debug/lib" 64 | # PROP Intermediate_Dir "../Win32/Debug/lib" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "../libusb" /D "WIN32" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /D "_LIB" /FR /FD /GZ /EHsc /c 68 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 | # ADD RSC /l 0x409 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo /n 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo /out:"../Win32/Debug/lib/libusb-1.0.lib" 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "libusb_static - Win32 Release" 82 | # Name "libusb_static - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=..\libusb\core.c 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=..\libusb\os\darwin_usb.c 93 | # PROP Exclude_From_Build 1 94 | # End Source File 95 | # Begin Source File 96 | 97 | SOURCE=..\libusb\descriptor.c 98 | # End Source File 99 | # Begin Source File 100 | 101 | SOURCE=..\libusb\io.c 102 | # End Source File 103 | # Begin Source File 104 | 105 | SOURCE=..\libusb\os\linux_usbfs.c 106 | # PROP Exclude_From_Build 1 107 | # End Source File 108 | # Begin Source File 109 | 110 | SOURCE=..\libusb\os\poll_windows.c 111 | # End Source File 112 | # Begin Source File 113 | 114 | SOURCE=..\libusb\sync.c 115 | # End Source File 116 | # Begin Source File 117 | 118 | SOURCE=..\libusb\os\threads_windows.c 119 | # End Source File 120 | # Begin Source File 121 | 122 | SOURCE=..\libusb\os\windows_usb.c 123 | # End Source File 124 | # End Group 125 | # Begin Group "Header Files" 126 | 127 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 128 | # Begin Source File 129 | 130 | SOURCE=.\config.h 131 | # End Source File 132 | # Begin Source File 133 | 134 | SOURCE=..\libusb\os\darwin_usb.h 135 | # End Source File 136 | # Begin Source File 137 | 138 | SOURCE=..\libusb\libusb.h 139 | # End Source File 140 | # Begin Source File 141 | 142 | SOURCE=..\libusb\libusbi.h 143 | # End Source File 144 | # Begin Source File 145 | 146 | SOURCE=..\libusb\os\linux_usbfs.h 147 | # End Source File 148 | # Begin Source File 149 | 150 | SOURCE=..\libusb\os\poll_posix.h 151 | # End Source File 152 | # Begin Source File 153 | 154 | SOURCE=..\libusb\os\poll_windows.h 155 | # End Source File 156 | # Begin Source File 157 | 158 | SOURCE=..\libusb\os\threads_posix.h 159 | # End Source File 160 | # Begin Source File 161 | 162 | SOURCE=..\libusb\os\threads_windows.h 163 | # End Source File 164 | # Begin Source File 165 | 166 | SOURCE=..\libusb\os\windows_usb.h 167 | # End Source File 168 | # End Group 169 | # End Target 170 | # End Project 171 | -------------------------------------------------------------------------------- /msvc/libusb_static_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | 37 | 38 | Header Files 39 | 40 | 41 | Header Files 42 | 43 | 44 | Header Files 45 | 46 | 47 | Header Files 48 | 49 | 50 | Header Files 51 | 52 | 53 | Header Files 54 | 55 | 56 | -------------------------------------------------------------------------------- /msvc/libusb_static_2012.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | 37 | 38 | Header Files 39 | 40 | 41 | Header Files 42 | 43 | 44 | Header Files 45 | 46 | 47 | Header Files 48 | 49 | 50 | Header Files 51 | 52 | 53 | Header Files 54 | 55 | 56 | -------------------------------------------------------------------------------- /msvc/libusbx.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "libusb_dll"=".\libusb_dll.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "libusb_static"=".\libusb_static.dsp" - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "listdevs"=".\listdevs.dsp" - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | Begin Project Dependency 39 | Project_Dep_Name libusb_static 40 | End Project Dependency 41 | }}} 42 | 43 | ############################################################################### 44 | 45 | Project: "xusb"=".\xusb.dsp" - Package Owner=<4> 46 | 47 | Package=<5> 48 | {{{ 49 | }}} 50 | 51 | Package=<4> 52 | {{{ 53 | Begin Project Dependency 54 | Project_Dep_Name libusb_static 55 | End Project Dependency 56 | }}} 57 | 58 | ############################################################################### 59 | 60 | Global: 61 | 62 | Package=<5> 63 | {{{ 64 | }}} 65 | 66 | Package=<3> 67 | {{{ 68 | }}} 69 | 70 | ############################################################################### 71 | 72 | -------------------------------------------------------------------------------- /msvc/libusbx_2005.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2005.vcproj", "{5AB6B770-1925-48D5-ABC2-930F3259C020}" 5 | ProjectSection(WebsiteProperties) = preProject 6 | Debug.AspNetCompiler.Debug = "True" 7 | Release.AspNetCompiler.Debug = "False" 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2005.vcproj", "{8224C054-5968-4238-832C-167155E7ECC3}" 11 | ProjectSection(WebsiteProperties) = preProject 12 | Debug.AspNetCompiler.Debug = "True" 13 | Release.AspNetCompiler.Debug = "False" 14 | EndProjectSection 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2005.vcproj", "{98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}" 17 | ProjectSection(WebsiteProperties) = preProject 18 | Debug.AspNetCompiler.Debug = "True" 19 | Release.AspNetCompiler.Debug = "False" 20 | EndProjectSection 21 | ProjectSection(ProjectDependencies) = postProject 22 | {5AB6B770-1925-48D5-ABC2-930F3259C020} = {5AB6B770-1925-48D5-ABC2-930F3259C020} 23 | EndProjectSection 24 | EndProject 25 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "xusb_2005.vcproj", "{08A6FA39-21B7-4A05-9252-2F9864A5E5A4}" 26 | ProjectSection(WebsiteProperties) = preProject 27 | Debug.AspNetCompiler.Debug = "True" 28 | Release.AspNetCompiler.Debug = "False" 29 | EndProjectSection 30 | ProjectSection(ProjectDependencies) = postProject 31 | {5AB6B770-1925-48D5-ABC2-930F3259C020} = {5AB6B770-1925-48D5-ABC2-930F3259C020} 32 | EndProjectSection 33 | EndProject 34 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2005.vcproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}" 35 | ProjectSection(WebsiteProperties) = preProject 36 | Debug.AspNetCompiler.Debug = "True" 37 | Release.AspNetCompiler.Debug = "False" 38 | EndProjectSection 39 | ProjectSection(ProjectDependencies) = postProject 40 | {5AB6B770-1925-48D5-ABC2-930F3259C020} = {5AB6B770-1925-48D5-ABC2-930F3259C020} 41 | EndProjectSection 42 | EndProject 43 | Global 44 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 45 | Debug|Win32 = Debug|Win32 46 | Debug|x64 = Debug|x64 47 | Release|Win32 = Release|Win32 48 | Release|x64 = Release|x64 49 | EndGlobalSection 50 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 51 | {5AB6B770-1925-48D5-ABC2-930F3259C020}.Debug|Win32.ActiveCfg = Debug|Win32 52 | {5AB6B770-1925-48D5-ABC2-930F3259C020}.Debug|Win32.Build.0 = Debug|Win32 53 | {5AB6B770-1925-48D5-ABC2-930F3259C020}.Debug|x64.ActiveCfg = Debug|x64 54 | {5AB6B770-1925-48D5-ABC2-930F3259C020}.Debug|x64.Build.0 = Debug|x64 55 | {5AB6B770-1925-48D5-ABC2-930F3259C020}.Release|Win32.ActiveCfg = Release|Win32 56 | {5AB6B770-1925-48D5-ABC2-930F3259C020}.Release|Win32.Build.0 = Release|Win32 57 | {5AB6B770-1925-48D5-ABC2-930F3259C020}.Release|x64.ActiveCfg = Release|x64 58 | {5AB6B770-1925-48D5-ABC2-930F3259C020}.Release|x64.Build.0 = Release|x64 59 | {8224C054-5968-4238-832C-167155E7ECC3}.Debug|Win32.ActiveCfg = Debug|Win32 60 | {8224C054-5968-4238-832C-167155E7ECC3}.Debug|Win32.Build.0 = Debug|Win32 61 | {8224C054-5968-4238-832C-167155E7ECC3}.Debug|x64.ActiveCfg = Debug|x64 62 | {8224C054-5968-4238-832C-167155E7ECC3}.Debug|x64.Build.0 = Debug|x64 63 | {8224C054-5968-4238-832C-167155E7ECC3}.Release|Win32.ActiveCfg = Release|Win32 64 | {8224C054-5968-4238-832C-167155E7ECC3}.Release|Win32.Build.0 = Release|Win32 65 | {8224C054-5968-4238-832C-167155E7ECC3}.Release|x64.ActiveCfg = Release|x64 66 | {8224C054-5968-4238-832C-167155E7ECC3}.Release|x64.Build.0 = Release|x64 67 | {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Debug|Win32.ActiveCfg = Debug|Win32 68 | {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Debug|Win32.Build.0 = Debug|Win32 69 | {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Debug|x64.ActiveCfg = Debug|x64 70 | {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Debug|x64.Build.0 = Debug|x64 71 | {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Release|Win32.ActiveCfg = Release|Win32 72 | {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Release|Win32.Build.0 = Release|Win32 73 | {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Release|x64.ActiveCfg = Release|x64 74 | {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Release|x64.Build.0 = Release|x64 75 | {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Debug|Win32.ActiveCfg = Debug|Win32 76 | {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Debug|Win32.Build.0 = Debug|Win32 77 | {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Debug|x64.ActiveCfg = Debug|x64 78 | {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Debug|x64.Build.0 = Debug|x64 79 | {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Release|Win32.ActiveCfg = Release|Win32 80 | {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Release|Win32.Build.0 = Release|Win32 81 | {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Release|x64.ActiveCfg = Release|x64 82 | {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Release|x64.Build.0 = Release|x64 83 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32 84 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32 85 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64 86 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.Build.0 = Debug|x64 87 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.ActiveCfg = Release|Win32 88 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.Build.0 = Release|Win32 89 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.ActiveCfg = Release|x64 90 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.Build.0 = Release|x64 91 | EndGlobalSection 92 | GlobalSection(SolutionProperties) = preSolution 93 | HideSolutionNode = FALSE 94 | EndGlobalSection 95 | EndGlobal 96 | -------------------------------------------------------------------------------- /msvc/libusbx_2010.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2010.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2010.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}" 6 | EndProject 7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2010.vcxproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}" 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "xusb_2010.vcxproj", "{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}" 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxload", "fxload_2010.vcxproj", "{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E} = {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E} 14 | EndProjectSection 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt", "getopt_2010.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2010.vcxproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Win32 = Debug|Win32 23 | Debug|x64 = Debug|x64 24 | Release|Win32 = Release|Win32 25 | Release|x64 = Release|x64 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32 30 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 31 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64 32 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 33 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32 34 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 35 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64 36 | {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 37 | {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 38 | {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 39 | {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 40 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32 41 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32 42 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64 43 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.Build.0 = Debug|x64 44 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.ActiveCfg = Release|Win32 45 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32 46 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64 47 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64 48 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.ActiveCfg = Debug|Win32 49 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.Build.0 = Debug|Win32 50 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.ActiveCfg = Debug|x64 51 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.Build.0 = Debug|x64 52 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.ActiveCfg = Release|Win32 53 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.Build.0 = Release|Win32 54 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.ActiveCfg = Release|x64 55 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.Build.0 = Release|x64 56 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.ActiveCfg = Debug|Win32 57 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.Build.0 = Debug|Win32 58 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.ActiveCfg = Debug|x64 59 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.Build.0 = Debug|x64 60 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.ActiveCfg = Release|Win32 61 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.Build.0 = Release|Win32 62 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.ActiveCfg = Release|x64 63 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.Build.0 = Release|x64 64 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32 65 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32 66 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64 67 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64 68 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32 69 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32 70 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64 71 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64 72 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32 73 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32 74 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64 75 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.Build.0 = Debug|x64 76 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.ActiveCfg = Release|Win32 77 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.Build.0 = Release|Win32 78 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.ActiveCfg = Release|x64 79 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.Build.0 = Release|x64 80 | EndGlobalSection 81 | GlobalSection(SolutionProperties) = preSolution 82 | HideSolutionNode = FALSE 83 | EndGlobalSection 84 | EndGlobal 85 | -------------------------------------------------------------------------------- /msvc/libusbx_2012.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 2012 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2012.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2012.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}" 6 | EndProject 7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2012.vcxproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}" 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "xusb_2012.vcxproj", "{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}" 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxload", "fxload_2012.vcxproj", "{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E} = {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E} 14 | EndProjectSection 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt", "getopt_2012.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2012.vcxproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Win32 = Debug|Win32 23 | Debug|x64 = Debug|x64 24 | Release|Win32 = Release|Win32 25 | Release|x64 = Release|x64 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32 30 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 31 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64 32 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 33 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32 34 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 35 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64 36 | {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 37 | {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 38 | {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 39 | {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 40 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32 41 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32 42 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64 43 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.Build.0 = Debug|x64 44 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.ActiveCfg = Release|Win32 45 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32 46 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64 47 | {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64 48 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.ActiveCfg = Debug|Win32 49 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.Build.0 = Debug|Win32 50 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.ActiveCfg = Debug|x64 51 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.Build.0 = Debug|x64 52 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.ActiveCfg = Release|Win32 53 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.Build.0 = Release|Win32 54 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.ActiveCfg = Release|x64 55 | {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.Build.0 = Release|x64 56 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.ActiveCfg = Debug|Win32 57 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.Build.0 = Debug|Win32 58 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.ActiveCfg = Debug|x64 59 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.Build.0 = Debug|x64 60 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.ActiveCfg = Release|Win32 61 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.Build.0 = Release|Win32 62 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.ActiveCfg = Release|x64 63 | {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.Build.0 = Release|x64 64 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32 65 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32 66 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64 67 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64 68 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32 69 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32 70 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64 71 | {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64 72 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32 73 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32 74 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64 75 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.Build.0 = Debug|x64 76 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.ActiveCfg = Release|Win32 77 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.Build.0 = Release|Win32 78 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.ActiveCfg = Release|x64 79 | {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.Build.0 = Release|x64 80 | EndGlobalSection 81 | GlobalSection(SolutionProperties) = preSolution 82 | HideSolutionNode = FALSE 83 | EndGlobalSection 84 | EndGlobal 85 | -------------------------------------------------------------------------------- /msvc/listdevs.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="listdevs" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=listdevs - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "listdevs.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "listdevs.mak" CFG="listdevs - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "listdevs - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "listdevs - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "listdevs - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "../Win32/Release/examples" 41 | # PROP Intermediate_Dir "../Win32/Release/examples/listdevs" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c 45 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "../libusb" /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /FR /FD /EHsc /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 54 | 55 | !ELSEIF "$(CFG)" == "listdevs - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "Debug" 60 | # PROP BASE Intermediate_Dir "Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "../Win32/Debug/examples" 65 | # PROP Intermediate_Dir "../Win32/Debug/examples/listdevs" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /FD /GZ /c 69 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../libusb" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /FR /FD /GZ /EHsc /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo /n "../Win32/Debug/dll/core.sbr" "../Win32/Debug/dll/descriptor.sbr" "../Win32/Debug/dll/io.sbr" "../Win32/Debug/dll/sync.sbr" "../Win32/Debug/dll/poll_windows.sbr" "../Win32/Debug/dll/threads_windows.sbr" "../Win32/Debug/dll/windows_usb.sbr" 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 78 | # SUBTRACT LINK32 /pdb:none 79 | 80 | !ENDIF 81 | 82 | # Begin Target 83 | 84 | # Name "listdevs - Win32 Release" 85 | # Name "listdevs - Win32 Debug" 86 | # Begin Group "Source Files" 87 | 88 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 89 | # Begin Source File 90 | 91 | SOURCE=..\examples\listdevs.c 92 | # End Source File 93 | # End Group 94 | # Begin Group "Header Files" 95 | 96 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 97 | # End Group 98 | # Begin Group "Resource Files" 99 | 100 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 101 | # End Group 102 | # End Target 103 | # End Project 104 | -------------------------------------------------------------------------------- /msvc/listdevs_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /msvc/listdevs_2012.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /msvc/listdevs_sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=listdevs 2 | TARGETTYPE=PROGRAM 3 | 386_STDCALL=0 4 | 5 | _NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 6 | !IFNDEF MSC_WARNING_LEVEL 7 | MSC_WARNING_LEVEL=/W3 8 | !ENDIF 9 | 10 | !IFDEF STATIC_LIBC 11 | USE_LIBCMT=1 12 | !ELSE 13 | USE_MSVCRT=1 14 | !ENDIF 15 | 16 | UMTYPE=console 17 | INCLUDES=..\..\libusb;$(DDK_INC_PATH) 18 | UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib 19 | SOURCES=..\listdevs.c 20 | -------------------------------------------------------------------------------- /msvc/stdint.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file was originally part of the w64 mingw-runtime package. 4 | */ 5 | 6 | /* ISO C9x 7.18 Integer types 7 | * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794) 8 | * 9 | * THIS SOFTWARE IS NOT COPYRIGHTED 10 | * 11 | * Contributor: Danny Smith 12 | * Modified for libusb/MSVC: Pete Batard 13 | * 14 | * This source code is offered for use in the public domain. You may 15 | * use, modify or distribute it freely. 16 | * 17 | * This code is distributed in the hope that it will be useful but 18 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 19 | * DISCLAIMED. This includes but is not limited to warranties of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | * 22 | * Date: 2010-04-02 23 | */ 24 | 25 | #ifndef _MSC_VER 26 | #error This header should only be used with Microsoft compilers 27 | #endif 28 | 29 | #ifndef _STDINT_H 30 | #define _STDINT_H 31 | 32 | #ifndef _INTPTR_T_DEFINED 33 | #define _INTPTR_T_DEFINED 34 | #ifndef __intptr_t_defined 35 | #define __intptr_t_defined 36 | #undef intptr_t 37 | #ifdef _WIN64 38 | typedef __int64 intptr_t; 39 | #else 40 | typedef int intptr_t; 41 | #endif /* _WIN64 */ 42 | #endif /* __intptr_t_defined */ 43 | #endif /* _INTPTR_T_DEFINED */ 44 | 45 | #ifndef _UINTPTR_T_DEFINED 46 | #define _UINTPTR_T_DEFINED 47 | #ifndef __uintptr_t_defined 48 | #define __uintptr_t_defined 49 | #undef uintptr_t 50 | #ifdef _WIN64 51 | typedef unsigned __int64 uintptr_t; 52 | #else 53 | typedef unsigned int uintptr_t; 54 | #endif /* _WIN64 */ 55 | #endif /* __uintptr_t_defined */ 56 | #endif /* _UINTPTR_T_DEFINED */ 57 | 58 | #ifndef _PTRDIFF_T_DEFINED 59 | #define _PTRDIFF_T_DEFINED 60 | #ifndef _PTRDIFF_T_ 61 | #define _PTRDIFF_T_ 62 | #undef ptrdiff_t 63 | #ifdef _WIN64 64 | typedef __int64 ptrdiff_t; 65 | #else 66 | typedef int ptrdiff_t; 67 | #endif /* _WIN64 */ 68 | #endif /* _PTRDIFF_T_ */ 69 | #endif /* _PTRDIFF_T_DEFINED */ 70 | 71 | #ifndef _WCHAR_T_DEFINED 72 | #define _WCHAR_T_DEFINED 73 | #ifndef __cplusplus 74 | typedef unsigned short wchar_t; 75 | #endif /* C++ */ 76 | #endif /* _WCHAR_T_DEFINED */ 77 | 78 | #ifndef _WCTYPE_T_DEFINED 79 | #define _WCTYPE_T_DEFINED 80 | #ifndef _WINT_T 81 | #define _WINT_T 82 | typedef unsigned short wint_t; 83 | typedef unsigned short wctype_t; 84 | #endif /* _WINT_T */ 85 | #endif /* _WCTYPE_T_DEFINED */ 86 | 87 | /* 7.18.1.1 Exact-width integer types */ 88 | typedef __int8 int8_t; 89 | typedef unsigned __int8 uint8_t; 90 | typedef __int16 int16_t; 91 | typedef unsigned __int16 uint16_t; 92 | typedef __int32 int32_t; 93 | typedef unsigned __int32 uint32_t; 94 | typedef __int64 int64_t; 95 | typedef unsigned __int64 uint64_t; 96 | 97 | /* 7.18.1.2 Minimum-width integer types */ 98 | typedef signed char int_least8_t; 99 | typedef unsigned char uint_least8_t; 100 | typedef short int_least16_t; 101 | typedef unsigned short uint_least16_t; 102 | typedef int int_least32_t; 103 | typedef unsigned uint_least32_t; 104 | typedef __int64 int_least64_t; 105 | typedef unsigned __int64 uint_least64_t; 106 | 107 | /* 7.18.1.3 Fastest minimum-width integer types 108 | * Not actually guaranteed to be fastest for all purposes 109 | * Here we use the exact-width types for 8 and 16-bit ints. 110 | */ 111 | typedef __int8 int_fast8_t; 112 | typedef unsigned __int8 uint_fast8_t; 113 | typedef __int16 int_fast16_t; 114 | typedef unsigned __int16 uint_fast16_t; 115 | typedef __int32 int_fast32_t; 116 | typedef unsigned __int32 uint_fast32_t; 117 | typedef __int64 int_fast64_t; 118 | typedef unsigned __int64 uint_fast64_t; 119 | 120 | /* 7.18.1.5 Greatest-width integer types */ 121 | typedef __int64 intmax_t; 122 | typedef unsigned __int64 uintmax_t; 123 | 124 | /* 7.18.2 Limits of specified-width integer types */ 125 | 126 | /* 7.18.2.1 Limits of exact-width integer types */ 127 | #define INT8_MIN (-128) 128 | #define INT16_MIN (-32768) 129 | #define INT32_MIN (-2147483647 - 1) 130 | #define INT64_MIN (-9223372036854775807LL - 1) 131 | 132 | #define INT8_MAX 127 133 | #define INT16_MAX 32767 134 | #define INT32_MAX 2147483647 135 | #define INT64_MAX 9223372036854775807LL 136 | 137 | #define UINT8_MAX 255 138 | #define UINT16_MAX 65535 139 | #define UINT32_MAX 0xffffffffU /* 4294967295U */ 140 | #define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ 141 | 142 | /* 7.18.2.2 Limits of minimum-width integer types */ 143 | #define INT_LEAST8_MIN INT8_MIN 144 | #define INT_LEAST16_MIN INT16_MIN 145 | #define INT_LEAST32_MIN INT32_MIN 146 | #define INT_LEAST64_MIN INT64_MIN 147 | 148 | #define INT_LEAST8_MAX INT8_MAX 149 | #define INT_LEAST16_MAX INT16_MAX 150 | #define INT_LEAST32_MAX INT32_MAX 151 | #define INT_LEAST64_MAX INT64_MAX 152 | 153 | #define UINT_LEAST8_MAX UINT8_MAX 154 | #define UINT_LEAST16_MAX UINT16_MAX 155 | #define UINT_LEAST32_MAX UINT32_MAX 156 | #define UINT_LEAST64_MAX UINT64_MAX 157 | 158 | /* 7.18.2.3 Limits of fastest minimum-width integer types */ 159 | #define INT_FAST8_MIN INT8_MIN 160 | #define INT_FAST16_MIN INT16_MIN 161 | #define INT_FAST32_MIN INT32_MIN 162 | #define INT_FAST64_MIN INT64_MIN 163 | 164 | #define INT_FAST8_MAX INT8_MAX 165 | #define INT_FAST16_MAX INT16_MAX 166 | #define INT_FAST32_MAX INT32_MAX 167 | #define INT_FAST64_MAX INT64_MAX 168 | 169 | #define UINT_FAST8_MAX UINT8_MAX 170 | #define UINT_FAST16_MAX UINT16_MAX 171 | #define UINT_FAST32_MAX UINT32_MAX 172 | #define UINT_FAST64_MAX UINT64_MAX 173 | 174 | /* 7.18.2.4 Limits of integer types capable of holding 175 | object pointers */ 176 | #ifdef _WIN64 177 | #define INTPTR_MIN INT64_MIN 178 | #define INTPTR_MAX INT64_MAX 179 | #define UINTPTR_MAX UINT64_MAX 180 | #else 181 | #define INTPTR_MIN INT32_MIN 182 | #define INTPTR_MAX INT32_MAX 183 | #define UINTPTR_MAX UINT32_MAX 184 | #endif 185 | 186 | /* 7.18.2.5 Limits of greatest-width integer types */ 187 | #define INTMAX_MIN INT64_MIN 188 | #define INTMAX_MAX INT64_MAX 189 | #define UINTMAX_MAX UINT64_MAX 190 | 191 | /* 7.18.3 Limits of other integer types */ 192 | #ifdef _WIN64 193 | #define PTRDIFF_MIN INT64_MIN 194 | #define PTRDIFF_MAX INT64_MAX 195 | #else 196 | #define PTRDIFF_MIN INT32_MIN 197 | #define PTRDIFF_MAX INT32_MAX 198 | #endif 199 | 200 | #define SIG_ATOMIC_MIN INT32_MIN 201 | #define SIG_ATOMIC_MAX INT32_MAX 202 | 203 | #ifndef SIZE_MAX 204 | #ifdef _WIN64 205 | #define SIZE_MAX UINT64_MAX 206 | #else 207 | #define SIZE_MAX UINT32_MAX 208 | #endif 209 | #endif 210 | 211 | #ifndef WCHAR_MIN /* also in wchar.h */ 212 | #define WCHAR_MIN 0U 213 | #define WCHAR_MAX 0xffffU 214 | #endif 215 | 216 | /* 217 | * wint_t is unsigned short for compatibility with MS runtime 218 | */ 219 | #define WINT_MIN 0U 220 | #define WINT_MAX 0xffffU 221 | 222 | 223 | /* 7.18.4 Macros for integer constants */ 224 | 225 | /* 7.18.4.1 Macros for minimum-width integer constants 226 | 227 | Accoding to Douglas Gwyn : 228 | "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC 229 | 9899:1999 as initially published, the expansion was required 230 | to be an integer constant of precisely matching type, which 231 | is impossible to accomplish for the shorter types on most 232 | platforms, because C99 provides no standard way to designate 233 | an integer constant with width less than that of type int. 234 | TC1 changed this to require just an integer constant 235 | *expression* with *promoted* type." 236 | 237 | The trick used here is from Clive D W Feather. 238 | */ 239 | 240 | #define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val)) 241 | #define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val)) 242 | #define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val)) 243 | /* The 'trick' doesn't work in C89 for long long because, without 244 | suffix, (val) will be evaluated as int, not intmax_t */ 245 | #define INT64_C(val) val##i64 246 | 247 | #define UINT8_C(val) (val) 248 | #define UINT16_C(val) (val) 249 | #define UINT32_C(val) (val##i32) 250 | #define UINT64_C(val) val##ui64 251 | 252 | /* 7.18.4.2 Macros for greatest-width integer constants */ 253 | #define INTMAX_C(val) val##i64 254 | #define UINTMAX_C(val) val##ui64 255 | 256 | #endif 257 | -------------------------------------------------------------------------------- /msvc/stress_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {28b6220e-d087-4f48-bd69-ffe0ac5bcc7a} 10 | 11 | 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /msvc/stress_2012.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {28b6220e-d087-4f48-bd69-ffe0ac5bcc7a} 10 | 11 | 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | -------------------------------------------------------------------------------- /msvc/xusb.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="xusb" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=xusb - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "xusb.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "xusb.mak" CFG="xusb - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "xusb - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "xusb - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "xusb - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "../Win32/Release/examples" 41 | # PROP Intermediate_Dir "../Win32/Release/examples/xusb" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c 45 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "../libusb" /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /FR /FD /EHsc /c 46 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 47 | # ADD RSC /l 0x409 /d "NDEBUG" 48 | BSC32=bscmake.exe 49 | # ADD BASE BSC32 /nologo 50 | # ADD BSC32 /nologo 51 | LINK32=link.exe 52 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 54 | 55 | !ELSEIF "$(CFG)" == "xusb - Win32 Debug" 56 | 57 | # PROP BASE Use_MFC 0 58 | # PROP BASE Use_Debug_Libraries 1 59 | # PROP BASE Output_Dir "xusb___Win32_Debug" 60 | # PROP BASE Intermediate_Dir "xusb___Win32_Debug" 61 | # PROP BASE Target_Dir "" 62 | # PROP Use_MFC 0 63 | # PROP Use_Debug_Libraries 1 64 | # PROP Output_Dir "../Win32/Debug/examples" 65 | # PROP Intermediate_Dir "../Win32/Debug/examples/xusb" 66 | # PROP Ignore_Export_Lib 0 67 | # PROP Target_Dir "" 68 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /FD /GZ /c 69 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "../libusb" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /FR /FD /GZ /EHsc /c 70 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 71 | # ADD RSC /l 0x409 /d "_DEBUG" 72 | BSC32=bscmake.exe 73 | # ADD BASE BSC32 /nologo 74 | # ADD BSC32 /nologo /n "../Win32/Debug/dll/core.sbr" "../Win32/Debug/dll/descriptor.sbr" "../Win32/Debug/dll/io.sbr" "../Win32/Debug/dll/sync.sbr" "../Win32/Debug/dll/poll_windows.sbr" "../Win32/Debug/dll/threads_windows.sbr" "../Win32/Debug/dll/windows_usb.sbr" 75 | LINK32=link.exe 76 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 77 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 78 | 79 | !ENDIF 80 | 81 | # Begin Target 82 | 83 | # Name "xusb - Win32 Release" 84 | # Name "xusb - Win32 Debug" 85 | # Begin Group "Source Files" 86 | 87 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 88 | # Begin Source File 89 | 90 | SOURCE=..\examples\xusb.c 91 | # End Source File 92 | # End Group 93 | # Begin Group "Header Files" 94 | 95 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 96 | # End Group 97 | # Begin Group "Resource Files" 98 | 99 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 100 | # End Group 101 | # End Target 102 | # End Project 103 | -------------------------------------------------------------------------------- /msvc/xusb_2010.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /msvc/xusb_2012.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /msvc/xusb_sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=xusb 2 | TARGETTYPE=PROGRAM 3 | 386_STDCALL=0 4 | 5 | _NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 6 | 7 | !IFNDEF MSC_WARNING_LEVEL 8 | MSC_WARNING_LEVEL=/W3 9 | !ENDIF 10 | 11 | !IFDEF STATIC_LIBC 12 | USE_LIBCMT=1 13 | !ELSE 14 | USE_MSVCRT=1 15 | !ENDIF 16 | 17 | UMTYPE=console 18 | INCLUDES=..\..\msvc;..\..\libusb;$(DDK_INC_PATH) 19 | UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib 20 | SOURCES=..\xusb.c 21 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/libusb 2 | LDADD = ../libusb/libusb-1.0.la 3 | 4 | noinst_PROGRAMS = stress 5 | 6 | stress_SOURCES = stress.c testlib.c 7 | -------------------------------------------------------------------------------- /tests/libusbx_testlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libusbx test library helper functions 3 | * Copyright © 2012 Toby Gray 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef LIBUSBX_TESTLIB_H 21 | #define LIBUSBX_TESTLIB_H 22 | 23 | #include 24 | 25 | #if !defined(bool) 26 | #define bool int 27 | #endif 28 | #if !defined(true) 29 | #define true (1 == 1) 30 | #endif 31 | #if !defined(false) 32 | #define false (!true) 33 | #endif 34 | 35 | /** Values returned from a test function to indicate test result */ 36 | typedef enum { 37 | /** Indicates that the test ran successfully. */ 38 | TEST_STATUS_SUCCESS, 39 | /** Indicates that the test failed one or more test. */ 40 | TEST_STATUS_FAILURE, 41 | /** Indicates that an unexpected error occurred. */ 42 | TEST_STATUS_ERROR, 43 | /** Indicates that the test can't be run. For example this may be 44 | * due to no suitable device being connected to perform the tests.*/ 45 | TEST_STATUS_SKIP 46 | } libusbx_testlib_result; 47 | 48 | /** 49 | * Context for test library functions 50 | */ 51 | typedef struct { 52 | char ** test_names; 53 | int test_count; 54 | bool list_tests; 55 | bool verbose; 56 | int output_fd; 57 | FILE* output_file; 58 | int null_fd; 59 | } libusbx_testlib_ctx; 60 | 61 | /** 62 | * Logs some test information or state 63 | */ 64 | void libusbx_testlib_logf(libusbx_testlib_ctx * ctx, 65 | const char* fmt, ...); 66 | 67 | /** 68 | * Function pointer for a libusbx test function. 69 | * 70 | * Should return TEST_STATUS_SUCCESS on success or another TEST_STATUS value. 71 | */ 72 | typedef libusbx_testlib_result 73 | (*libusbx_testlib_test_function)(libusbx_testlib_ctx * ctx); 74 | 75 | /** 76 | * Structure holding a test description. 77 | */ 78 | typedef struct { 79 | /** Human readable name of the test. */ 80 | const char * name; 81 | /** The test library will call this function to run the test. */ 82 | libusbx_testlib_test_function function; 83 | } libusbx_testlib_test; 84 | 85 | /** 86 | * Value to use at the end of a test array to indicate the last 87 | * element. 88 | */ 89 | #define LIBUSBX_NULL_TEST {NULL, NULL} 90 | 91 | /** 92 | * Runs the tests provided. 93 | * 94 | * Before running any tests argc and argv will be processed 95 | * to determine the mode of operation. 96 | * 97 | * \param argc The argc from main 98 | * \param argv The argv from main 99 | * \param tests A NULL_TEST terminated array of tests 100 | * \return 0 on success, non-zero on failure 101 | */ 102 | int libusbx_testlib_run_tests(int argc, 103 | char ** argv, 104 | const libusbx_testlib_test * tests); 105 | 106 | #endif //LIBUSBX_TESTLIB_H 107 | -------------------------------------------------------------------------------- /tests/stress.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libusbx stress test program to perform simple stress tests 3 | * Copyright © 2012 Toby Gray 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "libusb.h" 25 | 26 | #include "libusbx_testlib.h" 27 | 28 | /** Test that creates and destroys a single concurrent context 29 | * 10000 times. */ 30 | static libusbx_testlib_result test_init_and_exit(libusbx_testlib_ctx * tctx) 31 | { 32 | libusb_context * ctx = NULL; 33 | int i; 34 | for (i = 0; i < 10000; ++i) { 35 | int r = libusb_init(&ctx); 36 | if (r != LIBUSB_SUCCESS) { 37 | libusbx_testlib_logf(tctx, 38 | "Failed to init libusb on iteration %d: %d", 39 | i, r); 40 | return TEST_STATUS_FAILURE; 41 | } 42 | libusb_exit(ctx); 43 | ctx = NULL; 44 | } 45 | 46 | return TEST_STATUS_SUCCESS; 47 | } 48 | 49 | /** Tests that devices can be listed 1000 times. */ 50 | static libusbx_testlib_result test_get_device_list(libusbx_testlib_ctx * tctx) 51 | { 52 | libusb_context * ctx = NULL; 53 | int r, i; 54 | r = libusb_init(&ctx); 55 | if (r != LIBUSB_SUCCESS) { 56 | libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r); 57 | return TEST_STATUS_FAILURE; 58 | } 59 | for (i = 0; i < 1000; ++i) { 60 | libusb_device ** device_list; 61 | ssize_t list_size = libusb_get_device_list(ctx, &device_list); 62 | if (list_size < 0 || device_list == NULL) { 63 | libusbx_testlib_logf(tctx, 64 | "Failed to get device list on iteration %d: %d (%p)", 65 | i, -list_size, device_list); 66 | return TEST_STATUS_FAILURE; 67 | } 68 | libusb_free_device_list(device_list, 1); 69 | } 70 | libusb_exit(ctx); 71 | return TEST_STATUS_SUCCESS; 72 | } 73 | 74 | /** Tests that 100 concurrent device lists can be open at a time. */ 75 | static libusbx_testlib_result test_many_device_lists(libusbx_testlib_ctx * tctx) 76 | { 77 | #define LIST_COUNT 100 78 | libusb_context * ctx = NULL; 79 | libusb_device ** device_lists[LIST_COUNT]; 80 | int r, i; 81 | memset(device_lists, 0, sizeof(device_lists)); 82 | 83 | r = libusb_init(&ctx); 84 | if (r != LIBUSB_SUCCESS) { 85 | libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r); 86 | return TEST_STATUS_FAILURE; 87 | } 88 | 89 | /* Create the 100 device lists. */ 90 | for (i = 0; i < LIST_COUNT; ++i) { 91 | ssize_t list_size = libusb_get_device_list(ctx, &(device_lists[i])); 92 | if (list_size < 0 || device_lists[i] == NULL) { 93 | libusbx_testlib_logf(tctx, 94 | "Failed to get device list on iteration %d: %d (%p)", 95 | i, -list_size, device_lists[i]); 96 | return TEST_STATUS_FAILURE; 97 | } 98 | } 99 | 100 | /* Destroy the 100 device lists. */ 101 | for (i = 0; i < LIST_COUNT; ++i) { 102 | if (device_lists[i]) { 103 | libusb_free_device_list(device_lists[i], 1); 104 | device_lists[i] = NULL; 105 | } 106 | } 107 | 108 | libusb_exit(ctx); 109 | return TEST_STATUS_SUCCESS; 110 | #undef LIST_COUNT 111 | } 112 | 113 | /** Tests that the default context (used for various things including 114 | * logging) works correctly when the first context created in a 115 | * process is destroyed. */ 116 | static libusbx_testlib_result test_default_context_change(libusbx_testlib_ctx * tctx) 117 | { 118 | libusb_context * ctx = NULL; 119 | int r, i; 120 | 121 | for (i = 0; i < 100; ++i) { 122 | /* First create a new context */ 123 | r = libusb_init(&ctx); 124 | if (r != LIBUSB_SUCCESS) { 125 | libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r); 126 | return TEST_STATUS_FAILURE; 127 | } 128 | 129 | /* Enable debug output, to be sure to use the context */ 130 | libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_DEBUG); 131 | libusb_set_debug(ctx, LIBUSB_LOG_LEVEL_DEBUG); 132 | 133 | /* Now create a reference to the default context */ 134 | r = libusb_init(NULL); 135 | if (r != LIBUSB_SUCCESS) { 136 | libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r); 137 | return TEST_STATUS_FAILURE; 138 | } 139 | 140 | /* Destroy the first context */ 141 | libusb_exit(ctx); 142 | /* Destroy the default context */ 143 | libusb_exit(NULL); 144 | } 145 | 146 | return TEST_STATUS_SUCCESS; 147 | } 148 | 149 | /* Fill in the list of tests. */ 150 | static const libusbx_testlib_test tests[] = { 151 | {"init_and_exit", &test_init_and_exit}, 152 | {"get_device_list", &test_get_device_list}, 153 | {"many_device_lists", &test_many_device_lists}, 154 | {"default_context_change", &test_default_context_change}, 155 | LIBUSBX_NULL_TEST 156 | }; 157 | 158 | int main (int argc, char ** argv) 159 | { 160 | return libusbx_testlib_run_tests(argc, argv, tests); 161 | } 162 | -------------------------------------------------------------------------------- /tests/testlib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libusbx test library helper functions 3 | * Copyright © 2012 Toby Gray 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "libusbx_testlib.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #ifdef _WIN32 31 | #include 32 | #define dup _dup 33 | #define dup2 _dup2 34 | #define open _open 35 | #define close _close 36 | #define fdopen _fdopen 37 | #define NULL_PATH "nul" 38 | #define STDOUT_FILENO 1 39 | #define STDERR_FILENO 2 40 | #else 41 | #include 42 | #define NULL_PATH "/dev/null" 43 | #endif 44 | #define INVALID_FD -1 45 | 46 | /** 47 | * Converts a test result code into a human readable string. 48 | */ 49 | static const char* test_result_to_str(libusbx_testlib_result result) 50 | { 51 | switch (result) { 52 | case TEST_STATUS_SUCCESS: 53 | return "Success"; 54 | case TEST_STATUS_FAILURE: 55 | return "Failure"; 56 | case TEST_STATUS_ERROR: 57 | return "Error"; 58 | case TEST_STATUS_SKIP: 59 | return "Skip"; 60 | default: 61 | return "Unknown"; 62 | } 63 | } 64 | 65 | static void print_usage(int argc, char ** argv) 66 | { 67 | printf("Usage: %s [-l] [-v] [ ...]\n", 68 | argc > 0 ? argv[0] : "test_*"); 69 | printf(" -l List available tests\n"); 70 | printf(" -v Don't redirect STDERR/STDOUT during tests\n"); 71 | } 72 | 73 | static void cleanup_test_output(libusbx_testlib_ctx * ctx) 74 | { 75 | if (ctx->output_file != NULL) { 76 | fclose(ctx->output_file); 77 | ctx->output_file = NULL; 78 | } 79 | if (ctx->output_fd != INVALID_FD) { 80 | close(ctx->output_fd); 81 | ctx->output_fd = INVALID_FD; 82 | } 83 | if (ctx->null_fd != INVALID_FD) { 84 | close(ctx->null_fd); 85 | ctx->null_fd = INVALID_FD; 86 | } 87 | } 88 | 89 | /** 90 | * Setup test output handles 91 | * \return zero on success, non-zero on failure 92 | */ 93 | static int setup_test_output(libusbx_testlib_ctx * ctx) 94 | { 95 | /* Keep a copy of STDOUT for test output */ 96 | ctx->output_fd = dup(STDOUT_FILENO); 97 | if (ctx->output_fd < 0) { 98 | ctx->output_fd = INVALID_FD; 99 | printf("Failed to duplicate output handle: %d\n", errno); 100 | return 1; 101 | } 102 | ctx->output_file = fdopen(ctx->output_fd, "w"); 103 | if (!ctx->output_file) { 104 | cleanup_test_output(ctx); 105 | printf("Failed to open FILE for output handle: %d\n", errno); 106 | return 1; 107 | } 108 | /* Stop output to stdout and stderr from being displayed if using non-verbose output */ 109 | if (!ctx->verbose) { 110 | /* Redirect STDOUT_FILENO and STDERR_FILENO to /dev/null or "nul"*/ 111 | ctx->null_fd = open(NULL_PATH, O_WRONLY); 112 | if (ctx->null_fd < 0) { 113 | ctx->null_fd = INVALID_FD; 114 | cleanup_test_output(ctx); 115 | printf("Failed to open null handle: %d\n", errno); 116 | return 1; 117 | } 118 | if ((dup2(ctx->null_fd, STDOUT_FILENO) < 0) || 119 | (dup2(ctx->null_fd, STDERR_FILENO) < 0)) { 120 | cleanup_test_output(ctx); 121 | return 1; 122 | } 123 | } 124 | return 0; 125 | } 126 | 127 | void libusbx_testlib_logf(libusbx_testlib_ctx * ctx, 128 | const char* fmt, ...) 129 | { 130 | va_list va; 131 | if (!ctx->output_file) 132 | return; 133 | va_start(va, fmt); 134 | vfprintf(ctx->output_file, fmt, va); 135 | va_end(va); 136 | fprintf(ctx->output_file, "\n"); 137 | fflush(ctx->output_file); 138 | } 139 | 140 | int libusbx_testlib_run_tests(int argc, 141 | char ** argv, 142 | const libusbx_testlib_test * tests) 143 | { 144 | int run_count = 0; 145 | int idx = 0; 146 | int pass_count = 0; 147 | int fail_count = 0; 148 | int error_count = 0; 149 | int skip_count = 0; 150 | int r, j; 151 | size_t arglen; 152 | libusbx_testlib_result test_result; 153 | libusbx_testlib_ctx ctx; 154 | 155 | /* Setup default mode of operation */ 156 | ctx.test_names = NULL; 157 | ctx.test_count = 0; 158 | ctx.list_tests = false; 159 | ctx.verbose = false; 160 | ctx.output_fd = INVALID_FD; 161 | ctx.output_file = NULL; 162 | ctx.null_fd = INVALID_FD; 163 | 164 | /* Parse command line options */ 165 | if (argc >= 2) { 166 | for (j = 1; j < argc; j++) { 167 | arglen = strlen(argv[j]); 168 | if ( ((argv[j][0] == '-') || (argv[j][0] == '/')) && 169 | arglen >=2 ) { 170 | switch (argv[j][1]) { 171 | case 'l': 172 | ctx.list_tests = true; 173 | break; 174 | case 'v': 175 | ctx.verbose = true; 176 | break; 177 | default: 178 | printf("Unknown option: '%s'\n", argv[j]); 179 | print_usage(argc, argv); 180 | return 1; 181 | } 182 | } else { 183 | /* End of command line options, remaining must be list of tests to run */ 184 | ctx.test_names = argv + j; 185 | ctx.test_count = argc - j; 186 | break; 187 | } 188 | } 189 | } 190 | 191 | /* Validate command line options */ 192 | if (ctx.test_names && ctx.list_tests) { 193 | printf("List of tests requested but test list provided\n"); 194 | print_usage(argc, argv); 195 | return 1; 196 | } 197 | 198 | /* Setup test log output */ 199 | r = setup_test_output(&ctx); 200 | if (r != 0) 201 | return r; 202 | 203 | /* Act on any options not related to running tests */ 204 | if (ctx.list_tests) { 205 | while (tests[idx].function != NULL) { 206 | libusbx_testlib_logf(&ctx, tests[idx].name); 207 | ++idx; 208 | } 209 | cleanup_test_output(&ctx); 210 | return 0; 211 | } 212 | 213 | /* Run any requested tests */ 214 | while (tests[idx].function != NULL) { 215 | const libusbx_testlib_test * test = &tests[idx]; 216 | ++idx; 217 | if (ctx.test_count > 0) { 218 | /* Filtering tests to run, check if this is one of them */ 219 | int i; 220 | for (i = 0; i < ctx.test_count; ++i) { 221 | if (strcmp(ctx.test_names[i], test->name) == 0) 222 | /* Matches a requested test name */ 223 | break; 224 | } 225 | if (i >= ctx.test_count) { 226 | /* Failed to find a test match, so do the next loop iteration */ 227 | continue; 228 | } 229 | } 230 | libusbx_testlib_logf(&ctx, 231 | "Starting test run: %s...", test->name); 232 | test_result = test->function(&ctx); 233 | libusbx_testlib_logf(&ctx, 234 | "%s (%d)", 235 | test_result_to_str(test_result), test_result); 236 | switch (test_result) { 237 | case TEST_STATUS_SUCCESS: pass_count++; break; 238 | case TEST_STATUS_FAILURE: fail_count++; break; 239 | case TEST_STATUS_ERROR: error_count++; break; 240 | case TEST_STATUS_SKIP: skip_count++; break; 241 | } 242 | ++run_count; 243 | } 244 | libusbx_testlib_logf(&ctx, "---"); 245 | libusbx_testlib_logf(&ctx, "Ran %d tests", run_count); 246 | libusbx_testlib_logf(&ctx, "Passed %d tests", pass_count); 247 | libusbx_testlib_logf(&ctx, "Failed %d tests", fail_count); 248 | libusbx_testlib_logf(&ctx, "Error in %d tests", error_count); 249 | libusbx_testlib_logf(&ctx, "Skipped %d tests", skip_count); 250 | 251 | cleanup_test_output(&ctx); 252 | return pass_count != run_count; 253 | } 254 | --------------------------------------------------------------------------------