diff --git a/examples/doc/quick_start_example1.c b/examples/doc/quick_start_example1.c index dc328b0..51dbf6f 100644 --- a/examples/doc/quick_start_example1.c +++ b/examples/doc/quick_start_example1.c @@ -4,7 +4,8 @@ #include #include -#include + +#include "nfc-utils.h" int main (int argc, const char *argv[]) diff --git a/examples/nfc-anticol.c b/examples/nfc-anticol.c index b6b2f6a..5b2769e 100644 --- a/examples/nfc-anticol.c +++ b/examples/nfc-anticol.c @@ -45,7 +45,6 @@ #include -#include #include "nfc-utils.h" #define SAK_FLAG_ATS_SUPPORTED 0x20 diff --git a/examples/nfc-emulate-forum-tag4.c b/examples/nfc-emulate-forum-tag4.c index b2b5235..e8368da 100644 --- a/examples/nfc-emulate-forum-tag4.c +++ b/examples/nfc-emulate-forum-tag4.c @@ -62,7 +62,6 @@ #include -#include #include "nfc-utils.h" #define MAX_FRAME_LEN 264 diff --git a/examples/nfc-emulate-tag.c b/examples/nfc-emulate-tag.c index bf19e81..6efe11d 100644 --- a/examples/nfc-emulate-tag.c +++ b/examples/nfc-emulate-tag.c @@ -49,7 +49,6 @@ #include -#include #include "nfc-utils.h" #define MAX_FRAME_LEN (264) diff --git a/examples/nfc-emulate-uid.c b/examples/nfc-emulate-uid.c index faa15c4..52df6c1 100644 --- a/examples/nfc-emulate-uid.c +++ b/examples/nfc-emulate-uid.c @@ -52,7 +52,6 @@ #include -#include #include "nfc-utils.h" #define MAX_FRAME_LEN 264 diff --git a/examples/nfc-list.c b/examples/nfc-list.c index b557179..79c90ba 100644 --- a/examples/nfc-list.c +++ b/examples/nfc-list.c @@ -51,7 +51,7 @@ #include #include -#include + #include "nfc-utils.h" #define MAX_DEVICE_COUNT 16 diff --git a/examples/nfc-mfultralight.c b/examples/nfc-mfultralight.c index 429cea3..733fcbe 100644 --- a/examples/nfc-mfultralight.c +++ b/examples/nfc-mfultralight.c @@ -47,7 +47,6 @@ #include #include -#include #include "mifare.h" diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 2edacb3..5aeb72f 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -46,7 +46,7 @@ #include #include -#include + #include "nfc-utils.h" #define MAX_DEVICE_COUNT 16 diff --git a/examples/nfc-relay-picc.c b/examples/nfc-relay-picc.c index f5a4ee7..b51ab81 100644 --- a/examples/nfc-relay-picc.c +++ b/examples/nfc-relay-picc.c @@ -47,11 +47,9 @@ #include #include #include -//#include #include -#include #include "nfc-utils.h" #ifndef _WIN32 diff --git a/examples/nfc-relay.c b/examples/nfc-relay.c index 4b36546..a9b5baa 100644 --- a/examples/nfc-relay.c +++ b/examples/nfc-relay.c @@ -45,7 +45,6 @@ #include -#include #include "nfc-utils.h" #define MAX_FRAME_LEN 264 diff --git a/examples/nfc-utils.h b/examples/nfc-utils.h index bfced61..8093ab1 100644 --- a/examples/nfc-utils.h +++ b/examples/nfc-utils.h @@ -39,6 +39,44 @@ # include # include +/** + * @macro DBG + * @brief Print a message of standard output only in DEBUG mode + */ +#ifdef DEBUG +// #define DBG(x, args...) printf("DBG %s:%d: " x "\n", __FILE__, __LINE__,## args ) +# define DBG(...) do { \ + warnx ("DBG %s:%d", __FILE__, __LINE__); \ + warnx (" " __VA_ARGS__ ); \ + } while (0) +#else +# define DBG(...) {} +#endif + +/** + * @macro WARN + * @brief Print a warn message + */ +# define WARN(...) do { \ + warnx ("WARNING %s:%d", __FILE__, __LINE__); \ + warnx (" " __VA_ARGS__ ); \ + } while (0) +#else +# define WARN(...) warnx ("WARNING: " __VA_ARGS__ ) +#endif + +/** + * @macro ERR + * @brief Print a error message + */ +# define ERR(...) do { \ + warnx ("ERROR %s:%d", __FILE__, __LINE__); \ + warnx (" " __VA_ARGS__ ); \ + } while (0) +#else +# define ERR(...) warnx ("ERROR: " __VA_ARGS__ ) +#endif + byte_t oddparity (const byte_t bt); void oddparity_byte_ts (const byte_t * pbtData, const size_t szLen, byte_t * pbtPar); diff --git a/examples/pn53x-diagnose.c b/examples/pn53x-diagnose.c index 50d9ea6..b1c420d 100644 --- a/examples/pn53x-diagnose.c +++ b/examples/pn53x-diagnose.c @@ -36,7 +36,6 @@ #include #include -#include #include "nfc-utils.h" #include "chips/pn53x.h" diff --git a/examples/pn53x-sam.c b/examples/pn53x-sam.c index f82352a..91eabee 100644 --- a/examples/pn53x-sam.c +++ b/examples/pn53x-sam.c @@ -54,9 +54,8 @@ #endif #include -#include -#include "nfc-utils.h" +#include "nfc-utils.h" #include "chips/pn53x.h" #define MAX_FRAME_LEN 264 diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index 5e23c99..3ea7e78 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -50,7 +50,6 @@ #include #include -#include #include "nfc-utils.h"