Look kcgi
kcgi is an open source CGI library and FastCGI for C web applications. It is minimal, secure, and auditable.
#include <sys/types.h> /* size_t, ssize_t */ #include <stdarg.h> /* va_list */ #include <stddef.h> /* NULL */ #include <stdint.h> /* int64_t */ #include <stdlib.h> /* EXIT_SUCCESS, etc. */ #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[KMIME__MAX == r.mime ? KMIME_APP_OCTET_STREAM : r.mime]); khttp_body(&r); khttp_puts(&r, "Hello, world!"); khttp_free(&r); return(EXIT_SUCCESS); }
source share