version 1.1, 2012/03/08 23:40:21
|
version 1.1.1.1.2.6, 2012/03/09 16:09:38
|
Line 135 www_initCGI(void)
|
Line 135 www_initCGI(void)
|
if (!str) { |
if (!str) { |
LOGERR; |
LOGERR; |
return NULL; |
return NULL; |
} | } else |
| memset(str, 0, ctlen + 1); |
for (i = 0; i < ctlen && (rlen = |
for (i = 0; i < ctlen && (rlen = |
read(STDIN_FILENO, (void*) str + i, ctlen - i)) > 0; i += rlen); |
read(STDIN_FILENO, (void*) str + i, ctlen - i)) > 0; i += rlen); |
str[ctlen] = 0; |
str[ctlen] = 0; |
Line 235 www_parseQuery(const char *str)
|
Line 236 www_parseQuery(const char *str)
|
} |
} |
|
|
free(base); |
free(base); |
return 0; | return cgi; |
} |
} |
|
|
/* |
/* |
Line 257 www_getValue(cgi_t * __restrict cgi, const char *name)
|
Line 258 www_getValue(cgi_t * __restrict cgi, const char *name)
|
|
|
SLIST_FOREACH(t, cgi, cgi_node) |
SLIST_FOREACH(t, cgi, cgi_node) |
if (t->cgi_name && !strcmp(name, t->cgi_name)) |
if (t->cgi_name && !strcmp(name, t->cgi_name)) |
break; | return t->cgi_value; |
|
|
return t->cgi_value; | return NULL; |
} |
} |
|
|
/* |
/* |
Line 307 www_addValue(cgi_t * __restrict cgi, const char *name,
|
Line 308 www_addValue(cgi_t * __restrict cgi, const char *name,
|
if (value) |
if (value) |
tmp->cgi_value = strdup(value); |
tmp->cgi_value = strdup(value); |
|
|
SLIST_INSERT_AFTER(t, tmp, cgi_node); | if (!t) |
| SLIST_INSERT_HEAD(cgi, tmp, cgi_node); |
| else |
| SLIST_INSERT_AFTER(t, tmp, cgi_node); |
return 0; |
return 0; |
} |
} |
|
|
Line 321 www_addValue(cgi_t * __restrict cgi, const char *name,
|
Line 325 www_addValue(cgi_t * __restrict cgi, const char *name,
|
int |
int |
www_delPair(cgi_t * __restrict cgi, const char *name) |
www_delPair(cgi_t * __restrict cgi, const char *name) |
{ |
{ |
struct tagCGI *t; | struct tagCGI *t, *tmp; |
|
|
if (!cgi || !name) { |
if (!cgi || !name) { |
www_SetErr(EINVAL, "Invalid argument(s)"); |
www_SetErr(EINVAL, "Invalid argument(s)"); |
Line 329 www_delPair(cgi_t * __restrict cgi, const char *name)
|
Line 333 www_delPair(cgi_t * __restrict cgi, const char *name)
|
} |
} |
|
|
/* search for delete */ |
/* search for delete */ |
SLIST_FOREACH(t, cgi, cgi_node) | SLIST_FOREACH_SAFE(t, cgi, cgi_node, tmp) |
if (t->cgi_name && !strcmp(name, t->cgi_name)) { |
if (t->cgi_name && !strcmp(name, t->cgi_name)) { |
SLIST_REMOVE(cgi, t, tagCGI, cgi_node); |
SLIST_REMOVE(cgi, t, tagCGI, cgi_node); |
|
|
|
if (t->cgi_name) |
|
free(t->cgi_name); |
|
if (t->cgi_value) |
|
free(t->cgi_value); |
|
free(t); |
return 1; |
return 1; |
} |
} |
|
|
Line 339 www_delPair(cgi_t * __restrict cgi, const char *name)
|
Line 349 www_delPair(cgi_t * __restrict cgi, const char *name)
|
} |
} |
|
|
/* |
/* |
|
* www_listPairs() - Walk over CGI session variables |
|
* |
|
* @cgi = Cgi session |
|
* @func = If !=NULL call function for each element |
|
* @arg = Optional argument pass through callback |
|
* return: -1 error or >-1 number of elements |
|
*/ |
|
inline int |
|
www_listPairs(cgi_t * __restrict cgi, list_cb_t func, void *arg) |
|
{ |
|
register int ret = 0; |
|
struct tagCGI *t; |
|
|
|
if (!cgi) { |
|
www_SetErr(EINVAL, "Invalid CGI session argument"); |
|
return -1; |
|
} |
|
|
|
SLIST_FOREACH(t, cgi, cgi_node) { |
|
ret++; |
|
|
|
if (func) |
|
func(t, arg); |
|
} |
|
|
|
return ret; |
|
} |
|
|
|
/* |
* www_header() - Output initial html header |
* www_header() - Output initial html header |
* |
* |
* @output = file handle |
* @output = file handle |
Line 486 www_parseMultiPart(const char *str, int ctlen, const c
|
Line 525 www_parseMultiPart(const char *str, int ctlen, const c
|
} |
} |
mime = mime_parseMultiPart(str, ctlen, www_getAttribute(attr, "boundary"), NULL); |
mime = mime_parseMultiPart(str, ctlen, www_getAttribute(attr, "boundary"), NULL); |
www_freeAttributes(&attr); |
www_freeAttributes(&attr); |
|
if (!mime) { |
|
www_closeCGI(&cgi); |
|
return NULL; |
|
} |
|
|
SLIST_FOREACH(m, mime, mime_node) { |
SLIST_FOREACH(m, mime, mime_node) { |
s = mime_getValue(m, "content-disposition"); |
s = mime_getValue(m, "content-disposition"); |
attr = www_parseAttributes(&s); |
attr = www_parseAttributes(&s); |
|
if (!www_getAttribute(attr, "name")) { |
|
www_freeAttributes(&attr); |
|
continue; |
|
} |
|
|
t = malloc(sizeof(struct tagCGI)); |
t = malloc(sizeof(struct tagCGI)); |
if (!t) { |
if (!t) { |