]> granicus.if.org Git - php/commitdiff
(PHP imap_get_quota) updated to properly reflect the RFC 2087 as per
authorDan Kalowsky <kalowsky@php.net>
Fri, 26 Jul 2002 16:22:43 +0000 (16:22 +0000)
committerDan Kalowsky <kalowsky@php.net>
Fri, 26 Jul 2002 16:22:43 +0000 (16:22 +0000)
 bug #14673
@- imap_get_quota now allows multiple resource values to be returned, as
   per RFC 2087, closes bug #14673 (kalowsky, Sander Steffann)

ext/imap/php_imap.c
ext/imap/php_imap.h

index abb15253d55f0f591cba10d6baaa89c3254c9dad..8826d4d3413e8645a666cf374676678049875cec 100644 (file)
@@ -22,6 +22,7 @@
    |          Andrew Skalski      <askalski@chekinc.com>                  |
    |          Hartmut Holzgraefe  <hartmut@six.de>                        |
    |          Jani Taskinen       <sniper@iki.fi>                         |
+   |          Daniel R. Kalowsky  <kalowsky@php.net>                      |
    | PHP 4.0 updates:  Zeev Suraski <zeev@zend.com>                       |
    +----------------------------------------------------------------------+
  */
@@ -377,18 +378,27 @@ void mail_free_messagelist(MESSAGELIST **msglist, MESSAGELIST **tail)
  */
 void mail_getquota(MAILSTREAM *stream, char *qroot, QUOTALIST *qlist)
 {
+       zval *t_map;
        TSRMLS_FETCH();
+/* put parsing code here */
+       for(; qlist; qlist = qlist->next) {
+               MAKE_STD_ZVAL(t_map);
+               if (array_init(t_map) == FAILURE) {
+                       php_error(E_WARNING, "Unable to allocate t_map memory");
+                       FREE_ZVAL(t_map);
+                       FREE_ZVAL(IMAPG(quota_return));
+               }
 
-       /* this should only be run through once */
-       for (; qlist; qlist = qlist->next)
-       {
-               IMAPG(quota_usage) = qlist->usage;
-               IMAPG(quota_limit) = qlist->limit;
+               add_assoc_long_ex(t_map, "usage", sizeof("usage"), qlist->usage);
+               add_assoc_long_ex(t_map, "limit", sizeof("usage"), qlist->limit);
+               add_assoc_zval_ex(IMAPG(quota_return), qlist->name, strlen(qlist->name), t_map);
        }
 }
 /* }}} */
+
 #endif
 
+
 /* {{{ php_imap_init_globals
  */
 static void php_imap_init_globals(zend_imap_globals *imap_globals)
@@ -411,6 +421,9 @@ static void php_imap_init_globals(zend_imap_globals *imap_globals)
        imap_globals->imap_sfolder_objects_tail = NIL;
 
        imap_globals->folderlist_style = FLIST_ARRAY;
+#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
+       imap_globals->quota_return = NULL;
+#endif
 }
 /* }}} */
 
@@ -1045,6 +1058,13 @@ PHP_FUNCTION(imap_get_quota)
 
        convert_to_string_ex(qroot);
 
+       MAKE_STD_ZVAL(IMAPG(quota_return));
+       if (array_init(IMAPG(quota_return)) == FAILURE) {
+               php_error(E_WARNING, "Unable to allocate array memory");
+               FREE_ZVAL(IMAPG(quota_return));
+               RETURN_FALSE;
+       }
+
        /* 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))) {
@@ -1053,12 +1073,12 @@ PHP_FUNCTION(imap_get_quota)
        }
 
        if (array_init(return_value) == FAILURE) {
-               php_error(E_WARNING, "%s(): Unable to allocate array memory", get_active_function_name(TSRMLS_C));
+               php_error(E_WARNING, "Unable to allocate array memory");
                RETURN_FALSE;
        }
-               
-       add_assoc_long(return_value, "usage", IMAPG(quota_usage));
-       add_assoc_long(return_value, "limit", IMAPG(quota_limit));
+
+       add_next_index_zval(return_value, IMAPG(quota_return));
+
 }
 /* }}} */
 
@@ -1087,9 +1107,8 @@ PHP_FUNCTION(imap_set_quota)
 }
 /* }}} */
 
-
 /* {{{ proto int imap_setacl(int stream_id, string mailbox, string id, string rights)
-       Sets the ACL for a giving mailbox */
+       Sets the ACL for a given mailbox */
 PHP_FUNCTION(imap_setacl)
 {
        zval **streamind, **mailbox, **id, **rights;
index f8ff92638b46f574883b8b4ee52531ca3a1d534a..73105cfa0e6ae58f00d3d2241d187ce769df7d99 100644 (file)
@@ -22,6 +22,7 @@
    |          Andrew Skalski      <askalski@chekinc.com>                  |
    |          Hartmut Holzgraefe  <hartmut@six.de>                        |
    |          Jani Taskinen       <sniper@iki.fi>                         |
+   |          Daniel R. Kalowsky  <kalowsky@php.net>                      |
    | PHP 4.0 updates:  Zeev Suraski <zeev@zend.com>                       |
    +----------------------------------------------------------------------+
  */
@@ -208,8 +209,7 @@ ZEND_BEGIN_MODULE_GLOBALS(imap)
        unsigned long status_uidnext;
        unsigned long status_uidvalidity;
 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
-       unsigned long quota_usage;
-       unsigned long quota_limit;
+       zval *quota_return;
 #endif
 ZEND_END_MODULE_GLOBALS(imap)