]> granicus.if.org Git - php/commitdiff
Optimize LDAP a little with Ex API
authorEvan Klinger <evan@php.net>
Mon, 22 Nov 1999 02:31:32 +0000 (02:31 +0000)
committerEvan Klinger <evan@php.net>
Mon, 22 Nov 1999 02:31:32 +0000 (02:31 +0000)
ext/ldap/ldap.c

index a3f24a5fd585757d695cc0000e90b3bfa1f50134..ef2b10858704e2e0cfbb56e1a9f52f90336ac86c 100644 (file)
@@ -319,14 +319,14 @@ PHP_FUNCTION(ldap_connect)
                        break;
 
                case 1: {
-                               pval *yyhost;
+                               pval **yyhost;
 
-                               if (getParameters(ht, 1, &yyhost) == FAILURE) {
+                               if (getParametersEx(1, &yyhost) == FAILURE) {
                                        RETURN_FALSE;
                                }
 
-                               convert_to_string(yyhost);
-                               host = yyhost->value.str.val;
+                               convert_to_string_ex(yyhost);
+                               host = (*yyhost)->value.str.val;
                                port = 389; /* Default port */
 
                                /* hashed_details_length = yyhost->value.str.len+4+1;
@@ -336,16 +336,16 @@ PHP_FUNCTION(ldap_connect)
                        break;
 
                case 2: {
-                               pval *yyhost, *yyport;
+                               pval **yyhost, **yyport;
 
-                               if (getParameters(ht, 2, &yyhost, &yyport) == FAILURE) {
+                               if (getParametersEx(2, &yyhost,&yyport) == FAILURE) {
                                        RETURN_FALSE;
                                }
 
-                               convert_to_string(yyhost);
-                               host = yyhost->value.str.val;
-                               convert_to_long(yyport);
-                               port = yyport->value.lval;
+                               convert_to_string_ex(yyhost);
+                               host = (*yyhost)->value.str.val;
+                               convert_to_long_ex(yyport);
+                               port = (*yyport)->value.lval;
 
                        /* Do we need to take care of hosts running multiple LDAP servers ? */
                                /*      hashed_details_length = yyhost->value.str.len+4+1;
@@ -375,34 +375,34 @@ PHP_FUNCTION(ldap_connect)
 /* }}} */
 
 
-static LDAP * _get_ldap_link(pval *link, HashTable *list)
+static LDAP * _get_ldap_link(pval **link, HashTable *list)
 {
        LDAP *ldap;
        int type;
        LDAP_TLS_VARS;
 
-       convert_to_long(link);
-       ldap = (LDAP *) php3_list_find(link->value.lval, &type);
+       convert_to_long_ex(link);
+       ldap = (LDAP *) php3_list_find((*link)->value.lval, &type);
        
        if (!ldap || !(type == LDAP_GLOBAL(le_link))) {
-         php_error(E_WARNING, "%d is not a LDAP link index", link->value.lval);
+         php_error(E_WARNING, "%d is not a LDAP link index",(*link)->value.lval);
          return NULL;
        }
        return ldap;
 }
 
 
-static LDAPMessage * _get_ldap_result(pval *result, HashTable *list)
+static LDAPMessage * _get_ldap_result(pval **result, HashTable *list)
 {
        LDAPMessage *ldap_result;
        int type;
        LDAP_TLS_VARS;
 
-       convert_to_long(result);
-       ldap_result = (LDAPMessage *) php3_list_find(result->value.lval, &type);
+       convert_to_long_ex(result);
+       ldap_result = (LDAPMessage *)php3_list_find((*result)->value.lval, &type);
 
        if (!ldap_result || type != LDAP_GLOBAL(le_result)) {
-               php_error(E_WARNING, "%d is not a LDAP result index", result->value.lval);
+               php_error(E_WARNING, "%d is not a LDAP result index",(*result)->value.lval);
                return NULL;
        }
 
@@ -410,17 +410,17 @@ static LDAPMessage * _get_ldap_result(pval *result, HashTable *list)
 }
 
 
-static LDAPMessage * _get_ldap_result_entry(pval *result, HashTable *list)
+static LDAPMessage * _get_ldap_result_entry(pval **result, HashTable *list)
 {
        LDAPMessage *ldap_result_entry;
        int type;
        LDAP_TLS_VARS;
 
-       convert_to_long(result);
-       ldap_result_entry = (LDAPMessage *) php3_list_find(result->value.lval, &type);
+       convert_to_long_ex(result);
+       ldap_result_entry = (LDAPMessage *)php3_list_find((*result)->value.lval, &type);
 
        if (!ldap_result_entry || type != LDAP_GLOBAL(le_result_entry)) {
-               php_error(E_WARNING, "%d is not a LDAP result entry index", result->value.lval);
+               php_error(E_WARNING, "%d is not a LDAP result entry index", (*result)->value.lval);
                return NULL;
        }
 
@@ -428,17 +428,17 @@ static LDAPMessage * _get_ldap_result_entry(pval *result, HashTable *list)
 }
 
 
-static BerElement * _get_ber_entry(pval *berp, HashTable *list)
+static BerElement * _get_ber_entry(pval **berp, HashTable *list)
 {
        BerElement *ber;
        int type;
        LDAP_TLS_VARS;
 
-       convert_to_long(berp);
-       ber = (BerElement *) php3_list_find(berp->value.lval, &type);
+       convert_to_long_ex(berp);
+       ber = (BerElement *) php3_list_find((*berp)->value.lval, &type);
 
        if ( type != LDAP_GLOBAL(le_ber_entry)) {
-               php_error(E_WARNING, "%d is not a BerElement index", berp->value.lval);
+               php_error(E_WARNING, "%d is not a BerElement index",(*berp)->value.lval);
                return NULL;
        }
 
@@ -448,11 +448,13 @@ static BerElement * _get_ber_entry(pval *berp, HashTable *list)
 #if 0
 PHP_FUNCTION(ber_free)
 {
-        pval *berp;
+        pval **berp;
                
-       if ( getParameters(ht,1,&berp) == FAILURE ) RETURN_FALSE;
+       if ( getParametersEx(1,&berp) == FAILURE ) {
+               WRONG_PARAM_COUNT;
+       }
        
-       php3_list_delete(berp->value.lval);
+       php3_list_delete((*berp)->value.lval);
        RETURN_TRUE;
 }
 #endif
@@ -461,14 +463,14 @@ PHP_FUNCTION(ber_free)
    Bind to LDAP directory */
 PHP_FUNCTION(ldap_bind)
 {
-       pval *link, *bind_rdn, *bind_pw;
+       pval **link, **bind_rdn, **bind_pw;
        char *ldap_bind_rdn, *ldap_bind_pw;
        LDAP *ldap;
 
        switch(ARG_COUNT(ht)) {
                case 1: /* Anonymous Bind */
-                       if (getParameters(ht, 1, &link) == FAILURE) {
-                               RETURN_FALSE;
+                       if (getParametersEx(1, &link) == FAILURE) {
+                               WRONG_PARAM_COUNT;
                        }
 
                        ldap_bind_rdn = NULL;
@@ -477,15 +479,15 @@ PHP_FUNCTION(ldap_bind)
                        break;
 
                case 3 :
-                       if (getParameters(ht, 3, &link, &bind_rdn, &bind_pw) == FAILURE) {
-                               RETURN_FALSE;
+                       if (getParametersEx(3, &link, &bind_rdn,&bind_pw) == FAILURE) {
+                               WRONG_PARAM_COUNT;
                        }
 
-                       convert_to_string(bind_rdn);
-                       convert_to_string(bind_pw);
+                       convert_to_string_ex(bind_rdn);
+                       convert_to_string_ex(bind_pw);
 
-                       ldap_bind_rdn = bind_rdn->value.str.val;
-                       ldap_bind_pw = bind_pw->value.str.val;
+                       ldap_bind_rdn = (*bind_rdn)->value.str.val;
+                       ldap_bind_pw = (*bind_pw)->value.str.val;
 
                        break;
 
@@ -517,19 +519,19 @@ PHP_FUNCTION(ldap_bind)
    Unbind from LDAP directory */
 PHP_FUNCTION(ldap_unbind)
 {
-       pval *link;
+       pval **link;
        LDAP *ldap;
 
-       if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &link) == FAILURE) {
+       if (ARG_COUNT(ht) != 1 || getParametersEx(1, &link) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
-       convert_to_long(link);
+       convert_to_long_ex(link);
 
        ldap = _get_ldap_link(link, list);
        if (ldap == NULL) RETURN_FALSE;
 
-       php3_list_delete(link->value.lval);
+       php3_list_delete((*link)->value.lval);
        RETURN_TRUE;
 }
 /* }}} */
@@ -537,7 +539,7 @@ PHP_FUNCTION(ldap_unbind)
 
 static void php3_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
 {
-       pval *link, *base_dn, *filter, *attrs, **attr;
+       pval **link, **base_dn, **filter, **attrs, **attr;
        char *ldap_base_dn, *ldap_filter;
        LDAP *ldap;
        char **ldap_attrs = NULL; 
@@ -548,35 +550,35 @@ static void php3_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
 
        switch(ARG_COUNT(ht)) {
                case 3 :
-                       if (getParameters(ht, 3, &link, &base_dn, &filter) == FAILURE) {
-                               RETURN_FALSE;
+                       if (getParametersEx(3, &link, &base_dn,&filter) == FAILURE) {
+                               WRONG_PARAM_COUNT;
                        }
 
-                       convert_to_string(base_dn);
-                       convert_to_string(filter);
+                       convert_to_string_ex(base_dn);
+                       convert_to_string_ex(filter);
 
-                       ldap_base_dn = base_dn->value.str.val;
-                       ldap_filter = filter->value.str.val;
+                       ldap_base_dn = (*base_dn)->value.str.val;
+                       ldap_filter = (*filter)->value.str.val;
 
                        break;
 
                case 4 : 
-                       if (getParameters(ht, 4, &link, &base_dn, &filter, &attrs) == FAILURE) {
-                               RETURN_FALSE;
+                       if (getParametersEx(4, &link, &base_dn,&filter, &attrs) == FAILURE) {
+                               WRONG_PARAM_COUNT;
                        }
 
-                       if (attrs->type != IS_ARRAY) {
+                       if ((*attrs)->type != IS_ARRAY) {
                                php_error(E_WARNING, "LDAP: Expected Array as last element");
                                RETURN_FALSE;
                        }
 
-                       convert_to_string(base_dn);
-                       convert_to_string(filter);
+                       convert_to_string_ex(base_dn);
+                       convert_to_string_ex(filter);
 
-                       ldap_base_dn = base_dn->value.str.val;
-                       ldap_filter = filter->value.str.val;
+                       ldap_base_dn = (*base_dn)->value.str.val;
+                       ldap_filter = (*filter)->value.str.val;
 
-                       num_attribs = zend_hash_num_elements(attrs->value.ht);
+                       num_attribs = zend_hash_num_elements((*attrs)->value.ht);
                        if ((ldap_attrs = emalloc((num_attribs+1) * sizeof(char *))) == NULL) {
                                php_error(E_WARNING, "LDAP: Could not allocate memory");
                                RETURN_FALSE;
@@ -584,13 +586,14 @@ static void php3_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
                        }
 
                        for(i=0; i<num_attribs; i++) {
-                               if (zend_hash_index_find(attrs->value.ht, i, (void **) &attr) == FAILURE) {
+                               if(zend_hash_index_find((*attrs)->value.ht, i, (void **) &attr) == FAILURE)
+{
                                        php_error(E_WARNING, "LDAP: Array initialization wrong");
                                        RETURN_FALSE;
                                        return;
                                }
                                SEPARATE_ZVAL(attr);
-                               convert_to_string(*attr);
+                               convert_to_string_ex(attr);
                                ldap_attrs[i] = (*attr)->value.str.val;
                        }
                        ldap_attrs[num_attribs] = NULL;
@@ -664,10 +667,10 @@ PHP_FUNCTION(ldap_search)
    Free result memory */
 PHP_FUNCTION(ldap_free_result)
 {
-       pval *result;
+       pval **result;
        LDAPMessage *ldap_result;
 
-       if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &result) == FAILURE) {
+       if (ARG_COUNT(ht) != 1 || getParametersEx(1, &result) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
@@ -675,7 +678,7 @@ PHP_FUNCTION(ldap_free_result)
        if (ldap_result == NULL) {
                RETVAL_FALSE;
        } else {
-               php3_list_delete(result->value.lval);  /* Delete list entry and call registered destructor function */
+               php3_list_delete((*result)->value.lval);  /* Delete list entry and call registered destructor function */
                RETVAL_TRUE;
        }
        return;
@@ -686,11 +689,11 @@ PHP_FUNCTION(ldap_free_result)
    Count the number of entries in a search result */
 PHP_FUNCTION(ldap_count_entries)
 {
-       pval *result, *link;
+       pval **result, **link;
        LDAP *ldap;
        LDAPMessage *ldap_result;
 
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result) == FAILURE) {
+       if (ARG_COUNT(ht) != 2 || getParametersEx(2, &link, &result) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
@@ -708,13 +711,13 @@ PHP_FUNCTION(ldap_count_entries)
    Return first result id */
 PHP_FUNCTION(ldap_first_entry)
 {
-       pval *result, *link;
+       pval **result, **link;
        LDAP *ldap;
        LDAPMessage *ldap_result;
        LDAPMessage *ldap_result_entry;
        LDAP_TLS_VARS;
 
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result) == FAILURE) {
+       if (ARG_COUNT(ht) != 2 || getParametersEx(2, &link, &result) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
@@ -736,12 +739,12 @@ PHP_FUNCTION(ldap_first_entry)
    Get next result entry */
 PHP_FUNCTION(ldap_next_entry)
 {
-       pval *result_entry, *link;
+       pval **result_entry, **link;
        LDAP *ldap;
        LDAPMessage *ldap_result_entry, *ldap_result_entry_next;
        LDAP_TLS_VARS;
 
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result_entry) == FAILURE) {
+       if (ARG_COUNT(ht) != 2 || getParametersEx(2, &link,&result_entry) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
@@ -763,7 +766,7 @@ PHP_FUNCTION(ldap_next_entry)
    Get all result entries */
 PHP_FUNCTION(ldap_get_entries)
 {
-       pval *link, *result;
+       pval **link, **result;
        LDAPMessage *ldap_result, *ldap_result_entry;
        pval *tmp1, *tmp2;
        LDAP *ldap;
@@ -774,7 +777,7 @@ PHP_FUNCTION(ldap_get_entries)
        char **ldap_value;
        char *dn;
 
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result) == FAILURE) {
+       if (ARG_COUNT(ht) != 2 || getParametersEx(2, &link, &result) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
@@ -848,14 +851,14 @@ PHP_FUNCTION(ldap_get_entries)
    Return first attribute */
 PHP_FUNCTION(ldap_first_attribute)
 {
-       pval *result,*link,*berp;
+       pval **result,**link,**berp;
        LDAP *ldap;
        LDAPMessage *ldap_result_entry;
        BerElement *ber;
        char *attribute;
        LDAP_TLS_VARS;
 
-       if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result,&berp) == FAILURE || ParameterPassedByReference(ht,3)==0 ) {
+       if (ARG_COUNT(ht) != 3 || getParametersEx(3, &link,&result,&berp) == FAILURE || ParameterPassedByReference(ht,3)==0 ) {
                WRONG_PARAM_COUNT;
        }
 
@@ -869,8 +872,8 @@ PHP_FUNCTION(ldap_first_attribute)
                RETURN_FALSE;
        } else {
                /* brep is passed by ref so we do not have to account for memory */
-               berp->type=IS_LONG;
-               berp->value.lval=php3_list_insert(ber, LDAP_GLOBAL(le_ber_entry));
+               (*berp)->type=IS_LONG;
+               (*berp)->value.lval=php3_list_insert(ber,LDAP_GLOBAL(le_ber_entry));
 
                RETVAL_STRING(attribute,1);
 #ifdef WINDOWS
@@ -884,13 +887,13 @@ PHP_FUNCTION(ldap_first_attribute)
    Get the next attribute in result */
 PHP_FUNCTION(ldap_next_attribute)
 {
-       pval *result,*link,*berp;
+       pval **result,**link,**berp;
        LDAP *ldap;
        LDAPMessage *ldap_result_entry;
        BerElement *ber;
        char *attribute;
 
-       if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result,&berp) == FAILURE ) {
+       if (ARG_COUNT(ht) != 3 || getParametersEx(3, &link,&result,&berp) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
 
@@ -917,7 +920,7 @@ PHP_FUNCTION(ldap_next_attribute)
    Get attributes from a search result entry */
 PHP_FUNCTION(ldap_get_attributes)
 {
-       pval *link, *result_entry;
+       pval **link, **result_entry;
        pval *tmp;
        LDAP *ldap;
        LDAPMessage *ldap_result_entry;
@@ -926,7 +929,7 @@ PHP_FUNCTION(ldap_get_attributes)
        int i, count, num_values, num_attrib;
        BerElement *ber;
 
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result_entry) == FAILURE) {
+       if (ARG_COUNT(ht) != 2 || getParametersEx(2, &link, &result_entry) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
@@ -975,14 +978,14 @@ PHP_FUNCTION(ldap_get_attributes)
    Get all values from a result entry */
 PHP_FUNCTION(ldap_get_values)
 {
-       pval *link, *result_entry, *attr;
+       pval **link, **result_entry, **attr;
        LDAP *ldap;
        LDAPMessage *ldap_result_entry;
        char *attribute;
        char **ldap_value;
        int i, num_values;
 
-       if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result_entry, &attr) == FAILURE) {
+       if (ARG_COUNT(ht) != 3 || getParametersEx(3, &link,&result_entry, &attr) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
@@ -992,8 +995,8 @@ PHP_FUNCTION(ldap_get_values)
        ldap_result_entry = _get_ldap_result_entry(result_entry, list);
        if (ldap_result_entry == NULL) RETURN_FALSE;
 
-       convert_to_string(attr);
-       attribute = attr->value.str.val;
+       convert_to_string_ex(attr);
+       attribute = (*attr)->value.str.val;
 
        if ((ldap_value = ldap_get_values(ldap, ldap_result_entry, attribute)) == NULL) {
 #if !HAVE_NSLDAP
@@ -1026,12 +1029,12 @@ PHP_FUNCTION(ldap_get_values)
    Get the DN of a result entry */
 PHP_FUNCTION(ldap_get_dn) 
 {
-       pval *link,*entryp;
+       pval **link,**entryp;
        LDAP *ld;
        LDAPMessage *entry;
        char *text;
 
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &entryp) == FAILURE) {
+       if (ARG_COUNT(ht) != 2 || getParametersEx(2, &link, &entryp) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
@@ -1057,18 +1060,18 @@ PHP_FUNCTION(ldap_get_dn)
    Splits DN into its component parts */
 PHP_FUNCTION(ldap_explode_dn)
 {
-       pval *dn, *with_attrib;
+       pval **dn, **with_attrib;
        char **ldap_value;
        int i, count;
 
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &dn, &with_attrib)== FAILURE) {
+       if (ARG_COUNT(ht) != 2 || getParametersEx(2, &dn,&with_attrib) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
-       convert_to_string(dn);
-       convert_to_long(with_attrib);
+       convert_to_string_ex(dn);
+       convert_to_long_ex(with_attrib);
 
-       ldap_value = ldap_explode_dn(dn->value.str.val, with_attrib->value.lval);
+       ldap_value = ldap_explode_dn((*dn)->value.str.val,(*with_attrib)->value.lval);
 
        i=0;
        while(ldap_value[i] != NULL) i++;
@@ -1091,16 +1094,16 @@ PHP_FUNCTION(ldap_explode_dn)
    Convert DN to User Friendly Naming format */
 PHP_FUNCTION(ldap_dn2ufn)
 {
-       pval *dn;
+       pval **dn;
        char *ufn;
 
-       if (ARG_COUNT(ht) !=1 || getParameters(ht,1,&dn)==FAILURE) {
+       if (ARG_COUNT(ht) !=1 || getParametersEx(1,&dn)==FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
-       convert_to_string(dn);
+       convert_to_string_ex(dn);
        
-       ufn = ldap_dn2ufn(dn->value.str.val);
+       ufn = ldap_dn2ufn((*dn)->value.str.val);
        
        if (ufn !=NULL) {
                RETVAL_STRING(ufn,1);
@@ -1119,7 +1122,7 @@ PHP_FUNCTION(ldap_dn2ufn)
 
 static void php3_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
 {
-       pval *link, *dn, *entry, *value, *ivalue;
+       pval **link, **dn, **entry, **value, **ivalue;
        LDAP *ldap;
        char *ldap_dn;
        LDAPMod **ldap_mods;
@@ -1128,11 +1131,11 @@ static void php3_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
        ulong index;
        int is_full_add=0; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */
  
-       if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &dn, &entry) == FAILURE) {
+       if (ARG_COUNT(ht) != 3 || getParametersEx(3, &link, &dn,&entry) == FAILURE) {
                WRONG_PARAM_COUNT;
        }       
 
-       if (entry->type != IS_ARRAY) {
+       if ((*entry)->type != IS_ARRAY) {
                php_error(E_WARNING, "LDAP: Expected Array as the last element");
                RETURN_FALSE;
        }
@@ -1140,14 +1143,14 @@ static void php3_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
        ldap = _get_ldap_link(link, list);
        if (ldap == NULL) RETURN_FALSE;
 
-       convert_to_string(dn);
-       ldap_dn = dn->value.str.val;
+       convert_to_string_ex(dn);
+       ldap_dn = (*dn)->value.str.val;
 
-       num_attribs = zend_hash_num_elements(entry->value.ht);
+       num_attribs = zend_hash_num_elements((*entry)->value.ht);
 
        ldap_mods = emalloc((num_attribs+1) * sizeof(LDAPMod *));
 
-       zend_hash_internal_pointer_reset(entry->value.ht);
+       zend_hash_internal_pointer_reset((*entry)->value.ht);
         /* added by gerrit thomson to fix ldap_add using ldap_mod_add */
         if ( oper == PHP_LD_FULL_ADD )
         {
@@ -1161,38 +1164,38 @@ static void php3_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
 
                ldap_mods[i]->mod_op = oper;
 
-               if (zend_hash_get_current_key(entry->value.ht, &attribute, &index) == HASH_KEY_IS_STRING) {
+               if (zend_hash_get_current_key((*entry)->value.ht,&attribute, &index) == HASH_KEY_IS_STRING) {
                        ldap_mods[i]->mod_type = estrdup(attribute);
                        efree(attribute);
                } else {
                        php_error(E_WARNING, "LDAP: Unknown Attribute in the data");
                }
 
-               zend_hash_get_current_data(entry->value.ht, (void **) &value);
+               zend_hash_get_current_data((*entry)->value.ht, (void **)&value);
 
-               if (value->type != IS_ARRAY) {
+               if ((*value)->type != IS_ARRAY) {
                        num_values = 1;
                } else {
-                       num_values = zend_hash_num_elements(value->value.ht);
+                       num_values = zend_hash_num_elements((*value)->value.ht);
                }
 
                ldap_mods[i]->mod_values = emalloc((num_values+1) * sizeof(char *));
 
 /* allow for arrays with one element, no allowance for arrays with none but probably not required, gerrit thomson. */
 /*              if (num_values == 1) {*/
-                if ((num_values == 1) && (value->type != IS_ARRAY)) {
-                       convert_to_string(value);
-                       ldap_mods[i]->mod_values[0] = value->value.str.val;
+                if ((num_values == 1) && ((*value)->type != IS_ARRAY)) {
+                       convert_to_string_ex(value);
+                       ldap_mods[i]->mod_values[0] = (*value)->value.str.val;
                } else {        
                        for(j=0; j<num_values; j++) {
-                               zend_hash_index_find(value->value.ht, j, (void **) &ivalue);
-                               convert_to_string(ivalue);
-                               ldap_mods[i]->mod_values[j] = ivalue->value.str.val;
+                               zend_hash_index_find((*value)->value.ht,j, (void **) &ivalue);
+                               convert_to_string_ex(ivalue);
+                               ldap_mods[i]->mod_values[j] = (*ivalue)->value.str.val;
                        }
                }
                ldap_mods[i]->mod_values[num_values] = NULL;
 
-               zend_hash_move_forward(entry->value.ht);
+               zend_hash_move_forward((*entry)->value.ht);
        }
        ldap_mods[num_attribs] = NULL;
 
@@ -1274,19 +1277,19 @@ PHP_FUNCTION(ldap_mod_del)
    Delete an entry from a directory */
 PHP_FUNCTION(ldap_delete)
 {
-       pval *link, *dn;
+       pval **link, **dn;
        LDAP *ldap;
        char *ldap_dn;
 
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &dn) == FAILURE) {
+       if (ARG_COUNT(ht) != 2 || getParametersEx(2, &link, &dn) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
        ldap = _get_ldap_link(link, list);
        if (ldap == NULL) RETURN_FALSE;
 
-       convert_to_string(dn);
-       ldap_dn = dn->value.str.val;
+       convert_to_string_ex(dn);
+       ldap_dn = (*dn)->value.str.val;
 
        if (ldap_delete_s(ldap, ldap_dn) != LDAP_SUCCESS) {
                ldap_perror(ldap, "LDAP");