aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-01-26 09:39:01 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-01-26 09:39:01 +0000
commitbcd4b40e67010378892ce56f551d9e45958f07fa (patch)
treee5fe07cbe90198d788a74dc3a3189d0094e2fcdd
parentd8eebab473de16ec293a53a3bab46f4fce787dc2 (diff)
supported IPv6 on Win32.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@932 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLog.ja5
-rw-r--r--configure.in25
-rw-r--r--libsylph/socket.c30
4 files changed, 57 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index a2a1b232..25eed9ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2006-01-26
+ * libsylph/socket.c
+ configure.in: supported IPv6 on Win32.
+
+2006-01-26
+
* src/textview.c
src/mimeview.c
src/summaryview.c
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 1f6a6276..0ed34210 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,10 @@
2006-01-26
+ * libsylph/socket.c
+ configure.in: Win32 で IPv6 に対応。
+
+2006-01-26
+
* src/textview.c
src/mimeview.c
src/summaryview.c
diff --git a/configure.in b/configure.in
index 55e2db79..116de230 100644
--- a/configure.in
+++ b/configure.in
@@ -300,13 +300,24 @@ AC_MSG_CHECKING([whether to use IPv6])
if test x"$ac_cv_enable_ipv6" = xyes; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING([for IPv6 support])
- AC_CACHE_VAL(ac_cv_ipv6,[
- AC_TRY_COMPILE([#define INET6
- #include <sys/types.h>
- #include <netinet/in.h>],
- [int x = IPPROTO_IPV6; struct in6_addr a;],
- ac_cv_ipv6=yes, ac_cv_ipv6=no)
- ])
+ if test "$native_win32" = yes; then
+ AC_CACHE_VAL(ac_cv_ipv6,[
+ AC_TRY_COMPILE([#define INET6
+ #include <sys/types.h>
+ #include <winsock2.h>
+ #include <ws2tcpip.h>],
+ [int x = IPPROTO_IPV6; struct in6_addr a;],
+ ac_cv_ipv6=yes, ac_cv_ipv6=no)
+ ])
+ else
+ AC_CACHE_VAL(ac_cv_ipv6,[
+ AC_TRY_COMPILE([#define INET6
+ #include <sys/types.h>
+ #include <netinet/in.h>],
+ [int x = IPPROTO_IPV6; struct in6_addr a;],
+ ac_cv_ipv6=yes, ac_cv_ipv6=no)
+ ])
+ fi
AC_MSG_RESULT($ac_cv_ipv6)
if test $ac_cv_ipv6 = yes; then
AC_DEFINE(INET6, 1, Define if you want IPv6 support.)
diff --git a/libsylph/socket.c b/libsylph/socket.c
index e0ca1fa5..834f760b 100644
--- a/libsylph/socket.c
+++ b/libsylph/socket.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#ifdef G_OS_WIN32
# include <winsock2.h>
+# include <ws2tcpip.h>
#else
# if HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -635,9 +636,27 @@ static gint sock_connect_by_hostname(gint sock, const gchar *hostname,
}
#else /* INET6 */
+
+#ifdef G_OS_WIN32
+/* MinGW defines gai_strerror() in ws2tcpip.h, but it is not implemented. */
+#undef gai_strerror
+const gchar *gai_strerror(gint errcode)
+{
+ static gchar str[32];
+
+ g_snprintf(str, sizeof(str), "gai errcode: (%d)", errcode);
+ return str;
+}
+#endif
+
static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port)
{
- gint sock = -1, gai_error;
+#ifdef G_OS_WIN32
+ SOCKET sock = INVALID_SOCKET;
+#else
+ gint sock = -1;
+#endif
+ gint gai_error;
struct addrinfo hints, *res, *ai;
gchar port_str[6];
@@ -658,7 +677,11 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port)
for (ai = res; ai != NULL; ai = ai->ai_next) {
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+#ifdef G_OS_WIN32
+ if (sock == INVALID_SOCKET)
+#else
if (sock < 0)
+#endif
continue;
if (sock_connect_with_timeout
@@ -688,7 +711,12 @@ SockInfo *sock_connect(const gchar *hostname, gushort port)
SockInfo *sockinfo;
#ifdef INET6
+#ifdef G_OS_WIN32
+ if ((sock = sock_connect_by_getaddrinfo(hostname, port))
+ == INVALID_SOCKET)
+#else
if ((sock = sock_connect_by_getaddrinfo(hostname, port)) < 0)
+#endif /* G_OS_WIN32 */
return NULL;
#else
#ifdef G_OS_WIN32