Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40091 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73363 invoked from network); 26 Aug 2008 12:59:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Aug 2008 12:59:06 -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:55190] helo=mail.xtech.com.ar) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/D1-03121-01EF3B84 for ; Tue, 26 Aug 2008 08:59:05 -0400 Received: by mail.xtech.com.ar (Postfix, from userid 19418) id DA9F75A8009; Tue, 26 Aug 2008 10:15:37 -0300 (ART) Received: from webmail.xtech.com.ar (localhost.localdomain [127.0.0.1]) by mail.xtech.com.ar (Postfix) with ESMTP id EB8F15A8004; Tue, 26 Aug 2008 10:15:36 -0300 (ART) Received: from 29-22-190-190.cab.prima.net.ar ([190.190.22.29]) (SquirrelMail authenticated user diegows@xtech.com.ar) by webmail.xtech.com.ar with HTTP; Tue, 26 Aug 2008 10:15:36 -0300 (ART) Message-ID: <54207.190.190.22.29.1219756536.squirrel@webmail.xtech.com.ar> In-Reply-To: <48ACCB1E.8030607@sci.fi> References: <20080821005220.GA23091@motherbox.xtech.com.ar> <48ACCB1E.8030607@sci.fi> Date: Tue, 26 Aug 2008 10:15:36 -0300 (ART) To: jani.taskinen@iki.fi Cc: "Diego Woitasen" , internals@lists.php.net User-Agent: SquirrelMail/1.4.7 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.0.2 Subject: Re: [PHP-DEV] [PATCH] add imap_myrights From: diegows@xtech.com.ar ("Diego Woitasen") On Wed, August 20, 2008 10:55 pm, Jani Taskinen wrote: > Diego Woitasen kirjoitti: >> 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 > > Does this really work? You're blindly overwriting the acl global, > AFAICT..? > Or is that intentional? Yes, it works. I use the imap_getacl() function as example to write imap_myrights(). What's the problem with overwriting acl global? > >> >> >> @@ -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; >> +} >> +/* }}} */ > > ..and again.. > >> + >> +/* {{{ 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); > > SET? Not GET? In what c-client version was this added anyway..? Yes, if I didn't misundertand the API. GET/SET are used to set or get API parameters, they don't anything at IMAP protocol. See imap_getacl() function for example. I'm using imap 2006k. > > --Jani > > >> + 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 - Soluciones Linux para empresas (54) 011 5219-0678