Misc: Simplify includes and misc. cleanup
authorPete Batard <pete@akeo.ie>
Wed, 27 Feb 2013 22:58:49 +0000 (22:58 +0000)
committerPete Batard <pete@akeo.ie>
Wed, 27 Feb 2013 22:58:49 +0000 (22:58 +0000)
* fxload sample provenance
* No need for <sys/types.h> in samples as already in libusb.h
* Don't bother about sscanf_s in xusb
* Use HAVE_### and rely on config.h where possible
* Formal inclusion of <winsock.h> in libusb.h for WinCE and WDK
* Cleanup of Windows' config.h
* Avoid ENAMETOOLONG and ENOTEMPTY conflict between errno.h and winsock.h for WinCE
* Additional newlines & braces cleanup

14 files changed:
examples/fxload.c
examples/listdevs.c
examples/xusb.c
libusb/core.c
libusb/io.c
libusb/libusb.h
libusb/libusbi.h
libusb/os/poll_windows.c
libusb/os/windows_common.h
libusb/os/windows_usb.c
libusb/version_nano.h
msvc/config.h
msvc/errno.h
tests/stress.c

index 93f9fb9d002fdebf2e2fc2dacce4d5a50bd2119a..42e0ca44b14e31698094b466e629c82136b93e74 100644 (file)
@@ -49,7 +49,7 @@ static bool dosyslog = false;
 #endif
 
 #ifndef FXLOAD_VERSION
-#define FXLOAD_VERSION (__DATE__ " (development)")
+#define FXLOAD_VERSION (__DATE__ " (libusbx)")
 #endif
 
 #ifndef ARRAYSIZE
index 8538bfa2e4e7f96b8b1b22ed828a62071c2302a9..e3d7ef002795cf3b24f934added0891186e23140 100644 (file)
@@ -18,9 +18,6 @@
  */
 
 #include <stdio.h>
-#if !defined(_WIN32_WCE)
-#include <sys/types.h>
-#endif
 
 #include "libusb.h"
 
index 707b58fc717212bad0e004d59daeadbb65ad4d07..1aa33637a5d098885288bb444c309b2de57bb5e4 100644 (file)
 #define msleep(msecs) usleep(1000*msecs)
 #endif
 
-#if !defined(_MSC_VER) || _MSC_VER<=1200 || defined(_WIN32_WCE)
-#define sscanf_s sscanf
-#endif
-
 #if !defined(bool)
 #define bool int
 #endif
@@ -47,7 +43,6 @@
 #define false (!true)
 #endif
 
-
 // Future versions of libusbx will use usb_interface instead of interface
 // in libusb_config_descriptor => catter for that
 #define usb_interface interface
@@ -992,7 +987,7 @@ int main(int argc, char** argv)
                                                break;
                                }
                                if (i != arglen) {
-                                       if (sscanf_s(argv[j], "%x:%x" , &tmp_vid, &tmp_pid) != 2) {
+                                       if (sscanf(argv[j], "%x:%x" , &tmp_vid, &tmp_pid) != 2) {
                                                printf("   Please specify VID & PID as \"vid:pid\" in hexadecimal format\n");
                                                return 1;
                                        }
index 52908afc6fa41e02d92635cc6bdb84346dc8a630..01b80827a1395731d4044deb2752cdcd4e6069f1 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
-
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 
-#if defined(OS_WINCE)
-#include "missing.h"   // getenv()
-#endif
-
 #include "libusbi.h"
+#ifdef HAVE_MISSING_H
+#include "missing.h"
+#endif
 
 #if defined(OS_LINUX)
 const struct usbi_os_backend * const usbi_backend = &linux_usbfs_backend;
index 58c077ce91126e004570ee4c676446342a4c97b6..2539b2636416114436553c3cddd82fa7dbe8c9a2 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
 #endif
-
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
-
 #ifdef USBI_TIMERFD_AVAILABLE
 #include <sys/timerfd.h>
 #endif
index c3b2f67050e354ec4757c60556d1fd1810b2486d..d7e84c086b39d7ff6381ac63b9746d1fd6a28450 100644 (file)
@@ -40,7 +40,7 @@
 #endif /* _SSIZE_T_DEFINED */
 #endif /* _MSC_VER */
 
-/* stdint.h is also not usually available on MS */
+/* stdint.h is not available on older MSVC */
 #if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
 typedef unsigned __int8   uint8_t;
 typedef unsigned __int16  uint16_t;
@@ -52,13 +52,14 @@ typedef unsigned __int32  uint32_t;
 #if !defined(_WIN32_WCE)
 #include <sys/types.h>
 #endif
-#include <time.h>
-#include <limits.h>
 
 #if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
 #include <sys/time.h>
 #endif
 
+#include <time.h>
+#include <limits.h>
+
 /* 'interface' might be defined as a macro on Windows, so we need to
  * undefine it so as not to break the current libusbx API, because
  * libusb_config_descriptor has an 'interface' member
@@ -69,9 +70,8 @@ typedef unsigned __int32  uint32_t;
 #if defined(interface)
 #undef interface
 #endif
-#if defined(_WIN32_WCE)
-// Needed for "struct timeval" definition
-#include <winsock2.h>
+#if !defined(__CYGWIN__)
+#include <winsock.h>
 #endif
 #endif
 
index f81b5d169bec94cbdb422675203a711d2207db25..e296a2c4e31ad1b2ec86687fd5b49c2539436594 100644 (file)
@@ -30,9 +30,6 @@
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #endif
-#ifdef DDKBUILD
-#include <winsock.h>   // needed for struct timeval for WDK
-#endif
 
 #include "libusb.h"
 #include "version.h"
index 03e6f3c35bf80579e45f7a6b59ecb0d132f0017b..559988a62fa9eeb576cba0f5a3bced73f39075bf 100644 (file)
@@ -43,7 +43,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <libusbi.h>
+#include "libusbi.h"
 
 // Uncomment to debug the polling layer
 //#define DEBUG_POLL_WINDOWS
index d12be6bc53a11499e1e20a7fc9eebf8bf3c52b4e..c06367829453686ae9be0ce2b50126881ac9a370 100644 (file)
 #define DLL_LOAD(dll, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll, name, name, ret_on_failure)
 #define DLL_DECLARE_PREFIXED(api, ret, prefix, name, args)   DLL_DECLARE_PREFIXNAME(api, ret, prefix##name, name, args)
 #define DLL_LOAD_PREFIXED(dll, prefix, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll, prefix##name, name, ret_on_failure)
-
index ffcfc01c2999272538991c05a1962acc6b460b70..1a0c846f7e7e282a4f4e87afcac0c1e0b51b2ab5 100644 (file)
@@ -34,7 +34,7 @@
 #include <objbase.h>
 #include <winioctl.h>
 
-#include <libusbi.h>
+#include "libusbi.h"
 #include "poll_windows.h"
 #include "windows_usb.h"
 
index 72343bac4a27e57e68550b96ecba34a52bfedae9..c6654db02aa5bab8fa67b426a7e3011c31c8c3e3 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10620
+#define LIBUSB_NANO 10621
index eb05d3d837eec6d4ebd747168c21824f415e29e4..1814db5fb2dd7d5f87555e50170c13bdeb0f1fbf 100644 (file)
 /* Default visibility */
 #define DEFAULT_VISIBILITY /**/
 
-/* Start with debug message logging enabled */
-//#define ENABLE_DEBUG_LOGGING 1
-
-/* Message logging */
+/* Enable global message logging */
 #define ENABLE_LOGGING 1
 
+/* Uncomment to start with debug message logging enabled */
+// #define ENABLE_DEBUG_LOGGING 1
+
+/* type of second poll() argument */
+#define POLL_NFDS_TYPE unsigned int
+
 /* Windows/WinCE backend */
 #if defined(_WIN32_WCE)
 #define OS_WINCE 1
+#define HAVE_MISSING_H
 #else
 #define OS_WINDOWS 1
-#endif
-
-/* type of second poll() argument */
-#define POLL_NFDS_TYPE unsigned int
-
-#if !defined(_WIN32_WCE)
-
-/* Define to 1 if you have the <signal.h> header file. */
 #define HAVE_SIGNAL_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
 #define HAVE_SYS_TYPES_H 1
-
-#endif
\ No newline at end of file
+#endif
index a1d4f64718ae524659aee58cc730594a35db8cfa..07d15e3d4458b909e8a5431c2597305b6dbb105f 100644 (file)
 /* 35 - Unknown Error */
 #define        EDEADLOCK       36      /* Resource deadlock avoided (non-Cyg) */
 #define        EDEADLK         36
+#if 0
 /* 37 - Unknown Error */
 #define        ENAMETOOLONG    38      /* Filename too long (91 in Cyg?) */
 #define        ENOLCK          39      /* No locks available (46 in Cyg?) */
 #define        ENOSYS          40      /* Function not implemented (88 in Cyg?) */
 #define        ENOTEMPTY       41      /* Directory not empty (90 in Cyg?) */
 #define        EILSEQ          42      /* Illegal byte sequence */
+#endif
 
 /*
  * NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the
index 26860a044649589bedf90034a2ec52f30c479668..e53f415962010b20d0bae1a40cc9a4d90de1197c 100644 (file)
 
 #include <stdio.h>
 #include <memory.h>
-#if !defined(_WIN32_WCE)
-#include <sys/types.h>
-#endif
 
 #include "libusb.h"
-
 #include "libusbx_testlib.h"
 
 /** Test that creates and destroys a single concurrent context