changeset 32390:c0c60e110c82

Fix the compilation of the Bonjour prpl on Windows. Fixes #14802 committer: Daniel Atallah <daniel.atallah@gmail.com>
author Eion Robb <eion@robbmob.com>
date Tue, 13 Dec 2011 15:24:16 +0000
parents 7967bb7db191
children b30d7c76db03 9f26efb70c67 5e085a727f4e
files libpurple/protocols/bonjour/jabber.c libpurple/protocols/bonjour/jabber.h libpurple/win32/libc_interface.c libpurple/win32/libc_interface.h libpurple/win32/libc_internal.h
diffstat 5 files changed, 51 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/jabber.c	Tue Dec 06 08:23:45 2011 +0000
+++ b/libpurple/protocols/bonjour/jabber.c	Tue Dec 13 15:24:16 2011 +0000
@@ -1448,7 +1448,7 @@
 }
 
 void
-append_iface_if_linklocal(char *ip, uint32_t interface) {
+append_iface_if_linklocal(char *ip, guint32 interface_param) {
 	struct in6_addr in6_addr;
 	int len_remain = INET6_ADDRSTRLEN - strlen(ip);
 
@@ -1460,5 +1460,5 @@
 		return;
 
 	snprintf(ip + strlen(ip), len_remain, "%%%d",
-		 interface);
+		 interface_param);
 }
--- a/libpurple/protocols/bonjour/jabber.h	Tue Dec 06 08:23:45 2011 +0000
+++ b/libpurple/protocols/bonjour/jabber.h	Tue Dec 13 15:24:16 2011 +0000
@@ -111,6 +111,6 @@
 int xep_iq_send_and_free(XepIq *iq);
 GSList * bonjour_jabber_get_local_ips(int fd);
 
-void append_iface_if_linklocal(char *ip, uint32_t interface);
+void append_iface_if_linklocal(char *ip, guint32 interface_param);
 
 #endif /* _BONJOUR_JABBER_H_ */
--- a/libpurple/win32/libc_interface.c	Tue Dec 06 08:23:45 2011 +0000
+++ b/libpurple/win32/libc_interface.c	Tue Dec 13 15:24:16 2011 +0000
@@ -300,6 +300,50 @@
   return (const char *) dst;
 }
 
+int
+wpurple_inet_pton(int af, const char *src, void *dst)
+{
+	/* struct sockaddr can't accomodate struct sockaddr_in6. */
+	union {
+		struct sockaddr_in6 sin6;
+		struct sockaddr_in sin;
+	} sa;
+	size_t srcsize;
+	
+	switch(af)
+	{
+		case AF_INET:
+			sa.sin.sin_family = AF_INET;
+			srcsize = sizeof (sa.sin);
+		break;
+		case AF_INET6:
+			sa.sin6.sin6_family = AF_INET6;
+			srcsize = sizeof (sa.sin6);
+		break;
+		default:
+			errno = WSAEPFNOSUPPORT;
+			return -1;
+	}
+	
+	if (WSAStringToAddress(src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
+	{
+		errno = WSAGetLastError();
+		return -1;
+	}
+	
+	switch(af)
+	{
+		case AF_INET:
+			memcpy(dst, &sa.sin.sin_addr, sizeof(sa.sin.sin_addr));
+		break;
+		case AF_INET6:
+			memcpy(dst, &sa.sin6.sin6_addr, sizeof(sa.sin6.sin6_addr));
+		break;
+	}
+	
+	return 1;
+}
+
 
 /* netdb.h */
 struct hostent* wpurple_gethostbyname(const char *name) {
--- a/libpurple/win32/libc_interface.h	Tue Dec 06 08:23:45 2011 +0000
+++ b/libpurple/win32/libc_interface.h	Tue Dec 13 15:24:16 2011 +0000
@@ -89,6 +89,9 @@
 #define inet_ntop( af, src, dst, cnt ) \
 wpurple_inet_ntop( af, src, dst, cnt )
 
+#define inet_pton( af, src, dst ) \
+wpurple_inet_pton( af, src, dst )
+
 /* netdb.h */
 #define gethostbyname( name ) \
 wpurple_gethostbyname( name )
--- a/libpurple/win32/libc_internal.h	Tue Dec 06 08:23:45 2011 +0000
+++ b/libpurple/win32/libc_internal.h	Tue Dec 13 15:24:16 2011 +0000
@@ -48,6 +48,7 @@
 int wpurple_inet_aton(const char *name, struct in_addr *addr);
 const char *
 wpurple_inet_ntop (int af, const void *src, char *dst, socklen_t cnt);
+int wpurple_inet_pton(int af, const char *src, void *dst);
 
 /* netdb.h */
 struct hostent* wpurple_gethostbyname(const char *name);