Browse Source

- 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)
PHP-4.0.5
foobar 26 years ago
parent
commit
a4a0e18ec4
  1. 59
      ext/ldap/ldap.c
  2. 5
      ext/ldap/php_ldap.h

59
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

5
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;

Loading…
Cancel
Save