ftptype_t type; /* current transfer type */
int pasv; /* 0=off; 1=pasv; 2=ready */
php_sockaddr_storage pasvaddr; /* passive mode address */
- long timeout_sec; /* User configurable timeout (seconds) */
+ zend_long timeout_sec; /* User configurable timeout (seconds) */
int autoseek; /* User configurable autoseek flag */
+ int usepasvaddress; /* Use the address returned by the pasv command */
int nb; /* "nonblocking" transfer in progress */
databuf_t *data; /* Data connection for "nonblocking" transfers */
/* autoseek for resuming */
ftp->autoseek = FTP_DEFAULT_AUTOSEEK;
-#if HAVE_OPENSSL_EXT
+ ftp->usepasvaddress = FTP_DEFAULT_USEPASVADDRESS;
+#ifdef HAVE_FTP_SSL
/* disable ssl */
ftp->use_ssl = 0;
#endif
zend_zval_type_name(z_value));
RETURN_FALSE;
}
- ftp->autoseek = Z_LVAL_P(z_value);
+ ftp->autoseek = Z_TYPE_P(z_value) == IS_TRUE ? 1 : 0;
RETURN_TRUE;
break;
- if (Z_TYPE_P(z_value) != IS_BOOL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Option USEPASVADDRESS expects value of type boolean, %s given",
+ case PHP_FTP_OPT_USEPASVADDRESS:
- ftp->usepasvaddress = Z_LVAL_P(z_value);
++ if (Z_TYPE_P(z_value) != IS_TRUE && Z_TYPE_P(z_value) != IS_FALSE) {
++ php_error_docref(NULL, E_WARNING, "Option USEPASVADDRESS expects value of type boolean, %s given",
+ zend_zval_type_name(z_value));
+ RETURN_FALSE;
+ }
++ ftp->usepasvaddress = Z_TYPE_P(z_value) == IS_TRUE ? 1 : 0;
+ RETURN_TRUE;
+ break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option '%ld'", option);
+ php_error_docref(NULL, E_WARNING, "Unknown option '%pd'", option);
RETURN_FALSE;
break;
}
case PHP_FTP_OPT_AUTOSEEK:
RETURN_BOOL(ftp->autoseek);
break;
+ case PHP_FTP_OPT_USEPASVADDRESS:
+ RETURN_BOOL(ftp->usepasvaddress);
+ break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option '%ld'", option);
+ php_error_docref(NULL, E_WARNING, "Unknown option '%pd'", option);
RETURN_FALSE;
break;
}
extern zend_module_entry php_ftp_module_entry;
#define php_ftp_module_ptr &php_ftp_module_entry
+#include "php_version.h"
+#define PHP_FTP_VERSION PHP_VERSION
+
#define PHP_FTP_OPT_TIMEOUT_SEC 0
#define PHP_FTP_OPT_AUTOSEEK 1
+ #define PHP_FTP_OPT_USEPASVADDRESS 2
#define PHP_FTP_AUTORESUME -1
PHP_MINIT_FUNCTION(ftp);