summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSterling Hughes <sterling@php.net>2000-04-06 12:36:47 +0000
committerSterling Hughes <sterling@php.net>2000-04-06 12:36:47 +0000
commit4766abb0e5e68821569a067850fe66a4947fd7da (patch)
tree6a82d729df80a0f33595a6174893d9b767b905b9
parentad0f9dbccb36468af96b786967dedd611af33e8d (diff)
downloadphp-git-4766abb0e5e68821569a067850fe66a4947fd7da.tar.gz
@- Added ldap_errno, ldap_err2str and ldap_error from PHP3 to PHP4. (Sterling)
-rw-r--r--ext/ldap/ldap.c76
-rw-r--r--ext/ldap/php_ldap.h4
2 files changed, 80 insertions, 0 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 364a9d8fca..ce822b2551 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -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
diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h
index a8e03a59c1..45b5f45cb5 100644
--- a/ext/ldap/php_ldap.h
+++ b/ext/ldap/php_ldap.h
@@ -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;