diff options
author | foobar <sniper@php.net> | 2000-08-02 13:11:46 +0000 |
---|---|---|
committer | foobar <sniper@php.net> | 2000-08-02 13:11:46 +0000 |
commit | a4a0e18ec4f5bf06672f4188b39858c3bbf98bb9 (patch) | |
tree | a17e3f7af41c1592f8ab40415574ec832cc8d357 | |
parent | 53435364293bc827fb1296a0a32e2e13451834f9 (diff) | |
download | php-git-a4a0e18ec4f5bf06672f4188b39858c3bbf98bb9.tar.gz |
- 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)
-rw-r--r-- | ext/ldap/ldap.c | 59 | ||||
-rw-r--r-- | ext/ldap/php_ldap.h | 5 |
2 files changed, 64 insertions, 0 deletions
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; |