summaryrefslogtreecommitdiff
path: root/http/shttpd_ext.c
diff options
context:
space:
mode:
Diffstat (limited to 'http/shttpd_ext.c')
-rw-r--r--http/shttpd_ext.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/http/shttpd_ext.c b/http/shttpd_ext.c
new file mode 100644
index 0000000..901f3f1
--- /dev/null
+++ b/http/shttpd_ext.c
@@ -0,0 +1,64 @@
+/* SHTTPD Extensions
+ *
+ * $Id$
+ */
+
+
+#if defined(USE_SIMPLE_HTTPD)
+
+#include <rtems.h>
+#include <shttpd/shttpd.h>
+#include <rtems/cpuuse.h>
+#include <rtems/stackchk.h>
+
+#include <stdio.h>
+
+#define START_HTML_BODY \
+ "HTTP/1.1 200 OK\r\n" \
+ "Content-Type: text/html\r\n\r\n" \
+ "<html><body>\r\n"
+
+#define END_HTML_BODY \
+
+void example_shttpd_callback(struct shttpd_arg *arg)
+{
+ const char *query;
+
+ query = shttpd_get_env(arg, "QUERY_STRING" );
+ if ( !query )
+ query = "";
+ /* fprintf( stderr, "RTEMS Request -%s-\n", query ); */
+
+ if ( !strcmp( query, "cpuuse_report" ) ) {
+ rtems_cpu_usage_report_with_handler( arg, shttpd_printf );
+ } else if ( !strcmp( query, "cpuuse_reset" ) ) {
+ rtems_cpu_usage_reset();
+ shttpd_printf(
+ arg,
+ START_HTML_BODY
+ " <p><big>CPU Usage data reset -- return to the previous page</big></p>"
+ END_HTML_BODY
+ );
+ } else if ( !strcmp( query, "stackuse_report" ) ) {
+ rtems_stack_checker_report_usage_with_handler( arg, shttpd_printf );
+ } else {
+ shttpd_printf(
+ arg,
+ START_HTML_BODY
+ " <h2>Unknown Request</h2>"
+ " <h3>URI: %s</br>"
+ " Arguments: %s</h3>"
+ END_HTML_BODY,
+ shttpd_get_env(arg, "REQUEST_URI"),
+ query
+ );
+ }
+ arg->flags |= SHTTPD_END_OF_OUTPUT;
+}
+
+void example_shttpd_addpages(struct shttpd_ctx *ctx)
+{
+ shttpd_register_uri( ctx, "/queries*", example_shttpd_callback, NULL );
+}
+
+#endif