diff --git a/contrib/win32/libnfc/buses/uart.c b/contrib/win32/libnfc/buses/uart.c index ba7ddfe8..6b2478d5 100644 --- a/contrib/win32/libnfc/buses/uart.c +++ b/contrib/win32/libnfc/buses/uart.c @@ -45,9 +45,7 @@ #define LOG_GROUP NFC_LOG_GROUP_COM #define LOG_CATEGORY "libnfc.bus.uart_win32" -// Handle platform specific includes #include "contrib/windows.h" -#define delay_ms( X ) Sleep( X ) struct serial_port_windows { HANDLE hPort; // Serial port handle diff --git a/examples/nfc-emulate-tag.c b/examples/nfc-emulate-tag.c index a2adbe67..a3f96e26 100644 --- a/examples/nfc-emulate-tag.c +++ b/examples/nfc-emulate-tag.c @@ -189,11 +189,7 @@ main(int argc, char *argv[]) (void) argc; const char *acLibnfcVersion; -#ifdef WIN32 - signal(SIGINT, (void (__cdecl *)(int)) intr_hdlr); -#else signal(SIGINT, intr_hdlr); -#endif nfc_init(&context); if (context == NULL) { diff --git a/examples/nfc-emulate-uid.c b/examples/nfc-emulate-uid.c index 690388ed..ff29d879 100644 --- a/examples/nfc-emulate-uid.c +++ b/examples/nfc-emulate-uid.c @@ -130,11 +130,7 @@ main(int argc, char *argv[]) } } -#ifdef WIN32 - signal(SIGINT, (void (__cdecl *)(int)) intr_hdlr); -#else signal(SIGINT, intr_hdlr); -#endif nfc_init(&context); if (context == NULL) { diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 4cea5d63..2acacc60 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -44,7 +44,6 @@ # include "config.h" #endif // HAVE_CONFIG_H -#include #include #include #include diff --git a/examples/nfc-relay.c b/examples/nfc-relay.c index e03c8cd2..6c0948c8 100644 --- a/examples/nfc-relay.c +++ b/examples/nfc-relay.c @@ -109,11 +109,7 @@ main(int argc, char *argv[]) // Display libnfc version printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion); -#ifdef WIN32 - signal(SIGINT, (void (__cdecl *)(int)) intr_hdlr); -#else signal(SIGINT, intr_hdlr); -#endif nfc_context *context; nfc_init(&context); diff --git a/examples/nfc-st25tb.c b/examples/nfc-st25tb.c index 7eb5deeb..8b8bb0c9 100644 --- a/examples/nfc-st25tb.c +++ b/examples/nfc-st25tb.c @@ -64,10 +64,6 @@ #include #include -#if defined(WIN32) /* mingw compiler */ -#include -#endif - #define ST25TB_SR_BLOCK_MAX_SIZE ((uint8_t) 4) // for static arrays typedef void(*get_info_specific) (uint8_t * systemArea); diff --git a/examples/pn53x-diagnose.c b/examples/pn53x-diagnose.c index b5b0e525..50f5169b 100644 --- a/examples/pn53x-diagnose.c +++ b/examples/pn53x-diagnose.c @@ -43,7 +43,6 @@ # include "config.h" #endif // HAVE_CONFIG_H -#include #include #include diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index 52beee16..d384098a 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -54,24 +54,11 @@ #include #include -#ifndef _WIN32 -# include -# define msleep(x) do { \ - struct timespec xsleep; \ - xsleep.tv_sec = x / 1000; \ - xsleep.tv_nsec = (x - xsleep.tv_sec * 1000) * 1000 * 1000; \ - nanosleep(&xsleep, NULL); \ - } while (0) -#else -# include -# define msleep Sleep -#endif - - #include #include "utils/nfc-utils.h" #include "libnfc/chips/pn53x.h" +#include "libnfc/nfc-internal.h" #define MAX_FRAME_LEN 264 diff --git a/libnfc/buses/uart.c b/libnfc/buses/uart.c index ffe64aa5..1e8054b9 100644 --- a/libnfc/buses/uart.c +++ b/libnfc/buses/uart.c @@ -57,22 +57,6 @@ #define LOG_GROUP NFC_LOG_GROUP_COM #define LOG_CATEGORY "libnfc.bus.uart" -#ifndef _WIN32 -// Needed by sleep() under Unix -# include -# include -# define msleep(x) do { \ - struct timespec xsleep; \ - xsleep.tv_sec = x / 1000; \ - xsleep.tv_nsec = (x - xsleep.tv_sec * 1000) * 1000 * 1000; \ - nanosleep(&xsleep, NULL); \ - } while (0) -#else -// Needed by Sleep() under Windows -# include -# define msleep Sleep -#endif - # if defined(__APPLE__) const char *serial_ports_device_radix[] = { "tty.SLAB_USBtoUART", "tty.usbserial", "tty.usbmodem", NULL }; # elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__FreeBSD_kernel__) diff --git a/libnfc/drivers/pcsc.c b/libnfc/drivers/pcsc.c index 106d99ac..34a9ac7d 100644 --- a/libnfc/drivers/pcsc.c +++ b/libnfc/drivers/pcsc.c @@ -67,17 +67,12 @@ #define SCARD_ATTR_VENDOR_IFD_SERIAL_NO SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0103) /**< Vendor-supplied interface device serial number. */ #define SCARD_ATTR_ICC_TYPE_PER_ATR SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0304) /**< Single byte indicating smart card type */ #else -#ifndef _Win32 +#ifndef _WIN32 #include #endif #include #endif -#ifdef WIN32 -#include -#define usleep(x) Sleep((x + 999) / 1000) -#endif - #define PCSC_DRIVER_NAME "pcsc" #include @@ -826,7 +821,7 @@ static int pcsc_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t pnd->last_error = pcsc_transmit(pnd, apdu_data, send_size, resp, &resp_len); memset(apdu_data, 0, sizeof(apdu_data)); memset(resp, 0, sizeof(resp)); - usleep(500000);//delay 500ms + msleep(500); } // then auth apdu_data[0] = 0xFF; diff --git a/libnfc/drivers/pn532_spi.c b/libnfc/drivers/pn532_spi.c index 39a8b51a..4d243c58 100644 --- a/libnfc/drivers/pn532_spi.c +++ b/libnfc/drivers/pn532_spi.c @@ -54,22 +54,6 @@ #define LOG_CATEGORY "libnfc.driver.pn532_spi" #define LOG_GROUP NFC_LOG_GROUP_DRIVER -#ifndef _WIN32 -// Needed by sleep() under Unix -# include -# include -# define msleep(x) do { \ - struct timespec xsleep; \ - xsleep.tv_sec = x / 1000; \ - xsleep.tv_nsec = (x - xsleep.tv_sec * 1000) * 1000 * 1000; \ - nanosleep(&xsleep, NULL); \ - } while (0) -#else -// Needed by Sleep() under Windows -# include -# define msleep Sleep -#endif - // Internal data structs const struct pn53x_io pn532_spi_io; struct pn532_spi_data { diff --git a/libnfc/nfc-internal.c b/libnfc/nfc-internal.c index 7ed834d2..bb0d6583 100644 --- a/libnfc/nfc-internal.c +++ b/libnfc/nfc-internal.c @@ -43,7 +43,6 @@ #include #include -#include #define LOG_GROUP NFC_LOG_GROUP_GENERAL #define LOG_CATEGORY "libnfc.general" diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index 74c05c21..648ac605 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -33,10 +33,6 @@ #define __NFC_INTERNAL_H__ #include -#include -#if !defined(_MSC_VER) -# include -#endif #include "nfc/nfc.h" @@ -63,6 +59,22 @@ #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif +#ifndef _WIN32 +// Needed by sleep() under Unix +# include +# include +# define msleep(x) do { \ + struct timespec xsleep; \ + xsleep.tv_sec = x / 1000; \ + xsleep.tv_nsec = (x - xsleep.tv_sec * 1000) * 1000 * 1000; \ + nanosleep(&xsleep, NULL); \ + } while (0) +#else +// Needed by Sleep() under Windows +# include +# define msleep Sleep +#endif + /* * Buffer management macros. * diff --git a/utils/nfc-list.c b/utils/nfc-list.c index bb6aaef9..ebc53bc3 100644 --- a/utils/nfc-list.c +++ b/utils/nfc-list.c @@ -44,7 +44,6 @@ # include "config.h" #endif // HAVE_CONFIG_H -#include #include #include #include diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index 244af45c..a93ba946 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -54,12 +54,6 @@ #include #include -#ifndef _WIN32 -#include -#include -#include -#endif - #include #include "mifare.h" diff --git a/utils/nfc-read-forum-tag3.c b/utils/nfc-read-forum-tag3.c index 52c6c2f8..890cecd1 100644 --- a/utils/nfc-read-forum-tag3.c +++ b/utils/nfc-read-forum-tag3.c @@ -62,10 +62,6 @@ #include "nfc-utils.h" -#if defined(WIN32) /* mingw compiler */ -#include -#endif - static nfc_device *pnd; static nfc_context *context; diff --git a/utils/nfc-relay-picc.c b/utils/nfc-relay-picc.c index d694f8a6..0d0fc37b 100644 --- a/utils/nfc-relay-picc.c +++ b/utils/nfc-relay-picc.c @@ -199,11 +199,7 @@ main(int argc, char *argv[]) // Display libnfc version printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion); -#ifdef WIN32 - signal(SIGINT, (void (__cdecl *)(int)) intr_hdlr); -#else signal(SIGINT, intr_hdlr); -#endif nfc_context *context; nfc_init(&context); diff --git a/utils/nfc-scan-device.c b/utils/nfc-scan-device.c index bdc100de..24482eed 100644 --- a/utils/nfc-scan-device.c +++ b/utils/nfc-scan-device.c @@ -43,7 +43,6 @@ # include "config.h" #endif // HAVE_CONFIG_H -#include #include #include #include diff --git a/utils/nfc-utils.c b/utils/nfc-utils.c index 72a33eda..c9e94ac8 100644 --- a/utils/nfc-utils.c +++ b/utils/nfc-utils.c @@ -38,7 +38,6 @@ * @brief Provide some examples shared functions like print, parity calculation, options parsing. */ #include -#include #include "nfc-utils.h"