info: simplify use of the functions table further
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 3 Dec 2015 11:32:20 +0000 (12:32 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 3 Dec 2015 11:49:53 +0000 (12:49 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/info/olsrd_info.c

index 0859267..ddcbf58 100644 (file)
@@ -81,67 +81,67 @@ static unsigned int determine_action(char *requ) {
   if (!functions->is_command)
     return 0;
 
   if (!functions->is_command)
     return 0;
 
-  if ((*functions->is_command)(requ, SIW_OLSRD_CONF))
+  if (functions->is_command(requ, SIW_OLSRD_CONF))
     return SIW_OLSRD_CONF;
 
     return SIW_OLSRD_CONF;
 
-  if ((*functions->is_command)(requ, SIW_ALL))
+  if (functions->is_command(requ, SIW_ALL))
     return SIW_ALL;
 
   // these are the two overarching categories
     return SIW_ALL;
 
   // these are the two overarching categories
-  if ((*functions->is_command)(requ, SIW_RUNTIME_ALL))
+  if (functions->is_command(requ, SIW_RUNTIME_ALL))
     return SIW_RUNTIME_ALL;
 
     return SIW_RUNTIME_ALL;
 
-  if ((*functions->is_command)(requ, SIW_STARTUP_ALL))
+  if (functions->is_command(requ, SIW_STARTUP_ALL))
     return SIW_STARTUP_ALL;
 
   // these are the individual sections
 
     return SIW_STARTUP_ALL;
 
   // these are the individual sections
 
-  if ((*functions->is_command)(requ, SIW_NEIGHBORS))
+  if (functions->is_command(requ, SIW_NEIGHBORS))
     return SIW_NEIGHBORS;
 
     return SIW_NEIGHBORS;
 
-  if ((*functions->is_command)(requ, SIW_LINKS))
+  if (functions->is_command(requ, SIW_LINKS))
     return SIW_LINKS;
 
     return SIW_LINKS;
 
-  if ((*functions->is_command)(requ, SIW_ROUTES))
+  if (functions->is_command(requ, SIW_ROUTES))
     return SIW_ROUTES;
 
     return SIW_ROUTES;
 
-  if ((*functions->is_command)(requ, SIW_HNA))
+  if (functions->is_command(requ, SIW_HNA))
     return SIW_HNA;
 
     return SIW_HNA;
 
-  if ((*functions->is_command)(requ, SIW_MID))
+  if (functions->is_command(requ, SIW_MID))
     return SIW_MID;
 
     return SIW_MID;
 
-  if ((*functions->is_command)(requ, SIW_TOPOLOGY))
+  if (functions->is_command(requ, SIW_TOPOLOGY))
     return SIW_TOPOLOGY;
 
     return SIW_TOPOLOGY;
 
-  if ((*functions->is_command)(requ, SIW_GATEWAYS))
+  if (functions->is_command(requ, SIW_GATEWAYS))
     return SIW_GATEWAYS;
 
     return SIW_GATEWAYS;
 
-  if ((*functions->is_command)(requ, SIW_INTERFACES))
+  if (functions->is_command(requ, SIW_INTERFACES))
     return SIW_INTERFACES;
 
     return SIW_INTERFACES;
 
-  if ((*functions->is_command)(requ, SIW_2HOP))
+  if (functions->is_command(requ, SIW_2HOP))
     return SIW_2HOP;
 
     return SIW_2HOP;
 
-  if ((*functions->is_command)(requ, SIW_SGW))
+  if (functions->is_command(requ, SIW_SGW))
     return SIW_SGW;
 
   // specials
 
     return SIW_SGW;
 
   // specials
 
-  if ((*functions->is_command)(requ, SIW_VERSION))
+  if (functions->is_command(requ, SIW_VERSION))
     return SIW_VERSION;
 
     return SIW_VERSION;
 
-  if ((*functions->is_command)(requ, SIW_CONFIG))
+  if (functions->is_command(requ, SIW_CONFIG))
     return SIW_CONFIG;
 
     return SIW_CONFIG;
 
-  if ((*functions->is_command)(requ, SIW_PLUGINS))
+  if (functions->is_command(requ, SIW_PLUGINS))
     return 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.
    */
     return 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 ((*functions->is_command)(requ, SIW_NEIGHBORS_FREIFUNK))
+  if (functions->is_command(requ, SIW_NEIGHBORS_FREIFUNK))
     return SIW_NEIGHBORS_FREIFUNK;
 
   return 0;
     return SIW_NEIGHBORS_FREIFUNK;
 
   return 0;
@@ -212,7 +212,7 @@ static void write_data(void *foo __attribute__ ((unused))) {
 static void send_info(unsigned int send_what, int the_socket) {
   struct autobuf abuf;
 
 static void send_info(unsigned int send_what, int the_socket) {
   struct autobuf abuf;
 
-  const char *content_type = functions->determine_mime_type ? (*functions->determine_mime_type)(send_what) : "text/plain; charset=utf-8";
+  const char *content_type = functions->determine_mime_type ? functions->determine_mime_type(send_what) : "text/plain; charset=utf-8";
   int contentLengthIndex = 0;
   int headerLength = 0;
 
   int contentLengthIndex = 0;
   int headerLength = 0;
 
@@ -226,41 +226,41 @@ static void send_info(unsigned int send_what, int the_socket) {
   // only add if normal format
   if (send_what & SIW_ALL) {
     if (functions->output_start)
   // only add if normal format
   if (send_what & SIW_ALL) {
     if (functions->output_start)
-      (*functions->output_start)(&abuf);
+      functions->output_start(&abuf);
 
     if ((send_what & SIW_NEIGHBORS) && functions->neighbors)
 
     if ((send_what & SIW_NEIGHBORS) && functions->neighbors)
-      (*functions->neighbors)(&abuf);
+      functions->neighbors(&abuf);
     if ((send_what & SIW_LINKS) && functions->links)
     if ((send_what & SIW_LINKS) && functions->links)
-      (*functions->links)(&abuf);
+      functions->links(&abuf);
     if ((send_what & SIW_ROUTES) && functions->routes)
     if ((send_what & SIW_ROUTES) && functions->routes)
-      (*functions->routes)(&abuf);
+      functions->routes(&abuf);
     if ((send_what & SIW_HNA) && functions->hna)
     if ((send_what & SIW_HNA) && functions->hna)
-      (*functions->hna)(&abuf);
+      functions->hna(&abuf);
     if ((send_what & SIW_MID) && functions->mid)
     if ((send_what & SIW_MID) && functions->mid)
-      (*functions->mid)(&abuf);
+      functions->mid(&abuf);
     if ((send_what & SIW_TOPOLOGY) && functions->topology)
     if ((send_what & SIW_TOPOLOGY) && functions->topology)
-      (*functions->topology)(&abuf);
+      functions->topology(&abuf);
     if ((send_what & SIW_GATEWAYS) && functions->gateways)
     if ((send_what & SIW_GATEWAYS) && functions->gateways)
-      (*functions->gateways)(&abuf);
+      functions->gateways(&abuf);
     if ((send_what & SIW_INTERFACES) && functions->interfaces)
     if ((send_what & SIW_INTERFACES) && functions->interfaces)
-      (*functions->interfaces)(&abuf);
+      functions->interfaces(&abuf);
     if ((send_what & SIW_2HOP) && functions->twohop)
     if ((send_what & SIW_2HOP) && functions->twohop)
-      (*functions->twohop)(&abuf);
+      functions->twohop(&abuf);
     if ((send_what & SIW_SGW) && functions->sgw)
     if ((send_what & SIW_SGW) && functions->sgw)
-      (*functions->sgw)(&abuf);
+      functions->sgw(&abuf);
 
     if ((send_what & SIW_VERSION) && functions->version)
 
     if ((send_what & SIW_VERSION) && functions->version)
-      (*functions->version)(&abuf);
+      functions->version(&abuf);
     if ((send_what & SIW_CONFIG) && functions->config)
     if ((send_what & SIW_CONFIG) && functions->config)
-      (*functions->config)(&abuf);
+      functions->config(&abuf);
     if ((send_what & SIW_PLUGINS) && functions->plugins)
     if ((send_what & SIW_PLUGINS) && functions->plugins)
-      (*functions->plugins)(&abuf);
+      functions->plugins(&abuf);
 
     if (functions->output_end)
 
     if (functions->output_end)
-      (*functions->output_end)(&abuf);
+      functions->output_end(&abuf);
   } else if ((send_what & SIW_OLSRD_CONF) && functions->olsrd_conf) {
     /* this outputs the olsrd.conf text directly, not normal format */
   } else if ((send_what & SIW_OLSRD_CONF) && functions->olsrd_conf) {
     /* this outputs the olsrd.conf text directly, not normal format */
-    (*functions->olsrd_conf)(&abuf);
+    functions->olsrd_conf(&abuf);
   }
 
   if (config->http_headers) {
   }
 
   if (config->http_headers) {
@@ -475,7 +475,7 @@ int info_plugin_init(const char * plugin_name, info_plugin_functions_t *plugin_f
   ipc_socket = -1;
 
   if (functions->init) {
   ipc_socket = -1;
 
   if (functions->init) {
-    (*functions->init)(name);
+    functions->init(name);
   }
 
   plugin_ipc_init();
   }
 
   plugin_ipc_init();