venaas          Wed Jan 17 05:43:40 2001 EDT

  Modified files:              
    /php4/ext/ldap      ldap.c 
  Log:
  Making parallel search allow different filter for each link
  
  
Index: php4/ext/ldap/ldap.c
diff -u php4/ext/ldap/ldap.c:1.80 php4/ext/ldap/ldap.c:1.81
--- php4/ext/ldap/ldap.c:1.80   Sat Jan 13 02:00:27 2001
+++ php4/ext/ldap/ldap.c        Wed Jan 17 05:43:39 2001
@@ -23,7 +23,7 @@
  */
  
 
-/* $Id: ldap.c,v 1.80 2001/01/13 10:00:27 venaas Exp $ */
+/* $Id: ldap.c,v 1.81 2001/01/17 13:43:39 venaas Exp $ */
 #define IS_EXT_MODULE
 
 #include "php.h"
@@ -235,7 +235,7 @@
 
        php_info_print_table_start();
        php_info_print_table_row(2, "LDAP Support", "enabled" );
-       php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.80 2001/01/13 
10:00:27 venaas Exp $" );
+       php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.81 2001/01/17 
+13:43:39 venaas Exp $" );
        php_info_print_table_row(2, "Total Links", maxl );
 #ifdef LDAP_API_VERSION
        snprintf(ldapapiversion, 31, "%d", LDAP_API_VERSION);
@@ -671,11 +671,10 @@
                        ldap_attrs[num_attribs] = NULL;
                
                case 3 :
-                       convert_to_string_ex(filter);
-                       ldap_filter = (*filter)->value.str.val;
-
                        /* parallel search? */
                        if (Z_TYPE_PP(link) != IS_ARRAY) {
+                               convert_to_string_ex(filter);
+                               ldap_filter = Z_STRVAL_PP(filter);
                                convert_to_string_ex(base_dn);
                                ldap_base_dn = Z_STRVAL_PP(base_dn);
                        }
@@ -688,7 +687,7 @@
 
        /* parallel search? */
        if (Z_TYPE_PP(link) == IS_ARRAY) {
-               int i, nlinks, nbases, *rcs;
+               int i, nlinks, nbases, nfilters, *rcs;
                LDAP **links;
                zval **entry;
                
@@ -717,6 +716,22 @@
                        ldap_base_dn = Z_STRLEN_PP(base_dn) < 1 ? NULL : 
Z_STRVAL_PP(base_dn);
                }
 
+               if (Z_TYPE_PP(filter) == IS_ARRAY) {
+                       nfilters = zend_hash_num_elements(Z_ARRVAL_PP(filter));
+                       if (nfilters != nlinks) {
+                               php_error(E_WARNING, "LDAP: Filter must either be a 
+string, or an array with the same number of elements as the links array");
+                               if (ldap_attrs != NULL) {
+                                       efree(ldap_attrs);
+                               }
+                               RETURN_FALSE;
+                       }
+                       zend_hash_internal_pointer_reset(Z_ARRVAL_PP(filter));
+               } else {
+                       nfilters = 0; /* this means string, not array */
+                       convert_to_string_ex(filter);
+                       ldap_filter = Z_STRVAL_PP(filter);
+               }
+
                links = emalloc(nlinks * sizeof(*links));
                rcs = emalloc(nlinks * sizeof(*rcs));
                
@@ -737,6 +752,12 @@
                                zend_hash_move_forward(Z_ARRVAL_PP(base_dn));
                                convert_to_string_ex(entry);
                                ldap_base_dn = Z_STRLEN_PP(entry) < 1 ? NULL : 
Z_STRVAL_PP(entry);
+                       }
+                       if (nfilters != 0) { /* filter an array? */
+                               zend_hash_get_current_data(Z_ARRVAL_PP(filter), (void 
+**)&entry);
+                               zend_hash_move_forward(Z_ARRVAL_PP(filter));
+                               convert_to_string_ex(entry);
+                               ldap_filter = Z_STRVAL_PP(entry);
                        }
 
                        php_set_opts(ldap, ldap_sizelimit, ldap_timelimit, ldap_deref);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to