From dba06a555e77310de67aa0c309c37b441c92c38d Mon Sep 17 00:00:00 2001
From: Romuald Conty <romuald@libnfc.org>
Date: Sat, 5 Mar 2011 08:53:46 +0000
Subject: [PATCH] remove nfc-message.h usage from examples.

---
 examples/doc/quick_start_example1.c |  3 ++-
 examples/nfc-anticol.c              |  1 -
 examples/nfc-emulate-forum-tag4.c   |  1 -
 examples/nfc-emulate-tag.c          |  1 -
 examples/nfc-emulate-uid.c          |  1 -
 examples/nfc-list.c                 |  2 +-
 examples/nfc-mfultralight.c         |  1 -
 examples/nfc-poll.c                 |  2 +-
 examples/nfc-relay-picc.c           |  2 --
 examples/nfc-relay.c                |  1 -
 examples/nfc-utils.h                | 38 +++++++++++++++++++++++++++++
 examples/pn53x-diagnose.c           |  1 -
 examples/pn53x-sam.c                |  3 +--
 examples/pn53x-tamashell.c          |  1 -
 14 files changed, 43 insertions(+), 15 deletions(-)

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 <stdlib.h>
 #include <nfc/nfc.h>
-#include <nfc/nfc-messages.h>
+
+#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 <nfc/nfc.h>
 
-#include <nfc/nfc-messages.h>
 #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 <nfc/nfc.h>
 
-#include <nfc/nfc-messages.h>
 #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 <nfc/nfc.h>
 
-#include <nfc/nfc-messages.h>
 #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 <nfc/nfc.h>
 
-#include <nfc/nfc-messages.h>
 #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 <string.h>
 
 #include <nfc/nfc.h>
-#include <nfc/nfc-messages.h>
+
 #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 <ctype.h>
 
 #include <nfc/nfc.h>
-#include <nfc/nfc-messages.h>
 
 #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 <nfc/nfc.h>
 #include <nfc/nfc-types.h>
-#include <nfc/nfc-messages.h>
+
 #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 <stdint.h>
 #include <string.h>
 #include <signal.h>
-//#include <stddef.h>
 
 #include <nfc/nfc.h>
 
-#include <nfc/nfc-messages.h>
 #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 <nfc/nfc.h>
 
-#include <nfc/nfc-messages.h>
 #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 <stdlib.h>
 #  include <string.h>
 
+/**
+ * @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 <string.h>
 
 #include <nfc/nfc.h>
-#include <nfc/nfc-messages.h>
 
 #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 <nfc/nfc.h>
-#include <nfc/nfc-messages.h>
-#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 <unistd.h>
 
 #include <nfc/nfc.h>
-#include <nfc/nfc-messages.h>
 
 #include "nfc-utils.h"