Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup unused code #724

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions contrib/win32/libnfc/buses/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions examples/nfc-emulate-tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions examples/nfc-emulate-uid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion examples/nfc-poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
# include "config.h"
#endif // HAVE_CONFIG_H

#include <err.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
Expand Down
4 changes: 0 additions & 4 deletions examples/nfc-relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions examples/nfc-st25tb.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@
#include <string.h>
#include <nfc/nfc.h>

#if defined(WIN32) /* mingw compiler */
#include <getopt.h>
#endif

#define ST25TB_SR_BLOCK_MAX_SIZE ((uint8_t) 4) // for static arrays
typedef void(*get_info_specific) (uint8_t * systemArea);

Expand Down
1 change: 0 additions & 1 deletion examples/pn53x-diagnose.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
# include "config.h"
#endif // HAVE_CONFIG_H

#include <err.h>
#include <stdlib.h>
#include <string.h>

Expand Down
15 changes: 1 addition & 14 deletions examples/pn53x-tamashell.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,11 @@
#include <ctype.h>
#include <time.h>

#ifndef _WIN32
# include <time.h>
# 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 <winbase.h>
# define msleep Sleep
#endif


#include <nfc/nfc.h>

#include "utils/nfc-utils.h"
#include "libnfc/chips/pn53x.h"
#include "libnfc/nfc-internal.h"

#define MAX_FRAME_LEN 264

Expand Down
16 changes: 0 additions & 16 deletions libnfc/buses/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <unistd.h>
# include <time.h>
# 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 <winbase.h>
# 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__)
Expand Down
9 changes: 2 additions & 7 deletions libnfc/drivers/pcsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <reader.h>
#endif
#include <winscard.h>
#endif

#ifdef WIN32
#include <windows.h>
#define usleep(x) Sleep((x + 999) / 1000)
#endif

#define PCSC_DRIVER_NAME "pcsc"

#include <nfc/nfc.h>
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 0 additions & 16 deletions libnfc/drivers/pn532_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <unistd.h>
# include <time.h>
# 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 <winbase.h>
# define msleep Sleep
#endif

// Internal data structs
const struct pn53x_io pn532_spi_io;
struct pn532_spi_data {
Expand Down
1 change: 0 additions & 1 deletion libnfc/nfc-internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

#include <stdlib.h>
#include <string.h>
#include <inttypes.h>

#define LOG_GROUP NFC_LOG_GROUP_GENERAL
#define LOG_CATEGORY "libnfc.general"
Expand Down
20 changes: 16 additions & 4 deletions libnfc/nfc-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
#define __NFC_INTERNAL_H__

#include <stdbool.h>
#include <err.h>
#if !defined(_MSC_VER)
# include <sys/time.h>
#endif

#include "nfc/nfc.h"

Expand All @@ -63,6 +59,22 @@
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif

#ifndef _WIN32
// Needed by sleep() under Unix
# include <unistd.h>
# include <time.h>
# 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 <windows.h>
# define msleep Sleep
#endif

/*
* Buffer management macros.
*
Expand Down
1 change: 0 additions & 1 deletion utils/nfc-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
# include "config.h"
#endif // HAVE_CONFIG_H

#include <err.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
Expand Down
6 changes: 0 additions & 6 deletions utils/nfc-mfclassic.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@
#include <string.h>
#include <ctype.h>

#ifndef _WIN32
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#endif

#include <nfc/nfc.h>

#include "mifare.h"
Expand Down
4 changes: 0 additions & 4 deletions utils/nfc-read-forum-tag3.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@

#include "nfc-utils.h"

#if defined(WIN32) /* mingw compiler */
#include <getopt.h>
#endif

static nfc_device *pnd;
static nfc_context *context;

Expand Down
4 changes: 0 additions & 4 deletions utils/nfc-relay-picc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion utils/nfc-scan-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
# include "config.h"
#endif // HAVE_CONFIG_H

#include <err.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
Expand Down
1 change: 0 additions & 1 deletion utils/nfc-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @brief Provide some examples shared functions like print, parity calculation, options parsing.
*/
#include <nfc/nfc.h>
#include <err.h>

#include "nfc-utils.h"

Expand Down