Skip to content

Commit

Permalink
Issue #13: Initial framework for FTP REST
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Nilsson <[email protected]>
  • Loading branch information
troglobit committed May 24, 2018
1 parent 926b638 commit 58c8d7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ftpcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,21 @@ static void handle_RMD(ctrl_t *ctrl, char *arg)
}
#endif

static void handle_REST(ctrl_t *ctrl, char *arg)
{
const char *errstr;
char buf[80];

if (!string_valid(arg)) {
send_msg(ctrl->sd, "550 Invalid argument.\r\n");
return;
}

ctrl->offset = strtonum(arg, 0, INT64_MAX, &errstr);
snprintf(buf, sizeof(buf), "350 Restarting at %ld. Send STOR or RETR to continue transfer.\r\n", ctrl->offset);
send_msg(ctrl->sd, buf);
}

static size_t num_nl(char *file)
{
FILE *fp;
Expand Down Expand Up @@ -987,6 +1002,7 @@ static void handle_FEAT(ctrl_t *ctrl, char *arg)
" PASV\r\n"
" SIZE\r\n"
" UTF8\r\n"
" REST STREAM\r\n"
" MLST modify*;perm*;size*;type*;\r\n"
"211 End\r\n");
send_msg(ctrl->sd, ctrl->buf);
Expand All @@ -1010,6 +1026,7 @@ static ftp_cmd_t supported[] = {
COMMAND(PORT),
COMMAND(EPRT),
COMMAND(RETR),
COMMAND(REST),
COMMAND(MDTM),
COMMAND(PASV),
COMMAND(EPSV),
Expand Down
1 change: 1 addition & 0 deletions uftpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ typedef struct {

/* TFTP */
char *file; /* Current file name to fetch */
off_t offset; /* Offset in current file, for REST */
FILE *fp; /* Current file in operation */
tftp_t *th; /* Same as buf, only as tftp_t */
size_t segsize; /* SEGSIZE, or per session negotiated */
Expand Down

0 comments on commit 58c8d7a

Please sign in to comment.