]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_user.cpp
New system for client exits using CullList seems stable, needs testing
[user/henk/code/inspircd.git] / src / cmd_user.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain.net>
8  *                <Craig.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include "inspircd_config.h"
20 #include "inspircd.h"
21 #include "inspircd_io.h"
22 #include <time.h>
23 #include <string>
24 #ifdef GCC3
25 #include <ext/hash_map>
26 #else
27 #include <hash_map>
28 #endif
29 #include <map>
30 #include <sstream>
31 #include <vector>
32 #include <deque>
33 #include "users.h"
34 #include "ctables.h"
35 #include "globals.h"
36 #include "modules.h"
37 #include "dynamic.h"
38 #include "wildcard.h"
39 #include "message.h"
40 #include "commands.h"
41 #include "mode.h"
42 #include "xline.h"
43 #include "inspstring.h"
44 #include "dnsqueue.h"
45 #include "helperfuncs.h"
46 #include "hashcomp.h"
47 #include "socketengine.h"
48 #include "typedefs.h"
49 #include "command_parse.h"
50 #include "cmd_user.h"
51
52 extern ServerConfig* Config;
53 extern InspIRCd* ServerInstance;
54 extern int MODCOUNT;
55 extern std::vector<Module*> modules;
56 extern std::vector<ircd_module*> factory;
57 extern time_t TIME;
58 extern user_hash clientlist;
59 extern chan_hash chanlist;
60 extern whowas_hash whowas;
61 extern std::vector<userrec*> all_opers;
62 extern std::vector<userrec*> local_users;
63 extern userrec* fd_ref_table[65536];
64
65 void cmd_user::Handle (char **parameters, int pcnt, userrec *user)
66 {
67         log(DEBUG,"Handling USER from cmd_user class!");
68         if (user->registered < 3)
69         {
70                 if (isident(parameters[0]) == 0) {
71                         // This kinda Sucks, According to the RFC thou, its either this,
72                         // or "You have already registered" :p -- Craig
73                         WriteServ(user->fd,"461 %s USER :Not enough parameters",user->nick);
74                 }
75                 else {
76                         /* We're not checking ident, but I'm not sure I like the idea of '~' prefixing.. */
77                         /* XXX - Should this IDENTMAX + 1 be IDENTMAX - 1? Ok, users.h has it defined as
78                          * char ident[IDENTMAX+2]; - WTF?
79                          */
80                         snprintf(user->ident, IDENTMAX+1, "~%s", parameters[0]);
81                         strlcpy(user->fullname,parameters[3],MAXGECOS);
82                         user->registered = (user->registered | 1);
83                 }
84         }
85         else
86         {
87                 WriteServ(user->fd,"462 %s :You may not reregister",user->nick);
88                 return;
89         }
90         /* parameters 2 and 3 are local and remote hosts, ignored when sent by client connection */
91         if (user->registered == 3)
92         {
93                 /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
94                 FOREACH_MOD(I_OnUserRegister,OnUserRegister(user));
95                 //ConnectUser(user,NULL);
96         }
97 }
98         
99