4.11network-demos-4-10-branchnetwork-demos-4-9-branch
Last change
on this file since ddd57c9 was
b80aaa9,
checked in by Joel Sherrill <joel.sherrill@…>, on 08/20/08 at 22:16:20
|
2008-08-20 Joel Sherrill <joel.sherrill@…>
- shttpd_ext.c: Fix warning.
|
-
Property mode set to
100644
|
File size:
1.5 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 | |
---|
23 | void 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( |
---|
34 | arg, |
---|
35 | (rtems_printk_plugin_t) shttpd_printf |
---|
36 | ); |
---|
37 | } else if ( !strcmp( query, "cpuuse_reset" ) ) { |
---|
38 | rtems_cpu_usage_reset(); |
---|
39 | shttpd_printf( |
---|
40 | arg, |
---|
41 | START_HTML_BODY |
---|
42 | " <p><big>CPU Usage data reset -- return to the previous page</big></p>" |
---|
43 | END_HTML_BODY |
---|
44 | ); |
---|
45 | } else if ( !strcmp( query, "stackuse_report" ) ) { |
---|
46 | rtems_stack_checker_report_usage_with_plugin( |
---|
47 | arg, |
---|
48 | (rtems_printk_plugin_t) shttpd_printf |
---|
49 | ); |
---|
50 | } else { |
---|
51 | shttpd_printf( |
---|
52 | arg, |
---|
53 | START_HTML_BODY |
---|
54 | " <h2>Unknown Request</h2>" |
---|
55 | " <h3>URI: %s</br>" |
---|
56 | " Arguments: %s</h3>" |
---|
57 | END_HTML_BODY, |
---|
58 | shttpd_get_env(arg, "REQUEST_URI"), |
---|
59 | query |
---|
60 | ); |
---|
61 | } |
---|
62 | arg->flags |= SHTTPD_END_OF_OUTPUT; |
---|
63 | } |
---|
64 | |
---|
65 | void example_shttpd_addpages(struct shttpd_ctx *ctx) |
---|
66 | { |
---|
67 | shttpd_register_uri( ctx, "/queries*", example_shttpd_callback, NULL ); |
---|
68 | } |
---|
69 | |
---|
70 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.