123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- #ifndef FTP_H
- #define FTP_H
- #include "php_network.h"
- #include <stdio.h>
- #ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
- #endif
- #define FTP_DEFAULT_TIMEOUT 90
- #define FTP_DEFAULT_AUTOSEEK 1
- #define FTP_DEFAULT_USEPASVADDRESS 1
- #define PHP_FTP_FAILED 0
- #define PHP_FTP_FINISHED 1
- #define PHP_FTP_MOREDATA 2
- #define FTP_BUFSIZE 4096
- typedef enum ftptype {
- FTPTYPE_ASCII=1,
- FTPTYPE_IMAGE
- } ftptype_t;
- typedef struct databuf
- {
- int listener;
- php_socket_t fd;
- ftptype_t type;
- char buf[FTP_BUFSIZE];
- #if HAVE_OPENSSL_EXT
- SSL *ssl_handle;
- int ssl_active;
- #endif
- } databuf_t;
- typedef struct ftpbuf
- {
- php_socket_t fd;
- php_sockaddr_storage localaddr;
- int resp;
- char inbuf[FTP_BUFSIZE];
- char *extra;
- int extralen;
- char outbuf[FTP_BUFSIZE];
- char *pwd;
- char *syst;
- ftptype_t type;
- int pasv;
- php_sockaddr_storage pasvaddr;
- long timeout_sec;
- int autoseek;
- int usepasvaddress;
- int nb;
- databuf_t *data;
- php_stream *stream;
- int lastch;
- int direction;
- int closestream;
- #if HAVE_OPENSSL_EXT
- int use_ssl;
- int use_ssl_for_data;
- int old_ssl;
- SSL *ssl_handle;
- int ssl_active;
- #endif
- } ftpbuf_t;
- ftpbuf_t* ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC);
- int ftp_quit(ftpbuf_t *ftp);
- void ftp_gc(ftpbuf_t *ftp);
- ftpbuf_t* ftp_close(ftpbuf_t *ftp);
- int ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC);
- int ftp_reinit(ftpbuf_t *ftp);
- const char* ftp_syst(ftpbuf_t *ftp);
- const char* ftp_pwd(ftpbuf_t *ftp);
- int ftp_exec(ftpbuf_t *ftp, const char *cmd);
- void ftp_raw(ftpbuf_t *ftp, const char *cmd, zval *return_value);
- int ftp_chdir(ftpbuf_t *ftp, const char *dir);
- int ftp_cdup(ftpbuf_t *ftp);
- char* ftp_mkdir(ftpbuf_t *ftp, const char *dir);
- int ftp_rmdir(ftpbuf_t *ftp, const char *dir);
- int ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filename_len);
- int ftp_alloc(ftpbuf_t *ftp, const long size, char **response);
- char** ftp_nlist(ftpbuf_t *ftp, const char *path TSRMLS_DC);
- char** ftp_list(ftpbuf_t *ftp, const char *path, int recursive TSRMLS_DC);
- int ftp_pasv(ftpbuf_t *ftp, int pasv);
- int ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC);
- int ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC);
- long ftp_size(ftpbuf_t *ftp, const char *path);
- time_t ftp_mdtm(ftpbuf_t *ftp, const char *path);
- int ftp_rename(ftpbuf_t *ftp, const char *src, const char *dest);
- int ftp_delete(ftpbuf_t *ftp, const char *path);
- int ftp_site(ftpbuf_t *ftp, const char *cmd);
- int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC);
- int ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC);
- int ftp_nb_continue_read(ftpbuf_t *ftp TSRMLS_DC);
- int ftp_nb_continue_write(ftpbuf_t *ftp TSRMLS_DC);
- #endif
|