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

From: Date: Sun, 25 Feb 2001 04:41:19 +0000
Subject: cvs: php4 /ext/imap config.m4 php_imap.c php_imap.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4259@lists.php.net to get a copy of this message
kalowsky Sat Feb 24 20:41:19 2001 EDT Modified files: /php4/ext/imap config.m4 php_imap.c php_imap.h Log: Updating the IMAP client to include quota support via the imap c-client2000 libraries. # Y2K support is good... Removes the SA_QUOTA and SA_QUOTA_ALL defines # After speaking with Mark Crispin, it is believed these never existed. Cleans up the imap_status() function to remove notion of quotas in a status message. # There is no quota setting in a STATUS message from c-client. Changes the config.m4 to support the client.h include # This should include all the approriate headers for c-client (as defined by # c-client maintainers) such as mail.h, and rfc822.h. Changed the directory search order for the include files as well. # Place the /usr/local/include last, and searched the # /usr/local/include/{c-client|imap} directories first (PHP imap_get_quota) Added (PHP imap_set_quota) Added @- IMAP quota support (imap_set_quota, imap_get_quota) enabled/added via @ c-client2000 PR: Submitted by: Reviewed by: Obtained from: Index: php4/ext/imap/config.m4 diff -u php4/ext/imap/config.m4:1.22 php4/ext/imap/config.m4:1.23 --- php4/ext/imap/config.m4:1.22 Mon Oct 2 15:16:53 2000 +++ php4/ext/imap/config.m4 Sat Feb 24 20:41:18 2001 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.22 2000/10/02 22:16:53 rasmus Exp $ +dnl $Id: config.m4,v 1.23 2001/02/25 04:41:18 kalowsky Exp $ AC_DEFUN(IMAP_INC_CHK,[if test -r $i$1/rfc822.h; then IMAP_DIR=$i; IMAP_INC_DIR=$i$1]) @@ -41,9 +41,9 @@ if test "$PHP_IMAP" != "no"; then for i in /usr/local /usr $PHP_IMAP; do IMAP_INC_CHK() - el[]IMAP_INC_CHK(/include) - el[]IMAP_INC_CHK(/include/imap) el[]IMAP_INC_CHK(/include/c-client) + el[]IMAP_INC_CHK(/include/imap) + el[]IMAP_INC_CHK(/include) el[]IMAP_INC_CHK(/imap) el[]IMAP_INC_CHK(/c-client) fi Index: php4/ext/imap/php_imap.c diff -u php4/ext/imap/php_imap.c:1.57 php4/ext/imap/php_imap.c:1.58 --- php4/ext/imap/php_imap.c:1.57 Wed Feb 21 12:33:46 2001 +++ php4/ext/imap/php_imap.c Sat Feb 24 20:41:18 2001 @@ -25,7 +25,7 @@ | PHP 4.0 updates: Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_imap.c,v 1.57 2001/02/21 20:33:46 thies Exp $ */ +/* $Id: php_imap.c,v 1.58 2001/02/25 04:41:18 kalowsky Exp $ */ #define IMAP41 @@ -101,6 +101,8 @@ PHP_FE(imap_createmailbox, NULL) PHP_FE(imap_renamemailbox, NULL) PHP_FE(imap_deletemailbox, NULL) + PHP_FE(imap_get_quota, NULL) + PHP_FE(imap_set_quota, NULL) PHP_FALIAS(imap_listmailbox, imap_list, NULL) PHP_FALIAS(imap_getmailboxes, imap_list_full, NULL) PHP_FALIAS(imap_scanmailbox, imap_listscan, NULL) @@ -355,6 +357,20 @@ sizeof(MESSAGELIST)); } +/* Mail GET_QUOTA callback + * Called via the mail_parameter function in c-client:src/c-client/mail.c + * Author DRK + */ +void mail_getquota(MAILSTREAM *stream, char *qroot,QUOTALIST *qlist) +{ + /* this should only be run through once */ + for (; qlist; qlist = qlist->next) + { + IMAPG(quota_usage) = qlist->usage; + IMAPG(quota_limit) = qlist->limit; + } +} + /* Mail garbage collect MESSAGELIST * Accepts: pointer to MESSAGELIST pointer * Author: CJH @@ -532,16 +548,12 @@ REGISTER_MAIN_LONG_CONSTANT("SA_UIDVALIDITY",SA_UIDVALIDITY , CONST_PERSISTENT | CONST_CS); /* UID validity value */ -#ifdef SA_QUOTA - sa_all |= SA_QUOTA; - REGISTER_MAIN_LONG_CONSTANT("SA_QUOTA",SA_QUOTA , CONST_PERSISTENT | CONST_CS); + sa_all |= GET_QUOTA; + REGISTER_MAIN_LONG_CONSTANT("GET_QUOTA",GET_QUOTA , CONST_PERSISTENT | CONST_CS); /* Disk space taken up by mailbox. */ -#endif -#ifdef SA_QUOTA_ALL - sa_all |= SA_QUOTA_ALL; - REGISTER_MAIN_LONG_CONSTANT("SA_QUOTA_ALL",SA_QUOTA_ALL , CONST_PERSISTENT | CONST_CS); + sa_all |= GET_QUOTAROOT; + REGISTER_MAIN_LONG_CONSTANT("GET_QUOTAROOT",GET_QUOTAROOT , CONST_PERSISTENT | CONST_CS); /* Disk space taken up by all mailboxes owned by user. */ -#endif REGISTER_MAIN_LONG_CONSTANT("SA_ALL", sa_all, CONST_PERSISTENT | CONST_CS); /* get all status information */ @@ -1000,6 +1012,80 @@ /* }}} */ +/* {{{ proto array imap_get_quota(int stream_id, string qroot) + Returns the quota set to the mailbox account qroot */ +PHP_FUNCTION(imap_get_quota) +{ + zval **streamind, **qroot; + + int ind, ind_type; + pils *imap_le_struct; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &qroot) == FAILURE) { + ZEND_WRONG_PARAM_COUNT(); + } + + convert_to_long_ex(streamind); + convert_to_string_ex(qroot); + + ind = Z_LVAL_PP(streamind); + imap_le_struct = (pils *) zend_list_find(ind, &ind_type); + if (!imap_le_struct || !IS_STREAM(ind_type)) { + php_error(E_WARNING, "Unable to find stream pointer"); + 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))) { + php_error(E_WARNING, "c-client imap_getquota failed"); + RETURN_FALSE; + } + + if (array_init(return_value) == FAILURE) { + 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)); +} +/* }}} */ + + +/* {{{ proto int imap_set_quota(int stream_id, string qroot, int mailbox_size) + Will set the quota for qroot mailbox */ +PHP_FUNCTION(imap_set_quota) +{ + zval **streamind, **qroot, **mailbox_size; + STRINGLIST limits; + int ind, ind_type; + pils *imap_le_struct; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &qroot, &mailbox_size) == FAILURE) { + ZEND_WRONG_PARAM_COUNT(); + } + + convert_to_long_ex(streamind); + convert_to_string_ex(qroot); + convert_to_long_ex(mailbox_size); + + limits.text.data = "STORAGE"; + limits.text.size = Z_LVAL_PP(mailbox_size); + limits.next = NIL; + + ind = Z_LVAL_PP(streamind); + imap_le_struct = (pils *) zend_list_find(ind, &ind_type); + if (!imap_le_struct || !IS_STREAM(ind_type)) { + php_error(E_WARNING, "Unable to find stream pointer"); + RETURN_FALSE; + } + RETURN_LONG(imap_setquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot), &limits)); +} +/* }}} */ + + /* {{{ proto int imap_expunge(int stream_id) Permanently delete all messages marked for deletion */ PHP_FUNCTION(imap_expunge) @@ -2813,6 +2899,7 @@ if (object_init(return_value) == FAILURE) { RETURN_FALSE; } + if (mail_status(imap_le_struct->imap_stream, Z_STRVAL_PP(mbx), Z_LVAL_PP(flags))) { add_property_long(return_value, "flags", IMAPG(status_flags)); if (IMAPG(status_flags) & SA_MESSAGES) { @@ -2830,16 +2917,6 @@ if (IMAPG(status_flags) & SA_UIDVALIDITY) { add_property_long(return_value, "uidvalidity", IMAPG(status_uidvalidity)); } -#ifdef SA_QUOTA - if (IMAPG(status_flags) & SA_QUOTA) { - add_property_long(return_value, "quota", IMAPG(status_quota)); - } -#endif -#ifdef SA_QUOTA - if (IMAPG(status_flags) & SA_QUOTA_ALL) { - add_property_long(return_value, "quota_all", IMAPG(status_quota_all)); - } -#endif } else { RETURN_FALSE; } @@ -4075,17 +4152,6 @@ if (IMAPG(status_flags) & SA_UIDVALIDITY) { IMAPG(status_uidvalidity)=status->uidvalidity; } - -#ifdef SA_QUOTA - if (IMAPG(status_flags) & SA_QUOTA) { - IMAPG(status_quota)=status->quota; - } -#endif -#ifdef SA_QUOTA_ALL - if (IMAPG(status_flags) & SA_QUOTA_ALL) { - IMAPG(status_quota_all)=status->quota_all; - } -#endif } void mm_log(char *str, long errflg) Index: php4/ext/imap/php_imap.h diff -u php4/ext/imap/php_imap.h:1.5 php4/ext/imap/php_imap.h:1.6 --- php4/ext/imap/php_imap.h:1.5 Tue Oct 17 08:42:05 2000 +++ php4/ext/imap/php_imap.h Sat Feb 24 20:41:18 2001 @@ -6,8 +6,12 @@ #include "build-defs.h" #endif -#include "mail.h" -#include "rfc822.h" +/* + #include "mail.h" + #include "rfc822.h" +*/ +#include "c-client.h" +#include "imap4r1.h" /* used for the imap_setquota function */ #include "modules.h" extern zend_module_entry imap_module_entry; @@ -100,6 +104,8 @@ PHP_FUNCTION(imap_deletemailbox); PHP_FUNCTION(imap_listmailbox); PHP_FUNCTION(imap_scanmailbox); +PHP_FUNCTION(imap_get_quota); +PHP_FUNCTION(imap_set_quota); PHP_FUNCTION(imap_subscribe); PHP_FUNCTION(imap_unsubscribe); PHP_FUNCTION(imap_append); @@ -156,12 +162,8 @@ unsigned long status_unseen; unsigned long status_uidnext; unsigned long status_uidvalidity; -#ifdef SA_QUOTA - unsigned long status_quota; -#endif -#ifdef SA_QUOTA_ALL - unsigned long status_quota_all; -#endif + unsigned long quota_usage; + unsigned long quota_limit; ZEND_END_MODULE_GLOBALS(imap)

« previous php.cvs (#4259) next »