ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/operserv/jupe.C
Revision: 1.8
Committed: Sat Sep 22 14:27:28 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +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.7 /**
2     * jupe.C: Jupiters a server.
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-2006 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.8 * $Id: jupe.C,v 1.7 2007-09-16 18:54:44 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.5 #include <ermyth/module.h>
17 pippijn 1.1
18 pippijn 1.8 static char const rcsid[] = "$Id: jupe.C,v 1.7 2007-09-16 18:54:44 pippijn Exp $";
19 pippijn 1.1
20 pippijn 1.8 REGISTER_MODULE ("operserv/jupe", false, "The Ermyth Team <http://ermyth.xinutec.org>");
21 pippijn 1.1
22     static void os_cmd_jupe (sourceinfo_t *si, int parc, char *parv[]);
23    
24 pippijn 1.5 command_t const os_jupe = { "JUPE", N_("Jupiters a server."), PRIV_JUPE, 2, os_cmd_jupe };
25 pippijn 1.1
26 pippijn 1.5 E cmdvec os_cmdtree;
27     E helpvec os_helptree;
28 pippijn 1.1
29 pippijn 1.5 bool
30     _modinit (module *m)
31 pippijn 1.1 {
32     os_cmdtree << os_jupe;
33 pippijn 1.4 help_addentry (os_helptree, "JUPE", "help/operserv/jupe", NULL);
34 pippijn 1.5
35     return true;
36 pippijn 1.1 }
37    
38     void
39     _moddeinit ()
40     {
41     os_cmdtree >> os_jupe;
42     help_delentry (os_helptree, "JUPE");
43     }
44    
45     static void
46     os_cmd_jupe (sourceinfo_t *si, int parc, char *parv[])
47     {
48     char *server = parv[0];
49     char *reason = parv[1];
50     char reasonbuf[BUFSIZE];
51    
52     if (!server || !reason)
53     {
54 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "JUPE");
55     command_fail (si, fault::needmoreparams, _("Usage: JUPE <server> <reason>"));
56 pippijn 1.1 return;
57     }
58    
59     if (!strchr (server, '.'))
60     {
61 pippijn 1.6 command_fail (si, fault::badparams, _("\2%s\2 is not a valid server name."), server);
62 pippijn 1.1 return;
63     }
64    
65     if (!irccasecmp (server, me.name))
66     {
67 pippijn 1.6 command_fail (si, fault::noprivs, _("\2%s\2 is the services server; it cannot be jupitered!"), server);
68 pippijn 1.1 return;
69     }
70    
71     if (!irccasecmp (server, me.actual))
72     {
73 pippijn 1.6 command_fail (si, fault::noprivs, _("\2%s\2 is the current uplink; it cannot be jupitered!"), server);
74 pippijn 1.1 return;
75     }
76    
77     logcommand (si, CMDLOG_ADMIN, "JUPE %s %s", server, reason);
78    
79     snprintf (reasonbuf, BUFSIZE, "[%s] %s", get_oper_name (si), reason);
80 pippijn 1.5 phandler->jupe (server, reasonbuf);
81 pippijn 1.1
82     command_success_nodata (si, _("\2%s\2 has been jupitered."), server);
83     }