/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ftp_client.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/11/01 15:50:56 by jhalford #+# #+# */ /* Updated: 2017/11/10 19:28:43 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FTP_CLIENT # define FTP_CLIENT # include "libft.h" # include # include # include # include # include # include # include # define FTP_CLIENT_USAGE "%s " # define ftp_cmd(ftp, ...) ftp_send((ftp)->cmd_sock, ##__VA_ARGS__) typedef struct s_cmd_map t_cmd_map; typedef struct s_ftp t_ftp; struct s_cmd_map { char *key; int (*f)(); char *help; }; enum e_dstate { DATA_NONE, DATA_PASV, DATA_ACTV, }; struct s_ftp { int cmd_sock; enum e_dstate data_state; union { struct sockaddr_in sin; int sock; } dconn; int d_sock; }; extern t_cmd_map g_cli_cmd[]; extern int g_debug; t_cmd_map *get_cmd(char *cmd); int ftp_msg(t_ftp *ftp, char **msg); int ftp_code(t_ftp *ftp); int ftp_send(int sock, char *msg, ...); int ftp_recv(int sock, char **msg); int ftp_recvraw(int sock, char **msg); int dconn_init(t_ftp *ftp); int dconn_open(t_ftp *ftp); int dconn_close(t_ftp *ftp); int console_msg(int level, char *str, ...); int cli_debug(t_ftp *ftp, char **av); int cli_user(t_ftp *ftp, char **av); int cli_ls(t_ftp *ftp, char **av); int cli_pwd(t_ftp *ftp, char **av); int cli_sh(t_ftp *ftp, char **av); int cli_get(t_ftp *ftp, char **av); int cli_put(t_ftp *ftp, char **av); int cli_cd(t_ftp *ftp, char **av); int cli_help(t_ftp *ftp, char **av); int cli_debug(t_ftp *ftp, char **av); int cli_local(t_ftp *ftp, char **av); int cli_rmd(t_ftp *ftp, char **av); int cli_mkd(t_ftp *ftp, char **av); int cli_pasv(t_ftp *ftp); #endif