1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #include "configreader.h"
16 #include "commands/cmd_user.h"
20 extern "C" command_t* init_command(InspIRCd* Instance)
22 return new cmd_user(Instance);
25 CmdResult cmd_user::Handle (const char** parameters, int pcnt, userrec *user)
27 /* A user may only send the USER command once */
28 if (!(user->registered & REG_USER))
30 if (!ServerInstance->IsIdent(parameters[0]))
33 * RFC says we must use this numeric, so we do. Let's make it a little more nub friendly though. :)
34 * -- Craig, and then w00t.
36 user->WriteServ("461 %s USER :Your username is not valid",user->nick);
41 /* We're not checking ident, but I'm not sure I like the idea of '~' prefixing.. */
42 /* XXX - The ident field is IDENTMAX+2 in size to account for +1 for the optional
43 * ~ character, and +1 for null termination, therefore we can safely use up to
46 strlcpy(user->ident, parameters[0], IDENTMAX);
47 strlcpy(user->fullname, *parameters[3] ? parameters[3] : "No info", MAXGECOS);
48 user->registered = (user->registered | REG_USER);
53 user->WriteServ("462 %s :You may not reregister",user->nick);
56 /* parameters 2 and 3 are local and remote hosts, ignored when sent by client connection */
57 if (user->registered == REG_NICKUSER)
60 /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
61 if (ServerInstance->next_call > ServerInstance->Time() + ServerInstance->Config->dns_timeout)
62 ServerInstance->next_call = ServerInstance->Time() + ServerInstance->Config->dns_timeout;
63 FOREACH_RESULT(I_OnUserRegister,OnUserRegister(user));