[asterisk-commits] rizzo: trunk r45160 - /trunk/main/http.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Oct 15 23:30:52 MST 2006


Author: rizzo
Date: Mon Oct 16 01:30:51 2006
New Revision: 45160

URL: http://svn.digium.com/view/asterisk?rev=45160&view=rev
Log:
simplify string parsing routines using ast_skip_*() functions.


Modified:
    trunk/main/http.c

Modified: trunk/main/http.c
URL: http://svn.digium.com/view/asterisk/trunk/main/http.c?rev=45160&r1=45159&r2=45160&view=diff
==============================================================================
--- trunk/main/http.c (original)
+++ trunk/main/http.c Mon Oct 16 01:30:51 2006
@@ -286,13 +286,11 @@
 	
 	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 @@
 	time_t t;
 
 	if (fgets(buf, sizeof(buf), ser->f)) {
-		/* Skip method */
-		uri = buf;
-		while(*uri && (*uri > 32))
-			uri++;
-		if (*uri) {
-			*uri = '\0';
-			uri++;
-		}
-
-		/* Skip white space */
-		while (*uri && (*uri < 33))
-			uri++;
-
-		if (*uri) {
-			c = uri;
-			while (*c && (*c > 32))
-				 c++;
-			if (*c) {
+		uri = ast_skip_nonblanks(buf);	/* Skip method */
+		if (*uri)
+			*uri++ = '\0';
+
+		uri = ast_skip_blanks(uri);	/* Skip white space */
+
+		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 @@
 						}
 					}
 				}
-			}
 		}
 
 		if (*uri) {



More information about the asterisk-commits mailing list