[xml] Windows CE port for current stable libxml2



First I like to congratulate for this great piece of software.

For a portable software project I need a Windows CE port for
libxml2. For the current stable version 2.6.27 I managed to
compile it under eVC4 (Embedded Visual C++/4.0) and test it
with both Windows Mobile/Emulator and Windows CE 4.2/SH4
successful.

The patch attached includes modifications needed to build it
under Windows CE ported to current SVN trunk.

The patch does not include the configuration file that is
also needed (I had to disable a few features which won't build
and I don't need). I think it would be best to add a
configuration file like include/win32config.h named
include/winCEconfig.h?

Another part missing is the right eVC4 Project file to actually
build the library. I don't managed to reuse the existing on
(created with bakefile) an just created a new from scratch.
I think the right approach is still to use the bakefile build
system (even if I'm not able to use it).

Cheers, Andy

--
FELA Management AG, http://www.fela.ch/


Index: catalog.c
===================================================================
--- catalog.c   (revision 3598)
+++ catalog.c   (working copy)
@@ -71,9 +71,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);
Index: libxml.h
===================================================================
--- libxml.h    (revision 3598)
+++ libxml.h    (working copy)
@@ -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
Index: nanoftp.c
===================================================================
--- nanoftp.c   (revision 3598)
+++ nanoftp.c   (working copy)
@@ -77,7 +77,7 @@
 #endif
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_WIN32_WCE)
 #define _WINSOCKAPI_
 #include <wsockcompat.h>
 #include <winsock2.h>
Index: nanohttp.c
===================================================================
--- nanohttp.c  (revision 3598)
+++ nanohttp.c  (working copy)
@@ -74,8 +74,7 @@
 #define SOCKET int
 #endif
 
-
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_WIN32_WCE)
 #define _WINSOCKAPI_
 #include <wsockcompat.h>
 #include <winsock2.h>
Index: trio.c
===================================================================
--- trio.c      (revision 3598)
+++ trio.c      (working copy)
@@ -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))
Index: triostr.c
===================================================================
--- triostr.c   (revision 3598)
+++ triostr.c   (working copy)
@@ -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
  */
Index: triostr.h
===================================================================
--- triostr.h   (revision 3598)
+++ triostr.h   (working copy)
@@ -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));
Index: win32/wince/wincecompat.c
===================================================================
--- win32/wince/wincecompat.c   (revision 3598)
+++ win32/wince/wincecompat.c   (working copy)
@@ -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;
Index: win32/wince/wincecompat.h
===================================================================
--- win32/wince/wincecompat.h   (revision 3598)
+++ win32/wince/wincecompat.h   (working copy)
@@ -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);
 
 /*
Index: xmlIO.c
===================================================================
--- xmlIO.c     (revision 3598)
+++ xmlIO.c     (working copy)
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]