From: foobar Date: Wed, 2 Aug 2000 13:11:46 +0000 (+0000) Subject: - Added two new functions: ldap_t61_to_8859() and ldap_8859_to_t61(). X-Git-Tag: PRE_FILE_COMPILE_API_CHANGE~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4a0e18ec4f5bf06672f4188b39858c3bbf98bb9;p=php - Added two new functions: ldap_t61_to_8859() and ldap_8859_to_t61(). These functions are available only when using openldap which is compiled with STR_TRANSLATION and LDAP_CHARSET_8859 defined in ldap_cdefs.h (Jani) --- diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index c25d19cce3..eefc8aa6ba 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -91,6 +91,12 @@ function_entry ldap_functions[] = { PHP_FE(ldap_err2str, NULL) PHP_FE(ldap_error, NULL) PHP_FE(ldap_compare, NULL) + +#ifdef STR_TRANSLATION + PHP_FE(ldap_t61_to_8859, NULL) + PHP_FE(ldap_8859_to_t61, NULL) +#endif + {NULL, NULL, NULL} }; @@ -1419,3 +1425,56 @@ PHP_FUNCTION(ldap_compare) { } /* }}} */ + +#ifdef STR_TRANSLATION +static void php_ldap_do_translate(INTERNAL_FUNCTION_PARAMETERS, int way) { + zval **value; + char *ldap_buf; + unsigned long ldap_len; + int result; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &value) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_string_ex(value); + ldap_buf = (*value)->value.str.val; + ldap_len = (*value)->value.str.len; + + if(ldap_len == 0) { + RETURN_FALSE; + } + + if(way == 1) { + result = ldap_8859_to_t61(&ldap_buf, &ldap_len, 0); + } else { + result = ldap_t61_to_8859(&ldap_buf, &ldap_len, 0); + } + + if (result == LDAP_SUCCESS) { + RETVAL_STRINGL(ldap_buf,ldap_len,1); + free(ldap_buf); + } else { + php_error(E_ERROR, "LDAP: Conversion from iso-8859-1 to t61 failed."); + RETVAL_FALSE; + } + + return; +} + + +/* {{{ proto string ldap_t61_to_8859(string value) + Translate t61 characters to 8859 characters */ +PHP_FUNCTION(ldap_t61_to_8859) { + php_ldap_do_translate(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); +} +/* }}} */ + + +/* {{{ proto string ldap_8859_to_t61(string value) + Translate 8859 characters to t61 characters */ +PHP_FUNCTION(ldap_8859_to_t61) { + php_ldap_do_translate(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); +} +/* }}} */ +#endif diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h index 8ede7263eb..3cf4592fe5 100644 --- a/ext/ldap/php_ldap.h +++ b/ext/ldap/php_ldap.h @@ -79,6 +79,11 @@ PHP_FUNCTION(ldap_error); PHP_FUNCTION(ldap_compare); +#ifdef STR_TRANSLATION +PHP_FUNCTION(ldap_t61_to_8859); +PHP_FUNCTION(ldap_8859_to_t61); +#endif + ZEND_BEGIN_MODULE_GLOBALS(ldap) long default_link; long num_links, max_links;