felipe          Sun Jun 29 14:34:39 2008 UTC

  Modified files:              
    /php-src/ext/ldap   ldap.c 
  Log:
  MFB:
  - New parameter parsing API
  - Added arginfo
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/ldap/ldap.c?r1=1.184&r2=1.185&diff_format=u
Index: php-src/ext/ldap/ldap.c
diff -u php-src/ext/ldap/ldap.c:1.184 php-src/ext/ldap/ldap.c:1.185
--- php-src/ext/ldap/ldap.c:1.184       Sun May  4 21:16:22 2008
+++ php-src/ext/ldap/ldap.c     Sun Jun 29 14:34:39 2008
@@ -23,7 +23,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: ldap.c,v 1.184 2008/05/04 21:16:22 colder Exp $ */
+/* $Id: ldap.c,v 1.185 2008/06/29 14:34:39 felipe Exp $ */
 #define IS_EXT_MODULE
 
 #ifdef HAVE_CONFIG_H
@@ -82,16 +82,6 @@
 ZEND_DECLARE_MODULE_GLOBALS(ldap)
 static PHP_GINIT_FUNCTION(ldap);
 
-static
-       ZEND_BEGIN_ARG_INFO(arg3to6of6_force_ref, 0)
-               ZEND_ARG_PASS_INFO(0)
-               ZEND_ARG_PASS_INFO(0)
-               ZEND_ARG_PASS_INFO(1)
-               ZEND_ARG_PASS_INFO(1)
-               ZEND_ARG_PASS_INFO(1)
-               ZEND_ARG_PASS_INFO(1)
-       ZEND_END_ARG_INFO();
-
 static int le_link, le_result, le_result_entry;
 
 #ifdef COMPILE_DL_LDAP
@@ -237,7 +227,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.184 
2008/05/04 21:16:22 colder Exp $");
+       php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.185 
2008/06/29 14:34:39 felipe Exp $");
 
        if (LDAPG(max_links) == -1) {
                snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links));
@@ -605,8 +595,9 @@
        int i, errno;
        int myargcount = ZEND_NUM_ARGS();
 
-       if (myargcount < 3 || myargcount > 8 || 
zend_get_parameters_ex(myargcount, &link, &base_dn, &filter, &attrs, 
&attrsonly, &sizelimit, &timelimit, &deref) != SUCCESS) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(myargcount TSRMLS_CC, "ZZZ|ZZZZZ", &link, 
&base_dn, &filter, &attrs, &attrsonly, 
+               &sizelimit, &timelimit, &deref) == FAILURE) {
+               return;
        }
 
        /* Reverse -> fall through */
@@ -2223,6 +2214,288 @@
 /* }}} */
 #endif
 
+/* {{{ arginfo */
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
+       ZEND_ARG_INFO(0, hostname)
+       ZEND_ARG_INFO(0, port)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_resource, 0, 0, 1)
+       ZEND_ARG_INFO(0, link_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_bind, 0, 0, 1)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, bind_rdn)
+       ZEND_ARG_INFO(0, bind_password)
+ZEND_END_ARG_INFO()
+
+#ifdef HAVE_LDAP_SASL
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_sasl_bind, 0, 0, 1)
+       ZEND_ARG_INFO(0, link)
+       ZEND_ARG_INFO(0, binddn)
+       ZEND_ARG_INFO(0, password)
+       ZEND_ARG_INFO(0, sasl_mech)
+       ZEND_ARG_INFO(0, sasl_realm)
+       ZEND_ARG_INFO(0, sasl_authz_id)
+       ZEND_ARG_INFO(0, props)
+ZEND_END_ARG_INFO()
+#endif
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_read, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, base_dn)
+       ZEND_ARG_INFO(0, filter)
+       ZEND_ARG_INFO(0, attributes)
+       ZEND_ARG_INFO(0, attrsonly)
+       ZEND_ARG_INFO(0, sizelimit)
+       ZEND_ARG_INFO(0, timelimit)
+       ZEND_ARG_INFO(0, deref)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_list, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, base_dn)
+       ZEND_ARG_INFO(0, filter)
+       ZEND_ARG_INFO(0, attributes)
+       ZEND_ARG_INFO(0, attrsonly)
+       ZEND_ARG_INFO(0, sizelimit)
+       ZEND_ARG_INFO(0, timelimit)
+       ZEND_ARG_INFO(0, deref)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_search, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, base_dn)
+       ZEND_ARG_INFO(0, filter)
+       ZEND_ARG_INFO(0, attributes)
+       ZEND_ARG_INFO(0, attrsonly)
+       ZEND_ARG_INFO(0, sizelimit)
+       ZEND_ARG_INFO(0, timelimit)
+       ZEND_ARG_INFO(0, deref)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_count_entries, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_entry, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_next_entry, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_get_entries, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_attribute, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_entry_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_next_attribute, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_entry_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_get_attributes, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_entry_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_get_values, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_entry_identifier)
+       ZEND_ARG_INFO(0, attribute)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_get_values_len, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_entry_identifier)
+       ZEND_ARG_INFO(0, attribute)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_get_dn, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, result_entry_identifier)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_explode_dn, 0, 0, 2)
+       ZEND_ARG_INFO(0, dn)
+       ZEND_ARG_INFO(0, with_attrib)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_dn2ufn, 0, 0, 1)
+       ZEND_ARG_INFO(0, dn)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_add, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, dn)
+       ZEND_ARG_INFO(0, entry)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_delete, 0, 0, 2)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, dn)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_modify, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, dn)
+       ZEND_ARG_INFO(0, entry)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_add, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, dn)
+       ZEND_ARG_INFO(0, entry)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_replace, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, dn)
+       ZEND_ARG_INFO(0, entry)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_del, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, dn)
+       ZEND_ARG_INFO(0, entry)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_err2str, 0, 0, 1)
+       ZEND_ARG_INFO(0, errno)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_compare, 0, 0, 4)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, dn)
+       ZEND_ARG_INFO(0, attribute)
+       ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_sort, 0, 0, 3)
+       ZEND_ARG_INFO(0, link)
+       ZEND_ARG_INFO(0, result)
+       ZEND_ARG_INFO(0, sortfilter)
+ZEND_END_ARG_INFO()
+
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_rename, 0, 0, 5)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, dn)
+       ZEND_ARG_INFO(0, newrdn)
+       ZEND_ARG_INFO(0, newparent)
+       ZEND_ARG_INFO(0, deleteoldrdn)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_get_option, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, option)
+       ZEND_ARG_INFO(1, retval)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_set_option, 0, 0, 3)
+       ZEND_ARG_INFO(0, link_identifier)
+       ZEND_ARG_INFO(0, option)
+       ZEND_ARG_INFO(1, newval)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_reference, 0, 0, 2)
+       ZEND_ARG_INFO(0, link)
+       ZEND_ARG_INFO(0, result)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_next_reference, 0, 0, 2)
+       ZEND_ARG_INFO(0, link)
+       ZEND_ARG_INFO(0, entry)
+ZEND_END_ARG_INFO()
+
+#ifdef HAVE_LDAP_PARSE_REFERENCE
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_parse_reference, 0, 0, 3)
+       ZEND_ARG_INFO(0, link)
+       ZEND_ARG_INFO(0, entry)
+       ZEND_ARG_INFO(1, referrals)
+ZEND_END_ARG_INFO()
+#endif
+
+
+#ifdef HAVE_LDAP_PARSE_RESULT
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_parse_result, 0, 0, 3)
+       ZEND_ARG_INFO(0, link)
+       ZEND_ARG_INFO(0, result)
+       ZEND_ARG_INFO(1, errcode)
+       ZEND_ARG_INFO(1, matcheddn)
+       ZEND_ARG_INFO(1, errmsg)
+       ZEND_ARG_INFO(1, referrals)
+ZEND_END_ARG_INFO()
+#endif
+#endif
+
+#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_set_rebind_proc, 0, 0, 2)
+       ZEND_ARG_INFO(0, link)
+       ZEND_ARG_INFO(0, callback)
+ZEND_END_ARG_INFO()
+#endif
+
+#ifdef STR_TRANSLATION
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_t61_to_8859, 0, 0, 1)
+       ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_8859_to_t61, 0, 0, 1)
+       ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+#endif
+/* }}} */
+       
 /*
        This is just a small subset of the functionality provided by the LDAP 
library. All the 
        operations are synchronous. Referrals are not handled automatically.
@@ -2230,69 +2503,69 @@
 /* {{{ ldap_functions[]
  */
 const zend_function_entry ldap_functions[] = {
-       PHP_FE(ldap_connect,                                                    
        NULL)
-       PHP_FALIAS(ldap_close,          ldap_unbind,                    NULL)
-       PHP_FE(ldap_bind,                                                       
                NULL)
+       PHP_FE(ldap_connect,                                                    
        arginfo_ldap_connect)
+       PHP_FALIAS(ldap_close,          ldap_unbind,                    
arginfo_ldap_resource)
+       PHP_FE(ldap_bind,                                                       
                arginfo_ldap_bind)
 #ifdef HAVE_LDAP_SASL
-       PHP_FE(ldap_sasl_bind,                                                  
        NULL)
+       PHP_FE(ldap_sasl_bind,                                                  
        arginfo_ldap_sasl_bind)
 #endif
-       PHP_FE(ldap_unbind,                                                     
                NULL)
-       PHP_FE(ldap_read,                                                       
                NULL)
-       PHP_FE(ldap_list,                                                       
                NULL)
-       PHP_FE(ldap_search,                                                     
                NULL)
-       PHP_FE(ldap_free_result,                                                
        NULL)
-       PHP_FE(ldap_count_entries,                                              
        NULL)
-       PHP_FE(ldap_first_entry,                                                
        NULL)
-       PHP_FE(ldap_next_entry,                                                 
        NULL)
-       PHP_FE(ldap_get_entries,                                                
        NULL)
-       PHP_FE(ldap_first_attribute,    third_arg_force_ref)
-       PHP_FE(ldap_next_attribute,             third_arg_force_ref)
-       PHP_FE(ldap_get_attributes,                                             
        NULL)
-       PHP_FALIAS(ldap_get_values,     ldap_get_values_len,                    
        NULL)
-       PHP_FE(ldap_get_values_len,                                             
        NULL)
-       PHP_FE(ldap_get_dn,                                                     
                NULL)
-       PHP_FE(ldap_explode_dn,                                                 
        NULL)
-       PHP_FE(ldap_dn2ufn,                                                     
                NULL)
-       PHP_FE(ldap_add,                                                        
                NULL)
-       PHP_FE(ldap_delete,                                                     
                NULL)
-       PHP_FALIAS(ldap_modify,         ldap_mod_replace,               NULL)
+       PHP_FE(ldap_unbind,                                                     
                arginfo_ldap_resource)
+       PHP_FE(ldap_read,                                                       
                arginfo_ldap_read)
+       PHP_FE(ldap_list,                                                       
                arginfo_ldap_list)
+       PHP_FE(ldap_search,                                                     
                arginfo_ldap_search)
+       PHP_FE(ldap_free_result,                                                
        arginfo_ldap_resource)
+       PHP_FE(ldap_count_entries,                                              
        arginfo_ldap_count_entries)
+       PHP_FE(ldap_first_entry,                                                
        arginfo_ldap_first_entry)
+       PHP_FE(ldap_next_entry,                                                 
        arginfo_ldap_next_entry)
+       PHP_FE(ldap_get_entries,                                                
        arginfo_ldap_get_entries)
+       PHP_FE(ldap_first_attribute,                                            
arginfo_ldap_first_attribute)
+       PHP_FE(ldap_next_attribute,                                             
        arginfo_ldap_next_attribute)
+       PHP_FE(ldap_get_attributes,                                             
        arginfo_ldap_get_attributes)
+       PHP_FALIAS(ldap_get_values,     ldap_get_values_len,    
arginfo_ldap_get_values)
+       PHP_FE(ldap_get_values_len,                                             
        arginfo_ldap_get_values_len)
+       PHP_FE(ldap_get_dn,                                                     
                arginfo_ldap_get_dn)
+       PHP_FE(ldap_explode_dn,                                                 
        arginfo_ldap_explode_dn)
+       PHP_FE(ldap_dn2ufn,                                                     
                arginfo_ldap_dn2ufn)
+       PHP_FE(ldap_add,                                                        
                arginfo_ldap_add)
+       PHP_FE(ldap_delete,                                                     
                arginfo_ldap_delete)
+       PHP_FALIAS(ldap_modify,         ldap_mod_replace,               
arginfo_ldap_modify)
 
 /* additional functions for attribute based modifications, Gerrit Thomson */
-       PHP_FE(ldap_mod_add,                                                    
        NULL)
-       PHP_FE(ldap_mod_replace,                                                
        NULL)
-       PHP_FE(ldap_mod_del,                                                    
        NULL)
+       PHP_FE(ldap_mod_add,                                                    
        arginfo_ldap_mod_add)
+       PHP_FE(ldap_mod_replace,                                                
        arginfo_ldap_mod_replace)
+       PHP_FE(ldap_mod_del,                                                    
        arginfo_ldap_mod_del)
 /* end gjt mod */
 
-       PHP_FE(ldap_errno,                                                      
                NULL)
-       PHP_FE(ldap_err2str,                                                    
        NULL)
-       PHP_FE(ldap_error,                                                      
                NULL)
-       PHP_FE(ldap_compare,                                                    
        NULL)
-       PHP_FE(ldap_sort,                                                       
                NULL)
+       PHP_FE(ldap_errno,                                                      
                arginfo_ldap_resource)
+       PHP_FE(ldap_err2str,                                                    
        arginfo_ldap_err2str)
+       PHP_FE(ldap_error,                                                      
                arginfo_ldap_resource)
+       PHP_FE(ldap_compare,                                                    
        arginfo_ldap_compare)
+       PHP_FE(ldap_sort,                                                       
                arginfo_ldap_sort)
 
 #if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
-       PHP_FE(ldap_rename,                                                     
                NULL)
-       PHP_FE(ldap_get_option,                 third_arg_force_ref)
-       PHP_FE(ldap_set_option,                                                 
        NULL)
-       PHP_FE(ldap_first_reference,                                            
NULL)
-       PHP_FE(ldap_next_reference,                                             
        NULL)
+       PHP_FE(ldap_rename,                                                     
                arginfo_ldap_rename)
+       PHP_FE(ldap_get_option,                                                 
        arginfo_ldap_get_option)
+       PHP_FE(ldap_set_option,                                                 
        arginfo_ldap_set_option)
+       PHP_FE(ldap_first_reference,                                            
arginfo_ldap_first_reference)
+       PHP_FE(ldap_next_reference,                                             
        arginfo_ldap_next_reference)
 #ifdef HAVE_LDAP_PARSE_REFERENCE
-       PHP_FE(ldap_parse_reference,    third_arg_force_ref)
+       PHP_FE(ldap_parse_reference,                                            
arginfo_ldap_parse_reference)
 #endif
 #ifdef HAVE_LDAP_PARSE_RESULT
-       PHP_FE(ldap_parse_result,                       arg3to6of6_force_ref)
+       PHP_FE(ldap_parse_result,                                               
        arginfo_ldap_parse_result)
 #endif
 #ifdef HAVE_LDAP_START_TLS_S
-       PHP_FE(ldap_start_tls,                                                  
        NULL)
+       PHP_FE(ldap_start_tls,                                                  
        arginfo_ldap_resource)
 #endif
 #endif
 
 #if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
-       PHP_FE(ldap_set_rebind_proc,                                            
NULL)
+       PHP_FE(ldap_set_rebind_proc,                                            
arginfo_ldap_set_rebind_proc)
 #endif
 
 #ifdef STR_TRANSLATION
-       PHP_FE(ldap_t61_to_8859,                                                
        NULL)
-       PHP_FE(ldap_8859_to_t61,                                                
        NULL)
+       PHP_FE(ldap_t61_to_8859,                                                
        arginfo_ldap_t61_to_8859)
+       PHP_FE(ldap_8859_to_t61,                                                
        arginfo_ldap_8859_to_t61)
 #endif
 
        {NULL, NULL, NULL}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to