Diff for /embedaddon/php/ext/ftp/php_ftp.c between versions 1.1 and 1.1.1.4

version 1.1, 2012/02/21 23:47:56 version 1.1.1.4, 2013/10/14 08:02:19
Line 2 Line 2
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | PHP Version 5                                                        |     | PHP Version 5                                                        |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
   | Copyright (c) 1997-2012 The PHP Group                                |   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |     | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |     | that is bundled with this package in the file LICENSE, and is        |
Line 41 Line 41
 #include "php_ftp.h"  #include "php_ftp.h"
 #include "ftp.h"  #include "ftp.h"
   
static int      le_ftpbuf;static int le_ftpbuf;
 #define le_ftpbuf_name "FTP Buffer"  #define le_ftpbuf_name "FTP Buffer"
   
 /* {{{ arginfo */  /* {{{ arginfo */
Line 607  PHP_FUNCTION(ftp_chmod) Line 607  PHP_FUNCTION(ftp_chmod)
         int             filename_len;          int             filename_len;
         long            mode;          long            mode;
   
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rls", &z_ftp, &mode, &filename, &filename_len) == FAILURE) {        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlp", &z_ftp, &mode, &filename, &filename_len) == FAILURE) {
                 RETURN_FALSE;                  RETURN_FALSE;
         }          }
   
Line 660  PHP_FUNCTION(ftp_nlist) Line 660  PHP_FUNCTION(ftp_nlist)
         char            **nlist, **ptr, *dir;          char            **nlist, **ptr, *dir;
         int             dir_len;          int             dir_len;
   
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &dir, &dir_len) == FAILURE) {        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &z_ftp, &dir, &dir_len) == FAILURE) {
                 return;                  return;
         }          }
   
Line 784  PHP_FUNCTION(ftp_nb_fget) Line 784  PHP_FUNCTION(ftp_nb_fget)
         ftptype_t       xtype;          ftptype_t       xtype;
         php_stream      *stream;          php_stream      *stream;
         char            *file;          char            *file;
        int             file_len, ret;        int             file_len;
        long            mode, resumepos=0;        long            mode, resumepos=0, ret;
   
         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrsl|l", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {          if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrsl|l", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
                 return;                  return;
Line 857  PHP_FUNCTION(ftp_get) Line 857  PHP_FUNCTION(ftp_get)
         int             local_len, remote_len;          int             local_len, remote_len;
         long            mode, resumepos=0;          long            mode, resumepos=0;
   
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssl|l", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) {        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) {
                 return;                  return;
         }          }
   
Line 874  PHP_FUNCTION(ftp_get) Line 874  PHP_FUNCTION(ftp_get)
 #endif  #endif
   
         if (ftp->autoseek && resumepos) {          if (ftp->autoseek && resumepos) {
                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", REPORT_ERRORS, NULL);
                 if (outstream == NULL) {                  if (outstream == NULL) {
                        outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);                        outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", REPORT_ERRORS, NULL);
                 }                  }
                 if (outstream != NULL) {                  if (outstream != NULL) {
                         /* if autoresume is wanted seek to end */                          /* if autoresume is wanted seek to end */
Line 888  PHP_FUNCTION(ftp_get) Line 888  PHP_FUNCTION(ftp_get)
                         }                          }
                 }                  }
         } else {          } else {
                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", REPORT_ERRORS, NULL);
         }          }
   
         if (outstream == NULL)  {          if (outstream == NULL)  {
Line 935  PHP_FUNCTION(ftp_nb_get) Line 935  PHP_FUNCTION(ftp_nb_get)
         mode = FTPTYPE_IMAGE;          mode = FTPTYPE_IMAGE;
 #endif  #endif
         if (ftp->autoseek && resumepos) {          if (ftp->autoseek && resumepos) {
                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", REPORT_ERRORS, NULL);
                 if (outstream == NULL) {                  if (outstream == NULL) {
                        outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);                        outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", REPORT_ERRORS, NULL);
                 }                  }
                 if (outstream != NULL) {                  if (outstream != NULL) {
                         /* if autoresume is wanted seek to end */                          /* if autoresume is wanted seek to end */
Line 949  PHP_FUNCTION(ftp_nb_get) Line 949  PHP_FUNCTION(ftp_nb_get)
                         }                          }
                 }                  }
         } else {          } else {
                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);                outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", REPORT_ERRORS, NULL);
         }          }
   
         if (outstream == NULL)  {          if (outstream == NULL)  {
Line 968  PHP_FUNCTION(ftp_nb_get) Line 968  PHP_FUNCTION(ftp_nb_get)
                 RETURN_LONG(PHP_FTP_FAILED);                  RETURN_LONG(PHP_FTP_FAILED);
         }          }
   
        if (ret == PHP_FTP_FINISHED) {        php_stream_close(outstream);
                php_stream_close(outstream); 
        } 
   
         RETURN_LONG(ret);          RETURN_LONG(ret);
 }  }
Line 982  PHP_FUNCTION(ftp_nb_continue) Line 980  PHP_FUNCTION(ftp_nb_continue)
 {  {
         zval            *z_ftp;          zval            *z_ftp;
         ftpbuf_t        *ftp;          ftpbuf_t        *ftp;
        int                ret;        long                ret;
   
         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_ftp) == FAILURE) {          if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_ftp) == FAILURE) {
                 return;                  return;
Line 1120  PHP_FUNCTION(ftp_put) Line 1118  PHP_FUNCTION(ftp_put)
         ftpbuf_t        *ftp;          ftpbuf_t        *ftp;
         ftptype_t       xtype;          ftptype_t       xtype;
         char            *remote, *local;          char            *remote, *local;
        int                remote_len, local_len;        long                remote_len, local_len;
         long            mode, startpos=0;          long            mode, startpos=0;
         php_stream      *instream;          php_stream      *instream;
   
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {
                 return;                  return;
         }          }
   
         ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);          ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
         XTYPE(xtype, mode);          XTYPE(xtype, mode);
   
        if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {        if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", REPORT_ERRORS, NULL))) {
                 RETURN_FALSE;                  RETURN_FALSE;
         }          }
   
Line 1173  PHP_FUNCTION(ftp_nb_put) Line 1171  PHP_FUNCTION(ftp_nb_put)
         ftpbuf_t        *ftp;          ftpbuf_t        *ftp;
         ftptype_t       xtype;          ftptype_t       xtype;
         char            *remote, *local;          char            *remote, *local;
        int             remote_len, local_len, ret;        int             remote_len, local_len;
        long            mode, startpos=0;        long            mode, startpos=0, ret;
         php_stream      *instream;          php_stream      *instream;
   
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {
                 return;                  return;
         }          }
   
         ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);          ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
         XTYPE(xtype, mode);          XTYPE(xtype, mode);
   
        if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {        if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", REPORT_ERRORS, NULL))) {
                 RETURN_FALSE;                  RETURN_FALSE;
         }          }
   
Line 1233  PHP_FUNCTION(ftp_size) Line 1231  PHP_FUNCTION(ftp_size)
         char            *file;          char            *file;
         int             file_len;          int             file_len;
   
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &file, &file_len) == FAILURE) {        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &z_ftp, &file, &file_len) == FAILURE) {
                 return;                  return;
         }          }
   
Line 1253  PHP_FUNCTION(ftp_mdtm) Line 1251  PHP_FUNCTION(ftp_mdtm)
         char            *file;          char            *file;
         int             file_len;          int             file_len;
   
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &file, &file_len) == FAILURE) {        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &z_ftp, &file, &file_len) == FAILURE) {
                 return;                  return;
         }          }
   

Removed from v.1.1  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>