Comparison of CGI libraries in C

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 ( 2014-05-21 Unknown (unversioned github download) Public domain Seungyoung Kim Download
cgic ( 2014-03-17 2.06 Advertising (see site for details) Thomas Boutrell Download
Lightweight CGI Library ( 2009-02-08 0.7 GNU GPL Martin Schulze Download
libcgic ( 2008 1.0 BSD licence Vladimir V. Pavluk Download
CGL ( 2005-08-18 1.2 BSD-like Carson Harding Download
cgi-util ( 2005 2.2.1 GNU Library GPL Bill Kendrick
Mike Simons
CGI-LIB ( 2004 2.0 GNU GPL Noel V Aguilar
Joel Dare
Un-CGI ( 2003-11-01 1.11 Gnu-like, see source code. Steven Grimm Download
cgihtml ( 2001-05-25 1.69 Unspecified Eric E. Kim Download
(Not working)
A CGI Library for C ( 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
cgic ANSI yes (web page) Maybe
Lightweight CGI Library GNU C yes (man files) 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

HTTP headers

Set content type Set charset Set status Set error message Add arbitrary HTTP headers Print header
qDecoder qcgires_SetContentType No No No No No
cgic cgiHeaderContentType No cgiHeaderStatus cgiHeaderStatus No No
Lightweight CGI Library cgiSetType No No No cgiSetHeader cgiHeader
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

Form parsing

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)
cgic Yes Yes Yes cgiFormStringMultiple No No
Lightweight CGI Library Yes Yes Yes separated by \n 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 qcgires_setcookie Maybe qcgires_removecookie
cgic Yes Yes Yes No
Lightweight CGI Library Yes No No 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 qcgires_redirect
cgic No No cgiWriteEnvironment cgiHeaderLocation
Lightweight CGI Library No No No cgiRedirect
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

Key to the tables

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.

"qDecoder" by Seungyoung Kim

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.

"cgic" by Thomas Boutrell


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.

"Lightweight CGI Library" by Martin Schulze

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.

"CGL" by Carson Harding

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.

"cgi-util" by Bill Kendrick
Mike Simons

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.

"cgihtml" by Eric E. Kim

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.

"A CGI Library for C" by William L. Chatfield

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.

Web links

Copyright © Ben Bullock 2009-2015. All rights reserved. For comments, questions, and corrections, please email Ben Bullock ( / Privacy / Disclaimer