@@ -704,13 +704,12 @@ PHP_MINFO_FUNCTION(imap)
704
704
PHP_FUNCTION (imap_open )
705
705
{
706
706
zend_string * mailbox , * user , * passwd ;
707
- zend_long retries = 0 , flags = NIL , cl_flags = NIL ;
707
+ zend_long retries = 0 , flags = 0 , cl_flags = 0 ;
708
708
MAILSTREAM * imap_stream ;
709
709
pils * imap_le_struct ;
710
710
HashTable * params = NULL ;
711
- int argc = ZEND_NUM_ARGS ();
712
711
713
- if (zend_parse_parameters (argc , "PSS|llh" , & mailbox , & user , & passwd , & flags , & retries , & params ) == FAILURE ) {
712
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "PSS|llh" , & mailbox , & user , & passwd , & flags , & retries , & params ) == FAILURE ) {
714
713
RETURN_THROWS ();
715
714
}
716
715
@@ -726,7 +725,7 @@ PHP_FUNCTION(imap_open)
726
725
RETURN_THROWS ();
727
726
}
728
727
729
- if (argc >= 4 ) {
728
+ if (flags ) {
730
729
if (flags & PHP_EXPUNGE ) {
731
730
cl_flags = CL_EXPUNGE ;
732
731
flags ^= PHP_EXPUNGE ;
@@ -795,7 +794,7 @@ PHP_FUNCTION(imap_open)
795
794
IMAPG (imap_password ) = estrndup (ZSTR_VAL (passwd ), ZSTR_LEN (passwd ));
796
795
797
796
#ifdef SET_MAXLOGINTRIALS
798
- if (argc >= 5 ) {
797
+ if (retries ) {
799
798
mail_parameters (NIL , SET_MAXLOGINTRIALS , (void * ) retries );
800
799
}
801
800
#endif
@@ -1168,7 +1167,6 @@ PHP_FUNCTION(imap_close)
1168
1167
pils * imap_le_struct = NULL ;
1169
1168
zend_long options = 0 , flags = NIL ;
1170
1169
1171
- /* TODO Change options to a boolean expunge flag? As it is the only valid flag. */
1172
1170
if (zend_parse_parameters (ZEND_NUM_ARGS (), "r|l" , & streamind , & options ) == FAILURE ) {
1173
1171
RETURN_THROWS ();
1174
1172
}
@@ -1258,11 +1256,11 @@ PHP_FUNCTION(imap_body)
1258
1256
zval * streamind ;
1259
1257
zend_long msgno , flags = 0 ;
1260
1258
pils * imap_le_struct ;
1261
- int msgindex , argc = ZEND_NUM_ARGS () ;
1259
+ int msgindex ;
1262
1260
char * body ;
1263
1261
unsigned long body_len = 0 ;
1264
1262
1265
- if (zend_parse_parameters (argc , "rl|l" , & streamind , & msgno , & flags ) == FAILURE ) {
1263
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "rl|l" , & streamind , & msgno , & flags ) == FAILURE ) {
1266
1264
RETURN_THROWS ();
1267
1265
}
1268
1266
@@ -1293,7 +1291,7 @@ PHP_FUNCTION(imap_body)
1293
1291
PHP_IMAP_CHECK_MSGNO (msgindex , 2 );
1294
1292
1295
1293
/* TODO Shouldn't this pass msgindex??? */
1296
- body = mail_fetchtext_full (imap_le_struct -> imap_stream , msgno , & body_len , ( argc == 3 ? flags : NIL ) );
1294
+ body = mail_fetchtext_full (imap_le_struct -> imap_stream , msgno , & body_len , flags );
1297
1295
if (body_len == 0 ) {
1298
1296
RETVAL_EMPTY_STRING ();
1299
1297
} else {
@@ -1308,10 +1306,9 @@ PHP_FUNCTION(imap_mail_copy)
1308
1306
zval * streamind ;
1309
1307
zend_long options = 0 ;
1310
1308
zend_string * seq , * folder ;
1311
- int argc = ZEND_NUM_ARGS ();
1312
1309
pils * imap_le_struct ;
1313
1310
1314
- if (zend_parse_parameters (argc , "rSS|l" , & streamind , & seq , & folder , & options ) == FAILURE ) {
1311
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "rSS|l" , & streamind , & seq , & folder , & options ) == FAILURE ) {
1315
1312
RETURN_THROWS ();
1316
1313
}
1317
1314
@@ -1324,7 +1321,7 @@ PHP_FUNCTION(imap_mail_copy)
1324
1321
RETURN_THROWS ();
1325
1322
}
1326
1323
1327
- if (mail_copy_full (imap_le_struct -> imap_stream , ZSTR_VAL (seq ), ZSTR_VAL (folder ), ( argc == 4 ? options : NIL ) ) == T ) {
1324
+ if (mail_copy_full (imap_le_struct -> imap_stream , ZSTR_VAL (seq ), ZSTR_VAL (folder ), options ) == T ) {
1328
1325
RETURN_TRUE ;
1329
1326
} else {
1330
1327
RETURN_FALSE ;
@@ -1339,9 +1336,8 @@ PHP_FUNCTION(imap_mail_move)
1339
1336
zend_string * seq , * folder ;
1340
1337
zend_long options = 0 ;
1341
1338
pils * imap_le_struct ;
1342
- int argc = ZEND_NUM_ARGS ();
1343
1339
1344
- if (zend_parse_parameters (argc , "rSS|l" , & streamind , & seq , & folder , & options ) == FAILURE ) {
1340
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "rSS|l" , & streamind , & seq , & folder , & options ) == FAILURE ) {
1345
1341
RETURN_THROWS ();
1346
1342
}
1347
1343
@@ -1354,7 +1350,10 @@ PHP_FUNCTION(imap_mail_move)
1354
1350
RETURN_THROWS ();
1355
1351
}
1356
1352
1357
- if (mail_copy_full (imap_le_struct -> imap_stream , ZSTR_VAL (seq ), ZSTR_VAL (folder ), (argc == 4 ? (options | CP_MOVE ) : CP_MOVE )) == T ) {
1353
+ /* Add CP_MOVE flag */
1354
+ options = (options | CP_MOVE );
1355
+
1356
+ if (mail_copy_full (imap_le_struct -> imap_stream , ZSTR_VAL (seq ), ZSTR_VAL (folder ), options ) == T ) {
1358
1357
RETURN_TRUE ;
1359
1358
} else {
1360
1359
RETURN_FALSE ;
@@ -1592,9 +1591,8 @@ PHP_FUNCTION(imap_delete)
1592
1591
pils * imap_le_struct ;
1593
1592
zend_string * sequence ;
1594
1593
zend_long flags = 0 ;
1595
- int argc = ZEND_NUM_ARGS ();
1596
1594
1597
- if (zend_parse_parameters (argc , "rS|l" , & streamind , & sequence , & flags ) == FAILURE ) {
1595
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "rS|l" , & streamind , & sequence , & flags ) == FAILURE ) {
1598
1596
RETURN_THROWS ();
1599
1597
}
1600
1598
@@ -1607,7 +1605,7 @@ PHP_FUNCTION(imap_delete)
1607
1605
RETURN_THROWS ();
1608
1606
}
1609
1607
1610
- mail_setflag_full (imap_le_struct -> imap_stream , ZSTR_VAL (sequence ), "\\DELETED" , ( argc == 3 ? flags : NIL ) );
1608
+ mail_setflag_full (imap_le_struct -> imap_stream , ZSTR_VAL (sequence ), "\\DELETED" , flags );
1611
1609
RETVAL_TRUE ;
1612
1610
}
1613
1611
/* }}} */
@@ -1619,9 +1617,8 @@ PHP_FUNCTION(imap_undelete)
1619
1617
zend_string * sequence ;
1620
1618
zend_long flags = 0 ;
1621
1619
pils * imap_le_struct ;
1622
- int argc = ZEND_NUM_ARGS ();
1623
1620
1624
- if (zend_parse_parameters (argc , "rS|l" , & streamind , & sequence , & flags ) == FAILURE ) {
1621
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "rS|l" , & streamind , & sequence , & flags ) == FAILURE ) {
1625
1622
RETURN_THROWS ();
1626
1623
}
1627
1624
@@ -1631,7 +1628,9 @@ PHP_FUNCTION(imap_undelete)
1631
1628
1632
1629
/* TODO Check if flags are valid (documentation is not present on php.net so need to check this first) */
1633
1630
1634
- mail_clearflag_full (imap_le_struct -> imap_stream , ZSTR_VAL (sequence ), "\\DELETED" , (argc == 3 ? flags : NIL ));
1631
+ mail_clearflag_full (imap_le_struct -> imap_stream , ZSTR_VAL (sequence ), "\\DELETED" , flags );
1632
+
1633
+ // TODO Return void?
1635
1634
RETVAL_TRUE ;
1636
1635
}
1637
1636
/* }}} */
@@ -1928,9 +1927,8 @@ PHP_FUNCTION(imap_fetchbody)
1928
1927
char * body ;
1929
1928
zend_string * sec ;
1930
1929
unsigned long len ;
1931
- int argc = ZEND_NUM_ARGS ();
1932
1930
1933
- if (zend_parse_parameters (argc , "rlS|l" , & streamind , & msgno , & sec , & flags ) == FAILURE ) {
1931
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "rlS|l" , & streamind , & msgno , & sec , & flags ) == FAILURE ) {
1934
1932
RETURN_THROWS ();
1935
1933
}
1936
1934
@@ -1953,7 +1951,7 @@ PHP_FUNCTION(imap_fetchbody)
1953
1951
PHP_IMAP_CHECK_MSGNO (msgno , 2 );
1954
1952
}
1955
1953
1956
- body = mail_fetchbody_full (imap_le_struct -> imap_stream , msgno , ZSTR_VAL (sec ), & len , ( argc == 4 ? flags : NIL ) );
1954
+ body = mail_fetchbody_full (imap_le_struct -> imap_stream , msgno , ZSTR_VAL (sec ), & len , flags );
1957
1955
1958
1956
if (!body ) {
1959
1957
php_error_docref (NULL , E_WARNING , "No body information available" );
@@ -1974,9 +1972,8 @@ PHP_FUNCTION(imap_fetchmime)
1974
1972
char * body ;
1975
1973
zend_string * sec ;
1976
1974
unsigned long len ;
1977
- int argc = ZEND_NUM_ARGS ();
1978
1975
1979
- if (zend_parse_parameters (argc , "rlS|l" , & streamind , & msgno , & sec , & flags ) == FAILURE ) {
1976
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "rlS|l" , & streamind , & msgno , & sec , & flags ) == FAILURE ) {
1980
1977
RETURN_THROWS ();
1981
1978
}
1982
1979
@@ -1999,7 +1996,7 @@ PHP_FUNCTION(imap_fetchmime)
1999
1996
PHP_IMAP_CHECK_MSGNO (msgno , 2 );
2000
1997
}
2001
1998
2002
- body = mail_fetch_mime (imap_le_struct -> imap_stream , msgno , ZSTR_VAL (sec ), & len , ( argc == 4 ? flags : NIL ) );
1999
+ body = mail_fetch_mime (imap_le_struct -> imap_stream , msgno , ZSTR_VAL (sec ), & len , flags );
2003
2000
2004
2001
if (!body ) {
2005
2002
php_error_docref (NULL , E_WARNING , "No body MIME information available" );
@@ -2673,9 +2670,8 @@ PHP_FUNCTION(imap_clearflag_full)
2673
2670
zend_string * sequence , * flag ;
2674
2671
zend_long flags = 0 ;
2675
2672
pils * imap_le_struct ;
2676
- int argc = ZEND_NUM_ARGS ();
2677
2673
2678
- if (zend_parse_parameters (argc , "rSS|l" , & streamind , & sequence , & flag , & flags ) == FAILURE ) {
2674
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "rSS|l" , & streamind , & sequence , & flag , & flags ) == FAILURE ) {
2679
2675
RETURN_THROWS ();
2680
2676
}
2681
2677
@@ -2688,7 +2684,7 @@ PHP_FUNCTION(imap_clearflag_full)
2688
2684
RETURN_THROWS ();
2689
2685
}
2690
2686
2691
- mail_clearflag_full (imap_le_struct -> imap_stream , ZSTR_VAL (sequence ), ZSTR_VAL (flag ), ( argc == 4 ? flags : NIL ) );
2687
+ mail_clearflag_full (imap_le_struct -> imap_stream , ZSTR_VAL (sequence ), ZSTR_VAL (flag ), flags );
2692
2688
RETURN_TRUE ;
2693
2689
}
2694
2690
/* }}} */
@@ -2739,7 +2735,7 @@ PHP_FUNCTION(imap_sort)
2739
2735
mypgm -> function = (short ) sort ;
2740
2736
mypgm -> next = NIL ;
2741
2737
2742
- slst = mail_sort (imap_le_struct -> imap_stream , (argc == 6 ? ZSTR_VAL (charset ) : NIL ), spg , mypgm , ( argc >= 4 ? flags : NIL ) );
2738
+ slst = mail_sort (imap_le_struct -> imap_stream , (argc == 6 ? ZSTR_VAL (charset ) : NIL ), spg , mypgm , flags );
2743
2739
2744
2740
if (spg && !(flags & SE_FREE )) {
2745
2741
mail_free_searchpgm (& spg );
0 commit comments