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

4.11network-demos-4-10-branchnetwork-demos-4-8-branchnetwork-demos-4-9-branch
Last change on this file since c193150 was c193150, checked in by Joel Sherrill <joel.sherrill@…>, on 09/06/07 at 23:02:45

2007-09-06 Joel Sherrill <joel.sherrill@…>

  • shttpd_ext.c: Use new name.
  • Property mode set to 100644
File size: 1.4 KB
Line 
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" ) ) {
33    rtems_cpu_usage_report_with_plugin( arg, shttpd_printf );
34  } else if ( !strcmp( query, "cpuuse_reset" ) ) {
35    rtems_cpu_usage_reset();
36    shttpd_printf(
37      arg,
38      START_HTML_BODY
39      " <p><big>CPU Usage data reset -- return to the previous page</big></p>"
40      END_HTML_BODY
41    );
42  } else if ( !strcmp( query, "stackuse_report" ) ) {
43    rtems_stack_checker_report_usage_with_plugin( arg, shttpd_printf );
44  } else {
45    shttpd_printf(
46      arg,
47      START_HTML_BODY
48      " <h2>Unknown Request</h2>"
49      " <h3>URI: %s</br>"
50      "  Arguments: %s</h3>"
51      END_HTML_BODY,
52      shttpd_get_env(arg, "REQUEST_URI"),
53      query
54    );
55  }
56  arg->flags |= SHTTPD_END_OF_OUTPUT;
57}
58
59void example_shttpd_addpages(struct shttpd_ctx *ctx)
60{
61  shttpd_register_uri( ctx, "/queries*", example_shttpd_callback, NULL );
62}
63
64#endif
Note: See TracBrowser for help on using the repository browser.