pollita         Tue Oct  3 19:51:35 2006 UTC

  Modified files:              
    /php-src/ext/standard       uuencode.c 
  Log:
  PHP6 updates for convert_uu(en|de)code()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/uuencode.c?r1=1.7&r2=1.8&diff_format=u
Index: php-src/ext/standard/uuencode.c
diff -u php-src/ext/standard/uuencode.c:1.7 php-src/ext/standard/uuencode.c:1.8
--- php-src/ext/standard/uuencode.c:1.7 Sun Jun 25 19:19:31 2006
+++ php-src/ext/standard/uuencode.c     Tue Oct  3 19:51:35 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: uuencode.c,v 1.7 2006/06/25 19:19:31 bjori Exp $ */
+/* $Id: uuencode.c,v 1.8 2006/10/03 19:51:35 pollita Exp $ */
 
 /*
  * Portions of this code are based on Berkeley's uuencode/uudecode
@@ -183,35 +183,60 @@
        return -1;
 }
 
-/* {{{ proto string convert_uuencode(string data) 
+/* {{{ proto string convert_uuencode(string data) U
    uuencode a string */
 PHP_FUNCTION(convert_uuencode)
 {
        char *src, *dst;
        int src_len, dst_len;
+       zend_uchar src_type;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &src, 
&src_len) == FAILURE || src_len < 1) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &src, 
&src_len, &src_type) == FAILURE || src_len < 1) {
                RETURN_FALSE;
        }
 
+       if (src_type == IS_UNICODE) {
+               src = zend_unicode_to_ascii((UChar*)src, src_len TSRMLS_CC);
+               if (!src) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or 
ASCII-Unicode string expected, non-ASCII-Unicode string received");
+                       RETURN_FALSE;
+               }
+       }
+
        dst_len = php_uuencode(src, src_len, &dst);
+       if (src_type == IS_UNICODE) {
+               efree(src);
+       }
 
-       RETURN_STRINGL(dst, dst_len, 0);
+       RETURN_RT_STRINGL(dst, dst_len, ZSTR_AUTOFREE);
 }
 /* }}} */
 
-/* {{{ proto string convert_uudecode(string data)
+/* {{{ proto string convert_uudecode(string data) U
    decode a uuencoded string */
 PHP_FUNCTION(convert_uudecode)
 {
        char *src, *dst;
        int src_len, dst_len;
+       zend_uchar src_type;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &src, 
&src_len) == FAILURE || src_len < 1) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &src, 
&src_len, &src_type) == FAILURE || src_len < 1) {
                RETURN_FALSE;
        }
 
+       if (src_type == IS_UNICODE) {
+               src = zend_unicode_to_ascii((UChar*)src, src_len TSRMLS_CC);
+               if (!src) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or 
ASCII-Unicode string expected, non-ASCII-Unicode string received");
+                       RETURN_FALSE;
+               }
+       }
+
        dst_len = php_uudecode(src, src_len, &dst);
+       if (src_type == IS_UNICODE) {
+               efree(src);
+       }
+
        if (dst_len < 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "The given 
parameter is not a valid uuencoded string.");
                RETURN_FALSE;

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

Reply via email to