Index: /trunk/thirds/cgic206/Makefile
===================================================================
--- /trunk/thirds/cgic206/Makefile	(revision 5)
+++ /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 5)
+++ /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 5)
+++ /trunk/thirds/cgic206/cgictest.c	(revision 6)
@@ -23,8 +23,10 @@
 	cgiReadEnvironment("/home/boutell/public_html/capcgi.dat");
 #endif
-	cgiHeaderContentType("text/html");
-	fprintf(cgiOut, "<HTML><HEAD>\n");
-	fprintf(cgiOut, "<TITLE>cgic test</TITLE></HEAD>\n");
-	fprintf(cgiOut, "<BODY><H1>cgic test</H1>\n");
+	dup2(cgiOut,stdout);
+	printf("Content-Type: text/html; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
+	//cgiHeaderContentType("text/html");
+	printf( "<HTML><HEAD>\n");
+	printf( "<TITLE>cgic test</TITLE></HEAD>\n");
+	printf( "<BODY><H1>cgic test</H1>\n");
 	Name();
 	Address();
@@ -36,5 +38,5 @@
 	NonExButtons();
 	RadioButtons();
-	fprintf(cgiOut, "</BODY></HTML>\n");
+	printf( "</BODY></HTML>\n");
 	return 0;
 }
@@ -45,23 +47,23 @@
 	switch (result) {
 		case cgiFormSuccess:
-		fprintf(cgiOut, "Name fetched, result code: cgiFormSuccess<br>\n");
+		printf( "Name fetched, result code: cgiFormSuccess<br>\n");
 		break;
 		case cgiFormTruncated:
-		fprintf(cgiOut, "Name fetched, result code: cgiFormTruncated<br>\n");
+		printf( "Name fetched, result code: cgiFormTruncated<br>\n");
 		break;
 		case cgiFormEmpty:
-		fprintf(cgiOut, "Name fetched, result code: cgiFormEmpty<br>\n");
+		printf( "Name fetched, result code: cgiFormEmpty<br>\n");
 		break;
 		case cgiFormNotFound:
-		fprintf(cgiOut, "Name fetched, result code: cgiFormNotFound<br>\n");
+		printf( "Name fetched, result code: cgiFormNotFound<br>\n");
 		break;
 		case cgiFormMemory:
-		fprintf(cgiOut, "Name fetched, result code: cgiFormMemory<br>\n");
+		printf( "Name fetched, result code: cgiFormMemory<br>\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<BR>\n", name);
+	printf( "Name: %s<BR>\n", name);
 }
 	
@@ -69,12 +71,12 @@
 	char address[241];
 	cgiFormString("address", address, 241);
-	fprintf(cgiOut, "Address: <PRE>\n%s</PRE>\n", address);
+	printf( "Address: <PRE>\n%s</PRE>\n", address);
 }
 
 void Hungry() {
 	if (cgiFormCheckboxSingle("hungry") == cgiFormSuccess) {
-		fprintf(cgiOut, "I'm Hungry!<BR>\n");
+		printf( "I'm Hungry!<BR>\n");
 	} else {
-		fprintf(cgiOut, "I'm Not Hungry!<BR>\n");
+		printf( "I'm Not Hungry!<BR>\n");
 	}
 }
@@ -83,5 +85,5 @@
 	double temperature;
 	cgiFormDoubleBounded("temperature", &temperature, 80.0, 120.0, 98.6);
-	fprintf(cgiOut, "My temperature is %f.<BR>\n", temperature);
+	printf( "My temperature is %f.<BR>\n", temperature);
 }
 	
@@ -89,5 +91,5 @@
 	int frogsEaten;
 	cgiFormInteger("frogs", &frogsEaten, 0);
-	fprintf(cgiOut, "I have eaten %d frogs.<BR>\n", frogsEaten);
+	printf( "I have eaten %d frogs.<BR>\n", frogsEaten);
 }
 
@@ -101,5 +103,5 @@
 	int colorChoice;
 	cgiFormSelectSingle("colors", colors, 3, &colorChoice, 0);
-	fprintf(cgiOut, "I am: %s<BR>\n", colors[colorChoice]);
+	printf( "I am: %s<BR>\n", colors[colorChoice]);
 }	 
 
@@ -118,14 +120,14 @@
 		flavorChoices, &invalid);
 	if (result == cgiFormNotFound) {
-		fprintf(cgiOut, "I hate ice cream.<p>\n");
+		printf( "I hate ice cream.<p>\n");
 	} else {	
-		fprintf(cgiOut, "My favorite ice cream flavors are:\n");
-		fprintf(cgiOut, "<ul>\n");
+		printf( "My favorite ice cream flavors are:\n");
+		printf( "<ul>\n");
 		for (i=0; (i < 3); i++) {
 			if (flavorChoices[i]) {
-				fprintf(cgiOut, "<li>%s\n", flavors[i]);
+				printf( "<li>%s\n", flavors[i]);
 			}
 		}
-		fprintf(cgiOut, "</ul>\n");
+		printf( "</ul>\n");
 	}
 }
@@ -146,5 +148,5 @@
 	cgiFormRadio("age", ages, 4, &ageChoice, 0);
 
-	fprintf(cgiOut, "Age of Truck: %s (method #1)<BR>\n", 
+	printf( "Age of Truck: %s (method #1)<BR>\n", 
 		ages[ageChoice]);
 
@@ -157,5 +159,5 @@
 	cgiFormString("age", ageText, 10);
 
-	fprintf(cgiOut, "Age of Truck: %s (method #2)<BR>\n", ageText);
+	printf( "Age of Truck: %s (method #2)<BR>\n", ageText);
 }
 
@@ -178,18 +180,18 @@
 		since votes for nonexistent candidates should probably
 		be discounted... */
-	fprintf(cgiOut, "Votes (method 1):<BR>\n");
+	printf( "Votes (method 1):<BR>\n");
 	result = cgiFormCheckboxMultiple("vote", votes, 4, 
 		voteChoices, &invalid);
 	if (result == cgiFormNotFound) {
-		fprintf(cgiOut, "I hate them all!<p>\n");
+		printf( "I hate them all!<p>\n");
 	} else {	
-		fprintf(cgiOut, "My preferred candidates are:\n");
-		fprintf(cgiOut, "<ul>\n");
+		printf( "My preferred candidates are:\n");
+		printf( "<ul>\n");
 		for (i=0; (i < 4); i++) {
 			if (voteChoices[i]) {
-				fprintf(cgiOut, "<li>%s\n", votes[i]);
+				printf( "<li>%s\n", votes[i]);
 			}
 		}
-		fprintf(cgiOut, "</ul>\n");
+		printf( "</ul>\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):<BR>\n");
+	printf( "Votes (method 2):<BR>\n");
 	result = cgiFormStringMultiple("vote", &responses);
 	if (result == cgiFormNotFound) {	
-		fprintf(cgiOut, "I hate them all!<p>\n");
+		printf( "I hate them all!<p>\n");
 	} else {
 		int i = 0;
-		fprintf(cgiOut, "My preferred candidates are:\n");
-		fprintf(cgiOut, "<ul>\n");
+		printf( "My preferred candidates are:\n");
+		printf( "<ul>\n");
 		while (responses[i]) {
-			fprintf(cgiOut, "<li>%s\n", responses[i]);
+			printf( "<li>%s\n", responses[i]);
 			i++;
 		}
-		fprintf(cgiOut, "</ul>\n");
+		printf( "</ul>\n");
 	}
 	/* We must be sure to free the string array or a memory
