[rtems commit] mghttpd: Add RTEMS printer support

Sebastian Huber sebh at rtems.org
Mon Jun 6 11:17:04 UTC 2016


Module:    rtems
Branch:    master
Commit:    214156d98c3421a84fe8ad27ba8891651eea7291
Changeset: http://git.rtems.org/rtems/commit/?id=214156d98c3421a84fe8ad27ba8891651eea7291

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jun  3 14:54:05 2016 +0200

mghttpd: Add RTEMS printer support

---

 cpukit/include/rtems/print.h |  4 ++--
 cpukit/mghttpd/mongoose.c    | 12 ++++++++++++
 cpukit/mghttpd/mongoose.h    |  4 ++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/cpukit/include/rtems/print.h b/cpukit/include/rtems/print.h
index 5268e8c..91c4515 100644
--- a/cpukit/include/rtems/print.h
+++ b/cpukit/include/rtems/print.h
@@ -39,10 +39,10 @@ extern "C" {
  * Type definition for the printer structure used to access the kernel print
  * support.
  */
-typedef struct {
+typedef struct rtems_printer {
   void                *context;
   rtems_print_plugin_t printer;
-}rtems_printer;
+} rtems_printer;
 
 /**
  * @brief check if the printer is valid.
diff --git a/cpukit/mghttpd/mongoose.c b/cpukit/mghttpd/mongoose.c
index dd243d3..a89fc56 100644
--- a/cpukit/mghttpd/mongoose.c
+++ b/cpukit/mghttpd/mongoose.c
@@ -5519,3 +5519,15 @@ struct mg_context *mg_start(const struct mg_callbacks *callbacks,
 
   return ctx;
 }
+#ifdef __rtems__
+#include <rtems/print.h>
+
+static int mg_printer_plugin(void *context, const char *fmt, va_list ap) {
+  return mg_vprintf(context, fmt, ap);
+}
+
+void rtems_print_printer_mg_printf(rtems_printer *printer, struct mg_connection *conn) {
+  printer->context = conn;
+  printer->printer = mg_printer_plugin;
+}
+#endif /* __rtems__ */
diff --git a/cpukit/mghttpd/mongoose.h b/cpukit/mghttpd/mongoose.h
index ad7c40f..330ed67 100644
--- a/cpukit/mghttpd/mongoose.h
+++ b/cpukit/mghttpd/mongoose.h
@@ -256,6 +256,10 @@ enum {
 // Works exactly like mg_write(), but allows to do message formatting.
 int mg_printf(struct mg_connection *,
               PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
+#ifdef __rtems__
+struct rtems_printer;
+void rtems_print_printer_mg_printf(struct rtems_printer *, struct mg_connection *);
+#endif /* __rtems__ */
 
 
 // Send contents of the entire file together with HTTP headers.




More information about the vc mailing list