/** * ircd_catserv.C: Meow! * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005 William Pitcock, et al. * The rights to this code are as documented under doc/pod/license.pod. * * $Id: ircd_catserv.C,v 1.5 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include static char const rcsid[] = "$Id: ircd_catserv.C,v 1.5 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("contrib/ircd_catserv", false, "The Ermyth Team "); service_t *catserv; cmdvec catserv_cmdtree; static void catserv_cmd_meow (sourceinfo_t *si, int parc, char *parv[]); static void catserv_cmd_help (sourceinfo_t *si, int parc, char *parv[]); static void catserv_handler (sourceinfo_t *si, int parc, char **parv); command_t const catserv_meow = { "MEOW", "Makes the cute little kitty-cat meow!", AC_NONE, 0, catserv_cmd_meow }; command_t const catserv_help = { "HELP", "Displays contextual help information.", AC_NONE, 1, catserv_cmd_help }; bool _modinit (module *m) { catserv = add_service ("CatServ", "meow", "meowth.nu", "Kitty cat!", catserv_handler, catserv_cmdtree); catserv_cmdtree << catserv_meow; catserv_cmdtree << catserv_help; return true; } void _moddeinit () { catserv_cmdtree >> catserv_help; catserv_cmdtree >> catserv_meow; del_service (catserv); } static void catserv_cmd_meow (sourceinfo_t *si, int parc, char *parv[]) { command_success_nodata (si, "Meow!"); } static void catserv_cmd_help (sourceinfo_t *si, int parc, char *parv[]) { command_help (si, catserv_cmdtree); } static void catserv_handler (sourceinfo_t *si, int parc, char *parv[]) { char orig[BUFSIZE]; char *cmd; char *text; /* this should never happen */ if (parv[0][0] == '&') { slog (LG_ERROR, "services(): got parv with local channel: %s", parv[0]); return; } /* make a copy of the original for debugging */ strlcpy (orig, parv[parc - 1], BUFSIZE); /* lets go through this to get the command */ cmd = strtok (parv[parc - 1], " "); text = strtok (NULL, ""); if (!cmd) return; if (*cmd == '\001') { handle_ctcp_common (si, cmd, text); return; } /* take the command through the hash table */ command_exec_split (catserv, si, cmd, text, catserv_cmdtree); }