ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/operserv/jupe.C
Revision: 1.6
Committed: Thu Aug 30 19:56:24 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.5: +7 -7 lines
Log Message:
- put faultcodes into their own namespace
- removed old files
- limited header garbage in atheme.h
- macros to inline bools for connection_t::is_*
- put some connection_t functions into the connection_t class

File Contents

# User Rev Content
1 pippijn 1.1 /*
2 pippijn 1.5 * Copyright © 2005-2006 William Pitcock, et al.
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * Jupiters a server.
6     *
7 pippijn 1.6 * $Id: jupe.C,v 1.5 2007-08-28 17:08:11 pippijn Exp $
8 pippijn 1.1 */
9    
10     #include "atheme.h"
11 pippijn 1.5 #include <ermyth/module.h>
12 pippijn 1.1
13 pippijn 1.6 static char const rcsid[] = "$Id: jupe.C,v 1.5 2007-08-28 17:08:11 pippijn Exp $";
14 pippijn 1.1
15 pippijn 1.5 REGISTER_MODULE ("operserv/jupe", false, "The Ermyth Team <http://ermyth.schmorp.de>");
16 pippijn 1.1
17     static void os_cmd_jupe (sourceinfo_t *si, int parc, char *parv[]);
18    
19 pippijn 1.5 command_t const os_jupe = { "JUPE", N_("Jupiters a server."), PRIV_JUPE, 2, os_cmd_jupe };
20 pippijn 1.1
21 pippijn 1.5 E cmdvec os_cmdtree;
22     E helpvec os_helptree;
23 pippijn 1.1
24 pippijn 1.5 bool
25     _modinit (module *m)
26 pippijn 1.1 {
27     os_cmdtree << os_jupe;
28 pippijn 1.4 help_addentry (os_helptree, "JUPE", "help/operserv/jupe", NULL);
29 pippijn 1.5
30     return true;
31 pippijn 1.1 }
32    
33     void
34     _moddeinit ()
35     {
36     os_cmdtree >> os_jupe;
37     help_delentry (os_helptree, "JUPE");
38     }
39    
40     static void
41     os_cmd_jupe (sourceinfo_t *si, int parc, char *parv[])
42     {
43     char *server = parv[0];
44     char *reason = parv[1];
45     char reasonbuf[BUFSIZE];
46    
47     if (!server || !reason)
48     {
49 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "JUPE");
50     command_fail (si, fault::needmoreparams, _("Usage: JUPE <server> <reason>"));
51 pippijn 1.1 return;
52     }
53    
54     if (!strchr (server, '.'))
55     {
56 pippijn 1.6 command_fail (si, fault::badparams, _("\2%s\2 is not a valid server name."), server);
57 pippijn 1.1 return;
58     }
59    
60     if (!irccasecmp (server, me.name))
61     {
62 pippijn 1.6 command_fail (si, fault::noprivs, _("\2%s\2 is the services server; it cannot be jupitered!"), server);
63 pippijn 1.1 return;
64     }
65    
66     if (!irccasecmp (server, me.actual))
67     {
68 pippijn 1.6 command_fail (si, fault::noprivs, _("\2%s\2 is the current uplink; it cannot be jupitered!"), server);
69 pippijn 1.1 return;
70     }
71    
72     logcommand (si, CMDLOG_ADMIN, "JUPE %s %s", server, reason);
73    
74     snprintf (reasonbuf, BUFSIZE, "[%s] %s", get_oper_name (si), reason);
75 pippijn 1.5 phandler->jupe (server, reasonbuf);
76 pippijn 1.1
77     command_success_nodata (si, _("\2%s\2 has been jupitered."), server);
78     }