1 /*
2  * h_user.c
3  *
4  * (C)1998-2011 by Marc Huber <Marc.Huber@web.de>
5  * All rights reserved.
6  *
7  * $Id: h_user.c,v 1.11 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_user.c,v 1.11 2015/03/14 06:11:26 marc Exp marc $";
14 
h_user(struct context * ctx,char * arg)15 void h_user(struct context *ctx, char *arg)
16 {
17     char *host;
18 
19     DebugIn(DEBUG_COMMAND);
20 
21     if (ctx->state == ST_conn) {
22 	ctx->state = ST_user;
23 
24 	host = strchr(arg, '@');
25 	if (host) {
26 	    *host++ = 0;
27 	    strset(&ctx->vhost, host);
28 	}
29 
30 	if (!strcasecmp(arg, "ftp") || !strcasecmp(arg, "anonymous")) {
31 	    reply(ctx, MSG_331_anon);
32 	    strset(&ctx->user, "ftp");
33 	    ctx->anonymous = 1;
34 	} else {
35 	    reply(ctx, MSG_331_user);
36 	    strset(&ctx->user, arg);
37 	    ctx->anonymous = 0;
38 	}
39     } else
40 	reply(ctx, MSG_503_Already_logged_in);
41 
42     DebugOut(DEBUG_COMMAND);
43 }
44