cvs: /php4/ext/ldap ldap.c php_ldap.h
| From: | Sterling Hughes | Date: | Thu, 06 Apr 2000 12:37:17 +0000 |
| Subject: | cvs: /php4/ext/ldap ldap.c php_ldap.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-13224@lists.php.net to get a copy of this message | ||
sterling Thu Apr 6 05:37:17 2000 EDT
Modified files:
/php4/ext/ldap ldap.c php_ldap.h
Log:
@- Added ldap_errno, ldap_err2str and ldap_error from PHP3 to PHP4. (Sterling)
Index: php4/ext/ldap/ldap.c
diff -u php4/ext/ldap/ldap.c:1.30 php4/ext/ldap/ldap.c:1.31
--- php4/ext/ldap/ldap.c:1.30 Mon Apr 3 15:00:18 2000
+++ php4/ext/ldap/ldap.c Thu Apr 6 05:36:47 2000
@@ -21,7 +21,7 @@
*/
-/* $Id: ldap.c,v 1.30 2000/04/03 22:00:18 andi Exp $ */
+/* $Id: ldap.c,v 1.31 2000/04/06 12:36:47 sterling Exp $ */
#define IS_EXT_MODULE
#include "php.h"
@@ -85,6 +85,9 @@
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}
};
@@ -174,7 +177,7 @@
php_printf("<table>"
"<tr><td>Total links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>RCS Version:</td><td>$Id: ldap.c,v 1.30 2000/04/03
22:00:18 andi Exp $</td></tr>\n"
+ "<tr><td>RCS Version:</td><td>$Id: ldap.c,v 1.31 2000/04/06
12:36:47 sterling Exp $</td></tr>\n"
#if HAVE_NSLDAP
"<tr><td>SDK Version:</td><td>%f</td></tr>"
"<tr><td>Highest LDAP Protocol
Supported:</td><td>%f</td></tr>"
@@ -1199,3 +1202,76 @@
}
/* }}} */
+/* {{{ 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: php4/ext/ldap/php_ldap.h
diff -u php4/ext/ldap/php_ldap.h:1.4 php4/ext/ldap/php_ldap.h:1.5
--- php4/ext/ldap/php_ldap.h:1.4 Sat Apr 1 08:23:39 2000
+++ php4/ext/ldap/php_ldap.h Thu Apr 6 05:36:47 2000
@@ -29,7 +29,7 @@
*/
-/* $Id: php_ldap.h,v 1.4 2000/04/01 16:23:39 zeev Exp $ */
+/* $Id: php_ldap.h,v 1.5 2000/04/06 12:36:47 sterling Exp $ */
#ifndef _PHP_LDAP_H
#define _PHP_LDAP_H
@@ -82,6 +82,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;