CVS update: php3/functions
| From: | kk | Date: | Thu, 01 Jul 1999 09:15:34 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-7931@lists.php.net to get a copy of this message | ||
Date: Thursday July 1, 1999 @ 5:15
Author: kk
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv5009/functions
Modified Files:
ldap.c php3_ldap.h
Log Message:
Added ldap_error(), ldap_errno() and ldap_str2err() functions.
Index: php3/functions/ldap.c
diff -u php3/functions/ldap.c:1.67 php3/functions/ldap.c:1.68
--- php3/functions/ldap.c:1.67 Mon Mar 8 11:56:47 1999
+++ php3/functions/ldap.c Thu Jul 1 05:15:33 1999
@@ -30,7 +30,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ldap.c,v 1.67 1999/03/08 16:56:47 rasmus Exp $ */
+/* $Id: ldap.c,v 1.68 1999/07/01 09:15:33 kk Exp $ */
#define IS_EXT_MODULE
#if !PHP_31 && defined(THREAD_SAFE)
#undef THREAD_SAFE
@@ -128,6 +128,11 @@
{"ldap_mod_replace", php3_ldap_mod_replace, NULL},
{"ldap_mod_del", php3_ldap_mod_del, NULL},
/* end gjt mod */
+/* additional functions for error handling, Kristian Koehntopp */
+ {"ldap_errno", php3_ldap_errno, NULL},
+ {"ldap_error", php3_ldap_error, NULL},
+ {"ldap_str2err", php3_ldap_str2err, NULL},
+/* end kk mod */
{NULL, NULL, NULL}
};
@@ -310,7 +315,7 @@
php3_printf("<table>"
"<tr><td>Total links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>RCS Version:</td><td>$Id: ldap.c,v 1.67 1999/03/08
16:56:47 rasmus Exp $</td></tr>\n"
+ "<tr><td>RCS Version:</td><td>$Id: ldap.c,v 1.68 1999/07/01
09:15:33 kk 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>"
@@ -545,6 +550,85 @@
}
}
/* }}} */
+
+/* {{{ proto int ldap_errno(int link)
+ Get the current ldap error number */
+void php3_ldap_errno(INTERNAL_FUNCTION_PARAMETERS)
+{
+LDAP *ldap;
+pval *link;
+
+ if (getParameters(ht, 1, &link) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ ldap = _get_ldap_link(link, list);
+ if (ldap == NULL) RETURN_LONG(0);
+
+#if !HAVE_NSLDAP
+#if LDAP_API_VERSION > 2000
+ RETURN_LONG(ldap_get_lderrno(ldap, NULL, NULL));
+#else
+ /* Looking at the data structures, I would bet on ld_error,
+ * not ld_errno, but ld->errno is what is used above...
+ * -- KK
+ */
+
+ RETURN_LONG(ldap->ld_errno);
+#endif
+#endif
+ RETURN_LONG(0);
+}
+
+/* {{{ proto string ldap_error(int link)
+ Get the current ldap error string */
+void php3_ldap_error(INTERNAL_FUNCTION_PARAMETERS)
+{
+LDAP *ldap;
+pval *link;
+int ld_errno;
+char *ld_error;
+
+ if (getParameters(ht, 1, &link) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ ldap = _get_ldap_link(link, list);
+ 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
+#endif
+
+ ld_error = ldap_err2string(ldap->ld_errno);
+
+ return_value->value.str.len = strlen(ld_error);
+ return_value->value.str.val = estrndup(ld_error, strlen(ld_error));
+ return_value->type = IS_STRING;
+}
+
+/* {{{ proto string ldap_str2err(int errno)
+ Convert error number to error string */
+void php3_ldap_str2err(INTERNAL_FUNCTION_PARAMETERS)
+{
+pval *errno;
+char *ld_error;
+
+ if (getParameters(ht, 1, &errno) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(errno);
+
+ ld_error = ldap_err2string(errno->value.lval);
+
+ return_value->value.str.len = strlen(ld_error);
+ return_value->value.str.val = estrndup(ld_error, strlen(ld_error));
+ return_value->type = IS_STRING;
+}
/* {{{ proto int ldap_close(int link)
Alias to ldap_unbind */
Index: php3/functions/php3_ldap.h
diff -u php3/functions/php3_ldap.h:1.25 php3/functions/php3_ldap.h:1.26
--- php3/functions/php3_ldap.h:1.25 Mon Mar 8 11:56:48 1999
+++ php3/functions/php3_ldap.h Thu Jul 1 05:15:33 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: php3_ldap.h,v 1.25 1999/03/08 16:56:48 rasmus Exp $ */
+/* $Id: php3_ldap.h,v 1.26 1999/07/01 09:15:33 kk Exp $ */
#ifndef _PHP3_LDAP_H
#define _PHP3_LDAP_H
@@ -87,6 +87,9 @@
extern void php3_ldap_mod_add(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ldap_mod_del(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ldap_mod_replace(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_ldap_errno(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_ldap_error(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_ldap_str2err(INTERNAL_FUNCTION_PARAMETERS);
typedef struct {
long default_link;