Skip to content

Instantly share code, notes, and snippets.

@Justasic
Created April 19, 2014 06:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Justasic/11075947 to your computer and use it in GitHub Desktop.
Save Justasic/11075947 to your computer and use it in GitHub Desktop.
This is a nice example on how to use the FastCGI library in C.
// libfcgi-dev includes
#define NO_FCGI_DEFINES 1
//#include <fcgio.h>
#include <fcgi_config.h>
#include <fcgi_stdio.h>
#include <string.h>
int main()
{
FCGX_Request request;
FCGX_Init();
memset(&request, 0, sizeof(FCGX_Request));
int sock_fd = FCGX_OpenSocket(":3000", 1024);
FCGX_InitRequest(&request, sock_fd, 0);
while(FCGX_Accept_r(&request) == 0)
{
const char *qstr = FCGX_GetParam("QUERY_STRING", request.envp);
FCGX_FPrintF(request.out, "%s", qstr);
FCGX_Finish_r(&request);
}
FCGX_Free(&request, sock_fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment