applied patch from Andreas Stricke to ease the compilation on Windows CE

* catalog.c libxml.h win32/wince/wincecompat.h win32/wince/wincecompat.c
  xmlIO.c nanohttp.c nanoftp.c trio.c triostr.c triostr.h: applied 
  patch from Andreas Stricke to ease the compilation on Windows CE
Daniel

svn path=/trunk/; revision=3600
diff --git a/ChangeLog b/ChangeLog
index 2a63ac7..b6a6855 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Apr 17 14:47:42 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+	* catalog.c libxml.h win32/wince/wincecompat.h win32/wince/wincecompat.c
+	  xmlIO.c nanohttp.c nanoftp.c trio.c triostr.c triostr.h: applied 
+	  patch from Andreas Stricke to ease the compilation on Windows CE
+
 Tue Apr 17 14:34:45 CEST 2007 Daniel Veillard <daniel@veillard.com>
 
 	* xmllint.c catalog.c: "xmllint unusable on win32" so applied
diff --git a/catalog.c b/catalog.c
index 92f5da5..95ebee8 100644
--- a/catalog.c
+++ b/catalog.c
@@ -77,9 +77,15 @@
 #if defined(_WIN32) && defined(_MSC_VER)
 #undef XML_XML_DEFAULT_CATALOG
 static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog";
+#if defined(_WIN32_WCE)
+/* Windows CE don't have a A variant */
+#define GetModuleHandleA GetModuleHandle
+#define GetModuleFileNameA GetModuleFileName
+#else
 void* __stdcall GetModuleHandleA(const char*);
 unsigned long __stdcall GetModuleFileNameA(void*, char*, unsigned long);
 #endif
+#endif
 
 static xmlChar *xmlCatalogNormalizePublic(const xmlChar *pubID);
 static int xmlExpandCatalog(xmlCatalogPtr catal, const char *filename);
diff --git a/libxml.h b/libxml.h
index 37c6156..478d3e3 100644
--- a/libxml.h
+++ b/libxml.h
@@ -32,6 +32,15 @@
 int vfprintf(FILE *, const char *, va_list);
 #endif
 
+/*
+ * Windows CE compatibility definitions and functions
+ * This is needed to compile libxml2 for Windows CE.
+ * At least I tested it with WinCE 4.2 for Emulator and SH4 target
+ */
+#if defined(_WIN32_WCE)
+#include <wincecompat.h>
+#endif
+
 #ifndef WITH_TRIO
 #include <stdio.h>
 #else
diff --git a/nanoftp.c b/nanoftp.c
index d7c67c2..8c4ea88 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -77,7 +77,7 @@
 #endif
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_WIN32_WCE)
 #define _WINSOCKAPI_
 #include <wsockcompat.h>
 #include <winsock2.h>
diff --git a/nanohttp.c b/nanohttp.c
index ae7923f..26b5d7e 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -74,8 +74,7 @@
 #define SOCKET int
 #endif
 
-
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_WIN32_WCE)
 #define _WINSOCKAPI_
 #include <wsockcompat.h>
 #include <winsock2.h>
diff --git a/trio.c b/trio.c
index fc0ae62..b116ccc 100644
--- a/trio.c
+++ b/trio.c
@@ -62,7 +62,9 @@
 #include <limits.h>
 #include <float.h>
 
-#if defined(__STDC_ISO_10646__) || defined(MB_LEN_MAX) || defined(USE_MULTIBYTE) || TRIO_WIDECHAR
+#if (defined(__STDC_ISO_10646__) || defined(MB_LEN_MAX) \
+     || defined(USE_MULTIBYTE) || TRIO_WIDECHAR) \
+    && !defined(_WIN32_WCE)
 # define TRIO_COMPILER_SUPPORTS_MULTIBYTE
 # if !defined(MB_LEN_MAX)
 #  define MB_LEN_MAX 6
@@ -73,6 +75,10 @@
 # define TRIO_COMPILER_SUPPORTS_MSVC_INT
 #endif
 
+#if defined(_WIN32_WCE)
+#include <wincecompat.h>
+#endif
+
 /*************************************************************************
  * Generic definitions
  */
@@ -92,7 +98,10 @@
 # include <stdarg.h>
 #endif
 #include <stddef.h>
+
+#ifdef HAVE_ERRNO_H
 #include <errno.h>
+#endif
 
 #ifndef NULL
 # define NULL 0
@@ -133,9 +142,13 @@
 # include <unistd.h>
 #endif
 #if defined(TRIO_PLATFORM_WIN32)
-# include <io.h>
-# define read _read
-# define write _write
+# if defined(_WIN32_WCE)
+#  include <wincecompat.h>
+# else
+#  include <io.h>
+#  define read _read
+#  define write _write
+# endif
 #endif /* TRIO_PLATFORM_WIN32 */
 
 #if TRIO_WIDECHAR
@@ -243,8 +256,9 @@
 # endif
 #endif
 
-#if !(defined(TRIO_COMPILER_SUPPORTS_C99) \
- || defined(TRIO_COMPILER_SUPPORTS_UNIX01))
+#if (!(defined(TRIO_COMPILER_SUPPORTS_C99) \
+ || defined(TRIO_COMPILER_SUPPORTS_UNIX01))) \
+ && !defined(_WIN32_WCE)
 # define floorl(x) floor((double)(x))
 # define fmodl(x,y) fmod((double)(x),(double)(y))
 # define powl(x,y) pow((double)(x),(double)(y))
diff --git a/triostr.c b/triostr.c
index 2082e96..30d13ac 100644
--- a/triostr.c
+++ b/triostr.c
@@ -73,7 +73,11 @@
 # endif
 #elif defined(TRIO_PLATFORM_WIN32)
 # define USE_STRCASECMP
-# define strcasecmp(x,y) strcmpi(x,y)
+# if defined(_WIN32_WCE)
+#  define strcasecmp(x,y) _stricmp(x,y)
+# else
+#  define strcasecmp(x,y) strcmpi(x,y)
+# endif
 #endif
 
 #if !(defined(TRIO_PLATFORM_SUNOS))
@@ -574,7 +578,7 @@
 }
 
 
-#if !defined(TRIO_MINIMAL)
+#if !defined(TRIO_MINIMAL) && !defined(_WIN32_WCE)
 /**
    Format the date/time according to @p format.
 
@@ -1887,7 +1891,7 @@
 #endif /* !defined(TRIO_MINIMAL) */
 
 
-#if !defined(TRIO_MINIMAL)
+#if !defined(TRIO_MINIMAL) && !defined(_WIN32_WCE)
 /*
  * trio_string_format_data_max
  */
diff --git a/triostr.h b/triostr.h
index 45f2306..27f4ace 100644
--- a/triostr.h
+++ b/triostr.h
@@ -65,7 +65,9 @@
 TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source));
 TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max));
 TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second));
+#if !defined(_WIN32_WCE)
 TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_PROTO((char *target, size_t max, const char *format, const struct tm *datetime));
+#endif
 TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_PROTO((const char *string, int type));
 TRIO_STRING_PUBLIC char *trio_index TRIO_PROTO((const char *string, int character));
 TRIO_STRING_PUBLIC char *trio_index_last TRIO_PROTO((const char *string, int character));
@@ -114,7 +116,9 @@
 TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *second));
 TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_PROTO((trio_string_t *self, trio_string_t *other));
 TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *other));
+#if !defined(_WIN32_WCE)
 TRIO_STRING_PUBLIC size_t trio_string_format_date_max TRIO_PROTO((trio_string_t *self, size_t max, const char *format, const struct tm *datetime));
+#endif
 TRIO_STRING_PUBLIC char *trio_string_index TRIO_PROTO((trio_string_t *self, int character));
 TRIO_STRING_PUBLIC char *trio_string_index_last TRIO_PROTO((trio_string_t *self, int character));
 TRIO_STRING_PUBLIC int trio_string_length TRIO_PROTO((trio_string_t *self));
diff --git a/win32/wince/wincecompat.c b/win32/wince/wincecompat.c
index bf70fcc..1d8df87 100644
--- a/win32/wince/wincecompat.c
+++ b/win32/wince/wincecompat.c
@@ -47,6 +47,14 @@
 }
 
 
+char *getcwd( char *buffer, unsigned int size)
+{
+    /* Windows CE don't have the concept of a current directory
+     * so we just return NULL to indicate an error
+     */
+    return NULL;
+}
+
 char *getenv( const char *varname )
 {
 	return NULL;
diff --git a/win32/wince/wincecompat.h b/win32/wince/wincecompat.h
index 49468a3..aa0f3dc 100644
--- a/win32/wince/wincecompat.h
+++ b/win32/wince/wincecompat.h
@@ -12,6 +12,7 @@
 #define __WINCECOMPAT_H__
 
 #include <stdio.h>
+#include <winbase.h>
 
 #define MAX_STRERROR 31
 
@@ -24,6 +25,8 @@
 #define O_TRUNC        0x0200  /* open and truncate */
 #define O_EXCL         0x0400  /* open only if file doesn't already exist */
 
+#define BUFSIZ 4096
+
 extern int errno;
 /* 
 	Prototypes 
@@ -33,6 +36,7 @@
 int open(const char *filename,int oflag, ...);
 int close(int handle);
 char *getenv( const char *varname );
+char *getcwd( char *buffer, unsigned int size);
 char *strerror(int errnum);
 
 /*
diff --git a/xmlIO.c b/xmlIO.c
index 081de2c..f576d76 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -36,10 +36,14 @@
 #include <zlib.h>
 #endif
 
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
 #include <windows.h>
 #endif
 
+#if defined(_WIN32_WCE)
+#include <winnls.h> /* for CP_UTF8 */
+#endif
+
 /* Figure a portable way to know if a file is a directory. */
 #ifndef HAVE_STAT
 #  ifdef HAVE__STAT