aboutsummaryrefslogtreecommitdiffstats
path: root/main/http.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-16 06:30:51 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-16 06:30:51 +0000
commitf326543d3c3d04d1af96881181015cc3e6f17ba8 (patch)
tree505f78b8a9d631149385ec765a3b3c94b88e0582 /main/http.c
parent8b4ea6655612f64276672c0a2cdc5a636482a38d (diff)
simplify string parsing routines using ast_skip_*() functions.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45160 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/http.c')
-rw-r--r--main/http.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/main/http.c b/main/http.c
index 26a443853..3e30ee652 100644
--- a/main/http.c
+++ b/main/http.c
@@ -286,13 +286,11 @@ static char *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **
params = strchr(uri, '?');
if (params) {
- *params = '\0';
- params++;
+ *params++ = '\0';
while ((var = strsep(&params, "&"))) {
val = strchr(var, '=');
if (val) {
- *val = '\0';
- val++;
+ *val++ = '\0';
ast_uri_decode(val);
} else
val = "";
@@ -364,36 +362,28 @@ static void *ast_httpd_helper_thread(void *data)
time_t t;
if (fgets(buf, sizeof(buf), ser->f)) {
- /* Skip method */
- uri = buf;
- while(*uri && (*uri > 32))
- uri++;
- if (*uri) {
- *uri = '\0';
- uri++;
- }
+ uri = ast_skip_nonblanks(buf); /* Skip method */
+ if (*uri)
+ *uri++ = '\0';
- /* Skip white space */
- while (*uri && (*uri < 33))
- uri++;
+ uri = ast_skip_blanks(uri); /* Skip white space */
- if (*uri) {
- c = uri;
- while (*c && (*c > 32))
- c++;
- if (*c) {
+ if (*uri) { /* terminate at the first blank */
+ c = ast_skip_nonblanks(uri);
+ if (*c)
*c = '\0';
- }
}
+ /* process "Cookie: " lines */
while (fgets(cookie, sizeof(cookie), ser->f)) {
/* Trim trailing characters */
- while(!ast_strlen_zero(cookie) && (cookie[strlen(cookie) - 1] < 33)) {
- cookie[strlen(cookie) - 1] = '\0';
- }
+ ast_trim_blanks(cookie);
if (ast_strlen_zero(cookie))
break;
- if (!strncasecmp(cookie, "Cookie: ", 8)) {
+ if (strncasecmp(cookie, "Cookie: ", 8))
+ continue;
+
+ /* XXX fix indentation */
/* TODO - The cookie parsing code below seems to work
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) {