[Olsr-dev] [PATCH v1 046/115] jsoninfo: move code from olsr_jsoninfo into olsr_plugin
Ferry Huberts
(spam-protected)
Wed Dec 2 21:28:19 CET 2015
From: Ferry Huberts <(spam-protected)>
To make it more compact
Signed-off-by: Ferry Huberts <(spam-protected)>
---
lib/jsoninfo/src/olsrd_jsoninfo.c | 98 ----------------------
lib/jsoninfo/src/olsrd_plugin.c | 57 ++++++++++---
.../src/{olsrd_jsoninfo.h => olsrd_plugin.h} | 0
3 files changed, 45 insertions(+), 110 deletions(-)
delete mode 100644 lib/jsoninfo/src/olsrd_jsoninfo.c
rename lib/jsoninfo/src/{olsrd_jsoninfo.h => olsrd_plugin.h} (100%)
diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.c b/lib/jsoninfo/src/olsrd_jsoninfo.c
deleted file mode 100644
index f0acfff..0000000
--- a/lib/jsoninfo/src/olsrd_jsoninfo.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_jsoninfo.h"
-#include "jsoninfo_printers.h"
-#include "../../info/olsrd_info.h"
-
-#define PLUGIN_NAME "JSONINFO"
-
-static printer_functions_t printer_functions = { //
- //
- .init = &plugin_init, //
- .is_command = &isCommand, //
- .determine_mime_type = &determine_mime_type, //
- .output_start = &output_start, //
- .output_end = &output_end, //
- .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 = &ipc_print_config, //
- .plugins = &ipc_print_plugins //
- };
-
-/**
- *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:
- */
diff --git a/lib/jsoninfo/src/olsrd_plugin.c b/lib/jsoninfo/src/olsrd_plugin.c
index 7794a0c..fffdfe2 100644
--- a/lib/jsoninfo/src/olsrd_plugin.c
+++ b/lib/jsoninfo/src/olsrd_plugin.c
@@ -42,24 +42,40 @@
* 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_jsoninfo.h"
-#include "defs.h"
-#include "../../info/info_types.h"
+#include "../../info/olsrd_info.h"
+#include "jsoninfo_printers.h"
-#define PLUGIN_NAME "OLSRD jsoninfo plugin"
+#define PLUGIN_NAME "JSONINFO"
+#define PLUGIN_TITLE "OLSRD jsoninfo plugin"
#define PLUGIN_VERSION "0.0"
#define PLUGIN_AUTHOR "Hans-Christoph Steiner"
-#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 = &plugin_init, //
+ .is_command = &isCommand, //
+ .determine_mime_type = &determine_mime_type, //
+ .output_start = &output_start, //
+ .output_end = &output_end, //
+ .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 = &ipc_print_config, //
+ .plugins = &ipc_print_plugins //
+ };
+
+
info_plugin_config_t info_plugin_config;
char uuidfile[FILENAME_MAX];
@@ -106,6 +122,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/jsoninfo/src/olsrd_jsoninfo.h b/lib/jsoninfo/src/olsrd_plugin.h
similarity index 100%
rename from lib/jsoninfo/src/olsrd_jsoninfo.h
rename to lib/jsoninfo/src/olsrd_plugin.h
--
2.5.0
More information about the Olsr-dev
mailing list