--- pan-0.13.3-org/configure.in Mon Dec 30 05:10:35 2002 +++ pan-0.13.3/configure.in Sat Feb 8 17:38:27 2003 @@ -5,7 +5,7 @@ dnl init autoconf AC_INIT([pan],[0.13.3],[http://bugzilla.gnome.org/enter_bug.cgi?product=Pan]) -AC_DEFINE(VERSION_TITLE,["That cat's something I can't explain"],[Release Title]) +AC_DEFINE(VERSION_TITLE,["That cat's something I can't explain (Debian GNU/Linux)"],[Release Title]) AC_PREREQ(2.50) AC_CONFIG_SRCDIR(pan/pan.c) AC_PROG_INTLTOOL([0.21]) @@ -29,6 +29,12 @@ AC_PROG_MAKE_SET AC_PROG_RANLIB +dnl +AC_TRY_COMPILE( [#include + #include ], + [struct addrinfo *serv_addr; getaddrinfo("::1" ,NULL, NULL,&serv_addr);]; + [], + [AC_DEFINE(HAVE_GETADDRINFO,,[getaddrinfo is available])]) dnl AC_TRY_COMPILE([#include ], [mkdir ("foo", 0777);], --- pan-0.13.3-org/pan/sockets.c Fri Dec 20 21:36:15 2002 +++ pan-0.13.3/pan/sockets.c Sun Feb 9 08:44:23 2003 @@ -86,12 +86,22 @@ const char * server_address, gint port) { +#if defined(HAVE_GETADDRINFO) + struct addrinfo hints; + struct addrinfo *serv_addr; + struct addrinfo *curr_addr; + int succeeded; + int error; + char sport[20]; + sprintf(sport,"%d",port); +#else struct sockaddr_in serv_addr; struct in_addr inaddr; struct hostent *hp; #if (defined(sun) || defined(__sun)) && (defined(__svr4) || defined(__SVR4) || defined(__svr4__)) unsigned long tinaddr; #endif +#endif /* sanity clause */ @@ -128,6 +138,44 @@ sock->nntp_username = NULL; sock->nntp_password = NULL; +#if defined(HAVE_GETADDRINFO) + /* set up the serv_addr struct */ + memset(&hints,0,sizeof(hints)); + hints.ai_family=PF_UNSPEC; + hints.ai_socktype=SOCK_STREAM; + error=getaddrinfo(server_address,sport, &hints,&serv_addr); + if(error) { + const char* error_str = errno ? gai_strerror(error) : ""; + log_add_va (LOG_ERROR, _("Can't resolve %s: %s"), + server_address, error_str); + return; + } + /* We get back a linked list of hosts, we should try each one of them + * But for each host we don't know if it is ipv4 or ipv6, so we have + * to remove the socket also */ + for(curr_addr=serv_addr,succeeded=0;curr_addr;curr_addr=curr_addr->ai_next) { + sock->sockfd = socket(serv_addr->ai_family,SOCK_STREAM,0); + if (sock->sockfd < 0) { + const char* error_str = errno ? strerror(errno) : ""; + log_add_va (LOG_INFO, _("Can't connect to %s: %s"), + server_address, error_str); + continue; + } + + if (connect (sock->sockfd, serv_addr->ai_addr, serv_addr->ai_addrlen)<0) + { + close (sock->sockfd); + log_add_va (LOG_INFO, _("Connection to %s, port %d failed: %s"), server_address, port, strerror(errno)); + } else { + succeeded=1; + break; + } + } + freeaddrinfo(serv_addr); + if(!succeeded) { + log_add_va (LOG_ERROR, _("Hosts exhausted, could not connect to any host.")); + } +#else /* set up the serv_addr struct */ memset ( &serv_addr, 0, sizeof(serv_addr) ); serv_addr.sin_family = AF_INET; @@ -169,6 +217,7 @@ log_add_va (LOG_ERROR, _("Connection to %s, port %d failed: %s"), server_address, port, strerror(errno)); return; } +#endif log_add_va (LOG_INFO, _("New connection %p for %s, port %d, sockfd %d"), sock, server_address, port, sock->sockfd); debug1 (DEBUG_PAN_OBJECT, "pan_socket_constructor: %p", sock);