Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16351 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20546 invoked by uid 1010); 1 Jun 2005 16:51:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 14103 invoked from network); 1 Jun 2005 16:28:29 -0000 Received: from unknown (HELO intra2net.com) (127.0.0.1) by localhost with SMTP; 1 Jun 2005 16:28:29 -0000 X-Host-Fingerprint: 81.169.173.116 rs02.intra2net.com Linux 2.5 (sometimes 2.4) (4) Received: from ([81.169.173.116:54371] helo=rs02.intra2net.com) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id 46/70-08505-622ED924 for ; Wed, 01 Jun 2005 12:28:24 -0400 Received: from intranator.m.i2n (unknown [172.16.1.99]) by rs02.intra2net.com (Postfix) with ESMTP id E13524180 for ; Wed, 1 Jun 2005 18:28:06 +0200 (CEST) Received: from localhost (intranator.m.i2n [127.0.0.1]) by localhost (Postfix) with ESMTP id 75DDB1C4 for ; Wed, 1 Jun 2005 18:27:12 +0200 (CEST) Received: from storm.m.i2n (storm.m.i2n [172.16.1.2]) by intranator.m.i2n (Postfix) with ESMTP id 55E8D114; Wed, 1 Jun 2005 18:27:11 +0200 (CEST) Organization: Intra2net AG To: internals@lists.php.net Date: Wed, 1 Jun 2005 18:28:04 +0200 User-Agent: KMail/1.7.2 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_UIenCkb8ZiC72vU" Message-ID: <200506011828.04990.thomas.jarosch@intra2net.com> X-Virus-Scanned: by Intranator (www.intranator.com) with AMaViS and F-Secure AntiVirus X-Spam-Status: hits=-9.3 tests=[ALL_TRUSTED=-3.3,BAYES_00=-6] X-Spam-Level: 907 Subject: [patch] new imap_status_current() function From: thomas.jarosch@intra2net.com (Thomas Jarosch) --Boundary-00=_UIenCkb8ZiC72vU Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, attached patch adds a new imap_status_current() function. This function exposes several status variables about the current selected folder. The patch was developed for PHP 4.3.11, but also applies to PHP 5.0.4 with fuzz. A little sidenote on the normal imap_status() function: It's undefined to call it for the current folder. Quoting RFC 3501, section 6.3.10: The STATUS command is intended to access the status of mailboxes other than the currently selected mailbox. Because the STATUS command can cause the mailbox to be opened internally, and because this information is available by other means on the selected mailbox, the STATUS command SHOULD NOT be used on the currently selected mailbox. Maybe it should be added to the documentation to use only the new imap_status_current() function for the current folder. Please CC: comments, I'm not on the list. Best regards, Thomas Jarosch --Boundary-00=_UIenCkb8ZiC72vU Content-Type: text/x-diff; charset="iso-8859-1"; name="php-imap-status-current.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="php-imap-status-current.patch" diff -u -r -p ext/imap/php_imap.c ext.imap/imap/php_imap.c --- ext/imap/php_imap.c Tue Jan 25 15:23:37 2005 +++ ext.imap/imap/php_imap.c Wed Jun 1 17:35:41 2005 @@ -115,6 +115,7 @@ function_entry imap_functions[] = { PHP_FE(imap_binary, NULL) PHP_FE(imap_utf8, NULL) PHP_FE(imap_status, NULL) + PHP_FE(imap_status_current, NULL) PHP_FE(imap_mailboxmsginfo, NULL) PHP_FE(imap_setflag_full, NULL) PHP_FE(imap_clearflag_full, NULL) @@ -2548,6 +2549,42 @@ PHP_FUNCTION(imap_msgno) convert_to_long_ex(msgno); RETURN_LONG(mail_msgno(imap_le_struct->imap_stream, Z_LVAL_PP(msgno))); +} +/* }}} */ + +/* {{{ proto object imap_status_current(resource stream_id, int options) + Get (cached) status info from current mailbox */ +PHP_FUNCTION(imap_status_current) +{ + zval **streamind, **pflags; + pils *imap_le_struct; + long flags = 0L; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &pflags) == FAILURE) { + ZEND_WRONG_PARAM_COUNT(); + } + + ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap); + + convert_to_long_ex(pflags); + flags = Z_LVAL_PP(pflags); + + if (object_init(return_value) == FAILURE) { + RETURN_FALSE; + } + + if (flags & SA_MESSAGES) { + add_property_long(return_value, "messages", imap_le_struct->imap_stream->nmsgs); + } + if (flags & SA_RECENT) { + add_property_long(return_value, "recent", imap_le_struct->imap_stream->recent); + } + if (flags & SA_UIDNEXT) { + add_property_long(return_value, "uidnext", imap_le_struct->imap_stream->uid_last+1); + } + if (flags & SA_UIDVALIDITY) { + add_property_long(return_value, "uidvalidity", imap_le_struct->imap_stream->uid_validity); + } } /* }}} */ diff -u -r -p ext/imap/php_imap.h ext.imap/imap/php_imap.h --- ext/imap/php_imap.h Fri Jun 13 16:45:36 2003 +++ ext.imap/imap/php_imap.h Wed Jun 1 17:35:49 2005 @@ -151,6 +151,7 @@ PHP_FUNCTION(imap_lsub); PHP_FUNCTION(imap_lsub_full); PHP_FUNCTION(imap_create); PHP_FUNCTION(imap_rename); +PHP_FUNCTION(imap_status_current); PHP_FUNCTION(imap_status); PHP_FUNCTION(imap_bodystruct); PHP_FUNCTION(imap_fetch_overview); --Boundary-00=_UIenCkb8ZiC72vU--