mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 16:50:14 +00:00
simplify string parsing routines using ast_skip_*() functions.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45160 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
41
main/http.c
41
main/http.c
@@ -286,13 +286,11 @@ static char *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **
|
|||||||
|
|
||||||
params = strchr(uri, '?');
|
params = strchr(uri, '?');
|
||||||
if (params) {
|
if (params) {
|
||||||
*params = '\0';
|
*params++ = '\0';
|
||||||
params++;
|
|
||||||
while ((var = strsep(¶ms, "&"))) {
|
while ((var = strsep(¶ms, "&"))) {
|
||||||
val = strchr(var, '=');
|
val = strchr(var, '=');
|
||||||
if (val) {
|
if (val) {
|
||||||
*val = '\0';
|
*val++ = '\0';
|
||||||
val++;
|
|
||||||
ast_uri_decode(val);
|
ast_uri_decode(val);
|
||||||
} else
|
} else
|
||||||
val = "";
|
val = "";
|
||||||
@@ -364,36 +362,28 @@ static void *ast_httpd_helper_thread(void *data)
|
|||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
if (fgets(buf, sizeof(buf), ser->f)) {
|
if (fgets(buf, sizeof(buf), ser->f)) {
|
||||||
/* Skip method */
|
uri = ast_skip_nonblanks(buf); /* Skip method */
|
||||||
uri = buf;
|
if (*uri)
|
||||||
while(*uri && (*uri > 32))
|
*uri++ = '\0';
|
||||||
uri++;
|
|
||||||
if (*uri) {
|
|
||||||
*uri = '\0';
|
|
||||||
uri++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip white space */
|
uri = ast_skip_blanks(uri); /* Skip white space */
|
||||||
while (*uri && (*uri < 33))
|
|
||||||
uri++;
|
|
||||||
|
|
||||||
if (*uri) {
|
if (*uri) { /* terminate at the first blank */
|
||||||
c = uri;
|
c = ast_skip_nonblanks(uri);
|
||||||
while (*c && (*c > 32))
|
if (*c)
|
||||||
c++;
|
|
||||||
if (*c) {
|
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* process "Cookie: " lines */
|
||||||
while (fgets(cookie, sizeof(cookie), ser->f)) {
|
while (fgets(cookie, sizeof(cookie), ser->f)) {
|
||||||
/* Trim trailing characters */
|
/* Trim trailing characters */
|
||||||
while(!ast_strlen_zero(cookie) && (cookie[strlen(cookie) - 1] < 33)) {
|
ast_trim_blanks(cookie);
|
||||||
cookie[strlen(cookie) - 1] = '\0';
|
|
||||||
}
|
|
||||||
if (ast_strlen_zero(cookie))
|
if (ast_strlen_zero(cookie))
|
||||||
break;
|
break;
|
||||||
if (!strncasecmp(cookie, "Cookie: ", 8)) {
|
if (strncasecmp(cookie, "Cookie: ", 8))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* XXX fix indentation */
|
||||||
|
|
||||||
/* TODO - The cookie parsing code below seems to work
|
/* TODO - The cookie parsing code below seems to work
|
||||||
in IE6 and FireFox 1.5. However, it is not entirely
|
in IE6 and FireFox 1.5. However, it is not entirely
|
||||||
@@ -440,7 +430,6 @@ static void *ast_httpd_helper_thread(void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*uri) {
|
if (*uri) {
|
||||||
|
|||||||
Reference in New Issue
Block a user