kcgi is an open source CGI and FastCGI library for C web applications. It is minimal, secure, and auditable. This is the README file for display with GitHub, which hosts a read-only source repository of the project. To keep up to date with the current stable release of kcgi, visit the kcgi website.
Implementing a CGI or FastCGI application with kcgi is easy. One usually specifies the pages recognised by the application and the known form inputs. kcgi then parses the request.
#include <stdint.h>
#include <stdlib.h>
#include <kcgi.h>
int main(void) {
struct kreq r;
const char *page = "index";
if (KCGI_OK != khttp_parse(&r, NULL, 0, &page, 1, 0))
return(EXIT_FAILURE);
khttp_head(&r, kresps[KRESP_STATUS], "%s", khttps[KHTTP_200]);
khttp_head(&r, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[r.mime]);
khttp_body(&r);
khttp_puts(&r, "Hello, world!");
khttp_free(&r);
return(EXIT_SUCCESS);
}
kcgi works out-of-the-box with modern UNIX systems.
Simply download the latest version's source
archive (or download
the project from GitHub), compile with make
, then sudo make install
.
Your operating system might already have kcgi as one of its third-party
libraries: check to make sure!
See the kcgi(3) manpage for complete library documentation.
The system contains a full regression suite and is also built to work with AFL. See the kcgi website for details on how to deploy (or write) tests.
All sources use the ISC (like OpenBSD) license. See the LICENSE.md file for details.