Serving Pages from ROM
To enable Appweb to be used on an embedded system without a file system, Appweb supports the compilation of web pages and configuration files into C code that can be stored in Read Only Memory (ROM) and fetched by Appweb to respond to relevant requests.
Appweb has a virtual file system interface that allows the run-time switching between serving web pages on a disk-based file system and a compiled ROM based store of web pages.
This ROM facility may also be used to enhance security by preventing the modification of web documents, or in performance critical situations were the serving of web pages from memory may be an effective optimization.
Compiling Web Pages
The Appweb makerom program is used to compile web documents, configuration files, and any other files that you would like to be compiled into C code. The makerom program will parse the files and convert them into C data structures which can then be compiled by your C/C++ compiler and linked into your application.
For example:
makerom `find web -print` >romFiles.c
This will create a list of all the web files and then convert these files into C structures in the file romFiles.c.
The makerom program takes two options:
Switch | Description |
---|---|
--prefix | Specifies a leading string prefix to remove from each of the compiled file names. Filenames should be relative paths and not start with "./". |
-- name | Specifies the name of top level C structure. Appweb allows multiple ROM directories to be included in a single application. This is necessary if using virtual hosts to allow each host to have its own web directory. |
It is important to include some essential Appweb configuration files into the ROM. These include the Appweb configuration file, the mime.types file, and any authorization database files. The following script is used to compile the web pages in three web directories ("sslWeb", "vhostWeb", and "web") and to also compile the essential configuration files.
Using ROM with PHP
The ROM facility is supported by the following Appweb modules and handlers: fileHandler, espHandler and the sslModule.
Ejscript and PHP do not support the Appweb ROM facility.