stas Mon, 24 Jan 2011 03:52:00 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=307691
Log: Add imap_fetchmime Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/imap/php_imap.c U php/php-src/branches/PHP_5_3/ext/imap/php_imap.h U php/php-src/trunk/ext/imap/php_imap.c U php/php-src/trunk/ext/imap/php_imap.h Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2011-01-24 02:48:15 UTC (rev 307690) +++ php/php-src/branches/PHP_5_3/NEWS 2011-01-24 03:52:00 UTC (rev 307691) @@ -49,6 +49,7 @@ (Ilia, valli at icsurselva dot ch) - IMAP extension: + . Implemented FR #53812 (get MIME headers of the part of the email). (Stas) . Fixed bug #53377 (imap_mime_header_decode() doesn't ignore \t during long MIME header unfolding). (Adam) Modified: php/php-src/branches/PHP_5_3/ext/imap/php_imap.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/imap/php_imap.c 2011-01-24 02:48:15 UTC (rev 307690) +++ php/php-src/branches/PHP_5_3/ext/imap/php_imap.c 2011-01-24 03:52:00 UTC (rev 307691) @@ -482,6 +482,7 @@ PHP_FE(imap_body, arginfo_imap_body) PHP_FE(imap_bodystruct, arginfo_imap_bodystruct) PHP_FE(imap_fetchbody, arginfo_imap_fetchbody) + PHP_FE(imap_fetchmime, arginfo_imap_fetchbody) PHP_FE(imap_savebody, arginfo_imap_savebody) PHP_FE(imap_fetchheader, arginfo_imap_fetchheader) PHP_FE(imap_fetchstructure, arginfo_imap_fetchstructure) @@ -2369,6 +2370,46 @@ /* }}} */ + +/* {{{ proto string imap_fetchmime(resource stream_id, int msg_no, string section [, int options]) + Get a specific body section's MIME headers */ +PHP_FUNCTION(imap_fetchmime) +{ + zval *streamind; + long msgno, flags = 0; + pils *imap_le_struct; + char *body, *sec; + int sec_len; + unsigned long len; + int argc = ZEND_NUM_ARGS(); + + if (zend_parse_parameters(argc TSRMLS_CC, "rls|l", &streamind, &msgno, &sec, &sec_len, &flags) == FAILURE) { + return; + } + + if (flags && ((flags & ~(FT_UID|FT_PEEK|FT_INTERNAL)) != 0)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid value for the options parameter"); + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap); + + if (argc < 4 || !(flags & FT_UID)) { + /* only perform the check if the msgno is a message number and not a UID */ + PHP_IMAP_CHECK_MSGNO(msgno); + } + + body = mail_fetch_mime(imap_le_struct->imap_stream, msgno, sec, &len, (argc == 4 ? flags : NIL)); + + if (!body) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No body MIME information available"); + RETURN_FALSE; + } + RETVAL_STRINGL(body, len, 1); +} + +/* }}} */ + /* {{{ proto bool imap_savebody(resource stream_id, string|resource file, int msg_no[, string section = ""[, int options = 0]]) Save a specific body section to a file */ PHP_FUNCTION(imap_savebody) Modified: php/php-src/branches/PHP_5_3/ext/imap/php_imap.h =================================================================== --- php/php-src/branches/PHP_5_3/ext/imap/php_imap.h 2011-01-24 02:48:15 UTC (rev 307690) +++ php/php-src/branches/PHP_5_3/ext/imap/php_imap.h 2011-01-24 03:52:00 UTC (rev 307691) @@ -114,6 +114,7 @@ PHP_FUNCTION(imap_body); PHP_FUNCTION(imap_fetchstructure); PHP_FUNCTION(imap_fetchbody); +PHP_FUNCTION(imap_fetchmime); PHP_FUNCTION(imap_savebody); PHP_FUNCTION(imap_gc); PHP_FUNCTION(imap_expunge); Modified: php/php-src/trunk/ext/imap/php_imap.c =================================================================== --- php/php-src/trunk/ext/imap/php_imap.c 2011-01-24 02:48:15 UTC (rev 307690) +++ php/php-src/trunk/ext/imap/php_imap.c 2011-01-24 03:52:00 UTC (rev 307691) @@ -482,6 +482,7 @@ PHP_FE(imap_body, arginfo_imap_body) PHP_FE(imap_bodystruct, arginfo_imap_bodystruct) PHP_FE(imap_fetchbody, arginfo_imap_fetchbody) + PHP_FE(imap_fetchmime, arginfo_imap_fetchbody) PHP_FE(imap_savebody, arginfo_imap_savebody) PHP_FE(imap_fetchheader, arginfo_imap_fetchheader) PHP_FE(imap_fetchstructure, arginfo_imap_fetchstructure) @@ -2361,6 +2362,46 @@ /* }}} */ + +/* {{{ proto string imap_fetchmime(resource stream_id, int msg_no, string section [, int options]) + Get a specific body section's MIME headers */ +PHP_FUNCTION(imap_fetchmime) +{ + zval *streamind; + long msgno, flags = 0; + pils *imap_le_struct; + char *body, *sec; + int sec_len; + unsigned long len; + int argc = ZEND_NUM_ARGS(); + + if (zend_parse_parameters(argc TSRMLS_CC, "rls|l", &streamind, &msgno, &sec, &sec_len, &flags) == FAILURE) { + return; + } + + if (flags && ((flags & ~(FT_UID|FT_PEEK|FT_INTERNAL)) != 0)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid value for the options parameter"); + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap); + + if (argc < 4 || !(flags & FT_UID)) { + /* only perform the check if the msgno is a message number and not a UID */ + PHP_IMAP_CHECK_MSGNO(msgno); + } + + body = mail_fetch_mime(imap_le_struct->imap_stream, msgno, sec, &len, (argc == 4 ? flags : NIL)); + + if (!body) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No body MIME information available"); + RETURN_FALSE; + } + RETVAL_STRINGL(body, len, 1); +} + +/* }}} */ + /* {{{ proto bool imap_savebody(resource stream_id, string|resource file, int msg_no[, string section = ""[, int options = 0]]) Save a specific body section to a file */ PHP_FUNCTION(imap_savebody) Modified: php/php-src/trunk/ext/imap/php_imap.h =================================================================== --- php/php-src/trunk/ext/imap/php_imap.h 2011-01-24 02:48:15 UTC (rev 307690) +++ php/php-src/trunk/ext/imap/php_imap.h 2011-01-24 03:52:00 UTC (rev 307691) @@ -114,6 +114,7 @@ PHP_FUNCTION(imap_body); PHP_FUNCTION(imap_fetchstructure); PHP_FUNCTION(imap_fetchbody); +PHP_FUNCTION(imap_fetchmime); PHP_FUNCTION(imap_savebody); PHP_FUNCTION(imap_gc); PHP_FUNCTION(imap_expunge);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php