1 |
/** |
2 |
* ns_generatepass.C: Generates a new password, either n digits long (w/ nickserv arg), or 7 digits |
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 Greg Feigenson |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: ns_generatepass.C,v 1.4 2007-09-09 20:05:51 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#include "atheme.h" |
16 |
#include <ermyth/module.h> |
17 |
|
18 |
static char const rcsid[] = "$Id: ns_generatepass.C,v 1.4 2007-09-09 20:05:51 pippijn Exp $"; |
19 |
|
20 |
REGISTER_MODULE ("nickserv/generatepass", false, "Epiphanic Networks <http://www.epiphanic.org>"); |
21 |
|
22 |
static void ns_cmd_generatepass (sourceinfo_t *si, int parc, char *parv[]); |
23 |
|
24 |
command_t const ns_generatepass = { "GENERATEPASS", "Generates a random password.", AC_NONE, 1, ns_cmd_generatepass }; |
25 |
|
26 |
E cmdvec ns_cmdtree; |
27 |
E helpvec ns_helptree; |
28 |
|
29 |
static void |
30 |
ns_cmd_generatepass (sourceinfo_t *si, int parc, char *parv[]) |
31 |
{ |
32 |
int n = 0; |
33 |
char *newpass; |
34 |
|
35 |
if (parc >= 1) |
36 |
n = atoi (parv[0]); |
37 |
|
38 |
if (n <= 0 || n > 127) |
39 |
n = 7; |
40 |
|
41 |
newpass = gen_pw (n); |
42 |
|
43 |
command_success_string (si, newpass, "Randomly generated password: %s", newpass); |
44 |
sfree (newpass); |
45 |
} |
46 |
|
47 |
bool |
48 |
_modinit (module *m) |
49 |
{ |
50 |
ns_cmdtree << ns_generatepass; |
51 |
help_addentry (ns_helptree, "GENERATEPASS", "help/nickserv/generatepass", NULL); |
52 |
|
53 |
/* You'll need to create a helpfile and put in help/nickserv */ |
54 |
|
55 |
return true; |
56 |
} |
57 |
|
58 |
void |
59 |
_moddeinit () |
60 |
{ |
61 |
ns_cmdtree >> ns_generatepass; |
62 |
help_delentry (ns_helptree, "GENERATEPASS"); |
63 |
} |