Use C99 standard bool type instead of locally defined one.
Check for types in configure pass. Fix a warning related to nfc_reader_select() (a length - uiInitDataLen - was set by NULL instead of 0).
This commit is contained in:
parent
f34857487d
commit
1dcb53dc4d
8 changed files with 41 additions and 29 deletions
46
configure.ac
46
configure.ac
|
@ -13,29 +13,21 @@ AC_PATH_PROG(PKG_CONFIG, pkg-config)
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS([stdio.h stdlib.h stdint.h stddef.h])
|
AC_HEADER_STDBOOL
|
||||||
|
AC_CHECK_HEADERS([stdio.h stdlib.h stdint.h stddef.h stdbool.h])
|
||||||
|
|
||||||
|
# Checks for types
|
||||||
# libusb
|
AC_TYPE_SIZE_T
|
||||||
PKG_CHECK_MODULES(LIBUSB, libusb, [WITH_USB=1], [WITH_USB=0])
|
AC_TYPE_UINT8_T
|
||||||
if test "$WITH_USB" == "0" ; then
|
AC_TYPE_UINT16_T
|
||||||
AC_MSG_ERROR([libusb is mandatory.])
|
AC_TYPE_UINT32_T
|
||||||
fi
|
AC_TYPE_UINT64_T
|
||||||
AC_SUBST(LIBUSB_LIBS)
|
AC_TYPE_INT32_T
|
||||||
AC_SUBST(LIBUSB_CFLAGS)
|
|
||||||
|
|
||||||
# libpcsclite
|
|
||||||
PKG_CHECK_MODULES(LIBPCSCLITE, libpcsclite, [WITH_PCSC=1], [WITH_PCSC=0])
|
|
||||||
if test "$WITH_PCSC" == "0" ; then
|
|
||||||
AC_MSG_ERROR([libpcsclite is mandatory.])
|
|
||||||
fi
|
|
||||||
AC_SUBST(LIBPCSCLITE_LIBS)
|
|
||||||
AC_SUBST(LIBPCSCLITE_CFLAGS)
|
|
||||||
|
|
||||||
# --enable-debug support
|
# --enable-debug support
|
||||||
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Debug flags]),[enable_debug=$enableval],[enable_debug="no"])
|
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Debug flags]),[enable_debug=$enableval],[enable_debug="no"])
|
||||||
|
|
||||||
AC_MSG_CHECKING(debug)
|
AC_MSG_CHECKING(for debug flag)
|
||||||
AC_MSG_RESULT($enable_debug)
|
AC_MSG_RESULT($enable_debug)
|
||||||
|
|
||||||
if test "x$enable_debug" = "xyes"
|
if test "x$enable_debug" = "xyes"
|
||||||
|
@ -44,6 +36,24 @@ then
|
||||||
fi
|
fi
|
||||||
AC_SUBST([DEBUG_CFLAGS])
|
AC_SUBST([DEBUG_CFLAGS])
|
||||||
|
|
||||||
|
# pkg-config check for
|
||||||
|
## libusb
|
||||||
|
PKG_CHECK_MODULES(LIBUSB, libusb, [WITH_USB=1], [WITH_USB=0])
|
||||||
|
if test "$WITH_USB" == "0" ; then
|
||||||
|
AC_MSG_ERROR([libusb is mandatory.])
|
||||||
|
fi
|
||||||
|
AC_SUBST(LIBUSB_LIBS)
|
||||||
|
AC_SUBST(LIBUSB_CFLAGS)
|
||||||
|
|
||||||
|
## libpcsclite
|
||||||
|
PKG_CHECK_MODULES(LIBPCSCLITE, libpcsclite, [WITH_PCSC=1], [WITH_PCSC=0])
|
||||||
|
if test "$WITH_PCSC" == "0" ; then
|
||||||
|
AC_MSG_ERROR([libpcsclite is mandatory.])
|
||||||
|
fi
|
||||||
|
AC_SUBST(LIBPCSCLITE_LIBS)
|
||||||
|
AC_SUBST(LIBPCSCLITE_CFLAGS)
|
||||||
|
|
||||||
|
# Set C standard to C99
|
||||||
CFLAGS="$CFLAGS -std=c99"
|
CFLAGS="$CFLAGS -std=c99"
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
|
|
|
@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "libnfc.h"
|
#include "libnfc.h"
|
||||||
|
|
|
@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define _LIBNFC_DEV_ACR122_H_
|
#define _LIBNFC_DEV_ACR122_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
|
@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define _LIBNFC_DEV_PN531_H_
|
#define _LIBNFC_DEV_PN531_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
|
@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define _LIBNFC_H_
|
#define _LIBNFC_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
|
@ -59,7 +59,7 @@ int main(int argc, const char* argv[])
|
||||||
printf("\nConnected to NFC reader: %s\n\n",pdi->acName);
|
printf("\nConnected to NFC reader: %s\n\n",pdi->acName);
|
||||||
|
|
||||||
// Poll for a ISO14443A (MIFARE) tag
|
// Poll for a ISO14443A (MIFARE) tag
|
||||||
if (nfc_reader_select(pdi,IM_ISO14443A_106,NULL,NULL,&ti))
|
if (nfc_reader_select(pdi,IM_ISO14443A_106,NULL,0,&ti))
|
||||||
{
|
{
|
||||||
printf("The following (NFC) ISO14443A tag was found:\n\n");
|
printf("The following (NFC) ISO14443A tag was found:\n\n");
|
||||||
printf(" ATQA (SENS_RES): "); print_hex(ti.tia.abtAtqa,2);
|
printf(" ATQA (SENS_RES): "); print_hex(ti.tia.abtAtqa,2);
|
||||||
|
@ -81,14 +81,14 @@ int main(int argc, const char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll for a ISO14443B tag
|
// Poll for a ISO14443B tag
|
||||||
if (nfc_reader_select(pdi,IM_ISO14443B_106,NULL,NULL,&ti))
|
if (nfc_reader_select(pdi,IM_ISO14443B_106,NULL,0,&ti))
|
||||||
{
|
{
|
||||||
// No test results yet
|
// No test results yet
|
||||||
printf("iso14443b\n");
|
printf("iso14443b\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll for a Jewel tag
|
// Poll for a Jewel tag
|
||||||
if (nfc_reader_select(pdi,IM_JEWEL_106,NULL,NULL,&ti))
|
if (nfc_reader_select(pdi,IM_JEWEL_106,NULL,0,&ti))
|
||||||
{
|
{
|
||||||
// No test results yet
|
// No test results yet
|
||||||
printf("jewel\n");
|
printf("jewel\n");
|
||||||
|
|
|
@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -74,7 +75,7 @@ bool read_card()
|
||||||
{
|
{
|
||||||
printf("x");
|
printf("x");
|
||||||
// When a failure occured we need to redo the anti-collision
|
// When a failure occured we need to redo the anti-collision
|
||||||
if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,NULL,&ti))
|
if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,0,&ti))
|
||||||
{
|
{
|
||||||
printf("!\nError: tag was removed\n");
|
printf("!\nError: tag was removed\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -157,7 +158,7 @@ bool write_card()
|
||||||
{
|
{
|
||||||
printf("x");
|
printf("x");
|
||||||
// When a failure occured we need to redo the anti-collision
|
// When a failure occured we need to redo the anti-collision
|
||||||
if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,NULL,&ti))
|
if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,0,&ti))
|
||||||
{
|
{
|
||||||
printf("!\nError: tag was removed\n");
|
printf("!\nError: tag was removed\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -312,7 +313,7 @@ int main(int argc, const char* argv[])
|
||||||
printf("Connected to NFC reader: %s\n",pdi->acName);
|
printf("Connected to NFC reader: %s\n",pdi->acName);
|
||||||
|
|
||||||
// Try to find a MIFARE Classic tag
|
// Try to find a MIFARE Classic tag
|
||||||
if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,NULL,&ti))
|
if (!nfc_reader_select(pdi,IM_ISO14443A_106,NULL,0,&ti))
|
||||||
{
|
{
|
||||||
printf("Error: no tag was found\n");
|
printf("Error: no tag was found\n");
|
||||||
nfc_disconnect(pdi);
|
nfc_disconnect(pdi);
|
||||||
|
|
|
@ -22,17 +22,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define _LIBNFC_TYPES_H_
|
#define _LIBNFC_TYPES_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
// Compiler directive, set struct alignment to 1 byte for compatibility
|
// Compiler directive, set struct alignment to 1 byte for compatibility
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
false = 0x00,
|
|
||||||
true = 0x01
|
|
||||||
} bool;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CT_PN531 = 0x10,
|
CT_PN531 = 0x10,
|
||||||
CT_PN532 = 0x20,
|
CT_PN532 = 0x20,
|
||||||
|
|
Loading…
Reference in a new issue