#ifndef _FTPLIB
#define _FTPLIB 1

#ifndef GOT_WORDLIST
typedef struct WORDLIST {char *word; struct WORDLIST *next;} Wordlist ;
#define GOT_WORDLIST 1
#endif

typedef struct FTPLINK {
	Chan *cmd; 
	Chan *data;
	Chan *listen;
	char *host;
	char *user;
	char *pass;
	char *passive_host;
	int passive_port;
	int isblock;
	int xisascii;
	long bytes_in;
	int silent;
	int aborted_transfer;
	int print_hashes; /* Jesse added this one. True if printing hashs.*/
	int portok;
	int passive;
	int (*fn)(char *mode, int sz, int tag);
	int fntag;
	int tout; /* Timeout in milliseconds */
} Ftplink;
void ftp_set_nostore(int x);
int ftp_printf(Ftplink *l, char * arg_list, ...);
int ftp_result(Ftplink *l, int expected, int maxval, char *reason);
int ftp_set_callback(Ftplink *l, int cbtag, int fn(char *curmode, int sz, int tag));
int ftp_link_setascii(Ftplink *l, int t);

int ftp_isalive(Ftplink *l, char *reason);
int ftp_free(Ftplink **ff);
int ftp_setprint_responses(int x);
int ftp_getprint_responses(void);
int ftp_list_wordlist(Ftplink *l, char *fname, Chan *cdata, Wordlist **w, char *reason);
int ftp_link_list_wordlist(Ftplink *l, char *cmd, char *rmtname, Wordlist **w, char *reason);

int ftp_new(Ftplink **ff);
int ftp_link_set(Ftplink *l, char *host, char *user, char *pass);
int ftp_setup_port_link(Ftplink *l,char *reason);

char *ftp_portstr(char *bf,char *ip, int port);
int ftp_setunique(int x);
int ftp_response_keep(Chan *c, int expected, int maxval, char *bf);
int ftp_setnewer(char *s, int len);
int ftp_setappend(int x);
int ftp_setdebug(int x);
int ftp_mlsd(char *fname, char *host, char *user, char *pass, FILE *fout, char *reason);
void ftp_setrestart(int x);
int ftp_mlst(char *fname, char *host, char *user, char *pass, FILE *fout, char *reason);
int ftp_setssl(int x);

int ftp_mput_options(char *wild, int wild_len, char *dst, char *host, char *user, char *pass, char *reason, int use_passive, int (*progress_indicator_callback)(char *, int i, int j));

int ftp_setascii(int x);
int ftp_getascii(void);
int ftp_reset_port(Ftplink *l,char * reason);
char *ftp_related(char *fname,char *dst, char *tmp);
int ftp_link_list(Ftplink *l, char *cmd, char *rmtname, FILE *fout, char *reason);
int ftp_mget(char *wild, char *dst, char *host, char *user, char *pass, char *reason);
int ftp_open_link(Ftplink *l, char *reason);
int ftp_mget_link(Ftplink *l,char *wild,char *dst,char *reason);
int ftp_mput_link(Ftplink *l, char *wild,  int wild_len, char *dst, char *reason);
int ftp_get_link(Ftplink *l, char *fname, char *lclname, int start, char *reason);
int ftp_login_link(Ftplink *l, char *reason);
int ftp_link_build(Ftplink **l, char *host, char *user, char *pass, char *reason);
int ftp_mput(char *wild, int wild_len, char *dst, char *host, char *user, char *pass, char *reason);
int ftp_list_stream(char *fname, Chan *cdata, FILE *fout, char *reason);
int ftp_list(char *fname, char *host, char *user, char *pass, FILE *fout, char *reason);
int ftp_mput_file(Ftplink *l, Chan *c, Chan **listen, Chan **cdata, char *fname, char *rmtfile, int isblock, char *reason);
int ftp_response(Chan *c, int expected, int maxval, char *reason);
int ftp_login(Chan *c, char *to, char *user, char *pass, char *reason);
int ftp_setup_port(Chan *c,Chan **listen, char *reason) ;
int ftp_send_block(Ftplink *l,char *fname, Chan **cdata, char *reason);
int ftp_send_stream(Ftplink *l,char *fname,  Chan **cdata, char *reason);
int ftp_send(char *fname, char *rmtname, char *host, char *user, char *pass, char *reason);
int ftp_write_block(Chan *c, char *bf, int len, int iseof, char *reason);
int ftp_read_block(Chan *c, char *bf, int maxlen, int *ismore, char *reason);
int ftp_get_block(Ftplink *l, FILE *f, Chan *cdata, int isblock, char *reason, long *sz);
int ftp_init(int (*ximsg)(const char * arg_list, ...), int (*xemsg)(const char * arg_list, ...) );
int ftp_setblock(int x);
int ftp_get(char *fname, char *lclname, char *host, char *user, char *pass, int *sz, char *reason);
int ftp_link_build(Ftplink **l, char *host, char *user, char *pass, char *reason);
int ftp_send_link(Ftplink *l, char *fname, char *rmtname, char *reason);
int ftp_get_raw(char *fname, char *lclname, char *host, char *user, char *pass, int start, int *sz, char *reason);
int ftp_word_add(Wordlist **w, char *name);
int ftp_word_free(Wordlist **w);
int ftp_word_find(Wordlist *w, char *s);
int ftp_word_findnc(Wordlist *w, char *s);
int ftp_word_reverse(Wordlist **wlist);
int ftp_do_abort(Ftplink *l);
int ftp_getpwd(Ftplink *f, char *buffer, unsigned int bfsz, char *reason) ;
int ftp_decode(char *bf, char *fname, char *xdate, int *sz, int *isdir, int *islink);
int ftp_set_timeout(Ftplink *l, int msec); /* Set in milli seconds default 2 minutes */
int ftp_setabort(int t);
int ftp_isopen(Ftplink *l);
#endif
