1 |
/** |
2 |
* rehash.C: This file contains functionality which implements the OperServ REHASH command. |
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 |
* Copyright © 2005-2006 Atheme Development Group |
10 |
* Rights to this code are documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: rehash.C,v 1.7 2007-09-16 18:54:44 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include <ermyth/module.h> |
17 |
#include <ermyth/database.h> |
18 |
|
19 |
static char const rcsid[] = "$Id: rehash.C,v 1.7 2007-09-16 18:54:44 pippijn Exp $"; |
20 |
|
21 |
REGISTER_MODULE ("operserv/rehash", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
22 |
|
23 |
static void os_cmd_rehash (sourceinfo_t *si, int parc, char *parv[]); |
24 |
|
25 |
command_t const os_rehash = { "REHASH", N_("Reload the configuration data."), PRIV_ADMIN, 0, os_cmd_rehash }; |
26 |
|
27 |
E cmdvec os_cmdtree; |
28 |
E helpvec os_helptree; |
29 |
|
30 |
bool |
31 |
_modinit (module *m) |
32 |
{ |
33 |
os_cmdtree << os_rehash; |
34 |
help_addentry (os_helptree, "REHASH", "help/operserv/rehash", NULL); |
35 |
|
36 |
return true; |
37 |
} |
38 |
|
39 |
void |
40 |
_moddeinit () |
41 |
{ |
42 |
os_cmdtree >> os_rehash; |
43 |
help_delentry (os_helptree, "REHASH"); |
44 |
} |
45 |
|
46 |
/* REHASH */ |
47 |
void |
48 |
os_cmd_rehash (sourceinfo_t *si, int parc, char *parv[]) |
49 |
{ |
50 |
snoop ("UPDATE: \2%s\2", get_oper_name (si)); |
51 |
wallops ("Updating database by request of \2%s\2.", get_oper_name (si)); |
52 |
expire_check (NULL); |
53 |
backend->save (); |
54 |
|
55 |
snoop ("REHASH: \2%s\2", get_oper_name (si)); |
56 |
logcommand (si, CMDLOG_ADMIN, "REHASH"); |
57 |
wallops ("Rehashing \2%s\2 by request of \2%s\2.", config_file, get_oper_name (si)); |
58 |
|
59 |
if (conf_rehash ()) |
60 |
command_success_nodata (si, _("REHASH completed.")); |
61 |
else |
62 |
command_fail (si, fault::nosuch_target, _("REHASH of \2%s\2 failed. Please corrrect any errors in the file and try again."), config_file); |
63 |
} |