summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJani Taskinen <jani@php.net>2007-10-06 01:42:40 +0000
committerJani Taskinen <jani@php.net>2007-10-06 01:42:40 +0000
commitcffb1afb105b9b91292ad6217f9b8e3695ee186a (patch)
tree89a2f83fae5d374c5195802d19b45561ebb9fefa
parentedb05ab6c02da93b2b846bf0d857890e28482386 (diff)
downloadphp-git-cffb1afb105b9b91292ad6217f9b8e3695ee186a.tar.gz
- Added LDAP_OPT_NETWORK_TIMEOUT option for ldap_set_option() to allow setting network timeout
-rw-r--r--ext/ldap/ldap.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 00a3c3510a..8440000be6 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -258,6 +258,9 @@ PHP_MINIT_FUNCTION(ldap)
REGISTER_LONG_CONSTANT("LDAP_OPT_DEREF", LDAP_OPT_DEREF, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_OPT_SIZELIMIT", LDAP_OPT_SIZELIMIT, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_OPT_TIMELIMIT", LDAP_OPT_TIMELIMIT, CONST_PERSISTENT | CONST_CS);
+#ifdef LDAP_OPT_NETWORK_TIMEOUT
+ REGISTER_LONG_CONSTANT("LDAP_OPT_NETWORK_TIMEOUT", LDAP_OPT_NETWORK_TIMEOUT, CONST_PERSISTENT | CONST_CS);
+#endif
REGISTER_LONG_CONSTANT("LDAP_OPT_PROTOCOL_VERSION", LDAP_OPT_PROTOCOL_VERSION, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_OPT_ERROR_NUMBER", LDAP_OPT_ERROR_NUMBER, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_OPT_REFERRALS", LDAP_OPT_REFERRALS, CONST_PERSISTENT | CONST_CS);
@@ -1714,12 +1717,29 @@ PHP_FUNCTION(ldap_get_option)
#endif
{
int val;
+
if (ldap_get_option(ld->link, opt, &val)) {
RETURN_FALSE;
}
zval_dtor(*retval);
ZVAL_LONG(*retval, val);
} break;
+#ifdef LDAP_OPT_NETWORK_TIMEOUT
+ case LDAP_OPT_NETWORK_TIMEOUT:
+ {
+ struct timeval *timeout;
+
+ if (ldap_get_option(ld->link, opt, (void *) &timeout)) {
+ if (timeout) {
+ ldap_memfree(timeout);
+ }
+ RETURN_FALSE;
+ }
+ zval_dtor(*retval);
+ ZVAL_LONG(*retval, timeout->tv_sec);
+ ldap_memfree(timeout);
+ } break;
+#endif
/* options with string value */
case LDAP_OPT_ERROR_STRING:
#ifdef LDAP_OPT_HOST_NAME
@@ -1795,12 +1815,26 @@ PHP_FUNCTION(ldap_set_option)
#endif
{
int val;
+
convert_to_long_ex(newval);
val = Z_LVAL_PP(newval);
if (ldap_set_option(ldap, opt, &val)) {
RETURN_FALSE;
}
} break;
+#ifdef LDAP_OPT_NETWORK_TIMEOUT
+ case LDAP_OPT_NETWORK_TIMEOUT:
+ {
+ struct timeval timeout;
+
+ convert_to_long_ex(newval);
+ timeout.tv_sec = Z_LVAL_PP(newval);
+ timeout.tv_usec = 0;
+ if (ldap_set_option(ldap, opt, (void *) &timeout)) {
+ RETURN_FALSE;
+ }
+ } break;
+#endif
/* options with string value */
case LDAP_OPT_ERROR_STRING:
#ifdef LDAP_OPT_HOST_NAME