Embedthis Appweb 3.4.0
Home > Programming Guide > Serving Pages from ROM

Quick Nav

See Also

Serving Pages from ROM

To enable Appweb to be used on embedded systems without file systems, 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:

find web -type f -print >fileList
makerom --files filelist >romFiles.c
cc -o romFiles.o romFiles.c

This will create a list of all the web files and then convert these files into C structures in the file romFiles.cpp.

The makerom program takes two options:

Switch Description
--prefix Specifies a prefix to remove from each of the compiled file names.
-- 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 also put into the ROM the essential Appweb configuration files. 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.

find sslWeb vhostWeb web -print >rom.files \
echo -e '.\nappweb.conf\nmime.types\nusers.db\ngroups.db' >>rom.files
makerom rom.files >romFiles.cpp

Using ROM with PHP

The ROM facility is supported by the following Appweb modules and handlers: authHandler, fileHandler, egiHandler, ejsHandler, sslModule and the openSslModule.

PHP does not support the Appweb ROM facility.

© Embedthis Software LLC, 2003-2012. All rights reserved. Embedthis, Ejscript and Appweb are trademarks of Embedthis Software LLC.