diff options
author | Sara Golemon <pollita@php.net> | 2003-09-18 17:36:08 +0000 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2003-09-18 17:36:08 +0000 |
commit | c553af47e06c434ea943d51a386c5f156ce34875 (patch) | |
tree | f0efa9faaf4208575dcc52b0606d5e58a24bf2db /ext/ftp/php_ftp.c | |
parent | 3efe102a4801a36f5515e8166c967ac595b4876e (diff) | |
download | php-git-c553af47e06c434ea943d51a386c5f156ce34875.tar.gz |
Add ftp_alloc() for servers which require client to predeclare filesize to be sent.
Diffstat (limited to 'ext/ftp/php_ftp.c')
-rw-r--r-- | ext/ftp/php_ftp.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 0d0d7e0ae9..e6a496a2ce 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -50,6 +50,13 @@ static int le_ftpbuf; #define le_ftpbuf_name "FTP Buffer" +static + ZEND_BEGIN_ARG_INFO(third_and_rest_force_ref, 1) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(1) + ZEND_END_ARG_INFO() + function_entry php_ftp_functions[] = { PHP_FE(ftp_connect, NULL) #ifdef HAVE_OPENSSL_EXT @@ -64,6 +71,7 @@ function_entry php_ftp_functions[] = { PHP_FE(ftp_mkdir, NULL) PHP_FE(ftp_rmdir, NULL) PHP_FE(ftp_chmod, NULL) + PHP_FE(ftp_alloc, third_and_rest_force_ref) PHP_FE(ftp_nlist, NULL) PHP_FE(ftp_rawlist, NULL) PHP_FE(ftp_systype, NULL) @@ -430,6 +438,35 @@ PHP_FUNCTION(ftp_chmod) } /* }}} */ +/* {{{ proto bool ftp_alloc(resource stream, int size[, &response]) + Attempt to allocate space on the remote FTP server */ +PHP_FUNCTION(ftp_alloc) +{ + zval *z_ftp, *zresponse = NULL; + ftpbuf_t *ftp; + int size, ret; + char *response = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &z_ftp, &size, &zresponse) == FAILURE) { + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); + + ret = ftp_alloc(ftp, size, zresponse ? &response : NULL); + if (response) { + zval_dtor(zresponse); + ZVAL_STRING(zresponse, response, 0); + } + + if (!ret) { + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + /* {{{ proto array ftp_nlist(resource stream, string directory) Returns an array of filenames in the given directory */ PHP_FUNCTION(ftp_nlist) |