DELE done, RMD and MKD look ok also

This commit is contained in:
Jack Halford 2017-11-10 19:49:11 +01:00
parent 1b3b422b31
commit fe67dfe17e
11 changed files with 63 additions and 14 deletions

View file

@ -33,6 +33,7 @@ OBJ_DIR = objs/
SRC_BASE = \ SRC_BASE = \
client/cli_cd.c\ client/cli_cd.c\
client/cli_debug.c\ client/cli_debug.c\
client/cli_dele.c\
client/cli_get.c\ client/cli_get.c\
client/cli_help.c\ client/cli_help.c\
client/cli_ls.c\ client/cli_ls.c\
@ -47,6 +48,7 @@ client/console_msg.c\
client/crlf.c\ client/crlf.c\
client/dconn.c\ client/dconn.c\
server/cmd_cwd.c\ server/cmd_cwd.c\
server/cmd_dele.c\
server/cmd_list.c\ server/cmd_list.c\
server/cmd_mkd.c\ server/cmd_mkd.c\
server/cmd_pasv.c\ server/cmd_pasv.c\

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/01 15:50:56 by jhalford #+# #+# */ /* Created: 2017/11/01 15:50:56 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:28:43 by jhalford ### ########.fr */ /* Updated: 2017/11/10 19:46:45 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -83,6 +83,7 @@ int cli_debug(t_ftp *ftp, char **av);
int cli_local(t_ftp *ftp, char **av); int cli_local(t_ftp *ftp, char **av);
int cli_rmd(t_ftp *ftp, char **av); int cli_rmd(t_ftp *ftp, char **av);
int cli_mkd(t_ftp *ftp, char **av); int cli_mkd(t_ftp *ftp, char **av);
int cli_dele(t_ftp *ftp, char **av);
int cli_pasv(t_ftp *ftp); int cli_pasv(t_ftp *ftp);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/01 15:56:59 by jhalford #+# #+# */ /* Created: 2017/11/01 15:56:59 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:21:00 by jhalford ### ########.fr */ /* Updated: 2017/11/10 19:39:47 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -89,5 +89,6 @@ int cmd_mkd(t_ftp *ftp, char **av);
int cmd_mkd(t_ftp *ftp, char **av); int cmd_mkd(t_ftp *ftp, char **av);
int cmd_mkd(t_ftp *ftp, char **av); int cmd_mkd(t_ftp *ftp, char **av);
int cmd_rmd(t_ftp *ftp, char **av); int cmd_rmd(t_ftp *ftp, char **av);
int cmd_dele(t_ftp *ftp, char **av);
#endif #endif

View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cli_dele.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 19:41:33 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:41:33 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ftp_client.h"
int cli_dele(t_ftp *ftp, char **av)
{
if (!av[1] || av[2])
return (console_msg(-1, "usage: unlink <directory>"));
ftp_cmd(ftp, "DELE %s", av[1]);
ftp_code(ftp);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 19:27:35 by jhalford #+# #+# */ /* Created: 2017/11/10 19:27:35 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:34:49 by jhalford ### ########.fr */ /* Updated: 2017/11/10 19:40:44 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 19:24:11 by jhalford #+# #+# */ /* Created: 2017/11/10 19:24:11 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:27:20 by jhalford ### ########.fr */ /* Updated: 2017/11/10 19:36:59 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/02 19:18:31 by jhalford #+# #+# */ /* Created: 2017/04/02 19:18:31 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:28:27 by jhalford ### ########.fr */ /* Updated: 2017/11/10 19:42:00 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,6 +22,7 @@ t_cmd_map g_cli_cmd[] =
{"pwd", cli_pwd, "print working directory on remote machine"}, {"pwd", cli_pwd, "print working directory on remote machine"},
{"mkdir", cli_mkd, "create a directory on remote machine"}, {"mkdir", cli_mkd, "create a directory on remote machine"},
{"rmdir", cli_rmd, "remove a directory from remote machine"}, {"rmdir", cli_rmd, "remove a directory from remote machine"},
{"unlink", cli_dele, "remove a file from remote machine"},
{"quit", NULL, "terminate ftp session and exit"}, {"quit", NULL, "terminate ftp session and exit"},
{"?", cli_help, "print local help information"}, {"?", cli_help, "print local help information"},

View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmd_dele.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 19:38:40 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:39:34 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "ftp_server.h"
int cmd_dele(t_ftp *ftp, char **av)
{
(void)av;
if (unlink(av[1]) < 0)
return (ftp_ret(ftp, "550 unlink error"));
else
return (ftp_ret(ftp, "250 file '%s' deleted", av[1]));
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 19:17:53 by jhalford #+# #+# */ /* Created: 2017/11/10 19:17:53 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:35:39 by jhalford ### ########.fr */ /* Updated: 2017/11/10 19:47:06 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,10 +14,7 @@
int cmd_mkd(t_ftp *ftp, char **av) int cmd_mkd(t_ftp *ftp, char **av)
{ {
(void)av;
if (mkdir(av[1], 0755) < 0) if (mkdir(av[1], 0755) < 0)
return (ftp_ret(ftp, "550 mkdir() error")); return (ftp_ret(ftp, "550 mkdir() error"));
else
return (ftp_ret(ftp, "257 '%s' created", av[1])); return (ftp_ret(ftp, "257 '%s' created", av[1]));
return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 19:21:10 by jhalford #+# #+# */ /* Created: 2017/11/10 19:21:10 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:26:29 by jhalford ### ########.fr */ /* Updated: 2017/11/10 19:48:53 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,6 +14,7 @@
int cmd_rmd(t_ftp *ftp, char **av) int cmd_rmd(t_ftp *ftp, char **av)
{ {
(void)av; if (remove(av[1]) < 0)
return (ftp_ret(ftp, "503 not implemented")); return (ftp_ret(ftp, "550 remove(3) error"));
return (ftp_ret(ftp, "257 '%s' deleted", av[1]));
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/02 15:02:48 by jhalford #+# #+# */ /* Created: 2017/04/02 15:02:48 by jhalford #+# #+# */
/* Updated: 2017/11/10 19:23:13 by jhalford ### ########.fr */ /* Updated: 2017/11/10 19:40:37 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -31,6 +31,7 @@ t_ftp_cmd g_ftp_cmd[] =
{"LIST", cmd_list, LOG_YES}, {"LIST", cmd_list, LOG_YES},
{"MKD", cmd_mkd, LOG_YES}, {"MKD", cmd_mkd, LOG_YES},
{"RMD", cmd_rmd, LOG_YES}, {"RMD", cmd_rmd, LOG_YES},
{"DELE", cmd_dele, LOG_YES},
{0, 0, 0}, {0, 0, 0},
}; };
int g_debug = 2; int g_debug = 2;