source: network-demos/http/shttpd_ext.c @ 81f6c2e

4.11network-demos-4-10-branch
Last change on this file since 81f6c2e was 0fe6b0d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/09 at 14:31:53

2009-11-23 Joel Sherrill <joel.sherrill@…>

  • Makefile, goahead_index.html, init.c, shttpd_ext.c, shttpd_index.html: Add Mongoose HTTPD support.
  • mongoose_ext.c, mongoose_index.html: New files.
  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[8c6b033]1/*  SHTTPD Extensions
2 *
3 *  $Id$
4 */
5
6
7#if defined(USE_SIMPLE_HTTPD)
8
9#include <rtems.h>
10#include <shttpd/shttpd.h>
11#include <rtems/cpuuse.h>
12#include <rtems/stackchk.h>
13
14#include <stdio.h>
15
16#define START_HTML_BODY \
17      "HTTP/1.1 200 OK\r\n" \
18      "Content-Type: text/html\r\n\r\n" \
19      "<html><body>\r\n"
20
21#define END_HTML_BODY \
22
23void example_shttpd_callback(struct shttpd_arg *arg)
24{
25  const char *query;
26
27  query = shttpd_get_env(arg, "QUERY_STRING" );
28  if ( !query )
29    query = "";
30  /* fprintf( stderr, "RTEMS Request -%s-\n", query ); */
31
32  if ( !strcmp( query, "cpuuse_report" ) ) {
[0fe6b0d]33
34    shttpd_printf( arg, "<pre>" );
[b80aaa9]35    rtems_cpu_usage_report_with_plugin(
36      arg,
37      (rtems_printk_plugin_t) shttpd_printf
38    );
[0fe6b0d]39    shttpd_printf( arg, "</pre>" );
[8c6b033]40  } else if ( !strcmp( query, "cpuuse_reset" ) ) {
41    rtems_cpu_usage_reset();
42    shttpd_printf(
43      arg,
44      START_HTML_BODY
45      " <p><big>CPU Usage data reset -- return to the previous page</big></p>"
46      END_HTML_BODY
47    );
48  } else if ( !strcmp( query, "stackuse_report" ) ) {
[0fe6b0d]49    shttpd_printf( arg, "<pre>" );
[b80aaa9]50    rtems_stack_checker_report_usage_with_plugin(
51      arg,
52      (rtems_printk_plugin_t) shttpd_printf
53    );
[0fe6b0d]54    shttpd_printf( arg, "</pre>" );
[8c6b033]55  } else {
56    shttpd_printf(
57      arg,
58      START_HTML_BODY
59      " <h2>Unknown Request</h2>"
60      " <h3>URI: %s</br>"
61      "  Arguments: %s</h3>"
62      END_HTML_BODY,
63      shttpd_get_env(arg, "REQUEST_URI"),
64      query
65    );
66  }
67  arg->flags |= SHTTPD_END_OF_OUTPUT;
68}
69
70void example_shttpd_addpages(struct shttpd_ctx *ctx)
71{
72  shttpd_register_uri( ctx, "/queries*", example_shttpd_callback, NULL );
73}
74
75#endif
Note: See TracBrowser for help on using the repository browser.