summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ddk_build.cmd55
-rw-r--r--examples/lsusb.c6
-rw-r--r--examples/lsusb_sources36
-rw-r--r--examples/xusb.c8
-rw-r--r--examples/xusb_sources36
-rw-r--r--libusb/io.c2
-rw-r--r--libusb/libusb-1.0.def1
7 files changed, 141 insertions, 3 deletions
diff --git a/ddk_build.cmd b/ddk_build.cmd
index 4ff6c02..e51d939 100644
--- a/ddk_build.cmd
+++ b/ddk_build.cmd
@@ -38,6 +38,9 @@ mkdir %dstPath%\dll
if exist %dstPath%\lib goto md5
md %dstPath%\lib
:md5
+if exist %dstPath%\examples goto md6
+md %dstPath%\examples
+:md6
@echo on
copy %srcPath%\libusb-%version%.dll %dstPath%\dll
@@ -45,6 +48,48 @@ copy %srcPath%\libusb-%version%.pdb %dstPath%\dll
copy %srcPath%\libusb-%version%.lib %dstPath%\lib
@echo off
+
+if exist examples\lsusb_ddkbuild goto md7
+md examples\lsusb_ddkbuild
+:md7
+
+cd examples\lsusb_ddkbuild
+copy ..\lsusb_sources sources
+@echo on
+build -cZ
+@echo off
+if errorlevel 1 goto buildlsusberror
+cd ..\..
+
+set srcPath=examples\lsusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
+@echo on
+
+copy %srcPath%\lsusb.exe %dstPath%\examples
+copy %srcPath%\lsusb.pdb %dstPath%\examples
+
+@echo off
+
+if exist examples\xusb_ddkbuild goto md8
+md examples\xusb_ddkbuild
+:md8
+
+cd examples\xusb_ddkbuild
+copy ..\xusb_sources sources
+@echo on
+build -cZ
+@echo off
+if errorlevel 1 goto buildxusberror
+cd ..\..
+
+set srcPath=examples\xusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
+@echo on
+
+copy %srcPath%\xusb.exe %dstPath%\examples
+copy %srcPath%\xusb.pdb %dstPath%\examples
+
+@echo off
+
+
goto done
@@ -54,6 +99,16 @@ cd ..\..
echo Build failed
goto done
+:buildlsusberror
+cd ..\..
+echo lsusb build failed
+goto done
+
+:buildxusberror
+cd ..\..
+echo xusb build failed
+goto done
+
:usage
echo ddk_build must be run in a WDK build environment
goto done
diff --git a/examples/lsusb.c b/examples/lsusb.c
index 317adf0..58d58fe 100644
--- a/examples/lsusb.c
+++ b/examples/lsusb.c
@@ -41,7 +41,11 @@ static void print_devs(libusb_device **devs)
}
}
-int main(void)
+int
+#ifdef _MSC_VER
+__cdecl
+#endif
+main(void)
{
libusb_device **devs;
int r;
diff --git a/examples/lsusb_sources b/examples/lsusb_sources
new file mode 100644
index 0000000..fcb4c4d
--- /dev/null
+++ b/examples/lsusb_sources
@@ -0,0 +1,36 @@
+TARGETNAME=lsusb
+TARGETTYPE=PROGRAM
+
+_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP)
+
+!IFNDEF MSC_WARNING_LEVEL
+
+MSC_WARNING_LEVEL=/W3
+
+!ENDIF
+
+
+
+!IF "$(_BUILDARCH)"=="AMD64"
+
+PTHREAD_LIB=pthreadVC2_x64.lib
+
+!ELSE
+
+PTHREAD_LIB=pthreadVC2.lib
+
+!ENDIF
+
+
+
+USE_MSVCRT=1
+
+UMTYPE=console
+
+INCLUDES=..\..\msvc;..\..;$(DDK_INC_PATH)
+
+UMLIBS=..\..\msvc\$(PTHREAD_LIB) \
+ ..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
+
+SOURCES=..\lsusb.c
+
diff --git a/examples/xusb.c b/examples/xusb.c
index 69b3d55..34030a6 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -467,7 +467,7 @@ int test_device(uint16_t vid, uint16_t pid)
nb_strings = string[0];
printf("Retrieving string descriptors...\n");
for (i=1; i<nb_strings; i++) {
- if (libusb_get_string_descriptor_ascii(handle, i, string, 128) >= 0) {
+ if (libusb_get_string_descriptor_ascii(handle, (uint8_t)i, string, 128) >= 0) {
printf("string (%d/%d): \"%s\"\n", i, nb_strings-1, string);
}
}
@@ -505,7 +505,11 @@ int test_device(uint16_t vid, uint16_t pid)
return 0;
}
-int main(int argc, char** argv)
+int
+#ifdef _MSC_VER
+__cdecl
+#endif
+main(int argc, char** argv)
{
int r;
diff --git a/examples/xusb_sources b/examples/xusb_sources
new file mode 100644
index 0000000..609f369
--- /dev/null
+++ b/examples/xusb_sources
@@ -0,0 +1,36 @@
+TARGETNAME=xusb
+TARGETTYPE=PROGRAM
+
+_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP)
+
+!IFNDEF MSC_WARNING_LEVEL
+
+MSC_WARNING_LEVEL=/W3
+
+!ENDIF
+
+
+
+!IF "$(_BUILDARCH)"=="AMD64"
+
+PTHREAD_LIB=pthreadVC2_x64.lib
+
+!ELSE
+
+PTHREAD_LIB=pthreadVC2.lib
+
+!ENDIF
+
+
+
+USE_MSVCRT=1
+
+UMTYPE=console
+
+INCLUDES=..\..\msvc;..\..;$(DDK_INC_PATH)
+
+UMLIBS=..\..\msvc\$(PTHREAD_LIB) \
+ ..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
+
+SOURCES=..\xusb.c
+
diff --git a/libusb/io.c b/libusb/io.c
index 7de9b46..c93b074 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1716,6 +1716,7 @@ static int handle_timeouts(struct libusb_context *ctx)
/* Note: there is code duplication between handle_timeouts_locked and
* handle_timeouts, as tranfer cancellation from the backend requires
* flying_transfers locks that are not set wholesale */
+#ifndef OS_WINDOWS
static int handle_timeouts_locked(struct libusb_context *ctx)
{
int r;
@@ -1757,6 +1758,7 @@ static int handle_timeouts_locked(struct libusb_context *ctx)
}
return 0;
}
+#endif
static int handle_timeouts(struct libusb_context *ctx)
{
diff --git a/libusb/libusb-1.0.def b/libusb/libusb-1.0.def
index 24c4c6b..3261694 100644
--- a/libusb/libusb-1.0.def
+++ b/libusb/libusb-1.0.def
@@ -53,3 +53,4 @@ EXPORTS
libusb_get_next_timeout
libusb_get_pollfds
libusb_set_pollfd_notifiers
+ libusb_strerror