Applied patch from Mikhail Grushinskiy for mingw compiler on Windows.

* Makefile.am configure.in example/Makefile.am libxml.h nanoftp.c
  nanohttp.c xmllint.c: Applied patch from Mikhail Grushinskiy for
  mingw compiler on Windows.
Daniel
diff --git a/ChangeLog b/ChangeLog
index b3936a7..059441f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Aug 14 03:19:08 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+	* Makefile.am configure.in example/Makefile.am libxml.h nanoftp.c
+	  nanohttp.c xmllint.c: Applied patch from Mikhail Grushinskiy for
+	  mingw compiler on Windows.
+
 Thu Aug 14 02:28:36 CEST 2003 Daniel Veillard <daniel@veillard.com>
 
 	* parser.c: fixed the serious CPU usage problem reported by
diff --git a/Makefile.am b/Makefile.am
index 2f74951..bab9ae8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,7 +39,8 @@
 endif
 
 DEPS = $(top_builddir)/libxml2.la
-LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm
+LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm @WIN32_EXTRA_LIBADD@
+
 
 man_MANS = xml2-config.1 libxml.3
 
diff --git a/configure.in b/configure.in
index d5c1206..63aaed0 100644
--- a/configure.in
+++ b/configure.in
@@ -714,6 +714,22 @@
 fi
 AC_SUBST(WITH_MEM_DEBUG)
 
+
+WIN32_EXTRA_LIBADD=
+WIN32_EXTRA_LDFLAGS=
+case "$host" in
+ *-*-mingw*)
+ WIN32_EXTRA_LIBADD="-lwsock32"
+ WIN32_EXTRA_LDFLAGS="-no-undefined"
+ AC_DEFINE([_WINSOCKAPI_],1,[Using the Win32 Socket implementation])
+ AC_DEFINE([snprintf],[_snprintf],[Win32 Std C name mangling work-around])
+ AC_DEFINE([vsnprintf],[_vsnprintf],[Win32 Std C name mangling work-around])
+ ;;
+esac
+AC_SUBST(WIN32_EXTRA_LIBADD)
+AC_SUBST(WIN32_EXTRA_LDFLAGS)
+
+
 AC_SUBST(CFLAGS)
 AC_SUBST(XML_CFLAGS)
 
diff --git a/example/Makefile.am b/example/Makefile.am
index b78e05f..45ab56b 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -7,5 +7,6 @@
 	-I$(top_builddir)/include		\
 	-I$(top_srcdir)/include -I@srcdir@
 
-LDADD = $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm
+LDADD = $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm @WIN32_EXTRA_LIBADD@
+
 
diff --git a/libxml.h b/libxml.h
index fcf0f9e..b26ff57 100644
--- a/libxml.h
+++ b/libxml.h
@@ -18,7 +18,7 @@
 #endif
 #endif
 
-#if defined(WIN32) && !defined(__CYGWIN__)
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
 #include "win32config.h"
 #elif defined(macintosh)
 #include "config-mac.h"
diff --git a/nanoftp.c b/nanoftp.c
index b6fd9a1..43ac8ac 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -76,6 +76,16 @@
 #endif
 #endif
 
+
+#ifdef __MINGW32__
+#define _WINSOCKAPI_
+#include <wsockcompat.h>
+#include <winsock2.h>
+#undef SOCKLEN_T
+#define SOCKLEN_T unsigned int
+#endif
+
+
 /**
  * A couple portability macros
  */
diff --git a/nanohttp.c b/nanohttp.c
index a3b4661..15cc94d 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -73,6 +73,16 @@
 #define SOCKET int
 #endif
 
+
+#ifdef __MINGW32__
+#define _WINSOCKAPI_
+#include <wsockcompat.h>
+#include <winsock2.h>
+#undef SOCKLEN_T
+#define SOCKLEN_T unsigned int
+#endif
+
+
 #include <libxml/globals.h>
 #include <libxml/xmlerror.h>
 #include <libxml/xmlmemory.h>
diff --git a/xmllint.c b/xmllint.c
index 00d806d..b8efb50 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -31,6 +31,15 @@
 #endif
 #endif /* _WIN32 */
 
+#ifdef __MINGW32__
+#define _WINSOCKAPI_
+#include <wsockcompat.h>
+#include <winsock2.h>
+#undef SOCKLEN_T
+#define SOCKLEN_T unsigned int
+#endif
+
+
 #ifdef HAVE_SYS_TIMEB_H
 #include <sys/timeb.h>
 #endif