$NetBSD: patch-ac,v 1.2 2006/01/06 22:46:51 adam Exp $

--- cgic.c.orig	2004-11-15 17:57:59.000000000 +0100
+++ cgic.c
@@ -119,8 +119,9 @@ static void cgiFreeResources();
 static int cgiStrEqNc(char *s1, char *s2);
 static int cgiStrBeginsNc(char *s1, char *s2);
 
-int main(int argc, char *argv[]) {
-	int result;
+int
+cgiInit(void)
+{
 	char *cgiContentLengthString;
 	char *e;
 	cgiSetupConstants();
@@ -206,17 +207,6 @@ int main(int argc, char *argv[]) {
 	cgiOut = stdout;
 	cgiRestored = 0;
 
-
-	/* These five lines keep compilers from
-		producing warnings that argc and argv
-		are unused. They have no actual function. */
-	if (argc) {
-		if (argv[0]) {
-			cgiRestored = 0;
-		}
-	}	
-
-
 	if (cgiStrEqNc(cgiRequestMethod, "post")) {
 #ifdef CGICDEBUG
 		CGICDEBUGSTART
@@ -284,9 +274,8 @@ int main(int argc, char *argv[]) {
 #endif /* CGICDEBUG */
 		}
 	}
-	result = cgiMain();
-	cgiFreeResources();
-	return result;
+	atexit(cgiFreeResources);
+	return 0;
 }
 
 static void cgiGetenv(char **s, char *var){
