]> granicus.if.org Git - php/commitdiff
@- Added ldap_errno, ldap_err2str and ldap_error from PHP3 to PHP4. (Sterling)
authorSterling Hughes <sterling@php.net>
Thu, 6 Apr 2000 12:36:47 +0000 (12:36 +0000)
committerSterling Hughes <sterling@php.net>
Thu, 6 Apr 2000 12:36:47 +0000 (12:36 +0000)
ext/ldap/ldap.c
ext/ldap/php_ldap.h

index 364a9d8fcadd2b846542493ca078b26915fd5430..ce822b2551fbc042a6bcebd08f851fbc8bf4683d 100644 (file)
@@ -85,6 +85,9 @@ function_entry ldap_functions[] = {
        PHP_FE(ldap_mod_replace,                                                NULL)
        PHP_FE(ldap_mod_del,                                                    NULL)
 /* end gjt mod */
+       PHP_FE(ldap_errno,                                                      NULL)
+       PHP_FE(ldap_err2str,                                                    NULL)
+       PHP_FE(ldap_error,                                                      NULL)
        {NULL, NULL, NULL}
 };
 
@@ -1199,3 +1202,76 @@ PHP_FUNCTION(ldap_delete)
 }
 /* }}} */
 
+/* {{{ proto int ldap_errno(int link)
+   Get the current ldap error number */
+PHP_FUNCTION(ldap_errno) {
+       LDAP* ldap;
+       pval** ldap_link;
+
+       if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(ht, &ldap_link) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+       convert_to_string_ex(ldap_link);
+
+       ldap = _get_ldap_link(ldap_link);
+       if (ldap == NULL) {
+               RETURN_LONG(0);
+       }
+
+#if !HAVE_NSLDAP
+#if LDAP_API_VERSION > 2000
+       RETURN_LONG( ldap_get_lderrno(ldap, NULL, NULL) );
+#else
+       RETURN_LONG( ldap->ld_errno );
+#endif
+#else
+       RETURN_LONG( ldap_get_lderrno(ldap, NULL, NULL) );
+#endif
+       RETURN_LONG(0);
+}
+/* }}} */
+
+
+/* {{{ proto string ldap_err2str(int errno)
+   Convert error number to error string */
+PHP_FUNCTION(ldap_err2str) {
+       zval** perrno;
+
+       if ( ARG_COUNT(ht) != 1 || zend_get_parameters_ex(ht, &perrno) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+       convert_to_long_ex(perrno);
+       RETURN_STRING(ldap_err2string((*perrno)->value.lval), 1);
+}
+/* }}} */
+
+
+/* {{{ proto string ldap_error(int link)
+   Get the current ldap error string */
+PHP_FUNCTION(ldap_error) {
+       LDAP* ldap;
+       pval** link;
+       int ld_errno;
+
+       if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(ht, &link) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+
+       ldap = _get_ldap_link(link);
+       if (ldap == NULL) {
+               RETURN_FALSE;
+       }
+
+#if !HAVE_NSLDAP
+#if LDAP_API_VERSION > 2000
+       ld_errno = ldap_get_lderrno(ldap, NULL, NULL);
+#else
+       ld_errno = ldap->ld_errno;
+#endif
+#else
+       ld_errno = ldap_get_lderrno(ldap, NULL, NULL);
+#endif
+
+       RETURN_STRING(ldap_err2string(ld_errno), 1);
+}
+/* }}} */
\ No newline at end of file
index a8e03a59c1c0efaf7441660dc095cbf81aa60e22..45b5f45cb5d62aa8374b126bc366e42c0d59656e 100644 (file)
@@ -83,6 +83,10 @@ PHP_FUNCTION(ldap_mod_add);
 PHP_FUNCTION(ldap_mod_replace);
 PHP_FUNCTION(ldap_mod_del);
 
+PHP_FUNCTION(ldap_errno);
+PHP_FUNCTION(ldap_err2str);
+PHP_FUNCTION(ldap_error);
+
 ZEND_BEGIN_MODULE_GLOBALS(ldap)
        long default_link;
        long num_links, max_links;