[Olsr-dev] [PATCH v1 045/115] txtinfo: move code from olsr_txtinfo into olsr_plugin

Ferry Huberts (spam-protected)
Wed Dec 2 21:28:18 CET 2015


From: Ferry Huberts <(spam-protected)>

To make it more compact

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/txtinfo/src/olsrd_plugin.c                     | 56 ++++++++++---
 .../src/{olsrd_txtinfo.h => olsrd_plugin.h}        |  0
 lib/txtinfo/src/olsrd_txtinfo.c                    | 98 ----------------------
 3 files changed, 44 insertions(+), 110 deletions(-)
 rename lib/txtinfo/src/{olsrd_txtinfo.h => olsrd_plugin.h} (100%)
 delete mode 100644 lib/txtinfo/src/olsrd_txtinfo.c

diff --git a/lib/txtinfo/src/olsrd_plugin.c b/lib/txtinfo/src/olsrd_plugin.c
index 0d7be62..6f8247c 100644
--- a/lib/txtinfo/src/olsrd_plugin.c
+++ b/lib/txtinfo/src/olsrd_plugin.c
@@ -42,24 +42,39 @@
  * Dynamic linked library for the olsr.org olsr daemon
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-
 #include "olsrd_plugin.h"
-#include "olsrd_txtinfo.h"
-#include "defs.h"
-#include "../../info/info_types.h"
+#include "../../info/olsrd_info.h"
+#include "txtinfo_printers.h"
 
-#define PLUGIN_NAME    "OLSRD txtinfo plugin"
+#define PLUGIN_NAME "TXTINFO"
+#define PLUGIN_TITLE    "OLSRD txtinfo plugin"
 #define PLUGIN_VERSION "0.1"
 #define PLUGIN_AUTHOR   "Lorenz Schori"
-#define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
+#define MOD_DESC PLUGIN_TITLE " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
 #define PLUGIN_INTERFACE_VERSION 5
 
+static printer_functions_t printer_functions = { //
+    //
+        .init = NULL, //
+        .is_command = &isCommand, //
+        .determine_mime_type = NULL, //
+        .output_start = NULL, //
+        .output_end = NULL, //
+        .neighbors = &ipc_print_neighbors, //
+        .links = &ipc_print_links, //
+        .routes = &ipc_print_routes, //
+        .topology = &ipc_print_topology, //
+        .hna = &ipc_print_hna, //
+        .mid = &ipc_print_mid, //
+        .gateways = &ipc_print_gateways, //
+        .sgw = &ipc_print_sgw, //
+        .version = &ipc_print_version, //
+        .olsrd_conf = &ipc_print_olsrd_conf, //
+        .interfaces = &ipc_print_interfaces, //
+        .config = NULL, //
+        .plugins = NULL //
+    };
+
 info_plugin_config_t info_plugin_config;
 bool vtime;
 
@@ -106,6 +121,23 @@ static void my_fini(void) {
   olsr_plugin_exit();
 }
 
+/**
+ *Do initialization here
+ *
+ *This function is called by the my_init
+ *function in uolsrd_plugin.c
+ */
+int olsrd_plugin_init(void) {
+  return info_plugin_init(PLUGIN_NAME, &printer_functions, &info_plugin_config);
+}
+
+/**
+ * destructor - called at unload
+ */
+void olsr_plugin_exit(void) {
+  info_plugin_exit();
+}
+
 int olsrd_plugin_interface_version(void) {
   return PLUGIN_INTERFACE_VERSION;
 }
diff --git a/lib/txtinfo/src/olsrd_txtinfo.h b/lib/txtinfo/src/olsrd_plugin.h
similarity index 100%
rename from lib/txtinfo/src/olsrd_txtinfo.h
rename to lib/txtinfo/src/olsrd_plugin.h
diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
deleted file mode 100644
index ebbf7a7..0000000
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * The olsr.org Optimized Link-State Routing daemon(olsrd)
- * Copyright (c) 2004
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in
- *   the documentation and/or other materials provided with the
- *   distribution.
- * * Neither the name of olsr.org, olsrd nor the names of its
- *   contributors may be used to endorse or promote products derived
- *   from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * Visit http://www.olsr.org for more information.
- *
- * If you find this software useful feel free to make a donation
- * to the project. For more information see the website or contact
- * the copyright holders.
- *
- */
-
-/*
- * Dynamic linked library for the olsr.org olsr daemon
- */
-
-#include "olsrd_txtinfo.h"
-#include "txtinfo_printers.h"
-#include "../../info/olsrd_info.h"
-
-#define PLUGIN_NAME "TXTINFO"
-
-static printer_functions_t printer_functions = { //
-    //
-        .init = NULL, //
-        .is_command = &isCommand, //
-        .determine_mime_type = NULL, //
-        .output_start = NULL, //
-        .output_end = NULL, //
-        .neighbors = &ipc_print_neighbors, //
-        .links = &ipc_print_links, //
-        .routes = &ipc_print_routes, //
-        .topology = &ipc_print_topology, //
-        .hna = &ipc_print_hna, //
-        .mid = &ipc_print_mid, //
-        .gateways = &ipc_print_gateways, //
-        .sgw = &ipc_print_sgw, //
-        .version = &ipc_print_version, //
-        .olsrd_conf = &ipc_print_olsrd_conf, //
-        .interfaces = &ipc_print_interfaces, //
-        .config = NULL, //
-        .plugins = NULL //
-    };
-
-/**
- *Do initialization here
- *
- *This function is called by the my_init
- *function in uolsrd_plugin.c
- */
-int olsrd_plugin_init(void) {
-  return info_plugin_init(PLUGIN_NAME, &printer_functions, &info_plugin_config);
-}
-
-/**
- * destructor - called at unload
- */
-void olsr_plugin_exit(void) {
-  info_plugin_exit();
-}
-
-/*
- * Local Variables:
- * mode: c
- * style: linux
- * c-basic-offset: 2
- * indent-tabs-mode: nil
- * End:
- */
-- 
2.5.0




More information about the Olsr-dev mailing list