Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40031 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10109 invoked from network); 21 Aug 2008 00:52:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2008 00:52:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=diegows@xtech.com.ar; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=diegows@xtech.com.ar; sender-id=unknown Received-SPF: error (pb1.pair.com: domain xtech.com.ar from 216.75.63.130 cause and error) X-PHP-List-Original-Sender: diegows@xtech.com.ar X-Host-Fingerprint: 216.75.63.130 mail.xtech.com.ar Linux 2.6 Received: from [216.75.63.130] ([216.75.63.130:43984] helo=mail.xtech.com.ar) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1F/F3-06543-A4CBCA84 for ; Wed, 20 Aug 2008 20:52:26 -0400 Received: by mail.xtech.com.ar (Postfix, from userid 19418) id 011C85A8005; Wed, 20 Aug 2008 22:08:58 -0300 (ART) Received: from localhost (motherbox.xtech.com.ar [200.68.115.49]) by mail.xtech.com.ar (Postfix) with ESMTP id DAA8F5A8002 for ; Wed, 20 Aug 2008 22:08:56 -0300 (ART) Date: Wed, 20 Aug 2008 21:52:20 -0300 To: internals@lists.php.net Message-ID: <20080821005220.GA23091@motherbox.xtech.com.ar> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.0.2 Subject: [PATCH] add imap_myrights From: diegows@xtech.com.ar (Diego Woitasen) Hi, I attach the patch that adds imap_myrights function to IMAP module. MYRIGHTS is a standard IMAP command defined in RFC 2086. diff -u -r php-5.2.6/ext/imap/php_imap.c php-myrights/ext/imap/php_imap.c --- php-5.2.6/ext/imap/php_imap.c Thu Apr 17 13:04:49 2008 +++ php-myrights/ext/imap/php_imap.c Tue Jun 3 18:06:37 2008 @@ -154,6 +154,7 @@ PHP_FE(imap_set_quota, NULL) PHP_FE(imap_setacl, NULL) PHP_FE(imap_getacl, NULL) + PHP_FE(imap_myrights, NULL) #endif PHP_FE(imap_mail, NULL) @@ -413,6 +414,20 @@ } /* }}} */ +/* {{{ mail_myrights + * + * Mail MYRIGHTS callback + * Called via the mail_parameter function in c-client:src/c-client/mail.c + */ +void mail_myrights(MAILSTREAM *stream, char *mailbox, char *rights) +{ + TSRMLS_FETCH(); + + ZVAL_STRING(IMAPG(imap_acl_list), rights, 1) + +} +/* }}} */ + #endif @@ -1087,6 +1102,35 @@ mail_parameters(NIL, SET_ACL, (void *) mail_getacl); if(!imap_getacl(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox))) { php_error(E_WARNING, "c-client imap_getacl failed"); + zval_dtor(return_value); + RETURN_FALSE; + } + + IMAPG(imap_acl_list) = NIL; +} +/* }}} */ + +/* {{{ proto string imap_myrights(resource stream_id, string mailbox) + Gets my rights (ACL) for a given mailbox */ +PHP_FUNCTION(imap_myrights) +{ + zval **streamind, **mailbox; + pils *imap_le_struct; + + if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &mailbox) == FAILURE) { + ZEND_WRONG_PARAM_COUNT(); + } + + ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap); + + convert_to_string_ex(mailbox); + + IMAPG(imap_acl_list) = return_value; + + /* set the callback for the GET_ACL function */ + mail_parameters(NIL, SET_MYRIGHTS, (void *) mail_myrights); + if(!imap_myrights(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox))) { + php_error(E_WARNING, "c-client imap_myrights failed"); zval_dtor(return_value); RETURN_FALSE; } diff -u -r php-5.2.6/ext/imap/php_imap.h php-myrights/ext/imap/php_imap.h --- php-5.2.6/ext/imap/php_imap.h Mon Dec 31 08:20:07 2007 +++ php-myrights/ext/imap/php_imap.h Tue Jun 3 18:05:14 2008 @@ -174,6 +174,7 @@ PHP_FUNCTION(imap_set_quota); PHP_FUNCTION(imap_setacl); PHP_FUNCTION(imap_getacl); +PHP_FUNCTION(imap_myrights); #endif -- ----------------------- Diego Woitasen - XTECH www.xtech.com.ar