Created
April 19, 2014 06:28
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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