version 1.1.1.1.2.1, 2012/03/09 09:38:55
|
version 1.1.1.1.2.3, 2012/03/09 12:33:41
|
Line 324 www_addValue(cgi_t * __restrict cgi, const char *name,
|
Line 324 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 332 www_delPair(cgi_t * __restrict cgi, const char *name)
|
Line 332 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; |
} |
} |
|
|
return 0; |
return 0; |
|
} |
|
|
|
/* |
|
* 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; |
} |
} |
|
|
/* |
/* |