eris

Very small inetd http server
git clone https://git.woozle.org/neale/eris.git

eris / contrib
Neale Pickett  ·  2012-11-07

g.cgi.c

 1/** g.cgi - CGI interface to cgit and git-http-backend
 2  *
 3  * This is a simple CGI to invoke cgit with a configuration
 4  * file of your choice.  It will also invoke git-http-backend
 5  * if appropriate, which in my (very light) testing runs about
 6  * twice as fast as plain HTTP with git-update-server-info.
 7  */
 8#include <string.h>
 9#include <stdlib.h>
10#include <unistd.h>
11
12/* Set these to appropriate paths */
13#define CGIT_CONFIG "/home/neale/public_html/cgitrc"
14#define GIT_PROJECT_ROOT "/home/neale/projects"
15
16int
17main(int argc, char *argv[])
18{
19    char *uri = getenv("REQUEST_URI");
20
21    if (uri && strstr(uri, "git-upload-pack")) {
22        /* Use git-http-backend for great speed! */
23        setenv("GIT_PROJECT_ROOT", GIT_PROJECT_ROOT, 1);
24        execlp("git", "git", "http-backend", NULL);
25    } else {
26        setenv("CGIT_CONFIG", CGIT_CONFIG, 1);
27        execlp("cgit", "cgit", NULL);
28    }
29
30    return 0;
31}