[Olsr-dev] [PATCH v1 018/115] jsoninfo: move determining the action into a separate function
Ferry Huberts
(spam-protected)
Wed Dec 2 21:27:51 CET 2015
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
lib/jsoninfo/src/olsrd_jsoninfo.c | 101 ++++++++++++++++++++------------------
1 file changed, 52 insertions(+), 49 deletions(-)
diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.c b/lib/jsoninfo/src/olsrd_jsoninfo.c
index e6caf93..5206aad 100644
--- a/lib/jsoninfo/src/olsrd_jsoninfo.c
+++ b/lib/jsoninfo/src/olsrd_jsoninfo.c
@@ -145,6 +145,57 @@ static int outbuffer_count = 0;
static struct timer_entry *writetimer_entry;
static struct timeval start_time;
+static void determine_action(unsigned int *send_what, char *requ) {
+ if (strstr(requ, "/olsrd.conf"))
+ *send_what |= SIW_OLSRD_CONF;
+ else if (strstr(requ, "/all"))
+ *send_what = SIW_ALL;
+ else {
+ // these are the two overarching categories
+ if (strstr(requ, "/runtime"))
+ *send_what |= SIW_RUNTIME_ALL;
+ if (strstr(requ, "/startup"))
+ *send_what |= SIW_STARTUP_ALL;
+
+ // these are the individual sections
+ if (strstr(requ, "/neighbors"))
+ *send_what |= SIW_NEIGHBORS;
+ if (strstr(requ, "/links"))
+ *send_what |= SIW_LINKS;
+ if (strstr(requ, "/routes"))
+ *send_what |= SIW_ROUTES;
+ if (strstr(requ, "/hna"))
+ *send_what |= SIW_HNA;
+ if (strstr(requ, "/mid"))
+ *send_what |= SIW_MID;
+ if (strstr(requ, "/topology"))
+ *send_what |= SIW_TOPOLOGY;
+ if (strstr(requ, "/gateways"))
+ *send_what |= SIW_GATEWAYS;
+ if (strstr(requ, "/interfaces"))
+ *send_what |= SIW_INTERFACES;
+ if (strstr(requ, "/2hop"))
+ *send_what |= SIW_2HOP;
+ if (strstr(requ, "/sgw"))
+ *send_what |= SIW_SGW;
+
+ // specials
+ if (strstr(requ, "/version"))
+ *send_what |= SIW_VERSION;
+ if (strstr(requ, "/config"))
+ *send_what |= SIW_CONFIG;
+ if (strstr(requ, "/plugins"))
+ *send_what |= SIW_PLUGINS;
+
+ /* To print out neighbours only on the Freifunk Status
+ * page the normal output is somewhat lengthy. The
+ * header parsing is sufficient for standard wget.
+ */
+ if (strstr(requ, "/neighbours"))
+ *send_what = SIW_NEIGHBORS | SIW_LINKS;
+ }
+}
+
/**
*Do initialization here
*
@@ -323,55 +374,7 @@ static void ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int
if (0 < s) {
requ[s] = 0;
- /* print out the requested tables */
- if (strstr(requ, "/olsrd.conf"))
- send_what |= SIW_OLSRD_CONF;
- else if (strstr(requ, "/all"))
- send_what = SIW_ALL;
- else {
- // these are the two overarching categories
- if (strstr(requ, "/runtime"))
- send_what |= SIW_RUNTIME_ALL;
- if (strstr(requ, "/startup"))
- send_what |= SIW_STARTUP_ALL;
-
- // these are the individual sections
- if (strstr(requ, "/neighbors"))
- send_what |= SIW_NEIGHBORS;
- if (strstr(requ, "/links"))
- send_what |= SIW_LINKS;
- if (strstr(requ, "/routes"))
- send_what |= SIW_ROUTES;
- if (strstr(requ, "/hna"))
- send_what |= SIW_HNA;
- if (strstr(requ, "/mid"))
- send_what |= SIW_MID;
- if (strstr(requ, "/topology"))
- send_what |= SIW_TOPOLOGY;
- if (strstr(requ, "/gateways"))
- send_what |= SIW_GATEWAYS;
- if (strstr(requ, "/interfaces"))
- send_what |= SIW_INTERFACES;
- if (strstr(requ, "/2hop"))
- send_what |= SIW_2HOP;
- if (strstr(requ, "/sgw"))
- send_what |= SIW_SGW;
-
- // specials
- if (strstr(requ, "/version"))
- send_what |= SIW_VERSION;
- if (strstr(requ, "/config"))
- send_what |= SIW_CONFIG;
- if (strstr(requ, "/plugins"))
- send_what |= SIW_PLUGINS;
-
- /* To print out neighbours only on the Freifunk Status
- * page the normal output is somewhat lengthy. The
- * header parsing is sufficient for standard wget.
- */
- if (strstr(requ, "/neighbours"))
- send_what = SIW_NEIGHBORS | SIW_LINKS;
- }
+ determine_action(&send_what, requ);
}
if (!send_what)
--
2.5.0
More information about the Olsr-dev
mailing list