apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apr CHANGES
Date Sat, 16 Dec 2000 02:06:48 GMT
trawick     00/12/15 18:06:47

  Modified:    include  apr_lib.h
               strings  apr_snprintf.c
               .        CHANGES
  Log:
  apr_snprintf()'s %pI format string now takes apr_sockaddr_t *
  instead of sockaddr_in *.
  
  Revision  Changes    Path
  1.48      +2 -1      apr/include/apr_lib.h
  
  Index: apr_lib.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_lib.h,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- apr_lib.h	2000/12/04 05:59:45	1.47
  +++ apr_lib.h	2000/12/16 02:06:47	1.48
  @@ -157,7 +157,8 @@
    * The extensions are:
    *
    * %pA	takes a struct in_addr *, and prints it as a.b.c.d
  - * %pI	takes a struct sockaddr_in * and prints it as a.b.c.d:port
  + * %pI	takes an apr_sockaddr_t * and prints it as a.b.c.d:port or
  + *      [ipv6-address]:port
    * %pp  takes a void * and outputs it in hex
    *
    * The %p hacks are to force gcc's printf warning code to skip
  
  
  
  1.8       +26 -8     apr/strings/apr_snprintf.c
  
  Index: apr_snprintf.c
  ===================================================================
  RCS file: /home/cvs/apr/strings/apr_snprintf.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- apr_snprintf.c	2000/11/02 00:14:34	1.7
  +++ apr_snprintf.c	2000/12/16 02:06:47	1.8
  @@ -60,6 +60,7 @@
   #include "apr_private.h"
   
   #include "apr_lib.h"
  +#include "apr_network_io.h"
   #include <math.h>
   #ifdef HAVE_CTYPE_H
   #include <ctype.h>
  @@ -488,15 +489,32 @@
   
   
   
  -static char *conv_sockaddr_in(struct sockaddr_in *si, char *buf_end, int *len)
  +static char *conv_apr_sockaddr(apr_sockaddr_t *sa, char *buf_end, int *len)
   {
       char *p = buf_end;
       bool_int is_negative;
       int sub_len;
  +    char *ipaddr_str;
   
  -    p = conv_10(ntohs(si->sin_port), TRUE, &is_negative, p, &sub_len);
  +    /* XXX IPv6: this assumes sin_port and sin6_port are at same offset */
  +    p = conv_10(ntohs(sa->sa.sin.sin_port), TRUE, &is_negative, p, &sub_len);
       *--p = ':';
  -    p = conv_in_addr(&si->sin_addr, p, &sub_len);
  +    apr_get_ipaddr(&ipaddr_str, sa);
  +    sub_len = strlen(ipaddr_str);
  +#if APR_HAVE_IPV6
  +    if (sa->sa.sin.sin_family == APR_INET6 &&
  +        !IN6_IS_ADDR_V4MAPPED(&sa->sa.sin6.sin6_addr)) {
  +        *(p - 1) = ']';
  +        p -= sub_len + 2;
  +        *p = '[';
  +        memcpy(p + 1, ipaddr_str, sub_len);
  +    }
  +    else
  +#endif
  +    {
  +        p -= sub_len;
  +        memcpy(p, ipaddr_str, sub_len);
  +    }
   
       *len = buf_end - p;
       return (p);
  @@ -1038,14 +1056,14 @@
   		    pad_char = ' ';
   		    break;
   
  -		    /* print a struct sockaddr_in as a.b.c.d:port */
  +		    /* print an apr_sockaddr_t as a.b.c.d:port */
   		case 'I':
   		    {
  -			struct sockaddr_in *si;
  +			apr_sockaddr_t *sa;
   
  -			si = va_arg(ap, struct sockaddr_in *);
  -			if (si != NULL) {
  -			    s = conv_sockaddr_in(si, &num_buf[NUM_BUF_SIZE], &s_len);
  +			sa = va_arg(ap, apr_sockaddr_t *);
  +			if (sa != NULL) {
  +			    s = conv_apr_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len);
   			    if (adjust_precision && precision < s_len)
   				s_len = precision;
   			}
  
  
  
  1.23      +3 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- CHANGES	2000/12/14 18:42:35	1.22
  +++ CHANGES	2000/12/16 02:06:47	1.23
  @@ -1,5 +1,8 @@
   Changes with APR b1
   
  +  *) apr_snprintf()'s %pI format string now takes apr_sockaddr_t *
  +     instead of sockaddr_in *.  [Jeff Trawick]
  +
     *) Fix a bug in apr_accept() for Win32 and Unix where the local 
        apr_sockaddr_t in the new connected socket was not initialized
        properly.  This could result in a bad string for apr_get_ipaddr(),
  
  
  

Mime
View raw message