]> granicus.if.org Git - php/commitdiff
- Added two new functions: ldap_t61_to_8859() and ldap_8859_to_t61().
authorfoobar <sniper@php.net>
Wed, 2 Aug 2000 13:11:46 +0000 (13:11 +0000)
committerfoobar <sniper@php.net>
Wed, 2 Aug 2000 13:11:46 +0000 (13:11 +0000)
  These functions are available only when using openldap which is compiled
  with STR_TRANSLATION and LDAP_CHARSET_8859 defined in ldap_cdefs.h (Jani)

ext/ldap/ldap.c
ext/ldap/php_ldap.h

index c25d19cce3718145740268b712682f868f51f11e..eefc8aa6ba35eee0f40f60eac5aa4a46842cdad1 100644 (file)
@@ -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
index 8ede7263ebe7110427119272f9235b5bb587591b..3cf4592fe5e7b9df764d5ee51390493a78102f15 100644 (file)
@@ -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;