ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/modules/contrib/ircd_catserv.C
Revision: 1.5
Committed: Sat Sep 22 14:27:27 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +3 -3 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

# Content
1 /**
2 * ircd_catserv.C: Meow!
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 William Pitcock, et al.
10 * The rights to this code are as documented under doc/pod/license.pod.
11 *
12 * $Id: ircd_catserv.C,v 1.4 2007-09-16 18:54:43 pippijn Exp $
13 */
14
15 #include "atheme.h"
16 #include <ermyth/module.h>
17
18 static char const rcsid[] = "$Id: ircd_catserv.C,v 1.4 2007-09-16 18:54:43 pippijn Exp $";
19
20 REGISTER_MODULE ("contrib/ircd_catserv", false, "The Ermyth Team <http://ermyth.xinutec.org>");
21
22 service_t *catserv;
23 cmdvec catserv_cmdtree;
24
25 static void catserv_cmd_meow (sourceinfo_t *si, int parc, char *parv[]);
26 static void catserv_cmd_help (sourceinfo_t *si, int parc, char *parv[]);
27 static void catserv_handler (sourceinfo_t *si, int parc, char **parv);
28
29 command_t const catserv_meow = { "MEOW", "Makes the cute little kitty-cat meow!", AC_NONE, 0, catserv_cmd_meow };
30 command_t const catserv_help = { "HELP", "Displays contextual help information.", AC_NONE, 1, catserv_cmd_help };
31
32 bool
33 _modinit (module *m)
34 {
35 catserv = add_service ("CatServ", "meow", "meowth.nu", "Kitty cat!", catserv_handler, catserv_cmdtree);
36
37 catserv_cmdtree << catserv_meow;
38 catserv_cmdtree << catserv_help;
39
40 return true;
41 }
42
43 void
44 _moddeinit ()
45 {
46 catserv_cmdtree >> catserv_help;
47 catserv_cmdtree >> catserv_meow;
48
49 del_service (catserv);
50 }
51
52 static void
53 catserv_cmd_meow (sourceinfo_t *si, int parc, char *parv[])
54 {
55 command_success_nodata (si, "Meow!");
56 }
57
58 static void
59 catserv_cmd_help (sourceinfo_t *si, int parc, char *parv[])
60 {
61 command_help (si, catserv_cmdtree);
62 }
63
64 static void
65 catserv_handler (sourceinfo_t *si, int parc, char *parv[])
66 {
67 char orig[BUFSIZE];
68 char *cmd;
69 char *text;
70
71 /* this should never happen */
72 if (parv[0][0] == '&')
73 {
74 slog (LG_ERROR, "services(): got parv with local channel: %s", parv[0]);
75 return;
76 }
77
78 /* make a copy of the original for debugging */
79 strlcpy (orig, parv[parc - 1], BUFSIZE);
80
81 /* lets go through this to get the command */
82 cmd = strtok (parv[parc - 1], " ");
83 text = strtok (NULL, "");
84
85 if (!cmd)
86 return;
87 if (*cmd == '\001')
88 {
89 handle_ctcp_common (si, cmd, text);
90 return;
91 }
92
93 /* take the command through the hash table */
94 command_exec_split (catserv, si, cmd, text, catserv_cmdtree);
95 }