ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/src/pmodule.C
Revision: 1.7
Committed: Sat Sep 22 14:27:30 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +2 -1 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

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