]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setident.cpp
Windows support. Tested and working to compile on freebsd and linux. Next step is...
[user/henk/code/inspircd.git] / src / modules / m_setident.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 "users.h"
15 #include "modules.h"
16 #include "inspircd.h"
17
18 /* $ModDesc: Provides support for the SETIDENT command */
19
20 /** Handle /SETIDENT
21  */
22 class cmd_setident : public command_t
23 {
24  public:
25  cmd_setident (InspIRCd* Instance) : command_t(Instance,"SETIDENT", 'o', 1)
26         {
27                 this->source = "m_setident.so";
28                 syntax = "<new-ident>";
29         }
30
31         CmdResult Handle(const char** parameters, int pcnt, userrec *user)
32         {
33                 size_t len = 0;
34                 for(const char* x = parameters[0]; *x; x++, len++)
35                 {
36                         if(((*x >= 'A') && (*x <= '}')) || strchr(".-0123456789", *x))
37                                 continue;
38
39                         user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
40                         return CMD_FAILURE;
41                 }
42                 if (len > IDENTMAX)
43                 {
44                         user->WriteServ("NOTICE %s :*** Ident is too long", user->nick);
45                         return CMD_FAILURE;
46                 }
47
48                 user->ChangeIdent(parameters[0]);
49                 ServerInstance->WriteOpers("%s used SETIDENT to change their ident to '%s'", user->nick, user->ident);
50
51                 return CMD_SUCCESS;
52         }
53 };
54
55
56 class ModuleSetIdent : public Module
57 {
58         cmd_setident*   mycommand;
59         
60  public:
61         ModuleSetIdent(InspIRCd* Me) : Module(Me)
62         {
63                 
64                 mycommand = new cmd_setident(ServerInstance);
65                 ServerInstance->AddCommand(mycommand);
66         }
67         
68         virtual ~ModuleSetIdent()
69         {
70         }
71         
72         virtual Version GetVersion()
73         {
74                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
75         }
76         
77 };
78
79 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
80
81 class ModuleSetIdentFactory : public ModuleFactory
82 {
83  public:
84         ModuleSetIdentFactory()
85         {
86         }
87         
88         ~ModuleSetIdentFactory()
89         {
90         }
91         
92         virtual Module * CreateModule(InspIRCd* Me)
93         {
94                 return new ModuleSetIdent(Me);
95         }
96         
97 };
98
99
100 extern "C" DllExport void * init_module( void )
101 {
102         return new ModuleSetIdentFactory;
103 }
104