GnuCash 2.4.99
fastcgi-hello.c
00001 
00002 #include <fcgi_stdio.h>
00003 #include <stdlib.h>
00004 #include <string.h>
00005 
00006 extern char **environ;
00007 
00008 int main (int argc, char *argv[])
00009 {
00010     char *query_string, *method, *len = 0x0;
00011     int count = 0;
00012     int i, ilen = 0;
00013 
00014     while (FCGI_Accept() >= 0)
00015     {
00016         printf("Content-type: text/html\r\n"
00017                "\r\n"
00018                "<title>FastCGI Hello!</title>"
00019                "<h1>FastCGI Hello!</h1>"
00020                "Request number %d running on host <i>%s</i>\n",
00021                ++count, getenv("SERVER_NAME"));
00022 
00023         printf("<p>If you have configured fastcgi correctly, then "
00024                "the request number should increment every time you "
00025                "hit reload on your browser.  You should also see "
00026                "\"%s\" (the name of this program) showing up in ps ax.\n",
00027                argv[0]);
00028 
00029         query_string = getenv ("QUERY_STRING");
00030         printf ("<p>The QUERY_STRING environment vairable is %s\n"
00031                 "The other environment variables are:<p>", query_string);
00032 
00033         for (i = 0; environ[i]; i++)
00034         {
00035             printf ("<br>%s\n", environ[i]);
00036         }
00037 
00038         method = getenv ("REQUEST_METHOD");
00039         if (!strcmp (method, "POST"))
00040         {
00041             char * bufp;
00042             ilen = atoi (getenv ("CONTENT_LENGTH"));
00043             printf ("<P>This is a method=post request, "
00044                     "with content length=%d<P>\n", ilen);
00045             bufp = (char *) malloc (ilen);
00046             fread (bufp, ilen, 1, stdin);
00047 
00048             printf ("The POST data is<P>%s\n", bufp);
00049             free (bufp);
00050         }
00051 
00052     }
00053     return 0;
00054 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines