ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/list.C
Revision: 1.7
Committed: Sun Sep 9 20:05:51 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.6: +3 -3 lines
Log Message:
- changed configurations to the c++ stdlib
- more #defines to enum
- removed getopt.h and link.h from the system as they were unused
- reworked logstreams
- added an itoa with old syntax
- made klines objects
- moved some global variables into appropriate classes
- fixed boost.foreach's compiler workaround #if's
- allow other files to add exceptions with ADD_EXCEPTION
- changed mynick_t to c++ object
- moved servers.h out of atheme.h
- corrected PING from inspircd 1.2

File Contents

# User Rev Content
1 pippijn 1.1 /*
2 pippijn 1.5 * Copyright © 2005 Robin Burchell, et al.
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * This file contains code for the ChanServ LIST function.
6     *
7 pippijn 1.7 * $Id: list.C,v 1.6 2007-08-30 19:56:22 pippijn Exp $
8 pippijn 1.1 */
9    
10 pippijn 1.6 #include <boost/foreach.hpp>
11    
12 pippijn 1.1 #include "atheme.h"
13 pippijn 1.5 #include <ermyth/module.h>
14 pippijn 1.1 #include <account/myuser.h>
15     #include <account/mychan.h>
16    
17 pippijn 1.7 static char const rcsid[] = "$Id: list.C,v 1.6 2007-08-30 19:56:22 pippijn Exp $";
18 pippijn 1.1
19 pippijn 1.5 REGISTER_MODULE ("chanserv/list", false, "The Ermyth Team <http://ermyth.schmorp.de>");
20 pippijn 1.1
21     static void cs_cmd_list (sourceinfo_t *si, int parc, char *parv[]);
22    
23 pippijn 1.5 command_t const cs_list = { "LIST", N_("Lists channels registered matching a given pattern."), PRIV_CHAN_AUSPEX, 1, cs_cmd_list };
24 pippijn 1.1
25 pippijn 1.5 E cmdvec cs_cmdtree;
26     E helpvec cs_helptree;
27 pippijn 1.1
28 pippijn 1.5 bool
29     _modinit (module *m)
30 pippijn 1.1 {
31     cs_cmdtree << cs_list;
32 pippijn 1.4 help_addentry (cs_helptree, "LIST", "help/chanserv/list", NULL);
33 pippijn 1.5
34     return true;
35 pippijn 1.1 }
36    
37     void
38     _moddeinit ()
39     {
40     cs_cmdtree >> cs_list;
41     help_delentry (cs_helptree, "LIST");
42     }
43    
44     static void
45     cs_cmd_list (sourceinfo_t *si, int parc, char *parv[])
46     {
47     mychan_t *mc;
48     char *chanpattern = parv[0];
49     char buf[BUFSIZE];
50     unsigned int matches = 0;
51    
52     if (!chanpattern)
53     {
54 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "LIST");
55     command_fail (si, fault::needmoreparams, _("Syntax: LIST <channel pattern>"));
56 pippijn 1.1 return;
57     }
58    
59     snoop ("LIST:CHANNELS: \2%s\2 by \2%s\2", chanpattern, get_oper_name (si));
60     command_success_nodata (si, _("Channels matching pattern \2%s\2:"), chanpattern);
61    
62 pippijn 1.7 foreach (mychan_t::pair_type &mp, mychan_t::map)
63 pippijn 1.6 {
64     mc = mp.second;
65     if (!match (chanpattern, mc->name))
66     {
67     /* in the future we could add a LIMIT parameter */
68     *buf = '\0';
69    
70     if (mc->find_metadata ("private:mark:setter"))
71     strlcat (buf, "\2[marked]\2", BUFSIZE);
72     if (mc->find_metadata ("private:close:closer"))
73     {
74     if (*buf)
75     strlcat (buf, " ", BUFSIZE);
76    
77     strlcat (buf, "\2[closed]\2", BUFSIZE);
78     }
79     if (mc->flags & MC_HOLD)
80     {
81     if (*buf)
82     strlcat (buf, " ", BUFSIZE);
83    
84     strlcat (buf, "\2[held]\2", BUFSIZE);
85     }
86    
87     command_success_nodata (si, "- %s (%s) %s", mc->name, mc->founder_names (), buf);
88     matches++;
89     }
90     }
91 pippijn 1.1
92     logcommand (si, CMDLOG_ADMIN, "LIST %s (%d matches)", chanpattern, matches);
93     if (matches == 0)
94     command_success_nodata (si, _("No channel matched pattern \2%s\2"), chanpattern);
95     else
96     command_success_nodata (si, ngettext (N_("\2%d\2 match for pattern \2%s\2"), N_("\2%d\2 matches for pattern \2%s\2"), matches), matches, chanpattern);
97     }