Small amount of changes. Haven't bothered with the tests.
* Build as Unicode project.
* CE CRT doesn't implement bsearch(); added one from the public domain.
* Added a couple of needed errno values.
* Conditionally exclude headers that don't exist on CE. Use APR's macros
where possible to make the decision.
Index: lib/charset_alias.h
===================================================================
--- lib/charset_alias.h (revision 574285)
+++ lib/charset_alias.h (working copy)
@@ -421,6 +421,49 @@
static const size_t charset_alias_count =
sizeof(charset_alias_list)/sizeof(charset_alias_list[0]) - 1;
+#ifdef _WIN32_WCE
+void *bsearch(const void *key, const void *base, size_t num, size_t width,
+ int (__cdecl *compare)( const void *a, const void *b))
+{
+ unsigned char *low = (unsigned char *)base;
+ unsigned char *high = (unsigned char *)base + (num - 1) * width;
+ unsigned char *mid = NULL;
+ size_t half = 0;
+ int result = 0;
+
+ ASSERT(base != NULL);
+ ASSERT(num <= INT_MAX);
+ ASSERT(compare != NULL);
+
+ while(low <= high)
+ {
+ half = num;
+ if(half / 2 != 0)
+ {
+ mid = low + (num & 1 ? half : (half - 1)) * width;
+ result = compare(key, mid);
+ if(!result)
+ return mid;
+ else if(result < 0)
+ {
+ high = mid - width;
+ num = num & 1 ? half : half - 1;
+ }
+ else
+ {
+ low = mid + width;
+ num = half;
+ }
+ }
+ else if(num)
+ return compare(key, low) ? NULL : low;
+ else
+ break;
+ }
+ return NULL;
+}
+#endif /* _WIN32_WCE */
+
/* Compare two aliases. */
static int charset_alias_compare (const void *u, const void *v)
{
Index: lib/iconv_module.c
===================================================================
--- lib/iconv_module.c (revision 574285)
+++ lib/iconv_module.c (working copy)
@@ -43,9 +43,18 @@
#include <string.h>
#include <stdlib.h>
+#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
+#endif
+#ifndef _WIN32_WCE
#include <sys/stat.h>
+#endif
+#ifdef _WIN32_WCE
+#define EINVAL 22
+#define ENOMEM 12
+#endif
+
#ifdef API_USE_BUILTIN_ALIASES
#include "charset_alias.h"
#endif