Index: branches/PublicaMundi_David-devel/thirds/cgic206/cgic.h
===================================================================
--- branches/PublicaMundi_David-devel/thirds/cgic206/cgic.h	(revision 511)
+++ branches/PublicaMundi_David-devel/thirds/cgic206/cgic.h	(revision 548)
@@ -10,6 +10,7 @@
 	types defined by it, such as FILE *. */
 
-#include "fcgi_stdio.h"
-//#include <stdio.h>
+//#include "fcgi_stdio.h"
+#include <fcgiapp.h>
+#include <stdio.h>
 
 /* The various CGI environment variables. Instead of using getenv(),
@@ -21,112 +22,57 @@
 	for debugging. */
 
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
+
+typedef struct cgiFormEntryStruct {
+        char *attr;
+    /* value is populated for regular form fields only.
+        For file uploads, it points to an empty string, and file
+        upload data should be read from the file tfileName. */ 
+    char *value;
+    /* When fileName is not an empty string, tfileName is not null,
+        and 'value' points to an empty string. */
+    /* Valid for both files and regular fields; does not include
+        terminating null of regular fields. */
+    int valueLength;
+    char *fileName; 
+    char *contentType;
+    /* Temporary file name for working storage of file uploads. */
+    char *tfileName;
+        struct cgiFormEntryStruct *next;
+} cgiFormEntry;
+
+
+
+
+struct cgi_env {
+int cgiRestored;// = 0;
 char *cgiServerSoftware;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiServerName;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiGatewayInterface;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiServerProtocol;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiServerPort;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiRequestMethod;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiPathInfo;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiPathTranslated;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiScriptName;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiQueryString;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiRemoteHost;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiRemoteAddr;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiAuthType;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiRemoteUser;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiRemoteIdent;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
-char *cgiContentType;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
+char cgiContentTypeData[1024];
+char *cgiContentType;// = cgiContentTypeData;
+
+char * cgiMultipartBoundary;
+cgiFormEntry *cgiFormEntryFirst;
+int cgiTreatUrlEncoding;
+
 char *cgiAccept;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiUserAgent;
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiReferrer;
 
 /* Cookies as sent to the server. You can also get them
 	individually, or as a string array; see the documentation. */
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiCookie;
-
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 char *cgiSid;
 
@@ -140,8 +86,4 @@
 	directly from cgiIn; the programmer need not do so. */
 
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
 int cgiContentLength;
 
@@ -152,20 +94,8 @@
 	cgiOut is always equivalent to stdout. */
 
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
-FILE *cgiOut;
-
-/* Pointer to CGI input. The programmer does not read from this.
-	We have continued to export it for backwards compatibility
-	so that cgic 1.x applications link properly. */
-
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
-FILE *cgiIn;
-
+char *cgiFindTarget;
+cgiFormEntry *cgiFindPos;
+
+};
 /* Possible return codes from the cgiForm family of functions (see below). */
 
@@ -195,5 +125,5 @@
 #endif
 cgiFormResultType cgiFormString(
-	char *name, char *result, int max);
+	char *name, char *result, int max,struct cgi_env **);
 
 extern 
@@ -202,5 +132,5 @@
 #endif
 cgiFormResultType cgiFormStringNoNewlines(
-	char *name, char *result, int max);
+	char *name, char *result, int max,struct cgi_env ** ce);
 
 
@@ -210,5 +140,5 @@
 #endif
 cgiFormResultType cgiFormStringSpaceNeeded(
-	char *name, int *length);
+	char *name, int *length,struct cgi_env ** ce);
 
 
@@ -218,5 +148,5 @@
 #endif
 cgiFormResultType cgiFormStringMultiple(
-	char *name, char ***ptrToStringArray);
+	char *name, char ***ptrToStringArray,struct cgi_env ** ce);
 
 extern 
@@ -231,5 +161,5 @@
 #endif
 cgiFormResultType cgiFormInteger(
-	char *name, int *result, int defaultV);
+	char *name, int *result, int defaultV,struct cgi_env ** ce);
 
 extern 
@@ -238,5 +168,5 @@
 #endif
 cgiFormResultType cgiFormIntegerBounded(
-	char *name, int *result, int min, int max, int defaultV);
+	char *name, int *result, int min, int max, int defaultV,struct cgi_env **ce);
 
 extern 
@@ -245,5 +175,5 @@
 #endif
 cgiFormResultType cgiFormDouble(
-	char *name, double *result, double defaultV);
+	char *name, double *result, double defaultV,struct cgi_env **);
 
 extern 
@@ -252,5 +182,5 @@
 #endif
 cgiFormResultType cgiFormDoubleBounded(
-	char *name, double *result, double min, double max, double defaultV);
+	char *name, double *result, double min, double max, double defaultV, struct cgi_env ** ce);
 
 extern 
@@ -260,5 +190,5 @@
 cgiFormResultType cgiFormSelectSingle(
 	char *name, char **choicesText, int choicesTotal, 
-	int *result, int defaultV);	
+	int *result, int defaultV,struct cgi_env **ce);	
 
 
@@ -269,5 +199,5 @@
 cgiFormResultType cgiFormSelectMultiple(
 	char *name, char **choicesText, int choicesTotal, 
-	int *result, int *invalid);
+	int *result, int *invalid,struct cgi_env **);
 
 /* Just an alias; users have asked for this */
@@ -279,5 +209,5 @@
 #endif
 cgiFormResultType cgiFormCheckboxSingle(
-	char *name);
+	char *name,struct cgi_env ** ce);
 
 extern 
@@ -287,5 +217,5 @@
 cgiFormResultType cgiFormCheckboxMultiple(
 	char *name, char **valuesText, int valuesTotal, 
-	int *result, int *invalid);
+	int *result, int *invalid,struct cgi_env ** ce);
 
 extern 
@@ -295,5 +225,5 @@
 cgiFormResultType cgiFormRadio(
 	char *name, char **valuesText, int valuesTotal, 
-	int *result, int defaultV);	
+	int *result, int defaultV,struct cgi_env **ce);	
 
 /* The paths returned by this function are the original names of files
@@ -305,5 +235,5 @@
 #endif
 cgiFormResultType cgiFormFileName(
-	char *name, char *result, int max);
+	char *name, char *result, int max,struct cgi_env **);
 
 /* The content type of the uploaded file, as reported by the browser.
@@ -315,5 +245,5 @@
 #endif
 cgiFormResultType cgiFormFileContentType(
-	char *name, char *result, int max);
+	char *name, char *result, int max,struct cgi_env ** ce);
 
 extern 
@@ -322,5 +252,5 @@
 #endif
 cgiFormResultType cgiFormFileSize(
-	char *name, int *sizeP);
+	char *name, int *sizeP,struct cgi_env ** ce);
 
 typedef struct cgiFileStruct *cgiFilePtr;
@@ -331,5 +261,5 @@
 #endif
 cgiFormResultType cgiFormFileOpen(
-	char *name, cgiFilePtr *cfpp);
+	char *name, cgiFilePtr *cfpp,struct cgi_env ** ce);
 
 extern 
@@ -352,5 +282,5 @@
 #endif
 cgiFormResultType cgiCookieString(
-	char *name, char *result, int max);
+	char *name, char *result, int max,char * cgiCookie);
 
 extern 
@@ -359,8 +289,8 @@
 #endif
 cgiFormResultType cgiCookieInteger(
-	char *name, int *result, int defaultV);
+	char *name, int *result, int defaultV,char * cgiCookie);
 
 cgiFormResultType cgiCookies(
-	char ***ptrToStringArray);
+	char ***ptrToStringArray,char* cgiCookie);
 
 /* path can be null or empty in which case a path of / (entire site) is set. 
@@ -372,5 +302,5 @@
 #endif
 void cgiHeaderCookieSetString(char *name, char *value, 
-	int secondsToLive, char *path, char *domain);
+	int secondsToLive, char *path, char *domain,FCGX_Stream *out);
 extern 
 #ifdef __cplusplus
@@ -378,20 +308,20 @@
 #endif
 void cgiHeaderCookieSetInteger(char *name, int value,
-	int secondsToLive, char *path, char *domain);
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
-void cgiHeaderLocation(char *redirectUrl);
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
-void cgiHeaderStatus(int status, char *statusMessage);
-extern 
-#ifdef __cplusplus
-"C" 
-#endif
-void cgiHeaderContentType(char *mimeType);
+	int secondsToLive, char *path, char *domain,FCGX_Stream *out);
+extern 
+#ifdef __cplusplus
+"C" 
+#endif
+void cgiHeaderLocation(char *redirectUrl,FCGX_Stream * out);
+extern 
+#ifdef __cplusplus
+"C" 
+#endif
+void cgiHeaderStatus(int status, char *statusMessage,FCGX_Stream * out);
+extern 
+#ifdef __cplusplus
+"C" 
+#endif
+void cgiHeaderContentType(char *mimeType,FCGX_Stream * out);
 
 typedef enum {
@@ -421,10 +351,10 @@
 #endif
 cgiFormResultType cgiFormEntries(
-	char ***ptrToStringArray);
+	char ***ptrToStringArray,struct cgi_env **ce);
 
 /* Output string with the <, &, and > characters HTML-escaped. 
 	's' is null-terminated. Returns cgiFormIO in the event
 	of error, cgiFormSuccess otherwise. */
-cgiFormResultType cgiHtmlEscape(char *s);
+cgiFormResultType cgiHtmlEscape(char *s,FCGX_Stream *out);
 
 /* Output data with the <, &, and > characters HTML-escaped. 
@@ -432,5 +362,5 @@
 	bytes in 'data'. Returns cgiFormIO in the event
 	of error, cgiFormSuccess otherwise. */
-cgiFormResultType cgiHtmlEscapeData(char *data, int len);
+cgiFormResultType cgiHtmlEscapeData(char *data, int len,FCGX_Stream *out);
 
 /* Output string with the " character HTML-escaped, and no
@@ -439,5 +369,5 @@
 	's' is null-terminated. Returns cgiFormIO in the event
 	of error, cgiFormSuccess otherwise. */
-cgiFormResultType cgiValueEscape(char *s);
+cgiFormResultType cgiValueEscape(char *s,FCGX_Stream *out);
 
 /* Output data with the " character HTML-escaped, and no
@@ -447,9 +377,9 @@
 	bytes in 'data'. Returns cgiFormIO in the event
 	of error, cgiFormSuccess otherwise. */
-cgiFormResultType cgiValueEscapeData(char *data, int len);
-
-int cgiMain_init(int argc, char *argv[]);
-
-void cgiFreeResources();
+cgiFormResultType cgiValueEscapeData(char *data, int len,FCGX_Stream *out);
+
+int cgiMain_init(int argc, char *argv[],struct cgi_env ** c,FCGX_Request *);
+
+void cgiFreeResources(struct cgi_env ** c);
 
 #endif /* CGI_C */
