jani Sat Oct 6 02:13:50 2007 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/ldap ldap.c Log: MFH:- Add support for LDAP_X_OPT_CONNECT_TIMEOUT (Netscape LDAP SDK equivalent for LDAP_OPT_NETWORK_TIMEOUT) http://cvs.php.net/viewvc.cgi/php-src/ext/ldap/ldap.c?r1=1.161.2.3.2.11.2.2&r2=1.161.2.3.2.11.2.3&diff_format=u Index: php-src/ext/ldap/ldap.c diff -u php-src/ext/ldap/ldap.c:1.161.2.3.2.11.2.2 php-src/ext/ldap/ldap.c:1.161.2.3.2.11.2.3 --- php-src/ext/ldap/ldap.c:1.161.2.3.2.11.2.2 Sat Oct 6 01:43:26 2007 +++ php-src/ext/ldap/ldap.c Sat Oct 6 02:13:50 2007 @@ -23,7 +23,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ldap.c,v 1.161.2.3.2.11.2.2 2007/10/06 01:43:26 jani Exp $ */ +/* $Id: ldap.c,v 1.161.2.3.2.11.2.3 2007/10/06 02:13:50 jani Exp $ */ #define IS_EXT_MODULE #ifdef HAVE_CONFIG_H @@ -260,6 +260,8 @@ 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); +#elif defined (LDAP_X_OPT_CONNECT_TIMEOUT) + REGISTER_LONG_CONSTANT("LDAP_OPT_NETWORK_TIMEOUT", LDAP_X_OPT_CONNECT_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); @@ -325,7 +327,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "LDAP Support", "enabled"); - php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.161.2.3.2.11.2.2 2007/10/06 01:43:26 jani Exp $"); + php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.161.2.3.2.11.2.3 2007/10/06 02:13:50 jani Exp $"); if (LDAPG(max_links) == -1) { snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links)); @@ -1726,20 +1728,30 @@ zval_dtor(*retval); ZVAL_LONG(*retval, val); } break; -#ifdef LDAP_OPT_NETWORK_TIMEOUT +#if defined(LDAP_OPT_NETWORK_TIMEOUT) || defined(LDAP_X_OPT_CONNECT_TIMEOUT) case LDAP_OPT_NETWORK_TIMEOUT: { +# ifdef LDAP_OPT_NETWORK_TIMEOUT struct timeval *timeout; - - if (ldap_get_option(ld->link, opt, (void *) &timeout)) { + + if (ldap_get_option(ld->link, LDAP_OPT_NETWORK_TIMEOUT, (void *) &timeout)) { if (timeout) { ldap_memfree(timeout); } RETURN_FALSE; - } + } zval_dtor(*retval); ZVAL_LONG(*retval, timeout->tv_sec); ldap_memfree(timeout); +# elif defined(LDAP_X_OPT_CONNECT_TIMEOUT) + int timeout; + + if (ldap_get_option(ld->link, LDAP_X_OPT_CONNECT_TIMEOUT, &timeout)) { + RETURN_FALSE; + } + zval_dtor(*retval); + ZVAL_LONG(*retval, (timeout / 1000)); +# endif } break; #endif /* options with string value */ @@ -1824,17 +1836,27 @@ RETURN_FALSE; } } break; -#ifdef LDAP_OPT_NETWORK_TIMEOUT +#if defined(LDAP_OPT_NETWORK_TIMEOUT) || defined(LDAP_X_OPT_CONNECT_TIMEOUT) case LDAP_OPT_NETWORK_TIMEOUT: { +# ifdef 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)) { + if (ldap_set_option(ldap, LDAP_OPT_NETWORK_TIMEOUT, (void *) &timeout)) { RETURN_FALSE; } +# elif defined(LDAP_X_OPT_CONNECT_TIMEOUT) + int timeout; + + convert_to_long_ex(newval); + timeou = 1000 * Z_LVAL_PP(newval); /* Convert to milliseconds */ + if (ldap_set_option(ldap, LDAP_X_OPT_CONNECT_TIMEOUT, &timeout)) { + RETURN_FALSE; + } +# endif } break; #endif /* options with string value */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php