ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/drop.C
Revision: 1.1
Committed: Thu Jul 19 08:24:52 2007 UTC (19 years, 3 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2005 William Pitcock, et al.
3     * Rights to this code are as documented in doc/LICENSE.
4     *
5     * This file contains code for the CService DROP function.
6     *
7     * $Id: drop.c 8321 2007-05-24 20:10:59Z jilles $
8     */
9    
10     #include "atheme.h"
11     #include <account/myuser.h>
12     #include <account/mychan.h>
13    
14     static char const rcsid[] = "$Id";
15    
16     struct cs_drop_listeners : callback::has_listeners
17     {
18     };
19    
20     cs_drop_listeners listeners;
21    
22     DECLARE_MODULE_V1 ("chanserv/drop", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>");
23    
24     static void cs_cmd_drop (sourceinfo_t *si, int parc, char *parv[]);
25    
26     command_t cs_drop = { "DROP", N_("Drops a channel registration."),
27     AC_NONE, 1, cs_cmd_drop
28     };
29    
30     cmdvec *cs_cmdtree;
31     helpvec *cs_helptree;
32    
33     void
34     _modinit (module_t *m)
35     {
36     MODULE_USE_SYMBOL_T (cs_cmdtree, cmdvec, "chanserv/main", "cs_cmdtree");
37     MODULE_USE_SYMBOL_T (cs_helptree, helpvec, "chanserv/main", "cs_helptree");
38    
39     cs_cmdtree << cs_drop;
40     help_addentry (cs_helptree, "DROP", "help/cservice/drop", NULL);
41     }
42    
43     void
44     _moddeinit ()
45     {
46     cs_cmdtree >> cs_drop;
47     help_delentry (cs_helptree, "DROP");
48     }
49    
50     static void
51     cs_cmd_drop (sourceinfo_t *si, int parc, char *parv[])
52     {
53     mychan_t *mc;
54     char *name = parv[0];
55    
56     if (!name)
57     {
58     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP");
59     command_fail (si, fault_needmoreparams, _("Syntax: DROP <#channel>"));
60     return;
61     }
62    
63     if (*name != '#')
64     {
65     command_fail (si, fault_badparams, STR_INVALID_PARAMS, "DROP");
66     command_fail (si, fault_badparams, _("Syntax: DROP <#channel>"));
67     return;
68     }
69    
70     if (!(mc = mychan_find (name)))
71     {
72     command_fail (si, fault_nosuch_target, _("\2%s\2 is not registered."), name);
73     return;
74     }
75    
76     if (si->c != NULL)
77     {
78     command_fail (si, fault_noprivs, _("For security reasons, you may not drop a channel registration with a fantasy command."));
79     return;
80     }
81    
82     if (!is_founder (mc, si->smu) && !has_priv (si, PRIV_CHAN_ADMIN))
83     {
84     command_fail (si, fault_noprivs, _("You are not authorized to perform this operation."));
85     return;
86     }
87    
88     if (mc->find_metadata ("private:close:closer") && !has_priv (si, PRIV_CHAN_ADMIN))
89     {
90     logcommand (si, CMDLOG_REGISTER, "%s failed DROP (closed)", mc->name);
91     command_fail (si, fault_noprivs, _("The channel \2%s\2 is closed; it cannot be dropped."), mc->name);
92     return;
93     }
94    
95     if (mc->flags & MC_HOLD)
96     {
97     command_fail (si, fault_noprivs, _("The channel \2%s\2 is held; it cannot be dropped."), mc->name);
98     return;
99     }
100    
101     if (!is_founder (mc, si->smu))
102     {
103     logcommand (si, CMDLOG_ADMIN | LG_REGISTER, "%s DROP", mc->name);
104     wallops ("%s dropped the channel \2%s\2", get_oper_name (si), name);
105     }
106     else
107     logcommand (si, CMDLOG_REGISTER, "%s DROP", mc->name);
108    
109     snoop ("DROP: \2%s\2 by \2%s\2 as \2%s\2", mc->name, get_oper_name (si), si->smu->name);
110    
111     hook_call_event ("channel_drop", mc);
112     if ((config_options.chan && irccasecmp (mc->name, config_options.chan)) || !config_options.chan)
113     part (mc->name, chansvs.nick);
114     mc->refcnt_dec ();
115     command_success_nodata (si, _("The channel \2%s\2 has been dropped."), name);
116     return;
117     }