1 /*
2  * h_mdtm.c
3  * (C)1999-2011 by Marc Huber <Marc.Huber@web.de>
4  *
5  * $Id: h_mdtm.c,v 1.11 2015/03/14 06:11:25 marc Exp marc $
6  *
7  */
8 
9 #include "headers.h"
10 
11 static const char rcsid[] __attribute__ ((used)) = "$Id: h_mdtm.c,v 1.11 2015/03/14 06:11:25 marc Exp marc $";
12 
h_mdtm(struct context * ctx,char * arg)13 void h_mdtm(struct context *ctx, char *arg)
14 {
15     char *t;
16     struct stat st;
17 
18     DebugIn(DEBUG_COMMAND);
19 
20     if ((t = buildpath(ctx, arg)) && (!pickystat(ctx, &st, t))) {
21 	if (S_ISREG(st.st_mode)) {
22 	    char buffer[40];
23 	    struct tm *tm = gmtime(&st.st_mtime);
24 	    strftime(buffer, (size_t) 40, "%Y%m%d%H%M%S", tm);
25 	    replyf(ctx, "213 %s\r\n", buffer);
26 	} else
27 	    reply(ctx, MSG_550_Not_plain_file);
28     } else
29 	reply(ctx, MSG_550_No_such_file_or_directory);
30 
31     DebugOut(DEBUG_COMMAND);
32 }
33