pajoye          Sat May  2 17:59:46 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/imap/tests     imap_mutf7_to_utf8.phpt 
                                imap_utf8_to_mutf7_basic.phpt 

  Modified files:              
    /php-src/ext/imap   php_imap.c php_imap.h 
  Log:
  - [DOC] MFH: add imap_mutf7_to_utf8 and imap_utf8_to_mutf7
  
http://cvs.php.net/viewvc.cgi/php-src/ext/imap/php_imap.c?r1=1.208.2.7.2.26.2.44&r2=1.208.2.7.2.26.2.45&diff_format=u
Index: php-src/ext/imap/php_imap.c
diff -u php-src/ext/imap/php_imap.c:1.208.2.7.2.26.2.44 
php-src/ext/imap/php_imap.c:1.208.2.7.2.26.2.45
--- php-src/ext/imap/php_imap.c:1.208.2.7.2.26.2.44     Thu Apr 30 18:56:25 2009
+++ php-src/ext/imap/php_imap.c Sat May  2 17:59:46 2009
@@ -26,7 +26,7 @@
    | PHP 4.0 updates:  Zeev Suraski <z...@zend.com>                       |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_imap.c,v 1.208.2.7.2.26.2.44 2009/04/30 18:56:25 pajoye Exp $ */
+/* $Id: php_imap.c,v 1.208.2.7.2.26.2.45 2009/05/02 17:59:46 pajoye Exp $ */
 
 #define IMAP41
 
@@ -351,6 +351,14 @@
        ZEND_ARG_INFO(0, buf)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_utf8_to_mutf7, 0, 0, 1)
+       ZEND_ARG_INFO(0, in)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mutf7_to_utf8, 0, 0, 1)
+       ZEND_ARG_INFO(0, in)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_setflag_full, 0, 0, 3)
        ZEND_ARG_INFO(0, stream_id)
        ZEND_ARG_INFO(0, sequence)
@@ -509,6 +517,8 @@
        PHP_FE(imap_search,                                                     
        arginfo_imap_search)
        PHP_FE(imap_utf7_decode,                                                
arginfo_imap_utf7_decode)
        PHP_FE(imap_utf7_encode,                                                
arginfo_imap_utf7_encode)
+       PHP_FE(imap_utf8_to_mutf7,                                              
arginfo_imap_utf8_to_mutf7)
+       PHP_FE(imap_mutf7_to_utf8,                                              
arginfo_imap_mutf7_to_utf8)
        PHP_FE(imap_mime_header_decode,                                 
arginfo_imap_mime_header_decode)
        PHP_FE(imap_thread,                                                     
        arginfo_imap_thread)
        PHP_FE(imap_timeout,                                                    
        arginfo_imap_timeout)
@@ -2885,6 +2895,47 @@
 #undef B64
 #undef UNB64
 
+static void php_imap_mutf7(INTERNAL_FUNCTION_PARAMETERS, int mode)
+{
+       char *in;
+       int in_len;
+       unsigned char *out;
+       
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &in, &in_len) 
== FAILURE) {
+               return;
+       }
+
+       if (in_len < 1) {
+               RETURN_EMPTY_STRING();
+       }
+
+       if (mode == 0) {
+               out = utf8_to_mutf7((unsigned char *) in);
+       } else {
+               out = utf8_from_mutf7((unsigned char *) in);
+       }
+
+       if (out == NIL) {
+               RETURN_FALSE;
+       } else {
+               RETURN_STRING((char *)out, 1);
+       }
+}
+
+/* {{{ proto string imap_utf8_to_mutf7(string in)
+   Encode a UTF-8 string to modified UTF-7 */
+PHP_FUNCTION(imap_utf8_to_mutf7)
+{
+       php_imap_mutf7(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+
+/* {{{ proto string imap_mutf7_to_utf8(string in)
+   Decode a modified UTF-7 string to UTF-8 */
+PHP_FUNCTION(imap_mutf7_to_utf8)
+{
+       php_imap_mutf7(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+
 /* {{{ proto bool imap_setflag_full(resource stream_id, string sequence, 
string flag [, int options])
    Sets flags on messages */
 PHP_FUNCTION(imap_setflag_full)
http://cvs.php.net/viewvc.cgi/php-src/ext/imap/php_imap.h?r1=1.32.2.2.2.1.2.3&r2=1.32.2.2.2.1.2.4&diff_format=u
Index: php-src/ext/imap/php_imap.h
diff -u php-src/ext/imap/php_imap.h:1.32.2.2.2.1.2.3 
php-src/ext/imap/php_imap.h:1.32.2.2.2.1.2.4
--- php-src/ext/imap/php_imap.h:1.32.2.2.2.1.2.3        Tue Apr 28 08:22:57 2009
+++ php-src/ext/imap/php_imap.h Sat May  2 17:59:46 2009
@@ -27,7 +27,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_imap.h,v 1.32.2.2.2.1.2.3 2009/04/28 08:22:57 pajoye Exp $ */
+/* $Id: php_imap.h,v 1.32.2.2.2.1.2.4 2009/05/02 17:59:46 pajoye Exp $ */
 
 #ifndef PHP_IMAP_H
 #define PHP_IMAP_H
@@ -165,6 +165,8 @@
 PHP_FUNCTION(imap_utf8);
 PHP_FUNCTION(imap_utf7_decode);
 PHP_FUNCTION(imap_utf7_encode);
+PHP_FUNCTION(imap_utf8_to_mutf7);
+PHP_FUNCTION(imap_mutf7_to_utf8);
 PHP_FUNCTION(imap_mime_header_decode);
 PHP_FUNCTION(imap_thread);
 PHP_FUNCTION(imap_timeout);

http://cvs.php.net/viewvc.cgi/php-src/ext/imap/tests/imap_mutf7_to_utf8.phpt?view=markup&rev=1.1
Index: php-src/ext/imap/tests/imap_mutf7_to_utf8.phpt
+++ php-src/ext/imap/tests/imap_mutf7_to_utf8.phpt
--TEST--
imap_mutf7_to_utf8
--SKIPIF--
<?php if (!extension_loaded("imap")) print "skip"; ?>
--FILE--
<?php

var_dump(imap_mutf7_to_utf8(b""));
var_dump(imap_mutf7_to_utf8(1));
var_dump(imap_mutf7_to_utf8(array(1,2)));
var_dump(imap_mutf7_to_utf8(b"t&AOQ-st"));

echo "Done\n";
?>
--EXPECTF--     
unicode(0) ""
unicode(1) "1"

Warning: imap_mutf7_to_utf8() expects parameter 1 to be binary string, array 
given in %s on line %d
NULL
unicode(4) "täst"
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/imap/tests/imap_utf8_to_mutf7_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/imap/tests/imap_utf8_to_mutf7_basic.phpt
+++ php-src/ext/imap/tests/imap_utf8_to_mutf7_basic.phpt
--TEST--
imap_utf8_to_mutf7
--SKIPIF--
<?php if (!extension_loaded("imap")) print "skip"; ?>
--FILE--
<?php

var_dump(imap_utf8_to_mutf7(""));
var_dump(imap_utf8_to_mutf7(1));
var_dump(imap_utf8_to_mutf7(array(1,2)));

$test = 't' . chr(228) . 'st';
var_dump(imap_utf8_to_mutf7(utf8_encode($test)));

echo "Done\n";
?>
--EXPECTF--     
string(0) ""
string(1) "1"

Warning: imap_utf8_to_mutf7() expects parameter 1 to be binary string, array 
given in %s on line %d
NULL
string(8) "t&AOQ-st"
Done



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to