Index: trunk/thirds/cgic206/Makefile
===================================================================
--- trunk/thirds/cgic206/Makefile (revision 1)
+++ trunk/thirds/cgic206/Makefile (revision 6)
@@ -3,5 +3,5 @@
AR=ar
RANLIB=ranlib
-LIBS=-L./ -lcgic ../fcgi-2.4.0/libfcgi/.libs/libfcgi.a
+LIBS=-L./ -lcgic /usr/lib/libfcgi.a
CFLAGS=-I//var/www/localhost/include
Index: trunk/thirds/cgic206/cgic.c
===================================================================
--- trunk/thirds/cgic206/cgic.c (revision 1)
+++ trunk/thirds/cgic206/cgic.c (revision 6)
@@ -136,8 +136,14 @@
cgiGetenv(&cgiServerPort, "SERVER_PORT");
cgiGetenv(&cgiRequestMethod, "REQUEST_METHOD");
+ if(strcmp(cgiRequestMethod,"")==0 && argc>=1)
+ cgiRequestMethod="GET";
cgiGetenv(&cgiPathInfo, "PATH_INFO");
cgiGetenv(&cgiPathTranslated, "PATH_TRANSLATED");
cgiGetenv(&cgiScriptName, "SCRIPT_NAME");
cgiGetenv(&cgiQueryString, "QUERY_STRING");
+ if(strcmp(cgiQueryString,"")==0 && argc>=2){
+ cgiQueryString=argv[1];
+ }else
+ fprintf(stderr,"cgiQueryString : %s\n",cgiQueryString);
cgiGetenv(&cgiRemoteHost, "REMOTE_HOST");
cgiGetenv(&cgiRemoteAddr, "REMOTE_ADDR");
@@ -190,4 +196,8 @@
cgiGetenv(&cgiContentLengthString, "CONTENT_LENGTH");
cgiContentLength = atoi(cgiContentLengthString);
+ if(cgiContentLength==0 && argc>=2){
+ cgiContentLength=strlen(argv[1]);
+ }
+ fprintf(stderr,"%d\n",cgiContentLength);
cgiGetenv(&cgiAccept, "HTTP_ACCEPT");
cgiGetenv(&cgiUserAgent, "HTTP_USER_AGENT");
@@ -208,6 +218,6 @@
#endif /* WIN32 */
cgiFormEntryFirst = 0;
- cgiIn = stdin;
- cgiOut = stdout;
+ cgiIn = FCGI_stdin;
+ cgiOut = FCGI_stdout;
cgiRestored = 0;
@@ -293,4 +303,5 @@
cgiFreeResources();
}
+ FCGI_Finish();
return result;
}
Index: trunk/thirds/cgic206/cgictest.c
===================================================================
--- trunk/thirds/cgic206/cgictest.c (revision 1)
+++ trunk/thirds/cgic206/cgictest.c (revision 6)
@@ -23,8 +23,10 @@
cgiReadEnvironment("/home/boutell/public_html/capcgi.dat");
#endif
- cgiHeaderContentType("text/html");
- fprintf(cgiOut, "
\n");
- fprintf(cgiOut, "cgic test\n");
- fprintf(cgiOut, "cgic test
\n");
+ dup2(cgiOut,stdout);
+ printf("Content-Type: text/html; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
+ //cgiHeaderContentType("text/html");
+ printf( "\n");
+ printf( "cgic test\n");
+ printf( "cgic test
\n");
Name();
Address();
@@ -36,5 +38,5 @@
NonExButtons();
RadioButtons();
- fprintf(cgiOut, "\n");
+ printf( "\n");
return 0;
}
@@ -45,23 +47,23 @@
switch (result) {
case cgiFormSuccess:
- fprintf(cgiOut, "Name fetched, result code: cgiFormSuccess
\n");
+ printf( "Name fetched, result code: cgiFormSuccess
\n");
break;
case cgiFormTruncated:
- fprintf(cgiOut, "Name fetched, result code: cgiFormTruncated
\n");
+ printf( "Name fetched, result code: cgiFormTruncated
\n");
break;
case cgiFormEmpty:
- fprintf(cgiOut, "Name fetched, result code: cgiFormEmpty
\n");
+ printf( "Name fetched, result code: cgiFormEmpty
\n");
break;
case cgiFormNotFound:
- fprintf(cgiOut, "Name fetched, result code: cgiFormNotFound
\n");
+ printf( "Name fetched, result code: cgiFormNotFound
\n");
break;
case cgiFormMemory:
- fprintf(cgiOut, "Name fetched, result code: cgiFormMemory
\n");
+ printf( "Name fetched, result code: cgiFormMemory
\n");
break;
default:
- fprintf(cgiOut, "Name fetched, unexpected result code: %d\n", result);
+ printf( "Name fetched, unexpected result code: %d\n", result);
break;
}
- fprintf(cgiOut, "Name: %s
\n", name);
+ printf( "Name: %s
\n", name);
}
@@ -69,12 +71,12 @@
char address[241];
cgiFormString("address", address, 241);
- fprintf(cgiOut, "Address: \n%s
\n", address);
+ printf( "Address: \n%s
\n", address);
}
void Hungry() {
if (cgiFormCheckboxSingle("hungry") == cgiFormSuccess) {
- fprintf(cgiOut, "I'm Hungry!
\n");
+ printf( "I'm Hungry!
\n");
} else {
- fprintf(cgiOut, "I'm Not Hungry!
\n");
+ printf( "I'm Not Hungry!
\n");
}
}
@@ -83,5 +85,5 @@
double temperature;
cgiFormDoubleBounded("temperature", &temperature, 80.0, 120.0, 98.6);
- fprintf(cgiOut, "My temperature is %f.
\n", temperature);
+ printf( "My temperature is %f.
\n", temperature);
}
@@ -89,5 +91,5 @@
int frogsEaten;
cgiFormInteger("frogs", &frogsEaten, 0);
- fprintf(cgiOut, "I have eaten %d frogs.
\n", frogsEaten);
+ printf( "I have eaten %d frogs.
\n", frogsEaten);
}
@@ -101,5 +103,5 @@
int colorChoice;
cgiFormSelectSingle("colors", colors, 3, &colorChoice, 0);
- fprintf(cgiOut, "I am: %s
\n", colors[colorChoice]);
+ printf( "I am: %s
\n", colors[colorChoice]);
}
@@ -118,14 +120,14 @@
flavorChoices, &invalid);
if (result == cgiFormNotFound) {
- fprintf(cgiOut, "I hate ice cream.\n");
+ printf( "I hate ice cream.
\n");
} else {
- fprintf(cgiOut, "My favorite ice cream flavors are:\n");
- fprintf(cgiOut, "
\n");
+ printf( "My favorite ice cream flavors are:\n");
+ printf( "\n");
for (i=0; (i < 3); i++) {
if (flavorChoices[i]) {
- fprintf(cgiOut, "- %s\n", flavors[i]);
+ printf( "
- %s\n", flavors[i]);
}
}
- fprintf(cgiOut, "
\n");
+ printf( "
\n");
}
}
@@ -146,5 +148,5 @@
cgiFormRadio("age", ages, 4, &ageChoice, 0);
- fprintf(cgiOut, "Age of Truck: %s (method #1)
\n",
+ printf( "Age of Truck: %s (method #1)
\n",
ages[ageChoice]);
@@ -157,5 +159,5 @@
cgiFormString("age", ageText, 10);
- fprintf(cgiOut, "Age of Truck: %s (method #2)
\n", ageText);
+ printf( "Age of Truck: %s (method #2)
\n", ageText);
}
@@ -178,18 +180,18 @@
since votes for nonexistent candidates should probably
be discounted... */
- fprintf(cgiOut, "Votes (method 1):
\n");
+ printf( "Votes (method 1):
\n");
result = cgiFormCheckboxMultiple("vote", votes, 4,
voteChoices, &invalid);
if (result == cgiFormNotFound) {
- fprintf(cgiOut, "I hate them all!\n");
+ printf( "I hate them all!
\n");
} else {
- fprintf(cgiOut, "My preferred candidates are:\n");
- fprintf(cgiOut, "
\n");
+ printf( "My preferred candidates are:\n");
+ printf( "\n");
for (i=0; (i < 4); i++) {
if (voteChoices[i]) {
- fprintf(cgiOut, "- %s\n", votes[i]);
+ printf( "
- %s\n", votes[i]);
}
}
- fprintf(cgiOut, "
\n");
+ printf( "
\n");
}
@@ -198,17 +200,17 @@
than the code and invented responses are not a danger
or can be checked in some other way. */
- fprintf(cgiOut, "Votes (method 2):
\n");
+ printf( "Votes (method 2):
\n");
result = cgiFormStringMultiple("vote", &responses);
if (result == cgiFormNotFound) {
- fprintf(cgiOut, "I hate them all!\n");
+ printf( "I hate them all!
\n");
} else {
int i = 0;
- fprintf(cgiOut, "My preferred candidates are:\n");
- fprintf(cgiOut, "
\n");
+ printf( "My preferred candidates are:\n");
+ printf( "\n");
while (responses[i]) {
- fprintf(cgiOut, "- %s\n", responses[i]);
+ printf( "
- %s\n", responses[i]);
i++;
}
- fprintf(cgiOut, "
\n");
+ printf( "
\n");
}
/* We must be sure to free the string array or a memory