ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/taxonomy.C
Revision: 1.9
Committed: Sat Sep 22 14:27:27 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +3 -3 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.8 /**
2     * taxonomy.C: Lists object properties via their metadata table.
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 pippijn 1.5 * Copyright © 2005 William Pitcock, et al.
10 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
11 pippijn 1.1 *
12 pippijn 1.9 * $Id: taxonomy.C,v 1.8 2007-09-16 18:54:43 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.5 #include <ermyth/module.h>
17 pippijn 1.1 #include <account/mychan.h>
18    
19 pippijn 1.9 static char const rcsid[] = "$Id: taxonomy.C,v 1.8 2007-09-16 18:54:43 pippijn Exp $";
20 pippijn 1.1
21 pippijn 1.9 REGISTER_MODULE ("chanserv/taxonomy", false, "The Ermyth Team <http://ermyth.xinutec.org>");
22 pippijn 1.1
23     static void cs_cmd_taxonomy (sourceinfo_t *si, int parc, char *parv[]);
24    
25 pippijn 1.5 command_t const cs_taxonomy = { "TAXONOMY", N_("Displays a channel's metadata."), AC_NONE, 1, cs_cmd_taxonomy };
26 pippijn 1.1
27 pippijn 1.5 E cmdvec cs_cmdtree;
28     E helpvec cs_helptree;
29 pippijn 1.1
30 pippijn 1.5 bool
31     _modinit (module *m)
32 pippijn 1.1 {
33     cs_cmdtree << cs_taxonomy;
34 pippijn 1.4 help_addentry (cs_helptree, "TAXONOMY", "help/chanserv/taxonomy", NULL);
35 pippijn 1.5
36     return true;
37 pippijn 1.1 }
38    
39     void
40     _moddeinit ()
41     {
42     cs_cmdtree >> cs_taxonomy;
43     help_delentry (cs_helptree, "TAXONOMY");
44     }
45    
46     void
47     cs_cmd_taxonomy (sourceinfo_t *si, int parc, char *parv[])
48     {
49     char *target = parv[0];
50     mychan_t *mc;
51     bool isoper;
52    
53     if (!target || *target != '#')
54     {
55 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "TAXONOMY");
56     command_fail (si, fault::needmoreparams, _("Syntax: TAXONOMY <#channel>"));
57 pippijn 1.1 return;
58     }
59    
60 pippijn 1.6 if (!(mc = mychan_t::find (target)))
61 pippijn 1.1 {
62 pippijn 1.6 command_fail (si, fault::nosuch_target, _("\2%s\2 is not a registered channel."), target);
63 pippijn 1.1 return;
64     }
65    
66     isoper = has_priv (si, PRIV_CHAN_AUSPEX);
67     if (isoper)
68     logcommand (si, CMDLOG_ADMIN, "%s TAXONOMY (oper)", mc->name);
69     else
70     logcommand (si, CMDLOG_GET, "%s TAXONOMY", mc->name);
71     command_success_nodata (si, _("Taxonomy for \2%s\2:"), target);
72    
73 pippijn 1.7 metadata::map_type::iterator mcmdit = mc->mdmap.begin ();
74     metadata::map_type::iterator mcmdet = mc->mdmap.end ();
75 pippijn 1.5 while (mcmdit != mcmdet)
76 pippijn 1.1 {
77 pippijn 1.7 metadata *md = mcmdit->second;
78 pippijn 1.5 ++mcmdit;
79 pippijn 1.1
80     if (md->is_private && !isoper)
81     continue;
82    
83     command_success_nodata (si, "%-32s: %s", md->key, md->value);
84     }
85    
86     command_success_nodata (si, _("End of \2%s\2 taxonomy."), target);
87     }