cvs: php4 /ext/imap php_imap.c
| From: | Ilia Alshanetsky | Date: | Thu, 12 Jun 2003 19:46:44 +0000 |
| Subject: | cvs: php4 /ext/imap php_imap.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-21655@lists.php.net to get a copy of this message | ||
iliaa Thu Jun 12 15:46:44 2003 EDT
Modified files:
/php4/ext/imap php_imap.c
Log:
Fixed bug #22505 (Allow imap_sort() and imap_search() to specify a charset)
Index: php4/ext/imap/php_imap.c
diff -u php4/ext/imap/php_imap.c:1.165 php4/ext/imap/php_imap.c:1.166
--- php4/ext/imap/php_imap.c:1.165 Tue Jun 10 16:03:30 2003
+++ php4/ext/imap/php_imap.c Thu Jun 12 15:46:44 2003
@@ -26,7 +26,7 @@
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_imap.c,v 1.165 2003/06/10 20:03:30 imajes Exp $ */
+/* $Id: php_imap.c,v 1.166 2003/06/12 19:46:44 iliaa Exp $ */
#define IMAP41
@@ -2393,11 +2393,11 @@
}
/* }}} */
-/* {{{ proto array imap_sort(resource stream_id, int criteria, int reverse [, int options [, string
search_criteria]])
+/* {{{ proto array imap_sort(resource stream_id, int criteria, int reverse [, int options [, string
search_criteria [, string charset]]])
Sort an array of message headers, optionally including only messages that meet specified
criteria. */
PHP_FUNCTION(imap_sort)
{
- zval **streamind, **pgm, **rev, **flags, **criteria;
+ zval **streamind, **pgm, **rev, **flags, **criteria, **charset;
pils *imap_le_struct;
unsigned long *slst, *sl;
char *search_criteria;
@@ -2405,7 +2405,7 @@
SEARCHPGM *spg=NIL;
int myargc = ZEND_NUM_ARGS();
- if (myargc < 3 || myargc > 5 || zend_get_parameters_ex(myargc, &streamind, &pgm,
&rev, &flags, &criteria) == FAILURE) {
+ if (myargc < 3 || myargc > 6 || zend_get_parameters_ex(myargc, &streamind, &pgm,
&rev, &flags, &criteria, &charset) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
@@ -2420,10 +2420,13 @@
if (myargc >= 4) {
convert_to_long_ex(flags);
}
- if (myargc == 5) {
+ if (myargc >= 5) {
search_criteria = estrndup(Z_STRVAL_PP(criteria), Z_STRLEN_PP(criteria));
spg = mail_criteria(search_criteria);
efree(search_criteria);
+ if (myargc == 6) {
+ convert_to_string_ex(charset);
+ }
} else {
spg = mail_newsearchpgm();
}
@@ -2433,7 +2436,7 @@
mypgm->function = (short) Z_LVAL_PP(pgm);
mypgm->next = NIL;
- slst = mail_sort(imap_le_struct->imap_stream, NIL, spg, mypgm, myargc >= 4 ?
Z_LVAL_PP(flags) : NIL);
+ slst = mail_sort(imap_le_struct->imap_stream, (myargc == 6 ? Z_STRVAL_PP(charset) : NIL), spg,
mypgm, (myargc >= 4 ? Z_LVAL_PP(flags) : NIL));
if (spg) {
mail_free_searchpgm(&spg);
@@ -3381,18 +3384,18 @@
}
/* }}} */
-/* {{{ proto array imap_search(resource stream_id, string criteria [, int options])
+/* {{{ proto array imap_search(resource stream_id, string criteria [, int options [, string
charset]])
Return a list of messages matching the given criteria */
PHP_FUNCTION(imap_search)
{
- zval **streamind, **criteria, **search_flags;
+ zval **streamind, **criteria, **search_flags, **charset;
pils *imap_le_struct;
long flags;
char *search_criteria;
MESSAGELIST *cur;
int argc = ZEND_NUM_ARGS();
- if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &streamind, &criteria,
&search_flags) == FAILURE) {
+ if (argc < 2 || argc > 4 || zend_get_parameters_ex(argc, &streamind, &criteria,
&search_flags, &charset) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
@@ -3406,10 +3409,13 @@
} else {
convert_to_long_ex(search_flags);
flags = Z_LVAL_PP(search_flags);
+ if (argc == 4) {
+ convert_to_string_ex(charset);
+ }
}
IMAPG(imap_messages) = IMAPG(imap_messages_tail) = NIL;
- mail_search_full(imap_le_struct->imap_stream, NIL, mail_criteria(search_criteria), flags);
+ mail_search_full(imap_le_struct->imap_stream, (argc == 4 ? Z_STRVAL_PP(charset) : NIL),
mail_criteria(search_criteria), flags);
if (IMAPG(imap_messages) == NIL) {
efree(search_criteria);
RETURN_FALSE;