]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #39362 (Added an option to imap_open/imap_reopen to control
authorIlia Alshanetsky <iliaa@php.net>
Sun, 5 Nov 2006 18:32:41 +0000 (18:32 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 5 Nov 2006 18:32:41 +0000 (18:32 +0000)
the number of connection retries).

ext/imap/php_imap.c

index bed1d0aed256b1c24c00b751f1f11fd8e14cdc1e..47adfd5b86f28846265aa109ae193412336f5f5c 100644 (file)
@@ -736,21 +736,21 @@ PHP_MINFO_FUNCTION(imap)
  */
 static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 {
-       zval **mailbox, **user, **passwd, **options;
+       zval **mailbox, **user, **passwd, **options, **retries;
        MAILSTREAM *imap_stream;
        pils *imap_le_struct;
        long flags=NIL;
        long cl_flags=NIL;
        int myargc = ZEND_NUM_ARGS();
        
-       if (myargc < 3 || myargc > 4 || zend_get_parameters_ex(myargc, &mailbox, &user, &passwd, &options) == FAILURE) {
+       if (myargc < 3 || myargc > 4 || zend_get_parameters_ex(myargc, &mailbox, &user, &passwd, &options, &retries) == FAILURE) {
                ZEND_WRONG_PARAM_COUNT();
        }
 
        convert_to_string_ex(mailbox);
        convert_to_string_ex(user);
        convert_to_string_ex(passwd);
-       if (myargc ==4) {
+       if (myargc >= 4) {
                convert_to_long_ex(options);
                flags = Z_LVAL_PP(options);
                if (flags & PHP_EXPUNGE) {
@@ -775,6 +775,13 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
        IMAPG(imap_user)     = estrndup(Z_STRVAL_PP(user), Z_STRLEN_PP(user));
        IMAPG(imap_password) = estrndup(Z_STRVAL_PP(passwd), Z_STRLEN_PP(passwd));
 
+#ifdef SET_MAXLOGINTRIALS
+       if (myargc == 5) {
+               convert_to_long_ex(retries);
+               mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) Z_LVAL_PP(retries));
+       }
+#endif
+
        imap_stream = mail_open(NIL, Z_STRVAL_PP(mailbox), flags);
 
        if (imap_stream == NIL) {
@@ -792,7 +799,7 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 }
 /* }}} */
 
-/* {{{ proto resource imap_open(string mailbox, string user, string password [, int options])
+/* {{{ proto resource imap_open(string mailbox, string user, string password [, int options [, int n_retries]])
    Open an IMAP stream to a mailbox */
 PHP_FUNCTION(imap_open)
 {
@@ -800,18 +807,18 @@ PHP_FUNCTION(imap_open)
 }
 /* }}} */
 
-/* {{{ proto bool imap_reopen(resource stream_id, string mailbox [, int options])
+/* {{{ proto bool imap_reopen(resource stream_id, string mailbox [, int options [, int n_retries]])
    Reopen an IMAP stream to a new mailbox */
 PHP_FUNCTION(imap_reopen)
 {
-       zval **streamind, **mailbox, **options;
+       zval **streamind, **mailbox, **options, **retries;
        pils *imap_le_struct; 
        MAILSTREAM *imap_stream;
        long flags=NIL;
        long cl_flags=NIL;
        int myargc=ZEND_NUM_ARGS();
 
-       if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &mailbox, &options) == FAILURE) {
+       if (myargc < 2 || myargc > 4 || zend_get_parameters_ex(myargc, &streamind, &mailbox, &options, &retries) == FAILURE) {
                ZEND_WRONG_PARAM_COUNT();
        }
 
@@ -819,7 +826,7 @@ PHP_FUNCTION(imap_reopen)
 
        convert_to_string_ex(mailbox);
 
-       if (myargc == 3) {
+       if (myargc >= 3) {
                convert_to_long_ex(options);
                flags = Z_LVAL_PP(options);
                if (flags & PHP_EXPUNGE) {
@@ -828,7 +835,12 @@ PHP_FUNCTION(imap_reopen)
                }
                imap_le_struct->flags = cl_flags;       
        }
-
+#ifdef SET_MAXLOGINTRIALS
+       if (myargc == 4) {
+               convert_to_long_ex(retries);
+               mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) Z_LVAL_PP(retries));
+       }
+#endif
        /* local filename, need to perform open_basedir checks */
        if (Z_STRVAL_PP(mailbox)[0] != '{' && php_check_open_basedir(Z_STRVAL_PP(mailbox) TSRMLS_CC)) {
                RETURN_FALSE;