This is a comparison of publicly available libraries in the C programming language which help to program with CGI, the "common gateway interface" for the world wide web. For more information on the common gateway interface, please see A simple guide to the common gateway interface.
Some of the fields in the following tables are marked as "unknown" or given a question mark because I have not had time to evaluate whether the library provides that particular feature. I apologise for the incompleteness of this list and hope that the incomplete list still has some value.
The following list of CGI libraries written in C is ordered by the date of the most recent release.
Library name (host) (Links open in a new window) |
Last update | Last version | Licence | Authors | Download |
---|---|---|---|---|---|
qDecoder (www.qdecoder.org) | 2012-05-17 | 12.0.2 | Public domain | Seungyoung Kim | Download |
Lightweight CGI Library (www.infodrom.org) | 2009-02-08 | 0.7 | GNU GPL | Martin Schulze | Download |
cgic (www.boutell.com) | 2008 | 2.05 | Advertising (see site for details) | Thomas Boutrell | Download |
libcgic (www.pavluk.org) | 2008 | 1.0 | BSD licence | Vladimir V. Pavluk | Download |
CGL (www.harding.motd.ca) | 2005-08-18 | 1.2 | BSD-like | Carson Harding | Download |
cgi-util (www.newbreedsoftware.com) | 2005 | 2.2.1 | GNU Library GPL |
Bill Kendrick Mike Simons |
Download |
CGI-LIB (www.joeldare.com) | 2004 | 2.0 | GNU GPL |
Noel V Aguilar Joel Dare |
Download |
Un-CGI (www.midwinter.com) | 2003-11-01 | 1.11 | Gnu-like, see source code. | Steven Grimm | Download |
cgihtml (www.eekim.com) | 2001-05-25 | 1.69 | Unspecified | Eric E. Kim |
Download (Not working) |
A CGI Library for C (sourceforge.net) | 1999 | 1.0 | GNU GPL or GNU Library GPL | William L. Chatfield | Download |
C version | Documentation | Automated tests | |
---|---|---|---|
qDecoder | Unknown |
yes (web page/doxygen)
|
No |
Lightweight CGI Library |
GNU C
|
yes (man files)
|
Maybe |
cgic |
ANSI
|
yes (web page)
|
Maybe |
libcgic | Unknown | No | Maybe |
CGL | Unknown |
yes (doc/cgl.txt)
|
Maybe |
cgi-util | Unknown |
yes (README.txt)
|
Maybe |
CGI-LIB | Unknown | Maybe | Maybe |
Un-CGI | Unknown | Maybe | Maybe |
cgihtml | Unknown | Yes | Maybe |
A CGI Library for C | Unknown | No | Maybe |
Set content type | Set charset | Set status | Set error message | Add arbitrary HTTP headers | Print header | |
---|---|---|---|---|---|---|
qDecoder |
qCgiResponseSetContentType
|
No | No | No | No | No |
Lightweight CGI Library |
cgiSetType
|
No | No | No |
cgiSetHeader
|
cgiHeader
|
cgic |
cgiHeaderContentType
|
No |
cgiHeaderStatus
|
cgiHeaderStatus
|
No | No |
libcgic | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe |
CGL |
cgl_content_header
|
No |
cgl_status_header
|
cgl_status_header
|
No |
cgl_html_header
|
cgi-util | No | No | No | No | No | No |
CGI-LIB | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe |
Un-CGI | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe |
cgihtml |
mime_header
|
No |
status
|
status
|
No |
http_header
|
A CGI Library for C | No | No | No | No | No | No |
process query string | application/x-url-formencoded | multipart/form-data (file upload) | Multiple values for one key | uri escape | uri unescape | |
---|---|---|---|---|---|---|
qDecoder | Yes | Yes | Yes | Maybe |
yes (in qLibc)
|
yes (in qLibc)
|
Lightweight CGI Library | Yes | Yes | Yes |
separated by \n
|
No | No |
cgic | Yes | Yes | Yes |
cgiFormStringMultiple
|
No | No |
libcgic | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe |
CGL | Yes | Yes | No |
cgl_getvalues
|
cgl_urlencode
|
cgl_urldecode
|
cgi-util | Yes | Yes | Yes | No | No |
unescape_url
|
CGI-LIB | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe |
Un-CGI | Maybe | Maybe | Maybe | Maybe | Maybe | Maybe |
cgihtml | Yes | Yes | Yes |
cgi_name_multi
|
No |
unescape_url
|
A CGI Library for C | Yes | Yes | Yes | No | No | No |
Read cookies | Set cookies | Create cookie time strings | Delete cookies | |
---|---|---|---|---|
qDecoder | Yes |
qCgiResponseSetCookie
|
Maybe |
qCgiResponseRemoveCookie
|
Lightweight CGI Library | Yes | No | No | No |
cgic | Yes | Yes | Yes | No |
libcgic | Maybe | Maybe | Maybe | Maybe |
CGL | Yes | Yes |
cgl_cookietime
|
No |
cgi-util |
cgi_getcookie
|
No | No | No |
CGI-LIB | Maybe | Maybe | Maybe | Maybe |
Un-CGI | Maybe | Maybe | Maybe | Maybe |
cgihtml | Yes | Yes | No | No |
A CGI Library for C | No | No | No | No |
html generation | compression | save environment | Redirects | |
---|---|---|---|---|
qDecoder | No | No | No |
qCgiResponseRedirect
|
Lightweight CGI Library | No | No | No |
cgiRedirect
|
cgic | No | No |
cgiWriteEnvironment
|
cgiHeaderLocation
|
libcgic | Maybe | Maybe | Maybe | Maybe |
CGL | Yes | No |
cgl_dumpenv
|
No |
cgi-util | No | No | No | No |
CGI-LIB | Maybe | Maybe | Maybe | Maybe |
Un-CGI | Maybe | Maybe | Maybe | Maybe |
cgihtml | Yes | No |
print_cgi_env
|
No |
A CGI Library for C | No | No | No | No |
No | Does not have this feature |
Maybe | Unknown or not tested |
Yes | Has this feature |
These reviews are meant to supplement the tabular information listed above. All of the CGI libraries listed on this page suffer from very similar problems; none of them has an automated test, almost all of them don't handle HTTP headers fully, and none of them handles compression at all.
Has basic CGI library features including parsing forms and setting and deleting cookies. The examples on the web page are written in C++ but the code itself is C. Lacks ways to set the HTTP status or the character set of the page.
One unusual feature is a way to force a download using a
Content-Disposition:
header.
This library appears to be quite difficult to use. The use of C string functions in parsing multipart/form-data is likely to cause problems in the case of binary file uploads with bytes equal to zero.
The web page for this library claims that it supports writing cookies, but I could not see where this was implemented.
★★★☆☆
This library has been around since the 1990s. It is carefully programmed to avoid problems such as memory leaks. It has a lot of documentation for each function. It also comes with example code and a debugging helper to capture the CGI environment.
Its licence requires users to either pay a fee or include
advertising for it in output. The library provides its own
main
function, and users must use something called
cgiMain
instead.
The C programming is a bit questionable. The first thing the library does is to read every possible environment variable into global variables, but most of these it goes on to completely ignore.
A lot of this code looks useful, but it barely seems to be robust.
Careless in the way that it relies on printf for functions like setting the HTTP headers, so there is no distinction between creating the flow of output and setting the headers. This kind of behaviour tends to make debugging difficult, especially it tends to cause problems with malformed HTTP headers if the programmer forgets what stage he is at in the flow of output. The library is also missing the feature of multipart form handling (file uploads).
The extensive use of hash tables to store form name and value pairs looks a bit excessive considering the number of these things in even a fairly large HTML form.
The library also contains a facility to print headers as if it was a web server rather than a CGI library.
This library is not clearly documented, and seems to be somewhat incomplete. For example, it provides nothing to deal with HTTP headers or cookies. On the bright side, it contains a lot of error status checking. It also contains odd-bod functions like an email address validation routine.
This library is no longer updated by its author. Its internals refer to ancient bugs of Netscape Navigator and uses cludges to do things like detect whether the browser can accept images. The download no longer works.
This library has no documentation. From looking at the code, the main ability seems to be to parse HTML form data. It does not seem to have any output parts.
The specification for the Hypertext Transfer Protocol (HTTP).