summaryrefslogtreecommitdiff
path: root/ext/ftp/ftp.c
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2003-09-18 17:36:08 +0000
committerSara Golemon <pollita@php.net>2003-09-18 17:36:08 +0000
commitc553af47e06c434ea943d51a386c5f156ce34875 (patch)
treef0efa9faaf4208575dcc52b0606d5e58a24bf2db /ext/ftp/ftp.c
parent3efe102a4801a36f5515e8166c967ac595b4876e (diff)
downloadphp-git-c553af47e06c434ea943d51a386c5f156ce34875.tar.gz
Add ftp_alloc() for servers which require client to predeclare filesize to be sent.
Diffstat (limited to 'ext/ftp/ftp.c')
-rw-r--r--ext/ftp/ftp.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index 03425a2d36..152b678b6b 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -605,6 +605,38 @@ ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filenam
}
/* }}} */
+/* {{{ ftp_alloc
+ */
+int
+ftp_alloc(ftpbuf_t *ftp, const int size, char **response)
+{
+ char buffer[64];
+
+ if (ftp == NULL || size <= 0) {
+ return 0;
+ }
+
+ snprintf(buffer, 64, "%d", size);
+
+ if (!ftp_putcmd(ftp, "ALLO", buffer)) {
+ return 0;
+ }
+
+ if (!ftp_getresp(ftp)) {
+ return 0;
+ }
+
+ if (response && ftp->inbuf) {
+ *response = estrdup(ftp->inbuf);
+ }
+
+ if (ftp->resp < 200 || ftp->resp >= 300) {
+ return 0;
+ }
+
+ return 1;
+}
+/* }}} */
/* {{{ ftp_nlist
*/