[Olsr-dev] [PATCH v1 06/44] txtinfo: use a define for the plugin name

Ferry Huberts (spam-protected)
Fri Nov 27 10:42:59 CET 2015


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/txtinfo/src/olsrd_txtinfo.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
index 5c14389..69f099e 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ b/lib/txtinfo/src/olsrd_txtinfo.c
@@ -87,6 +87,9 @@
 #define close(x) closesocket(x)
 #endif /* _WIN32 */
 
+/* defines to make txtinfo and jsoninfo look alike */
+#define PLUGIN_NAME "TXTINFO"
+
 static int ipc_socket;
 
 /* IPC initialization function */
@@ -174,13 +177,13 @@ static int plugin_ipc_init(void) {
   /* Init ipc socket */
   if ((ipc_socket = socket(olsr_cnf->ip_version, SOCK_STREAM, 0)) == -1) {
 #ifndef NODEBUG
-    olsr_printf(1, "(TXTINFO) socket()=%s\n", strerror(errno));
+    olsr_printf(1, "("PLUGIN_NAME") socket()=%s\n", strerror(errno));
 #endif /* NODEBUG */
     return 0;
   } else {
     if (setsockopt(ipc_socket, SOL_SOCKET, SO_REUSEADDR, (char *) &yes, sizeof(yes)) < 0) {
 #ifndef NODEBUG
-      olsr_printf(1, "(TXTINFO) setsockopt()=%s\n", strerror(errno));
+      olsr_printf(1, "("PLUGIN_NAME") setsockopt()=%s\n", strerror(errno));
 #endif /* NODEBUG */
       return 0;
     }
@@ -223,7 +226,7 @@ static int plugin_ipc_init(void) {
     /* bind the socket to the port number */
     if (bind(ipc_socket, &sst.in, addrlen) == -1) {
 #ifndef NODEBUG
-      olsr_printf(1, "(TXTINFO) bind()=%s\n", strerror(errno));
+      olsr_printf(1, "("PLUGIN_NAME") bind()=%s\n", strerror(errno));
 #endif /* NODEBUG */
       return 0;
     }
@@ -231,7 +234,7 @@ static int plugin_ipc_init(void) {
     /* show that we are willing to listen */
     if (listen(ipc_socket, 1) == -1) {
 #ifndef NODEBUG
-      olsr_printf(1, "(TXTINFO) listen()=%s\n", strerror(errno));
+      olsr_printf(1, "("PLUGIN_NAME") listen()=%s\n", strerror(errno));
 #endif /* NODEBUG */
       return 0;
     }
@@ -240,7 +243,7 @@ static int plugin_ipc_init(void) {
     add_olsr_socket(ipc_socket, &ipc_action, NULL, NULL, SP_PR_READ);
 
 #ifndef NODEBUG
-    olsr_printf(2, "(TXTINFO) listening on port %d\n", ipc_port);
+    olsr_printf(2, "("PLUGIN_NAME") listening on port %d\n", ipc_port);
 #endif /* NODEBUG */
   }
   return 1;
@@ -263,7 +266,7 @@ static void ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int
 
   if ((ipc_connection = accept(fd, &pin.in, &addrlen)) == -1) {
 #ifndef NODEBUG
-    olsr_printf(1, "(TXTINFO) accept()=%s\n", strerror(errno));
+    olsr_printf(1, "("PLUGIN_NAME") accept()=%s\n", strerror(errno));
 #endif /* NODEBUG */
     return;
   }
@@ -276,7 +279,7 @@ static void ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int
 #ifdef TXTINFO_ALLOW_LOCALHOST
       if (ntohl(pin.in4.sin_addr.s_addr) != INADDR_LOOPBACK) {
 #endif /* TXTINFO_ALLOW_LOCALHOST */
-      olsr_printf(1, "(TXTINFO) From host(%s) not allowed!\n", addr);
+      olsr_printf(1, "("PLUGIN_NAME") From host(%s) not allowed!\n", addr);
       close(ipc_connection);
       return;
 #ifdef TXTINFO_ALLOW_LOCALHOST
@@ -288,14 +291,14 @@ static void ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int
       addr[0] = '\0';
     /* Use in6addr_any (::) in olsr.conf to allow anybody. */
     if (!ip6equal(&in6addr_any, &txtinfo_accept_ip.v6) && !ip6equal(&pin.in6.sin6_addr, &txtinfo_accept_ip.v6)) {
-      olsr_printf(1, "(TXTINFO) From host(%s) not allowed!\n", addr);
+      olsr_printf(1, "("PLUGIN_NAME") From host(%s) not allowed!\n", addr);
       close(ipc_connection);
       return;
     }
   }
 
 #ifndef NODEBUG
-  olsr_printf(2, "(TXTINFO) Connect from %s\n", addr);
+  olsr_printf(2, "("PLUGIN_NAME") Connect from %s\n", addr);
 #endif /* NODEBUG */
 
   /* purge read buffer to prevent blocking on linux */
-- 
2.5.0




More information about the Olsr-dev mailing list