Hans Leidekker : wldap32: Fix build against latest OpenLDAP release.

Alexandre Julliard julliard at winehq.org
Thu Nov 8 07:07:39 CST 2007


Module: wine
Branch: master
Commit: 032dbfe47493648084f57e24d019d63bfbe04dca
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=032dbfe47493648084f57e24d019d63bfbe04dca

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Thu Nov  8 12:35:36 2007 +0100

wldap32: Fix build against latest OpenLDAP release.

---

 configure                      |   10 +++++-
 configure.ac                   |    6 +++-
 dlls/wldap32/parse.c           |   69 ++++++++++++++++++++++++++++++++++-----
 dlls/wldap32/winldap_private.h |    8 +++++
 include/config.h.in            |   12 +++++++
 5 files changed, 94 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 1fc3fa7..d2f86cf 100755
--- a/configure
+++ b/configure
@@ -12902,11 +12902,19 @@ LIBS="$LIBS $LDAPLIBS $LIBPTHREAD"
 
 
 
+
+
+
+
 for ac_func in \
 	ldap_count_references \
 	ldap_first_reference \
 	ldap_next_reference \
-	ldap_parse_reference
+	ldap_parse_reference \
+	ldap_parse_sort_control \
+	ldap_parse_sortresponse_control \
+	ldap_parse_vlv_control \
+	ldap_parse_vlvresponse_control
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/configure.ac b/configure.ac
index aa90092..3d62f45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -864,7 +864,11 @@ then
 	ldap_count_references \
 	ldap_first_reference \
 	ldap_next_reference \
-	ldap_parse_reference,
+	ldap_parse_reference \
+	ldap_parse_sort_control \
+	ldap_parse_sortresponse_control \
+	ldap_parse_vlv_control \
+	ldap_parse_vlvresponse_control,
         [$LDAPLIBS $LIBPTHREAD])
 fi
 WINE_NOTICE_IF([test "x$LDAPLIBS" = "x"],[libldap (OpenLDAP) development files not found.
diff --git a/dlls/wldap32/parse.c b/dlls/wldap32/parse.c
index e47adf2..81c30b3 100644
--- a/dlls/wldap32/parse.c
+++ b/dlls/wldap32/parse.c
@@ -325,7 +325,13 @@ ULONG CDECL ldap_parse_sort_controlW( WLDAP32_LDAP *ld, PLDAPControlW *control,
 #ifdef HAVE_LDAP
     char *attrU = NULL;
     LDAPControl **controlU = NULL;
+#ifdef HAVE_LDAP_PARSE_SORT_CONTROL
     unsigned long res;
+#elif defined(HAVE_LDAP_PARSE_SORTRESPONSE_CONTROL)
+    ber_int_t res;
+    LDAPControl *sortcontrol = NULL;
+    unsigned int i;
+#endif
 
     TRACE( "(%p, %p, %p, %p)\n", ld, control, result, attr );
 
@@ -336,10 +342,29 @@ ULONG CDECL ldap_parse_sort_controlW( WLDAP32_LDAP *ld, PLDAPControlW *control,
         if (!controlU) return WLDAP32_LDAP_NO_MEMORY;
     }
 
-    ret = ldap_parse_sort_control( ld, controlU, &res, &attrU );
-
-    *result = res;
-    *attr = strUtoW( attrU );
+#ifdef HAVE_LDAP_PARSE_SORT_CONTROL
+    if (!(ret = ldap_parse_sort_control( ld, controlU, &res, &attrU )))
+    {
+        *result = res;
+        *attr = strUtoW( attrU );
+    }
+#elif defined(HAVE_LDAP_PARSE_SORTRESPONSE_CONTROL)
+    for (i = 0; controlU[i]; i++)
+    {
+        if (!strcmp( LDAP_SERVER_RESP_SORT_OID, controlU[i]->ldctl_oid ))
+            sortcontrol = controlU[i];
+    }
+    if (!sortcontrol)
+    {
+        controlarrayfreeU( controlU );
+        return WLDAP32_LDAP_CONTROL_NOT_FOUND;
+    }
+    if (!(ret = ldap_parse_sortresponse_control( ld, sortcontrol, &res, &attrU )))
+    {
+        *result = res;
+        *attr = strUtoW( attrU );
+    }
+#endif
     controlarrayfreeU( controlU );
 
 #endif
@@ -405,7 +430,13 @@ INT CDECL ldap_parse_vlv_controlW( WLDAP32_LDAP *ld, PLDAPControlW *control,
     int ret = LDAP_NOT_SUPPORTED;
 #ifdef HAVE_LDAP
     LDAPControl **controlU = NULL;
+#ifdef HAVE_LDAP_PARSE_VLV_CONTROL
     unsigned long pos, count;
+#elif defined(HAVE_LDAP_PARSE_VLVRESPONSE_CONTROL)
+    ber_int_t pos, count;
+    LDAPControl *vlvcontrol = NULL;
+    unsigned int i;
+#endif
 
     TRACE( "(%p, %p, %p, %p, %p, %p)\n", ld, control, targetpos,
            listcount, context, errcode );
@@ -417,11 +448,31 @@ INT CDECL ldap_parse_vlv_controlW( WLDAP32_LDAP *ld, PLDAPControlW *control,
         if (!controlU) return WLDAP32_LDAP_NO_MEMORY;
     }
 
-    ret = ldap_parse_vlv_control( ld, controlU, &pos, &count,
-                                  (struct berval **)context, errcode );
-
-    *targetpos = pos;
-    *listcount = count;
+#ifdef HAVE_LDAP_PARSE_VLV_CONTROL
+    if (!(ret = ldap_parse_vlv_control( ld, controlU, &pos, &count,
+                                        (struct berval **)context, errcode )))
+    {
+        *targetpos = pos;
+        *listcount = count;
+    }
+#elif defined(HAVE_LDAP_PARSE_VLVRESPONSE_CONTROL)
+    for (i = 0; controlU[i]; i++)
+    {
+        if (!strcmp( LDAP_CONTROL_VLVRESPONSE, controlU[i]->ldctl_oid ))
+            vlvcontrol = controlU[i];
+    }
+    if (!vlvcontrol)
+    {
+        controlarrayfreeU( controlU );
+        return WLDAP32_LDAP_CONTROL_NOT_FOUND;
+    }
+    if (!(ret = ldap_parse_vlvresponse_control( ld, vlvcontrol, &pos, &count,
+                                                (struct berval **)context, errcode )))
+    {
+        *targetpos = pos;
+        *listcount = count;
+    }
+#endif
     controlarrayfreeU( controlU );
 
 #endif
diff --git a/dlls/wldap32/winldap_private.h b/dlls/wldap32/winldap_private.h
index 4936a58..e494e20 100644
--- a/dlls/wldap32/winldap_private.h
+++ b/dlls/wldap32/winldap_private.h
@@ -190,6 +190,14 @@ typedef struct WLDAP32_berval
 #define LDAP_PAGED_RESULT_OID_STRING_W (const WCHAR []){'1','.','2','.', \
         '8','4','0','.','1','1','3','5','5','6','.','1','.','4','.','3','1','9',0}
 
+#define LDAP_SERVER_RESP_SORT_OID "1.2.840.113556.1.4.474"
+#define LDAP_SERVER_RESP_SORT_OID_W (const WCHAR []){'1','.','2','.', \
+        '8','4','0','.','1','1','3','5','5','6','.','1','.','4','.','4','7','4',0}
+
+#define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10"
+#define LDAP_CONTROL_VLVRESPONSE_W (const WCHAR []){'2','.','1','6','.', \
+        '8','4','0','.','1','.','1','1','3','7','3','0','.','3','.','4','.','1','0',0}
+
 typedef struct ldapcontrolA
 {
     PCHAR ldctl_oid;
diff --git a/include/config.h.in b/include/config.h.in
index c352c42..75e5d64 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -288,6 +288,18 @@
 /* Define to 1 if you have the `ldap_parse_reference' function. */
 #undef HAVE_LDAP_PARSE_REFERENCE
 
+/* Define to 1 if you have the `ldap_parse_sortresponse_control' function. */
+#undef HAVE_LDAP_PARSE_SORTRESPONSE_CONTROL
+
+/* Define to 1 if you have the `ldap_parse_sort_control' function. */
+#undef HAVE_LDAP_PARSE_SORT_CONTROL
+
+/* Define to 1 if you have the `ldap_parse_vlvresponse_control' function. */
+#undef HAVE_LDAP_PARSE_VLVRESPONSE_CONTROL
+
+/* Define to 1 if you have the `ldap_parse_vlv_control' function. */
+#undef HAVE_LDAP_PARSE_VLV_CONTROL
+
 /* Define if you have libaudioIO */
 #undef HAVE_LIBAUDIOIO
 




More information about the wine-cvs mailing list