Embedded Web Server for the CR16
to adopt a monolithic style. Both are supported in this server. Moreover, Web pages may
include provision for dynamic data i.e. data returned by one of the user-specific tasks may be
inserted into the page by the server prior to transmission. To support this feature, all
embedded pages follow a defined format, and predefined constructs are utilized to organize
and manage the transmission of each page.
Formatting your own embedded html page proceeds as follows:
Web pages may comprise one or more discrete sections, each of which will assume the form
of a array of characters. Sections should be given a common logical name, similar to that of
Begin the page with 2 (two) CR/LF (\r\n) sequences. (The user-defined portion is the HTTP
entity body. The body follows the HTTP header, and must be delimited by 2 carriage
return/line feed sequences.)
You may optionally begin each line with a CR/LF sequence (\r\n) to make the browsers
source view easier to read (these may be omitted to save space).
Escape any C specific characters (such as quotes or percentage signs). For example, any
quotation marks within your html code must be replaced with \.
Delimit each line with quotes to form one string literal.
Terminate each array (one or more) with a semicolon as per C coding requirements.
As a simple example, consider the following html listing using the above approach. Figure 21
shows just how Internet Explorer renders this very short section of embedded html code.
const UBYTE err504_htm =
const UBYTE err504_htm2 =
"<BODY><H1>HTTP Error 504 - Remote Node Error</H1>"
const UBYTE err504_htm3 =
" responded with error: ";
const UBYTE err504_htm4 =
"\r\n<P><HR><ADDRESS>Jeffs/1.3.9 Server at www.cr16.com "
"\r\n Port 80</ADDRESS>"
Figure 17. Simple embedded page.
Once your page is written, you now insert pointers to the pages addresse(s) and other
pertinent parameters into a control structure as defined in Figure 18. (See Figure 19 for
this pages data structure.)
Finally, you must give your page an Identifier and insert it into the list of pages as shown in
Figure 20. This is simply the name you wish to use for the object. HTTP resources are
commonly identified by what they call a URI, or Uniform Resource Identifier. For example,