]> granicus.if.org Git - php/commitdiff
ported ext/ftp
authorAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 19:49:34 +0000 (21:49 +0200)
committerAnatol Belski <ab@php.net>
Tue, 19 Aug 2014 19:49:34 +0000 (21:49 +0200)
ext/ftp/ftp.c
ext/ftp/ftp.h
ext/ftp/php_ftp.c

index 30f8e1d1bbdb2d66bd1272ee811fcd46879bf664..330f6f09e083d093bee9296b043c07d000a2be3d 100644 (file)
@@ -121,7 +121,7 @@ union ipbox {
 /* {{{ ftp_open
  */
 ftpbuf_t*
-ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC)
+ftp_open(const char *host, short port, php_int_t timeout_sec TSRMLS_DC)
 {
        ftpbuf_t                *ftp;
        socklen_t                size;
@@ -248,7 +248,7 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
 {
 #if HAVE_OPENSSL_EXT
        SSL_CTX *ctx = NULL;
-       long ssl_ctx_options = SSL_OP_ALL;
+       php_int_t ssl_ctx_options = SSL_OP_ALL;
 #endif
        if (ftp == NULL) {
                return 0;
@@ -616,7 +616,7 @@ ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filenam
 /* {{{ ftp_alloc
  */
 int
-ftp_alloc(ftpbuf_t *ftp, const long size, zend_string **response)
+ftp_alloc(ftpbuf_t *ftp, const php_int_t size, zend_string **response)
 {
        char buffer[64];
 
@@ -791,7 +791,7 @@ ftp_pasv(ftpbuf_t *ftp, int pasv)
 /* {{{ ftp_get
  */
 int
-ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC)
+ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, php_int_t resumepos TSRMLS_DC)
 {
        databuf_t               *data = NULL;
        size_t                  rcvd;
@@ -883,10 +883,10 @@ bail:
 /* {{{ ftp_put
  */
 int
-ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC)
+ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, php_int_t startpos TSRMLS_DC)
 {
        databuf_t               *data = NULL;
-       long                    size;
+       php_int_t                       size;
        char                    *ptr;
        int                     ch;
        char                    arg[11];
@@ -960,7 +960,7 @@ bail:
 
 /* {{{ ftp_size
  */
-long
+php_int_t
 ftp_size(ftpbuf_t *ftp, const char *path)
 {
        if (ftp == NULL) {
@@ -1227,7 +1227,7 @@ ftp_getresp(ftpbuf_t *ftp)
 int
 my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
 {
-       long            size, sent;
+       php_int_t               size, sent;
     int         n;
 
        size = len;
@@ -1493,7 +1493,7 @@ data_accept(databuf_t *data, ftpbuf_t *ftp TSRMLS_DC)
 
 #if HAVE_OPENSSL_EXT
        SSL_CTX         *ctx;
-       long ssl_ctx_options = SSL_OP_ALL;
+       php_int_t ssl_ctx_options = SSL_OP_ALL;
 #endif
 
        if (data->fd != -1) {
@@ -1711,7 +1711,7 @@ bail:
 /* {{{ ftp_nb_get
  */
 int
-ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC)
+ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, php_int_t resumepos TSRMLS_DC)
 {
        databuf_t               *data = NULL;
        char                    arg[11];
@@ -1828,7 +1828,7 @@ bail:
 /* {{{ ftp_nb_put
  */
 int
-ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC)
+ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, php_int_t startpos TSRMLS_DC)
 {
        databuf_t               *data = NULL;
        char                    arg[11];
index 6b2b1ae1922e47e4e12f04e6766289f2be4831e6..9891a14e55ec22f0351fd6aa828df32a19f885ff 100644 (file)
@@ -69,7 +69,7 @@ typedef struct ftpbuf
        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 configureable timeout (seconds) */
+       php_int_t       timeout_sec;    /* User configureable timeout (seconds) */
        int                     autoseek;       /* User configureable autoseek flag */
 
        int                             nb;             /* "nonblocking" transfer in progress */
@@ -93,7 +93,7 @@ typedef struct ftpbuf
 /* open a FTP connection, returns ftpbuf (NULL on error)
  * port is the ftp port in network byte order, or 0 for the default
  */
-ftpbuf_t*      ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC);
+ftpbuf_t*      ftp_open(const char *host, short port, php_int_t timeout_sec TSRMLS_DC);
 
 /* quits from the ftp session (it still needs to be closed)
  * return true on success, false on error
@@ -146,7 +146,7 @@ int         ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int fi
  * however some servers will not accept STOR or APPE until ALLO is confirmed. 
  * If response is passed, it is estrdup()ed from ftp->inbuf and must be freed
  * or assigned to a zval returned to the user */
-int            ftp_alloc(ftpbuf_t *ftp, const long size, zend_string **response);
+int            ftp_alloc(ftpbuf_t *ftp, const php_int_t size, zend_string **response);
 
 /* returns a NULL-terminated array of filenames in the given path
  * or NULL on error.  the return array must be freed (but don't
@@ -169,15 +169,15 @@ int               ftp_pasv(ftpbuf_t *ftp, int pasv);
 /* retrieves a file and saves its contents to outfp
  * returns true on success, false on error
  */
-int            ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC);
+int            ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, php_int_t resumepos TSRMLS_DC);
 
 /* stores the data from a file, socket, or process as a file on the remote server
  * returns true on success, false on error
  */
-int            ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC);
+int            ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, php_int_t startpos TSRMLS_DC);
 
 /* returns the size of the given file, or -1 on error */
-long           ftp_size(ftpbuf_t *ftp, const char *path);
+php_int_t              ftp_size(ftpbuf_t *ftp, const char *path);
 
 /* returns the last modified time of the given file, or -1 on error */
 time_t         ftp_mdtm(ftpbuf_t *ftp, const char *path);
@@ -194,12 +194,12 @@ int               ftp_site(ftpbuf_t *ftp, const char *cmd);
 /* retrieves part of a file and saves its contents to outfp
  * returns true on success, false on error
  */
-int            ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC);
+int            ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, php_int_t resumepos TSRMLS_DC);
 
 /* stores the data from a file, socket, or process as a file on the remote server
  * returns true on success, false on error
  */
-int            ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC);
+int            ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, php_int_t startpos TSRMLS_DC);
 
 /* continues a previous nb_(f)get command
  */
index c247c96dd281232f4dda8cf7f573aa12e471ff15..cb4cd37a004ef5203ea33a5c2cc3fd89d4d1d78b 100644 (file)
@@ -344,10 +344,10 @@ PHP_FUNCTION(ftp_connect)
        ftpbuf_t        *ftp;
        char            *host;
        int             host_len;
-       long            port = 0;
-       long            timeout_sec = FTP_DEFAULT_TIMEOUT;
+       php_int_t               port = 0;
+       php_int_t               timeout_sec = FTP_DEFAULT_TIMEOUT;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &host, &host_len, &port, &timeout_sec) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ii", &host, &host_len, &port, &timeout_sec) == FAILURE) {
                return;
        }
 
@@ -380,10 +380,10 @@ PHP_FUNCTION(ftp_ssl_connect)
        ftpbuf_t        *ftp;
        char            *host;
        int             host_len;
-       long            port = 0;
-       long            timeout_sec = FTP_DEFAULT_TIMEOUT;
+       php_int_t               port = 0;
+       php_int_t               timeout_sec = FTP_DEFAULT_TIMEOUT;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &host, &host_len, &port, &timeout_sec) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ii", &host, &host_len, &port, &timeout_sec) == FAILURE) {
                return;
        }
 
@@ -606,9 +606,9 @@ PHP_FUNCTION(ftp_chmod)
        ftpbuf_t        *ftp;
        char            *filename;
        int             filename_len;
-       long            mode;
+       php_int_t               mode;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlp", &z_ftp, &mode, &filename, &filename_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rip", &z_ftp, &mode, &filename, &filename_len) == FAILURE) {
                RETURN_FALSE;
        }
 
@@ -629,10 +629,10 @@ PHP_FUNCTION(ftp_alloc)
 {
        zval            *z_ftp, *zresponse = NULL;
        ftpbuf_t        *ftp;
-       long            size, ret;
+       php_int_t               size, ret;
        zend_string     *response = NULL;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &z_ftp, &size, &zresponse) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri|z/", &z_ftp, &size, &zresponse) == FAILURE) {
                RETURN_FALSE;
        }
 
@@ -742,9 +742,9 @@ PHP_FUNCTION(ftp_fget)
        php_stream      *stream;
        char            *file;
        int             file_len;
-       long            mode, resumepos=0;
+       php_int_t               mode, resumepos=0;
 
-       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, "rrsi|i", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
                return;
        }
 
@@ -786,9 +786,9 @@ PHP_FUNCTION(ftp_nb_fget)
        php_stream      *stream;
        char            *file;
        int             file_len;
-       long            mode, resumepos=0, ret;
+       php_int_t               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, "rrsi|i", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
                return;
        }
 
@@ -856,9 +856,9 @@ PHP_FUNCTION(ftp_get)
        php_stream      *outstream;
        char            *local, *remote;
        int             local_len, remote_len;
-       long            mode, resumepos=0;
+       php_int_t               mode, resumepos=0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppi|i", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) {
                return;
        }
 
@@ -919,9 +919,9 @@ PHP_FUNCTION(ftp_nb_get)
        php_stream      *outstream;
        char            *local, *remote;
        int             local_len, remote_len, ret;
-       long            mode, resumepos=0;
+       php_int_t               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, "rssi|i", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) {
                return;
        }
 
@@ -985,7 +985,7 @@ PHP_FUNCTION(ftp_nb_continue)
 {
        zval            *z_ftp;
        ftpbuf_t        *ftp;
-       long            ret;
+       php_int_t               ret;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_ftp) == FAILURE) {
                return;
@@ -1025,11 +1025,11 @@ PHP_FUNCTION(ftp_fput)
        ftpbuf_t        *ftp;
        ftptype_t       xtype;
        int             remote_len;
-       long            mode, startpos=0;
+       php_int_t               mode, startpos=0;
        php_stream      *stream;
        char            *remote;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsrl|l", &z_ftp, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsri|i", &z_ftp, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) {
                return;
        }
 
@@ -1072,11 +1072,11 @@ PHP_FUNCTION(ftp_nb_fput)
        ftpbuf_t        *ftp;
        ftptype_t       xtype;
        int             remote_len, ret;
-       long            mode, startpos=0;
+       php_int_t               mode, startpos=0;
        php_stream      *stream;
        char            *remote;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsrl|l", &z_ftp, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsri|i", &z_ftp, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) {
                return;
        }
 
@@ -1124,11 +1124,11 @@ PHP_FUNCTION(ftp_put)
        ftpbuf_t        *ftp;
        ftptype_t       xtype;
        char            *remote, *local;
-       long            remote_len, local_len;
-       long            mode, startpos=0;
+       php_int_t               remote_len, local_len;
+       php_int_t               mode, startpos=0;
        php_stream      *instream;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppi|i", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {
                return;
        }
 
@@ -1178,10 +1178,10 @@ PHP_FUNCTION(ftp_nb_put)
        ftptype_t       xtype;
        char            *remote, *local;
        int             remote_len, local_len;
-       long            mode, startpos=0, ret;
+       php_int_t               mode, startpos=0, ret;
        php_stream      *instream;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppi|i", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) {
                return;
        }
 
@@ -1368,10 +1368,10 @@ PHP_FUNCTION(ftp_close)
 PHP_FUNCTION(ftp_set_option)
 {
        zval            *z_ftp, *z_value;
-       long            option;
+       php_int_t               option;
        ftpbuf_t        *ftp;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &z_ftp, &option, &z_value) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "riz", &z_ftp, &option, &z_value) == FAILURE) {
                return;
        }
 
@@ -1413,10 +1413,10 @@ PHP_FUNCTION(ftp_set_option)
 PHP_FUNCTION(ftp_get_option)
 {
        zval            *z_ftp;
-       long            option;
+       php_int_t               option;
        ftpbuf_t        *ftp;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &z_ftp, &option) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", &z_ftp, &option) == FAILURE) {
                return;
        }