* Decode multipart/form-data
*/
#define MULTIPART_DELTA 5
-s_var **cgiReadMultipart (char *boundary)
+s_cgi *cgiReadMultipart (char *boundary)
{
char *line;
char *cp, *xp;
int numresults = 0, current = 0;
int index = 0;
size_t len;
+ s_cgi *res;
while ((line = cgiGetLine (stdin)) != NULL) {
}
- return result;
+ if ((res = (s_cgi *)malloc (sizeof (s_cgi))) == NULL)
+ return NULL;
+
+ res->vars = result;
+ res->cookies = NULL;
+ res->files = NULL;
+
+ return res;
}
/* cgiReadVariables()
* Read from stdin if no string is provided via CGI. Variables that
* doesn't have a value associated with it doesn't get stored.
*/
-s_var **cgiReadVariables ()
+s_cgi *cgiReadVariables ()
{
int length;
char *line = NULL;
s_var **result;
int i, k, len;
char tmp[101];
+ s_cgi *res;
cp = getenv("CONTENT_TYPE");
cgiDebugOutput (2, "Content-Type: %s", cp);
}
cp = ++ip;
}
- return result;
+
+ if ((res = (s_cgi *)malloc (sizeof (s_cgi))) == NULL)
+ return NULL;
+
+ res->vars = result;
+ res->cookies = NULL;
+ res->files = NULL;
+
+ return res;
}
/* cgiInit()
s_cgi *cgiInit()
{
s_cgi *res;
- s_var **vars;
- s_cookie **cookies;
- vars = cgiReadVariables ();
- cookies = cgiReadCookies ();
+ res = cgiReadVariables ();
+ res->cookies = cgiReadCookies ();
- if (!vars && !cookies)
+ if (!res->vars && !res->cookies && !res->files) {
+ free (res);
return NULL;
-
- if ((res = (s_cgi *)malloc (sizeof (s_cgi))) == NULL)
- return NULL;
- res->vars = vars;
- res->cookies = cookies;
+ }
return res;
}