version 1.3.4.2, 2012/07/31 22:59:33
|
version 1.4.6.1, 2013/01/17 14:52:44
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 130 www_initCGI(void)
|
Line 130 www_initCGI(void)
|
} |
} |
|
|
/* allocated space for post data */ |
/* allocated space for post data */ |
str = io_malloc(ctlen + 1); | str = e_malloc(ctlen + 1); |
if (!str) { |
if (!str) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
return NULL; |
return NULL; |
} else |
} else |
memset(str, 0, ctlen + 1); |
memset(str, 0, ctlen + 1); |
Line 145 www_initCGI(void)
|
Line 145 www_initCGI(void)
|
else if (!www_cmp(s, "multipart/form-data")) |
else if (!www_cmp(s, "multipart/form-data")) |
cgi = www_parseMultiPart(str, ctlen, s); |
cgi = www_parseMultiPart(str, ctlen, s); |
|
|
io_free(str); | e_free(str); |
} else { |
} else { |
/* Unknown method */ |
/* Unknown method */ |
www_SetErr(EFAULT, "Unknown request method"); |
www_SetErr(EFAULT, "Unknown request method"); |
Line 170 www_closeCGI(cgi_t ** __restrict cgi)
|
Line 170 www_closeCGI(cgi_t ** __restrict cgi)
|
return; |
return; |
|
|
while ((t = SLIST_FIRST(*cgi))) { |
while ((t = SLIST_FIRST(*cgi))) { |
io_freeVar(&t->cgi_name); | ait_freeVar(&t->cgi_name); |
io_freeVar(&t->cgi_value); | ait_freeVar(&t->cgi_value); |
|
|
SLIST_REMOVE_HEAD(*cgi, cgi_node); |
SLIST_REMOVE_HEAD(*cgi, cgi_node); |
io_free(t); | e_free(t); |
} |
} |
|
|
io_free(*cgi); | e_free(*cgi); |
*cgi = NULL; |
*cgi = NULL; |
} |
} |
|
|
Line 199 www_parseQuery(const char *str)
|
Line 199 www_parseQuery(const char *str)
|
return NULL; |
return NULL; |
} |
} |
|
|
cgi = io_malloc(sizeof(cgi_t)); | cgi = e_malloc(sizeof(cgi_t)); |
if (!cgi) { |
if (!cgi) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
return NULL; |
return NULL; |
} else { |
} else { |
memset(cgi, 0, sizeof(cgi_t)); |
memset(cgi, 0, sizeof(cgi_t)); |
SLIST_INIT(cgi); |
SLIST_INIT(cgi); |
} |
} |
|
|
base = wrk = io_strdup(str); | base = wrk = e_strdup(str); |
|
|
while (*wrk) { |
while (*wrk) { |
t = io_malloc(sizeof(struct tagCGI)); | t = e_malloc(sizeof(struct tagCGI)); |
if (!t) { |
if (!t) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
www_closeCGI(&cgi); |
www_closeCGI(&cgi); |
return NULL; |
return NULL; |
} else |
} else |
Line 232 www_parseQuery(const char *str)
|
Line 232 www_parseQuery(const char *str)
|
old = t; |
old = t; |
} |
} |
|
|
io_free(base); | e_free(base); |
return cgi; |
return cgi; |
} |
} |
|
|
Line 292 www_addValue(cgi_t * __restrict cgi, const char *name,
|
Line 292 www_addValue(cgi_t * __restrict cgi, const char *name,
|
} |
} |
|
|
/* add new one */ |
/* add new one */ |
tmp = io_malloc(sizeof(struct tagCGI)); | tmp = e_malloc(sizeof(struct tagCGI)); |
if (!tmp) { |
if (!tmp) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
return -1; |
return -1; |
} else |
} else |
memset(tmp, 0, sizeof(struct tagCGI)); |
memset(tmp, 0, sizeof(struct tagCGI)); |
|
|
tmp->cgi_name = io_allocVar(); | tmp->cgi_name = ait_allocVar(); |
if (!tmp->cgi_name) { |
if (!tmp->cgi_name) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
io_free(tmp); | e_free(tmp); |
return -1; |
return -1; |
} else |
} else |
AIT_SET_STR(tmp->cgi_name, name); |
AIT_SET_STR(tmp->cgi_name, name); |
tmp->cgi_value = io_allocVar(); | tmp->cgi_value = ait_allocVar(); |
if (!tmp->cgi_name) { |
if (!tmp->cgi_name) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
io_freeVar(&tmp->cgi_name); | ait_freeVar(&tmp->cgi_name); |
io_free(tmp); | e_free(tmp); |
return -1; |
return -1; |
} else |
} else |
AIT_SET_STR(tmp->cgi_value, value); |
AIT_SET_STR(tmp->cgi_value, value); |
Line 344 www_delPair(cgi_t * __restrict cgi, const char *name)
|
Line 344 www_delPair(cgi_t * __restrict cgi, const char *name)
|
if (t->cgi_name && !strcmp(name, AIT_GET_STR(t->cgi_name))) { |
if (t->cgi_name && !strcmp(name, AIT_GET_STR(t->cgi_name))) { |
SLIST_REMOVE(cgi, t, tagCGI, cgi_node); |
SLIST_REMOVE(cgi, t, tagCGI, cgi_node); |
|
|
io_freeVar(&t->cgi_name); | ait_freeVar(&t->cgi_name); |
io_freeVar(&t->cgi_value); | ait_freeVar(&t->cgi_value); |
io_free(t); | e_free(t); |
return 1; |
return 1; |
} |
} |
|
|
Line 408 quotStr(const char *str, const char **end)
|
Line 408 quotStr(const char *str, const char **end)
|
if (*str != '"') { |
if (*str != '"') { |
n = strspn(str, "!#$%&'*+-.0123456789?ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
n = strspn(str, "!#$%&'*+-.0123456789?ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
"^_`abcdefghijklmnopqrstuvwxyz{|}~"); |
"^_`abcdefghijklmnopqrstuvwxyz{|}~"); |
s = io_allocVar(); | s = ait_allocVar(); |
if (!s) { |
if (!s) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
return NULL; |
return NULL; |
} else { |
} else { |
AIT_SET_STRSIZ(s, n + 1); |
AIT_SET_STRSIZ(s, n + 1); |
Line 426 quotStr(const char *str, const char **end)
|
Line 426 quotStr(const char *str, const char **end)
|
else |
else |
len = e - str; |
len = e - str; |
|
|
s = io_allocVar(); | s = ait_allocVar(); |
if (!s) { |
if (!s) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
return NULL; |
return NULL; |
} else { |
} else { |
AIT_SET_STRSIZ(s, len + 1); |
AIT_SET_STRSIZ(s, len + 1); |
Line 460 addAttr(const char **ct)
|
Line 460 addAttr(const char **ct)
|
return NULL; |
return NULL; |
else |
else |
c++; |
c++; |
while (isspace(*c)) | while (isspace((int) *c)) |
c++; |
c++; |
|
|
if (!(eq = strchr(c, '='))) |
if (!(eq = strchr(c, '='))) |
return NULL; |
return NULL; |
|
|
a = io_malloc(sizeof(struct tagCGI)); | a = e_malloc(sizeof(struct tagCGI)); |
if (!a) { |
if (!a) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
return NULL; |
return NULL; |
} |
} |
a->cgi_name = io_allocVar(); | a->cgi_name = ait_allocVar(); |
if (!a->cgi_name) { |
if (!a->cgi_name) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
io_free(a); | e_free(a); |
return NULL; |
return NULL; |
} |
} |
|
|
Line 482 addAttr(const char **ct)
|
Line 482 addAttr(const char **ct)
|
AIT_SET_STR(a->cgi_name, c); |
AIT_SET_STR(a->cgi_name, c); |
a->cgi_value = quotStr(eq, &c); |
a->cgi_value = quotStr(eq, &c); |
if (!a->cgi_value) { |
if (!a->cgi_value) { |
io_freeVar(&a->cgi_name); | ait_freeVar(&a->cgi_name); |
io_free(a); | e_free(a); |
return NULL; |
return NULL; |
} |
} |
|
|
Line 515 www_parseMultiPart(const char *str, int ctlen, const c
|
Line 515 www_parseMultiPart(const char *str, int ctlen, const c
|
return NULL; |
return NULL; |
} |
} |
|
|
cgi = io_malloc(sizeof(cgi_t)); | cgi = e_malloc(sizeof(cgi_t)); |
if (!cgi) { |
if (!cgi) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
return NULL; |
return NULL; |
} else { |
} else { |
memset(cgi, 0, sizeof(cgi_t)); |
memset(cgi, 0, sizeof(cgi_t)); |
Line 546 www_parseMultiPart(const char *str, int ctlen, const c
|
Line 546 www_parseMultiPart(const char *str, int ctlen, const c
|
continue; |
continue; |
} |
} |
|
|
t = io_malloc(sizeof(struct tagCGI)); | t = e_malloc(sizeof(struct tagCGI)); |
if (!t) { |
if (!t) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
mime_close(&mime); |
mime_close(&mime); |
www_closeCGI(&cgi); |
www_closeCGI(&cgi); |
return NULL; |
return NULL; |
Line 557 www_parseMultiPart(const char *str, int ctlen, const c
|
Line 557 www_parseMultiPart(const char *str, int ctlen, const c
|
|
|
AIT_COPY_VAL(t->cgi_name, www_getAttribute(attr, "name")); |
AIT_COPY_VAL(t->cgi_name, www_getAttribute(attr, "name")); |
len = mime_calcRawSize(m); |
len = mime_calcRawSize(m); |
t->cgi_value = io_allocVar(); | t->cgi_value = ait_allocVar(); |
if (!t->cgi_value) { |
if (!t->cgi_value) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
io_freeVar(&t->cgi_name); | ait_freeVar(&t->cgi_name); |
io_free(t); | e_free(t); |
mime_close(&mime); |
mime_close(&mime); |
www_closeCGI(&cgi); |
www_closeCGI(&cgi); |
return NULL; |
return NULL; |
Line 600 www_parseAttributes(const char **ct)
|
Line 600 www_parseAttributes(const char **ct)
|
return NULL; |
return NULL; |
} |
} |
|
|
attr = io_malloc(sizeof(cgi_t)); | attr = e_malloc(sizeof(cgi_t)); |
if (!attr) { |
if (!attr) { |
www_SetErr(io_GetErrno(), "%s", io_GetError()); | www_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); |
return NULL; |
return NULL; |
} else { |
} else { |
memset(attr, 0, sizeof(cgi_t)); |
memset(attr, 0, sizeof(cgi_t)); |