1 |
/* |
2 |
* pmodule.C: Protocol command management. |
3 |
* |
4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
5 |
* Rights to this code are as documented in COPYING. |
6 |
* |
7 |
* |
8 |
* Portions of this file were derived from sources bearing the following license: |
9 |
* Rights to this code are documented in doc/pod/license.pod. |
10 |
* Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
11 |
*/ |
12 |
|
13 |
static char const rcsid[] = "$Id: pmodule.C,v 1.6 2007-09-16 18:54:45 pippijn Exp $"; |
14 |
|
15 |
#include <map> |
16 |
|
17 |
#include "atheme.h" |
18 |
#include "pmodule.h" |
19 |
#include <util/predicates.h> |
20 |
|
21 |
typedef std::map<char const * const, pcommand_t const *, str_lt> pcommand_map; |
22 |
pcommand_map pcommands; |
23 |
|
24 |
cmode_t *mode_list; |
25 |
extmode_t *ignore_mode_list; |
26 |
cmode_t *status_mode_list; |
27 |
cmode_t *prefix_mode_list; |
28 |
protocol::ircd_t *ircd; |
29 |
bool protocol::handler::loaded = false; |
30 |
|
31 |
void |
32 |
pcommand_add (pcommand_t const &pcmd) |
33 |
{ |
34 |
if (pcommand_find (pcmd.token)) |
35 |
{ |
36 |
slog (LG_INFO, "pcommand_add(): token %s is already registered", pcmd.token); |
37 |
return; |
38 |
} |
39 |
|
40 |
pcommands[pcmd.token] = &pcmd; |
41 |
} |
42 |
|
43 |
void |
44 |
pcommand_delete (pcommand_t const &pcmd) |
45 |
{ |
46 |
if (!pcommand_find (pcmd.token)) |
47 |
{ |
48 |
slog (LG_INFO, "pcommand_delete(): token %s is not registered", pcmd.token); |
49 |
return; |
50 |
} |
51 |
|
52 |
pcommands.erase (pcmd.token); |
53 |
} |
54 |
|
55 |
pcommand_t const * |
56 |
pcommand_find (char const * const token) |
57 |
{ |
58 |
pcommand_map::iterator it; |
59 |
if ((it = pcommands.find (token)) != pcommands.end ()) |
60 |
return it->second; |
61 |
return NULL; |
62 |
} |