diff options
author | Pierre Joye <pajoye@php.net> | 2009-05-02 17:59:46 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2009-05-02 17:59:46 +0000 |
commit | 9faccc3da1ccea9f7d6475e07b9a761ebd276c37 (patch) | |
tree | b44b654c86ef0148309b7a6a3b22d3fe97e4c852 /ext/imap/php_imap.c | |
parent | 72d2473d5bb461d59d21644daae07c1dac1033a1 (diff) | |
download | php-git-9faccc3da1ccea9f7d6475e07b9a761ebd276c37.tar.gz |
- [DOC] MFH: add imap_mutf7_to_utf8 and imap_utf8_to_mutf7
Diffstat (limited to 'ext/imap/php_imap.c')
-rw-r--r-- | ext/imap/php_imap.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 0114056c3a..8ad4ac1a4a 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -351,6 +351,14 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_utf7_encode, 0, 0, 1) 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 @@ const zend_function_entry imap_functions[] = { 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 @@ PHP_FUNCTION(imap_utf7_encode) #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) |