Windows: Don't let device disappear from hid_enumerate() when open

Change the CreateFileA() flags to support the following:
1. Devices can still be opened in exclusive mode,
2. Devices which must be opened in shared mode can still be opened.
3. Opened devices (even with exclusive opens) still show in
hid_enumerate()

Thanks to github user vanweric for suggesting these flags and to Brendan
Shanks for discussion and testing.
Merge branch 'master' of github.com:signal11/hidapi
Remove unnecessary setlocale() on Mac
Linux: Don't set locale if it's already been set

Adapted from a patch received from Axel Rohde <axel.rohde@gmail.com>
Linux: Took out one more setlocale()
Linux/hidraw: Fix return value string functions
	get_serial_number()
	get_manufacturer_string()
	get_product_string()

This matches the documentation in header file to return 0 on success and -1
on error.
Mac: Fix return value for string functions
	get_serial_number()
	get_manufacturer_string()
	get_product_string()

This is to match the documentation in the header file, returning 0 on
success and -1 on error.
Linux: Added make targets for building shared libraries.
Linux: Clean up Makefile

Create separate targets for libusb and hidraw implementations.
Build shared libraries in a more standard way.
Add Comments.
All: Make serial_number parameter to hid_open() const.

This prevents a warning when passing in a literal.
Fixed a typo that made the shared libraries be empty. Added the hidtest-* binaries to the list of files ignored by git.
Linux/libusb: Shutdown thread if it's not possible to submit transfer

This happens if a device gets opened a second time. The call to
libusb_submit_transfer() will fail, indicating that the read thread should
be shut down.
Linux: add -lrt to link with librt.

This is required for some distributions but not others.
FreeBSD: Add FreeBSD implementation.

This adds a FreeBSD implementation to HIDAPI using the libusb back-end. The
libusb/ folder now contains the libusb implementation and associated
Makefiles for Linux and FreeBSD. All libusb code has been removed from the
linux/ folder, so that the code in libusb/ can be shared by both (and
future) platforms.

This commit renames linux/hid-libusb.c to libusb/hid.c. Make sure to
use git log --follow to see full history of that file.

This code was written by:
 Alex Dupre <ale@FreeBSD.org>
 Alan Ott <alan@signal11.us>
Libusb: Cleanup

Remove unnecessary initialization in new_hid_device()
Remove unnecessary NULL-termination in usb_get_string()
testgui: Fix signed/unsigned warning
Libusb: testgui: Explicitly link to libpthread.

Reported by: Xiaofan Chen <xiaofanc@gmail.com>
Windows: Fix compile when using DDK

There are type definitions that allow compilation without requiring the
Windows DDK to be installed for compilation/linking however one of the
types used was wrong and when actually compiled against the DDK, it
would fail.
Mac: Add CFRetain()/CFRelease() pair on the device handle

Adding retain/release to the device since we keep the reference in
our object.
Windows: Fixed an incorrect return type on HidP_GetCaps()

Addresses an issue with the return type of HidP_GetCaps() which was
returning the wrong status code because of the invalid return type of
BOOLEAN which is a UCHAR. The return code is supposed to be 0x110000
which obviously doesn't fit in a UCHAR so it was being rounded to
0x0. Basically, no return codes were ever making it through that call.