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