Style cosmetics for the IPv6 code.
authorFabian Keil <fk@fabiankeil.de>
Fri, 17 Apr 2009 11:34:35 +0000 (11:34 +0000)
committerFabian Keil <fk@fabiankeil.de>
Fri, 17 Apr 2009 11:34:35 +0000 (11:34 +0000)
filters.c
jbsockets.c
jcc.c
loadcfg.c
project.h
urlmatch.c

index 15dba3d..c5d8d6e 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -1,4 +1,4 @@
-const char filters_rcs[] = "$Id: filters.c,v 1.114 2009/04/17 11:27:49 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.115 2009/04/17 11:29:18 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
@@ -40,6 +40,9 @@ const char filters_rcs[] = "$Id: filters.c,v 1.114 2009/04/17 11:27:49 fabiankei
  *
  * Revisions   :
  *    $Log: filters.c,v $
+ *    Revision 1.115  2009/04/17 11:29:18  fabiankeil
+ *    Compile fix for BSD libc.
+ *
  *    Revision 1.114  2009/04/17 11:27:49  fabiankeil
  *    Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
  *
@@ -734,13 +737,13 @@ static jb_err prepare_for_filtering(struct client_state *csp);
  *          3  :  len  = length of IP address in octets
  *          4  :  port = port number in network order;
  *
- * Returns     :  0 = no errror; otherwise 
+ * Returns     :  0 = no errror; -1 otherwise.
  *
  *********************************************************************/
 int sockaddr_storage_to_ip(const struct sockaddr_storage *addr, uint8_t **ip,
       unsigned int *len, in_port_t **port)
 {
-   if (!addr)
+   if (NULL == addr)
    {
       return(-1);
    }
@@ -748,33 +751,33 @@ int sockaddr_storage_to_ip(const struct sockaddr_storage *addr, uint8_t **ip,
    switch (addr->ss_family)
    {
       case AF_INET:
-         if (len)
+         if (NULL != len)
          {
             *len = 4;
          }
-         if (ip)
+         if (NULL != ip)
          {
             *ip = (uint8_t *)
-               &(( (struct sockaddr_in *) addr)->sin_addr.s_addr);
+               &(((struct sockaddr_in *)addr)->sin_addr.s_addr);
          }
-         if (port)
+         if (NULL != port)
          {
-            *port = &((struct sockaddr_in *) addr)->sin_port;
+            *port = &((struct sockaddr_in *)addr)->sin_port;
          }
          break;
 
       case AF_INET6:
-         if (len)
+         if (NULL != len)
          {
             *len = 16;
          }
-         if (ip)
+         if (NULL != ip)
          {
-            *ip = ( (struct sockaddr_in6 *) addr)->sin6_addr.s6_addr;
+            *ip = ((struct sockaddr_in6 *)addr)->sin6_addr.s6_addr;
          }
-         if (port)
+         if (NULL != port)
          {
-            *port = &((struct sockaddr_in6 *) addr)->sin6_port;
+            *port = &((struct sockaddr_in6 *)addr)->sin6_port;
          }
          break;
 
@@ -795,8 +798,8 @@ int sockaddr_storage_to_ip(const struct sockaddr_storage *addr, uint8_t **ip,
  *
  * Parameters  :
  *          1  :  network = socket address of subnework
- *          3  :  netmask = network mask as socket address 
- *          2  :  address = checked socket address against given network
+ *          2  :  netmask = network mask as socket address
+ *          3  :  address = checked socket address against given network
  *
  * Returns     :  0 = doesn't match; 1 = does match
  *
@@ -810,12 +813,12 @@ int match_sockaddr(const struct sockaddr_storage *network,
    in_port_t *network_port, *netmask_port, *address_port;
    int i;
 
-   if (network->ss_family != netmask->ss_family) 
+   if (network->ss_family != netmask->ss_family)
    {
       /* This should never happen */
       log_error(LOG_LEVEL_ERROR,
-            "Internal error at %s:%llu: network and netmask differ in family",
-            __FILE__, __LINE__);
+         "Internal error at %s:%llu: network and netmask differ in family",
+         __FILE__, __LINE__);
       return 0;
    }
 
@@ -824,15 +827,15 @@ int match_sockaddr(const struct sockaddr_storage *network,
    sockaddr_storage_to_ip(address, &address_addr, NULL, &address_port);
 
    /* Check for family */
-   if (network->ss_family == AF_INET && address->ss_family == AF_INET6 &&
-         IN6_IS_ADDR_V4MAPPED((struct in6_addr *)address_addr))
+   if ((network->ss_family == AF_INET) && (address->ss_family == AF_INET6)
+      && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)address_addr))
    {
       /* Map AF_INET6 V4MAPPED address into AF_INET */
       address_addr += 12;
       addr_len = 4;
    }
-   else if (network->ss_family == AF_INET6 && address->ss_family == AF_INET &&
-         IN6_IS_ADDR_V4MAPPED((struct in6_addr *)network_addr))
+   else if ((network->ss_family == AF_INET6) && (address->ss_family == AF_INET)
+      && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)network_addr))
    {
       /* Map AF_INET6 V4MAPPED network into AF_INET */
       network_addr += 12;
@@ -851,15 +854,15 @@ int match_sockaddr(const struct sockaddr_storage *network,
    }
 
    /* TODO: Optimize by checking by words insted of octets */
-   for (i=0; i < addr_len && netmask_addr[i]; i++)
+   for (i = 0; (i < addr_len) && netmask_addr[i]; i++)
    {
-      if ( (network_addr[i] & netmask_addr[i]) !=
-           (address_addr[i] & netmask_addr[i]) )
+      if ((network_addr[i] & netmask_addr[i]) !=
+          (address_addr[i] & netmask_addr[i]))
       {
          return 0;
       }
    }
-   
+
    return 1;
 }
 #endif /* def HAVE_GETADDRINFO */
@@ -896,7 +899,7 @@ int block_acl(const struct access_control_addr *dst, const struct client_state *
    {
       if (
 #ifdef HAVE_GETADDRINFO
-            match_sockaddr(&acl->src->addr, &acl->src->mask, &csp->tcp_addr) 
+            match_sockaddr(&acl->src->addr, &acl->src->mask, &csp->tcp_addr)
 #else
             (csp->ip_addr_long & acl->src->mask) == acl->src->addr
 #endif
@@ -912,11 +915,11 @@ int block_acl(const struct access_control_addr *dst, const struct client_state *
          }
          else if (
 #ifdef HAVE_GETADDRINFO
-               /* XXX: Undefined acl->dst is full of zeros and should be
-                * considered as wildcard address.
-                * sockaddr_storage_to_ip() failes on such dst because of
-                * uknown sa_familly on glibc. However this test is not
-                * portable.
+               /*
+                * XXX: An undefined acl->dst is full of zeros and should be
+                * considered a wildcard address. sockaddr_storage_to_ip()
+                * fails on such destinations because of unknown sa_familly
+                * (glibc only?). However this test is not portable.
                 *
                 * So, we signal the acl->dst is wildcard in wildcard_dst.
                 */
@@ -974,7 +977,7 @@ int acl_addr(const char *aspec, struct access_control_addr *aca)
    char *acl_spec = NULL;
 
 #ifdef HAVE_GETADDRINFO
-   /* FIXME: Depend on ai_family */
+   /* XXX: Depend on ai_family */
    masklength = 128;
 #else
    masklength = 32;
@@ -1015,10 +1018,10 @@ int acl_addr(const char *aspec, struct access_control_addr *aca)
       return(-1);
    }
 
-   if (*acl_spec == '[' && NULL != (p = strchr(acl_spec, ']')))
+   if ((*acl_spec == '[') && (NULL != (p = strchr(acl_spec, ']'))))
    {
       *p = '\0';
-      memmove(acl_spec, acl_spec + 1, (size_t) (p - acl_spec));
+      memmove(acl_spec, acl_spec + 1, (size_t)(p - acl_spec));
 
       if (*++p != ':')
       {
@@ -1035,13 +1038,13 @@ int acl_addr(const char *aspec, struct access_control_addr *aca)
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
 
-   i = getaddrinfo(acl_spec, (p) ? ++p : NULL, &hints, &result);
+   i = getaddrinfo(acl_spec, ((p) ? ++p : NULL), &hints, &result);
    freez(acl_spec);
 
    if (i != 0)
    {
-      log_error(LOG_LEVEL_ERROR, "Can not resolve [%s]:%s: %s", acl_spec, p,
-            gai_strerror(i));
+      log_error(LOG_LEVEL_ERROR, "Can not resolve [%s]:%s: %s",
+         acl_spec, p, gai_strerror(i));
       return(-1);
    }
 
@@ -1077,8 +1080,8 @@ int acl_addr(const char *aspec, struct access_control_addr *aca)
 
    /* build the netmask */
 #ifdef HAVE_GETADDRINFO
-   /* Clip masklength according current family */
-   if (aca->addr.ss_family == AF_INET && masklength > 32)
+   /* Clip masklength according to current family. */
+   if ((aca->addr.ss_family == AF_INET) && (masklength > 32))
    {
       masklength = 32;
    }
@@ -1091,15 +1094,19 @@ int acl_addr(const char *aspec, struct access_control_addr *aca)
 
    if (p)
    {
-      /* Port number in ACL has been specified, check ports in future */
+      /* ACL contains a port number, check ports in the future. */
       *mask_port = 1;
    }
 
-   /* XXX: This could be optimized to operate on whole words instead of octets
-    * (128-bit CPU could do it in one iteration). */
-   /* Octets after prefix can be ommitted because of previous initialization
-    * to zeros. */
-   for (i=0; i < addr_len && masklength; i++)
+   /*
+    * XXX: This could be optimized to operate on whole words instead
+    * of octets (128-bit CPU could do it in one iteration).
+    */
+   /*
+    * Octets after prefix can be ommitted because of
+    * previous initialization to zeros.
+    */
+   for (i = 0; (i < addr_len) && masklength; i++)
    {
       if (masklength >= 8)
       {
@@ -1108,8 +1115,11 @@ int acl_addr(const char *aspec, struct access_control_addr *aca)
       }
       else
       {
-         /* XXX: This assumes MSB of octet is on the left site. This should be
-          * true for all architectures or solved on link layer of OSI model. */
+         /*
+          * XXX: This assumes MSB of octet is on the left side.
+          * This should be true for all architectures or solved
+          * by the link layer.
+          */
          mask_data[i] = ~((1 << (8 - masklength)) - 1);
          masklength = 0;
       }
@@ -2974,6 +2984,4 @@ int content_filters_enabled(const struct current_action_spec *action)
   Local Variables:
   tab-width: 3
   end:
-
-  vim:softtabstop=3 shiftwidth=3
 */
index 76f1cb8..6d4923e 100644 (file)
@@ -1,4 +1,4 @@
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.50 2008/12/20 14:53:55 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.51 2009/04/17 11:27:49 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
@@ -35,6 +35,9 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.50 2008/12/20 14:53:55 fabian
  *
  * Revisions   :
  *    $Log: jbsockets.c,v $
+ *    Revision 1.51  2009/04/17 11:27:49  fabiankeil
+ *    Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
+ *
  *    Revision 1.50  2008/12/20 14:53:55  fabiankeil
  *    Add config option socket-timeout to control the time
  *    Privoxy waits for data to arrive on a socket. Useful
@@ -375,23 +378,23 @@ jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
 #endif /* def FEATURE_ACL */
 
    retval = snprintf(service, sizeof(service), "%d", portnum);
-   if (-1 == retval || sizeof(service) <= retval)
+   if ((-1 == retval) || (sizeof(service) <= retval))
    {
       log_error(LOG_LEVEL_ERROR,
-            "Port number (%d) ASCII decimal representation doesn't fit into 6 bytes",
-            portnum);
+         "Port number (%d) ASCII decimal representation doesn't fit into 6 bytes",
+         portnum);
       csp->http->host_ip_addr_str = strdup("unknown");
       return(JB_INVALID_SOCKET);
    }
 
-   memset((char *)&hints, 0, sizeof hints);
+   memset((char *)&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; /* avoid service look-up */
    if ((retval = getaddrinfo(host, service, &hints, &result)))
    {
       log_error(LOG_LEVEL_INFO,
-            "Can not resolve %s: %s", host, gai_strerror(retval));
+         "Can not resolve %s: %s", host, gai_strerror(retval));
       csp->http->host_ip_addr_str = strdup("unknown");
       return(JB_INVALID_SOCKET);
    }
@@ -415,12 +418,13 @@ jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
 
       csp->http->host_ip_addr_str = malloc(NI_MAXHOST);
       retval = getnameinfo(rp->ai_addr, rp->ai_addrlen,
-            csp->http->host_ip_addr_str, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
+         csp->http->host_ip_addr_str, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
       if (!csp->http->host_ip_addr_str || retval)
       {
-         log_error(LOG_LEVEL_ERROR, "Can not save csp->http->host_ip_addr_str: %s",
-               (csp->http->host_ip_addr_str) ? gai_strerror(retval) :
-               "Insufficient memory");
+         log_error(LOG_LEVEL_ERROR,
+            "Can not save csp->http->host_ip_addr_str: %s",
+            (csp->http->host_ip_addr_str) ?
+            gai_strerror(retval) : "Insufficient memory");
          freez(csp->http->host_ip_addr_str);
          continue;
       }
@@ -455,7 +459,7 @@ jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
       {
 #ifdef _WIN32
          if (errno == WSAEINPROGRESS)
-#elif __OS2__ 
+#elif __OS2__
          if (sock_errno() == EINPROGRESS)
 #else /* ifndef _WIN32 */
          if (errno == EINPROGRESS)
@@ -464,7 +468,7 @@ jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
             break;
          }
 
-#ifdef __OS2__ 
+#ifdef __OS2__
          if (sock_errno() != EINTR)
 #else
          if (errno != EINTR)
@@ -501,23 +505,26 @@ jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
          close_socket(fd);
          continue;
       }
-      
+
       break; /* for; Connection established; don't try other addresses */
    }
 
    freeaddrinfo(result);
    if (!rp)
    {
-      log_error(LOG_LEVEL_INFO, "Could not connect to TCP/[%s]:%s", host, service);
+      log_error(LOG_LEVEL_INFO,
+         "Could not connect to TCP/[%s]:%s", host, service);
       return(JB_INVALID_SOCKET);
    }
-   /* XXX: Current connection verification (EINPROGRESS && select() for
-    * writing) is not sufficient. E.g. on my Linux-2.6.27 with glibc-2.6
-    * select returns socket ready for writing, however subsequential write(2)
-    * fails with ENOCONNECT. Read Linux connect(2) man page about non-blocking
-    * sockets.
-    * Thus we can not log here the socket is connected. */
-   /*log_error(LOG_LEVEL_INFO, "Connected to TCP/[%s]:%s", host, service);*/
+   /*
+    * XXX: Current connection verification (EINPROGRESS && select()
+    * for writing) is not sufficient. E.g. on Linux-2.6.27 with glibc-2.6
+    * select returns socket ready for writing, however subsequential
+    * write(2) fails with ENOCONNECT. Read Linux connect(2) man page
+    * about non-blocking sockets.
+    * Thus we can't log here that the socket is connected.
+    */
+   /* log_error(LOG_LEVEL_INFO, "Connected to TCP/[%s]:%s", host, service); */
 
    return(fd);
 
@@ -852,8 +859,11 @@ int bind_port(const char *hostnam, int portnum, jb_socket *pfd)
 #ifdef HAVE_GETADDRINFO
    struct addrinfo hints;
    struct addrinfo *result, *rp;
-   /* TODO: portnum shuld be string to allow symbolic service names in
-    * configuration and to avoid following int2string */
+   /*
+    * XXX: portnum should be a string to allow symbolic service
+    * names in the configuration file and to avoid the following
+    * int2string.
+    */
    char servnam[6];
    int retval;
 #else
@@ -868,27 +878,27 @@ int bind_port(const char *hostnam, int portnum, jb_socket *pfd)
 
 #ifdef HAVE_GETADDRINFO
    retval = snprintf(servnam, sizeof(servnam), "%d", portnum);
-   if (-1 == retval || sizeof(servnam) <= retval)
+   if ((-1 == retval) || (sizeof(servnam) <= retval))
    {
       log_error(LOG_LEVEL_ERROR,
-            "Port number (%d) ASCII decimal representation doesn't fit into 6 bytes",
-            portnum);
+         "Port number (%d) ASCII decimal representation doesn't fit into 6 bytes",
+         portnum);
       return -1;
    }
 
    memset(&hints, 0, sizeof(struct addrinfo));
-   hints.ai_family=AF_UNSPEC;
-   hints.ai_socktype=SOCK_STREAM;
-   hints.ai_flags=AI_PASSIVE|AI_ADDRCONFIG;
-   hints.ai_protocol=0; /* Realy any stream protocol or TCP only */
-   hints.ai_canonname=NULL;
-   hints.ai_addr=NULL;
-   hints.ai_next=NULL;
+   hints.ai_family = AF_UNSPEC;
+   hints.ai_socktype = SOCK_STREAM;
+   hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+   hints.ai_protocol = 0; /* Realy any stream protocol or TCP only */
+   hints.ai_canonname = NULL;
+   hints.ai_addr = NULL;
+   hints.ai_next = NULL;
 
    if ((retval = getaddrinfo(hostnam, servnam, &hints, &result)))
    {
       log_error(LOG_LEVEL_ERROR,
-            "Can not resolve %s: %s", hostnam, gai_strerror(retval));
+         "Can not resolve %s: %s", hostnam, gai_strerror(retval));
       return -2;
    }
 #else
@@ -983,11 +993,16 @@ int bind_port(const char *hostnam, int portnum, jb_socket *pfd)
       }
    }
    else
+   {
       /* bind() succeeded, escape from for-loop */
-      /* TODO: Support multiple listening sockets (e.g. localhost resolves to
-       * AF_INET and AF_INET6, but only fist address is used */
+      /*
+       * XXX: Support multiple listening sockets (e.g. localhost
+       * resolves to AF_INET and AF_INET6, but only the first address
+       * is used
+       */
       break;
    }
+   }
 
    freeaddrinfo(result);
    if (rp == NULL)
@@ -1076,10 +1091,12 @@ void get_host_information(jb_socket afd, char **ip_address, char **hostname)
       }
 #ifdef HAVE_GETNAMEINFO
       *ip_address = malloc(NI_MAXHOST);
-      if ((retval = getnameinfo((struct sockaddr *) &server, s_length,
-                  *ip_address, NI_MAXHOST, NULL, 0, NI_NUMERICHOST))) {
-         log_error(LOG_LEVEL_ERROR, "Unable to print my own IP address: %s",
-               gai_strerror(retval));
+      retval = getnameinfo((struct sockaddr *) &server, s_length,
+         *ip_address, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
+      if (retval)
+      {
+         log_error(LOG_LEVEL_ERROR,
+            "Unable to print my own IP address: %s", gai_strerror(retval));
          freez(*ip_address);
          return;
       }
@@ -1097,10 +1114,12 @@ void get_host_information(jb_socket afd, char **ip_address, char **hostname)
 
 #ifdef HAVE_GETNAMEINFO
       *hostname = malloc(NI_MAXHOST);
-      if ((retval = getnameinfo((struct sockaddr *) &server, s_length,
-                  *hostname, NI_MAXHOST, NULL, 0, NI_NAMEREQD))) {
-         log_error(LOG_LEVEL_ERROR, "Unable to resolve my own IP address: %s",
-               gai_strerror(retval));
+      retval = getnameinfo((struct sockaddr *) &server, s_length,
+         *hostname, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
+      if (retval)
+      {
+         log_error(LOG_LEVEL_ERROR,
+            "Unable to resolve my own IP address: %s", gai_strerror(retval));
          freez(*hostname);
       }
 #else
@@ -1346,6 +1365,4 @@ unsigned long resolve_hostname_to_ip(const char *host)
   Local Variables:
   tab-width: 3
   end:
-
-  vim:softtabstop=3 shiftwidth=3
 */
diff --git a/jcc.c b/jcc.c
index c8e9ea7..83e3b3a 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.242 2009/04/11 10:44:47 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.243 2009/04/17 11:27:49 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -33,6 +33,9 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.242 2009/04/11 10:44:47 fabiankeil Exp $"
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.243  2009/04/17 11:27:49  fabiankeil
+ *    Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
+ *
  *    Revision 1.242  2009/04/11 10:44:47  fabiankeil
  *    Update a comment. We're not in Kansas anymore.
  *
@@ -4536,6 +4539,4 @@ static void listen_loop(void)
   Local Variables:
   tab-width: 3
   end:
-
-  vim:softtabstop=3 shiftwidth=3
 */
index 76363eb..d6fa0d7 100644 (file)
--- a/loadcfg.c
+++ b/loadcfg.c
@@ -1,4 +1,4 @@
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.93 2009/03/18 21:46:26 fabiankeil Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.94 2009/04/17 11:27:49 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
@@ -35,6 +35,9 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.93 2009/03/18 21:46:26 fabiankeil
  *
  * Revisions   :
  *    $Log: loadcfg.c,v $
+ *    Revision 1.94  2009/04/17 11:27:49  fabiankeil
+ *    Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
+ *
  *    Revision 1.93  2009/03/18 21:46:26  fabiankeil
  *    Revert the last commit as there's a better way.
  *
@@ -1198,12 +1201,12 @@ struct configuration_spec * load_config(void)
             {
                cur_fwd->forward_host = strdup(p);
 
-               if (*cur_fwd->forward_host == '[' && 
-                     NULL != (p = strchr(cur_fwd->forward_host, ']')))
+               if ((*cur_fwd->forward_host == '[')
+                  && (NULL != (p = strchr(cur_fwd->forward_host, ']'))))
                {
                   *p++ = '\0';
                   memmove(cur_fwd->forward_host, cur_fwd->forward_host + 1,
-                        (size_t) (p - cur_fwd->forward_host));
+                     (size_t)(p - cur_fwd->forward_host));
                   if (*p == ':')
                   {
                      cur_fwd->forward_port = atoi(++p);
@@ -1273,12 +1276,12 @@ struct configuration_spec * load_config(void)
             {
                cur_fwd->gateway_host = strdup(p);
 
-               if (*cur_fwd->gateway_host == '[' && 
-                     NULL != (p = strchr(cur_fwd->gateway_host, ']')))
+               if ((*cur_fwd->gateway_host == '[')
+                  && (NULL != (p = strchr(cur_fwd->gateway_host, ']'))))
                {
                   *p++ = '\0';
                   memmove(cur_fwd->gateway_host, cur_fwd->gateway_host + 1,
-                        (size_t) (p - cur_fwd->gateway_host));
+                     (size_t)(p - cur_fwd->gateway_host));
                   if (*p == ':')
                   {
                      cur_fwd->gateway_port = atoi(++p);
@@ -1303,12 +1306,12 @@ struct configuration_spec * load_config(void)
             {
                cur_fwd->forward_host = strdup(p);
 
-               if (*cur_fwd->forward_host == '[' && 
-                     NULL != (p = strchr(cur_fwd->forward_host, ']')))
+               if ((*cur_fwd->forward_host == '[')
+                  && (NULL != (p = strchr(cur_fwd->forward_host, ']'))))
                {
                   *p++ = '\0';
                   memmove(cur_fwd->forward_host, cur_fwd->forward_host + 1,
-                        (size_t) (p - cur_fwd->forward_host));
+                     (size_t)(p - cur_fwd->forward_host));
                   if (*p == ':')
                   {
                      cur_fwd->forward_port = atoi(++p);
@@ -1384,12 +1387,12 @@ struct configuration_spec * load_config(void)
 
             cur_fwd->gateway_host = strdup(p);
 
-            if (*cur_fwd->gateway_host == '[' && 
-                  NULL != (p = strchr(cur_fwd->gateway_host, ']')))
+            if ((*cur_fwd->gateway_host == '[')
+               && (NULL != (p = strchr(cur_fwd->gateway_host, ']'))))
             {
                *p++ = '\0';
                memmove(cur_fwd->gateway_host, cur_fwd->gateway_host + 1,
-                     (size_t) (p - cur_fwd->gateway_host));
+                  (size_t)(p - cur_fwd->gateway_host));
                if (*p == ':')
                {
                   cur_fwd->gateway_port = atoi(++p);
@@ -1919,19 +1922,21 @@ struct configuration_spec * load_config(void)
 
    if ( NULL != config->haddr )
    {
-      if (*config->haddr == '[' && NULL != (p = strchr(config->haddr, ']')) &&
-            p[1] == ':' && 0 < (config->hport = atoi(p + 2)))
+      if ((*config->haddr == '[')
+         && (NULL != (p = strchr(config->haddr, ']')))
+         && (p[1] == ':')
+         && (0 < (config->hport = atoi(p + 2))))
       {
-         *p='\0';
-         memmove((void *) config->haddr, config->haddr + 1,
-               (size_t) (p - config->haddr));
+         *p = '\0';
+         memmove((void *)config->haddr, config->haddr + 1,
+            (size_t)(p - config->haddr));
       }
-      else if (NULL != (p = strchr(config->haddr, ':')) &&
-            0 < (config->hport = atoi(p + 1)))
+      else if (NULL != (p = strchr(config->haddr, ':'))
+         && (0 < (config->hport = atoi(p + 1))))
       {
          *p = '\0';
       }
-      else 
+      else
       {
          log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
          /* Never get here - LOG_LEVEL_FATAL causes program exit */
@@ -2108,6 +2113,4 @@ static void savearg(char *command, char *argument, struct configuration_spec * c
   Local Variables:
   tab-width: 3
   end:
-
-  vim:softtabstop=3 shiftwidth=3
 */
index 19f7523..77f6a54 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1,7 +1,7 @@
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.129 2009/03/08 14:12:51 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.130 2009/04/17 11:27:49 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
@@ -37,6 +37,9 @@
  *
  * Revisions   :
  *    $Log: project.h,v $
+ *    Revision 1.130  2009/04/17 11:27:49  fabiankeil
+ *    Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
+ *
  *    Revision 1.129  2009/03/08 14:12:51  fabiankeil
  *    All the CSP_FLAG_FOO bit masks should be unsigned ints.
  *
@@ -1896,6 +1899,4 @@ struct configuration_spec
   Local Variables:
   tab-width: 3
   end:
-
-  vim:softtabstop=3 shiftwidth=3
 */
index fa11f20..916edb1 100644 (file)
@@ -1,4 +1,4 @@
-const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.47 2009/03/02 19:18:10 fabiankeil Exp $";
+const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.48 2009/04/17 11:27:49 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/urlmatch.c,v $
@@ -33,6 +33,9 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.47 2009/03/02 19:18:10 fabianke
  *
  * Revisions   :
  *    $Log: urlmatch.c,v $
+ *    Revision 1.48  2009/04/17 11:27:49  fabiankeil
+ *    Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
+ *
  *    Revision 1.47  2009/03/02 19:18:10  fabiankeil
  *    Streamline parse_http_request()'s prototype. As
  *    cparser pointed out it doesn't actually use csp.
@@ -554,8 +557,8 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr
             return JB_ERR_PARSE;
          }
 
-         *port++='\0';
-         
+         *port++ = '\0';
+
          if (*port == '\0')
          {
             port = NULL;
@@ -569,7 +572,7 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr
       }
       else
       {
-         /* Plain non-escaped hostname */ 
+         /* Plain non-escaped hostname */
          port = strchr(host, ':');
       }
 
@@ -876,18 +879,20 @@ static jb_err compile_url_pattern(struct url_spec *url, char *buf)
       *p = '\0';
    }
 
-   /* XXX: IPv6 numeric hostname contains colons, thus we need to delimit the
-    * hostname before real port separator. Because brackets are used in
-    * hostname matching on lower layer, we can't use it. I decided to use
-    * angle brackets '<' '>' instead. */
-   if (buf[0] == '<' && NULL != (p = strchr(buf + 1, '>')))
+   /*
+    * IPv6 numeric hostnames can contain colons, thus we need
+    * to delimit the hostname before the real port separator.
+    * As brackets are already used in the hostname pattern,
+    * we use angle brackets ('<', '>') instead.
+    */
+   if ((buf[0] == '<') && (NULL != (p = strchr(buf + 1, '>'))))
    {
       *p++ = '\0';
       buf++;
 
       if (*p == '\0')
       {
-         /* Only IPv6 address without port number */
+         /* IPv6 address without port number */
          p = NULL;
       }
       else if (*p != ':')
@@ -1505,6 +1510,4 @@ int match_portlist(const char *portlist, int port)
   Local Variables:
   tab-width: 3
   end:
-
-  vim:softtabstop=3 shiftwidth=3
 */