Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: CVS

svn commit: r834006 - /httpd/httpd/trunk/modules/loggers/mod_log_config.c

 

 

Apache cvs RSS feed   Index | Next | Previous | View Threaded


sf at apache

Nov 9, 2009, 2:00 AM

Post #1 of 1 (127 views)
Permalink
svn commit: r834006 - /httpd/httpd/trunk/modules/loggers/mod_log_config.c

Author: sf
Date: Mon Nov 9 09:59:53 2009
New Revision: 834006

URL: http://svn.apache.org/viewvc?rev=834006&view=rev
Log:
Simplify code by using apr_strtok

Modified:
httpd/httpd/trunk/modules/loggers/mod_log_config.c

Modified: httpd/httpd/trunk/modules/loggers/mod_log_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/loggers/mod_log_config.c?rev=834006&r1=834005&r2=834006&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/loggers/mod_log_config.c (original)
+++ httpd/httpd/trunk/modules/loggers/mod_log_config.c Mon Nov 9 09:59:53 2009
@@ -496,7 +496,7 @@

static const char *log_cookie(request_rec *r, char *a)
{
- const char *cookies;
+ const char *cookies_entry;

/*
* This supports Netscape version 0 cookies while being tolerant to
@@ -508,31 +508,20 @@
* - commas to separate cookies
*/

- if ((cookies = apr_table_get(r->headers_in, "Cookie"))) {
- const char *cookie;
- const char *cookie_end;
- const char *cp;
- int a_len = strlen(a);
- /*
- * Loop over semicolon-separated cookies.
- */
- for (cookie = cookies; *cookie != '\0'; cookie = cookie_end + strspn(cookie_end, "; \t")) {
- /* Loop invariant: "cookie" always points to start of cookie name */
-
- /* Set cookie_end to ';' that ends this cookie, or '\0' at EOS */
- cookie_end = cookie + strcspn(cookie, ";");
-
- cp = cookie + a_len;
- if (cp >= cookie_end)
- continue;
- cp += strspn(cp, " \t");
- if (*cp == '=' && !strncasecmp(cookie, a, a_len)) {
- char *cookie_value;
- cp++; /* Move past '=' */
- cp += strspn(cp, " \t"); /* Move past WS */
- cookie_value = apr_pstrmemdup(r->pool, cp, cookie_end - cp);
- return ap_escape_logitem(r->pool, cookie_value);
- }
+ if ((cookies_entry = apr_table_get(r->headers_in, "Cookie"))) {
+ char *cookie, *last1, *last2;
+ char *cookies = apr_pstrdup(r->pool, cookies_entry);
+
+ while ((cookie = apr_strtok(cookies, ";", &last1))) {
+ char *name = apr_strtok(cookie, "=", &last2);
+ char *value;
+ apr_collapse_spaces(name, name);
+
+ if (!strcasecmp(name, a) && (value = apr_strtok(NULL, "=", &last2))) {
+ value += strspn(value, " \t"); /* Move past WS */
+ return ap_escape_logitem(r->pool, value);
+ }
+ cookies = NULL;
}
}
return NULL;

Apache cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.