[Olsr-dev] [PATCH v1 030/115] txtinfo: determine the mime type via the functions table

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


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/info/info_types.h           | 2 ++
 lib/txtinfo/src/olsrd_txtinfo.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/info/info_types.h b/lib/info/info_types.h
index bd5905f..7b51b48 100644
--- a/lib/info/info_types.h
+++ b/lib/info/info_types.h
@@ -71,10 +71,12 @@
 /* this data is not normal format but olsrd.conf format */
 #define SIW_OLSRD_CONF 0x2000
 
+typedef const char * (*mime_type)(unsigned int send_what);
 typedef void (*printer_neighbors)(struct autobuf *abuf, bool list_2hop);
 typedef void (*printer_generic)(struct autobuf *abuf);
 
 typedef struct {
+    mime_type determine_mime_type;
     printer_neighbors neighbors;
     printer_generic links;
     printer_generic routes;
diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
index e4070fd..74a9379 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ b/lib/txtinfo/src/olsrd_txtinfo.c
@@ -86,6 +86,7 @@ static struct timer_entry *writetimer_entry;
 
 static printer_functions_t printer_functions = { //
     //
+        .determine_mime_type = NULL, //
         .neighbors = &ipc_print_neighbors, //
         .links = &ipc_print_links, //
         .routes = &ipc_print_routes, //
@@ -395,7 +396,7 @@ static void info_write_data(void *foo __attribute__ ((unused))) {
 static void send_info(unsigned int send_what, int the_socket) {
   struct autobuf abuf;
 
-  const char *content_type = "text/plain; charset=utf-8";
+  const char *content_type = (printer_functions.determine_mime_type) ? (*printer_functions.determine_mime_type)(send_what) : "text/plain; charset=utf-8";
   int contentLengthPlaceholderStart = 0;
   int headerLength = 0;
 
-- 
2.5.0




More information about the Olsr-dev mailing list