From 7924d10fadbfa2255cffee6453587f8610c0b39e Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Tue, 8 Sep 2009 10:25:59 +0000 Subject: [PATCH] Prevent from exporting messages macros outside of libnfc. --- src/Makefile.am | 6 +++++- src/anticol.c | 2 ++ src/defines.h | 12 ------------ src/dev_acr122.c | 1 + src/dev_arygon.c | 2 ++ src/dev_pn533.c | 7 ++++--- src/emulate.c | 1 + src/libnfc.c | 1 + src/list.c | 1 + src/messages.h | 38 ++++++++++++++++++++++++++++++++++++++ src/relay.c | 1 + src/rs232.c | 2 ++ 12 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 src/messages.h diff --git a/src/Makefile.am b/src/Makefile.am index bd74061..93a0099 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,7 +5,11 @@ bin_PROGRAMS = nfc-anticol nfc-list nfc-mftool nfc-mfultool nfc-relay nfc-emulat # set the include path found by configure INCLUDES= $(all_includes) -nfcinclude_HEADERS = libnfc.h bitutils.h defines.h types.h mifaretag.h mifareultag.h devices.h rs232.h dev_arygon.h dev_pn531.h dev_pn533.h +nfc_devices_headers = dev_arygon.h dev_pn531.h dev_pn533.h +nfc_examples_headers = mifaretag.h mifareultag.h +nfcinclude_HEADERS = libnfc.h bitutils.h defines.h types.h rs232.h devices.h messages.h +nfcinclude_HEADERS += $(nfc_devices_headers) +nfcinclude_HEADERS += $(nfc_examples_headers) nfcincludedir = $(includedir)/libnfc lib_LTLIBRARIES = libnfc.la diff --git a/src/anticol.c b/src/anticol.c index 4d7fccf..6694636 100644 --- a/src/anticol.c +++ b/src/anticol.c @@ -27,6 +27,8 @@ along with this program. If not, see #include "libnfc.h" +#include "messages.h" + #define SAK_FLAG_ATS_SUPPORTED 0x20 static byte_t abtRx[MAX_FRAME_LEN]; diff --git a/src/defines.h b/src/defines.h index 5a65c49..c37f1e9 100644 --- a/src/defines.h +++ b/src/defines.h @@ -29,18 +29,6 @@ typedef void* dev_spec; // Device connection specification #define DEVICE_NAME_LENGTH 256 #define MAX_DEVICES 16 -// Useful macros -#ifdef DEBUG -// #define DBG(x, args...) printf("DBG %s:%d: " x "\n", __FILE__, __LINE__,## args ) - #define DBG(x, ...) printf("DBG %s:%d: " x "\n", __FILE__, __LINE__, ## __VA_ARGS__ ) -#else - #define DBG(...) {} -#endif - -#define INFO(x, ...) printf("INFO: " x "\n", ## __VA_ARGS__ ) -#define WARN(x, ...) printf("WARNING: " x "\n", ## __VA_ARGS__ ) -#define ERR(x, ...) printf("ERROR: " x "\n", ## __VA_ARGS__ ) - #if defined __cplusplus #define LIBNFC_EXTERN_C extern "C" #else diff --git a/src/dev_acr122.c b/src/dev_acr122.c index 604d0b3..26a8d96 100644 --- a/src/dev_acr122.c +++ b/src/dev_acr122.c @@ -31,6 +31,7 @@ along with this program. If not, see #endif #include "defines.h" +#include "messages.h" #include "bitutils.h" // WINDOWS: #define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE SCARD_CTL_CODE(3500) diff --git a/src/dev_arygon.c b/src/dev_arygon.c index 1db1140..16c0091 100644 --- a/src/dev_arygon.c +++ b/src/dev_arygon.c @@ -19,8 +19,10 @@ along with this program. If not, see */ #include "dev_arygon.h" + #include "rs232.h" #include "bitutils.h" +#include "messages.h" #ifdef _WIN32 #define SERIAL_STRING "COM" diff --git a/src/dev_pn533.c b/src/dev_pn533.c index 851771c..add894e 100644 --- a/src/dev_pn533.c +++ b/src/dev_pn533.c @@ -21,14 +21,15 @@ along with this program. If not, see /* Thanks to d18c7db and Okko for example code */ - -#include "defines.h" +#include "dev_pn533.h" #include #include #include -#include "dev_pn533.h" + +#include "defines.h" #include "bitutils.h" +#include "messages.h" #define BUFFER_LENGTH 256 #define USB_TIMEOUT 30000 diff --git a/src/emulate.c b/src/emulate.c index bce6613..1b50c94 100644 --- a/src/emulate.c +++ b/src/emulate.c @@ -25,6 +25,7 @@ along with this program. If not, see #include #include "libnfc.h" +#include "messages.h" static byte_t abtRecv[MAX_FRAME_LEN]; static uint32_t uiRecvBits; diff --git a/src/libnfc.c b/src/libnfc.c index f491272..86101e5 100644 --- a/src/libnfc.c +++ b/src/libnfc.c @@ -27,6 +27,7 @@ along with this program. If not, see #include "devices.h" #include "bitutils.h" +#include "messages.h" // Registers and symbols masks used to covers parts within a register #define REG_CIU_TX_MODE 0x6302 diff --git a/src/list.c b/src/list.c index 31f725e..bd6e15c 100644 --- a/src/list.c +++ b/src/list.c @@ -25,6 +25,7 @@ along with this program. If not, see #include #include "libnfc.h" +#include "messages.h" static dev_info* pdi; static byte_t abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 }; diff --git a/src/messages.h b/src/messages.h new file mode 100644 index 0000000..ab38a4e --- /dev/null +++ b/src/messages.h @@ -0,0 +1,38 @@ +/* + +Public platform independent Near Field Communication (NFC) library +Copyright (C) 2009, Roel Verdult + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see + +*/ + +#ifndef _LIBNFC_MESSAGES_H_ +#define _LIBNFC_MESSAGES_H_ + +// #define DEBUG /* DEBUG flag can also be enabled using ./configure --enable-debug */ + +// Useful macros +#ifdef DEBUG +// #define DBG(x, args...) printf("DBG %s:%d: " x "\n", __FILE__, __LINE__,## args ) + #define DBG(x, ...) printf("DBG %s:%d: " x "\n", __FILE__, __LINE__, ## __VA_ARGS__ ) +#else + #define DBG(...) {} +#endif + +#define INFO(x, ...) printf("INFO: " x "\n", ## __VA_ARGS__ ) +#define WARN(x, ...) printf("WARNING: " x "\n", ## __VA_ARGS__ ) +#define ERR(x, ...) printf("ERROR: " x "\n", ## __VA_ARGS__ ) + +#endif // _LIBNFC_MESSAGES_H_ diff --git a/src/relay.c b/src/relay.c index 9f32a6f..2f7557a 100644 --- a/src/relay.c +++ b/src/relay.c @@ -24,6 +24,7 @@ along with this program. If not, see #include #include "libnfc.h" +#include "messages.h" static byte_t abtReaderRx[MAX_FRAME_LEN]; static byte_t abtReaderRxPar[MAX_FRAME_LEN]; diff --git a/src/rs232.c b/src/rs232.c index 57edcb5..abce517 100644 --- a/src/rs232.c +++ b/src/rs232.c @@ -26,6 +26,8 @@ available: http://www.teuniz.net/RS-232/index.html #include "rs232.h" +#include "messages.h" + // Test if we are dealing with unix operating systems #ifndef _WIN32