diff src/protocols/gg/lib/http.c @ 11546:3c536224f0d0

[gaim-migrate @ 13801] Update gg to compile and seem to work on win32. The win32 thread implementation in libgg has not been tested *at all*, but I think that the gaim tie-in is all synchronous anyway (yes, it hangs up the UI wonderfully whendoing stuff). I should probably look into getting some of this stuff back into libgg committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 14 Sep 2005 19:10:39 +0000
parents cf15c1cdcfbd
children 9cbc5967fbfd
line wrap: on
line diff
--- a/src/protocols/gg/lib/http.c	Wed Sep 14 19:01:33 2005 +0000
+++ b/src/protocols/gg/lib/http.c	Wed Sep 14 19:10:39 2005 +0000
@@ -1,4 +1,4 @@
-/* $Id: http.c 13582 2005-08-28 22:46:01Z boler $ */
+/* $Id: http.c 13801 2005-09-14 19:10:39Z datallah $ */
 
 /*
  *  (C) Copyright 2001-2002 Wojtek Kaniewski <wojtekka@irc.pl>
@@ -19,16 +19,20 @@
  */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/wait.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#endif
 
 #include "libgadu-config.h"
 
 #include <ctype.h>
 #include <errno.h>
+#ifndef _WIN32
 #include <netdb.h>
+#endif
 #ifdef __GG_LIBGADU_HAVE_PTHREAD
 #  include <pthread.h>
 #endif
@@ -101,10 +105,12 @@
 	gg_debug(GG_DEBUG_MISC, "=> -----BEGIN-HTTP-QUERY-----\n%s\n=> -----END-HTTP-QUERY-----\n", h->query);
 
 	if (async) {
-#ifndef __GG_LIBGADU_HAVE_PTHREAD
+#ifdef __GG_LIBGADU_HAVE_PTHREAD
+		if (gg_resolve_pthread(&h->fd, &h->resolver, hostname)) {
+#elif defined _WIN32
+		if (gg_resolve_win32thread(&h->fd, &h->resolver, hostname)) {
+#else
 		if (gg_resolve(&h->fd, &h->pid, hostname)) {
-#else
-		if (gg_resolve_pthread(&h->fd, &h->resolver, hostname)) {
 #endif
 			gg_debug(GG_DEBUG_MISC, "// gg_http_connect() resolver failed\n");
 			gg_http_free(h);
@@ -198,14 +204,21 @@
 		close(h->fd);
 		h->fd = -1;
 
-#ifndef __GG_LIBGADU_HAVE_PTHREAD
-		waitpid(h->pid, NULL, 0);
-#else
+#ifdef __GG_LIBGADU_HAVE_PTHREAD
 		if (h->resolver) {
 			pthread_cancel(*((pthread_t *) h->resolver));
 			free(h->resolver);
 			h->resolver = NULL;
 		}
+#elif defined _WIN32
+		if (h->resolver) {
+			HANDLE hnd = h->resolver;
+			TerminateThread(hnd, 0);
+			CloseHandle(hnd);
+			h->resolver = NULL;
+		}
+#else
+		waitpid(h->pid, NULL, 0);
 #endif
 
 		gg_debug(GG_DEBUG_MISC, "=> http, connecting to %s:%d\n", inet_ntoa(a), h->port);