X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fftp.h;h=a09f0f15cd0a70c99f408cfbf8d085a42708569f;hb=7690b174f121007c511f40d69c70d72e6953b5a9;hp=13cc415efb75727fd82369762bba15b74fd5df65;hpb=e0c59f7f4ddb73390dc9c16569254c0e2a921931;p=oftp diff --git a/src/ftp.h b/src/ftp.h index 13cc415..a09f0f1 100644 --- a/src/ftp.h +++ b/src/ftp.h @@ -1,17 +1,22 @@ #ifndef FTP_H_ #define FTP_H_ +#include + enum {FTP_DIR, FTP_FILE}; /* ftp_dirent type */ enum { + FTP_TYPE, FTP_PWD, FTP_CHDIR, + FTP_CDUP, FTP_MKDIR, FTP_RMDIR, FTP_DEL, FTP_LIST, FTP_RETR, - FTP_STORE + FTP_STORE, + FTP_XFER }; enum { @@ -21,13 +26,13 @@ enum { }; enum { - FTP_MOD_REMDIR = 0x100, - FTP_MOD_LOCDIR = 0x200 + FTP_MOD_DIR = 0x100 }; struct ftp_op { int op; char *arg; + void *data; struct ftp_op *next; }; @@ -36,8 +41,6 @@ struct ftp_dirent { char *name; int type; long size; - - struct ftp_dirent *next; }; struct ftp { @@ -46,6 +49,7 @@ struct ftp { int status, busy; char *user, *pass; + int passive; struct ftp_op *qhead, *qtail; @@ -57,13 +61,23 @@ struct ftp { int num_crecv; char drecv[256]; - char *curdir_rem, *curdir_loc; - struct ftp_dirent *dent_rem, *dent_loc; + char *curdir; + struct ftp_dirent *dirent; /* dynamic array */ int last_resp; int modified; }; +struct ftp_transfer { + int op; + char *rname; + FILE *fp; /* option: file */ + char *mem; /* option: darray */ + long total, count; + + void (*done)(struct ftp*, struct ftp_transfer*); +}; + struct ftp *ftp_alloc(void); void ftp_free(struct ftp *ftp); @@ -77,9 +91,11 @@ int ftp_sockets(struct ftp *ftp, int *sockv, int maxsize); int ftp_handle(struct ftp *ftp, int s); int ftp_queue(struct ftp *ftp, int op, const char *arg); -int ftp_waitresp(struct ftp *ftp, time_t timeout); +int ftp_queue_transfer(struct ftp *ftp, struct ftp_transfer *xfer); +int ftp_waitresp(struct ftp *ftp, long timeout); int ftp_update(struct ftp *ftp); +int ftp_type(struct ftp *ftp, const char *type); int ftp_pwd(struct ftp *ftp); int ftp_chdir(struct ftp *ftp, const char *dirname); int ftp_mkdir(struct ftp *ftp, const char *dirname); @@ -88,6 +104,12 @@ int ftp_delete(struct ftp *ftp, const char *fname); int ftp_list(struct ftp *ftp); int ftp_retrieve(struct ftp *ftp, const char *fname); int ftp_store(struct ftp *ftp, const char *fname); +int ftp_transfer(struct ftp *ftp, struct ftp_transfer *xfer); + +const char *ftp_curdir(struct ftp *ftp); +int ftp_num_dirent(struct ftp *ftp); +struct ftp_dirent *ftp_dirent(struct ftp *ftp, int idx); +int ftp_direntcmp(const void *a, const void *b); #endif /* FTP_H_ */