diff options
author | svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b <svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-03-28 21:59:56 +0000 |
---|---|---|
committer | svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b <svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-03-28 21:59:56 +0000 |
commit | 55bf4dbcabf378e9472b7d31d6edf87f6ac853e9 (patch) | |
tree | 7a9454ea6b8750256e242cf6d5fba3ca7a4b5044 /modules |
Initial Anope Import
git-svn-id: svn://svn.anope.org/anope/trunk@1 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'modules')
-rw-r--r-- | modules/Makefile | 26 | ||||
-rw-r--r-- | modules/README | 1 | ||||
-rwxr-xr-x | modules/compile.sh | 37 | ||||
-rwxr-xr-x | modules/configure | 21 | ||||
-rw-r--r-- | modules/hs_moo.c | 99 | ||||
-rw-r--r-- | modules/ircd_catserv.c | 128 | ||||
-rw-r--r-- | modules/module.h | 9 |
7 files changed, 321 insertions, 0 deletions
diff --git a/modules/Makefile b/modules/Makefile new file mode 100644 index 000000000..797cee008 --- /dev/null +++ b/modules/Makefile @@ -0,0 +1,26 @@ +include ../Makefile.inc +include ./Makefile.inc + +OBJECTS= $(SRCS:.c=.o) +SO_FILES=$(OBJECTS:.o=.s) +CDEFS= -g -rdynamic -Wall +CFLAGS=$(BASE_CFLAGS) $(CDEFS) + +all: $(OBJECTS) + +install: $(SO_FILES) + $(CP_ALL) ./*.so $(MODULE_PATH) + +distclean: clean spotless + +.c.o: + $(CC) $(CFLAGS) -c $< + +.o.s: + ld -shared $< -o $*.so + +clean: + rm -f *.o core + +spotless: clean + rm -f *.so Makefile.inc diff --git a/modules/README b/modules/README new file mode 100644 index 000000000..6aee0ac47 --- /dev/null +++ b/modules/README @@ -0,0 +1 @@ +Please read the "MODULES" file located on the "docs" directory. diff --git a/modules/compile.sh b/modules/compile.sh new file mode 100755 index 000000000..912780b65 --- /dev/null +++ b/modules/compile.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# Disabled for Anope 1.6 until we figure out a better way to +# download modules safely. +# if [ "$1" = "getmods" ] ; then +# wget -nv -r -l 1 -A c -nd -nc http://modules.anope.org/download/ +# rm -f robots.txt +# exit 0 +# fi + +if [ ! -f ../Makefile.inc ]; then + echo "" + echo "*** ERROR: Unable to find ../Makefile.inc. You must ./configure Anope before" + echo "*** ERROR: compiling modules. Please read the INSTALL document for details." + echo "" + exit 1 +fi + +echo -n "SRCS=" > ./Makefile.inc +FIRST=1 +for oldfile in *.c +do + if [ "$FIRST" = 1 ] ; then + echo -n " "$oldfile >> ./Makefile.inc + else + echo "\\" >> ./Makefile.inc + echo -n " " $oldfile >> ./Makefile.inc + fi + FIRST=0 +done +echo "" >> ./Makefile.inc + +make + +if [ "$1" = "install" ] ; then + make install +fi diff --git a/modules/configure b/modules/configure new file mode 100755 index 000000000..5d75aaad9 --- /dev/null +++ b/modules/configure @@ -0,0 +1,21 @@ +#!/bin/sh + +echo -n "SRCS=" > ./Makefile.inc +FIRST=1 +for oldfile in *.c +do + if [ "$FIRST" = 1 ] ; then + echo -n " "$oldfile >> ./Makefile.inc + else + echo "\\" >> ./Makefile.inc + echo -n " " $oldfile >> ./Makefile.inc + fi + FIRST=0 +done +echo "" >> ./Makefile.inc + +cat <<EOT +All done! Now run "make" (or possibly "gmake") to compile your modules. +See the INSTALL, README and FAQ files if you have any problems. +EOT +exit 0 diff --git a/modules/hs_moo.c b/modules/hs_moo.c new file mode 100644 index 000000000..97d48ae04 --- /dev/null +++ b/modules/hs_moo.c @@ -0,0 +1,99 @@ +/** + * This is an EXAMPLE module, which adds the "moo" command to HostServ + * + * This command does NOT do anything useful at all! + * + * Please visit http://modules.anope.org for useful modules! + * + **/ +#include "module.h" + +#define AUTHOR "Anope" /* Set the Author for a modinfo reply */ +#define VERSION "1.1" /* Set the version for a modinfo reply */ + +int hs_moo_show(User * u); /* Function to use when a /hs moo command is recived */ +int test(int argc, char **argv); +void myHostServHelp(User *u); /* Function to display out help in a /hs help response */ +int myHostServMooHelp(User *u); /* Function to display help to _everyone_ when a /hs help moo is called*/ +int myHostServMooRegHelp(User *u); /* Function to display extra help to regular-users when a /hs help moo is called*/ +int myHostServMooOperHelp(User *u); /* Function to display extra help to opers when a /hs help moo is called*/ +int myHostServMooAdminHelp(User *u); /* Function to display extra help to admins when a /hs help moo is called*/ +int myHostServMooRootHelp(User *u); /* Function to display extra help to roors when a /hs help moo is called*/ + +int AnopeInit(int argc, char **argv) /* This will be executed when the module is loaded */ +{ + Command *c; /* Pointer to a Command */ + c = createCommand("moo", hs_moo_show, NULL, -1, -1, -1, -1, -1); /* Create a new command "moo" pointing to hs_moo */ + + moduleAddHelp(c,myHostServMooHelp); /* add help for all users to this command */ + moduleAddRegHelp(c,myHostServMooRegHelp); /* add extra regular-user only help to this command */ + moduleAddOperHelp(c,myHostServMooOperHelp); /* add extra oper only help to this command */ + moduleAddAdminHelp(c,myHostServMooAdminHelp); /* add extra admin only help to this command */ + moduleAddRootHelp(c,myHostServMooRootHelp); /* add extra root only help to this command */ + + moduleSetHostHelp(myHostServHelp); /* add us to the .hs help list */ + + + alog("hs_moo.so: Add Command 'moo' Status: %d", /* Log the command being added */ + moduleAddCommand(HOSTSERV, c, MOD_HEAD)); /* And add it to the HOSTSERV cmd table */ + moduleAddCallback("test",time(NULL)+dotime("15s"),test,0,NULL); /* set a call-back function to exec in 3 mins time */ + moduleDelCallback("test"); + moduleAddAuthor(AUTHOR); /* tell Anope about the author */ + moduleAddVersion(VERSION); /* Tell Anope about the verison */ + return MOD_CONT; +} + +int hs_moo_show(User * u) +{ + notice(s_HostServ, u->nick, "MOO! - This command was loaded via a module!"); /* Just notice the user */ + return MOD_STOP; /* MOD_STOP means we will NOT pass control back to other */ +} /* modules waiting to handle the /hs moo command! */ + +int test(int argc, char **argv) { + alog("CallBack from hs_moo with %d paramaters",argc); + return MOD_CONT; +} + + +/***************************************************************************************************************************************/ +/* The code below here shows various ways of dealing with the module help system */ +/***************************************************************************************************************************************/ + +void myHostServHelp(User *u) { + notice(s_HostServ,u->nick, " MOO Moo's at the user!"); /* this will appear in the help list */ +} + +int myHostServMooHelp(User *u) { + notice(s_HostServ,u->nick,"Syntax: Moo"); /* this will be sent to everyone who does /msg hostserv help moo */ + notice(s_HostServ,u->nick,"This command is an example provided"); + notice(s_HostServ,u->nick,"by the Anope development team."); + return MOD_CONT; /* allow any other module's with help for /hs moo to run */ +} + +int myHostServMooRootHelp(User *u) { /* this will only be sent to ROOTS ONLY who /msg hostserv moo */ + myHostServMooAdminHelp(u); /* this line lets us show roots the ADMIN help as well as the root help */ + notice(s_HostServ,u->nick,"Only roots will see this part of the help"); + return MOD_CONT; +} + +int myHostServMooAdminHelp(User *u) { /* this will only be sent to ADMINS ONLY who /msg hostserv moo */ + myHostServMooOperHelp(u); /* this line lets us show admins the OPER help as well as the admin help */ + notice(s_HostServ,u->nick,"Only admins will see this part of the help"); + notice(s_HostServ,u->nick,"why not visit us on www.anope.org ?"); + return MOD_CONT; +} + +int myHostServMooOperHelp(User *u) { /* this will only be sent to OPERS ONLY who /msg hostserv moo */ + notice(s_HostServ,u->nick,"Only opers will see this part of the help"); + notice(s_HostServ,u->nick,"for more help/support with modules"); + notice(s_HostServ,u->nick,"visit us on irc.anope.org #anope! :)"); + return MOD_CONT; +} + +int myHostServMooRegHelp(User *u) { /* this will only be sent to REGULAR USERS ONLY who /msg hostserv moo */ + notice(s_HostServ,u->nick,"Only non-opers will see this part of the help"); + notice(s_HostServ,u->nick,"as we've left it hidden from opers"); + return MOD_CONT; +} + +/* EOF */ diff --git a/modules/ircd_catserv.c b/modules/ircd_catserv.c new file mode 100644 index 000000000..436b18dcc --- /dev/null +++ b/modules/ircd_catserv.c @@ -0,0 +1,128 @@ +/** + * Simple module to load up a client called CatServ and process commands for it + * This module is an example, and has no useful purpose! + * + * Please visit http://modules.anope.org for useful modules! + * + **/ + +#include "module.h" + +#define AUTHOR "Anope" +#define VERSION "1.1" + +int my_privmsg(char *source, int ac, char **av); +CommandHash *Catserv_cmdTable[MAX_CMD_HASH]; + +void addClient(char *nick, char *realname); +void addMessageList(void); +void delClient(void); +char *s_CatServ = "CatServ"; +void catserv(User * u, char *buf); + +int do_meow(User * u); +int do_purr(User * u); + +int AnopeInit(int argc, char **argv) +{ + Message *msg = NULL; + int status; + msg = createMessage("PRIVMSG", my_privmsg); + status = moduleAddMessage(msg, MOD_HEAD); + if (status == MOD_ERR_OK) { + addClient(s_CatServ, "meow!"); + addMessageList(); + } + moduleAddAuthor(AUTHOR); + moduleAddVersion(VERSION); + alog("ircd_catserv.so: loaded, message status [%d]", status); + return MOD_CONT; +} + +void AnopeFini(void) +{ + delClient(); +} + +int my_privmsg(char *source, int ac, char **av) +{ + User *u; + char *s; + + /* First, some basic checks */ + if (ac != 2) + return MOD_CONT; /* bleh */ + if (!(u = finduser(source))) { + return MOD_CONT; + } /* non-user source */ + if (*av[0] == '#') { + return MOD_CONT; + } + /* Channel message */ + /* we should prolly honour the ignore list here, but i cba for this... */ + s = strchr(av[0], '@'); + if (s) { + *s++ = 0; + if (stricmp(s, ServerName) != 0) + return MOD_CONT; + } + if ((stricmp(av[0], s_CatServ)) == 0) { /* its for US! */ + catserv(u, av[1]); + return MOD_STOP; + } else { /* ok it isnt us, let the old code have it */ + return MOD_CONT; + } +} + +void addClient(char *nick, char *realname) +{ + NEWNICK(nick, "catserv", "meow.meow.land", realname, "+", 1); +} + +void delClient(void) +{ + send_cmd(s_CatServ, "QUIT :Module Unloaded!"); +} + +void addMessageList(void) +{ + Command *c; + c = createCommand("meow", do_meow, NULL, -1, -1, -1, -1, -1); + addCommand(Catserv_cmdTable, c, MOD_UNIQUE); + c = createCommand("purr", do_purr, NULL, -1, -1, -1, -1, -1); + addCommand(Catserv_cmdTable, c, MOD_UNIQUE); +} + +/*****************************************************************************/ +/* Main CatServ routine. */ +void catserv(User * u, char *buf) +{ + char *cmd, *s; + + cmd = strtok(buf, " "); + + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) + s = "\1"; + notice(s_CatServ, u->nick, "\1PING %s", s); + } else if (skeleton) { + notice_lang(s_CatServ, u, SERVICE_OFFLINE, s_CatServ); + } else { + mod_run_cmd(s_CatServ, u, Catserv_cmdTable, cmd); + } +} + +int do_meow(User * u) +{ + notice(s_CatServ, u->nick, "MEOW!"); + return MOD_STOP; +} + +int do_purr(User * u) +{ + notice(s_CatServ, u->nick, "PURR!"); + return MOD_STOP; +} + diff --git a/modules/module.h b/modules/module.h new file mode 100644 index 000000000..336762955 --- /dev/null +++ b/modules/module.h @@ -0,0 +1,9 @@ +#include "../services.h" +#include "../commands.h" +#include "../language.h" +#include "../modules.h" + +#define MOD_UNIQUE 0 +#define MOD_HEAD 1 +#define MOD_TAIL 2 + |