source: network-demos/http/shttpd_ext.c @ af6a124

4.11
Last change on this file since af6a124 was af6a124, checked in by Joel Sherrill <joel.sherrill@…>, on 05/15/12 at 21:23:55

network-demos - Remove CVS Ids (scripted)

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