changeset 29939:db6735e579f8

Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to handle all the stuff in resolver.c for DNS resolution. I couldn't quite see how to reconcile our earlier stuff with this new code. Hopefully a more skilled Win32 developer can finish this.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Mon, 22 Feb 2010 00:36:15 +0000
parents 6359fde67f4c
children c0d337670835
files libpurple/protocols/gg/lib/common.c libpurple/protocols/gg/lib/dcc.c libpurple/protocols/gg/lib/dcc7.c libpurple/protocols/gg/lib/events.c libpurple/protocols/gg/lib/http.c libpurple/protocols/gg/lib/libgadu.c libpurple/protocols/gg/lib/pubdir.c libpurple/protocols/gg/lib/resolver.c libpurple/protocols/gg/lib/resolver.h
diffstat 9 files changed, 104 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/gg/lib/common.c	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/common.c	Mon Feb 22 00:36:15 2010 +0000
@@ -47,27 +47,34 @@
  *
  * \brief Funkcje wykorzystywane przez różne moduły biblioteki
  */
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#ifdef sun
-#  include <sys/filio.h>
+
+#include "libgadu.h"
+#include "libgadu-internal.h"
+
+#ifndef _WIN32
+#  include <sys/types.h>
+#  include <sys/ioctl.h>
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+#  ifdef sun
+#    include <sys/filio.h>
+#  endif
 #endif
 
 #include <errno.h>
 #include <fcntl.h>
-#include <netdb.h>
+
+#ifndef _WIN32
+# include <netdb.h>
+#endif
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
-#include "libgadu.h"
-#include "libgadu-internal.h"
-
 /**
  * Plik, do którego będą przekazywane informacje odpluskwiania.
  *
--- a/libpurple/protocols/gg/lib/dcc.c	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/dcc.c	Mon Feb 22 00:36:15 2010 +0000
@@ -25,15 +25,19 @@
  *
  * \brief Obsługa połączeń bezpośrednich do wersji Gadu-Gadu 6.x
  */
+#include "libgadu.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#ifdef sun
-#  include <sys/filio.h>
+
+#ifndef _WIN32
+#  include <sys/ioctl.h>
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+#  ifdef sun
+#    include <sys/filio.h>
+#  endif
 #endif
 
 #include <ctype.h>
@@ -46,7 +50,6 @@
 #include <unistd.h>
 
 #include "compat.h"
-#include "libgadu.h"
 
 #ifndef GG_DEBUG_DISABLE
 
--- a/libpurple/protocols/gg/lib/dcc7.c	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/dcc7.c	Mon Feb 22 00:36:15 2010 +0000
@@ -28,15 +28,21 @@
  * \brief Obsługa połączeń bezpośrednich od wersji Gadu-Gadu 7.x
  */
 
+#include "libgadu.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#ifdef sun
-#  include <sys/filio.h>
+
+#ifndef _WIN32
+#  include <sys/ioctl.h>
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+#  ifdef sun
+#    include <sys/filio.h>
+#  endif
 #endif
+
 #include <time.h>
 
 #include <ctype.h>
@@ -49,7 +55,6 @@
 #include <unistd.h>
 
 #include "compat.h"
-#include "libgadu.h"
 
 #define gg_debug_dcc(dcc, fmt...) \
 	gg_debug_session((dcc) ? (dcc)->sess : NULL, fmt)
@@ -942,7 +947,7 @@
 		{
 			struct sockaddr_in sin;
 			int fd, one = 1;
-			unsigned int sin_len = sizeof(sin);
+			socklen_t sin_len = sizeof(sin);
 
 			gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_LISTENING\n");
 
--- a/libpurple/protocols/gg/lib/events.c	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/events.c	Mon Feb 22 00:36:15 2010 +0000
@@ -27,16 +27,20 @@
  * \brief Obsługa zdarzeń
  */
 
+#include "libgadu.h"
+#include "libgadu-internal.h"
+
 #include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+
+#ifndef _WIN32
+#  include <sys/ioctl.h>
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+#endif
 
 #include "compat.h"
-#include "libgadu.h"
 #include "protocol.h"
-#include "libgadu-internal.h"
 
 #include <errno.h>
 #include <stdio.h>
@@ -1534,7 +1538,7 @@
 		{
 			char buf[1024], *client, *auth;
 			int res = 0;
-			unsigned int res_size = sizeof(res);
+			socklen_t res_size = sizeof(res);
 			const char *host;
 
 			gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() GG_STATE_CONNECTING_HUB\n");
@@ -1752,7 +1756,7 @@
 		case GG_STATE_CONNECTING_GG:
 		{
 			int res = 0;
-			unsigned int res_size = sizeof(res);
+			socklen_t res_size = sizeof(res);
 
 			gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() GG_STATE_CONNECTING_GG\n");
 
@@ -2054,7 +2058,7 @@
 
 			if (gg_dcc_ip == (unsigned long) inet_addr("255.255.255.255")) {
 				struct sockaddr_in sin;
-				unsigned int sin_len = sizeof(sin);
+				socklen_t sin_len = sizeof(sin);
 
 				gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() detecting address\n");
 
--- a/libpurple/protocols/gg/lib/http.c	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/http.c	Mon Feb 22 00:36:15 2010 +0000
@@ -24,18 +24,26 @@
  * \brief Obsługa połączeń HTTP
  */
 
+#include "libgadu.h"
+
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+
+#ifndef _WIN32
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+#endif
 
 #include "compat.h"
-#include "libgadu.h"
 #include "resolver.h"
 
 #include <ctype.h>
 #include <errno.h>
-#include <netdb.h>
+
+#ifndef _WIN32
+#  include <netdb.h>
+#endif
+
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -230,7 +238,7 @@
 
 	if (h->state == GG_STATE_CONNECTING) {
 		int res = 0;
-		unsigned int res_size = sizeof(res);
+		socklen_t res_size = sizeof(res);
 
 		if (h->async && (getsockopt(h->fd, SOL_SOCKET, SO_ERROR, &res, &res_size) || res)) {
 			gg_debug(GG_DEBUG_MISC, "=> http, async connection failed (errno=%d, %s)\n", (res) ? res : errno , strerror((res) ? res : errno));
@@ -249,7 +257,7 @@
 	}
 
 	if (h->state == GG_STATE_SENDING_QUERY) {
-		int res;
+		ssize_t res;
 
 		if ((res = write(h->fd, h->query, strlen(h->query))) < 1) {
 			gg_debug(GG_DEBUG_MISC, "=> http, write() failed (len=%d, res=%d, errno=%d)\n", strlen(h->query), res, errno);
--- a/libpurple/protocols/gg/lib/libgadu.c	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/libgadu.c	Mon Feb 22 00:36:15 2010 +0000
@@ -28,22 +28,34 @@
  * \brief Główny moduł biblioteki
  */
 
+#include "libgadu.h"
+#include "libgadu-internal.h"
+
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#ifdef sun
-#  include <sys/filio.h>
+
+#ifdef _WIN32
+#  include <io.h>
+#  include <fcntl.h>
+#  include <errno.h>
+#  define SHUT_RDWR SD_BOTH
+#else
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+#  ifdef sun
+#    include <sys/filio.h>
+#  endif
 #endif
 
 #include "compat.h"
-#include "libgadu.h"
 #include "protocol.h"
 #include "resolver.h"
-#include "libgadu-internal.h"
 
-#include <errno.h>
-#include <netdb.h>
+#ifndef _WIN32
+#  include <errno.h> /* on Win32 this is included above */
+#  include <netdb.h>
+#endif
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
--- a/libpurple/protocols/gg/lib/pubdir.c	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/pubdir.c	Mon Feb 22 00:36:15 2010 +0000
@@ -26,6 +26,9 @@
  * \brief Obsługa katalogu publicznego
  */
 
+#include "libgadu.h"
+#include "libgadu-config.h"
+
 #include <ctype.h>
 #include <errno.h>
 #include <stdarg.h>
@@ -34,8 +37,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "libgadu.h"
-
 /**
  * Rejestruje nowego użytkownika.
  *
--- a/libpurple/protocols/gg/lib/resolver.c	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/resolver.c	Mon Feb 22 00:36:15 2010 +0000
@@ -28,15 +28,18 @@
  * \brief Funkcje rozwiązywania nazw
  */
 
-#include <sys/wait.h>
-#include <netdb.h>
+#ifndef _WIN32
+#  include <sys/wait.h>
+#  include <netdb.h>
+#  include <signal.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+#endif
+
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <signal.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 
 #include "libgadu.h"
 #include "resolver.h"
--- a/libpurple/protocols/gg/lib/resolver.h	Sun Feb 21 16:52:42 2010 +0000
+++ b/libpurple/protocols/gg/lib/resolver.h	Mon Feb 22 00:36:15 2010 +0000
@@ -21,7 +21,9 @@
 #ifndef LIBGADU_RESOLVER_H
 #define LIBGADU_RESOLVER_H
 
-#include <arpa/inet.h>
+#ifndef _WIN32
+#  include <arpa/inet.h>
+#endif
 
 int gg_gethostbyname_real(const char *hostname, struct in_addr *result, int pthread);