libmfcgi – minimal application framework
libmfcgi is a minimal, open source (ISC-licensed) framework for web applications written in C. For the time being, its only underlying server method is FastCGI. It's internally asynchronous, so requests can wait for external data (databases, session servers, etc.) without blocking the application. It interfaces with libhtml for DOM manipulation; existing implementations (and the example) generally also use libmutf8 for UTF-8 manipulation, htmlc for generating DOM trees from HTML source at compile time, and libmmail for e-mail handling (these are not required by libmfcgi). libmfcgi is designed for extreme horizontal and vertical scalability.
Internally, libmfcgi aggressively minimises memory usage, using shared pools and state machines instead of ad hoc allocations and frees. Query fields and cookie values may be looked up in constant time when applications provide characteristic maps on startup (see mfcgi(3) for details); values are hashed when a request is processed.
Why? There are few FastCGI application frameworks in C that support asynchronous processing and strong support for internally-manipulated DOM trees (instead of static content).
Consider the following example, which is distributed with the source package: the index_page.html HTML source is compiled with htmlc into a DOM tree, which is manipulated by example.c. See also the Makefile.example.
The libmfcgi library is a BSD.lv Project member.
Sources correctly build and install on OpenBSD, NetBSD, and GNU/Linux operating systems, tested variously on generic i386, AMD64, and DEC Alpha. The current version is 0.3.0. It requires the libfcgi and libhtml libraries. The example also requires htmlc.
Note: this library is heavily under development! Please contact the author if you wish to use it.
The manual is generated automatically and refers to the current snapshot. A complete example implementation is distributed with the source package.
For all issues related to libmfcgi, contact Kristaps Dzonsons, kris...@bsd.lv.
24-06-2010: version 0.3.0
The page dispatcher call-back has changed to accomodate for lots of application-private data: per-object, per-page, and per-application. Furthermore, the initialisation phase has been modified to accept statically-allocated structures, simplying memory management. Synchronised with libmutf8-0.2.2 and libhtml-0.3.0. (note that the functionality of htmlc has been deprecated in favour of directly interfacing with libhtml hcaches).
22-04-2010: version 0.2.1
Cookies are now internally handled with the mf_page_cookie() family. Pages may also be called by using the remaining path information (app/foo instead of app?page=foo). This breaks binary compatibility: several functions have been renamed to allow for both cookie and query field validation and table-based lookups. Synchronised with libmutf8-0.2.2, htmlc-0.1.14, libhtml-0.2.14.
02-03-2010: version 0.1.16
Removed framework dependency of libmutf8. Removed default
02-03-2010: version 0.1.15
Improved logging facilities. Added
25-02-2010: version 0.1.14
Added accessors to all query values (via set iterators), not just indexed or named ones. Allowed multiple values per indexed/named query. Added transparent HTTP-POST support: internally uses global buffer queues for optimal memory usage. These map directly into the standard query functions. Note that multipart or other fanciness not yet supported.
19-02-2010: version 0.1.13
Now using libmutf8. Using enumerations instead of CPP definitions for lots of values. Bugfix in deref of NULL validation function pointer. Synchronised with libmutf8-0.1.1, htmlc-0.1.11, libhtml-0.2.7.
17-02-2010: version 0.1.12
Overhaul of query parsing: query objects are acquired from a global pool during query string parse, then tabularised and validated according to a page's validation rules.
See cvsweb for historical notes.
Copyright © 2009, 2010 Kristaps Dzonsons, $Date: 2010/06/24 13:33:48 $