cvs: php4 /ext/imap php_imap.c php_imap.h

From: Date: Fri, 26 Jul 2002 16:26:02 +0000
Subject: cvs: php4 /ext/imap php_imap.c php_imap.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12992@lists.php.net to get a copy of this message
kalowsky Fri Jul 26 12:26:02 2002 EDT Modified files: /php4/ext/imap php_imap.c php_imap.h Log: Adding initial support for PHP imap_get_quotaroot # apparently c-client does not like Cyrus's GETQUOTAROOT return list this # is still be worked out, but all functionality should be there # Return array is still not very organized Index: php4/ext/imap/php_imap.c diff -u php4/ext/imap/php_imap.c:1.126 php4/ext/imap/php_imap.c:1.127 --- php4/ext/imap/php_imap.c:1.126 Fri Jul 26 12:22:43 2002 +++ php4/ext/imap/php_imap.c Fri Jul 26 12:26:01 2002 @@ -26,7 +26,7 @@ | PHP 4.0 updates: Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_imap.c,v 1.126 2002/07/26 16:22:43 kalowsky Exp $ */ +/* $Id: php_imap.c,v 1.127 2002/07/26 16:26:01 kalowsky Exp $ */ #define IMAP41 @@ -135,6 +135,7 @@ #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) #endif @@ -396,6 +397,23 @@ } /* }}} */ +/* {{{ mail_getquotaroot + * + * Mail GET_QUOTAROOT callback + * Called via the mail_parameter function in c-client:src/c-client/mail.c + * Author DRK + */ +void mail_getquotaroot(MAILSTREAM *stream, char *mbx, STRINGLIST *qroot) +{ + TSRMLS_FETCH(); + + add_next_index_string(IMAPG(quotaroot_return), mbx, 1); + for(; qroot; qroot = qroot->next) { + add_next_index_string(IMAPG(quotaroot_return), qroot->text.data, 1); + } + +} +/* }}} */ #endif @@ -423,6 +441,7 @@ imap_globals->folderlist_style = FLIST_ARRAY; #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001) imap_globals->quota_return = NULL; + imap_globals->quotaroot_return = NULL; #endif } /* }}} */ @@ -1079,6 +1098,45 @@ add_next_index_zval(return_value, IMAPG(quota_return)); +} +/* }}} */ + +/* {{{ proto array imap_get_quotaroot(int stream_id, string mbox) + Returns the quota set to the mailbox account mbox */ +PHP_FUNCTION(imap_get_quotaroot) +{ + zval **streamind, **mbox; + zval *quotaroot_return; + pils *imap_le_struct; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &mbox) == FAILURE) { + ZEND_WRONG_PARAM_COUNT(); + } + + ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap); + + convert_to_string_ex(mbox); + + MAKE_STD_ZVAL(IMAPG(quotaroot_return)); + if (array_init(IMAPG(quotaroot_return)) == FAILURE) { + php_error(E_WARNING, "%s(): Unable to allocate array memory", get_active_function_name(TSRMLS_C)); + FREE_ZVAL(quotaroot_return); + RETURN_FALSE; + } + + /* set the callback for the GET_QUOTAROOT function */ + mail_parameters(NIL, SET_QUOTAROOT, (void *) mail_getquotaroot); + if(!imap_getquotaroot(imap_le_struct->imap_stream, Z_STRVAL_PP(mbox))) { + php_error(E_WARNING, "c-client imap_getquotaroot failed"); + RETURN_FALSE; + } + + if (array_init(return_value) == FAILURE) { + php_error(E_WARNING, "%s(): Unable to allocate array memory", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; + } + + add_next_index_zval(return_value, IMAPG(quotaroot_return)); } /* }}} */ Index: php4/ext/imap/php_imap.h diff -u php4/ext/imap/php_imap.h:1.20 php4/ext/imap/php_imap.h:1.21 --- php4/ext/imap/php_imap.h:1.20 Fri Jul 26 12:22:43 2002 +++ php4/ext/imap/php_imap.h Fri Jul 26 12:26:01 2002 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_imap.h,v 1.20 2002/07/26 16:22:43 kalowsky Exp $ */ +/* $Id: php_imap.h,v 1.21 2002/07/26 16:26:01 kalowsky Exp $ */ #ifndef PHP_IMAP_H #define PHP_IMAP_H @@ -178,6 +178,7 @@ #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001) PHP_FUNCTION(imap_get_quota); +PHP_FUNCTION(imap_get_quotaroot); PHP_FUNCTION(imap_set_quota); PHP_FUNCTION(imap_setacl); #endif @@ -210,6 +211,7 @@ unsigned long status_uidvalidity; #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001) zval *quota_return; + zval *quotaroot_return; #endif ZEND_END_MODULE_GLOBALS(imap)

« previous php.cvs (#12992) next »