summaryrefslogtreecommitdiff
path: root/ext/imap/php_imap.c
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 19:39:21 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 19:39:21 -0400
commit6821b67124604da690c5e9276d5370d679c63ac8 (patch)
treebefb4ca2520eb577950cef6cb76d10b914cbf67a /ext/imap/php_imap.c
parentcd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f (diff)
downloadphp-6821b67124604da690c5e9276d5370d679c63ac8.tar.gz
Imported Upstream version 5.3.0RC1upstream/5.3.0_RC1upstream/5.3.0RC1
Diffstat (limited to 'ext/imap/php_imap.c')
-rw-r--r--ext/imap/php_imap.c1782
1 files changed, 995 insertions, 787 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index e58e99778..b820d3ec6 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -26,7 +26,7 @@
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_imap.c,v 1.208.2.7.2.43 2008/12/31 11:17:38 sebastian Exp $ */
+/* $Id: php_imap.c,v 1.208.2.7.2.26.2.31 2009/01/08 16:13:51 iliaa Exp $ */
#define IMAP41
@@ -67,6 +67,12 @@ MAILSTREAM DEFAULTPROTO;
#define SENDBUFLEN 16385
#endif
+#if defined(__GNUC__) && __GNUC__ >= 4
+# define PHP_IMAP_EXPORT __attribute__ ((visibility("default")))
+#else
+# define PHP_IMAP_EXPORT
+#endif
+
static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC);
static void _php_imap_add_body(zval *arg, BODY *body TSRMLS_DC);
@@ -92,90 +98,441 @@ void *fs_get(size_t size);
ZEND_DECLARE_MODULE_GLOBALS(imap)
static PHP_GINIT_FUNCTION(imap);
+/* {{{ arginfo */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_open, 0, 0, 3)
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_ARG_INFO(0, user)
+ ZEND_ARG_INFO(0, password)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, n_retries)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_reopen, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, n_retries)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_append, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, folder)
+ ZEND_ARG_INFO(0, message)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_num_msg, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_ping, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_num_recent, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ZEND_END_ARG_INFO()
+
+#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_get_quota, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, qroot)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_get_quotaroot, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mbox)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_set_quota, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, qroot)
+ ZEND_ARG_INFO(0, mailbox_size)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_setacl, 0, 0, 4)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_ARG_INFO(0, id)
+ ZEND_ARG_INFO(0, rights)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_getacl, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ZEND_END_ARG_INFO()
+#endif
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_expunge, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_close, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_headers, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_body, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mail_copy, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msglist)
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mail_move, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, sequence)
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_createmailbox, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_renamemailbox, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, old_name)
+ ZEND_ARG_INFO(0, new_name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_deletemailbox, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_list, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, ref)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_getmailboxes, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, ref)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_listscan, 0, 0, 4)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, ref)
+ ZEND_ARG_INFO(0, pattern)
+ ZEND_ARG_INFO(0, content)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_check, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_delete, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_undelete, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_headerinfo, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, from_length)
+ ZEND_ARG_INFO(0, subject_length)
+ ZEND_ARG_INFO(0, default_host)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_rfc822_parse_headers, 0, 0, 1)
+ ZEND_ARG_INFO(0, headers)
+ ZEND_ARG_INFO(0, default_host)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_lsub, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, ref)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_getsubscribed, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, ref)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_subscribe, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_unsubscribe, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_fetchstructure, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_fetchbody, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, section)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_savebody, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, file)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, section)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_base64, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_qprint, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_8bit, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_binary, 0, 0, 1)
+ ZEND_ARG_INFO(0, text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mailboxmsginfo, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_rfc822_write_address, 0, 0, 3)
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_ARG_INFO(0, host)
+ ZEND_ARG_INFO(0, personal)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_rfc822_parse_adrlist, 0, 0, 2)
+ ZEND_ARG_INFO(0, address_string)
+ ZEND_ARG_INFO(0, default_host)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_utf8, 0, 0, 1)
+ ZEND_ARG_INFO(0, mime_encoded_text)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_utf7_decode, 0, 0, 1)
+ ZEND_ARG_INFO(0, buf)
+ZEND_END_ARG_INFO()
+
+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_setflag_full, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, sequence)
+ ZEND_ARG_INFO(0, flag)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_clearflag_full, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, sequence)
+ ZEND_ARG_INFO(0, flag)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_sort, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, criteria)
+ ZEND_ARG_INFO(0, reverse)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, search_criteria)
+ ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_fetchheader, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_uid, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_msgno, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, unique_msg_id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_status, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_bodystruct, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, msg_no)
+ ZEND_ARG_INFO(0, section)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_fetch_overview, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, sequence)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mail_compose, 0, 0, 2)
+ ZEND_ARG_INFO(0, envelope)
+ ZEND_ARG_INFO(0, body)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mail, 0, 0, 3)
+ ZEND_ARG_INFO(0, to)
+ ZEND_ARG_INFO(0, subject)
+ ZEND_ARG_INFO(0, message)
+ ZEND_ARG_INFO(0, additional_headers)
+ ZEND_ARG_INFO(0, cc)
+ ZEND_ARG_INFO(0, bcc)
+ ZEND_ARG_INFO(0, rpath)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_search, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, criteria)
+ ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_imap_alerts, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_imap_errors, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_imap_last_error, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mime_header_decode, 0, 0, 1)
+ ZEND_ARG_INFO(0, str)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_thread, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, options)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_timeout, 0, 0, 1)
+ ZEND_ARG_INFO(0, timeout_type)
+ ZEND_ARG_INFO(0, timeout)
+ZEND_END_ARG_INFO()
+/* }}} */
+
/* {{{ imap_functions[]
*/
-zend_function_entry imap_functions[] = {
- PHP_FE(imap_open, NULL)
- PHP_FE(imap_reopen, NULL)
- PHP_FE(imap_close, NULL)
- PHP_FE(imap_num_msg, NULL)
- PHP_FE(imap_num_recent, NULL)
- PHP_FE(imap_headers, NULL)
- PHP_FE(imap_headerinfo, NULL)
- PHP_FE(imap_rfc822_parse_headers, NULL)
- PHP_FE(imap_rfc822_write_address, NULL)
- PHP_FE(imap_rfc822_parse_adrlist, NULL)
- PHP_FE(imap_body, NULL)
- PHP_FE(imap_bodystruct, NULL)
- PHP_FE(imap_fetchbody, NULL)
- PHP_FE(imap_savebody, NULL)
- PHP_FE(imap_fetchheader, NULL)
- PHP_FE(imap_fetchstructure, NULL)
- PHP_FE(imap_expunge, NULL)
- PHP_FE(imap_delete, NULL)
- PHP_FE(imap_undelete, NULL)
- PHP_FE(imap_check, NULL)
- PHP_FE(imap_mail_copy, NULL)
- PHP_FE(imap_mail_move, NULL)
- PHP_FE(imap_mail_compose, NULL)
- PHP_FE(imap_createmailbox, NULL)
- PHP_FE(imap_renamemailbox, NULL)
- PHP_FE(imap_deletemailbox, NULL)
- PHP_FE(imap_subscribe, NULL)
- PHP_FE(imap_unsubscribe, NULL)
- PHP_FE(imap_append, NULL)
- PHP_FE(imap_ping, NULL)
- PHP_FE(imap_base64, NULL)
- PHP_FE(imap_qprint, NULL)
- PHP_FE(imap_8bit, NULL)
- PHP_FE(imap_binary, NULL)
- PHP_FE(imap_utf8, NULL)
- PHP_FE(imap_status, NULL)
- PHP_FE(imap_mailboxmsginfo, NULL)
- PHP_FE(imap_setflag_full, NULL)
- PHP_FE(imap_clearflag_full, NULL)
- PHP_FE(imap_sort, NULL)
- PHP_FE(imap_uid, NULL)
- PHP_FE(imap_msgno, NULL)
- PHP_FE(imap_list, NULL)
- PHP_FE(imap_lsub, NULL)
- PHP_FE(imap_fetch_overview, NULL)
- PHP_FE(imap_alerts, NULL)
- PHP_FE(imap_errors, NULL)
- PHP_FE(imap_last_error, NULL)
- PHP_FE(imap_search, NULL)
- PHP_FE(imap_utf7_decode, NULL)
- PHP_FE(imap_utf7_encode, NULL)
- PHP_FE(imap_mime_header_decode, NULL)
- PHP_FE(imap_thread, NULL)
- PHP_FE(imap_timeout, NULL)
+const zend_function_entry imap_functions[] = {
+ PHP_FE(imap_open, arginfo_imap_open)
+ PHP_FE(imap_reopen, arginfo_imap_reopen)
+ PHP_FE(imap_close, arginfo_imap_close)
+ PHP_FE(imap_num_msg, arginfo_imap_num_msg)
+ PHP_FE(imap_num_recent, arginfo_imap_num_recent)
+ PHP_FE(imap_headers, arginfo_imap_headers)
+ PHP_FE(imap_headerinfo, arginfo_imap_headerinfo)
+ PHP_FE(imap_rfc822_parse_headers, arginfo_imap_rfc822_parse_headers)
+ PHP_FE(imap_rfc822_write_address, arginfo_imap_rfc822_write_address)
+ PHP_FE(imap_rfc822_parse_adrlist, arginfo_imap_rfc822_parse_adrlist)
+ PHP_FE(imap_body, arginfo_imap_body)
+ PHP_FE(imap_bodystruct, arginfo_imap_bodystruct)
+ PHP_FE(imap_fetchbody, arginfo_imap_fetchbody)
+ PHP_FE(imap_savebody, arginfo_imap_savebody)
+ PHP_FE(imap_fetchheader, arginfo_imap_fetchheader)
+ PHP_FE(imap_fetchstructure, arginfo_imap_fetchstructure)
+ PHP_FE(imap_expunge, arginfo_imap_expunge)
+ PHP_FE(imap_delete, arginfo_imap_delete)
+ PHP_FE(imap_undelete, arginfo_imap_undelete)
+ PHP_FE(imap_check, arginfo_imap_check)
+ PHP_FE(imap_mail_copy, arginfo_imap_mail_copy)
+ PHP_FE(imap_mail_move, arginfo_imap_mail_move)
+ PHP_FE(imap_mail_compose, arginfo_imap_mail_compose)
+ PHP_FE(imap_createmailbox, arginfo_imap_createmailbox)
+ PHP_FE(imap_renamemailbox, arginfo_imap_renamemailbox)
+ PHP_FE(imap_deletemailbox, arginfo_imap_deletemailbox)
+ PHP_FE(imap_subscribe, arginfo_imap_subscribe)
+ PHP_FE(imap_unsubscribe, arginfo_imap_unsubscribe)
+ PHP_FE(imap_append, arginfo_imap_append)
+ PHP_FE(imap_ping, arginfo_imap_ping)
+ PHP_FE(imap_base64, arginfo_imap_base64)
+ PHP_FE(imap_qprint, arginfo_imap_qprint)
+ PHP_FE(imap_8bit, arginfo_imap_8bit)
+ PHP_FE(imap_binary, arginfo_imap_binary)
+ PHP_FE(imap_utf8, arginfo_imap_utf8)
+ PHP_FE(imap_status, arginfo_imap_status)
+ PHP_FE(imap_mailboxmsginfo, arginfo_imap_mailboxmsginfo)
+ PHP_FE(imap_setflag_full, arginfo_imap_setflag_full)
+ PHP_FE(imap_clearflag_full, arginfo_imap_clearflag_full)
+ PHP_FE(imap_sort, arginfo_imap_sort)
+ PHP_FE(imap_uid, arginfo_imap_uid)
+ PHP_FE(imap_msgno, arginfo_imap_msgno)
+ PHP_FE(imap_list, arginfo_imap_list)
+ PHP_FE(imap_lsub, arginfo_imap_lsub)
+ PHP_FE(imap_fetch_overview, arginfo_imap_fetch_overview)
+ PHP_FE(imap_alerts, arginfo_imap_alerts)
+ PHP_FE(imap_errors, arginfo_imap_errors)
+ PHP_FE(imap_last_error, arginfo_imap_last_error)
+ 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_mime_header_decode, arginfo_imap_mime_header_decode)
+ PHP_FE(imap_thread, arginfo_imap_thread)
+ PHP_FE(imap_timeout, arginfo_imap_timeout)
#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
- PHP_FE(imap_get_quota, NULL)
- PHP_FE(imap_get_quotaroot, NULL)
- PHP_FE(imap_set_quota, NULL)
- PHP_FE(imap_setacl, NULL)
- PHP_FE(imap_getacl, NULL)
+ PHP_FE(imap_get_quota, arginfo_imap_get_quota)
+ PHP_FE(imap_get_quotaroot, arginfo_imap_get_quotaroot)
+ PHP_FE(imap_set_quota, arginfo_imap_set_quota)
+ PHP_FE(imap_setacl, arginfo_imap_setacl)
+ PHP_FE(imap_getacl, arginfo_imap_getacl)
#endif
- PHP_FE(imap_mail, NULL)
-
- PHP_FALIAS(imap_header, imap_headerinfo, NULL)
- PHP_FALIAS(imap_listmailbox, imap_list, NULL)
- PHP_FALIAS(imap_getmailboxes, imap_list_full, NULL)
- PHP_FALIAS(imap_scanmailbox, imap_listscan, NULL)
- PHP_FALIAS(imap_listsubscribed, imap_lsub, NULL)
- PHP_FALIAS(imap_getsubscribed, imap_lsub_full, NULL)
- PHP_FALIAS(imap_fetchtext, imap_body, NULL)
- PHP_FALIAS(imap_scan, imap_listscan, NULL)
- PHP_FALIAS(imap_create, imap_createmailbox, NULL)
- PHP_FALIAS(imap_rename, imap_renamemailbox, NULL)
+ PHP_FE(imap_mail, arginfo_imap_mail)
+
+ PHP_FALIAS(imap_header, imap_headerinfo, arginfo_imap_headerinfo)
+ PHP_FALIAS(imap_listmailbox, imap_list, arginfo_imap_list)
+ PHP_FALIAS(imap_getmailboxes, imap_list_full, arginfo_imap_getmailboxes)
+ PHP_FALIAS(imap_scanmailbox, imap_listscan, arginfo_imap_listscan)
+ PHP_FALIAS(imap_listsubscribed, imap_lsub, arginfo_imap_lsub)
+ PHP_FALIAS(imap_getsubscribed, imap_lsub_full, arginfo_imap_getsubscribed)
+ PHP_FALIAS(imap_fetchtext, imap_body, arginfo_imap_body)
+ PHP_FALIAS(imap_scan, imap_listscan, arginfo_imap_listscan)
+ PHP_FALIAS(imap_create, imap_createmailbox, arginfo_imap_createmailbox)
+ PHP_FALIAS(imap_rename, imap_renamemailbox, arginfo_imap_renamemailbox)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ imap dependencies */
-static zend_module_dep imap_deps[] = {
+static const zend_module_dep imap_deps[] = {
ZEND_MOD_REQUIRED("standard")
{NULL, NULL, NULL}
};
@@ -739,6 +1096,21 @@ PHP_MINFO_FUNCTION(imap)
{
php_info_print_table_start();
php_info_print_table_row(2, "IMAP c-Client Version", CCLIENTVERSION);
+#if HAVE_IMAP2007b
+ php_info_print_table_row(2, "IMAP c-Client Version", "2007b");
+#elif HAVE_IMAP2007a
+ php_info_print_table_row(2, "IMAP c-Client Version", "2007a");
+#elif HAVE_IMAP2004
+ php_info_print_table_row(2, "IMAP c-Client Version", "2004");
+#elif HAVE_IMAP2001
+ php_info_print_table_row(2, "IMAP c-Client Version", "2001");
+#elif HAVE_IMAP2000
+ php_info_print_table_row(2, "IMAP c-Client Version", "2000");
+#elif defined(IMAP41)
+ php_info_print_table_row(2, "IMAP c-Client Version", "4.1");
+#else
+ php_info_print_table_row(2, "IMAP c-Client Version", "4.0");
+#endif
#if HAVE_IMAP_SSL
php_info_print_table_row(2, "SSL Support", "enabled");
#endif
@@ -753,23 +1125,19 @@ PHP_MINFO_FUNCTION(imap)
*/
static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
- zval **mailbox, **user, **passwd, **options, **retries;
+ char *mailbox, *user, *passwd;
+ int mailbox_len, user_len, passwd_len;
+ long retries = 0, flags = NIL, cl_flags = NIL;
MAILSTREAM *imap_stream;
pils *imap_le_struct;
- long flags=NIL;
- long cl_flags=NIL;
- int myargc = ZEND_NUM_ARGS();
+ int argc = ZEND_NUM_ARGS();
- if (myargc < 3 || myargc > 5 || zend_get_parameters_ex(myargc, &mailbox, &user, &passwd, &options, &retries) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "sss|ll", &mailbox, &mailbox_len, &user, &user_len,
+ &passwd, &passwd_len, &flags, &retries) == FAILURE) {
+ return;
}
- convert_to_string_ex(mailbox);
- convert_to_string_ex(user);
- convert_to_string_ex(passwd);
- if (myargc >= 4) {
- convert_to_long_ex(options);
- flags = Z_LVAL_PP(options);
+ if (argc >= 4) {
if (flags & PHP_EXPUNGE) {
cl_flags = CL_EXPUNGE;
flags ^= PHP_EXPUNGE;
@@ -785,30 +1153,29 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
/* local filename, need to perform open_basedir and safe_mode checks */
- if (Z_STRVAL_PP(mailbox)[0] != '{' &&
- (php_check_open_basedir(Z_STRVAL_PP(mailbox) TSRMLS_CC) ||
- (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(mailbox), NULL, CHECKUID_CHECK_FILE_AND_DIR)))) {
+ if (mailbox[0] != '{' &&
+ (php_check_open_basedir(mailbox TSRMLS_CC) ||
+ (PG(safe_mode) && !php_checkuid(mailbox, NULL, CHECKUID_CHECK_FILE_AND_DIR)))) {
RETURN_FALSE;
}
- IMAPG(imap_user) = estrndup(Z_STRVAL_PP(user), Z_STRLEN_PP(user));
- IMAPG(imap_password) = estrndup(Z_STRVAL_PP(passwd), Z_STRLEN_PP(passwd));
+ IMAPG(imap_user) = estrndup(user, user_len);
+ IMAPG(imap_password) = estrndup(passwd, passwd_len);
#ifdef SET_MAXLOGINTRIALS
- if (myargc == 5) {
- convert_to_long_ex(retries);
- if (Z_LVAL_PP(retries) < 0) {
+ if (argc == 5) {
+ if (retries < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING ,"Retries must be greater or equal to 0");
} else {
- mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) Z_LVAL_PP(retries));
+ mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) retries);
}
}
#endif
- imap_stream = mail_open(NIL, Z_STRVAL_PP(mailbox), flags);
+ imap_stream = mail_open(NIL, mailbox, flags);
if (imap_stream == NIL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't open stream %s", Z_STRVAL_PP(mailbox));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't open stream %s", mailbox);
efree(IMAPG(imap_user)); IMAPG(imap_user) = 0;
efree(IMAPG(imap_password)); IMAPG(imap_password) = 0;
RETURN_FALSE;
@@ -834,24 +1201,23 @@ PHP_FUNCTION(imap_open)
Reopen an IMAP stream to a new mailbox */
PHP_FUNCTION(imap_reopen)
{
- zval **streamind, **mailbox, **options, **retries;
+ zval *streamind;
+ char *mailbox;
+ int mailbox_len;
+ long options = NULL, retries = NULL;
pils *imap_le_struct;
MAILSTREAM *imap_stream;
long flags=NIL;
long cl_flags=NIL;
- int myargc=ZEND_NUM_ARGS();
- if (myargc < 2 || myargc > 4 || zend_get_parameters_ex(myargc, &streamind, &mailbox, &options, &retries) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|ll", &streamind, &mailbox, &mailbox_len, &options, &retries) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(mailbox);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- if (myargc >= 3) {
- convert_to_long_ex(options);
- flags = Z_LVAL_PP(options);
+ if (options) {
+ flags = options;
if (flags & PHP_EXPUNGE) {
cl_flags = CL_EXPUNGE;
flags ^= PHP_EXPUNGE;
@@ -859,19 +1225,18 @@ PHP_FUNCTION(imap_reopen)
imap_le_struct->flags = cl_flags;
}
#ifdef SET_MAXLOGINTRIALS
- if (myargc == 4) {
- convert_to_long_ex(retries);
- mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) Z_LVAL_PP(retries));
+ if (retries) {
+ mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) retries);
}
#endif
/* local filename, need to perform open_basedir and safe_mode checks */
- if (Z_STRVAL_PP(mailbox)[0] != '{' &&
- (php_check_open_basedir(Z_STRVAL_PP(mailbox) TSRMLS_CC) ||
- (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(mailbox), NULL, CHECKUID_CHECK_FILE_AND_DIR)))) {
+ if (mailbox[0] != '{' &&
+ (php_check_open_basedir(mailbox TSRMLS_CC) ||
+ (PG(safe_mode) && !php_checkuid(mailbox, NULL, CHECKUID_CHECK_FILE_AND_DIR)))) {
RETURN_FALSE;
}
- imap_stream = mail_open(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox), flags);
+ imap_stream = mail_open(imap_le_struct->imap_stream, mailbox, flags);
if (imap_stream == NIL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't re-open stream");
RETURN_FALSE;
@@ -885,27 +1250,21 @@ PHP_FUNCTION(imap_reopen)
Append a new message to a specified mailbox */
PHP_FUNCTION(imap_append)
{
- zval **streamind, **folder, **message, **flags;
- pils *imap_le_struct;
+ zval *streamind;
+ char *folder, *message, *flags = NULL;
+ int folder_len, message_len, flags_len = 0;
+ pils *imap_le_struct;
STRING st;
- int myargc=ZEND_NUM_ARGS();
-
- if (myargc < 3 || myargc > 4 || zend_get_parameters_ex(myargc, &streamind, &folder, &message, &flags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(folder);
- convert_to_string_ex(message);
- if (myargc == 4) {
- convert_to_string_ex(flags);
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|s", &streamind, &folder, &folder_len, &message, &message_len, &flags, &flags_len) == FAILURE) {
+ return;
}
+
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- INIT (&st, mail_string, (void *) Z_STRVAL_PP(message), Z_STRLEN_PP(message));
+ INIT (&st, mail_string, (void *) message, message_len);
- if (mail_append_full(imap_le_struct->imap_stream, Z_STRVAL_PP(folder), myargc==4 ? Z_STRVAL_PP(flags) : NIL, NIL, &st)) {
+ if (mail_append_full(imap_le_struct->imap_stream, folder, (flags ? flags : NIL), NIL, &st)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -917,14 +1276,14 @@ PHP_FUNCTION(imap_append)
Gives the number of messages in the current mailbox */
PHP_FUNCTION(imap_num_msg)
{
- zval **streamind;
+ zval *streamind;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &streamind) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
RETURN_LONG(imap_le_struct->imap_stream->nmsgs);
}
@@ -934,14 +1293,14 @@ PHP_FUNCTION(imap_num_msg)
Check if the IMAP stream is still active */
PHP_FUNCTION(imap_ping)
{
- zval **streamind;
+ zval *streamind;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &streamind) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
RETURN_BOOL(mail_ping(imap_le_struct->imap_stream));
}
@@ -951,14 +1310,14 @@ PHP_FUNCTION(imap_ping)
Gives the number of recent messages in current mailbox */
PHP_FUNCTION(imap_num_recent)
{
- zval **streamind;
+ zval *streamind;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &streamind) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
RETURN_LONG(imap_le_struct->imap_stream->recent);
}
@@ -969,23 +1328,23 @@ PHP_FUNCTION(imap_num_recent)
Returns the quota set to the mailbox account qroot */
PHP_FUNCTION(imap_get_quota)
{
- zval **streamind, **qroot;
+ zval *streamind;
+ char *qroot;
+ int qroot_len;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &qroot) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &streamind, &qroot, &qroot_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(qroot);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
array_init(return_value);
IMAPG(quota_return) = &return_value;
/* set the callback for the GET_QUOTA function */
mail_parameters(NIL, SET_QUOTA, (void *) mail_getquota);
- if(!imap_getquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot))) {
+ if (!imap_getquota(imap_le_struct->imap_stream, qroot)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "c-client imap_getquota failed");
zval_dtor(return_value);
RETURN_FALSE;
@@ -997,23 +1356,23 @@ PHP_FUNCTION(imap_get_quota)
Returns the quota set to the mailbox account mbox */
PHP_FUNCTION(imap_get_quotaroot)
{
- zval **streamind, **mbox;
+ zval *streamind;
+ char *mbox;
+ int mbox_len;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &mbox) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &streamind, &mbox, &mbox_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(mbox);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
array_init(return_value);
IMAPG(quota_return) = &return_value;
/* set the callback for the GET_QUOTAROOT function */
mail_parameters(NIL, SET_QUOTA, (void *) mail_getquota);
- if(!imap_getquotaroot(imap_le_struct->imap_stream, Z_STRVAL_PP(mbox))) {
+ if (!imap_getquotaroot(imap_le_struct->imap_stream, mbox)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "c-client imap_getquotaroot failed");
zval_dtor(return_value);
RETURN_FALSE;
@@ -1025,24 +1384,24 @@ PHP_FUNCTION(imap_get_quotaroot)
Will set the quota for qroot mailbox */
PHP_FUNCTION(imap_set_quota)
{
- zval **streamind, **qroot, **mailbox_size;
+ zval *streamind;
+ char *qroot;
+ int qroot_len;
+ long mailbox_size;
pils *imap_le_struct;
STRINGLIST limits;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &qroot, &mailbox_size) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsl", &streamind, &qroot, &qroot_len, &mailbox_size) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(qroot);
- convert_to_long_ex(mailbox_size);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
limits.text.data = "STORAGE";
- limits.text.size = Z_LVAL_PP(mailbox_size);
+ limits.text.size = mailbox_size;
limits.next = NIL;
- RETURN_BOOL(imap_setquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot), &limits));
+ RETURN_BOOL(imap_setquota(imap_le_struct->imap_stream, qroot, &limits));
}
/* }}} */
@@ -1050,20 +1409,18 @@ PHP_FUNCTION(imap_set_quota)
Sets the ACL for a given mailbox */
PHP_FUNCTION(imap_setacl)
{
- zval **streamind, **mailbox, **id, **rights;
+ zval *streamind;
+ char *mailbox, *id, *rights;
+ int mailbox_len, id_len, rights_len;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &streamind, &mailbox, &id, &rights) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &streamind, &mailbox, &mailbox_len, &id, &id_len, &rights, &rights_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(mailbox);
- convert_to_string_ex(id);
- convert_to_string_ex(rights);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- RETURN_BOOL(imap_setacl(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox), Z_STRVAL_PP(id), Z_STRVAL_PP(rights)));
+ RETURN_BOOL(imap_setacl(imap_le_struct->imap_stream, mailbox, id, rights));
}
/* }}} */
@@ -1072,16 +1429,16 @@ PHP_FUNCTION(imap_setacl)
Gets the ACL for a given mailbox */
PHP_FUNCTION(imap_getacl)
{
- zval **streamind, **mailbox;
+ zval *streamind;
+ char *mailbox;
+ int mailbox_len;
pils *imap_le_struct;
- if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &mailbox) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &streamind, &mailbox, &mailbox_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(mailbox);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
/* initializing the special array for the return values */
array_init(return_value);
@@ -1090,7 +1447,7 @@ PHP_FUNCTION(imap_getacl)
/* set the callback for the GET_ACL function */
mail_parameters(NIL, SET_ACL, (void *) mail_getacl);
- if(!imap_getacl(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox))) {
+ if (!imap_getacl(imap_le_struct->imap_stream, mailbox)) {
php_error(E_WARNING, "c-client imap_getacl failed");
zval_dtor(return_value);
RETURN_FALSE;
@@ -1107,14 +1464,14 @@ PHP_FUNCTION(imap_getacl)
Permanently delete all messages marked for deletion */
PHP_FUNCTION(imap_expunge)
{
- zval **streamind;
+ zval *streamind;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &streamind) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
mail_expunge (imap_le_struct->imap_stream);
@@ -1126,26 +1483,25 @@ PHP_FUNCTION(imap_expunge)
Close an IMAP stream */
PHP_FUNCTION(imap_close)
{
- zval **options, **streamind=NULL;
+ zval *streamind;
pils *imap_le_struct=NULL;
- long flags = NIL;
- int myargcount=ZEND_NUM_ARGS();
+ long options = 0, flags = NIL;
+ int argc = ZEND_NUM_ARGS();
- if (myargcount < 1 || myargcount > 2 || zend_get_parameters_ex(myargcount, &streamind, &options) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "r|l", &streamind, &options) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- if (myargcount == 2) {
- convert_to_long_ex(options);
- flags = Z_LVAL_PP(options);
+ if (argc == 2) {
+ flags = options;
- /* Check that flags is exactly equal to PHP_EXPUNGE or Zero*/
+ /* Check that flags is exactly equal to PHP_EXPUNGE or zero */
if (flags && ((flags & ~PHP_EXPUNGE) != 0)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid value for the flags parameter");
RETURN_FALSE;
- }
+ }
/* Do the translation from PHP's internal PHP_EXPUNGE define to c-client's CL_EXPUNGE */
if (flags & PHP_EXPUNGE) {
@@ -1155,7 +1511,7 @@ PHP_FUNCTION(imap_close)
imap_le_struct->flags = flags;
}
- zend_list_delete(Z_RESVAL_PP(streamind));
+ zend_list_delete(Z_RESVAL_P(streamind));
RETURN_TRUE;
}
@@ -1165,18 +1521,18 @@ PHP_FUNCTION(imap_close)
Returns headers for all messages in a mailbox */
PHP_FUNCTION(imap_headers)
{
- zval **streamind;
+ zval *streamind;
pils *imap_le_struct;
unsigned long i;
char *t;
unsigned int msgno;
char tmp[MAILTMPLEN];
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &streamind) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
/* Initialize return array */
array_init(return_value);
@@ -1215,66 +1571,56 @@ PHP_FUNCTION(imap_headers)
Read the message body */
PHP_FUNCTION(imap_body)
{
- zval **streamind, **msgno, **pflags;
+ zval *streamind;
+ long msgno, flags = 0;
pils *imap_le_struct;
- int msgindex, myargc=ZEND_NUM_ARGS();
- long flags=0L;
+ int msgindex, argc = ZEND_NUM_ARGS();
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &msgno, &pflags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rl|l", &streamind, &msgno, &flags) == FAILURE) {
+ return;
}
-
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_long_ex(msgno);
- if (myargc == 3) {
- convert_to_long_ex(pflags);
- flags = Z_LVAL_PP(pflags);
- 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;
- }
+ 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;
}
- if ((myargc == 3) && (flags & FT_UID)) {
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
+
+ if ((argc == 3) && (flags & FT_UID)) {
/* This should be cached; if it causes an extra RTT to the
IMAP server, then that's the price we pay for making
sure we don't crash. */
- msgindex = mail_msgno(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
+ msgindex = mail_msgno(imap_le_struct->imap_stream, msgno);
} else {
- msgindex = Z_LVAL_PP(msgno);
+ msgindex = msgno;
}
if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
RETURN_FALSE;
}
- RETVAL_STRING(mail_fetchtext_full (imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL, myargc==3 ? Z_LVAL_PP(pflags) : NIL), 1);
+ RETVAL_STRING(mail_fetchtext_full(imap_le_struct->imap_stream, msgno, NIL, (argc == 3 ? flags : NIL)), 1);
}
/* }}} */
-/* {{{ proto bool imap_mail_copy(resource stream_id, int msg_no, string mailbox [, int options])
+/* {{{ proto bool imap_mail_copy(resource stream_id, string msglist, string mailbox [, int options])
Copy specified message to a mailbox */
PHP_FUNCTION(imap_mail_copy)
{
- zval **streamind, **seq, **folder, **options;
+ zval *streamind;
+ long options = 0;
+ char *seq, *folder;
+ int seq_len, folder_len, argc = ZEND_NUM_ARGS();
pils *imap_le_struct;
- int myargcount = ZEND_NUM_ARGS();
- if (myargcount > 4 || myargcount < 3 || zend_get_parameters_ex(myargcount, &streamind, &seq, &folder, &options) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rss|l", &streamind, &seq, &seq_len, &folder, &folder_len, &options) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_string_ex(seq);
- convert_to_string_ex(folder);
- if (myargcount == 4) {
- convert_to_long_ex(options);
- }
-
- if (mail_copy_full(imap_le_struct->imap_stream, Z_STRVAL_PP(seq), Z_STRVAL_PP(folder), myargcount==4 ? Z_LVAL_PP(options) : NIL)==T) {
+ if (mail_copy_full(imap_le_struct->imap_stream, seq, folder, (argc == 4 ? options : NIL)) == T) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1282,27 +1628,24 @@ PHP_FUNCTION(imap_mail_copy)
}
/* }}} */
-/* {{{ proto bool imap_mail_move(resource stream_id, int msg_no, string mailbox [, int options])
+/* {{{ proto bool imap_mail_move(resource stream_id, string sequence, string mailbox [, int options])
Move specified message to a mailbox */
PHP_FUNCTION(imap_mail_move)
{
- zval **streamind, **seq, **folder, **options;
+ zval *streamind;
+ char *seq, *folder;
+ int seq_len, folder_len;
+ long options = 0;
pils *imap_le_struct;
- int myargcount = ZEND_NUM_ARGS();
+ int argc = ZEND_NUM_ARGS();
- if (myargcount > 4 || myargcount < 3 || zend_get_parameters_ex(myargcount, &streamind, &seq, &folder, &options) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rss|l", &streamind, &seq, &seq_len, &folder, &folder_len, &options) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_string_ex(seq);
- convert_to_string_ex(folder);
- if (myargcount == 4) {
- convert_to_long_ex(options);
- }
-
- if (mail_copy_full(imap_le_struct->imap_stream, Z_STRVAL_PP(seq), Z_STRVAL_PP(folder), myargcount == 4 ? (Z_LVAL_PP(options) | CP_MOVE) : CP_MOVE) == T) {
+ if (mail_copy_full(imap_le_struct->imap_stream, seq, folder, (argc == 4 ? (options | CP_MOVE) : CP_MOVE)) == T) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1314,18 +1657,18 @@ PHP_FUNCTION(imap_mail_move)
Create a new mailbox */
PHP_FUNCTION(imap_createmailbox)
{
- zval **streamind, **folder;
+ zval *streamind;
+ char *folder;
+ int folder_len;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &folder) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &streamind, &folder, &folder_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(folder);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- if (mail_create(imap_le_struct->imap_stream, Z_STRVAL_PP(folder)) == T) {
+ if (mail_create(imap_le_struct->imap_stream, folder) == T) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1337,19 +1680,18 @@ PHP_FUNCTION(imap_createmailbox)
Rename a mailbox */
PHP_FUNCTION(imap_renamemailbox)
{
- zval **streamind, **old_mailbox, **new_mailbox;
+ zval *streamind;
+ char *old_mailbox, *new_mailbox;
+ int old_mailbox_len, new_mailbox_len;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &old_mailbox, &new_mailbox) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &streamind, &old_mailbox, &old_mailbox_len, &new_mailbox, &new_mailbox_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_string_ex(old_mailbox);
- convert_to_string_ex(new_mailbox);
-
- if (mail_rename(imap_le_struct->imap_stream, Z_STRVAL_PP(old_mailbox), Z_STRVAL_PP(new_mailbox))==T) {
+ if (mail_rename(imap_le_struct->imap_stream, old_mailbox, new_mailbox) == T) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1361,18 +1703,18 @@ PHP_FUNCTION(imap_renamemailbox)
Delete a mailbox */
PHP_FUNCTION(imap_deletemailbox)
{
- zval **streamind, **folder;
+ zval *streamind;
+ char *folder;
+ int folder_len;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &folder) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &streamind, &folder, &folder_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(folder);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- if (mail_delete(imap_le_struct->imap_stream, Z_STRVAL_PP(folder))==T) {
+ if (mail_delete(imap_le_struct->imap_stream, folder) == T) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1384,24 +1726,23 @@ PHP_FUNCTION(imap_deletemailbox)
Read the list of mailboxes */
PHP_FUNCTION(imap_list)
{
- zval **streamind, **ref, **pat;
+ zval *streamind;
+ char *ref, *pat;
+ int ref_len, pat_len;
pils *imap_le_struct;
STRINGLIST *cur=NIL;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &ref, &pat) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &streamind, &ref, &ref_len, &pat, &pat_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(ref);
- convert_to_string_ex(pat);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
/* set flag for normal, old mailbox list */
IMAPG(folderlist_style) = FLIST_ARRAY;
IMAPG(imap_folders) = IMAPG(imap_folders_tail) = NIL;
- mail_list(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat));
+ mail_list(imap_le_struct->imap_stream, ref, pat);
if (IMAPG(imap_folders) == NIL) {
RETURN_FALSE;
}
@@ -1423,25 +1764,24 @@ PHP_FUNCTION(imap_list)
/* Author: CJH */
PHP_FUNCTION(imap_list_full)
{
- zval **streamind, **ref, **pat, *mboxob;
+ zval *streamind, *mboxob;
+ char *ref, *pat;
+ int ref_len, pat_len;
pils *imap_le_struct;
FOBJECTLIST *cur=NIL;
char *delim=NIL;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &ref, &pat) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &streamind, &ref, &ref_len, &pat, &pat_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(ref);
- convert_to_string_ex(pat);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
/* set flag for new, improved array of objects mailbox list */
IMAPG(folderlist_style) = FLIST_OBJECT;
IMAPG(imap_folder_objects) = IMAPG(imap_folder_objects_tail) = NIL;
- mail_list(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat));
+ mail_list(imap_le_struct->imap_stream, ref, pat);
if (IMAPG(imap_folder_objects) == NIL) {
RETURN_FALSE;
}
@@ -1474,22 +1814,20 @@ PHP_FUNCTION(imap_list_full)
Read list of mailboxes containing a certain string */
PHP_FUNCTION(imap_listscan)
{
- zval **streamind, **ref, **pat, **content;
+ zval *streamind;
+ char *ref, *pat, *content;
+ int ref_len, pat_len, content_len;
pils *imap_le_struct;
STRINGLIST *cur=NIL;
- if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &streamind, &ref, &pat, &content) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &streamind, &ref, &ref_len, &pat, &pat_len, &content, &content_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(ref);
- convert_to_string_ex(pat);
- convert_to_string_ex(content);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
IMAPG(imap_folders) = NIL;
- mail_scan(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat), Z_STRVAL_PP(content));
+ mail_scan(imap_le_struct->imap_stream, ref, pat, content);
if (IMAPG(imap_folders) == NIL) {
RETURN_FALSE;
}
@@ -1510,15 +1848,15 @@ PHP_FUNCTION(imap_listscan)
Get mailbox properties */
PHP_FUNCTION(imap_check)
{
- zval **streamind;
+ zval *streamind;
pils *imap_le_struct;
char date[100];
-
- if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &streamind) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
if (mail_ping (imap_le_struct->imap_stream) == NIL) {
RETURN_FALSE;
@@ -1542,46 +1880,42 @@ PHP_FUNCTION(imap_check)
Mark a message for deletion */
PHP_FUNCTION(imap_delete)
{
- zval **streamind, **sequence, **flags;
+ zval *streamind, **sequence;
pils *imap_le_struct;
- int myargc=ZEND_NUM_ARGS();
+ long flags = 0;
+ int argc = ZEND_NUM_ARGS();
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &sequence, &flags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rZ|l", &streamind, &sequence, &flags) == FAILURE) {
+ return;
}
-
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
convert_to_string_ex(sequence);
- if (myargc == 3) {
- convert_to_long_ex(flags);
- }
- mail_setflag_full(imap_le_struct->imap_stream, Z_STRVAL_PP(sequence), "\\DELETED", myargc==3 ? Z_LVAL_PP(flags) : NIL);
+ mail_setflag_full(imap_le_struct->imap_stream, Z_STRVAL_PP(sequence), "\\DELETED", (argc == 3 ? flags : NIL));
RETVAL_TRUE;
}
/* }}} */
-/* {{{ proto bool imap_undelete(resource stream_id, int msg_no)
+/* {{{ proto bool imap_undelete(resource stream_id, int msg_no [, int flags])
Remove the delete flag from a message */
PHP_FUNCTION(imap_undelete)
{
- zval **streamind, **sequence, **flags;
+ zval *streamind, **sequence;
+ long flags = 0;
pils *imap_le_struct;
- int myargc=ZEND_NUM_ARGS();
+ int argc = ZEND_NUM_ARGS();
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &sequence, &flags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rZ|l", &streamind, &sequence, &flags) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
convert_to_string_ex(sequence);
- if (myargc == 3) {
- convert_to_long_ex(flags);
- }
- mail_clearflag_full(imap_le_struct->imap_stream, Z_STRVAL_PP(sequence), "\\DELETED", myargc==3 ? Z_LVAL_PP(flags) : NIL);
+ mail_clearflag_full(imap_le_struct->imap_stream, Z_STRVAL_PP(sequence), "\\DELETED", (argc == 3 ? flags : NIL));
RETVAL_TRUE;
}
/* }}} */
@@ -1590,51 +1924,47 @@ PHP_FUNCTION(imap_undelete)
Read the headers of the message */
PHP_FUNCTION(imap_headerinfo)
{
- zval **streamind, **msgno, **fromlength, **subjectlength, **defaulthost;
+ zval *streamind;
+ char *defaulthost = NULL;
+ int defaulthost_len = 0, argc = ZEND_NUM_ARGS();
+ long msgno, fromlength, subjectlength;
pils *imap_le_struct;
MESSAGECACHE *cache;
ENVELOPE *en;
char dummy[2000], fulladdress[MAILTMPLEN + 1];
- int myargc = ZEND_NUM_ARGS();
- if (myargc < 2 || myargc > 5 || zend_get_parameters_ex(myargc, &streamind, &msgno, &fromlength, &subjectlength, &defaulthost) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rl|lls", &streamind, &msgno, &fromlength, &subjectlength, &defaulthost, &defaulthost_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_long_ex(msgno);
- if (myargc >= 3) {
- convert_to_long_ex(fromlength);
- if (Z_LVAL_PP(fromlength) < 0 || Z_LVAL_PP(fromlength) > MAILTMPLEN) {
+ if (argc >= 3) {
+ if (fromlength < 0 || fromlength > MAILTMPLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "From length has to be between 0 and %d", MAILTMPLEN);
RETURN_FALSE;
}
} else {
fromlength = 0x00;
}
- if (myargc >= 4) {
- convert_to_long_ex(subjectlength);
- if (Z_LVAL_PP(subjectlength) < 0 || Z_LVAL_PP(subjectlength) > MAILTMPLEN) {
+ if (argc >= 4) {
+ if (subjectlength < 0 || subjectlength > MAILTMPLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Subject length has to be between 0 and %d", MAILTMPLEN);
RETURN_FALSE;
}
} else {
subjectlength = 0x00;
}
- if (myargc == 5) {
- convert_to_string_ex(defaulthost);
- }
- PHP_IMAP_CHECK_MSGNO(Z_LVAL_PP(msgno));
+ PHP_IMAP_CHECK_MSGNO(msgno);
- if (mail_fetchstructure(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL)) {
- cache = mail_elt(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
+ if (mail_fetchstructure(imap_le_struct->imap_stream, msgno, NIL)) {
+ cache = mail_elt(imap_le_struct->imap_stream, msgno);
} else {
RETURN_FALSE;
}
- en = mail_fetchenvelope(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
+ en = mail_fetchenvelope(imap_le_struct->imap_stream, msgno);
/* call a function to parse all the text, so that we can use the
same function to parse text from other sources */
@@ -1662,12 +1992,12 @@ PHP_FUNCTION(imap_headerinfo)
if (en->from && fromlength) {
fulladdress[0] = 0x00;
- mail_fetchfrom(fulladdress, imap_le_struct->imap_stream, Z_LVAL_PP(msgno), Z_LVAL_PP(fromlength));
+ mail_fetchfrom(fulladdress, imap_le_struct->imap_stream, msgno, fromlength);
add_property_string(return_value, "fetchfrom", fulladdress, 1);
}
if (en->subject && subjectlength) {
fulladdress[0] = 0x00;
- mail_fetchsubject(fulladdress, imap_le_struct->imap_stream, Z_LVAL_PP(msgno), Z_LVAL_PP(subjectlength));
+ mail_fetchsubject(fulladdress, imap_le_struct->imap_stream, msgno, subjectlength);
add_property_string(return_value, "fetchsubject", fulladdress, 1);
}
}
@@ -1677,25 +2007,20 @@ PHP_FUNCTION(imap_headerinfo)
Parse a set of mail headers contained in a string, and return an object similar to imap_headerinfo() */
PHP_FUNCTION(imap_rfc822_parse_headers)
{
- zval **headers, **defaulthost;
+ char *headers, *defaulthost = NULL;
ENVELOPE *en;
- int myargc = ZEND_NUM_ARGS();
+ int headers_len, defaulthost_len = 0, argc = ZEND_NUM_ARGS();
- if (myargc < 1 || myargc > 2 || zend_get_parameters_ex(myargc, &headers, &defaulthost) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "s|s", &headers, &headers_len, &defaulthost, &defaulthost_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(headers);
- if (myargc == 2) {
- convert_to_string_ex(defaulthost);
- }
-
- if (myargc == 2) {
- rfc822_parse_msg(&en, NULL, Z_STRVAL_PP(headers), Z_STRLEN_PP(headers), NULL, Z_STRVAL_PP(defaulthost), NIL);
+ if (argc == 2) {
+ rfc822_parse_msg(&en, NULL, headers, headers_len, NULL, defaulthost, NIL);
} else {
- rfc822_parse_msg(&en, NULL, Z_STRVAL_PP(headers), Z_STRLEN_PP(headers), NULL, "UNKNOWN", NIL);
+ rfc822_parse_msg(&en, NULL, headers, headers_len, NULL, "UNKNOWN", NIL);
}
-
+
/* call a function to parse all the text, so that we can use the
same function no matter where the headers are from */
_php_make_header_object(return_value, en TSRMLS_CC);
@@ -1709,24 +2034,23 @@ PHP_FUNCTION(imap_rfc822_parse_headers)
Return a list of subscribed mailboxes */
PHP_FUNCTION(imap_lsub)
{
- zval **streamind, **ref, **pat;
+ zval *streamind;
+ char *ref, *pat;
+ int ref_len, pat_len;
pils *imap_le_struct;
STRINGLIST *cur=NIL;
-
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &ref, &pat) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &streamind, &ref, &ref_len, &pat, &pat_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(ref);
- convert_to_string_ex(pat);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
/* set flag for normal, old mailbox list */
IMAPG(folderlist_style) = FLIST_ARRAY;
IMAPG(imap_sfolders) = NIL;
- mail_lsub(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat));
+ mail_lsub(imap_le_struct->imap_stream, ref, pat);
if (IMAPG(imap_sfolders) == NIL) {
RETURN_FALSE;
}
@@ -1747,25 +2071,24 @@ PHP_FUNCTION(imap_lsub)
/* Author: CJH */
PHP_FUNCTION(imap_lsub_full)
{
- zval **streamind, **ref, **pat, *mboxob;
+ zval *streamind, *mboxob;
+ char *ref, *pat;
+ int ref_len, pat_len;
pils *imap_le_struct;
FOBJECTLIST *cur=NIL;
char *delim=NIL;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &ref, &pat) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &streamind, &ref, &ref_len, &pat, &pat_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(ref);
- convert_to_string_ex(pat);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
/* set flag for new, improved array of objects list */
IMAPG(folderlist_style) = FLIST_OBJECT;
IMAPG(imap_sfolder_objects) = IMAPG(imap_sfolder_objects_tail) = NIL;
- mail_lsub(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat));
+ mail_lsub(imap_le_struct->imap_stream, ref, pat);
if (IMAPG(imap_sfolder_objects) == NIL) {
RETURN_FALSE;
}
@@ -1798,18 +2121,18 @@ PHP_FUNCTION(imap_lsub_full)
Subscribe to a mailbox */
PHP_FUNCTION(imap_subscribe)
{
- zval **streamind, **folder;
+ zval *streamind;
+ char *folder;
+ int folder_len;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &folder) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &streamind, &folder, &folder_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(folder);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- if (mail_subscribe(imap_le_struct->imap_stream, Z_STRVAL_PP(folder))==T) {
+ if (mail_subscribe(imap_le_struct->imap_stream, folder) == T) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1821,18 +2144,18 @@ PHP_FUNCTION(imap_subscribe)
Unsubscribe from a mailbox */
PHP_FUNCTION(imap_unsubscribe)
{
- zval **streamind, **folder;
+ zval *streamind;
+ char *folder;
+ int folder_len;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &folder) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &streamind, &folder, &folder_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(folder);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- if (mail_unsubscribe(imap_le_struct->imap_stream, Z_STRVAL_PP(folder))==T) {
+ if (mail_unsubscribe(imap_le_struct->imap_stream, folder) == T) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1844,52 +2167,46 @@ PHP_FUNCTION(imap_unsubscribe)
Read the full structure of a message */
PHP_FUNCTION(imap_fetchstructure)
{
- zval **streamind, **msgno, **pflags;
+ zval *streamind;
+ long msgno, flags = 0;
pils *imap_le_struct;
BODY *body;
- int msgindex, myargc=ZEND_NUM_ARGS();
- long flags=0L;
+ int msgindex, argc = ZEND_NUM_ARGS();
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &msgno, &pflags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rl|l", &streamind, &msgno, &flags) == FAILURE) {
+ return;
}
-
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_long_ex(msgno);
- if (Z_LVAL_PP(msgno) < 1) {
+ if (flags && ((flags & ~FT_UID) != 0)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid value for the options parameter");
RETURN_FALSE;
}
- if (myargc == 3) {
- convert_to_long_ex(pflags);
- flags = Z_LVAL_PP(pflags);
+
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- if (flags && ((flags & ~FT_UID) != 0)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid value for the options parameter");
- RETURN_FALSE;
- }
+ if (msgno < 1) {
+ RETURN_FALSE;
}
object_init(return_value);
- if ((myargc == 3) && (flags & FT_UID)) {
+ if ((argc == 3) && (flags & FT_UID)) {
/* This should be cached; if it causes an extra RTT to the
IMAP server, then that's the price we pay for making
sure we don't crash. */
- msgindex = mail_msgno(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
+ msgindex = mail_msgno(imap_le_struct->imap_stream, msgno);
} else {
- msgindex = Z_LVAL_PP(msgno);
+ msgindex = msgno;
}
PHP_IMAP_CHECK_MSGNO(msgindex);
- mail_fetchstructure_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), &body , myargc == 3 ? Z_LVAL_PP(pflags) : NIL);
-
+ mail_fetchstructure_full(imap_le_struct->imap_stream, msgno, &body , (argc == 3 ? flags : NIL));
+
if (!body) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No body information available");
RETURN_FALSE;
}
-
+
_php_imap_add_body(return_value, body TSRMLS_CC);
}
/* }}} */
@@ -1898,37 +2215,31 @@ PHP_FUNCTION(imap_fetchstructure)
Get a specific body section */
PHP_FUNCTION(imap_fetchbody)
{
- zval **streamind, **msgno, **sec, **pflags;
+ zval *streamind;
+ long msgno, flags = 0;
pils *imap_le_struct;
- char *body;
- long flags=0L;
+ char *body, *sec;
+ int sec_len;
unsigned long len;
- int myargc=ZEND_NUM_ARGS();
+ int argc = ZEND_NUM_ARGS();
- if (myargc < 3 || myargc > 4 || zend_get_parameters_ex(myargc, &streamind, &msgno, &sec, &pflags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rls|l", &streamind, &msgno, &sec, &sec_len, &flags) == FAILURE) {
+ return;
}
-
-
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_long_ex(msgno);
- convert_to_string_ex(sec);
- if (myargc == 4) {
- convert_to_long_ex(pflags);
- flags = Z_LVAL_PP(pflags);
- 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;
- }
+
+ 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;
}
- if (myargc < 4 || !(flags & FT_UID)) {
+ 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(Z_LVAL_PP(msgno));
+ PHP_IMAP_CHECK_MSGNO(msgno);
}
- body = mail_fetchbody_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), Z_STRVAL_PP(sec), &len, myargc==4 ? Z_LVAL_PP(pflags) : NIL);
+ body = mail_fetchbody_full(imap_le_struct->imap_stream, msgno, sec, &len, (argc == 4 ? flags : NIL));
if (!body) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No body information available");
@@ -1994,17 +2305,15 @@ PHP_FUNCTION(imap_savebody)
Decode BASE64 encoded text */
PHP_FUNCTION(imap_base64)
{
- zval **text;
- char *decode;
+ char *text, *decode;
+ int text_len;
unsigned long newlength;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &text) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &text, &text_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(text);
-
- decode = (char *) rfc822_base64((unsigned char *) Z_STRVAL_PP(text), Z_STRLEN_PP(text), &newlength);
+ decode = (char *) rfc822_base64((unsigned char *) text, text_len, &newlength);
if (decode == NULL) {
RETURN_FALSE;
@@ -2019,17 +2328,15 @@ PHP_FUNCTION(imap_base64)
Convert a quoted-printable string to an 8-bit string */
PHP_FUNCTION(imap_qprint)
{
- zval **text;
- char *decode;
+ char *text, *decode;
+ int text_len;
unsigned long newlength;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &text) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &text, &text_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(text);
-
- decode = (char *) rfc822_qprint((unsigned char *) Z_STRVAL_PP(text), Z_STRLEN_PP(text), &newlength);
+ decode = (char *) rfc822_qprint((unsigned char *) text, text_len, &newlength);
if (decode == NULL) {
RETURN_FALSE;
@@ -2044,17 +2351,15 @@ PHP_FUNCTION(imap_qprint)
Convert an 8-bit string to a quoted-printable string */
PHP_FUNCTION(imap_8bit)
{
- zval **text;
- char *decode;
+ char *text, *decode;
+ int text_len;
unsigned long newlength;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &text) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &text, &text_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(text);
-
- decode = (char *) rfc822_8bit((unsigned char *) Z_STRVAL_PP(text), Z_STRLEN_PP(text), &newlength);
+ decode = (char *) rfc822_8bit((unsigned char *) text, text_len, &newlength);
if (decode == NULL) {
RETURN_FALSE;
@@ -2069,17 +2374,15 @@ PHP_FUNCTION(imap_8bit)
Convert an 8bit string to a base64 string */
PHP_FUNCTION(imap_binary)
{
- zval **text;
- char *decode;
+ char *text, *decode;
+ int text_len;
unsigned long newlength;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &text) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &text, &text_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(text);
-
- decode = rfc822_binary(Z_STRVAL_PP(text), Z_STRLEN_PP(text), &newlength);
+ decode = rfc822_binary(text, text_len, &newlength);
if (decode == NULL) {
RETURN_FALSE;
@@ -2094,16 +2397,16 @@ PHP_FUNCTION(imap_binary)
Returns info about the current mailbox */
PHP_FUNCTION(imap_mailboxmsginfo)
{
- zval **streamind;
+ zval *streamind;
pils *imap_le_struct;
char date[100];
unsigned int msgno, unreadmsg, deletedmsg, msize;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &streamind) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
/* Initialize return object */
object_init(return_value);
@@ -2141,30 +2444,27 @@ PHP_FUNCTION(imap_mailboxmsginfo)
Returns a properly formatted email address given the mailbox, host, and personal info */
PHP_FUNCTION(imap_rfc822_write_address)
{
- zval **mailbox, **host, **personal;
+ char *mailbox, *host, *personal;
+ int mailbox_len, host_len, personal_len;
ADDRESS *addr;
char *string;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &mailbox, &host, &personal) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &mailbox, &mailbox_len, &host, &host_len, &personal, &personal_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(mailbox);
- convert_to_string_ex(host);
- convert_to_string_ex(personal);
-
addr=mail_newaddr();
if (mailbox) {
- addr->mailbox = cpystr(Z_STRVAL_PP(mailbox));
+ addr->mailbox = cpystr(mailbox);
}
if (host) {
- addr->host = cpystr(Z_STRVAL_PP(host));
+ addr->host = cpystr(host);
}
if (personal) {
- addr->personal = cpystr(Z_STRVAL_PP(personal));
+ addr->personal = cpystr(personal);
}
addr->next=NIL;
@@ -2184,24 +2484,21 @@ PHP_FUNCTION(imap_rfc822_write_address)
Parses an address string */
PHP_FUNCTION(imap_rfc822_parse_adrlist)
{
- zval **str, **defaulthost, *tovals;
+ zval *tovals;
+ char *str, *defaulthost, *str_copy;
+ int str_len, defaulthost_len;
ADDRESS *addresstmp;
ENVELOPE *env;
- char *str_copy;
-
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &str, &defaulthost) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &str, &str_len, &defaulthost, &defaulthost_len) == FAILURE) {
+ return;
}
- SEPARATE_ZVAL(str);
- convert_to_string_ex(str);
- convert_to_string_ex(defaulthost);
-
env = mail_newenvelope();
/* rfc822_parse_adrlist() modifies passed string. Copy it. */
- str_copy = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
- rfc822_parse_adrlist(&env->to, str_copy, Z_STRVAL_PP(defaulthost));
+ str_copy = estrndup(str, str_len);
+ rfc822_parse_adrlist(&env->to, str_copy, defaulthost);
efree(str_copy);
array_init(return_value);
@@ -2234,21 +2531,20 @@ PHP_FUNCTION(imap_rfc822_parse_adrlist)
Convert a mime-encoded text to UTF-8 */
PHP_FUNCTION(imap_utf8)
{
- zval **str;
+ char *str;
+ int str_len;
SIZEDTEXT src, dest;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ return;
}
-
- convert_to_string_ex(str);
src.data = NULL;
src.size = 0;
dest.data = NULL;
dest.size = 0;
- cpytxt(&src, Z_STRVAL_PP(str), Z_STRLEN_PP(str));
+ cpytxt(&src, str, str_len);
#ifndef HAVE_NEW_MIME2TEXT
utf8_mime2text(&src, &dest);
@@ -2291,11 +2587,11 @@ PHP_FUNCTION(imap_utf8)
PHP_FUNCTION(imap_utf7_decode)
{
/* author: Andrew Skalski <askalski@chek.com> */
- zval **arg;
+ char *arg;
const unsigned char *in, *inp, *endp;
unsigned char *out, *outp;
unsigned char c;
- int inlen, outlen;
+ int arg_len, inlen, outlen;
enum {
ST_NORMAL, /* printable text */
ST_DECODE0, /* encoded text rotation... */
@@ -2304,16 +2600,12 @@ PHP_FUNCTION(imap_utf7_decode)
ST_DECODE3
} state;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(arg); /* Is this string really modified?
- If it is use and you don't want it to be seen outside of the function
- then use zend_get_parameters() */
-
- in = (const unsigned char *) Z_STRVAL_PP(arg);
- inlen = Z_STRLEN_PP(arg);
+ in = (const unsigned char *) arg;
+ inlen = arg_len;
/* validate and compute length of output string */
outlen = 0;
@@ -2434,26 +2726,24 @@ PHP_FUNCTION(imap_utf7_decode)
PHP_FUNCTION(imap_utf7_encode)
{
/* author: Andrew Skalski <askalski@chek.com> */
- zval **arg;
+ char *arg;
const unsigned char *in, *inp, *endp;
unsigned char *out, *outp;
unsigned char c;
- int inlen, outlen;
+ int arg_len, inlen, outlen;
enum {
ST_NORMAL, /* printable text */
ST_ENCODE0, /* encoded text rotation... */
ST_ENCODE1,
ST_ENCODE2
} state;
-
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(arg);
-
- in = (const unsigned char *) Z_STRVAL_PP(arg);
- inlen = Z_STRLEN_PP(arg);
+ in = (const unsigned char *) arg;
+ inlen = arg_len;
/* compute the length of the result string */
outlen = 0;
@@ -2557,23 +2847,19 @@ PHP_FUNCTION(imap_utf7_encode)
Sets flags on messages */
PHP_FUNCTION(imap_setflag_full)
{
- zval **streamind, **sequence, **flag, **flags;
+ zval *streamind;
+ char *sequence, *flag;
+ int sequence_len, flag_len;
+ long flags = NULL;
pils *imap_le_struct;
- int myargc = ZEND_NUM_ARGS();
- if (myargc < 3 || myargc > 4 || zend_get_parameters_ex(myargc, &streamind, &sequence, &flag, &flags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|l", &streamind, &sequence, &sequence_len, &flag, &flag_len, &flags) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_string_ex(sequence);
- convert_to_string_ex(flag);
- if (myargc==4) {
- convert_to_long_ex(flags);
- }
-
- mail_setflag_full(imap_le_struct->imap_stream, Z_STRVAL_PP(sequence), Z_STRVAL_PP(flag), myargc==4 ? Z_LVAL_PP(flags) : NIL);
+ mail_setflag_full(imap_le_struct->imap_stream, sequence, flag, (flags ? flags : NIL));
RETURN_TRUE;
}
/* }}} */
@@ -2582,23 +2868,20 @@ PHP_FUNCTION(imap_setflag_full)
Clears flags on messages */
PHP_FUNCTION(imap_clearflag_full)
{
- zval **streamind, **sequence, **flag, **flags;
+ zval *streamind;
+ char *sequence, *flag;
+ int sequence_len, flag_len;
+ long flags = 0;
pils *imap_le_struct;
- int myargc = ZEND_NUM_ARGS();
+ int argc = ZEND_NUM_ARGS();
- if (myargc < 3 || myargc > 4 || zend_get_parameters_ex(myargc, &streamind, &sequence, &flag, &flags) ==FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rss|l", &streamind, &sequence, &sequence_len, &flag, &flag_len, &flags) ==FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_string_ex(sequence);
- convert_to_string_ex(flag);
- if (myargc==4) {
- convert_to_long_ex(flags);
- }
-
- mail_clearflag_full(imap_le_struct->imap_stream, Z_STRVAL_PP(sequence), Z_STRVAL_PP(flag), myargc==4 ? Z_LVAL_PP(flags) : NIL);
+ mail_clearflag_full(imap_le_struct->imap_stream, sequence, flag, (argc == 4 ? flags : NIL));
RETURN_TRUE;
}
/* }}} */
@@ -2607,51 +2890,47 @@ PHP_FUNCTION(imap_clearflag_full)
Sort an array of message headers, optionally including only messages that meet specified criteria. */
PHP_FUNCTION(imap_sort)
{
- zval **streamind, **pgm, **rev, **flags, **criteria, **charset;
+ zval *streamind;
+ char *criteria = NULL, *charset = NULL;
+ int criteria_len, charset_len;
+ long pgm, rev, flags = 0;
pils *imap_le_struct;
unsigned long *slst, *sl;
char *search_criteria;
SORTPGM *mypgm=NIL;
SEARCHPGM *spg=NIL;
- int myargc = ZEND_NUM_ARGS();
+ int argc = ZEND_NUM_ARGS();
- if (myargc < 3 || myargc > 6 || zend_get_parameters_ex(myargc, &streamind, &pgm, &rev, &flags, &criteria, &charset) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rll|lss", &streamind, &pgm, &rev, &flags, &criteria, &criteria_len, &charset, &charset_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_long_ex(rev);
- convert_to_long_ex(pgm);
- if (Z_LVAL_PP(pgm) > SORTSIZE) {
+ if (pgm > SORTSIZE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unrecognized sort criteria");
RETURN_FALSE;
}
- if (myargc >= 4) {
- convert_to_long_ex(flags);
- if (Z_LVAL_PP(flags) < 0) {
+ if (argc >= 4) {
+ if (flags < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Search options parameter has to be greater than or equal to 0");
RETURN_FALSE;
}
}
- if (myargc >= 5) {
- convert_to_string_ex(criteria);
- search_criteria = estrndup(Z_STRVAL_PP(criteria), Z_STRLEN_PP(criteria));
+ if (argc >= 5) {
+ search_criteria = estrndup(criteria, criteria_len);
spg = mail_criteria(search_criteria);
efree(search_criteria);
- if (myargc == 6) {
- convert_to_string_ex(charset);
- }
} else {
spg = mail_newsearchpgm();
}
mypgm = mail_newsortpgm();
- mypgm->reverse = Z_LVAL_PP(rev);
- mypgm->function = (short) Z_LVAL_PP(pgm);
+ mypgm->reverse = rev;
+ mypgm->function = (short) pgm;
mypgm->next = NIL;
- slst = mail_sort(imap_le_struct->imap_stream, (myargc == 6 ? Z_STRVAL_PP(charset) : NIL), spg, mypgm, (myargc >= 4 ? Z_LVAL_PP(flags) : NIL));
+ slst = mail_sort(imap_le_struct->imap_stream, (argc == 6 ? charset : NIL), spg, mypgm, (argc >= 4 ? flags : NIL));
if (spg) {
mail_free_searchpgm(&spg);
@@ -2671,40 +2950,34 @@ PHP_FUNCTION(imap_sort)
Get the full unfiltered header for a message */
PHP_FUNCTION(imap_fetchheader)
{
- zval **streamind, **msgno, **pflags;
+ zval *streamind;
+ long msgno, flags=0L;
pils *imap_le_struct;
- int msgindex, myargc = ZEND_NUM_ARGS();
- long flags=0L;
+ int msgindex, argc = ZEND_NUM_ARGS();
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &msgno, &pflags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rl|l", &streamind, &msgno, &flags) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_long_ex(msgno);
- if (myargc == 3) {
- convert_to_long_ex(pflags);
- flags = Z_LVAL_PP(pflags);
- if (flags && ((flags & ~(FT_UID|FT_INTERNAL|FT_PREFETCHTEXT)) != 0)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid value for the options parameter");
- RETURN_FALSE;
- }
- }
-
+ if (flags && ((flags & ~(FT_UID|FT_INTERNAL|FT_PREFETCHTEXT)) != 0)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid value for the options parameter");
+ RETURN_FALSE;
+ }
- if ((myargc == 3) && (flags & FT_UID)) {
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
+
+ if ((argc == 3) && (flags & FT_UID)) {
/* This should be cached; if it causes an extra RTT to the
IMAP server, then that's the price we pay for making sure
we don't crash. */
- msgindex = mail_msgno(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
+ msgindex = mail_msgno(imap_le_struct->imap_stream, msgno);
} else {
- msgindex = Z_LVAL_PP(msgno);
+ msgindex = msgno;
}
PHP_IMAP_CHECK_MSGNO(msgindex);
- RETVAL_STRING(mail_fetchheader_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL, NIL, (myargc == 3 ? Z_LVAL_PP(pflags) : NIL)), 1);
+ RETVAL_STRING(mail_fetchheader_full(imap_le_struct->imap_stream, msgno, NIL, NIL, (argc == 3 ? flags : NIL)), 1);
}
/* }}} */
@@ -2712,25 +2985,24 @@ PHP_FUNCTION(imap_fetchheader)
Get the unique message id associated with a standard sequential message number */
PHP_FUNCTION(imap_uid)
{
- zval **streamind, **msgno;
+ zval *streamind;
+ long msgno;
pils *imap_le_struct;
int msgindex;
-
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &msgno) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &streamind, &msgno) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_long_ex(msgno);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- msgindex = Z_LVAL_PP(msgno);
+ msgindex = msgno;
if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
RETURN_FALSE;
}
- RETURN_LONG(mail_uid(imap_le_struct->imap_stream, Z_LVAL_PP(msgno)));
+ RETURN_LONG(mail_uid(imap_le_struct->imap_stream, msgno));
}
/* }}} */
@@ -2738,18 +3010,17 @@ PHP_FUNCTION(imap_uid)
Get the sequence number associated with a UID */
PHP_FUNCTION(imap_msgno)
{
- zval **streamind, **msgno;
+ zval *streamind;
+ long msgno;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &msgno) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &streamind, &msgno) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_long_ex(msgno);
-
- RETURN_LONG(mail_msgno(imap_le_struct->imap_stream, Z_LVAL_PP(msgno)));
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
+
+ RETURN_LONG(mail_msgno(imap_le_struct->imap_stream, msgno));
}
/* }}} */
@@ -2757,21 +3028,21 @@ PHP_FUNCTION(imap_msgno)
Get status info from a mailbox */
PHP_FUNCTION(imap_status)
{
- zval **streamind, **mbx, **flags;
+ zval *streamind;
+ char *mbx;
+ int mbx_len;
+ long flags;
pils *imap_le_struct;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &mbx, &flags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsl", &streamind, &mbx, &mbx_len, &flags) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- convert_to_string_ex(mbx);
- convert_to_long_ex(flags);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
object_init(return_value);
- if (mail_status(imap_le_struct->imap_stream, Z_STRVAL_PP(mbx), Z_LVAL_PP(flags))) {
+ if (mail_status(imap_le_struct->imap_stream, mbx, flags)) {
add_property_long(return_value, "flags", IMAPG(status_flags));
if (IMAPG(status_flags) & SA_MESSAGES) {
add_property_long(return_value, "messages", IMAPG(status_messages));
@@ -2798,29 +3069,29 @@ PHP_FUNCTION(imap_status)
Read the structure of a specified body section of a specific message */
PHP_FUNCTION(imap_bodystruct)
{
- zval **streamind, **msg, **section;
+ zval *streamind;
+ long msg;
+ char *section;
+ int section_len;
pils *imap_le_struct;
zval *parametres, *param, *dparametres, *dparam;
PARAMETER *par, *dpar;
BODY *body;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &msg, &section) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rls", &streamind, &msg, &section, &section_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_long_ex(msg);
- convert_to_string_ex(section);
-
- if (!Z_LVAL_PP(msg) || Z_LVAL_PP(msg) < 1 || (unsigned) Z_LVAL_PP(msg) > imap_le_struct->imap_stream->nmsgs) {
+ if (!msg || msg < 1 || (unsigned) msg > imap_le_struct->imap_stream->nmsgs) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
RETURN_FALSE;
}
object_init(return_value);
- body=mail_body(imap_le_struct->imap_stream, Z_LVAL_PP(msg), Z_STRVAL_PP(section));
+ body=mail_body(imap_le_struct->imap_stream, msg, section);
if (body == NULL) {
zval_dtor(return_value);
RETURN_FALSE;
@@ -2912,39 +3183,35 @@ PHP_FUNCTION(imap_bodystruct)
/* }}} */
-/* {{{ proto array imap_fetch_overview(resource stream_id, int msg_no [, int options])
+/* {{{ proto array imap_fetch_overview(resource stream_id, string sequence [, int options])
Read an overview of the information in the headers of the given message sequence */
PHP_FUNCTION(imap_fetch_overview)
{
- zval **streamind, **sequence, **pflags;
+ zval *streamind;
+ char *sequence;
+ int sequence_len;
pils *imap_le_struct;
zval *myoverview;
char *address;
- long status, flags=0L;
- int myargc = ZEND_NUM_ARGS();
-
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &sequence, &pflags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
+ long status, flags = 0L;
+ int argc = ZEND_NUM_ARGS();
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ if (zend_parse_parameters(argc TSRMLS_CC, "rs|l", &streamind, &sequence, &sequence_len, &flags) == FAILURE) {
+ return;
+ }
- convert_to_string_ex(sequence);
- if(myargc == 3) {
- convert_to_long_ex(pflags);
- flags = Z_LVAL_PP(pflags);
- if (flags && ((flags & ~FT_UID) != 0)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid value for the options parameter");
- RETURN_FALSE;
- }
+ if (flags && ((flags & ~FT_UID) !=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);
+
array_init(return_value);
-
- status = (flags & FT_UID)
- ? mail_uid_sequence (imap_le_struct->imap_stream, Z_STRVAL_PP(sequence))
- : mail_sequence (imap_le_struct->imap_stream, Z_STRVAL_PP(sequence));
+
+ status = (flags & FT_UID)
+ ? mail_uid_sequence(imap_le_struct->imap_stream, sequence)
+ : mail_sequence(imap_le_struct->imap_stream, sequence);
if (status) {
MESSAGECACHE *elt;
@@ -3005,7 +3272,7 @@ PHP_FUNCTION(imap_fetch_overview)
Create a MIME message based on given envelope and body sections */
PHP_FUNCTION(imap_mail_compose)
{
- zval **envelope, **body;
+ zval *envelope, *body;
char *key;
zval **data, **pvalue, **disp_data, **env_data;
ulong ind;
@@ -3017,72 +3284,62 @@ PHP_FUNCTION(imap_mail_compose)
char *tmp=NULL, *mystring=NULL, *t=NULL, *tempstring=NULL, *str_copy = NULL;
int toppart = 0;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &envelope, &body) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "aa", &envelope, &body) == FAILURE) {
+ return;
}
- if (Z_TYPE_PP(envelope) != IS_ARRAY) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected Array as envelope parameter");
- RETURN_FALSE;
- }
-
- if (Z_TYPE_PP(body) != IS_ARRAY) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected Array as body parameter");
- RETURN_FALSE;
- }
-
#define PHP_RFC822_PARSE_ADRLIST(target, value) \
str_copy = estrndup(Z_STRVAL_PP(value), Z_STRLEN_PP(value)); \
rfc822_parse_adrlist(target, str_copy, "NO HOST"); \
efree(str_copy);
env = mail_newenvelope();
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "remail", sizeof("remail"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "remail", sizeof("remail"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
env->remail = cpystr(Z_STRVAL_PP(pvalue));
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "return_path", sizeof("return_path"), (void **) &pvalue)== SUCCESS) {
- convert_to_string_ex(pvalue)
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "return_path", sizeof("return_path"), (void **) &pvalue)== SUCCESS) {
+ convert_to_string_ex(pvalue);
PHP_RFC822_PARSE_ADRLIST(&env->return_path, pvalue);
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "date", sizeof("date"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "date", sizeof("date"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
env->date = cpystr(Z_STRVAL_PP(pvalue));
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "from", sizeof("from"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "from", sizeof("from"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
PHP_RFC822_PARSE_ADRLIST(&env->from, pvalue);
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "reply_to", sizeof("reply_to"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "reply_to", sizeof("reply_to"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
PHP_RFC822_PARSE_ADRLIST(&env->reply_to, pvalue);
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "in_reply_to", sizeof("in_reply_to"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "in_reply_to", sizeof("in_reply_to"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
env->in_reply_to = cpystr(Z_STRVAL_PP(pvalue));
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "subject", sizeof("subject"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "subject", sizeof("subject"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
env->subject = cpystr(Z_STRVAL_PP(pvalue));
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "to", sizeof("to"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "to", sizeof("to"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
PHP_RFC822_PARSE_ADRLIST(&env->to, pvalue);
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "cc", sizeof("cc"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "cc", sizeof("cc"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
PHP_RFC822_PARSE_ADRLIST(&env->cc, pvalue);
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "bcc", sizeof("bcc"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "bcc", sizeof("bcc"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
PHP_RFC822_PARSE_ADRLIST(&env->bcc, pvalue);
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "message_id", sizeof("message_id"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "message_id", sizeof("message_id"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
- env->message_id = cpystr(Z_STRVAL_PP(pvalue));
+ env->message_id=cpystr(Z_STRVAL_PP(pvalue));
}
- if (zend_hash_find(Z_ARRVAL_PP(envelope), "custom_headers", sizeof("custom_headers"), (void **) &pvalue)== SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(envelope), "custom_headers", sizeof("custom_headers"), (void **) &pvalue)== SUCCESS) {
if (Z_TYPE_PP(pvalue) == IS_ARRAY) {
custom_headers_param = tmp_param = NULL;
while (zend_hash_get_current_data(Z_ARRVAL_PP(pvalue), (void **) &env_data) == SUCCESS) {
@@ -3098,8 +3355,8 @@ PHP_FUNCTION(imap_mail_compose)
}
}
- zend_hash_internal_pointer_reset(Z_ARRVAL_PP(body));
- if (zend_hash_get_current_data(Z_ARRVAL_PP(body), (void **) &data) != SUCCESS || Z_TYPE_PP(data) != IS_ARRAY) {
+ zend_hash_internal_pointer_reset(Z_ARRVAL_P(body));
+ if (zend_hash_get_current_data(Z_ARRVAL_P(body), (void **) &data) != SUCCESS || Z_TYPE_PP(data) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "body parameter must be a non-empty array");
RETURN_FALSE;
}
@@ -3199,9 +3456,9 @@ PHP_FUNCTION(imap_mail_compose)
}
}
- zend_hash_move_forward(Z_ARRVAL_PP(body));
+ zend_hash_move_forward(Z_ARRVAL_P(body));
- while (zend_hash_get_current_data(Z_ARRVAL_PP(body), (void **) &data) == SUCCESS) {
+ while (zend_hash_get_current_data(Z_ARRVAL_P(body), (void **) &data) == SUCCESS) {
if (Z_TYPE_PP(data) == IS_ARRAY) {
short type = -1;
if (zend_hash_find(Z_ARRVAL_PP(data), "type", sizeof("type"), (void **) &pvalue)== SUCCESS) {
@@ -3311,7 +3568,7 @@ PHP_FUNCTION(imap_mail_compose)
bod->md5 = cpystr(Z_STRVAL_PP(pvalue));
}
}
- zend_hash_move_forward(Z_ARRVAL_PP(body));
+ zend_hash_move_forward(Z_ARRVAL_P(body));
}
if (bod && bod->type == TYPEMULTIPART && (!bod->nested.part || !bod->nested.part->next)) {
@@ -3591,66 +3848,33 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
Send an email message */
PHP_FUNCTION(imap_mail)
{
- zval **argv[7];
char *to=NULL, *message=NULL, *headers=NULL, *subject=NULL, *cc=NULL, *bcc=NULL, *rpath=NULL;
- int argc = ZEND_NUM_ARGS();
+ int to_len, message_len, headers_len, subject_len, cc_len, bcc_len, rpath_len, argc = ZEND_NUM_ARGS();
- if (argc < 3 || argc > 7 || zend_get_parameters_array_ex(argc, argv) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "sss|ssss", &to, &to_len, &subject, &subject_len, &message, &message_len,
+ &headers, &headers_len, &cc, &cc_len, &bcc, &bcc_len, &rpath, &rpath_len) == FAILURE) {
+ return;
}
/* To: */
- convert_to_string_ex(argv[0]);
- if (Z_STRVAL_PP(argv[0])) {
- to = Z_STRVAL_PP(argv[0]);
- } else {
+ if (!to_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No to field in mail command");
RETURN_FALSE;
}
/* Subject: */
- convert_to_string_ex(argv[1]);
- if (Z_STRVAL_PP(argv[1])) {
- subject = Z_STRVAL_PP(argv[1]);
- } else {
+ if (!subject_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No subject field in mail command");
RETURN_FALSE;
}
/* message body */
- convert_to_string_ex(argv[2]);
- if (Z_STRVAL_PP(argv[2])) {
- message = Z_STRVAL_PP(argv[2]);
- } else {
+ if (!message_len) {
/* this is not really an error, so it is allowed. */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No message string in mail command");
message = NULL;
}
- /* other headers */
- if (argc > 3) {
- convert_to_string_ex(argv[3]);
- headers = Z_STRVAL_PP(argv[3]);
- }
-
- /* cc */
- if (argc > 4) {
- convert_to_string_ex(argv[4]);
- cc = Z_STRVAL_PP(argv[4]);
- }
-
- /* bcc */
- if (argc > 5) {
- convert_to_string_ex(argv[5]);
- bcc = Z_STRVAL_PP(argv[5]);
- }
-
- /* rpath */
- if (argc > 6) {
- convert_to_string_ex(argv[6]);
- rpath = Z_STRVAL_PP(argv[6]);
- }
-
if (_php_imap_mail(to, subject, message, headers, cc, bcc, rpath TSRMLS_CC)) {
RETURN_TRUE;
} else {
@@ -3663,34 +3887,25 @@ PHP_FUNCTION(imap_mail)
Return a list of messages matching the given criteria */
PHP_FUNCTION(imap_search)
{
- zval **streamind, **criteria, **search_flags, **charset;
+ zval *streamind;
+ char *criteria, *charset = NULL;
+ int criteria_len, charset_len = 0;
+ long flags = SE_FREE;
pils *imap_le_struct;
- long flags;
char *search_criteria;
MESSAGELIST *cur;
int argc = ZEND_NUM_ARGS();
- if (argc < 2 || argc > 4 || zend_get_parameters_ex(argc, &streamind, &criteria, &search_flags, &charset) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "rs|ls", &streamind, &criteria, &criteria_len, &flags, &charset, &charset_len) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
- convert_to_string_ex(criteria);
- search_criteria = estrndup(Z_STRVAL_PP(criteria), Z_STRLEN_PP(criteria));
-
- if (argc == 2) {
- flags = SE_FREE;
- } else {
- convert_to_long_ex(search_flags);
- flags = Z_LVAL_PP(search_flags);
- if (argc == 4) {
- convert_to_string_ex(charset);
- }
- }
+ search_criteria = estrndup(criteria, criteria_len);
IMAPG(imap_messages) = IMAPG(imap_messages_tail) = NIL;
- mail_search_full(imap_le_struct->imap_stream, (argc == 4 ? Z_STRVAL_PP(charset) : NIL), mail_criteria(search_criteria), flags);
+ mail_search_full(imap_le_struct->imap_stream, (argc == 4 ? charset : NIL), mail_criteria(search_criteria), flags);
if (IMAPG(imap_messages) == NIL) {
efree(search_criteria);
RETURN_FALSE;
@@ -3715,8 +3930,8 @@ PHP_FUNCTION(imap_alerts)
{
STRINGLIST *cur=NIL;
- if (ZEND_NUM_ARGS() > 0) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
}
if (IMAPG(imap_alertstack) == NIL) {
@@ -3742,8 +3957,8 @@ PHP_FUNCTION(imap_errors)
{
ERRORLIST *cur=NIL;
- if (ZEND_NUM_ARGS() > 0) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
}
if (IMAPG(imap_errorstack) == NIL) {
@@ -3769,8 +3984,8 @@ PHP_FUNCTION(imap_last_error)
{
ERRORLIST *cur=NIL;
- if (ZEND_NUM_ARGS() > 0) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
}
if (IMAPG(imap_errorstack) == NIL) {
@@ -3792,21 +4007,20 @@ PHP_FUNCTION(imap_last_error)
PHP_FUNCTION(imap_mime_header_decode)
{
/* Author: Ted Parnefors <ted@mtv.se> */
- zval **str, *myobject;
- char *string, *charset, encoding, *text, *decode;
+ zval *myobject;
+ char *str, *string, *charset, encoding, *text, *decode;
+ int str_len;
long charset_token, encoding_token, end_token, end, offset=0, i;
unsigned long newlength;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(str);
-
array_init(return_value);
- string = Z_STRVAL_PP(str);
- end = Z_STRLEN_PP(str);
+ string = str;
+ end = str_len;
charset = (char *) safe_emalloc((end + 1), 2, 0);
text = &charset[end + 1];
@@ -3886,34 +4100,6 @@ PHP_FUNCTION(imap_mime_header_decode)
}
/* }}} */
-/* {{{ _php_rfc822_len
- * Calculate string length based on imap's rfc822_cat function.
- */
-static int _php_rfc822_len(char *str)
-{
- int len;
- char *p;
-
- if (!str || !*str) {
- return 0;
- }
-
- /* strings with special characters will need to be quoted, as a safety measure we
- * add 2 bytes for the quotes just in case.
- */
- len = strlen(str) + 2;
- p = str;
- /* rfc822_cat() will escape all " and \ characters, therefor we need to increase
- * our buffer length to account for these characters.
- */
- while ((p = strpbrk(p, "\\\""))) {
- p++;
- len++;
- }
-
- return len;
-}
-/* }}} */
/* Support Functions */
@@ -3953,6 +4139,35 @@ static char* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC)
#else
+/* {{{ _php_rfc822_len
+ * Calculate string length based on imap's rfc822_cat function.
+ */
+static int _php_rfc822_len(char *str)
+{
+ int len;
+ char *p;
+
+ if (!str || !*str) {
+ return 0;
+ }
+
+ /* strings with special characters will need to be quoted, as a safety measure we
+ * add 2 bytes for the quotes just in case.
+ */
+ len = strlen(str) + 2;
+ p = str;
+ /* rfc822_cat() will escape all " and \ characters, therefor we need to increase
+ * our buffer length to account for these characters.
+ */
+ while ((p = strpbrk(p, "\\\""))) {
+ p++;
+ len++;
+ }
+
+ return len;
+}
+/* }}} */
+
/* {{{ _php_imap_get_address_size
*/
static int _php_imap_address_size (ADDRESS *addresslist)
@@ -4290,25 +4505,18 @@ static int build_thread_tree(THREADNODE *top, zval **tree)
Return threaded by REFERENCES tree */
PHP_FUNCTION(imap_thread)
{
- zval **streamind, **search_flags;
+ zval *streamind;
pils *imap_le_struct;
- long flags;
+ long flags = SE_FREE;
char criteria[] = "ALL";
THREADNODE *top;
int argc = ZEND_NUM_ARGS();
- if ( argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &streamind, &search_flags) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(argc TSRMLS_CC, "r|l", &streamind, &flags) == FAILURE) {
+ return;
}
- ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-
- if (argc == 1) {
- flags = SE_FREE;
- } else {
- convert_to_long_ex(search_flags);
- flags = Z_LVAL_PP(search_flags);
- }
+ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap", le_imap);
top = mail_thread(imap_le_struct->imap_stream, "REFERENCES", NIL, mail_criteria(criteria), flags);
@@ -4433,7 +4641,7 @@ static char *php_mail_gets(readfn_t f, void *stream, unsigned long size, GETS_DA
/* {{{ Interfaces to C-client
*/
-void mm_searched(MAILSTREAM *stream, unsigned long number)
+PHP_IMAP_EXPORT void mm_searched(MAILSTREAM *stream, unsigned long number)
{
MESSAGELIST *cur = NIL;
TSRMLS_FETCH();
@@ -4453,20 +4661,20 @@ void mm_searched(MAILSTREAM *stream, unsigned long number)
}
}
-void mm_exists(MAILSTREAM *stream, unsigned long number)
+PHP_IMAP_EXPORT void mm_exists(MAILSTREAM *stream, unsigned long number)
{
}
-void mm_expunged(MAILSTREAM *stream, unsigned long number)
+PHP_IMAP_EXPORT void mm_expunged(MAILSTREAM *stream, unsigned long number)
{
}
-void mm_flags(MAILSTREAM *stream, unsigned long number)
+PHP_IMAP_EXPORT void mm_flags(MAILSTREAM *stream, unsigned long number)
{
}
/* Author: CJH */
-void mm_notify(MAILSTREAM *stream, char *str, long errflg)
+PHP_IMAP_EXPORT void mm_notify(MAILSTREAM *stream, char *str, long errflg)
{
STRINGLIST *cur = NIL;
TSRMLS_FETCH();
@@ -4489,7 +4697,7 @@ void mm_notify(MAILSTREAM *stream, char *str, long errflg)
}
}
-void mm_list(MAILSTREAM *stream, DTYPE delimiter, char *mailbox, long attributes)
+PHP_IMAP_EXPORT void mm_list(MAILSTREAM *stream, DTYPE delimiter, char *mailbox, long attributes)
{
STRINGLIST *cur=NIL;
FOBJECTLIST *ocur=NIL;
@@ -4536,7 +4744,7 @@ void mm_list(MAILSTREAM *stream, DTYPE delimiter, char *mailbox, long attributes
}
}
-void mm_lsub(MAILSTREAM *stream, DTYPE delimiter, char *mailbox, long attributes)
+PHP_IMAP_EXPORT void mm_lsub(MAILSTREAM *stream, DTYPE delimiter, char *mailbox, long attributes)
{
STRINGLIST *cur=NIL;
FOBJECTLIST *ocur=NIL;
@@ -4580,7 +4788,7 @@ void mm_lsub(MAILSTREAM *stream, DTYPE delimiter, char *mailbox, long attributes
}
}
-void mm_status(MAILSTREAM *stream, char *mailbox, MAILSTATUS *status)
+PHP_IMAP_EXPORT void mm_status(MAILSTREAM *stream, char *mailbox, MAILSTATUS *status)
{
TSRMLS_FETCH();
@@ -4602,7 +4810,7 @@ void mm_status(MAILSTREAM *stream, char *mailbox, MAILSTATUS *status)
}
}
-void mm_log(char *str, long errflg)
+PHP_IMAP_EXPORT void mm_log(char *str, long errflg)
{
ERRORLIST *cur = NIL;
TSRMLS_FETCH();
@@ -4628,14 +4836,14 @@ void mm_log(char *str, long errflg)
}
}
-void mm_dlog(char *str)
+PHP_IMAP_EXPORT void mm_dlog(char *str)
{
/* CJH: this is for debugging; it might be useful to allow setting
the stream to debug mode and capturing this somewhere - syslog?
php debugger? */
}
-void mm_login(NETMBX *mb, char *user, char *pwd, long trial)
+PHP_IMAP_EXPORT void mm_login(NETMBX *mb, char *user, char *pwd, long trial)
{
TSRMLS_FETCH();
@@ -4647,20 +4855,20 @@ void mm_login(NETMBX *mb, char *user, char *pwd, long trial)
strlcpy (pwd, IMAPG(imap_password), MAILTMPLEN);
}
-void mm_critical(MAILSTREAM *stream)
+PHP_IMAP_EXPORT void mm_critical(MAILSTREAM *stream)
{
}
-void mm_nocritical(MAILSTREAM *stream)
+PHP_IMAP_EXPORT void mm_nocritical(MAILSTREAM *stream)
{
}
-long mm_diskerror(MAILSTREAM *stream, long errcode, long serious)
+PHP_IMAP_EXPORT long mm_diskerror(MAILSTREAM *stream, long errcode, long serious)
{
return 1;
}
-void mm_fatal(char *str)
+PHP_IMAP_EXPORT void mm_fatal(char *str)
{
}
/* }}} */