1 /*
2 * h_rnfr.c
3 *
4 * (C)1998-2011 by Marc Huber <Marc.Huber@web.de>
5 * All rights reserved.
6 *
7 * $Id: h_rnfr.c,v 1.10 2015/03/14 06:11:26 marc Exp marc $
8 *
9 */
10
11 #include "headers.h"
12
13 static const char rcsid[] __attribute__ ((used)) = "$Id: h_rnfr.c,v 1.10 2015/03/14 06:11:26 marc Exp marc $";
14
h_rnfr(struct context * ctx,char * arg)15 void h_rnfr(struct context *ctx, char *arg)
16 {
17 char *t;
18 struct stat st;
19
20 DebugIn(DEBUG_COMMAND);
21
22 if ((t = buildpath(ctx, arg)) && (strlen(t) > ctx->rootlen) && (!pickystat(ctx, &st, t)) && (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))) {
23 ctx->last_command_was_rnfr = 1;
24
25 if (strlen(t) >= sizeof(ctx->filename)) {
26 logerr("buffer too small in %s:%d (%s/%s)", __FILE__, __LINE__, ctx->user, t);
27 reply(ctx, MSG_551_Internal_error);
28 cleanup_data(ctx, ctx->dfn);
29 DebugOut(DEBUG_COMMAND);
30 return;
31 }
32 strcpy(ctx->filename, t);
33 reply(ctx, MSG_350_Awaiting_dest);
34 } else
35 reply(ctx, MSG_550_No_such_file);
36
37 DebugOut(DEBUG_COMMAND);
38 }
39