[evolution-exchange] Windows build fixes



commit 2b976733835d948eb7ffa79322f1924edde5f47f
Author: Fridrich Strba <fridrich strba bluewin ch>
Date:   Mon Mar 8 21:12:05 2010 +0100

    Windows build fixes

 addressbook/e-book-backend-gal.c |   14 +++++++-
 addressbook/e-book-backend-gal.h |   69 +++++++++++++++++++++++++++++++++++++-
 configure.ac                     |   10 +++++-
 3 files changed, 90 insertions(+), 3 deletions(-)
---
diff --git a/addressbook/e-book-backend-gal.c b/addressbook/e-book-backend-gal.c
index 6086f65..b8e3dfd 100644
--- a/addressbook/e-book-backend-gal.c
+++ b/addressbook/e-book-backend-gal.c
@@ -53,6 +53,10 @@
 #include "e-book-backend-gal.h"
 #include <libical/ical.h>
 
+#ifdef _WIN32
+#include <winber.h>
+#endif
+
 #ifndef LDAP_CONTROL_PAGEDRESULTS
 #ifdef ENABLE_CACHE
 #undef ENABLE_CACHE
@@ -2244,9 +2248,17 @@ getNextPage:
 			return;
 		}
 		ber_printf( prber, "{iO}", pageSize, &cookie );
-		if (ber_flatten2( prber, &c[i].ldctl_value, 0 ) == -1) {
+#ifdef G_OS_WIN32
+		if ( ber_flatten( prber, &c[i].ldctl_value ) == -1 ) {
+			ber_free( prber, 1 );
+			return;
+		}
+		ber_free( prber, 1 );
+#else
+		if ( ber_flatten2( prber, &c[i].ldctl_value, 0 ) == -1 ) {
 			return;
 		}
+#endif
 		d(printf ("Setting parameters		\n"));
 		c[i].ldctl_oid = (gchar *) LDAP_CONTROL_PAGEDRESULTS;
 		c[i].ldctl_iscritical = pagedResults > 1;
diff --git a/addressbook/e-book-backend-gal.h b/addressbook/e-book-backend-gal.h
index cbfee0a..456e7af 100644
--- a/addressbook/e-book-backend-gal.h
+++ b/addressbook/e-book-backend-gal.h
@@ -6,13 +6,80 @@
 
 #include "libedata-book/e-book-backend.h"
 
-#ifdef SUNLDAP
+#if defined(SUNLDAP) || defined(G_OS_WIN32)
 /*   copy from openldap ldap.h   */
 #define LDAP_RANGE(n,x,y)      (((x) <= (n)) && ((n) <= (y)))
+#ifndef LDAP_NAME_ERROR
 #define LDAP_NAME_ERROR(n)     LDAP_RANGE((n), 0x20, 0x24)
+#endif
+#ifndef LBER_USE_DER
 #define LBER_USE_DER			0x01
+#endif
+#ifndef LDAP_CONTROL_PAGEDRESULTS
 #define LDAP_CONTROL_PAGEDRESULTS      "1.2.840.113556.1.4.319"
 #endif
+#endif
+
+#ifndef LDAP_TYPE_OR_VALUE_EXISTS
+#define LDAP_TYPE_OR_VALUE_EXISTS 0x14
+#endif
+#ifndef LDAP_SCOPE_DEFAULT
+#define LDAP_SCOPE_DEFAULT -1
+#endif
+#ifndef LDAP_OPT_SUCCESS
+#define LDAP_OPT_SUCCESS 0x00
+#endif
+#ifndef LDAP_INSUFFICIENT_ACCESS
+#define LDAP_INSUFFICIENT_ACCESS 0x32
+#endif
+#ifndef LDAP_OPT_SERVER_CONTROLS
+#define LDAP_OPT_SERVER_CONTROLS 0x12
+#endif
+
+#ifdef G_OS_WIN32
+/* map between the WinLDAP API and OpenLDAP API */
+#  ifndef ldap_msgtype
+#    define ldap_msgtype(m) ((m)->lm_msgtype)
+#  endif
+
+#  ifndef ldap_first_message
+#    define ldap_first_message ldap_first_entry
+#  endif
+
+#  ifndef ldap_next_message
+#    define ldap_next_message ldap_next_entry
+#  endif
+
+#  ifndef LDAP_RES_MODDN
+#    define LDAP_RES_MODDN LDAP_RES_MODRDN
+#  endif
+
+#  ifdef ldap_compare_ext
+#    undef ldap_compare_ext
+#  endif
+#  ifdef ldap_search_ext
+#    undef ldap_search_ext
+#  endif
+#  ifdef ldap_start_tls_s
+#    undef ldap_start_tls_s
+#  endif
+
+#  ifdef UNICODE
+#    define ldap_compare_ext(ld,dn,a,v,sc,cc,msg) \
+        ldap_compare_extW(ld,dn,a,0,v,sc,cc,msg)
+#    define ldap_search_ext(ld,base,scope,f,a,o,sc,cc,(t),s,msg) \
+        ldap_search_extW(ld,base,scope,f,a,o,sc,cc,((PLDAP_TIMEVAL)t)?((PLDAP_TIMEVAL)t)->tv_sec:0,s,msg)
+#    define ldap_start_tls_s(ld,sc,cc) \
+        ldap_start_tls_sW(ld,0,0,sc,cc)
+#  else /* !UNICODE */
+#    define ldap_compare_ext(ld,dn,a,v,sc,cc,msg) \
+        ldap_compare_extA(ld,dn,a,0,v,sc,cc,msg)
+#    define ldap_search_ext(ld,base,scope,f,a,o,sc,cc,t,s,msg) \
+        ldap_search_extA(ld,base,scope,f,a,o,sc,cc,((PLDAP_TIMEVAL)t)?((PLDAP_TIMEVAL)t)->tv_sec:0,s,msg)
+#    define ldap_start_tls_s(ld,sc,cc) \
+        ldap_start_tls_sA(ld,0,0,sc,cc)
+#  endif /* UNICODE */
+#endif /* G_OS_WIN32 */
 
 typedef struct _EBookBackendGALPrivate EBookBackendGALPrivate;
 
diff --git a/configure.ac b/configure.ac
index aa7f0dd..1b9e4a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,7 +152,9 @@ PKG_CHECK_MODULES(EVOLUTION_DATA_SERVER,
 dnl ************************
 dnl Check for socklen_t type
 dnl ************************
-AC_EGREP_HEADER([socklen_t], [sys/socket.h], [:], [AC_DEFINE(socklen_t, int, [Define to "int" if socklen_t is not defined])])
+if test x$os_win32 != xyes; then
+   AC_EGREP_HEADER(socklen_t, sys/socket.h, :, AC_DEFINE(socklen_t, int, [Define to "int" if socklen_t is not defined]))
+fi
 
 dnl *******************
 dnl GObject marshalling
@@ -345,6 +347,12 @@ AC_CACHE_CHECK([for LDAP Paged Control], [ac_cv_ldappaged],
 	]],
 	)], [ac_cv_ldappaged="yes"], [ac_cv_ladppaged="no"], [ac_cv_ldappaged="yes"]))
 
+# hardcode this for win32 because winldap.h supports the paged results
+# although with a tad different API
+if test x$os_win32 = xyes; then
+   ac_cv_ldappaged=yes
+fi
+
 if test "x$ac_cv_ldappaged" = "xyes"; then
 	AC_DEFINE([HAVE_LDAP_PAGED], 1, [Supports Paged results])
 	if test "x$check_db" = "xyes"; then



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