]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_user.cpp
Jesus, look who's the commit whore today. More header updates, and removal of namespa...
[user/henk/code/inspircd.git] / src / cmd_user.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "configreader.h"
15 #include "users.h"
16 #include "commands/cmd_user.h"
17
18
19
20 extern "C" command_t* init_command(InspIRCd* Instance)
21 {
22         return new cmd_user(Instance);
23 }
24
25 CmdResult cmd_user::Handle (const char** parameters, int pcnt, userrec *user)
26 {
27         if (user->registered < REG_NICKUSER)
28         {
29                 if (!ServerInstance->IsIdent(parameters[0])) {
30                         // This kinda Sucks, According to the RFC thou, its either this,
31                         // or "You have already registered" :p -- Craig
32                         user->WriteServ("461 %s USER :Not enough parameters",user->nick);
33                         return CMD_FAILURE;
34                 }
35                 else {
36                         /* We're not checking ident, but I'm not sure I like the idea of '~' prefixing.. */
37                         /* XXX - The ident field is IDENTMAX+2 in size to account for +1 for the optional
38                          * ~ character, and +1 for null termination, therefore we can safely use up to
39                          * IDENTMAX here.
40                          */
41                         strlcpy(user->ident, parameters[0], IDENTMAX);
42                         strlcpy(user->fullname,parameters[3],MAXGECOS);
43                         user->registered = (user->registered | REG_USER);
44                 }
45         }
46         else
47         {
48                 user->WriteServ("462 %s :You may not reregister",user->nick);
49                 return CMD_FAILURE;
50         }
51         /* parameters 2 and 3 are local and remote hosts, ignored when sent by client connection */
52         if (user->registered == REG_NICKUSER)
53         {
54                 int MOD_RESULT = 0;
55                 /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
56                 if (ServerInstance->next_call > ServerInstance->Time() + ServerInstance->Config->dns_timeout)
57                         ServerInstance->next_call = ServerInstance->Time() + ServerInstance->Config->dns_timeout;
58                 FOREACH_RESULT(I_OnUserRegister,OnUserRegister(user));
59                 if (MOD_RESULT > 0)
60                         return CMD_FAILURE;
61
62         }
63
64         return CMD_SUCCESS;
65 }