iliaa Thu Jan 8 16:15:45 2009 UTC
Modified files:
/php-src/ext/imap php_imap.c
Log:
MFB: Improved parameter fixing & address a compiler warning
http://cvs.php.net/viewvc.cgi/php-src/ext/imap/php_imap.c?r1=1.270&r2=1.271&diff_format=u
Index: php-src/ext/imap/php_imap.c
diff -u php-src/ext/imap/php_imap.c:1.270 php-src/ext/imap/php_imap.c:1.271
--- php-src/ext/imap/php_imap.c:1.270 Wed Jan 7 18:25:50 2009
+++ php-src/ext/imap/php_imap.c Thu Jan 8 16:15:45 2009
@@ -26,7 +26,7 @@
| PHP 4.0 updates: Zeev Suraski <[email protected]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_imap.c,v 1.270 2009/01/07 18:25:50 felipe Exp $ */
+/* $Id: php_imap.c,v 1.271 2009/01/08 16:15:45 iliaa Exp $ */
#define IMAP41
@@ -1191,20 +1191,19 @@
zval *streamind;
char *mailbox;
int mailbox_len;
- long options, retries;
+ long options = NULL, retries = NULL;
pils *imap_le_struct;
MAILSTREAM *imap_stream;
long flags=NIL;
long cl_flags=NIL;
- int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "rs|ll", &streamind,
&mailbox, &mailbox_len, &options, &retries) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|ll",
&streamind, &mailbox, &mailbox_len, &options, &retries) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap",
le_imap);
- if (argc >= 3) {
+ if (options) {
flags = options;
if (flags & PHP_EXPUNGE) {
cl_flags = CL_EXPUNGE;
@@ -1213,7 +1212,7 @@
imap_le_struct->flags = cl_flags;
}
#ifdef SET_MAXLOGINTRIALS
- if (argc == 4) {
+ if (retries) {
mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) retries);
}
#endif
@@ -1241,9 +1240,8 @@
int folder_len, message_len, flags_len = 0;
pils *imap_le_struct;
STRING st;
- int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "rss|s", &streamind, &folder,
&folder_len, &message, &message_len, &flags, &flags_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|s",
&streamind, &folder, &folder_len, &message, &message_len, &flags, &flags_len)
== FAILURE) {
return;
}
@@ -1251,7 +1249,7 @@
INIT (&st, mail_string, (void *) message, message_len);
- if (mail_append_full(imap_le_struct->imap_stream, folder, (argc == 4 ?
flags : NIL), NIL, &st)) {
+ if (mail_append_full(imap_le_struct->imap_stream, folder, (flags ?
flags : NIL), NIL, &st)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -2840,17 +2838,16 @@
zval *streamind;
char *sequence, *flag;
int sequence_len, flag_len;
- long flags;
+ long flags = NULL;
pils *imap_le_struct;
- int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "rss|l", &streamind,
&sequence, &sequence_len, &flag, &flag_len, &flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|l",
&streamind, &sequence, &sequence_len, &flag, &flag_len, &flags) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, &streamind, -1, "imap",
le_imap);
- mail_setflag_full(imap_le_struct->imap_stream, sequence, flag, (argc ==
4 ? flags : NIL));
+ mail_setflag_full(imap_le_struct->imap_stream, sequence, flag, (flags ?
flags : NIL));
RETURN_TRUE;
}
/* }}} */
@@ -4093,34 +4090,6 @@
}
/* }}} */
-/* {{{ _php_rfc822_len
- * Calculate string length based on imap's rfc822_cat function.
- */
-static int _php_rfc822_len(char *str)
-{
- int len;
- char *p;
-
- if (!str || !*str) {
- return 0;
- }
-
- /* strings with special characters will need to be quoted, as a safety
measure we
- * add 2 bytes for the quotes just in case.
- */
- len = strlen(str) + 2;
- p = str;
- /* rfc822_cat() will escape all " and \ characters, therefor we need to
increase
- * our buffer length to account for these characters.
- */
- while ((p = strpbrk(p, "\\\""))) {
- p++;
- len++;
- }
-
- return len;
-}
-/* }}} */
/* Support Functions */
@@ -4160,6 +4129,35 @@
#else
+/* {{{ _php_rfc822_len
+ * Calculate string length based on imap's rfc822_cat function.
+ */
+static int _php_rfc822_len(char *str)
+{
+ int len;
+ char *p;
+
+ if (!str || !*str) {
+ return 0;
+ }
+
+ /* strings with special characters will need to be quoted, as a safety
measure we
+ * add 2 bytes for the quotes just in case.
+ */
+ len = strlen(str) + 2;
+ p = str;
+ /* rfc822_cat() will escape all " and \ characters, therefor we need to
increase
+ * our buffer length to account for these characters.
+ */
+ while ((p = strpbrk(p, "\\\""))) {
+ p++;
+ len++;
+ }
+
+ return len;
+}
+/* }}} */
+
/* {{{ _php_imap_get_address_size
*/
static int _php_imap_address_size (ADDRESS *addresslist)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php