summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2005-05-02 19:02:12 +0000
committerrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2005-05-02 19:02:12 +0000
commite0583918834a3f8683e430adf3923ea89d2a449a (patch)
treeff36ada734c3874d3be1a806e3a2b994386b54ed /src
parent49491770383e66f1b8074d8b0f80026e3086e9d8 (diff)
BUILD : 1.7.8 (753) BUGS : N/a NOTES : Merged anope-dev with trunk
git-svn-id: svn://svn.anope.org/anope/trunk@753 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@516 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r--src/Makefile36
-rwxr-xr-xsrc/bin/am8
-rw-r--r--src/botserv.c1575
-rw-r--r--src/channels.c65
-rw-r--r--src/chanserv.c4064
-rw-r--r--src/commands.c18
-rw-r--r--src/config.c402
-rw-r--r--src/core/Makefile45
-rw-r--r--src/core/Makefile.sub30
-rw-r--r--src/core/Makefile.win3225
-rw-r--r--src/core/bs_act.c93
-rw-r--r--src/core/bs_assign.c102
-rw-r--r--src/core/bs_badwords.c290
-rw-r--r--src/core/bs_bot.c372
-rw-r--r--src/core/bs_botlist.c108
-rw-r--r--src/core/bs_fantasy.c80
-rw-r--r--src/core/bs_fantasy_kick.c87
-rw-r--r--src/core/bs_fantasy_kickban.c90
-rw-r--r--src/core/bs_fantasy_owner.c87
-rw-r--r--src/core/bs_fantasy_seen.c136
-rw-r--r--src/core/bs_fantasy_unban.c78
-rw-r--r--src/core/bs_help.c67
-rw-r--r--src/core/bs_info.c282
-rw-r--r--src/core/bs_kick.c377
-rw-r--r--src/core/bs_say.c97
-rw-r--r--src/core/bs_set.c207
-rw-r--r--src/core/bs_unassign.c88
-rwxr-xr-xsrc/core/configure35
-rw-r--r--src/core/cs_access.c507
-rw-r--r--src/core/cs_akick.c584
-rw-r--r--src/core/cs_ban.c227
-rw-r--r--src/core/cs_clear.c375
-rw-r--r--src/core/cs_drop.c128
-rw-r--r--src/core/cs_forbid.c132
-rw-r--r--src/core/cs_getkey.c88
-rw-r--r--src/core/cs_getpass.c100
-rw-r--r--src/core/cs_help.c84
-rw-r--r--src/core/cs_identify.c118
-rw-r--r--src/core/cs_info.c249
-rw-r--r--src/core/cs_invite.c88
-rw-r--r--src/core/cs_kick.c152
-rw-r--r--src/core/cs_list.c172
-rw-r--r--src/core/cs_logout.c128
-rw-r--r--src/core/cs_modes.c392
-rw-r--r--src/core/cs_register.c199
-rw-r--r--src/core/cs_sendpass.c123
-rw-r--r--src/core/cs_set.c839
-rw-r--r--src/core/cs_status.c102
-rw-r--r--src/core/cs_suspend.c188
-rw-r--r--src/core/cs_topic.c119
-rw-r--r--src/core/cs_xop.c474
-rw-r--r--src/core/he_help.c76
-rw-r--r--src/core/hs_del.c91
-rw-r--r--src/core/hs_delall.c96
-rw-r--r--src/core/hs_group.c121
-rw-r--r--src/core/hs_help.c66
-rw-r--r--src/core/hs_list.c179
-rw-r--r--src/core/hs_off.c87
-rw-r--r--src/core/hs_on.c102
-rw-r--r--src/core/hs_set.c147
-rw-r--r--src/core/hs_setall.c150
-rw-r--r--src/core/ms_cancel.c105
-rw-r--r--src/core/ms_check.c118
-rw-r--r--src/core/ms_del.c199
-rw-r--r--src/core/ms_help.c66
-rw-r--r--src/core/ms_info.c231
-rw-r--r--src/core/ms_list.c197
-rw-r--r--src/core/ms_read.c201
-rw-r--r--src/core/ms_rsend.c119
-rw-r--r--src/core/ms_send.c73
-rw-r--r--src/core/ms_sendall.c95
-rw-r--r--src/core/ms_set.c265
-rw-r--r--src/core/ms_staff.c92
-rw-r--r--src/core/ns_access.c189
-rw-r--r--src/core/ns_alist.c186
-rw-r--r--src/core/ns_drop.c156
-rw-r--r--src/core/ns_forbid.c151
-rw-r--r--src/core/ns_getemail.c102
-rw-r--r--src/core/ns_getpass.c111
-rw-r--r--src/core/ns_ghost.c122
-rw-r--r--src/core/ns_group.c326
-rw-r--r--src/core/ns_help.c77
-rw-r--r--src/core/ns_identify.c160
-rw-r--r--src/core/ns_info.c272
-rw-r--r--src/core/ns_list.c230
-rw-r--r--src/core/ns_logout.c125
-rw-r--r--src/core/ns_recover.c111
-rw-r--r--src/core/ns_register.c486
-rw-r--r--src/core/ns_release.c107
-rw-r--r--src/core/ns_sendpass.c120
-rw-r--r--src/core/ns_set.c519
-rw-r--r--src/core/ns_status.c94
-rw-r--r--src/core/ns_suspend.c193
-rw-r--r--src/core/ns_update.c90
-rw-r--r--src/core/os_admin.c250
-rw-r--r--src/core/os_akill.c378
-rw-r--r--src/core/os_chankill.c130
-rw-r--r--src/core/os_chanlist.c116
-rw-r--r--src/core/os_clearmodes.c356
-rw-r--r--src/core/os_defcon.c167
-rw-r--r--src/core/os_global.c81
-rw-r--r--src/core/os_help.c66
-rw-r--r--src/core/os_ignore.c200
-rw-r--r--src/core/os_jupe.c88
-rw-r--r--src/core/os_kick.c100
-rw-r--r--src/core/os_killclones.c129
-rw-r--r--src/core/os_logonnews.c65
-rw-r--r--src/core/os_mode.c101
-rw-r--r--src/core/os_modinfo.c149
-rw-r--r--src/core/os_modlist.c182
-rw-r--r--src/core/os_modload.c96
-rw-r--r--src/core/os_modunload.c95
-rw-r--r--src/core/os_noop.c106
-rw-r--r--src/core/os_oline.c111
-rw-r--r--src/core/os_oper.c244
-rw-r--r--src/core/os_opernews.c65
-rw-r--r--src/core/os_quit.c82
-rw-r--r--src/core/os_randomnews.c65
-rw-r--r--src/core/os_raw.c77
-rw-r--r--src/core/os_reload.c84
-rw-r--r--src/core/os_restart.c89
-rw-r--r--src/core/os_session.c68
-rw-r--r--src/core/os_set.c262
-rw-r--r--src/core/os_sgline.c355
-rw-r--r--src/core/os_shutdown.c83
-rw-r--r--src/core/os_sqline.c355
-rw-r--r--src/core/os_staff.c158
-rw-r--r--src/core/os_stats.c400
-rw-r--r--src/core/os_svsnick.c126
-rw-r--r--src/core/os_szline.c350
-rw-r--r--src/core/os_umode.c116
-rw-r--r--src/core/os_update.c74
-rw-r--r--src/core/os_userlist.c121
-rw-r--r--src/datafiles.c4
-rw-r--r--src/encrypt.c4
-rw-r--r--src/events.c48
-rw-r--r--src/helpserv.c33
-rw-r--r--src/hostserv.c523
-rw-r--r--src/init.c22
-rw-r--r--src/ircd.c1114
-rw-r--r--src/main.c18
-rw-r--r--src/makefile.win3222
-rw-r--r--src/memoserv.c1164
-rw-r--r--src/messages.c7
-rw-r--r--src/misc.c2
-rw-r--r--src/modules.c431
-rwxr-xr-xsrc/modules/configure30
-rw-r--r--src/modules/cs_appendtopic.c188
-rw-r--r--src/modules/cs_enforce.c334
-rw-r--r--src/modules/cs_tban.c171
-rw-r--r--src/modules/demos/catserv/Makefile (renamed from src/modules/catserv/Makefile)0
-rw-r--r--src/modules/demos/catserv/README (renamed from src/modules/catserv/README)0
-rw-r--r--src/modules/demos/catserv/catserv_extern.h (renamed from src/modules/catserv/catserv_extern.h)0
-rw-r--r--src/modules/demos/catserv/catserv_messages.c (renamed from src/modules/catserv/catserv_messages.c)0
-rw-r--r--src/modules/demos/catserv/catserv_messages.h (renamed from src/modules/catserv/catserv_messages.h)0
-rw-r--r--src/modules/demos/catserv/ircd_catserv.c (renamed from src/modules/catserv/ircd_catserv.c)2
-rw-r--r--src/modules/demos/catserv/makefile.win32 (renamed from src/modules/catserv/makefile.win32)0
-rw-r--r--src/modules/demos/catserv/meow.c (renamed from src/modules/catserv/meow.c)0
-rw-r--r--src/modules/demos/catserv/meow.h (renamed from src/modules/catserv/meow.h)0
-rw-r--r--src/modules/demos/catserv/purr.c (renamed from src/modules/catserv/purr.c)0
-rw-r--r--src/modules/demos/catserv/purr.h (renamed from src/modules/catserv/purr.h)0
-rw-r--r--src/modules/demos/events.c82
-rw-r--r--src/modules/demos/hs_conf.c74
-rw-r--r--src/modules/demos/hs_moo.c (renamed from src/modules/hs_moo.c)2
-rw-r--r--src/modules/events.c53
-rw-r--r--src/modules/makefile.inc.win324
-rw-r--r--src/modules/makefile.win321
-rw-r--r--src/modules/module.h10
-rw-r--r--src/modules/ns_maxemail.c190
-rw-r--r--src/modules/ns_noop.c483
-rw-r--r--src/modules/os_info.c639
-rw-r--r--src/news.c2
-rw-r--r--src/nickserv.c2599
-rw-r--r--src/operserv.c3737
-rw-r--r--src/protocol/Makefile45
-rw-r--r--src/protocol/Makefile.sub30
-rw-r--r--src/protocol/Makefile.win3226
-rw-r--r--src/protocol/bahamut.c (renamed from src/bahamut.c)565
-rw-r--r--src/protocol/bahamut.h131
-rwxr-xr-xsrc/protocol/configure35
-rw-r--r--src/protocol/dreamforge.c (renamed from src/dreamforge.c)520
-rw-r--r--src/protocol/dreamforge.h111
-rw-r--r--src/protocol/hybrid.c (renamed from src/hybrid.c)522
-rw-r--r--src/protocol/hybrid.h115
-rw-r--r--src/protocol/inspircd.c1500
-rw-r--r--src/protocol/inspircd.h124
-rw-r--r--src/protocol/plexus.c (renamed from src/plexus.c)528
-rw-r--r--src/protocol/plexus.h126
-rw-r--r--src/protocol/ptlink.c (renamed from src/ptlink.c)521
-rw-r--r--src/protocol/ptlink.h149
-rw-r--r--src/protocol/rageircd.c (renamed from src/rageircd.c)564
-rw-r--r--src/protocol/rageircd.h113
-rw-r--r--src/protocol/ratbox.c (renamed from src/ratbox.c)542
-rw-r--r--src/protocol/ratbox.h119
-rw-r--r--src/protocol/shadowircd.c (renamed from src/shadowircd.c)545
-rw-r--r--src/protocol/shadowircd.h142
-rw-r--r--src/protocol/solidircd.c (renamed from src/solidircd.c)570
-rw-r--r--src/protocol/solidircd.h137
-rw-r--r--src/protocol/ultimate2.c (renamed from src/ultimate2.c)514
-rw-r--r--src/protocol/ultimate2.h120
-rw-r--r--src/protocol/ultimate3.c (renamed from src/ultimate3.c)541
-rw-r--r--src/protocol/ultimate3.h125
-rw-r--r--src/protocol/unreal31.c (renamed from src/unreal31.c)508
-rw-r--r--src/protocol/unreal31.h124
-rw-r--r--src/protocol/unreal32.c (renamed from src/unreal32.c)1060
-rw-r--r--src/protocol/unreal32.h153
-rw-r--r--src/protocol/viagra.c (renamed from src/viagra.c)548
-rw-r--r--src/protocol/viagra.h132
-rw-r--r--src/servers.c4
-rw-r--r--src/tools/Makefile.win323
-rw-r--r--src/tools/db-merger.c4
-rw-r--r--src/tools/epona2anope.c4
-rw-r--r--src/users.c8
213 files changed, 32664 insertions, 18412 deletions
diff --git a/src/Makefile b/src/Makefile
index f80b157ac..4fb8e9467 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,26 +2,21 @@ MYSQL_OBJ = $(MYSQL:.c=.o)
RDB_OBJ = $(RDB:.c=.o)
IRCD_OBJ = $(IRCDFILE:.c=.o)
OBJS = actions.o base64.o botserv.o channels.o chanserv.o commands.o compat.o \
- config.o datafiles.o encrypt.o events.o helpserv.o hostserv.o init.o language.o list.o log.o mail.o main.o \
+ config.o datafiles.o encrypt.o events.o helpserv.o hostserv.o init.o ircd.o language.o list.o log.o mail.o main.o \
memory.o memoserv.o messages.o misc.o modules.o news.o nickserv.o operserv.o \
- process.o send.o servers.o sessions.o slist.o sockutil.o timeout.o users.o \
- $(VSNPRINTF_O) $(RDB_OBJ) $(MYSQL_OBJ) $(IRCD_OBJ)
+ process.o send.o servers.o sessions.o slist.o sockutil.o timeout.o users.o \
+ $(VSNPRINTF_O) $(RDB_OBJ) $(MYSQL_OBJ)
SRCS = actions.c base64.c botserv.c channels.c chanserv.c commands.c compat.c \
- config.c datafiles.c encrypt.c events.c helpserv.c hostserv.c init.c language.c list.c log.c mail.c main.c \
+ config.c datafiles.c encrypt.c events.c helpserv.c hostserv.c init.c ircd.c language.c list.c log.c mail.c main.c \
memory.c memoserv.c messages.c misc.c modules.c news.c nickserv.c operserv.c \
process.c send.c servers.c sessions.c slist.c sockutil.c timeout.c users.c \
- $(VSNPRINTF_C) $(RDB) $(MYSQL) $(IRCDFILE)
+ $(VSNPRINTF_C) $(RDB) $(MYSQL)
INCLUDES = ../include/commands.h ../include/defs.h ../include/language.h \
../include/pseudo.h ../include/sysconf.h ../include/config.h \
../include/encrypt.h ../include/messages.h ../include/services.h \
../include/timeout.h ../include/datafiles.h ../include/extern.h \
- ../include/modules.h ../include/slist.h \
- ../include/dreamforge.h ../include/bahamut.h ../include/ultimate2.h \
- ../include/ultimate3.h ../include/hybrid.h ../include/ptlink.h ../include/unreal31.h \
- ../include/viagra.h ../include/rageircd.h ../include/unreal32.h ../include/solidircd.h \
- ../include/plexus.h ../include/shadowircd.h
-
+ ../include/modules.h ../include/slist.h
MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \
'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \
@@ -54,6 +49,7 @@ datafiles.o: datafiles.c $(INCLUDES)
encrypt.o: encrypt.c $(INCLUDES)
events.o: events.c $(INCLUDES)
init.o: init.c $(INCLUDES)
+ircd.o: ircd.c $(INCLUDES)
helpserv.o: helpserv.c $(INCLUDES)
hostserv.o: hostserv.c $(INCLUDES)
language.o: language.c $(INCLUDES)
@@ -84,15 +80,29 @@ rdb.o: rdb.c $(INCLUDES)
modules: DUMMY
(cd modules ; ./configure ; ${MAKE} ${MAKEARGS} all)
-clean: clean_modules
+protocols: DUMMY
+ (cd protocol ; ./configure ; ${MAKE} ${MAKEARGS} all)
+core: DUMMY
+ (cd core ; ./configure ; ${MAKE} ${MAKEARGS} all)
+
+clean: clean_modules clean_protocols clean_core
rm -f *.o services a.out
clean_modules:
@touch modules/Makefile.inc # Horribly ugly...
(cd modules ; ${MAKE} ${MAKEARGS} clean)
+clean_protocols:
+ @touch protocol/Makefile.inc
+ (cd protocol ; ${MAKE} ${MAKEARGS} clean)
+
+clean_core:
+ @touch core/Makefile.inc
+ (cd core ; ${MAKE} ${MAKEARGS} clean)
spotless: clean
(cd modules ; ${MAKE} ${MAKEARGS} distclean)
+ (cd protocol ; ${MAKE} ${MAKEARGS} distclean)
+ (cd core ; ${MAKE} ${MAKEARGS} distclean)
install: services
test -d ${BINDEST} || mkdir ${BINDEST}
@@ -110,6 +120,8 @@ install: services
test -d ${MODULE_PATH} || mkdir ${MODULE_PATH} ; \
test -d ${MODULE_PATH}/runtime || mkdir ${MODULE_PATH}/runtime ; \
(cd modules ; $(MAKE) install) ; \
+ (cd protocol ; ${MAKE} install) ; \
+ (cd core ; ${MAKE} install) ; \
fi
@if [ "$(RUNGROUP)" ] ; then \
echo chgrp -R $(RUNGROUP) $(DATDEST) ; \
diff --git a/src/bin/am b/src/bin/am
index c8e693b2e..44a091c1c 100755
--- a/src/bin/am
+++ b/src/bin/am
@@ -423,6 +423,14 @@ NOTES : ";
}
system("indent -kr -nut $prefix/*.c");
system("rm -f $prefix/*~");
+ if (-d "src/core") {
+ system("indent -kr -nut src/core/*.c");
+ system("rm -f src/core/*~");
+ }
+ if (-d "src/protocol") {
+ system("indent -kr -nut src/protocol/*.c");
+ system("rm -f src/protocol/*~");
+ }
print "*** Bumping the revision number...\n";
# Re-write the control file
diff --git a/src/botserv.c b/src/botserv.c
index 0eec8f8d9..961f07cee 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -17,15 +17,6 @@
#include "services.h"
#include "pseudo.h"
-/**
- * RFC: defination of a valid nick
- * nickname = ( letter / special ) *8( letter / digit / special / "-" )
- * letter = %x41-5A / %x61-7A ; A-Z / a-z
- * digit = %x30-39 ; 0-9
- * special = %x5B-60 / %x7B-7D ; "[", "]", "\", "`", "_", "^", "{", "|", "}"
- **/
-#define isvalidnick(c) ( isalnum(c) || ((c) >='\x5B' && (c) <='\x60') || ((c) >='\x7B' && (c) <='\x7D') || (c)=='-' )
-
/*************************************************************************/
@@ -36,62 +27,17 @@ int nbots = 0;
BotInfo *makebot(char *nick);
static UserData *get_user_data(Channel * c, User * u);
-static void unassign(User * u, ChannelInfo * ci);
+E void unassign(User * u, ChannelInfo * ci);
static void check_ban(ChannelInfo * ci, User * u, int ttbtype);
static void bot_kick(ChannelInfo * ci, User * u, int message, ...);
-static void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
- char *reason);
-static void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
- char *reason);
-static void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode,
- char *nick);
-
-static int do_help(User * u);
-static int do_bot(User * u);
-static int do_botlist(User * u);
-static int do_assign(User * u);
-static int do_unassign(User * u);
-static int do_info(User * u);
-static int do_set(User * u);
-static int do_kickcmd(User * u);
-static int do_badwords(User * u);
-static int do_say(User * u);
-static int do_act(User * u);
-void moduleAddBotServCmds(void);
+
+E void moduleAddBotServCmds(void);
/*************************************************************************/
/* *INDENT-OFF* */
void moduleAddBotServCmds(void) {
- Command *c;
- c = createCommand("HELP",do_help,NULL, -1,-1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("BOTLIST", do_botlist, NULL, BOT_HELP_BOTLIST, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("ASSIGN", do_assign, NULL, BOT_HELP_ASSIGN, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("UNASSIGN", do_unassign, NULL, BOT_HELP_UNASSIGN, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("INFO", do_info, NULL, BOT_HELP_INFO, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("SET", do_set, NULL, BOT_HELP_SET, -1,-1,BOT_SERVADMIN_HELP_SET, BOT_SERVADMIN_HELP_SET); addCoreCommand(BOTSERV,c);
- c = createCommand("SET DONTKICKOPS", NULL, NULL, BOT_HELP_SET_DONTKICKOPS, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("SET DONTKICKVOICES", NULL, NULL, BOT_HELP_SET_DONTKICKVOICES, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("SET FANTASY", NULL, NULL, BOT_HELP_SET_FANTASY, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("SET GREET", NULL, NULL, BOT_HELP_SET_GREET, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("SET SYMBIOSIS", NULL, NULL, BOT_HELP_SET_SYMBIOSIS, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK", do_kickcmd, NULL, BOT_HELP_KICK, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK BADWORDS", NULL, NULL, BOT_HELP_KICK_BADWORDS, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK BOLDS", NULL, NULL, BOT_HELP_KICK_BOLDS, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK CAPS", NULL, NULL, BOT_HELP_KICK_CAPS, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK COLORS", NULL, NULL, BOT_HELP_KICK_COLORS, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK FLOOD", NULL, NULL, BOT_HELP_KICK_FLOOD, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK REPEAT", NULL, NULL, BOT_HELP_KICK_REPEAT, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK REVERSES", NULL, NULL, BOT_HELP_KICK_REVERSES, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("KICK UNDERLINES", NULL, NULL, BOT_HELP_KICK_UNDERLINES, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("BADWORDS", do_badwords, NULL, BOT_HELP_BADWORDS, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("SAY", do_say, NULL, BOT_HELP_SAY, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
- c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -1,-1,-1,-1); addCoreCommand(BOTSERV,c);
-
- /* Services admins commands */
- c = createCommand("BOT", do_bot, is_services_admin, -1,-1, -1,BOT_SERVADMIN_HELP_BOT, BOT_SERVADMIN_HELP_BOT); addCoreCommand(BOTSERV,c);
- c = createCommand("SET NOBOT", NULL, NULL, -1,-1, -1,BOT_SERVADMIN_HELP_SET_NOBOT, BOT_SERVADMIN_HELP_SET_NOBOT); addCoreCommand(BOTSERV,c);
- c = createCommand("SET PRIVATE", NULL, NULL, -1,-1, -1,BOT_SERVADMIN_HELP_SET_PRIVATE, BOT_SERVADMIN_HELP_SET_PRIVATE); addCoreCommand(BOTSERV,c);
+ modules_core_init(BotServCoreNumber, BotServCoreModules);
}
/* *INDENT-ON* */
/*************************************************************************/
@@ -192,6 +138,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
int16 cstatus = 0;
char *cmd;
UserData *ud;
+ int found = 0;
if (!u || !buf || !ci) {
@@ -459,149 +406,13 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
&& check_access(u, ci, CA_FANTASIA)) {
cmd = strtok(buf, " ");
- if (cmd) {
- if (!stricmp(cmd, "!deowner") && ircd->owner) {
- if (is_founder(u, ci))
- bot_raw_mode(u, ci, ircd->ownerunset, u->nick);
- } else if (!stricmp(cmd, "!kb")) {
- char *target = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- if (!target && check_access(u, ci, CA_BANME)) {
- bot_raw_ban(u, ci, u->nick, "Requested");
- } else if (target && check_access(u, ci, CA_BAN)) {
- if (!stricmp(target, ci->bi->nick)) {
- bot_raw_ban(u, ci, u->nick, "Oops!");
- } else {
- if (!reason)
- bot_raw_ban(u, ci, target, "Requested");
- else
- bot_raw_ban(u, ci, target, reason);
- }
- }
- } else if ((!stricmp(cmd, "!kick")) || (!stricmp(cmd, "!k"))) {
- char *target = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- if (!target && check_access(u, ci, CA_KICKME)) {
- bot_raw_kick(u, ci, u->nick, "Requested");
- } else if (target && check_access(u, ci, CA_KICK)) {
- if (!stricmp(target, ci->bi->nick))
- bot_raw_kick(u, ci, u->nick, "Oops!");
- else if (!reason)
- bot_raw_kick(u, ci, target, "Requested");
- else
- bot_raw_kick(u, ci, target, reason);
- }
- } else if (!stricmp(cmd, "!owner") && ircd->owner) {
- if (is_founder(u, ci))
- bot_raw_mode(u, ci, ircd->ownerset, u->nick);
- } else if (!stricmp(cmd, "!seen")) {
- char *target = strtok(NULL, " ");
- char buf[BUFSIZE];
-
- if (target) {
- User *u2;
- NickAlias *na;
- ChanAccess *access;
-
- if (!stricmp(ci->bi->nick, target)) {
- /* If we look for the bot */
- snprintf(buf, sizeof(buf),
- getstring(u->na, BOT_SEEN_BOT), u->nick);
- anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
- buf);
- } else if (!(na = findnick(target))
- || (na->status & NS_VERBOTEN)) {
- /* If the nick is not registered or forbidden */
- snprintf(buf, sizeof(buf),
- getstring(u->na, BOT_SEEN_UNKNOWN),
- target);
- anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
- buf);
- } else if ((u2 = nc_on_chan(ci->c, na->nc))) {
- /* If the nick we're looking for is on the channel,
- * there are three possibilities: it's yourself,
- * it's the nick we look for, it's an alias of the
- * nick we look for.
- */
- if (u == u2 || (u->na && u->na->nc == na->nc))
- snprintf(buf, sizeof(buf),
- getstring(u->na, BOT_SEEN_YOU),
- u->nick);
- else if (!stricmp(u2->nick, target))
- snprintf(buf, sizeof(buf),
- getstring(u->na, BOT_SEEN_ON_CHANNEL),
- u2->nick);
- else
- snprintf(buf, sizeof(buf),
- getstring(u->na,
- BOT_SEEN_ON_CHANNEL_AS),
- target, u2->nick);
- anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
- buf);
- } else if ((access = get_access_entry(na->nc, ci))) {
- /* User is on the access list but not present actually.
- Special case: if access->last_seen is 0 it's that we
- never seen the user.
- */
- if (access->last_seen) {
- char durastr[192];
- duration(u->na, durastr, sizeof(durastr),
- time(NULL) - access->last_seen);
- snprintf(buf, sizeof(buf),
- getstring(u->na, BOT_SEEN_ON), target,
- durastr);
- } else {
- snprintf(buf, sizeof(buf),
- getstring(u->na, BOT_SEEN_NEVER),
- target);
- }
- anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
- buf);
- } else if (na->nc == ci->founder) {
- /* User is the founder of the channel */
- char durastr[192];
- duration(u->na, durastr, sizeof(durastr),
- time(NULL) - na->last_seen);
- snprintf(buf, sizeof(buf),
- getstring(u->na, BOT_SEEN_ON), target,
- durastr);
- anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
- buf);
- } else {
- /* All other cases */
- snprintf(buf, sizeof(buf),
- getstring(u->na, BOT_SEEN_UNKNOWN),
- target);
- anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
- buf);
- }
- }
- } else if (!stricmp(cmd, "!unban")
- && check_access(u, ci, CA_UNBAN)) {
- char *target = strtok(NULL, " ");
-
- if (!target)
- common_unban(ci, u->nick);
- else
- common_unban(ci, target);
- } else {
- CSModeUtil *util = csmodeutils;
-
- do {
- if (!stricmp(cmd, util->bsname)) {
- char *target = strtok(NULL, " ");
-
- if (!target
- && check_access(u, ci, util->levelself))
- bot_raw_mode(u, ci, util->mode, u->nick);
- else if (target
- && check_access(u, ci, util->level))
- bot_raw_mode(u, ci, util->mode, target);
- }
- } while ((++util)->name != NULL);
- }
+ if (cmd && (cmd[0] == '!')) {
+ char *params = strtok(NULL, "");
+ if (params)
+ send_event(EVENT_BOT_FANTASY, 4, cmd, u->nick, ci->name,
+ params);
+ else
+ send_event(EVENT_BOT_FANTASY, 3, cmd, u->nick, ci->name);
}
}
}
@@ -732,7 +543,7 @@ void save_bs_rdb_dbase(void)
/* Inserts a bot in the bot list. I can't be much explicit mh? */
-static void insert_bot(BotInfo * bi)
+void insert_bot(BotInfo * bi)
{
BotInfo *ptr, *prev;
@@ -772,46 +583,9 @@ BotInfo *makebot(char *nick)
/*************************************************************************/
-static void change_bot_nick(BotInfo * bi, char *newnick)
-{
- if (bi->next)
- bi->next->prev = bi->prev;
- if (bi->prev)
- bi->prev->next = bi->next;
- else
- botlists[tolower(*bi->nick)] = bi->next;
-
- if (bi->nick)
- free(bi->nick);
- bi->nick = sstrdup(newnick);
-
- insert_bot(bi);
-}
/*************************************************************************/
-static int delbot(BotInfo * bi)
-{
- cs_remove_bot(bi);
-
- if (bi->next)
- bi->next->prev = bi->prev;
- if (bi->prev)
- bi->prev->next = bi->next;
- else
- botlists[tolower(*bi->nick)] = bi->next;
-
- nbots--;
-
- free(bi->nick);
- free(bi->user);
- free(bi->host);
- free(bi->real);
-
- free(bi);
-
- return 1;
-}
/*************************************************************************/
@@ -847,9 +621,9 @@ BotInfo *findbot(char *nick)
/* Unassign a bot from a channel. Assumes u, ci and ci->bi are not NULL */
-static void unassign(User * u, ChannelInfo * ci)
+void unassign(User * u, ChannelInfo * ci)
{
- send_event(EVENT_BOT_UNASSIGN, ci->name);
+ send_event(EVENT_BOT_UNASSIGN, 2, ci->name, ci->bi->nick);
if (ci->c && ci->c->usercount >= BSMinUsers) {
anope_cmd_part(ci->bi->nick, ci->name, "UNASSIGN from %s",
@@ -989,7 +763,7 @@ void bot_join(ChannelInfo * ci)
}
/* Should we be invited? */
- if ((ci->c->mode & CMODE_i)
+ if ((ci->c->mode & anope_get_invite_mode())
|| (ci->c->limit && ci->c->usercount >= ci->c->limit))
anope_cmd_notice_ops(NULL, ci->c->name,
"%s invited %s into the channel.",
@@ -997,7 +771,7 @@ void bot_join(ChannelInfo * ci)
}
anope_cmd_join(ci->bi->nick, ci->c->name, ci->c->creation_time);
anope_cmd_bot_chan_mode(ci->bi->nick, ci->c->name);
- send_event(EVENT_BOT_JOIN, ci->name);
+ send_event(EVENT_BOT_JOIN, 2, ci->name, ci->bi->nick);
}
/*************************************************************************/
@@ -1078,8 +852,8 @@ static void bot_kick(ChannelInfo * ci, User * u, int message, ...)
/* Makes a simple ban and kicks the target */
-static void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
- char *reason)
+void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
+ char *reason)
{
int ac;
char *av[4];
@@ -1154,8 +928,8 @@ static void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
/* Makes a kick with a "dynamic" reason ;) */
-static void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
- char *reason)
+void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
+ char *reason)
{
char *av[3];
User *u = finduser(nick);
@@ -1194,8 +968,8 @@ static void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
/* Makes a mode operation on a channel for a nick */
-static void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode,
- char *nick)
+void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode,
+ char *nick)
{
char *av[4];
int ac;
@@ -1242,1307 +1016,6 @@ static void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode,
}
/*************************************************************************/
-
-static int do_help(User * u)
-{
- char *cmd = strtok(NULL, "");
-
- if (!cmd) {
- notice_help(s_BotServ, u, BOT_HELP, BSMinUsers);
- if (is_services_oper(u))
- notice_help(s_BotServ, u, BOT_SERVADMIN_HELP);
- moduleDisplayHelp(4, u);
- } else {
- mod_help_cmd(s_BotServ, u, BOTSERV, cmd);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_bot(User * u)
-{
- BotInfo *bi;
- char *cmd = strtok(NULL, " ");
- char *ch = NULL;
-
- if (!cmd)
- syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
- else if (!stricmp(cmd, "ADD")) {
- char *nick = strtok(NULL, " ");
- char *user = strtok(NULL, " ");
- char *host = strtok(NULL, " ");
- char *real = strtok(NULL, "");
-
- if (!nick || !user || !host || !real)
- syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
- else if (readonly)
- notice_lang(s_BotServ, u, BOT_BOT_READONLY);
- else if (findbot(nick))
- notice_lang(s_BotServ, u, BOT_BOT_ALREADY_EXISTS, nick);
- else {
- NickAlias *na;
-
- /**
- * Check the nick is valid re RFC 2812
- **/
- if (isdigit(nick[0]) || nick[0] == '-') {
- notice_lang(s_BotServ, u, BOT_BAD_NICK);
- return MOD_CONT;
- }
- for (ch = nick; *ch && (ch - nick) < NICKMAX; ch++) {
- if (!isvalidnick(*ch)) {
- notice_lang(s_BotServ, u, BOT_BAD_NICK);
- return MOD_CONT;
- }
- }
-
- /* check for hardcored ircd forbidden nicks */
- if (!anope_valid_nick(nick)) {
- notice_lang(s_BotServ, u, BOT_BAD_NICK);
- return MOD_CONT;
- }
-
- if (!isValidHost(host, 3)) {
- notice_lang(s_BotServ, u, BOT_BAD_HOST);
- return MOD_CONT;
- }
- for (ch = user; *ch && (ch - user) < USERMAX; ch++) {
- if (!isalnum(*ch)) {
- notice_lang(s_BotServ, u, BOT_BAD_IDENT);
- return MOD_CONT;
- }
- }
-
- /**
- * Check the host is valid re RFC 2812
- **/
-
- /* Check whether it's a services client's nick and return if so - Certus */
- /* use nickIsServices reduce the total number lines of code - TSL */
-
- if (nickIsServices(nick, 0)) {
- notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED);
- return MOD_CONT;
- }
-
- /* We check whether the nick is registered, and inform the user
- * if so. You need to drop the nick manually before you can use
- * it as a bot nick from now on -GD
- */
- if ((na = findnick(nick))) {
- notice_lang(s_BotServ, u, NICK_ALREADY_REGISTERED, nick);
- return MOD_CONT;
- }
-
- bi = makebot(nick);
- if (!bi) {
- notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED);
- return MOD_CONT;
- }
-
- bi->user = sstrdup(user);
- bi->host = sstrdup(host);
- bi->real = sstrdup(real);
- bi->created = time(NULL);
- bi->chancount = 0;
-
- /* We check whether user with this nick is online, and kill it if so */
- EnforceQlinedNick(nick, s_BotServ);
-
- /* We make the bot online, ready to serve */
- anope_cmd_bot_nick(bi->nick, bi->user, bi->host, bi->real,
- ircd->botserv_bot_mode);
-
- notice_lang(s_BotServ, u, BOT_BOT_ADDED, bi->nick, bi->user,
- bi->host, bi->real);
-
- send_event(EVENT_BOT_CREATE, bi->nick);
- }
- } else if (!stricmp(cmd, "CHANGE")) {
- char *oldnick = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
- char *user = strtok(NULL, " ");
- char *host = strtok(NULL, " ");
- char *real = strtok(NULL, "");
-
- if (!oldnick || !nick)
- syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
- else if (readonly)
- notice_lang(s_BotServ, u, BOT_BOT_READONLY);
- else if (!(bi = findbot(oldnick)))
- notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, oldnick);
- else {
- NickAlias *na;
-
- /* Checks whether there *are* changes.
- * Case sensitive because we may want to change just the case.
- * And we must finally check that the nick is not already
- * taken by another bot.
- */
- if (!strcmp(bi->nick, nick)
- && ((user) ? !strcmp(bi->user, user) : 1)
- && ((host) ? !strcmp(bi->host, host) : 1)
- && ((real) ? !strcmp(bi->real, real) : 1)) {
- notice_lang(s_BotServ, u, BOT_BOT_ANY_CHANGES);
- return MOD_CONT;
- }
-
- /* Check whether it's a services client's nick and return if so - Certus */
- /* use nickIsServices() to reduce the number of lines of code - TSL */
- if (nickIsServices(nick, 0)) {
- notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED);
- return MOD_CONT;
- }
-
- /**
- * Check the nick is valid re RFC 2812
- **/
- if (isdigit(nick[0]) || nick[0] == '-') {
- notice_lang(s_BotServ, u, BOT_BAD_NICK);
- return MOD_CONT;
- }
- for (ch = nick; *ch && (ch - nick) < NICKMAX; ch++) {
- if (!isvalidnick(*ch)) {
- notice_lang(s_BotServ, u, BOT_BAD_NICK);
- return MOD_CONT;
- }
- }
-
- /* check for hardcored ircd forbidden nicks */
- if (!anope_valid_nick(nick)) {
- notice_lang(s_BotServ, u, BOT_BAD_NICK);
- return MOD_CONT;
- }
-
- if (!isValidHost(host, 3)) {
- notice_lang(s_BotServ, u, BOT_BAD_HOST);
- return MOD_CONT;
- }
-
- for (ch = user; *ch && (ch - user) < USERMAX; ch++) {
- if (!isalnum(*ch)) {
- notice_lang(s_BotServ, u, BOT_BAD_IDENT);
- return MOD_CONT;
- }
- }
-
- if (stricmp(bi->nick, nick) && findbot(nick)) {
- notice_lang(s_BotServ, u, BOT_BOT_ALREADY_EXISTS, nick);
- return MOD_CONT;
- }
-
- if (stricmp(bi->nick, nick)) {
- /* We check whether the nick is registered, and inform the user
- * if so. You need to drop the nick manually before you can use
- * it as a bot nick from now on -GD
- */
- if ((na = findnick(nick))) {
- notice_lang(s_BotServ, u, NICK_ALREADY_REGISTERED,
- nick);
- return MOD_CONT;
- }
-
- /* The new nick is really different, so we remove the Q line for
- the old nick. */
- if (ircd->sqline) {
- anope_cmd_unsqline(bi->nick);
- }
-
- /* We check whether user with this nick is online, and kill it if so */
- EnforceQlinedNick(nick, s_BotServ);
- }
-
- if (strcmp(nick, bi->nick))
- change_bot_nick(bi, nick);
-
- if (user && strcmp(user, bi->user)) {
- free(bi->user);
- bi->user = sstrdup(user);
- }
- if (host && strcmp(host, bi->host)) {
- free(bi->host);
- bi->host = sstrdup(host);
- }
- if (real && strcmp(real, bi->real)) {
- free(bi->real);
- bi->real = sstrdup(real);
- }
-
- /* If only the nick changes, we just make the bot change his nick,
- else we must make it quit and rejoin. */
- if (!user)
- anope_cmd_chg_nick(oldnick, bi->nick);
- else {
- anope_cmd_quit(oldnick, "Quit: Be right back");
-
- anope_cmd_bot_nick(bi->nick, bi->user, bi->host, bi->real,
- ircd->botserv_bot_mode);
- bot_rejoin_all(bi);
- }
-
- notice_lang(s_BotServ, u, BOT_BOT_CHANGED, oldnick, bi->nick,
- bi->user, bi->host, bi->real);
-
- send_event(EVENT_BOT_CHANGE, bi->nick);
- }
- } else if (!stricmp(cmd, "DEL")) {
- char *nick = strtok(NULL, " ");
-
- if (!nick)
- syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
- else if (readonly)
- notice_lang(s_BotServ, u, BOT_BOT_READONLY);
- else if (!(bi = findbot(nick)))
- notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick);
- else {
- send_event(EVENT_BOT_DEL, bi->nick);
- anope_cmd_quit(bi->nick,
- "Quit: Help! I'm being deleted by %s!",
- u->nick);
- if (ircd->sqline) {
- anope_cmd_unsqline(bi->nick);
- }
- delbot(bi);
-
- notice_lang(s_BotServ, u, BOT_BOT_DELETED, nick);
- }
- } else if (!stricmp(cmd, "LIST"))
- do_botlist(u);
- else
- syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
-
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_botlist(User * u)
-{
- int i, count = 0;
- BotInfo *bi;
-
- if (!nbots) {
- notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY);
- return MOD_CONT;
- }
-
- for (i = 0; i < 256; i++) {
- for (bi = botlists[i]; bi; bi = bi->next) {
- if (!(bi->flags & BI_PRIVATE)) {
- if (!count)
- notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER);
- count++;
- notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick,
- bi->user, bi->host);
- }
- }
- }
-
- if (is_oper(u) && count < nbots) {
- notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER);
-
- for (i = 0; i < 256; i++) {
- for (bi = botlists[i]; bi; bi = bi->next) {
- if (bi->flags & BI_PRIVATE) {
- notice_user(s_BotServ, u, " %-15s (%s@%s)",
- bi->nick, bi->user, bi->host);
- count++;
- }
- }
- }
- }
-
- if (!count)
- notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY);
- else
- notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_assign(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
- BotInfo *bi;
- ChannelInfo *ci;
-
- if (readonly)
- notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY);
- else if (!chan || !nick)
- syntax_error(s_BotServ, u, "ASSIGN", BOT_ASSIGN_SYNTAX);
- else if (!(bi = findbot(nick)))
- notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick);
- else if (bi->flags & BI_PRIVATE && !is_oper(u))
- notice_lang(s_BotServ, u, PERMISSION_DENIED);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- else if (ci->flags & CI_VERBOTEN)
- notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
- else if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0))
- notice_lang(s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan);
- else if ((ci->botflags & BS_NOBOT)
- || (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u)))
- notice_lang(s_BotServ, u, PERMISSION_DENIED);
- else {
- if (ci->bi)
- unassign(u, ci);
- ci->bi = bi;
- bi->chancount++;
- if (ci->c && ci->c->usercount >= BSMinUsers) {
- bot_join(ci);
- }
- notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name);
- send_event(EVENT_BOT_ASSIGN, ci->name);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_unassign(User * u)
-{
- char *chan = strtok(NULL, " ");
- ChannelInfo *ci;
-
- if (readonly)
- notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY);
- else if (!chan)
- syntax_error(s_BotServ, u, "UNASSIGN", BOT_UNASSIGN_SYNTAX);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- else if (ci->flags & CI_VERBOTEN)
- notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
- else if (!is_services_admin(u) && !check_access(u, ci, CA_ASSIGN))
- notice_lang(s_BotServ, u, ACCESS_DENIED);
- else {
- if (ci->bi)
- unassign(u, ci);
- notice_lang(s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static void send_bot_channels(User * u, BotInfo * bi)
-{
- int i;
- ChannelInfo *ci;
- char buf[307], *end;
-
- *buf = 0;
- end = buf;
-
- for (i = 0; i < 256; i++) {
- for (ci = chanlists[i]; ci; ci = ci->next) {
- if (ci->bi == bi) {
- if (strlen(buf) + strlen(ci->name) > 300) {
- notice_user(s_BotServ, u, buf);
- *buf = 0;
- end = buf;
- }
- end +=
- snprintf(end, sizeof(buf) - (end - buf), " %s ",
- ci->name);
- }
- }
- }
-
- if (*buf)
- notice_user(s_BotServ, u, buf);
- return;
-}
-
-static int do_info(User * u)
-{
- BotInfo *bi;
- ChannelInfo *ci;
- char *query = strtok(NULL, " ");
-
- int need_comma = 0, is_servadmin = is_services_admin(u);
- char buf[BUFSIZE], *end;
- const char *commastr = getstring(u->na, COMMA_SPACE);
-
- if (!query)
- syntax_error(s_BotServ, u, "INFO", BOT_INFO_SYNTAX);
- else if ((bi = findbot(query))) {
- char buf[BUFSIZE];
- struct tm *tm;
-
- notice_lang(s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick);
- notice_lang(s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host);
- notice_lang(s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real);
- tm = localtime(&bi->created);
- strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
- notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf);
- notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS,
- getstring(u->na,
- (bi->
- flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE :
- BOT_INFO_OPT_NONE));
- notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount);
-
- if (is_services_admin(u))
- send_bot_channels(u, bi);
- } else if ((ci = cs_findchan(query))) {
- if (!is_servadmin && !is_founder(u, ci)) {
- notice_lang(s_BotServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
- if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, query);
- return MOD_CONT;
- }
-
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_HEADER, ci->name);
- if (ci->bi)
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE);
-
- if (ci->botflags & BS_KICK_BADWORDS) {
- if (ci->ttb[TTB_BADWORDS])
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->ttb[TTB_BADWORDS]);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS,
- getstring(u->na, BOT_INFO_ACTIVE));
- } else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS,
- getstring(u->na, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_BOLDS) {
- if (ci->ttb[TTB_BOLDS])
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->ttb[TTB_BOLDS]);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS,
- getstring(u->na, BOT_INFO_ACTIVE));
- } else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS,
- getstring(u->na, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_CAPS) {
- if (ci->ttb[TTB_CAPS])
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->ttb[TTB_CAPS], ci->capsmin,
- ci->capspercent);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON,
- getstring(u->na, BOT_INFO_ACTIVE), ci->capsmin,
- ci->capspercent);
- } else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF,
- getstring(u->na, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_COLORS) {
- if (ci->ttb[TTB_COLORS])
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->ttb[TTB_COLORS]);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS,
- getstring(u->na, BOT_INFO_ACTIVE));
- } else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS,
- getstring(u->na, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_FLOOD) {
- if (ci->ttb[TTB_FLOOD])
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->ttb[TTB_FLOOD], ci->floodlines,
- ci->floodsecs);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->floodlines, ci->floodsecs);
- } else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF,
- getstring(u->na, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_REPEAT) {
- if (ci->ttb[TTB_REPEAT])
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->ttb[TTB_REPEAT], ci->repeattimes);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->repeattimes);
- } else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF,
- getstring(u->na, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_REVERSES) {
- if (ci->ttb[TTB_REVERSES])
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->ttb[TTB_REVERSES]);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES,
- getstring(u->na, BOT_INFO_ACTIVE));
- } else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES,
- getstring(u->na, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_UNDERLINES) {
- if (ci->ttb[TTB_UNDERLINES])
- notice_lang(s_BotServ, u,
- BOT_INFO_CHAN_KICK_UNDERLINES_BAN,
- getstring(u->na, BOT_INFO_ACTIVE),
- ci->ttb[TTB_UNDERLINES]);
- else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES,
- getstring(u->na, BOT_INFO_ACTIVE));
- } else
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES,
- getstring(u->na, BOT_INFO_INACTIVE));
-
- end = buf;
- *end = 0;
- if (ci->botflags & BS_DONTKICKOPS) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s",
- getstring(u->na, BOT_INFO_OPT_DONTKICKOPS));
- need_comma = 1;
- }
- if (ci->botflags & BS_DONTKICKVOICES) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, BOT_INFO_OPT_DONTKICKVOICES));
- need_comma = 1;
- }
- if (ci->botflags & BS_FANTASY) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, BOT_INFO_OPT_FANTASY));
- need_comma = 1;
- }
- if (ci->botflags & BS_GREET) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, BOT_INFO_OPT_GREET));
- need_comma = 1;
- }
- if (ci->botflags & BS_NOBOT) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, BOT_INFO_OPT_NOBOT));
- need_comma = 1;
- }
- if (ci->botflags & BS_SYMBIOSIS) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, BOT_INFO_OPT_SYMBIOSIS));
- need_comma = 1;
- }
- notice_lang(s_BotServ, u, BOT_INFO_CHAN_OPTIONS,
- *buf ? buf : getstring(u->na, BOT_INFO_OPT_NONE));
-
- } else
- notice_lang(s_BotServ, u, BOT_INFO_NOT_FOUND, query);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *option = strtok(NULL, " ");
- char *value = strtok(NULL, " ");
- int is_servadmin = is_services_admin(u);
-
- ChannelInfo *ci;
-
- if (readonly)
- notice_lang(s_BotServ, u, BOT_SET_DISABLED);
- else if (!chan || !option || !value)
- syntax_error(s_BotServ, u, "SET", BOT_SET_SYNTAX);
- else if (is_servadmin && !stricmp(option, "PRIVATE")) {
- BotInfo *bi;
-
- if ((bi = findbot(chan))) {
- if (!stricmp(value, "ON")) {
- bi->flags |= BI_PRIVATE;
- notice_lang(s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick);
- } else if (!stricmp(value, "OFF")) {
- bi->flags &= ~BI_PRIVATE;
- notice_lang(s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick);
- } else {
- syntax_error(s_BotServ, u, "SET PRIVATE",
- BOT_SET_PRIVATE_SYNTAX);
- }
- } else {
- notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, chan);
- }
- return MOD_CONT;
- } else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- else if (ci->flags & CI_VERBOTEN)
- notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
- else if (!is_servadmin && !check_access(u, ci, CA_SET))
- notice_lang(s_BotServ, u, ACCESS_DENIED);
- else {
- if (!stricmp(option, "DONTKICKOPS")) {
- if (!stricmp(value, "ON")) {
- ci->botflags |= BS_DONTKICKOPS;
- notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_ON,
- ci->name);
- } else if (!stricmp(value, "OFF")) {
- ci->botflags &= ~BS_DONTKICKOPS;
- notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_OFF,
- ci->name);
- } else {
- syntax_error(s_BotServ, u, "SET DONTKICKOPS",
- BOT_SET_DONTKICKOPS_SYNTAX);
- }
- } else if (!stricmp(option, "DONTKICKVOICES")) {
- if (!stricmp(value, "ON")) {
- ci->botflags |= BS_DONTKICKVOICES;
- notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_ON,
- ci->name);
- } else if (!stricmp(value, "OFF")) {
- ci->botflags &= ~BS_DONTKICKVOICES;
- notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF,
- ci->name);
- } else {
- syntax_error(s_BotServ, u, "SET DONTKICKVOICES",
- BOT_SET_DONTKICKVOICES_SYNTAX);
- }
- } else if (!stricmp(option, "FANTASY")) {
- if (!stricmp(value, "ON")) {
- ci->botflags |= BS_FANTASY;
- notice_lang(s_BotServ, u, BOT_SET_FANTASY_ON, ci->name);
- } else if (!stricmp(value, "OFF")) {
- ci->botflags &= ~BS_FANTASY;
- notice_lang(s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name);
- } else {
- syntax_error(s_BotServ, u, "SET FANTASY",
- BOT_SET_FANTASY_SYNTAX);
- }
- } else if (!stricmp(option, "GREET")) {
- if (!stricmp(value, "ON")) {
- ci->botflags |= BS_GREET;
- notice_lang(s_BotServ, u, BOT_SET_GREET_ON, ci->name);
- } else if (!stricmp(value, "OFF")) {
- ci->botflags &= ~BS_GREET;
- notice_lang(s_BotServ, u, BOT_SET_GREET_OFF, ci->name);
- } else {
- syntax_error(s_BotServ, u, "SET GREET",
- BOT_SET_GREET_SYNTAX);
- }
- } else if (is_servadmin && !stricmp(option, "NOBOT")) {
- if (!stricmp(value, "ON")) {
- ci->botflags |= BS_NOBOT;
- if (ci->bi)
- unassign(u, ci);
- notice_lang(s_BotServ, u, BOT_SET_NOBOT_ON, ci->name);
- } else if (!stricmp(value, "OFF")) {
- ci->botflags &= ~BS_NOBOT;
- notice_lang(s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name);
- } else {
- syntax_error(s_BotServ, u, "SET NOBOT",
- BOT_SET_NOBOT_SYNTAX);
- }
- } else if (!stricmp(option, "SYMBIOSIS")) {
- if (!stricmp(value, "ON")) {
- ci->botflags |= BS_SYMBIOSIS;
- notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name);
- } else if (!stricmp(value, "OFF")) {
- ci->botflags &= ~BS_SYMBIOSIS;
- notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name);
- } else {
- syntax_error(s_BotServ, u, "SET SYMBIOSIS",
- BOT_SET_SYMBIOSIS_SYNTAX);
- }
- } else {
- notice_help(s_BotServ, u, BOT_SET_UNKNOWN, option);
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_kickcmd(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *option = strtok(NULL, " ");
- char *value = strtok(NULL, " ");
- char *ttb = strtok(NULL, " ");
-
- ChannelInfo *ci;
-
- if (readonly)
- notice_lang(s_BotServ, u, BOT_KICK_DISABLED);
- else if (!chan || !option || !value)
- syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
- else if (stricmp(value, "ON") && stricmp(value, "OFF"))
- syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- else if (ci->flags & CI_VERBOTEN)
- notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
- else if (!is_services_admin(u) && !check_access(u, ci, CA_SET))
- notice_lang(s_BotServ, u, ACCESS_DENIED);
- else {
- if (!stricmp(option, "BADWORDS")) {
- if (!stricmp(value, "ON")) {
- if (ttb) {
- ci->ttb[TTB_BADWORDS] =
- strtol(ttb, (char **) NULL, 10);
- /* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */
- if (errno == ERANGE || errno == EINVAL
- || ci->ttb[TTB_BADWORDS] < 0) {
- /* leaving the debug behind since we might want to know what these are */
- if (debug) {
- alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BADWORDS]);
- }
- /* reset the value back to 0 - TSL */
- ci->ttb[TTB_BADWORDS] = 0;
- notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
- return MOD_CONT;
- }
- } else {
- ci->ttb[TTB_BADWORDS] = 0;
- }
- ci->botflags |= BS_KICK_BADWORDS;
- if (ci->ttb[TTB_BADWORDS])
- notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN,
- ci->ttb[TTB_BADWORDS]);
- else
- notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON);
- } else {
- ci->botflags &= ~BS_KICK_BADWORDS;
- notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_OFF);
- }
- } else if (!stricmp(option, "BOLDS")) {
- if (!stricmp(value, "ON")) {
- if (ttb) {
- ci->ttb[TTB_BOLDS] = strtol(ttb, (char **) NULL, 10);
- if (errno == ERANGE || errno == EINVAL
- || ci->ttb[TTB_BOLDS] < 0) {
- if (debug) {
- alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BOLDS]);
- }
- ci->ttb[TTB_BOLDS] = 0;
- notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
- return MOD_CONT;
- }
- } else
- ci->ttb[TTB_BOLDS] = 0;
- ci->botflags |= BS_KICK_BOLDS;
- if (ci->ttb[TTB_BOLDS])
- notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON_BAN,
- ci->ttb[TTB_BOLDS]);
- else
- notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON);
- } else {
- ci->botflags &= ~BS_KICK_BOLDS;
- notice_lang(s_BotServ, u, BOT_KICK_BOLDS_OFF);
- }
- } else if (!stricmp(option, "CAPS")) {
- if (!stricmp(value, "ON")) {
- char *min = strtok(NULL, " ");
- char *percent = strtok(NULL, " ");
-
- if (ttb) {
- ci->ttb[TTB_CAPS] = strtol(ttb, (char **) NULL, 10);
- if (errno == ERANGE || errno == EINVAL
- || ci->ttb[TTB_CAPS] < 0) {
- if (debug) {
- alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_CAPS]);
- }
- ci->ttb[TTB_CAPS] = 0;
- notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
- return MOD_CONT;
- }
- } else
- ci->ttb[TTB_CAPS] = 0;
-
- if (!min)
- ci->capsmin = 10;
- else
- ci->capsmin = atol(min);
- if (ci->capsmin < 1)
- ci->capsmin = 10;
-
- if (!percent)
- ci->capspercent = 25;
- else
- ci->capspercent = atol(percent);
- if (ci->capspercent < 1 || ci->capspercent > 100)
- ci->capspercent = 25;
-
- ci->botflags |= BS_KICK_CAPS;
- if (ci->ttb[TTB_CAPS])
- notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON_BAN,
- ci->capsmin, ci->capspercent,
- ci->ttb[TTB_CAPS]);
- else
- notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON,
- ci->capsmin, ci->capspercent);
- } else {
- ci->botflags &= ~BS_KICK_CAPS;
- notice_lang(s_BotServ, u, BOT_KICK_CAPS_OFF);
- }
- } else if (!stricmp(option, "COLORS")) {
- if (!stricmp(value, "ON")) {
- if (ttb) {
- ci->ttb[TTB_COLORS] = strtol(ttb, (char **) NULL, 10);
- if (errno == ERANGE || errno == EINVAL
- || ci->ttb[TTB_COLORS] < 0) {
- if (debug) {
- alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_COLORS]);
- }
- ci->ttb[TTB_COLORS] = 0;
- notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
- return MOD_CONT;
- }
- } else
- ci->ttb[TTB_COLORS] = 0;
- ci->botflags |= BS_KICK_COLORS;
- if (ci->ttb[TTB_COLORS])
- notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON_BAN,
- ci->ttb[TTB_COLORS]);
- else
- notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON);
- } else {
- ci->botflags &= ~BS_KICK_COLORS;
- notice_lang(s_BotServ, u, BOT_KICK_COLORS_OFF);
- }
- } else if (!stricmp(option, "FLOOD")) {
- if (!stricmp(value, "ON")) {
- char *lines = strtok(NULL, " ");
- char *secs = strtok(NULL, " ");
-
- if (ttb) {
- ci->ttb[TTB_FLOOD] = strtol(ttb, (char **) NULL, 10);
- if (errno == ERANGE || errno == EINVAL
- || ci->ttb[TTB_FLOOD] < 0) {
- if (debug) {
- alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_FLOOD]);
- }
- ci->ttb[TTB_FLOOD] = 0;
- notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
- return MOD_CONT;
- }
- } else
- ci->ttb[TTB_FLOOD] = 0;
-
- if (!lines)
- ci->floodlines = 6;
- else
- ci->floodlines = atol(lines);
- if (ci->floodlines < 2)
- ci->floodlines = 6;
-
- if (!secs)
- ci->floodsecs = 10;
- else
- ci->floodsecs = atol(secs);
- if (ci->floodsecs < 1 || ci->floodsecs > BSKeepData)
- ci->floodsecs = 10;
-
- ci->botflags |= BS_KICK_FLOOD;
- if (ci->ttb[TTB_FLOOD])
- notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON_BAN,
- ci->floodlines, ci->floodsecs,
- ci->ttb[TTB_FLOOD]);
- else
- notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON,
- ci->floodlines, ci->floodsecs);
- } else {
- ci->botflags &= ~BS_KICK_FLOOD;
- notice_lang(s_BotServ, u, BOT_KICK_FLOOD_OFF);
- }
- } else if (!stricmp(option, "REPEAT")) {
- if (!stricmp(value, "ON")) {
- char *times = strtok(NULL, " ");
-
- if (ttb) {
- ci->ttb[TTB_REPEAT] = strtol(ttb, (char **) NULL, 10);
- if (errno == ERANGE || errno == EINVAL
- || ci->ttb[TTB_REPEAT] < 0) {
- if (debug) {
- alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REPEAT]);
- }
- ci->ttb[TTB_REPEAT] = 0;
- notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
- return MOD_CONT;
- }
- } else
- ci->ttb[TTB_REPEAT] = 0;
-
- if (!times)
- ci->repeattimes = 3;
- else
- ci->repeattimes = atol(times);
- if (ci->repeattimes < 2)
- ci->repeattimes = 3;
-
- ci->botflags |= BS_KICK_REPEAT;
- if (ci->ttb[TTB_REPEAT])
- notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON_BAN,
- ci->repeattimes, ci->ttb[TTB_REPEAT]);
- else
- notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON,
- ci->repeattimes);
- } else {
- ci->botflags &= ~BS_KICK_REPEAT;
- notice_lang(s_BotServ, u, BOT_KICK_REPEAT_OFF);
- }
- } else if (!stricmp(option, "REVERSES")) {
- if (!stricmp(value, "ON")) {
- if (ttb) {
- ci->ttb[TTB_REVERSES] =
- strtol(ttb, (char **) NULL, 10);
- if (errno == ERANGE || errno == EINVAL
- || ci->ttb[TTB_REVERSES] < 0) {
- if (debug) {
- alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REVERSES]);
- }
- ci->ttb[TTB_REVERSES] = 0;
- notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
- return MOD_CONT;
- }
- } else
- ci->ttb[TTB_REVERSES] = 0;
- ci->botflags |= BS_KICK_REVERSES;
- if (ci->ttb[TTB_REVERSES])
- notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON_BAN,
- ci->ttb[TTB_REVERSES]);
- else
- notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON);
- } else {
- ci->botflags &= ~BS_KICK_REVERSES;
- notice_lang(s_BotServ, u, BOT_KICK_REVERSES_OFF);
- }
- } else if (!stricmp(option, "UNDERLINES")) {
- if (!stricmp(value, "ON")) {
- if (ttb) {
- ci->ttb[TTB_UNDERLINES] =
- strtol(ttb, (char **) NULL, 10);
- if (errno == ERANGE || errno == EINVAL
- || ci->ttb[TTB_UNDERLINES] < 0) {
- if (debug) {
- alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_UNDERLINES]);
- }
- ci->ttb[TTB_UNDERLINES] = 0;
- notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
- return MOD_CONT;
- }
- } else
- ci->ttb[TTB_UNDERLINES] = 0;
- ci->botflags |= BS_KICK_UNDERLINES;
- if (ci->ttb[TTB_UNDERLINES])
- notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN,
- ci->ttb[TTB_UNDERLINES]);
- else
- notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON);
- } else {
- ci->botflags &= ~BS_KICK_UNDERLINES;
- notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_OFF);
- }
- } else
- notice_help(s_BotServ, u, BOT_KICK_UNKNOWN, option);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int badwords_del_callback(User * u, int num, va_list args)
-{
- BadWord *bw;
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *last = va_arg(args, int *);
- if (num < 1 || num > ci->bwcount)
- return 0;
- *last = num;
-
- bw = &ci->badwords[num - 1];
- if (bw->word)
- free(bw->word);
- bw->word = NULL;
- bw->in_use = 0;
-
- return 1;
-}
-
-static int badwords_list(User * u, int index, ChannelInfo * ci,
- int *sent_header)
-{
- BadWord *bw = &ci->badwords[index];
-
- if (!bw->in_use)
- return 0;
- if (!*sent_header) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_HEADER, ci->name);
- *sent_header = 1;
- }
-
- notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_FORMAT, index + 1,
- bw->word,
- ((bw->type ==
- BW_SINGLE) ? "(SINGLE)" : ((bw->type ==
- BW_START) ? "(START)"
- : ((bw->type ==
- BW_END) ? "(END)" : "")))
- );
- return 1;
-}
-
-static int badwords_list_callback(User * u, int num, va_list args)
-{
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *sent_header = va_arg(args, int *);
- if (num < 1 || num > ci->bwcount)
- return 0;
- return badwords_list(u, num - 1, ci, sent_header);
-}
-
-static int do_badwords(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *cmd = strtok(NULL, " ");
- char *word = strtok(NULL, "");
- ChannelInfo *ci;
- BadWord *bw;
-
- int i;
- int need_args = (cmd
- && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR")));
-
- if (!cmd || (need_args ? 0 : !word)) {
- syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!check_access(u, ci, CA_BADWORDS)
- && (!need_args || !is_services_admin(u))) {
- notice_lang(s_BotServ, u, ACCESS_DENIED);
- } else if (stricmp(cmd, "ADD") == 0) {
-
- char *opt, *pos;
- int type = BW_ANY;
-
- if (readonly) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED);
- return MOD_CONT;
- }
-
- pos = strrchr(word, ' ');
- if (pos) {
- opt = pos + 1;
- if (*opt) {
- if (!stricmp(opt, "SINGLE"))
- type = BW_SINGLE;
- else if (!stricmp(opt, "START"))
- type = BW_START;
- else if (!stricmp(opt, "END"))
- type = BW_END;
- if (type != BW_ANY)
- *pos = 0;
- }
- }
-
- for (bw = ci->badwords, i = 0; i < ci->bwcount; bw++, i++) {
- if (bw->word && ((BSCaseSensitive && (!strcmp(bw->word, word)))
- || (!BSCaseSensitive
- && (!stricmp(bw->word, word))))) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS,
- bw->word, ci->name);
- return MOD_CONT;
- }
- }
-
- for (i = 0; i < ci->bwcount; i++) {
- if (!ci->badwords[i].in_use)
- break;
- }
- if (i == ci->bwcount) {
- if (i < BSBadWordsMax) {
- ci->bwcount++;
- ci->badwords =
- srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount);
- } else {
- notice_lang(s_BotServ, u, BOT_BADWORDS_REACHED_LIMIT,
- BSBadWordsMax);
- return MOD_CONT;
- }
- }
- bw = &ci->badwords[i];
- bw->in_use = 1;
- bw->word = sstrdup(word);
- bw->type = type;
-
- notice_lang(s_BotServ, u, BOT_BADWORDS_ADDED, bw->word, ci->name);
-
- } else if (stricmp(cmd, "DEL") == 0) {
-
- if (readonly) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED);
- return MOD_CONT;
- }
-
- /* Special case: is it a number/list? Only do search if it isn't. */
- if (isdigit(*word) && strspn(word, "1234567890,-") == strlen(word)) {
- int count, deleted, last = -1;
- deleted =
- process_numlist(word, &count, badwords_del_callback, u, ci,
- &last);
- if (!deleted) {
- if (count == 1) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_NO_SUCH_ENTRY,
- last, ci->name);
- } else {
- notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH,
- ci->name);
- }
- } else if (deleted == 1) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_ONE,
- ci->name);
- } else {
- notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_SEVERAL,
- deleted, ci->name);
- }
- } else {
- for (i = 0; i < ci->bwcount; i++) {
- if (ci->badwords[i].in_use
- && !stricmp(ci->badwords[i].word, word))
- break;
- }
- if (i == ci->bwcount) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word,
- chan);
- return MOD_CONT;
- }
- bw = &ci->badwords[i];
- notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED, bw->word,
- ci->name);
- if (bw->word)
- free(bw->word);
- bw->word = NULL;
- bw->in_use = 0;
- }
-
- } else if (stricmp(cmd, "LIST") == 0) {
- int sent_header = 0;
-
- if (ci->bwcount == 0) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, chan);
- return MOD_CONT;
- }
- if (word && strspn(word, "1234567890,-") == strlen(word)) {
- process_numlist(word, NULL, badwords_list_callback, u, ci,
- &sent_header);
- } else {
- for (i = 0; i < ci->bwcount; i++) {
- if (!(ci->badwords[i].in_use))
- continue;
- if (word && ci->badwords[i].word
- && !match_wild_nocase(word, ci->badwords[i].word))
- continue;
- badwords_list(u, i, ci, &sent_header);
- }
- }
- if (!sent_header)
- notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, chan);
-
- } else if (stricmp(cmd, "CLEAR") == 0) {
-
- if (readonly) {
- notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED);
- return MOD_CONT;
- }
-
- for (i = 0; i < ci->bwcount; i++)
- if (ci->badwords[i].word)
- free(ci->badwords[i].word);
-
- free(ci->badwords);
- ci->badwords = NULL;
- ci->bwcount = 0;
-
- notice_lang(s_BotServ, u, BOT_BADWORDS_CLEAR);
-
- } else {
- syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_say(User * u)
-{
- ChannelInfo *ci;
-
- char *chan = strtok(NULL, " ");
- char *text = strtok(NULL, "");
-
- if (!chan || !text)
- syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- else if (ci->flags & CI_VERBOTEN)
- notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
- else if (!ci->bi)
- notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
- else if (!ci->c || ci->c->usercount < BSMinUsers)
- notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name);
- else if (!check_access(u, ci, CA_SAY))
- notice_lang(s_BotServ, u, ACCESS_DENIED);
- else {
- if (text[0] != '\001') {
- anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", text);
- ci->bi->lastmsg = time(NULL);
- if (logchan && LogBot)
- anope_cmd_privmsg(ci->bi->nick, LogChannel,
- "SAY %s %s %s", u->nick, ci->name, text);
- } else {
- syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX);
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_act(User * u)
-{
- ChannelInfo *ci;
-
- char *chan = strtok(NULL, " ");
- char *text = strtok(NULL, "");
-
- if (!chan || !text)
- syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX);
- else if (!(ci = cs_findchan(chan)))
- notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
- else if (ci->flags & CI_VERBOTEN)
- notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
- else if (!ci->bi)
- notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
- else if (!ci->c || ci->c->usercount < BSMinUsers)
- notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name);
- else if (!check_access(u, ci, CA_SAY))
- notice_lang(s_BotServ, u, ACCESS_DENIED);
- else {
- strnrepl(text, BUFSIZE, "\001", "");
- anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION %s %c", 1,
- text, 1);
- ci->bi->lastmsg = time(NULL);
- if (logchan && LogBot)
- anope_cmd_privmsg(ci->bi->nick, LogChannel, "ACT %s %s %s",
- u->nick, ci->name, text);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
/**
* Normalize buffer stripping control characters and colors
* @param A string to be parsed for control and color codes
@@ -2554,7 +1027,7 @@ char *normalizeBuffer(char *buf)
int i, len, j = 0;
len = strlen(buf);
- newbuf = (char *) malloc(sizeof(char) * len + 1);
+ newbuf = (char *) smalloc(sizeof(char) * len + 1);
for (i = 0; i < len; i++) {
switch (buf[i]) {
diff --git a/src/channels.c b/src/channels.c
index 7d25c548f..86a42e118 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -256,10 +256,12 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av,
chan_remove_user_status(chan, user, cum->status);
} else if ((cbm = &cbmodes[(int) mode])->flag != 0) {
- if (add)
- chan->mode |= cbm->flag;
- else
- chan->mode &= ~cbm->flag;
+ if (check >= 0) {
+ if (add)
+ chan->mode |= cbm->flag;
+ else
+ chan->mode &= ~cbm->flag;
+ }
if (cbm->setvalue) {
if (add || !(cbm->flags & CBM_MINUS_NO_ARG)) {
@@ -272,6 +274,13 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av,
}
cbm->setvalue(chan, add ? *av : NULL);
}
+
+ if (check < 0) {
+ if (add)
+ chan->mode |= cbm->flag;
+ else
+ chan->mode &= ~cbm->flag;
+ }
} else if ((cmm = &cmmodes[(int) mode])->addmask) {
if (ac == 0) {
alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name);
@@ -287,7 +296,7 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av,
}
}
- if (check) {
+ if (check > 0) {
check_modes(chan);
if (check < 2) {
@@ -537,6 +546,8 @@ void do_join(const char *source, int ac, char **av)
if (debug)
alog("debug: %s joins %s", source, s);
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, source, s);
+
if (*s == '0') {
c = user->chans;
while (c) {
@@ -557,6 +568,8 @@ void do_join(const char *source, int ac, char **av)
chan = findchan(s);
chan = join_user_update(user, chan, s);
chan_set_correct_modes(user, chan, 1);
+
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, source, s);
}
}
@@ -663,6 +676,8 @@ void do_part(const char *source, int ac, char **av)
alog("user: BUG parting %s: channel entry found but c->chan NULL", s);
return;
}
+ send_event(EVENT_PART_CHANNEL, 3, EVENT_START, user->nick,
+ c->chan->name);
chan_deluser(user, c->chan);
if (c->next)
c->next->prev = c->prev;
@@ -671,6 +686,8 @@ void do_part(const char *source, int ac, char **av)
else
user->chans = c->next;
free(c);
+ send_event(EVENT_PART_CHANNEL, 3, EVENT_STOP, user->nick,
+ c->chan->name);
}
}
}
@@ -805,6 +822,9 @@ void do_sjoin(const char *source, int ac, char **av)
anope_cmd_kick(s_OperServ, av[1], s, "Q-Lined");
} else {
if (!check_kick(user, av[1])) {
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START,
+ user->nick, av[1]);
+
/* Make the user join; if the channel does not exist it
* will be created there. This ensures that the channel
* is not created to be immediately destroyed, and
@@ -827,6 +847,9 @@ void do_sjoin(const char *source, int ac, char **av)
&& !c->topic_sync)
restore_topic(c->name);
chan_set_correct_modes(user, c, 1);
+
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP,
+ user->nick, av[1]);
}
}
@@ -881,6 +904,9 @@ void do_sjoin(const char *source, int ac, char **av)
anope_cmd_kick(s_OperServ, av[1], s, "Q-Lined");
} else {
if (!check_kick(user, av[1])) {
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START,
+ user->nick, av[1]);
+
/* Make the user join; if the channel does not exist it
* will be created there. This ensures that the channel
* is not created to be immediately destroyed, and
@@ -900,6 +926,9 @@ void do_sjoin(const char *source, int ac, char **av)
}
chan_set_correct_modes(user, c, 1);
+
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP,
+ user->nick, av[1]);
}
}
@@ -952,6 +981,9 @@ void do_sjoin(const char *source, int ac, char **av)
anope_cmd_kick(s_OperServ, av[1], s, "Q-Lined");
} else {
if (!check_kick(user, av[1])) {
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START,
+ user->nick, av[1]);
+
/* Make the user join; if the channel does not exist it
* will be created there. This ensures that the channel
* is not created to be immediately destroyed, and
@@ -971,6 +1003,9 @@ void do_sjoin(const char *source, int ac, char **av)
}
chan_set_correct_modes(user, c, 1);
+
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP,
+ user->nick, av[1]);
}
}
@@ -1011,11 +1046,17 @@ void do_sjoin(const char *source, int ac, char **av)
if (is_sqlined && !is_oper(user)) {
anope_cmd_kick(s_OperServ, av[1], user->nick, "Q-Lined");
} else {
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, user->nick,
+ av[1]);
+
c = join_user_update(user, c, av[1]);
c->creation_time = ts;
if (is_created && c->ci)
restore_topic(c->name);
chan_set_correct_modes(user, c, 1);
+
+ send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, user->nick,
+ av[1]);
}
}
}
@@ -1122,6 +1163,8 @@ void do_topic(const char *source, int ac, char **av)
/* We can be sure that the topic will be in sync here -GD */
c->topic_sync = 1;
+ ci = c->ci;
+
/* If the current topic we have matches the last known topic for this
* channel exactly, there's no need to update anything and we can as
* well just return silently without updating anything. -GD
@@ -1138,13 +1181,20 @@ void do_topic(const char *source, int ac, char **av)
free(c->topic);
c->topic = NULL;
}
- if (ac > 3 && *av[3])
+ if (ac > 3 && *av[3]) {
c->topic = sstrdup(av[3]);
+ }
strscpy(c->topic_setter, av[1], sizeof(c->topic_setter));
c->topic_time = topic_time;
record_topic(av[0]);
+
+ if (ci->last_topic) {
+ send_event(EVENT_TOPIC_UPDATED, 2, av[0], ci->last_topic);
+ } else {
+ send_event(EVENT_TOPIC_UPDATED, 2, av[0], "");
+ }
}
/*************************************************************************/
@@ -1471,8 +1521,9 @@ Channel *chan_create(char *chan)
stick_all(c->ci);
}
- if (serv_uplink && is_sync(serv_uplink) && (!(c->topic_sync)))
+ if (serv_uplink && is_sync(serv_uplink) && (!(c->topic_sync))) {
restore_topic(chan);
+ }
return c;
}
diff --git a/src/chanserv.c b/src/chanserv.c
index 6ee7d0056..4d197770e 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -102,7 +102,7 @@ LevelInfo levelinfo[] = {
{ CA_SAY, "SAY", CHAN_LEVEL_SAY },
{ -1 }
};
-static int levelinfo_maxwidth = 0;
+int levelinfo_maxwidth = 0;
CSModeUtil csmodeutils[] = {
{ "DEOP", "!deop", "-o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME },
@@ -116,207 +116,20 @@ CSModeUtil csmodeutils[] = {
{ NULL }
};
-int xop_msgs[4][14] = {
- { CHAN_AOP_SYNTAX,
- CHAN_AOP_DISABLED,
- CHAN_AOP_NICKS_ONLY,
- CHAN_AOP_ADDED,
- CHAN_AOP_MOVED,
- CHAN_AOP_NO_SUCH_ENTRY,
- CHAN_AOP_NOT_FOUND,
- CHAN_AOP_NO_MATCH,
- CHAN_AOP_DELETED,
- CHAN_AOP_DELETED_ONE,
- CHAN_AOP_DELETED_SEVERAL,
- CHAN_AOP_LIST_EMPTY,
- CHAN_AOP_LIST_HEADER,
- CHAN_AOP_CLEAR
- },
- { CHAN_SOP_SYNTAX,
- CHAN_SOP_DISABLED,
- CHAN_SOP_NICKS_ONLY,
- CHAN_SOP_ADDED,
- CHAN_SOP_MOVED,
- CHAN_SOP_NO_SUCH_ENTRY,
- CHAN_SOP_NOT_FOUND,
- CHAN_SOP_NO_MATCH,
- CHAN_SOP_DELETED,
- CHAN_SOP_DELETED_ONE,
- CHAN_SOP_DELETED_SEVERAL,
- CHAN_SOP_LIST_EMPTY,
- CHAN_SOP_LIST_HEADER,
- CHAN_SOP_CLEAR
- },
- { CHAN_VOP_SYNTAX,
- CHAN_VOP_DISABLED,
- CHAN_VOP_NICKS_ONLY,
- CHAN_VOP_ADDED,
- CHAN_VOP_MOVED,
- CHAN_VOP_NO_SUCH_ENTRY,
- CHAN_VOP_NOT_FOUND,
- CHAN_VOP_NO_MATCH,
- CHAN_VOP_DELETED,
- CHAN_VOP_DELETED_ONE,
- CHAN_VOP_DELETED_SEVERAL,
- CHAN_VOP_LIST_EMPTY,
- CHAN_VOP_LIST_HEADER,
- CHAN_VOP_CLEAR
- },
- { CHAN_HOP_SYNTAX,
- CHAN_HOP_DISABLED,
- CHAN_HOP_NICKS_ONLY,
- CHAN_HOP_ADDED,
- CHAN_HOP_MOVED,
- CHAN_HOP_NO_SUCH_ENTRY,
- CHAN_HOP_NOT_FOUND,
- CHAN_HOP_NO_MATCH,
- CHAN_HOP_DELETED,
- CHAN_HOP_DELETED_ONE,
- CHAN_HOP_DELETED_SEVERAL,
- CHAN_HOP_LIST_EMPTY,
- CHAN_HOP_LIST_HEADER,
- CHAN_HOP_CLEAR
- }
-};
-
/* *INDENT-ON* */
/*************************************************************************/
void alpha_insert_chan(ChannelInfo * ci);
-static ChannelInfo *makechan(const char *chan);
+ChannelInfo *makechan(const char *chan);
int delchan(ChannelInfo * ci);
void reset_levels(ChannelInfo * ci);
-static int is_identified(User * user, ChannelInfo * ci);
-static void make_unidentified(User * u, ChannelInfo * ci);
-
-static int do_help(User * u);
-static int do_register(User * u);
-static int do_identify(User * u);
-static int do_logout(User * u);
-static int do_drop(User * u);
-static int do_set(User * u);
-static int do_set_founder(User * u, ChannelInfo * ci, char *param);
-static int do_set_successor(User * u, ChannelInfo * ci, char *param);
-static int do_set_password(User * u, ChannelInfo * ci, char *param);
-static int do_set_desc(User * u, ChannelInfo * ci, char *param);
-static int do_set_url(User * u, ChannelInfo * ci, char *param);
-static int do_set_email(User * u, ChannelInfo * ci, char *param);
-static int do_set_entrymsg(User * u, ChannelInfo * ci, char *param);
-static int do_set_bantype(User * u, ChannelInfo * ci, char *param);
-static int do_set_mlock(User * u, ChannelInfo * ci, char *param);
-static int do_set_keeptopic(User * u, ChannelInfo * ci, char *param);
-static int do_set_topiclock(User * u, ChannelInfo * ci, char *param);
-static int do_set_private(User * u, ChannelInfo * ci, char *param);
-static int do_set_secureops(User * u, ChannelInfo * ci, char *param);
-static int do_set_securefounder(User * u, ChannelInfo * ci, char *param);
-static int do_set_restricted(User * u, ChannelInfo * ci, char *param);
-static int do_set_secure(User * u, ChannelInfo * ci, char *param);
-static int do_set_signkick(User * u, ChannelInfo * ci, char *param);
-static int do_set_opnotice(User * u, ChannelInfo * ci, char *param);
-static int do_set_xop(User * u, ChannelInfo * ci, char *param);
-static int do_set_peace(User * u, ChannelInfo * ci, char *param);
-static int do_set_noexpire(User * u, ChannelInfo * ci, char *param);
-static int do_xop(User * u, char *xname, int xlev, int *xmsgs);
-static int do_aop(User * u);
-static int do_hop(User * u);
-static int do_sop(User * u);
-static int do_vop(User * u);
-static int do_access(User * u);
-static int do_akick(User * u);
-static int do_info(User * u);
-static int do_list(User * u);
-static int do_invite(User * u);
-static int do_levels(User * u);
-static int do_util(User * u, CSModeUtil * util);
-static int do_op(User * u);
-static int do_deop(User * u);
-static int do_voice(User * u);
-static int do_devoice(User * u);
-static int do_halfop(User * u);
-static int do_dehalfop(User * u);
-static int do_protect(User * u);
-static int do_deprotect(User * u);
-static int do_owner(User * u);
-static int do_deowner(User * u);
-static int do_cs_kick(User * u);
-static int do_ban(User * u);
-static int do_cs_topic(User * u);
-static int do_unban(User * u);
-static int do_clear(User * u);
-static int do_getkey(User * u);
-static int do_getpass(User * u);
-static int do_sendpass(User * u);
-static int do_forbid(User * u);
-static int do_suspend(User * u);
-static int do_unsuspend(User * u);
-static int do_status(User * u);
+int is_identified(User * user, ChannelInfo * ci);
+
void moduleAddChanServCmds(void);
/*************************************************************************/
/* *INDENT-OFF* */
void moduleAddChanServCmds(void) {
- Command *c;
- c = createCommand("HELP", do_help, NULL, -1, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("REGISTER", do_register, NULL, CHAN_HELP_REGISTER, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("IDENTIFY", do_identify, NULL, CHAN_HELP_IDENTIFY, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("LOGOUT", do_logout, NULL, -1,CHAN_HELP_LOGOUT, -1,CHAN_SERVADMIN_HELP_LOGOUT, CHAN_SERVADMIN_HELP_LOGOUT); addCoreCommand(CHANSERV,c);
- c = createCommand("DROP", do_drop, NULL, -1,CHAN_HELP_DROP, -1,CHAN_SERVADMIN_HELP_DROP, CHAN_SERVADMIN_HELP_DROP); addCoreCommand(CHANSERV,c);
- c = createCommand("SET", do_set, NULL, CHAN_HELP_SET,-1, -1,CHAN_SERVADMIN_HELP_SET, CHAN_SERVADMIN_HELP_SET); addCoreCommand(CHANSERV,c);
- c = createCommand("SET FOUNDER", NULL, NULL, CHAN_HELP_SET_FOUNDER, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET SUCCESSOR", NULL, NULL, CHAN_HELP_SET_SUCCESSOR, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET PASSWORD", NULL, NULL, CHAN_HELP_SET_PASSWORD, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET DESC", NULL, NULL, CHAN_HELP_SET_DESC, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET URL", NULL, NULL, CHAN_HELP_SET_URL, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET EMAIL", NULL, NULL, CHAN_HELP_SET_EMAIL, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET ENTRYMSG", NULL, NULL, CHAN_HELP_SET_ENTRYMSG, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET BANTYPE", NULL, NULL, CHAN_HELP_SET_BANTYPE, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET PRIVATE", NULL, NULL, CHAN_HELP_SET_PRIVATE, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET KEEPTOPIC", NULL, NULL, CHAN_HELP_SET_KEEPTOPIC, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET TOPICLOCK", NULL, NULL, CHAN_HELP_SET_TOPICLOCK, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET MLOCK", NULL, NULL, CHAN_HELP_SET_MLOCK, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET RESTRICTED", NULL, NULL, CHAN_HELP_SET_RESTRICTED, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET SECURE", NULL, NULL, CHAN_HELP_SET_SECURE, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET SECUREOPS", NULL, NULL, CHAN_HELP_SET_SECUREOPS, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET SECUREFOUNDER", NULL, NULL, CHAN_HELP_SET_SECUREFOUNDER, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET SIGNKICK", NULL, NULL, CHAN_HELP_SET_SIGNKICK, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET OPNOTICE", NULL, NULL, CHAN_HELP_SET_OPNOTICE, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET XOP", NULL, NULL, CHAN_HELP_SET_XOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET PEACE", NULL, NULL, CHAN_HELP_SET_PEACE, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SET NOEXPIRE", NULL, NULL, -1, -1, -1,CHAN_SERVADMIN_HELP_SET_NOEXPIRE,CHAN_SERVADMIN_HELP_SET_NOEXPIRE); addCoreCommand(CHANSERV,c);
- c = createCommand("AOP", do_aop, NULL, CHAN_HELP_AOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("HOP", do_hop, NULL, CHAN_HELP_HOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SOP", do_sop, NULL, CHAN_HELP_SOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("VOP", do_vop, NULL, CHAN_HELP_VOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("ACCESS", do_access, NULL, CHAN_HELP_ACCESS, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("ACCESS LEVELS", NULL, NULL, CHAN_HELP_ACCESS_LEVELS, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("AKICK", do_akick, NULL, CHAN_HELP_AKICK, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("LEVELS", do_levels, NULL, CHAN_HELP_LEVELS, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("INFO", do_info, NULL, CHAN_HELP_INFO,-1, CHAN_SERVADMIN_HELP_INFO, CHAN_SERVADMIN_HELP_INFO,CHAN_SERVADMIN_HELP_INFO); addCoreCommand(CHANSERV,c);
- c = createCommand("LIST", do_list, NULL, -1,CHAN_HELP_LIST, CHAN_SERVADMIN_HELP_LIST,CHAN_SERVADMIN_HELP_LIST, CHAN_SERVADMIN_HELP_LIST); addCoreCommand(CHANSERV,c);
- c = createCommand("OP", do_op, NULL, CHAN_HELP_OP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("DEOP", do_deop, NULL, CHAN_HELP_DEOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("VOICE", do_voice, NULL, CHAN_HELP_VOICE, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("DEVOICE", do_devoice, NULL, CHAN_HELP_DEVOICE, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("HALFOP", do_halfop, NULL, CHAN_HELP_HALFOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("DEHALFOP", do_dehalfop, NULL, CHAN_HELP_DEHALFOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("PROTECT", do_protect, NULL, CHAN_HELP_PROTECT, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("DEPROTECT",do_deprotect,NULL, CHAN_HELP_DEPROTECT, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("OWNER", do_owner, NULL, CHAN_HELP_OWNER, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("DEOWNER", do_deowner, NULL, CHAN_HELP_DEOWNER, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("ADMIN", do_protect, NULL, CHAN_HELP_PROTECT, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("DEADMIN",do_deprotect,NULL, CHAN_HELP_DEPROTECT, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("KICK", do_cs_kick, NULL, CHAN_HELP_KICK, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("BAN", do_ban, NULL, CHAN_HELP_BAN, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("TOPIC", do_cs_topic, NULL, CHAN_HELP_TOPIC, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("INVITE", do_invite, NULL, CHAN_HELP_INVITE, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("UNBAN", do_unban, NULL, CHAN_HELP_UNBAN, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("CLEAR", do_clear, NULL, CHAN_HELP_CLEAR, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("GETKEY", do_getkey, NULL, CHAN_HELP_GETKEY, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("SENDPASS", do_sendpass, NULL, CHAN_HELP_SENDPASS, -1,-1,-1,-1); addCoreCommand(CHANSERV,c);
- c = createCommand("GETPASS", do_getpass, is_services_admin, -1, -1, -1, CHAN_SERVADMIN_HELP_GETPASS, CHAN_SERVADMIN_HELP_GETPASS); addCoreCommand(CHANSERV,c);
- c = createCommand("FORBID", do_forbid, is_services_admin, -1, -1, -1, CHAN_SERVADMIN_HELP_FORBID, CHAN_SERVADMIN_HELP_FORBID); addCoreCommand(CHANSERV,c);
- c = createCommand("SUSPEND", do_suspend, is_services_admin, -1, -1, -1, CHAN_SERVADMIN_HELP_SUSPEND, CHAN_SERVADMIN_HELP_SUSPEND); addCoreCommand(CHANSERV,c);
- c = createCommand("UNSUSPEND",do_unsuspend, is_services_admin, -1, -1, -1, CHAN_SERVADMIN_HELP_UNSUSPEND, CHAN_SERVADMIN_HELP_UNSUSPEND); addCoreCommand(CHANSERV,c);
- c = createCommand("STATUS", do_status, is_services_admin, -1, -1, -1, CHAN_SERVADMIN_HELP_STATUS, CHAN_SERVADMIN_HELP_STATUS); addCoreCommand(CHANSERV,c);
+ modules_core_init(ChanServCoreNumber, ChanServCoreModules);
}
/* *INDENT-ON* */
@@ -325,7 +138,7 @@ void moduleAddChanServCmds(void) {
/* Returns modes for mlock in a nice way. */
-static char *get_mlock_modes(ChannelInfo * ci, int complete)
+char *get_mlock_modes(ChannelInfo * ci, int complete)
{
static char res[BUFSIZE];
@@ -1739,18 +1552,21 @@ void record_topic(const char *chan)
if (readonly)
return;
+
c = findchan(chan);
if (!c || !(ci = c->ci))
return;
+
if (ci->last_topic)
free(ci->last_topic);
+
if (c->topic)
ci->last_topic = sstrdup(c->topic);
else
ci->last_topic = NULL;
+
strscpy(ci->last_topic_setter, c->topic_setter, NICKMAX);
ci->last_topic_time = c->topic_time;
- send_event(EVENT_TOPIC_UPDATED, chan);
}
/*************************************************************************/
@@ -1883,7 +1699,7 @@ void expire_chans()
next = ci->next;
if (!ci->c && now - ci->last_used >= CSExpire
&& !(ci->flags & (CI_VERBOTEN | CI_NO_EXPIRE))) {
- send_event(EVENT_CHAN_EXPIRE, ci->name);
+ send_event(EVENT_CHAN_EXPIRE, 1, ci->name);
alog("Expiring channel %s (founder: %s)", ci->name,
(ci->founder ? ci->founder->display : "(none)"));
delchan(ci);
@@ -2092,7 +1908,7 @@ void alpha_insert_chan(ChannelInfo * ci)
* structure if the channel was successfully registered, NULL otherwise.
* Assumes channel does not already exist. */
-static ChannelInfo *makechan(const char *chan)
+ChannelInfo *makechan(const char *chan)
{
int i;
ChannelInfo *ci;
@@ -2322,7 +2138,7 @@ int is_real_founder(User * user, ChannelInfo * ci)
/* Has the given user password-identified as founder for the channel? */
-static int is_identified(User * user, ChannelInfo * ci)
+int is_identified(User * user, ChannelInfo * ci)
{
struct u_chaninfolist *c;
@@ -2437,29 +2253,6 @@ int get_idealban(ChannelInfo * ci, User * u, char *ret, int retlen)
/*************************************************************************/
-static void make_unidentified(User * u, ChannelInfo * ci)
-{
- struct u_chaninfolist *uci;
-
- if (!u || !ci)
- return;
-
- for (uci = u->founder_chans; uci; uci = uci->next) {
- if (uci->chan == ci) {
- if (uci->next)
- uci->next->prev = uci->prev;
- if (uci->prev)
- uci->prev->next = uci->next;
- else
- u->founder_chans = uci->next;
- free(uci);
- break;
- }
- }
-}
-
-/*************************************************************************/
-
char *cs_get_flood(ChannelInfo * ci)
{
if (!ci) {
@@ -2544,7 +2337,7 @@ void cs_set_key(ChannelInfo * ci, char *value)
if (value && *value != ':' && !strchr(value, ',')) {
ci->mlock_key = sstrdup(value);
} else {
- ci->mlock_on &= ~CMODE_k;
+ ci->mlock_on &= ~anope_get_key_mode();
ci->mlock_key = NULL;
}
}
@@ -2560,7 +2353,7 @@ void cs_set_limit(ChannelInfo * ci, char *value)
ci->mlock_limit = value ? strtoul(value, NULL, 10) : 0;
if (ci->mlock_limit <= 0)
- ci->mlock_on &= ~CMODE_l;
+ ci->mlock_on &= ~anope_get_limit_mode();
}
/*************************************************************************/
@@ -2634,1019 +2427,8 @@ char *get_xop_level(int level)
/*********************** ChanServ command routines ***********************/
/*************************************************************************/
-static int do_help(User * u)
-{
- char *cmd = strtok(NULL, "");
-
- if (!cmd) {
- notice_help(s_ChanServ, u, CHAN_HELP);
- if (ircd->extrahelp) {
- notice_help(s_ChanServ, u, ircd->extrahelp);
- }
- if (CSExpire >= 86400)
- notice_help(s_ChanServ, u, CHAN_HELP_EXPIRES,
- CSExpire / 86400);
- if (is_services_oper(u))
- notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP);
- moduleDisplayHelp(2, u);
- } else if (stricmp(cmd, "LEVELS DESC") == 0) {
- int i;
- notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC);
- if (!levelinfo_maxwidth) {
- for (i = 0; levelinfo[i].what >= 0; i++) {
- int len = strlen(levelinfo[i].name);
- if (len > levelinfo_maxwidth)
- levelinfo_maxwidth = len;
- }
- }
- for (i = 0; levelinfo[i].what >= 0; i++) {
- notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC_FORMAT,
- levelinfo_maxwidth, levelinfo[i].name,
- getstring(u->na, levelinfo[i].desc));
- }
- } else {
- mod_help_cmd(s_ChanServ, u, CHANSERV, cmd);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_register(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *pass = strtok(NULL, " ");
- char *desc = strtok(NULL, "");
- NickCore *nc;
- Channel *c;
- ChannelInfo *ci;
- struct u_chaninfolist *uc;
- int is_servadmin = is_services_admin(u);
-#ifdef USE_ENCRYPTION
- char founderpass[PASSMAX + 1];
-#endif
-
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_REGISTER_DISABLED);
- return MOD_CONT;
- }
-
- if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) {
- notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED);
- return MOD_CONT;
- }
-
- if (!desc) {
- syntax_error(s_ChanServ, u, "REGISTER", CHAN_REGISTER_SYNTAX);
- } else if (*chan == '&') {
- notice_lang(s_ChanServ, u, CHAN_REGISTER_NOT_LOCAL);
- } else if (*chan != '#') {
- notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED);
- } else if (!u->na || !(nc = u->na->nc)) {
- notice_lang(s_ChanServ, u, CHAN_MUST_REGISTER_NICK, s_NickServ);
- } else if (!nick_recognized(u)) {
- notice_lang(s_ChanServ, u, CHAN_MUST_IDENTIFY_NICK, s_NickServ,
- s_NickServ);
- } else if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_REGISTER_NONE_CHANNEL, chan);
- } else if ((ci = cs_findchan(chan)) != NULL) {
- if (ci->flags & CI_VERBOTEN) {
- alog("%s: Attempt to register FORBIDden channel %s by %s!%s@%s", s_ChanServ, ci->name, u->nick, u->username, u->host);
- notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
- } else {
- notice_lang(s_ChanServ, u, CHAN_ALREADY_REGISTERED, chan);
- }
- } else if (!stricmp(chan, "#")) {
- notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
- } else if (!chan_has_user_status(c, u, CUS_OP)) {
- notice_lang(s_ChanServ, u, CHAN_MUST_BE_CHANOP);
-
- } else if (!is_servadmin && nc->channelmax > 0
- && nc->channelcount >= nc->channelmax) {
- notice_lang(s_ChanServ, u,
- nc->channelcount >
- nc->
- channelmax ? CHAN_EXCEEDED_CHANNEL_LIMIT :
- CHAN_REACHED_CHANNEL_LIMIT, nc->channelmax);
- } else if (stricmp(u->nick, pass) == 0
- || (StrictPasswords && strlen(pass) < 5)) {
- notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD);
- } else if (!(ci = makechan(chan))) {
- alog("%s: makechan() failed for REGISTER %s", s_ChanServ, chan);
- notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED);
-
-#ifdef USE_ENCRYPTION
- } else if (strscpy(founderpass, pass, PASSMAX + 1),
- encrypt_in_place(founderpass, PASSMAX) < 0) {
- alog("%s: Couldn't encrypt password for %s (REGISTER)",
- s_ChanServ, chan);
- notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED);
- delchan(ci);
-#endif
-
- } else {
- c->ci = ci;
- ci->c = c;
- ci->bantype = CSDefBantype;
- ci->flags = CSDefFlags;
- ci->mlock_on = ircd->defmlock;
- ci->memos.memomax = MSMaxMemos;
- ci->last_used = ci->time_registered;
- ci->founder = nc;
-#ifdef USE_ENCRYPTION
- if (strlen(pass) > PASSMAX)
- notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX);
- memset(pass, 0, strlen(pass));
- memcpy(ci->founderpass, founderpass, PASSMAX);
- ci->flags |= CI_ENCRYPTEDPW;
-#else
- if (strlen(pass) > PASSMAX - 1) /* -1 for null byte */
- notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX - 1);
- strscpy(ci->founderpass, pass, PASSMAX);
-#endif
- ci->desc = sstrdup(desc);
- if (c->topic) {
- ci->last_topic = sstrdup(c->topic);
- strscpy(ci->last_topic_setter, c->topic_setter, NICKMAX);
- ci->last_topic_time = c->topic_time;
- } else {
- /* Set this to something, otherwise it will maliform the topic */
- strscpy(ci->last_topic_setter, s_ChanServ, NICKMAX);
- }
- ci->bi = NULL;
- ci->botflags = BSDefFlags;
- ci->founder->channelcount++;
- alog("%s: Channel '%s' registered by %s!%s@%s", s_ChanServ, chan,
- u->nick, u->username, u->host);
- notice_lang(s_ChanServ, u, CHAN_REGISTERED, chan, u->nick);
-#ifndef USE_ENCRYPTION
- notice_lang(s_ChanServ, u, CHAN_PASSWORD_IS, ci->founderpass);
-#endif
- uc = scalloc(sizeof(*uc), 1);
- uc->next = u->founder_chans;
- uc->prev = NULL;
- if (u->founder_chans)
- u->founder_chans->prev = uc;
- u->founder_chans = uc;
- uc->chan = ci;
- /* Implement new mode lock */
- check_modes(c);
- /* On most ircds you do not receive the admin/owner mode till its registered */
- if (ircd->admin) {
- anope_cmd_mode(s_ChanServ, chan, "%s %s", ircd->adminset,
- u->nick);
- }
- if (ircd->owner && ircd->ownerset) {
- anope_cmd_mode(s_ChanServ, chan, "%s %s", ircd->ownerset,
- u->nick);
- }
- send_event(EVENT_CHAN_REGISTERED, chan);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_identify(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *pass = strtok(NULL, " ");
- ChannelInfo *ci;
- struct u_chaninfolist *uc;
-
- if (!pass) {
- syntax_error(s_ChanServ, u, "IDENTIFY", CHAN_IDENTIFY_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!nick_identified(u)) {
- notice_lang(s_ChanServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else if (is_founder(u, ci)) {
- notice_lang(s_ChanServ, u, NICK_ALREADY_IDENTIFIED);
- } else {
- int res;
-
- if ((res = check_password(pass, ci->founderpass)) == 1) {
- if (!is_identified(u, ci)) {
- uc = scalloc(sizeof(*uc), 1);
- uc->next = u->founder_chans;
- if (u->founder_chans)
- u->founder_chans->prev = uc;
- u->founder_chans = uc;
- uc->chan = ci;
- alog("%s: %s!%s@%s identified for %s", s_ChanServ, u->nick,
- u->username, u->host, ci->name);
- }
-
- notice_lang(s_ChanServ, u, CHAN_IDENTIFY_SUCCEEDED, chan);
- } else if (res < 0) {
- alog("%s: check_password failed for %s", s_ChanServ, ci->name);
- notice_lang(s_ChanServ, u, CHAN_IDENTIFY_FAILED);
- } else {
- alog("%s: Failed IDENTIFY for %s by %s!%s@%s",
- s_ChanServ, ci->name, u->nick, u->username, u->host);
- notice_lang(s_ChanServ, u, PASSWORD_INCORRECT);
- bad_password(u);
- }
-
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_logout(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
- ChannelInfo *ci;
- User *u2 = NULL;
- int is_servadmin = is_services_admin(u);
-
- if (!chan || (!nick && !is_servadmin)) {
- syntax_error(s_ChanServ, u, "LOGOUT",
- (!is_servadmin ? CHAN_LOGOUT_SYNTAX :
- CHAN_LOGOUT_SERVADMIN_SYNTAX));
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (nick && !(u2 = finduser(nick))) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
- } else if (!is_servadmin && u2 != u && !is_real_founder(u, ci)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
- if (u2) {
- make_unidentified(u2, ci);
- notice_lang(s_ChanServ, u, CHAN_LOGOUT_SUCCEEDED, nick, chan);
- alog("%s: User %s!%s@%s has been logged out of channel %s.",
- s_ChanServ, u2->nick, u2->username, u2->host, chan);
- } else {
- int i;
- for (i = 0; i < 1024; i++)
- for (u2 = userlist[i]; u2; u2 = u2->next)
- make_unidentified(u2, ci);
- notice_lang(s_ChanServ, u, CHAN_LOGOUT_ALL_SUCCEEDED, chan);
- alog("%s: All users identified have been logged out of channel %s.", s_ChanServ, chan);
- }
-
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_drop(User * u)
-{
- char *chan = strtok(NULL, " ");
- ChannelInfo *ci;
- int is_servadmin = is_services_admin(u);
-
- if (readonly && !is_servadmin) {
- notice_lang(s_ChanServ, u, CHAN_DROP_DISABLED);
- return MOD_CONT;
- }
-
- if (!chan) {
- syntax_error(s_ChanServ, u, "DROP", CHAN_DROP_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!is_servadmin && (ci->flags & CI_SUSPENDED)) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!is_servadmin
- && (ci->
- flags & CI_SECUREFOUNDER ? !is_real_founder(u,
- ci) :
- !is_founder(u, ci))) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
- int level = get_access(u, ci);
-
- if (readonly) /* in this case we know they're a Services admin */
- notice_lang(s_ChanServ, u, READ_ONLY_MODE);
-
- if (ci->c) {
- if (ircd->regmode) {
- ci->c->mode &= ~ircd->regmode;
- anope_cmd_mode(whosends(ci), ci->name, "-r");
- }
- }
-
- if (ircd->chansqline && (ci->flags & CI_VERBOTEN)) {
- anope_cmd_unsqline(ci->name);
- }
-
- alog("%s: Channel %s dropped by %s!%s@%s (founder: %s)",
- s_ChanServ, ci->name, u->nick, u->username,
- u->host, (ci->founder ? ci->founder->display : "(none)"));
-
- delchan(ci);
-
- /* We must make sure that the Services admin has not normally the right to
- * drop the channel before issuing the wallops.
- */
- if (WallDrop && is_servadmin && level < ACCESS_FOUNDER)
- anope_cmd_global(s_ChanServ,
- "\2%s\2 used DROP on channel \2%s\2", u->nick,
- chan);
-
- notice_lang(s_ChanServ, u, CHAN_DROPPED, chan);
- send_event(EVENT_CHAN_DROP, chan);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Main SET routine. Calls other routines as follows:
- * do_set_command(User *command_sender, ChannelInfo *ci, char *param);
- * The parameter passed is the first space-delimited parameter after the
- * option name, except in the case of DESC, TOPIC, and ENTRYMSG, in which
- * it is the entire remainder of the line. Additional parameters beyond
- * the first passed in the function call can be retrieved using
- * strtok(NULL, toks).
- */
-static int do_set(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *cmd = strtok(NULL, " ");
- char *param;
- ChannelInfo *ci;
- int is_servadmin = is_services_admin(u);
-
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_SET_DISABLED);
- return MOD_CONT;
- }
-
- if (cmd) {
- if (stricmp(cmd, "DESC") == 0 || stricmp(cmd, "ENTRYMSG") == 0)
- param = strtok(NULL, "");
- else
- param = strtok(NULL, " ");
- } else {
- param = NULL;
- }
-
- if (!param && (!cmd || (stricmp(cmd, "SUCCESSOR") != 0 &&
- stricmp(cmd, "URL") != 0 &&
- stricmp(cmd, "EMAIL") != 0 &&
- stricmp(cmd, "ENTRYMSG") != 0))) {
- syntax_error(s_ChanServ, u, "SET", CHAN_SET_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!is_servadmin && !check_access(u, ci, CA_SET)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (stricmp(cmd, "FOUNDER") == 0) {
- if (!is_servadmin
- && (ci->
- flags & CI_SECUREFOUNDER ? !is_real_founder(u,
- ci) :
- !is_founder(u, ci))) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
- do_set_founder(u, ci, param);
- }
- } else if (stricmp(cmd, "SUCCESSOR") == 0) {
- if (!is_servadmin
- && (ci->
- flags & CI_SECUREFOUNDER ? !is_real_founder(u,
- ci) :
- !is_founder(u, ci))) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
- do_set_successor(u, ci, param);
- }
- } else if (stricmp(cmd, "PASSWORD") == 0) {
- if (!is_servadmin
- && (ci->
- flags & CI_SECUREFOUNDER ? !is_real_founder(u,
- ci) :
- !is_founder(u, ci))) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
- do_set_password(u, ci, param);
- }
- } else if (stricmp(cmd, "DESC") == 0) {
- do_set_desc(u, ci, param);
- } else if (stricmp(cmd, "URL") == 0) {
- do_set_url(u, ci, param);
- } else if (stricmp(cmd, "EMAIL") == 0) {
- do_set_email(u, ci, param);
- } else if (stricmp(cmd, "ENTRYMSG") == 0) {
- do_set_entrymsg(u, ci, param);
- } else if (stricmp(cmd, "TOPIC") == 0) {
- notice_lang(s_ChanServ, u, OBSOLETE_COMMAND, "TOPIC");
- } else if (stricmp(cmd, "BANTYPE") == 0) {
- do_set_bantype(u, ci, param);
- } else if (stricmp(cmd, "MLOCK") == 0) {
- do_set_mlock(u, ci, param);
- } else if (stricmp(cmd, "KEEPTOPIC") == 0) {
- do_set_keeptopic(u, ci, param);
- } else if (stricmp(cmd, "TOPICLOCK") == 0) {
- do_set_topiclock(u, ci, param);
- } else if (stricmp(cmd, "PRIVATE") == 0) {
- do_set_private(u, ci, param);
- } else if (stricmp(cmd, "SECUREOPS") == 0) {
- do_set_secureops(u, ci, param);
- } else if (stricmp(cmd, "SECUREFOUNDER") == 0) {
- if (!is_servadmin
- && (ci->
- flags & CI_SECUREFOUNDER ? !is_real_founder(u,
- ci) :
- !is_founder(u, ci))) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
- do_set_securefounder(u, ci, param);
- }
- } else if (stricmp(cmd, "RESTRICTED") == 0) {
- do_set_restricted(u, ci, param);
- } else if (stricmp(cmd, "SECURE") == 0) {
- do_set_secure(u, ci, param);
- } else if (stricmp(cmd, "SIGNKICK") == 0) {
- do_set_signkick(u, ci, param);
- } else if (stricmp(cmd, "OPNOTICE") == 0) {
- do_set_opnotice(u, ci, param);
- } else if (stricmp(cmd, "XOP") == 0) {
- do_set_xop(u, ci, param);
- } else if (stricmp(cmd, "PEACE") == 0) {
- do_set_peace(u, ci, param);
- } else if (stricmp(cmd, "NOEXPIRE") == 0) {
- do_set_noexpire(u, ci, param);
- } else {
- notice_lang(s_ChanServ, u, CHAN_SET_UNKNOWN_OPTION, cmd);
- notice_lang(s_ChanServ, u, MORE_INFO, s_ChanServ, "SET");
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_founder(User * u, ChannelInfo * ci, char *param)
-{
- NickAlias *na = findnick(param);
- NickCore *nc, *nc0 = ci->founder;
-
- if (!na) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param);
- return MOD_CONT;
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param);
- return MOD_CONT;
- }
-
- nc = na->nc;
- if (nc->channelmax > 0 && nc->channelcount >= nc->channelmax
- && !is_services_admin(u)) {
- notice_lang(s_ChanServ, u, CHAN_SET_FOUNDER_TOO_MANY_CHANS, param);
- return MOD_CONT;
- }
-
- alog("%s: Changing founder of %s from %s to %s by %s!%s@%s",
- s_ChanServ, ci->name, ci->founder->display, nc->display, u->nick,
- u->username, u->host);
-
- /* Founder and successor must not be the same group */
- if (nc == ci->successor)
- ci->successor = NULL;
-
- nc0->channelcount--;
- ci->founder = nc;
- nc->channelcount++;
-
- notice_lang(s_ChanServ, u, CHAN_FOUNDER_CHANGED, ci->name, param);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_successor(User * u, ChannelInfo * ci, char *param)
-{
- NickAlias *na;
- NickCore *nc;
-
- if (param) {
- na = findnick(param);
-
- if (!na) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param);
- return MOD_CONT;
- }
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param);
- return MOD_CONT;
- }
- if (na->nc == ci->founder) {
- notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_IS_FOUNDER, param,
- ci->name);
- return MOD_CONT;
- }
- nc = na->nc;
-
- } else {
- nc = NULL;
- }
-
- alog("%s: Changing successor of %s from %s to %s by %s!%s@%s",
- s_ChanServ, ci->name,
- (ci->successor ? ci->successor->display : "none"),
- (nc ? nc->display : "none"), u->nick, u->username, u->host);
-
- ci->successor = nc;
-
- if (nc)
- notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_CHANGED, ci->name,
- param);
- else
- notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_UNSET, ci->name);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_password(User * u, ChannelInfo * ci, char *param)
-{
- int len = strlen(param);
-
- if (stricmp(u->nick, param) == 0 || (StrictPasswords && len < 5)) {
- notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD);
- return MOD_CONT;
- }
-#ifdef USE_ENCRYPTION
- if (len > PASSMAX) {
- len = PASSMAX;
- param[len] = 0;
- notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX);
- }
-
- if (encrypt(param, len, ci->founderpass, PASSMAX) < 0) {
- memset(param, 0, strlen(param));
- alog("%s: Failed to encrypt password for %s (set)", s_ChanServ,
- ci->name);
- notice_lang(s_ChanServ, u, CHAN_SET_PASSWORD_FAILED);
- return MOD_CONT;
- }
-
- memset(param, 0, strlen(param));
- notice_lang(s_ChanServ, u, CHAN_PASSWORD_CHANGED, ci->name);
-
-#else /* !USE_ENCRYPTION */
- if (strlen(param) > PASSMAX - 1) /* -1 for null byte */
- notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX - 1);
- strscpy(ci->founderpass, param, PASSMAX);
- notice_lang(s_ChanServ, u, CHAN_PASSWORD_CHANGED_TO, ci->name,
- ci->founderpass);
-#endif /* USE_ENCRYPTION */
-
- if (get_access(u, ci) < ACCESS_FOUNDER) {
- alog("%s: %s!%s@%s set password as Services admin for %s",
- s_ChanServ, u->nick, u->username, u->host, ci->name);
- if (WallSetpass)
- anope_cmd_global(s_ChanServ,
- "\2%s\2 set password as Services admin for channel \2%s\2",
- u->nick, ci->name);
- } else {
- alog("%s: %s!%s@%s changed password of %s (founder: %s)",
- s_ChanServ, u->nick, u->username, u->host,
- ci->name, ci->founder->display);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_desc(User * u, ChannelInfo * ci, char *param)
-{
- if (ci->desc)
- free(ci->desc);
- ci->desc = sstrdup(param);
- notice_lang(s_ChanServ, u, CHAN_DESC_CHANGED, ci->name, param);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_url(User * u, ChannelInfo * ci, char *param)
-{
- if (ci->url)
- free(ci->url);
- if (param) {
- ci->url = sstrdup(param);
- notice_lang(s_ChanServ, u, CHAN_URL_CHANGED, ci->name, param);
- } else {
- ci->url = NULL;
- notice_lang(s_ChanServ, u, CHAN_URL_UNSET, ci->name);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_email(User * u, ChannelInfo * ci, char *param)
-{
- if (ci->email)
- free(ci->email);
- if (param) {
- ci->email = sstrdup(param);
- notice_lang(s_ChanServ, u, CHAN_EMAIL_CHANGED, ci->name, param);
- } else {
- ci->email = NULL;
- notice_lang(s_ChanServ, u, CHAN_EMAIL_UNSET, ci->name);
- }
- return MOD_CONT;
-}
-
/*************************************************************************/
-static int do_set_entrymsg(User * u, ChannelInfo * ci, char *param)
-{
- if (ci->entry_message)
- free(ci->entry_message);
- if (param) {
- ci->entry_message = sstrdup(param);
- notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_CHANGED, ci->name,
- param);
- } else {
- ci->entry_message = NULL;
- notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_UNSET, ci->name);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_mlock(User * u, ChannelInfo * ci, char *param)
-{
- int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */
- unsigned char mode;
- CBMode *cbm;
-
- if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) {
- notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED);
- return MOD_CONT;
- }
-
- /* Reinitialize everything */
- if (ircd->chanreg) {
- ci->mlock_on = ircd->regmode;
- } else {
- ci->mlock_on = 0;
- }
- ci->mlock_off = ci->mlock_limit = 0;
- ci->mlock_key = NULL;
- if (ircd->fmode) {
- ci->mlock_flood = NULL;
- }
- if (ircd->Lmode) {
- ci->mlock_redirect = NULL;
- }
-
- while ((mode = *param++)) {
- switch (mode) {
- case '+':
- add = 1;
- continue;
- case '-':
- add = 0;
- continue;
- default:
- if (add < 0)
- continue;
- }
-
- if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) {
- if ((cbm->flags & CBM_NO_MLOCK)
- || ((cbm->flags & CBM_NO_USER_MLOCK) && !is_oper(u))) {
- notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR,
- mode);
- } else if (add) {
- ci->mlock_on |= cbm->flag;
- ci->mlock_off &= ~cbm->flag;
- if (cbm->cssetvalue)
- cbm->cssetvalue(ci, strtok(NULL, " "));
- } else {
- ci->mlock_off |= cbm->flag;
- if (ci->mlock_on & cbm->flag) {
- ci->mlock_on &= ~cbm->flag;
- if (cbm->cssetvalue)
- cbm->cssetvalue(ci, NULL);
- }
- }
- } else {
- notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_UNKNOWN_CHAR, mode);
- }
- } /* while (*param) */
-
- if (ircd->Lmode) {
- /* We can't mlock +L if +l is not mlocked as well. */
- if ((ci->mlock_on & ircd->chan_lmode) && !(ci->mlock_on & CMODE_l)) {
- ci->mlock_on &= ~ircd->chan_lmode;
- free(ci->mlock_redirect);
- notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED);
- }
- }
-
- /* Some ircd we can't set NOKNOCK without INVITE */
- /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */
- if (ircd->noknock && ircd->knock_needs_i) {
- if ((ci->mlock_on & ircd->noknock) && !(ci->mlock_on & CMODE_i)) {
- ci->mlock_on &= ~ircd->noknock;
- notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED);
- }
- }
-
- /* Since we always enforce mode r there is no way to have no
- * mode lock at all.
- */
- if (get_mlock_modes(ci, 0)) {
- notice_lang(s_ChanServ, u, CHAN_MLOCK_CHANGED, ci->name,
- get_mlock_modes(ci, 0));
- }
-
- /* Implement the new lock. */
- if (ci->c)
- check_modes(ci->c);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_bantype(User * u, ChannelInfo * ci, char *param)
-{
- char *endptr;
-
- int16 bantype = strtol(param, &endptr, 10);
-
- if (*endptr != 0 || bantype < 0 || bantype > 3) {
- notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_INVALID, param);
- } else {
- ci->bantype = bantype;
- notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_CHANGED, ci->name,
- ci->bantype);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_keeptopic(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_KEEPTOPIC;
- notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_KEEPTOPIC;
- notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET KEEPTOPIC",
- CHAN_SET_KEEPTOPIC_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_topiclock(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_TOPICLOCK;
- notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_TOPICLOCK;
- notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET TOPICLOCK",
- CHAN_SET_TOPICLOCK_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_private(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_PRIVATE;
- notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_PRIVATE;
- notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET PRIVATE",
- CHAN_SET_PRIVATE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_secureops(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_SECUREOPS;
- notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_SECUREOPS;
- notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET SECUREOPS",
- CHAN_SET_SECUREOPS_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_securefounder(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_SECUREFOUNDER;
- notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_SECUREFOUNDER;
- notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET SECUREFOUNDER",
- CHAN_SET_SECUREFOUNDER_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_restricted(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_RESTRICTED;
- if (ci->levels[CA_NOJOIN] < 0)
- ci->levels[CA_NOJOIN] = 0;
- notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_RESTRICTED;
- if (ci->levels[CA_NOJOIN] >= 0)
- ci->levels[CA_NOJOIN] = -2;
- notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET RESTRICTED",
- CHAN_SET_RESTRICTED_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_secure(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_SECURE;
- notice_lang(s_ChanServ, u, CHAN_SET_SECURE_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_SECURE;
- notice_lang(s_ChanServ, u, CHAN_SET_SECURE_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET SECURE", CHAN_SET_SECURE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_signkick(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_SIGNKICK;
- ci->flags &= ~CI_SIGNKICK_LEVEL;
- notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_ON, ci->name);
- } else if (stricmp(param, "LEVEL") == 0) {
- ci->flags |= CI_SIGNKICK_LEVEL;
- ci->flags &= ~CI_SIGNKICK;
- notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_LEVEL, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~(CI_SIGNKICK | CI_SIGNKICK_LEVEL);
- notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET SIGNKICK",
- CHAN_SET_SIGNKICK_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_opnotice(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_OPNOTICE;
- notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_OPNOTICE;
- notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET OPNOTICE",
- CHAN_SET_OPNOTICE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-#define CHECKLEV(lev) ((ci->levels[(lev)] != ACCESS_INVALID) && (access->level >= ci->levels[(lev)]))
-
-static int do_set_xop(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- if (!(ci->flags & CI_XOP)) {
- int i;
- ChanAccess *access;
-
- for (access = ci->access, i = 0; i < ci->accesscount;
- access++, i++) {
- if (!access->in_use)
- continue;
- /* This will probably cause wrong levels to be set, but hey,
- * it's better than losing it altogether.
- */
- if (CHECKLEV(CA_AKICK) || CHECKLEV(CA_SET)) {
- access->level = ACCESS_SOP;
- } else if (CHECKLEV(CA_AUTOOP) || CHECKLEV(CA_OPDEOP)
- || CHECKLEV(CA_OPDEOPME)) {
- access->level = ACCESS_AOP;
- } else if (ircd->halfop) {
- if (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP)
- || CHECKLEV(CA_HALFOPME)) {
- access->level = ACCESS_HOP;
- }
- } else if (CHECKLEV(CA_AUTOVOICE) || CHECKLEV(CA_VOICE)
- || CHECKLEV(CA_VOICEME)) {
- access->level = ACCESS_VOP;
- } else {
- access->in_use = 0;
- access->nc = NULL;
- }
- }
-
- reset_levels(ci);
- ci->flags |= CI_XOP;
- }
-
- alog("%s: %s!%s@%s enabled XOP for %s", s_ChanServ, u->nick,
- u->username, u->host, ci->name);
- notice_lang(s_ChanServ, u, CHAN_SET_XOP_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_XOP;
-
- alog("%s: %s!%s@%s disabled XOP for %s", s_ChanServ, u->nick,
- u->username, u->host, ci->name);
- notice_lang(s_ChanServ, u, CHAN_SET_XOP_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET XOP", CHAN_SET_XOP_SYNTAX);
- }
- return MOD_CONT;
-}
-
-#undef CHECKLEV
-
-/*************************************************************************/
-
-static int do_set_peace(User * u, ChannelInfo * ci, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_PEACE;
- notice_lang(s_ChanServ, u, CHAN_SET_PEACE_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_PEACE;
- notice_lang(s_ChanServ, u, CHAN_SET_PEACE_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET PEACE", CHAN_SET_PEACE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_noexpire(User * u, ChannelInfo * ci, char *param)
-{
- if (!is_services_admin(u)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
- if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_NO_EXPIRE;
- notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_ON, ci->name);
- } else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_NO_EXPIRE;
- notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_OFF, ci->name);
- } else {
- syntax_error(s_ChanServ, u, "SET NOEXPIRE",
- CHAN_SET_NOEXPIRE_SYNTAX);
- }
- return MOD_CONT;
-}
/*************************************************************************/
@@ -3654,655 +2436,6 @@ static int do_set_noexpire(User * u, ChannelInfo * ci, char *param)
* `perm' is incremented whenever a permission-denied error occurs
*/
-static int xop_del(User * u, ChanAccess * access, int *perm, int uacc,
- int xlev)
-{
- if (!access->in_use || access->level != xlev)
- return 0;
- if (!is_services_admin(u) && uacc <= access->level) {
- (*perm)++;
- return 0;
- }
- access->nc = NULL;
- access->in_use = 0;
- return 1;
-}
-
-static int xop_del_callback(User * u, int num, va_list args)
-{
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *last = va_arg(args, int *);
- int *perm = va_arg(args, int *);
- int uacc = va_arg(args, int);
- int xlev = va_arg(args, int);
-
- if (num < 1 || num > ci->accesscount)
- return 0;
- *last = num;
-
- return xop_del(u, &ci->access[num - 1], perm, uacc, xlev);
-}
-
-
-static int xop_list(User * u, int index, ChannelInfo * ci,
- int *sent_header, int xlev, int xmsg)
-{
- ChanAccess *access = &ci->access[index];
-
- if (!access->in_use || access->level != xlev)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_ChanServ, u, xmsg, ci->name);
- *sent_header = 1;
- }
-
- notice_lang(s_ChanServ, u, CHAN_XOP_LIST_FORMAT, index + 1,
- access->nc->display);
- return 1;
-}
-
-static int xop_list_callback(User * u, int num, va_list args)
-{
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *sent_header = va_arg(args, int *);
- int xlev = va_arg(args, int);
- int xmsg = va_arg(args, int);
-
- if (num < 1 || num > ci->accesscount)
- return 0;
-
- return xop_list(u, num - 1, ci, sent_header, xlev, xmsg);
-}
-
-
-static int do_xop(User * u, char *xname, int xlev, int *xmsgs)
-{
- char *chan = strtok(NULL, " ");
- char *cmd = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
-
- ChannelInfo *ci;
- NickAlias *na;
- NickCore *nc;
-
- int i;
- int change = 0;
- short ulev;
- int is_list = (cmd && stricmp(cmd, "LIST") == 0);
- int is_servadmin = is_services_admin(u);
- ChanAccess *access;
-
- /* If CLEAR, we don't need any parameters.
- * If LIST, we don't *require* any parameters, but we can take any.
- * If DEL or ADD we require a nick. */
- if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 : !nick)) {
- syntax_error(s_ChanServ, u, xname, xmsgs[0]);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!(ci->flags & CI_XOP)) {
- notice_lang(s_ChanServ, u, CHAN_XOP_ACCESS, s_ChanServ);
- } else if (stricmp(cmd, "ADD") == 0) {
- if (readonly) {
- notice_lang(s_ChanServ, u, xmsgs[1]);
- return MOD_CONT;
- }
-
- ulev = get_access(u, ci);
-
- if ((xlev >= ulev || ulev < ACCESS_AOP) && !is_servadmin) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- na = findnick(nick);
- if (!na) {
- notice_lang(s_ChanServ, u, xmsgs[2]);
- return MOD_CONT;
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, na->nick);
- return MOD_CONT;
- }
-
- nc = na->nc;
- for (access = ci->access, i = 0; i < ci->accesscount;
- access++, i++) {
- if (access->nc == nc) {
- /**
- * Patch provided by PopCorn to prevert AOP's reducing SOP's levels
- **/
- if ((access->level >= ulev) && (!is_servadmin)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
- change++;
- break;
- }
- }
-
- if (!change) {
- for (i = 0; i < ci->accesscount; i++)
- if (!ci->access[i].in_use)
- break;
-
- if (i == ci->accesscount) {
- if (i < CSAccessMax) {
- ci->accesscount++;
- ci->access =
- srealloc(ci->access,
- sizeof(ChanAccess) * ci->accesscount);
- } else {
- notice_lang(s_ChanServ, u, CHAN_XOP_REACHED_LIMIT,
- CSAccessMax);
- return MOD_CONT;
- }
- }
-
- access = &ci->access[i];
- access->nc = nc;
- }
-
- access->in_use = 1;
- access->level = xlev;
- access->last_seen = 0;
-
- alog("%s: %s!%s@%s (level %d) %s access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, change ? "changed" : "set", access->level, na->nick, nc->display, ci->name);
-
- if (!change) {
- notice_lang(s_ChanServ, u, xmsgs[3], access->nc->display,
- ci->name);
- } else {
- notice_lang(s_ChanServ, u, xmsgs[4], access->nc->display,
- ci->name);
- }
-
- } else if (stricmp(cmd, "DEL") == 0) {
- int deleted, a, b;
- if (readonly) {
- notice_lang(s_ChanServ, u, xmsgs[1]);
- return MOD_CONT;
- }
-
- if (ci->accesscount == 0) {
- notice_lang(s_ChanServ, u, xmsgs[11], chan);
- return MOD_CONT;
- }
-
- ulev = get_access(u, ci);
-
- /* Special case: is it a number/list? Only do search if it isn't. */
- if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) {
- int count, last = -1, perm = 0;
- deleted =
- process_numlist(nick, &count, xop_del_callback, u, ci,
- &last, &perm, ulev, xlev);
- if (!deleted) {
- if (perm) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else if (count == 1) {
- notice_lang(s_ChanServ, u, xmsgs[5], last, ci->name);
- } else {
- notice_lang(s_ChanServ, u, xmsgs[7], ci->name);
- }
- } else if (deleted == 1) {
- notice_lang(s_ChanServ, u, xmsgs[9], ci->name);
- } else {
- notice_lang(s_ChanServ, u, xmsgs[10], deleted, ci->name);
- }
- } else {
- na = findnick(nick);
- if (!na) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, nick);
- return MOD_CONT;
- }
- nc = na->nc;
-
- for (i = 0; i < ci->accesscount; i++)
- if (ci->access[i].nc == nc && ci->access[i].level == xlev)
- break;
-
- if (i == ci->accesscount) {
- notice_lang(s_ChanServ, u, xmsgs[6], nick, chan);
- return MOD_CONT;
- }
-
- access = &ci->access[i];
- if (!is_servadmin && ulev <= access->level) {
- deleted = 0;
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- notice_lang(s_ChanServ, u, xmsgs[8], access->nc->display,
- ci->name);
- access->nc = NULL;
- access->in_use = 0;
- deleted = 1;
- }
- }
- if (deleted) {
- /* Reordering - DrStein */
- for (b = 0; b < ci->accesscount; b++) {
- if (ci->access[b].in_use) {
- for (a = 0; a < ci->accesscount; a++) {
- if (a > b)
- break;
- if (!ci->access[a].in_use) {
- ci->access[a].in_use = 1;
- ci->access[a].level = ci->access[b].level;
- ci->access[a].nc = ci->access[b].nc;
- ci->access[a].last_seen =
- ci->access[b].last_seen;
- ci->access[b].nc = NULL;
- ci->access[b].in_use = 0;
- break;
- }
- }
- }
- }
- }
- } else if (stricmp(cmd, "LIST") == 0) {
- int sent_header = 0;
-
- ulev = get_access(u, ci);
-
- if (!is_servadmin && ulev < ACCESS_AOP) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- return MOD_CONT;
- }
-
- if (ci->accesscount == 0) {
- notice_lang(s_ChanServ, u, xmsgs[11], ci->name);
- return MOD_CONT;
- }
-
- if (nick && strspn(nick, "1234567890,-") == strlen(nick)) {
- process_numlist(nick, NULL, xop_list_callback, u, ci,
- &sent_header, xlev, xmsgs[12]);
- } else {
- for (i = 0; i < ci->accesscount; i++) {
- if (nick && ci->access[i].nc
- && !match_wild_nocase(nick, ci->access[i].nc->display))
- continue;
- xop_list(u, i, ci, &sent_header, xlev, xmsgs[12]);
- }
- }
- if (!sent_header)
- notice_lang(s_ChanServ, u, xmsgs[7], chan);
- } else if (stricmp(cmd, "CLEAR") == 0) {
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED);
- return MOD_CONT;
- }
-
- if (ci->accesscount == 0) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
- return MOD_CONT;
- }
-
- if (!is_servadmin && !is_founder(u, ci)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- for (i = 0; i < ci->accesscount; i++) {
- if (ci->access[i].in_use && ci->access[i].level == xlev) {
- ci->access[i].nc = NULL;
- ci->access[i].in_use = 0;
- }
- }
-
- notice_lang(s_ChanServ, u, xmsgs[13], ci->name);
- } else {
- syntax_error(s_ChanServ, u, xname, xmsgs[0]);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_aop(User * u)
-{
- return do_xop(u, "AOP", ACCESS_AOP, xop_msgs[0]);
-}
-
-/*************************************************************************/
-
-static int do_hop(User * u)
-{
- return do_xop(u, "HOP", ACCESS_HOP, xop_msgs[3]);
-}
-
-/*************************************************************************/
-
-static int do_sop(User * u)
-{
- return do_xop(u, "SOP", ACCESS_SOP, xop_msgs[1]);
-}
-
-/*************************************************************************/
-
-static int do_vop(User * u)
-{
- return do_xop(u, "VOP", ACCESS_VOP, xop_msgs[2]);
-}
-
-/*************************************************************************/
-
-/* `last' is set to the last index this routine was called with
- * `perm' is incremented whenever a permission-denied error occurs
- */
-
-static int access_del(User * u, ChanAccess * access, int *perm, int uacc)
-{
- if (!access->in_use)
- return 0;
- if (!is_services_admin(u) && uacc <= access->level) {
- (*perm)++;
- return 0;
- }
- access->nc = NULL;
- access->in_use = 0;
- return 1;
-}
-
-static int access_del_callback(User * u, int num, va_list args)
-{
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *last = va_arg(args, int *);
- int *perm = va_arg(args, int *);
- int uacc = va_arg(args, int);
- if (num < 1 || num > ci->accesscount)
- return 0;
- *last = num;
- return access_del(u, &ci->access[num - 1], perm, uacc);
-}
-
-
-static int access_list(User * u, int index, ChannelInfo * ci,
- int *sent_header)
-{
- ChanAccess *access = &ci->access[index];
- char *xop;
-
- if (!access->in_use)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_HEADER, ci->name);
- *sent_header = 1;
- }
-
- if (ci->flags & CI_XOP) {
- xop = get_xop_level(access->level);
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_XOP_FORMAT, index + 1,
- xop, access->nc->display);
- } else {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_AXS_FORMAT, index + 1,
- access->level, access->nc->display);
- }
- return 1;
-}
-
-static int access_list_callback(User * u, int num, va_list args)
-{
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *sent_header = va_arg(args, int *);
- if (num < 1 || num > ci->accesscount)
- return 0;
- return access_list(u, num - 1, ci, sent_header);
-}
-
-
-static int do_access(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *cmd = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
- char *s = strtok(NULL, " ");
-
- ChannelInfo *ci;
- NickAlias *na;
- NickCore *nc;
- ChanAccess *access;
-
- int i;
- int level = 0, ulev;
- int is_list = (cmd && stricmp(cmd, "LIST") == 0);
- int is_servadmin = is_services_admin(u);
-
- /* If LIST, we don't *require* any parameters, but we can take any.
- * If DEL, we require a nick and no level.
- * Else (ADD), we require a level (which implies a nick). */
- if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 :
- (stricmp(cmd, "DEL") == 0) ? (!nick || s) : !s)) {
- syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- /* We still allow LIST in xOP mode, but not others */
- } else if ((ci->flags & CI_XOP) && !is_list) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP, s_ChanServ);
- } else if (((is_list && !check_access(u, ci, CA_ACCESS_LIST))
- || (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE)))
- && !is_servadmin) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (stricmp(cmd, "ADD") == 0) {
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED);
- return MOD_CONT;
- }
-
- level = atoi(s);
- ulev = get_access(u, ci);
-
- if (!is_servadmin && level >= ulev) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (level == 0) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_NONZERO);
- return MOD_CONT;
- } else if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_RANGE,
- ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
- return MOD_CONT;
- }
-
- na = findnick(nick);
- if (!na) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_NICKS_ONLY);
- return MOD_CONT;
- }
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, nick);
- return MOD_CONT;
- }
-
- nc = na->nc;
- for (access = ci->access, i = 0; i < ci->accesscount;
- access++, i++) {
- if (access->nc == nc) {
- /* Don't allow lowering from a level >= ulev */
- if (!is_servadmin && access->level >= ulev) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
- if (access->level == level) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_UNCHANGED,
- access->nc->display, chan, level);
- return MOD_CONT;
- }
- access->level = level;
- alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, access->level, na->nick, nc->display, ci->name);
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_CHANGED,
- access->nc->display, chan, level);
- return MOD_CONT;
- }
- }
-
- for (i = 0; i < ci->accesscount; i++) {
- if (!ci->access[i].in_use)
- break;
- }
- if (i == ci->accesscount) {
- if (i < CSAccessMax) {
- ci->accesscount++;
- ci->access =
- srealloc(ci->access,
- sizeof(ChanAccess) * ci->accesscount);
- } else {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_REACHED_LIMIT,
- CSAccessMax);
- return MOD_CONT;
- }
- }
-
- access = &ci->access[i];
- access->nc = nc;
- access->in_use = 1;
- access->level = level;
- access->last_seen = 0;
-
- alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, access->level, na->nick, nc->display, ci->name);
- notice_lang(s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display,
- ci->name, access->level);
- } else if (stricmp(cmd, "DEL") == 0) {
- int deleted, a, b;
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED);
- return MOD_CONT;
- }
-
- if (ci->accesscount == 0) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
- return MOD_CONT;
- }
-
- /* Special case: is it a number/list? Only do search if it isn't. */
- if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) {
- int count, last = -1, perm = 0;
- deleted = process_numlist(nick, &count, access_del_callback, u,
- ci, &last, &perm, get_access(u, ci));
- if (!deleted) {
- if (perm) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else if (count == 1) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_SUCH_ENTRY,
- last, ci->name);
- } else {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_MATCH,
- ci->name);
- }
- } else if (deleted == 1) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED_ONE,
- ci->name);
- } else {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED_SEVERAL,
- deleted, ci->name);
- }
- } else {
- na = findnick(nick);
- if (!na) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, nick);
- return MOD_CONT;
- }
- nc = na->nc;
- for (i = 0; i < ci->accesscount; i++) {
- if (ci->access[i].nc == nc)
- break;
- }
- if (i == ci->accesscount) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_NOT_FOUND, nick,
- chan);
- return MOD_CONT;
- }
- access = &ci->access[i];
- if (!is_servadmin && get_access(u, ci) <= access->level) {
- deleted = 0;
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED,
- access->nc->display, ci->name);
- alog("%s: %s!%s@%s (level %d) deleted access of %s (group %s) on %s", s_ChanServ, u->nick, u->username, u->host, get_access(u, ci), na->nick, access->nc->display, chan);
- access->nc = NULL;
- access->in_use = 0;
- deleted = 1;
- }
- }
-
- if (deleted) {
- /* Reordering - DrStein */
- for (b = 0; b < ci->accesscount; b++) {
- if (ci->access[b].in_use) {
- for (a = 0; a < ci->accesscount; a++) {
- if (a > b)
- break;
- if (!ci->access[a].in_use) {
- ci->access[a].in_use = 1;
- ci->access[a].level = ci->access[b].level;
- ci->access[a].nc = ci->access[b].nc;
- ci->access[a].last_seen =
- ci->access[b].last_seen;
- ci->access[b].nc = NULL;
- ci->access[b].in_use = 0;
- break;
- }
- }
- }
- }
- }
- } else if (stricmp(cmd, "LIST") == 0) {
- int sent_header = 0;
-
- if (ci->accesscount == 0) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
- return MOD_CONT;
- }
- if (nick && strspn(nick, "1234567890,-") == strlen(nick)) {
- process_numlist(nick, NULL, access_list_callback, u, ci,
- &sent_header);
- } else {
- for (i = 0; i < ci->accesscount; i++) {
- if (nick && ci->access[i].nc
- && !match_wild_nocase(nick, ci->access[i].nc->display))
- continue;
- access_list(u, i, ci, &sent_header);
- }
- }
- if (!sent_header) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_MATCH, chan);
- } else {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_FOOTER, ci->name);
- }
- } else if (stricmp(cmd, "CLEAR") == 0) {
-
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED);
- return MOD_CONT;
- }
-
- if (!is_servadmin && !is_founder(u, ci)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- free(ci->access);
- ci->access = NULL;
- ci->accesscount = 0;
-
- notice_lang(s_ChanServ, u, CHAN_ACCESS_CLEAR, ci->name);
- alog("%s: %s!%s@%s (level %d) cleared access list on %s",
- s_ChanServ, u->nick, u->username, u->host,
- get_access(u, ci), chan);
-
- } else {
- syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX);
- }
- return MOD_CONT;
-}
/*************************************************************************/
@@ -4392,2170 +2525,3 @@ void stick_all(ChannelInfo * ci)
free(av[0]);
}
}
-
-/* `last' is set to the last index this routine was called with */
-static int akick_del(User * u, AutoKick * akick)
-{
- if (!(akick->flags & AK_USED))
- return 0;
- if (akick->flags & AK_ISNICK) {
- akick->u.nc = NULL;
- } else {
- free(akick->u.mask);
- akick->u.mask = NULL;
- }
- if (akick->reason) {
- free(akick->reason);
- akick->reason = NULL;
- }
- if (akick->creator) {
- free(akick->creator);
- akick->creator = NULL;
- }
- akick->addtime = 0;
- akick->flags = 0;
- return 1;
-}
-
-static int akick_del_callback(User * u, int num, va_list args)
-{
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *last = va_arg(args, int *);
- if (num < 1 || num > ci->akickcount)
- return 0;
- *last = num;
- return akick_del(u, &ci->akick[num - 1]);
-}
-
-
-static int akick_list(User * u, int index, ChannelInfo * ci,
- int *sent_header)
-{
- AutoKick *akick = &ci->akick[index];
-
- if (!(akick->flags & AK_USED))
- return 0;
- if (!*sent_header) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name);
- *sent_header = 1;
- }
-
- notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1,
- ((akick->flags & AK_ISNICK) ? akick->u.nc->
- display : akick->u.mask),
- (akick->reason ? akick->
- reason : getstring(u->na, NO_REASON)));
- return 1;
-}
-
-static int akick_list_callback(User * u, int num, va_list args)
-{
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *sent_header = va_arg(args, int *);
- if (num < 1 || num > ci->akickcount)
- return 0;
- return akick_list(u, num - 1, ci, sent_header);
-}
-
-static int akick_view(User * u, int index, ChannelInfo * ci,
- int *sent_header)
-{
- AutoKick *akick = &ci->akick[index];
- char timebuf[64];
- struct tm tm;
-
- if (!(akick->flags & AK_USED))
- return 0;
- if (!*sent_header) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name);
- *sent_header = 1;
- }
-
- if (akick->addtime) {
- tm = *localtime(&akick->addtime);
- strftime_lang(timebuf, sizeof(timebuf), u,
- STRFTIME_SHORT_DATE_FORMAT, &tm);
- } else {
- snprintf(timebuf, sizeof(timebuf), getstring(u->na, UNKNOWN));
- }
-
- notice_lang(s_ChanServ, u,
- ((akick->
- flags & AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK :
- CHAN_AKICK_VIEW_FORMAT), index + 1,
- ((akick->flags & AK_ISNICK) ? akick->u.nc->
- display : akick->u.mask),
- akick->creator ? akick->creator : getstring(u->na,
- UNKNOWN),
- timebuf,
- (akick->reason ? akick->
- reason : getstring(u->na, NO_REASON)));
- return 1;
-}
-
-static int akick_view_callback(User * u, int num, va_list args)
-{
- ChannelInfo *ci = va_arg(args, ChannelInfo *);
- int *sent_header = va_arg(args, int *);
- if (num < 1 || num > ci->akickcount)
- return 0;
- return akick_view(u, num - 1, ci, sent_header);
-}
-
-static int do_akick(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *cmd = strtok(NULL, " ");
- char *mask = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
- ChannelInfo *ci;
- AutoKick *akick;
- int i;
- Channel *c;
- struct c_userlist *cu = NULL;
- struct c_userlist *next;
- char *argv[3];
- int count = 0;
-
- if (!cmd || (!mask && (!stricmp(cmd, "ADD") || !stricmp(cmd, "STICK")
- || !stricmp(cmd, "UNSTICK")
- || !stricmp(cmd, "DEL")))) {
-
- syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!check_access(u, ci, CA_AKICK) && !is_services_admin(u)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (stricmp(cmd, "ADD") == 0) {
-
- NickAlias *na = findnick(mask);
- NickCore *nc = NULL;
- char *nick, *user, *host;
-
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
- return MOD_CONT;
- }
-
- if (!na) {
- split_usermask(mask, &nick, &user, &host);
- mask =
- scalloc(strlen(nick) + strlen(user) + strlen(host) + 3, 1);
- sprintf(mask, "%s!%s@%s", nick, user, host);
- free(nick);
- free(user);
- free(host);
- } else {
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, mask);
- return MOD_CONT;
- }
- nc = na->nc;
- }
-
- /* Check excepts BEFORE we get this far */
- if (ircd->except) {
- if (is_excepted_mask(ci, mask) == 1) {
- notice_lang(s_ChanServ, u, CHAN_EXCEPTED, mask, chan);
- return MOD_CONT;
- }
- }
-
- for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) {
- if (!(akick->flags & AK_USED))
- continue;
- if ((akick->flags & AK_ISNICK) ? akick->u.nc == nc
- : stricmp(akick->u.mask, mask) == 0) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS,
- (akick->flags & AK_ISNICK) ? akick->u.nc->
- display : akick->u.mask, chan);
- return MOD_CONT;
- }
- }
-
- for (i = 0; i < ci->akickcount; i++) {
- if (!(ci->akick[i].flags & AK_USED))
- break;
- }
- if (i == ci->akickcount) {
- if (ci->akickcount >= CSAutokickMax) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT,
- CSAutokickMax);
- return MOD_CONT;
- }
- ci->akickcount++;
- ci->akick =
- srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount);
- }
- akick = &ci->akick[i];
- akick->flags = AK_USED;
- if (nc) {
- akick->flags |= AK_ISNICK;
- akick->u.nc = nc;
- } else {
- akick->u.mask = mask;
- }
- akick->creator = sstrdup(u->nick);
- akick->addtime = time(NULL);
- if (reason) {
- if (strlen(reason) > 200)
- reason[200] = '\0';
- akick->reason = sstrdup(reason);
- } else {
- akick->reason = NULL;
- }
-
- /* Auto ENFORCE #63 */
- c = findchan(ci->name);
- if (c) {
- cu = c->users;
- while (cu) {
- next = cu->next;
- if (check_kick(cu->user, c->name)) {
- argv[0] = sstrdup(c->name);
- argv[1] = sstrdup(cu->user->nick);
- if (akick->reason)
- argv[2] = sstrdup(akick->reason);
- else
- argv[2] = sstrdup("none");
-
- do_kick(s_ChanServ, 3, argv);
-
- free(argv[2]);
- free(argv[1]);
- free(argv[0]);
- count++;
-
- }
- cu = next;
- }
- }
- notice_lang(s_ChanServ, u, CHAN_AKICK_ADDED, mask, chan);
-
- if (count)
- notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan,
- count);
-
- } else if (stricmp(cmd, "STICK") == 0) {
- NickAlias *na;
- NickCore *nc;
-
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
- return MOD_CONT;
- }
-
- if (ci->akickcount == 0) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name);
- return MOD_CONT;
- }
-
- na = findnick(mask);
- nc = (na ? na->nc : NULL);
-
- for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) {
- if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK))
- continue;
- if (!stricmp(akick->u.mask, mask))
- break;
- }
-
- if (i == ci->akickcount) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask,
- ci->name);
- return MOD_CONT;
- }
-
- akick->flags |= AK_STUCK;
- notice_lang(s_ChanServ, u, CHAN_AKICK_STUCK, akick->u.mask,
- ci->name);
-
- if (ci->c)
- stick_mask(ci, akick);
- } else if (stricmp(cmd, "UNSTICK") == 0) {
- NickAlias *na;
- NickCore *nc;
-
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
- return MOD_CONT;
- }
-
- if (ci->akickcount == 0) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name);
- return MOD_CONT;
- }
-
- na = findnick(mask);
- nc = (na ? na->nc : NULL);
-
- for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) {
- if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK))
- continue;
- if (!stricmp(akick->u.mask, mask))
- break;
- }
-
- if (i == ci->akickcount) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask,
- ci->name);
- return MOD_CONT;
- }
-
- akick->flags &= ~AK_STUCK;
- notice_lang(s_ChanServ, u, CHAN_AKICK_UNSTUCK, akick->u.mask,
- ci->name);
-
- } else if (stricmp(cmd, "DEL") == 0) {
- int deleted, a, b;
-
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
- return MOD_CONT;
- }
-
- if (ci->akickcount == 0) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan);
- return MOD_CONT;
- }
-
- /* Special case: is it a number/list? Only do search if it isn't. */
- if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
- int count, last = -1;
- deleted = process_numlist(mask, &count, akick_del_callback, u,
- ci, &last);
- if (!deleted) {
- if (count == 1) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_NO_SUCH_ENTRY,
- last, ci->name);
- } else {
- notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH,
- ci->name);
- }
- } else if (deleted == 1) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_ONE,
- ci->name);
- } else {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_SEVERAL,
- deleted, ci->name);
- }
- } else {
- NickAlias *na = findnick(mask);
- NickCore *nc = (na ? na->nc : NULL);
-
- for (akick = ci->akick, i = 0; i < ci->akickcount;
- akick++, i++) {
- if (!(akick->flags & AK_USED))
- continue;
- if (((akick->flags & AK_ISNICK) && akick->u.nc == nc)
- || (!(akick->flags & AK_ISNICK)
- && stricmp(akick->u.mask, mask) == 0))
- break;
- }
- if (i == ci->akickcount) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask,
- chan);
- return MOD_CONT;
- }
- notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED, mask, chan);
- akick_del(u, akick);
- deleted = 1;
- }
- if (deleted) {
- /* Reordering - DrStein */
- for (b = 0; b < ci->akickcount; b++) {
- if (ci->akick[b].flags & AK_USED) {
- for (a = 1; a < ci->akickcount; a++) {
- if (a > b)
- break;
- if (!(ci->akick[a].flags & AK_USED)) {
- ci->akick[a].flags = ci->akick[b].flags;
- if (ci->akick[b].flags & AK_ISNICK) {
- ci->akick[a].u.nc = ci->akick[b].u.nc;
- } else {
- ci->akick[a].u.mask =
- sstrdup(ci->akick[b].u.mask);
- }
- ci->akick[a].reason =
- sstrdup(ci->akick[b].reason);
- ci->akick[a].creator =
- sstrdup(ci->akick[b].creator);
- ci->akick[a].addtime = ci->akick[b].addtime;
-
- akick_del(u, &ci->akick[b]);
- break;
- }
- }
- }
- }
- }
- } else if (stricmp(cmd, "LIST") == 0) {
- int sent_header = 0;
-
- if (ci->akickcount == 0) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan);
- return MOD_CONT;
- }
- if (mask && isdigit(*mask) &&
- strspn(mask, "1234567890,-") == strlen(mask)) {
- process_numlist(mask, NULL, akick_list_callback, u, ci,
- &sent_header);
- } else {
- for (akick = ci->akick, i = 0; i < ci->akickcount;
- akick++, i++) {
- if (!(akick->flags & AK_USED))
- continue;
- if (mask) {
- if (!(akick->flags & AK_ISNICK)
- && !match_wild_nocase(mask, akick->u.mask))
- continue;
- if ((akick->flags & AK_ISNICK)
- && !match_wild_nocase(mask, akick->u.nc->display))
- continue;
- }
- akick_list(u, i, ci, &sent_header);
- }
- }
- if (!sent_header)
- notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan);
-
- } else if (stricmp(cmd, "VIEW") == 0) {
- int sent_header = 0;
-
- if (ci->akickcount == 0) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan);
- return MOD_CONT;
- }
- if (mask && isdigit(*mask) &&
- strspn(mask, "1234567890,-") == strlen(mask)) {
- process_numlist(mask, NULL, akick_view_callback, u, ci,
- &sent_header);
- } else {
- for (akick = ci->akick, i = 0; i < ci->akickcount;
- akick++, i++) {
- if (!(akick->flags & AK_USED))
- continue;
- if (mask) {
- if (!(akick->flags & AK_ISNICK)
- && !match_wild_nocase(mask, akick->u.mask))
- continue;
- if ((akick->flags & AK_ISNICK)
- && !match_wild_nocase(mask, akick->u.nc->display))
- continue;
- }
- akick_view(u, i, ci, &sent_header);
- }
- }
- if (!sent_header)
- notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan);
-
- } else if (stricmp(cmd, "ENFORCE") == 0) {
- Channel *c = findchan(ci->name);
- struct c_userlist *cu = NULL;
- struct c_userlist *next;
- char *argv[3];
- int count = 0;
-
- if (!c) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, ci->name);
- return MOD_CONT;
- }
-
- cu = c->users;
-
- while (cu) {
- next = cu->next;
- if (check_kick(cu->user, c->name)) {
- argv[0] = sstrdup(c->name);
- argv[1] = sstrdup(cu->user->nick);
- argv[2] = sstrdup(CSAutokickReason);
-
- do_kick(s_ChanServ, 3, argv);
-
- free(argv[2]);
- free(argv[1]);
- free(argv[0]);
-
- count++;
- }
- cu = next;
- }
-
- notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan, count);
-
- } else if (stricmp(cmd, "CLEAR") == 0) {
-
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
- return MOD_CONT;
- }
-
- for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) {
- if (!(akick->flags & AK_USED))
- continue;
- akick_del(u, akick);
- }
-
- free(ci->akick);
- ci->akick = NULL;
- ci->akickcount = 0;
-
- notice_lang(s_ChanServ, u, CHAN_AKICK_CLEAR, ci->name);
-
- } else {
- syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_levels(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *cmd = strtok(NULL, " ");
- char *what = strtok(NULL, " ");
- char *s = strtok(NULL, " ");
- char *error;
-
- ChannelInfo *ci;
- int level;
- int i;
-
- /* If SET, we want two extra parameters; if DIS[ABLE] or FOUNDER, we want only
- * one; else, we want none.
- */
- if (!cmd
- || ((stricmp(cmd, "SET") == 0) ? !s
- : ((strnicmp(cmd, "DIS", 3) == 0)) ? (!what || s) : !!what)) {
- syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (ci->flags & CI_XOP) {
- notice_lang(s_ChanServ, u, CHAN_LEVELS_XOP);
- } else if (!is_founder(u, ci) && !is_services_admin(u)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (stricmp(cmd, "SET") == 0) {
- level = strtol(s, &error, 10);
-
- if (*error != '\0') {
- syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX);
- return MOD_CONT;
- }
-
- if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) {
- notice_lang(s_ChanServ, u, CHAN_LEVELS_RANGE,
- ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
- return MOD_CONT;
- }
-
- for (i = 0; levelinfo[i].what >= 0; i++) {
- if (stricmp(levelinfo[i].name, what) == 0) {
- ci->levels[levelinfo[i].what] = level;
-
- alog("%s: %s!%s@%s set level %s on channel %s to %d",
- s_ChanServ, u->nick, u->username, u->host,
- levelinfo[i].name, ci->name, level);
- notice_lang(s_ChanServ, u, CHAN_LEVELS_CHANGED,
- levelinfo[i].name, chan, level);
- return MOD_CONT;
- }
- }
-
- notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ);
-
- } else if (stricmp(cmd, "DIS") == 0 || stricmp(cmd, "DISABLE") == 0) {
- for (i = 0; levelinfo[i].what >= 0; i++) {
- if (stricmp(levelinfo[i].name, what) == 0) {
- ci->levels[levelinfo[i].what] = ACCESS_INVALID;
-
- alog("%s: %s!%s@%s disabled level %s on channel %s",
- s_ChanServ, u->nick, u->username, u->host,
- levelinfo[i].name, ci->name);
- notice_lang(s_ChanServ, u, CHAN_LEVELS_DISABLED,
- levelinfo[i].name, chan);
- return MOD_CONT;
- }
- }
-
- notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ);
- } else if (stricmp(cmd, "LIST") == 0) {
- int i;
-
- notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_HEADER, chan);
-
- if (!levelinfo_maxwidth) {
- for (i = 0; levelinfo[i].what >= 0; i++) {
- int len = strlen(levelinfo[i].name);
- if (len > levelinfo_maxwidth)
- levelinfo_maxwidth = len;
- }
- }
-
- for (i = 0; levelinfo[i].what >= 0; i++) {
- int j = ci->levels[levelinfo[i].what];
-
- if (j == ACCESS_INVALID) {
- j = levelinfo[i].what;
-
- if (j == CA_AUTOOP || j == CA_AUTODEOP || j == CA_AUTOVOICE
- || j == CA_NOJOIN) {
- notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED,
- levelinfo_maxwidth, levelinfo[i].name);
- } else {
- notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED,
- levelinfo_maxwidth, levelinfo[i].name);
- }
- } else if (j == ACCESS_FOUNDER) {
- notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_FOUNDER,
- levelinfo_maxwidth, levelinfo[i].name);
- } else {
- notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_NORMAL,
- levelinfo_maxwidth, levelinfo[i].name, j);
- }
- }
-
- } else if (stricmp(cmd, "RESET") == 0) {
- reset_levels(ci);
-
- alog("%s: %s!%s@%s reset levels definitions on channel %s",
- s_ChanServ, u->nick, u->username, u->host, ci->name);
- notice_lang(s_ChanServ, u, CHAN_LEVELS_RESET, chan);
- } else {
- syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* SADMINS and users, who have identified for a channel, can now cause it's
- * Enstry Message and Successor to be displayed by supplying the ALL parameter.
- * Syntax: INFO channel [ALL]
- * -TheShadow (29 Mar 1999)
- */
-
-static int do_info(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *param = strtok(NULL, " ");
- ChannelInfo *ci;
- char buf[BUFSIZE], *end;
- struct tm *tm;
- int need_comma = 0;
- const char *commastr = getstring(u->na, COMMA_SPACE);
- int is_servadmin = is_services_admin(u);
- int show_all = 0;
- time_t expt;
-
- if (!chan) {
- syntax_error(s_ChanServ, u, "INFO", CHAN_INFO_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- if (is_oper(u) && ci->forbidby)
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan,
- ci->forbidby,
- (ci->forbidreason ? ci->
- forbidreason : getstring(u->na, NO_REASON)));
- else
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!ci->founder) {
- /* Paranoia... this shouldn't be able to happen */
- delchan(ci);
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else {
-
- /* Should we show all fields? Only for sadmins and identified users */
- if (param && stricmp(param, "ALL") == 0 &&
- (check_access(u, ci, CA_INFO) || is_servadmin))
- show_all = 1;
-
- notice_lang(s_ChanServ, u, CHAN_INFO_HEADER, chan);
- notice_lang(s_ChanServ, u, CHAN_INFO_NO_FOUNDER,
- ci->founder->display);
-
- if (show_all && ci->successor)
- notice_lang(s_ChanServ, u, CHAN_INFO_NO_SUCCESSOR,
- ci->successor->display);
-
- notice_lang(s_ChanServ, u, CHAN_INFO_DESCRIPTION, ci->desc);
- tm = localtime(&ci->time_registered);
- strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
- notice_lang(s_ChanServ, u, CHAN_INFO_TIME_REGGED, buf);
- tm = localtime(&ci->last_used);
- strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
- notice_lang(s_ChanServ, u, CHAN_INFO_LAST_USED, buf);
- if (ci->last_topic && (show_all || (!(ci->mlock_on & CMODE_s)
- && (!ci->c
- || !(ci->c->
- mode & CMODE_s))))) {
- notice_lang(s_ChanServ, u, CHAN_INFO_LAST_TOPIC,
- ci->last_topic);
- notice_lang(s_ChanServ, u, CHAN_INFO_TOPIC_SET_BY,
- ci->last_topic_setter);
- }
-
- if (ci->entry_message && show_all)
- notice_lang(s_ChanServ, u, CHAN_INFO_ENTRYMSG,
- ci->entry_message);
- if (ci->url)
- notice_lang(s_ChanServ, u, CHAN_INFO_URL, ci->url);
- if (ci->email)
- notice_lang(s_ChanServ, u, CHAN_INFO_EMAIL, ci->email);
-
- if (show_all) {
- notice_lang(s_ChanServ, u, CHAN_INFO_BANTYPE, ci->bantype);
-
- end = buf;
- *end = 0;
- if (ci->flags & CI_KEEPTOPIC) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s",
- getstring(u->na, CHAN_INFO_OPT_KEEPTOPIC));
- need_comma = 1;
- }
- if (ci->flags & CI_OPNOTICE) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, CHAN_INFO_OPT_OPNOTICE));
- need_comma = 1;
- }
- if (ci->flags & CI_PEACE) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, CHAN_INFO_OPT_PEACE));
- need_comma = 1;
- }
- if (ci->flags & CI_PRIVATE) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, CHAN_INFO_OPT_PRIVATE));
- need_comma = 1;
- }
- if (ci->flags & CI_RESTRICTED) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na,
- CHAN_INFO_OPT_RESTRICTED));
- need_comma = 1;
- }
- if (ci->flags & CI_SECURE) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, CHAN_INFO_OPT_SECURE));
- need_comma = 1;
- }
- if (ci->flags & CI_SECUREOPS) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, CHAN_INFO_OPT_SECUREOPS));
- need_comma = 1;
- }
- if (ci->flags & CI_SECUREFOUNDER) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na,
- CHAN_INFO_OPT_SECUREFOUNDER));
- need_comma = 1;
- }
- if ((ci->flags & CI_SIGNKICK)
- || (ci->flags & CI_SIGNKICK_LEVEL)) {
- end +=
- snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "", getstring(u->na,
- CHAN_INFO_OPT_SIGNKICK));
- need_comma = 1;
- }
- if (ci->flags & CI_TOPICLOCK) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, CHAN_INFO_OPT_TOPICLOCK));
- need_comma = 1;
- }
- if (ci->flags & CI_XOP) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, CHAN_INFO_OPT_XOP));
- need_comma = 1;
- }
- notice_lang(s_ChanServ, u, CHAN_INFO_OPTIONS,
- *buf ? buf : getstring(u->na, CHAN_INFO_OPT_NONE));
- notice_lang(s_ChanServ, u, CHAN_INFO_MODE_LOCK,
- get_mlock_modes(ci, 1));
-
- }
- if (show_all) {
- if (ci->flags & CI_NO_EXPIRE) {
- notice_lang(s_ChanServ, u, CHAN_INFO_NO_EXPIRE);
- } else {
- if (is_servadmin) {
- expt = ci->last_used + CSExpire;
- tm = localtime(&expt);
- strftime_lang(buf, sizeof(buf), u,
- STRFTIME_DATE_TIME_FORMAT, tm);
- notice_lang(s_ChanServ, u, CHAN_INFO_EXPIRE, buf);
- }
- }
- }
- if (ci->flags & CI_SUSPENDED) {
- notice_lang(s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby,
- (ci->forbidreason ? ci->
- forbidreason : getstring(u->na, NO_REASON)));
- }
-
- if (!show_all && (check_access(u, ci, CA_INFO) || is_servadmin))
- notice_lang(s_ChanServ, u, NICK_INFO_FOR_MORE, s_ChanServ,
- ci->name);
-
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_list(User * u)
-{
- char *pattern = strtok(NULL, " ");
- ChannelInfo *ci;
- int nchans, i;
- char buf[BUFSIZE];
- int is_servadmin = is_services_admin(u);
- int count = 0, from = 0, to = 0;
- char *tmp = NULL;
- char *s = NULL;
- char *keyword;
- int32 matchflags = 0;
-
-
- if (CSListOpersOnly && (!u || !is_oper(u))) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (!pattern) {
- syntax_error(s_ChanServ, u, "LIST",
- is_servadmin ? CHAN_LIST_SERVADMIN_SYNTAX :
- CHAN_LIST_SYNTAX);
- } else {
-
- if (pattern) {
- if (pattern[0] == '#') {
- tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */
- if (!tmp) {
- return MOD_CONT;
- }
- for (s = tmp; *s; s++) {
- if (!isdigit(*s)) {
- return MOD_CONT;
- }
- }
- from = atoi(tmp);
- tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */
- if (!tmp) {
- return MOD_CONT;
- }
- for (s = tmp; *s; s++) {
- if (!isdigit(*s)) {
- return MOD_CONT;
- }
- }
- to = atoi(tmp);
- pattern = sstrdup("*");
- }
- }
-
- nchans = 0;
-
- while (is_servadmin && (keyword = strtok(NULL, " "))) {
- if (stricmp(keyword, "FORBIDDEN") == 0)
- matchflags |= CI_VERBOTEN;
- if (stricmp(keyword, "SUSPENDED") == 0)
- matchflags |= CI_SUSPENDED;
- if (stricmp(keyword, "NOEXPIRE") == 0)
- matchflags |= CI_NO_EXPIRE;
- }
-
- notice_lang(s_ChanServ, u, CHAN_LIST_HEADER, pattern);
- for (i = 0; i < 256; i++) {
- for (ci = chanlists[i]; ci; ci = ci->next) {
- if (!is_servadmin && ((ci->flags & CI_PRIVATE)
- || (ci->flags & CI_VERBOTEN)))
- continue;
- if ((matchflags != 0) && !(ci->flags & matchflags))
- continue;
-
- if (stricmp(pattern, ci->name) == 0
- || match_wild_nocase(pattern, ci->name)) {
- if ((((count + 1 >= from) && (count + 1 <= to))
- || ((from == 0) && (to == 0)))
- && (++nchans <= CSListMax)) {
- char noexpire_char = ' ';
- if (is_servadmin && (ci->flags & CI_NO_EXPIRE))
- noexpire_char = '!';
-
- if (ci->flags & CI_VERBOTEN) {
- snprintf(buf, sizeof(buf),
- "%-20s [Forbidden]", ci->name);
- } else if (ci->flags & CI_SUSPENDED) {
- snprintf(buf, sizeof(buf),
- "%-20s [Suspended]", ci->name);
- } else {
- snprintf(buf, sizeof(buf), "%-20s %s",
- ci->name, ci->desc ? ci->desc : "");
- }
-
- notice_user(s_ChanServ, u, " %c%s",
- noexpire_char, buf);
- }
- count++;
- }
- }
- }
- notice_lang(s_ChanServ, u, CHAN_LIST_END,
- nchans > CSListMax ? CSListMax : nchans, nchans);
- }
- return MOD_CONT;
-
-}
-
-/*************************************************************************/
-
-static int do_invite(User * u)
-{
- char *chan = strtok(NULL, " ");
- Channel *c;
- ChannelInfo *ci;
-
- if (!chan) {
- syntax_error(s_ChanServ, u, "INVITE", CHAN_INVITE_SYNTAX);
- } else if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!u || !check_access(u, ci, CA_INVITE)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- anope_cmd_invite(whosends(ci), chan, u->nick);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* do_util: not a command, but does the job of other */
-
-static int do_util(User * u, CSModeUtil * util)
-{
- char *av[2];
- char *chan = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
-
- Channel *c;
- ChannelInfo *ci;
- User *u2;
-
- int is_same;
-
- if (!chan) {
- struct u_chanlist *uc;
-
- av[0] = util->mode;
- av[1] = u->nick;
-
- /* Sets the mode to the user on every channels he is on. */
-
- for (uc = u->chans; uc; uc = uc->next) {
- if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
- && check_access(u, ci, util->levelself)) {
- anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
- util->mode, u->nick);
- chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
-
- if (util->notice && ci->flags & util->notice)
- notice(whosends(ci), uc->chan->name,
- "%s command used for %s by %s", util->name,
- u->nick, u->nick);
- }
- }
-
- return MOD_CONT;
- } else if (!nick) {
- nick = u->nick;
- }
-
- is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0);
-
- if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
- } else if (is_same ? !(u2 = u) : !(u2 = finduser(nick))) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
- } else if (!is_on_chan(c, u2)) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
- } else if (is_same ? !check_access(u, ci, util->levelself) :
- !check_access(u, ci, util->level)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (*util->mode == '-' && !is_same && (ci->flags & CI_PEACE)
- && (get_access(u2, ci) >= get_access(u, ci))) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else if (*util->mode == '-' && is_protected(u2)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- anope_cmd_mode(whosends(ci), c->name, "%s %s", util->mode,
- u2->nick);
-
- av[0] = util->mode;
- av[1] = u2->nick;
- chan_set_modes(s_ChanServ, c, 2, av, 1);
-
- if (util->notice && ci->flags & util->notice)
- notice(whosends(ci), c->name, "%s command used for %s by %s",
- util->name, u2->nick, u->nick);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_op(User * u)
-{
- return do_util(u, &csmodeutils[MUT_OP]);
-}
-
-/*************************************************************************/
-
-static int do_deop(User * u)
-{
- return do_util(u, &csmodeutils[MUT_DEOP]);
-}
-
-/*************************************************************************/
-
-static int do_voice(User * u)
-{
- return do_util(u, &csmodeutils[MUT_VOICE]);
-}
-
-/*************************************************************************/
-
-static int do_devoice(User * u)
-{
- return do_util(u, &csmodeutils[MUT_DEVOICE]);
-}
-
-/*************************************************************************/
-
-static int do_halfop(User * u)
-{
- if (ircd->halfop) {
- return do_util(u, &csmodeutils[MUT_HALFOP]);
- } else {
- return MOD_CONT;
- }
-}
-
-/*************************************************************************/
-
-static int do_dehalfop(User * u)
-{
- if (ircd->halfop) {
- return do_util(u, &csmodeutils[MUT_DEHALFOP]);
- } else {
- return MOD_CONT;
- }
-}
-
-/*************************************************************************/
-
-static int do_protect(User * u)
-{
- if (ircd->protect || ircd->admin) {
- return do_util(u, &csmodeutils[MUT_PROTECT]);
- } else {
- return MOD_CONT;
- }
-}
-
-/*************************************************************************/
-
-static int do_deprotect(User * u)
-{
- if (ircd->protect || ircd->admin) {
- return do_util(u, &csmodeutils[MUT_DEPROTECT]);
- } else {
- return MOD_CONT;
- }
-}
-
-/*************************************************************************/
-
-static int do_owner(User * u)
-{
- char *av[2];
- char *chan = strtok(NULL, " ");
-
- Channel *c;
- ChannelInfo *ci;
- struct u_chanlist *uc;
-
- if (!ircd->owner) {
- return MOD_CONT;
- }
-
- if (!chan) {
- av[0] = sstrdup(ircd->ownerset);
- av[1] = u->nick;
-
- /* Sets the mode to the user on every channels he is on. */
-
- for (uc = u->chans; uc; uc = uc->next) {
- if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
- && is_founder(u, ci)) {
- anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
- av[0], u->nick);
- chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
- }
- }
-
- free(av[0]);
- return MOD_CONT;
- }
-
- if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
- } else if (!is_on_chan(c, u)) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name);
- } else if (!is_founder(u, ci)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
- anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerset,
- u->nick);
-
- av[0] = sstrdup(ircd->ownerset);
- av[1] = u->nick;
- chan_set_modes(s_ChanServ, c, 2, av, 1);
- free(av[0]);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_deowner(User * u)
-{
- char *av[2];
- char *chan = strtok(NULL, " ");
-
- Channel *c;
- ChannelInfo *ci;
- struct u_chanlist *uc;
-
- if (!ircd->owner) {
- return MOD_CONT;
- }
-
- if (!chan) {
- av[0] = sstrdup(ircd->ownerunset);
- av[1] = u->nick;
-
- /* Sets the mode to the user on every channels he is on. */
-
- for (uc = u->chans; uc; uc = uc->next) {
- if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
- && is_founder(u, ci)) {
- anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
- av[0], u->nick);
- chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
- }
- }
-
- free(av[0]);
- return MOD_CONT;
- }
-
- if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
- } else if (!is_on_chan(c, u)) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name);
- } else if (!is_founder(u, ci)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
- anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerunset,
- u->nick);
-
- av[0] = sstrdup(ircd->ownerunset);
- av[1] = u->nick;
- chan_set_modes(s_ChanServ, c, 2, av, 1);
- free(av[0]);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_cs_kick(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *params = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- Channel *c;
- ChannelInfo *ci;
- User *u2;
-
- int is_same;
-
- if (!reason) {
- reason = "Requested";
- } else {
- if (strlen(reason) > 200)
- reason[200] = '\0';
- }
-
- if (!chan) {
- struct u_chanlist *uc, *next;
-
- /* Kicks the user on every channels he is on. */
-
- for (uc = u->chans; uc; uc = next) {
- next = uc->next;
- if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
- && check_access(u, ci, CA_KICKME)) {
- char *av[3];
-
- if ((ci->flags & CI_SIGNKICK)
- || ((ci->flags & CI_SIGNKICK_LEVEL)
- && !check_access(u, ci, CA_SIGNKICK)))
- anope_cmd_kick(whosends(ci), ci->name, u->nick,
- "%s (%s)", reason, u->nick);
- else
- anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s",
- reason);
- av[0] = ci->name;
- av[1] = u->nick;
- av[2] = reason;
- do_kick(s_ChanServ, 3, av);
- }
- }
-
- return MOD_CONT;
- } else if (!params) {
- params = u->nick;
- }
-
- is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0);
-
- if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params);
- } else if (!is_on_chan(c, u2)) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
- } else if (!is_same ? !check_access(u, ci, CA_KICK) :
- !check_access(u, ci, CA_KICKME)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (!is_same && (ci->flags & CI_PEACE)
- && (get_access(u2, ci) >= get_access(u, ci))) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else if (is_protected(u2)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- char *av[3];
-
- if ((ci->flags & CI_SIGNKICK)
- || ((ci->flags & CI_SIGNKICK_LEVEL)
- && !check_access(u, ci, CA_SIGNKICK)))
- anope_cmd_kick(whosends(ci), ci->name, params, "%s (%s)",
- reason, u->nick);
- else
- anope_cmd_kick(whosends(ci), ci->name, params, "%s", reason);
- av[0] = ci->name;
- av[1] = params;
- av[2] = reason;
- do_kick(s_ChanServ, 3, av);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_ban(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *params = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- Channel *c;
- ChannelInfo *ci;
- User *u2;
-
- int is_same;
-
- if (!reason) {
- reason = "Requested";
- } else {
- if (strlen(reason) > 200)
- reason[200] = '\0';
- }
-
- if (!chan) {
- struct u_chanlist *uc, *next;
-
- /* Bans the user on every channels he is on. */
-
- for (uc = u->chans; uc; uc = next) {
- next = uc->next;
- if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
- && check_access(u, ci, CA_BANME)) {
- char *av[3];
- char mask[BUFSIZE];
-
- /*
- * Dont ban/kick the user on channels where he is excepted
- * to prevent services <-> server wars.
- */
- if (ircd->except) {
- if (is_excepted(ci, u))
- notice_lang(s_ChanServ, u, CHAN_EXCEPTED,
- u->nick, ci->name);
- continue;
- }
- if (is_protected(u)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- continue;
- }
-
- av[0] = sstrdup("+b");
- get_idealban(ci, u, mask, sizeof(mask));
- av[1] = mask;
- anope_cmd_mode(whosends(ci), uc->chan->name, "+b %s",
- av[1]);
- chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
- free(av[0]);
-
- if ((ci->flags & CI_SIGNKICK)
- || ((ci->flags & CI_SIGNKICK_LEVEL)
- && !check_access(u, ci, CA_SIGNKICK)))
- anope_cmd_kick(whosends(ci), ci->name, u->nick,
- "%s (%s)", reason, u->nick);
- else
- anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s",
- reason);
- av[0] = ci->name;
- av[1] = u->nick;
- av[2] = reason;
- do_kick(s_ChanServ, 3, av);
- }
- }
-
- return MOD_CONT;
- } else if (!params) {
- params = u->nick;
- }
-
- is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0);
-
- if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) {
- notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params);
- } else if (!is_same ? !check_access(u, ci, CA_BAN) :
- !check_access(u, ci, CA_BANME)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (!is_same && (ci->flags & CI_PEACE)
- && (get_access(u2, ci) >= get_access(u, ci))) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- /*
- * Dont ban/kick the user on channels where he is excepted
- * to prevent services <-> server wars.
- */
- } else if (ircd->except && is_excepted(ci, u2)) {
- notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
- } else if (ircd->protectedumode && is_protected(u2)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- char *av[3];
- char mask[BUFSIZE];
-
- av[0] = sstrdup("+b");
- get_idealban(ci, u2, mask, sizeof(mask));
- av[1] = mask;
- anope_cmd_mode(whosends(ci), c->name, "+b %s", av[1]);
- chan_set_modes(s_ChanServ, c, 2, av, 1);
- free(av[0]);
-
- /* We still allow host banning while not allowing to kick */
- if (!is_on_chan(c, u2))
- return MOD_CONT;
-
- if ((ci->flags & CI_SIGNKICK)
- || ((ci->flags & CI_SIGNKICK_LEVEL)
- && !check_access(u, ci, CA_SIGNKICK)))
- anope_cmd_kick(whosends(ci), ci->name, params, "%s (%s)",
- reason, u->nick);
- else
- anope_cmd_kick(whosends(ci), ci->name, params, "%s", reason);
-
- av[0] = ci->name;
- av[1] = params;
- av[2] = reason;
- do_kick(s_ChanServ, 3, av);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_cs_topic(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *topic = strtok(NULL, "");
-
- Channel *c;
- ChannelInfo *ci;
-
- if (!chan) {
- syntax_error(s_ChanServ, u, "TOPIC", CHAN_TOPIC_SYNTAX);
- } else if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
- } else if (!is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- if (ci->last_topic)
- free(ci->last_topic);
- ci->last_topic = topic ? sstrdup(topic) : NULL;
- strscpy(ci->last_topic_setter, u->nick, NICKMAX);
- ci->last_topic_time = time(NULL);
-
- if (c->topic)
- free(c->topic);
- c->topic = topic ? sstrdup(topic) : NULL;
- strscpy(c->topic_setter, u->nick, NICKMAX);
- if (ircd->topictsbackward) {
- c->topic_time = c->topic_time - 1;
- } else {
- c->topic_time = ci->last_topic_time;
- }
-
- if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC))
- alog("%s: %s!%s@%s changed topic of %s as services admin.",
- s_ChanServ, u->nick, u->username, u->host, c->name);
- if (ircd->join2set) {
- if (whosends(ci) == s_ChanServ) {
- anope_cmd_join(s_ChanServ, c->name, time(NULL));
- anope_cmd_mode(NULL, c->name, "+o %s", s_ChanServ);
- }
- }
- anope_cmd_topic(whosends(ci), c->name, u->nick, topic ? topic : "",
- c->topic_time);
- if (ircd->join2set) {
- if (whosends(ci) == s_ChanServ) {
- anope_cmd_part(s_ChanServ, c->name, NULL);
- }
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_unban(User * u)
-{
- char *chan = strtok(NULL, " ");
- Channel *c;
- ChannelInfo *ci;
-
- if (!chan) {
- syntax_error(s_ChanServ, u, "UNBAN", CHAN_UNBAN_SYNTAX);
- } else if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!check_access(u, ci, CA_UNBAN)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- common_unban(ci, u->nick);
- notice_lang(s_ChanServ, u, CHAN_UNBANNED, chan);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_clear(User * u)
-{
- char *chan = strtok(NULL, " ");
- char *what = strtok(NULL, " ");
- char tmp[BUFSIZE];
- Channel *c;
- ChannelInfo *ci;
-
- if (!what) {
- syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX);
- } else if (!(c = findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (!(ci = c->ci)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!u || !check_access(u, ci, CA_CLEAR)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else if (stricmp(what, "bans") == 0) {
- char *av[2];
- int i;
-
- /* Save original ban info */
- int count = c->bancount;
- char **bans = scalloc(sizeof(char *) * count, 1);
- for (i = 0; i < count; i++)
- bans[i] = sstrdup(c->bans[i]);
-
- for (i = 0; i < count; i++) {
- av[0] = sstrdup("-b");
- av[1] = bans[i];
- anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
- chan_set_modes(whosends(ci), c, 2, av, 0);
- free(av[1]);
- free(av[0]);
- }
- notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan);
- free(bans);
- } else if (ircd->except && stricmp(what, "excepts") == 0) {
- char *av[2];
- int i;
-
- /* Save original except info */
- int count = c->exceptcount;
- char **excepts = scalloc(sizeof(char *) * count, 1);
- for (i = 0; i < count; i++)
- excepts[i] = sstrdup(c->excepts[i]);
-
- for (i = 0; i < count; i++) {
- av[0] = sstrdup("-e");
- av[1] = excepts[i];
- anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
- chan_set_modes(whosends(ci), c, 2, av, 0);
- free(av[1]);
- free(av[0]);
- }
- notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan);
- free(excepts);
-
- } else if (ircd->invitemode && stricmp(what, "invites") == 0) {
- char *av[2];
- int i;
-
- /* Save original except info */
- int count = c->invitecount;
- char **invites = scalloc(sizeof(char *) * count, 1);
- for (i = 0; i < count; i++)
- invites[i] = sstrdup(c->invite[i]);
-
- for (i = 0; i < count; i++) {
- av[0] = sstrdup("-I");
- av[1] = invites[i];
- anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
- chan_set_modes(whosends(ci), c, 2, av, 0);
- free(av[1]);
- free(av[0]);
- }
- notice_lang(s_ChanServ, u, CHAN_CLEARED_INVITES, chan);
- free(invites);
-
- } else if (stricmp(what, "modes") == 0) {
- char buf[BUFSIZE], *end = buf;
- char *argv[2];
-
- if (c->mode) {
- /* Clear modes the bulk of the modes */
- anope_cmd_mode(whosends(ci), c->name, "%s",
- ircd->modestoremove);
- argv[0] = sstrdup(ircd->modestoremove);
- chan_set_modes(whosends(ci), c, 1, argv, 0);
- free(argv[0]);
-
- /* to prevent the internals from complaining send -k, -L, -f by themselves if we need
- to send them - TSL */
- if (c->key) {
- anope_cmd_mode(whosends(ci), c->name, "-k %s", c->key);
- argv[0] = sstrdup("-k");
- argv[1] = c->key;
- chan_set_modes(whosends(ci), c, 2, argv, 0);
- free(argv[0]);
- }
- if (ircd->Lmode && c->redirect) {
- anope_cmd_mode(whosends(ci), c->name, "-L %s",
- c->redirect);
- argv[0] = sstrdup("-L");
- argv[1] = c->redirect;
- chan_set_modes(whosends(ci), c, 2, argv, 0);
- free(argv[0]);
- }
- if (ircd->fmode && c->flood) {
- if (flood_mode_char_remove) {
- anope_cmd_mode(whosends(ci), c->name, "%s %s",
- flood_mode_char_remove, c->flood);
- argv[0] = sstrdup(flood_mode_char_remove);
- argv[1] = c->flood;
- chan_set_modes(whosends(ci), c, 2, argv, 0);
- free(argv[0]);
- } else {
- if (debug) {
- alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes");
- }
- }
- }
- check_modes(c);
- }
-
-
-
- /* TODO: decide if the above implementation is better than this one. */
-
- if (0) {
- CBModeInfo *cbmi = cbmodeinfos;
- CBMode *cbm;
-
- do {
- if (c->mode & cbmi->flag)
- *end++ = cbmi->mode;
- } while ((++cbmi)->flag != 0);
-
- cbmi = cbmodeinfos;
-
- do {
- if (cbmi->getvalue && (c->mode & cbmi->flag)
- && !(cbmi->flags & CBM_MINUS_NO_ARG)) {
- char *value = cbmi->getvalue(c);
-
- if (value) {
- *end++ = ' ';
- while (*value)
- *end++ = *value++;
-
- /* Free the value */
- cbm = &cbmodes[(int) cbmi->mode];
- cbm->setvalue(c, NULL);
- }
- }
- } while ((++cbmi)->flag != 0);
-
- *end = 0;
-
- anope_cmd_mode(whosends(ci), c->name, "-%s", buf);
- c->mode = 0;
- check_modes(c);
- }
- notice_lang(s_ChanServ, u, CHAN_CLEARED_MODES, chan);
- } else if (stricmp(what, "ops") == 0) {
- char *av[3];
- struct c_userlist *cu, *next;
-
- if (ircd->svsmode_ucmode) {
- av[0] = sstrdup(chan);
- anope_cmd_svsmode_chan(av[0], "-o", NULL);
- if (ircd->owner) {
- anope_cmd_svsmode_chan(av[0], ircd->ownerunset, NULL);
- }
- if (ircd->protect || ircd->admin) {
- anope_cmd_svsmode_chan(av[0], ircd->adminunset, NULL);
- }
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- av[0] = sstrdup(chan);
- if (!chan_has_user_status(c, cu->user, CUS_OP)) {
- if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) {
- if (!chan_has_user_status(c, cu->user, CUS_OWNER)) {
- continue;
- } else {
- snprintf(tmp, BUFSIZE, "%so",
- ircd->ownerunset);
- av[1] = sstrdup(tmp);
-
- }
- } else {
- snprintf(tmp, BUFSIZE, "%so", ircd->adminunset);
- av[1] = sstrdup(tmp);
- }
- } else {
- av[1] = sstrdup("-o");
- }
- av[2] = sstrdup(cu->user->nick);
- do_cmode(s_ChanServ, 3, av);
- free(av[2]);
- free(av[1]);
- free(av[0]);
- }
- } else {
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- av[0] = sstrdup(chan);
- if (!chan_has_user_status(c, cu->user, CUS_OP)) {
- if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) {
- if (!chan_has_user_status(c, cu->user, CUS_OWNER)) {
- continue;
- } else {
- snprintf(tmp, BUFSIZE, "%so",
- ircd->ownerunset);
- av[1] = sstrdup(tmp);
- }
- } else {
- snprintf(tmp, BUFSIZE, "%so", ircd->adminunset);
- av[1] = sstrdup(tmp);
- }
- } else {
- av[1] = sstrdup("-o");
- }
- av[2] = sstrdup(cu->user->nick);
- anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
- av[2]);
- do_cmode(s_ChanServ, 3, av);
- free(av[2]);
- free(av[1]);
- free(av[0]);
- }
- }
- notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan);
- } else if (ircd->halfop && stricmp(what, "hops") == 0) {
- char *av[3];
- struct c_userlist *cu, *next;
-
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_HALFOP))
- continue;
- av[0] = sstrdup(chan);
- av[1] = sstrdup("-h");
- av[2] = sstrdup(cu->user->nick);
- if (ircd->svsmode_ucmode) {
- anope_cmd_svsmode_chan(av[0], av[1], NULL);
- do_cmode(s_ChanServ, 3, av);
- break;
- } else {
- anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
- av[2]);
- }
- do_cmode(s_ChanServ, 3, av);
- free(av[2]);
- free(av[1]);
- free(av[0]);
- }
- notice_lang(s_ChanServ, u, CHAN_CLEARED_HOPS, chan);
- } else if (stricmp(what, "voices") == 0) {
- char *av[3];
- struct c_userlist *cu, *next;
-
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_VOICE))
- continue;
- av[0] = sstrdup(chan);
- av[1] = sstrdup("-v");
- av[2] = sstrdup(cu->user->nick);
- if (ircd->svsmode_ucmode) {
- anope_cmd_svsmode_chan(av[0], av[1], NULL);
- do_cmode(s_ChanServ, 3, av);
- break;
- } else {
- anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
- av[2]);
- }
- do_cmode(s_ChanServ, 3, av);
- free(av[2]);
- free(av[1]);
- free(av[0]);
- }
- notice_lang(s_ChanServ, u, CHAN_CLEARED_VOICES, chan);
- } else if (stricmp(what, "users") == 0) {
- char *av[3];
- struct c_userlist *cu, *next;
- char buf[256];
-
- snprintf(buf, sizeof(buf), "CLEAR USERS command from %s", u->nick);
-
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- av[0] = sstrdup(chan);
- av[1] = sstrdup(cu->user->nick);
- av[2] = sstrdup(buf);
- anope_cmd_kick(whosends(ci), av[0], av[1], av[2]);
- do_kick(s_ChanServ, 3, av);
- free(av[2]);
- free(av[1]);
- free(av[0]);
- }
- notice_lang(s_ChanServ, u, CHAN_CLEARED_USERS, chan);
- } else {
- syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_getkey(User * u)
-{
- char *chan = strtok(NULL, " ");
- ChannelInfo *ci;
-
- if (!chan) {
- syntax_error(s_ChanServ, u, "GETKEY", CHAN_GETKEY_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!check_access(u, ci, CA_GETKEY)) {
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (!ci->c || !ci->c->key) {
- notice_lang(s_ChanServ, u, CHAN_GETKEY_NOKEY, chan);
- } else {
- notice_lang(s_ChanServ, u, CHAN_GETKEY_KEY, chan, ci->c->key);
- }
-
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_getpass(User * u)
-{
-#ifndef USE_ENCRYPTION
- char *chan = strtok(NULL, " ");
- ChannelInfo *ci;
-#endif
-
- /* Assumes that permission checking has already been done. */
-#ifdef USE_ENCRYPTION
- notice_lang(s_ChanServ, u, CHAN_GETPASS_UNAVAILABLE);
-#else
- if (!chan) {
- syntax_error(s_ChanServ, u, "GETPASS", CHAN_GETPASS_SYNTAX);
- } else if (!(ci = cs_findchan(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (CSRestrictGetPass && !is_services_root(u)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else {
- alog("%s: %s!%s@%s used GETPASS on %s",
- s_ChanServ, u->nick, u->username, u->host, ci->name);
- if (WallGetpass) {
- anope_cmd_global(s_ChanServ,
- "\2%s\2 used GETPASS on channel \2%s\2",
- u->nick, chan);
- }
- notice_lang(s_ChanServ, u, CHAN_GETPASS_PASSWORD_IS,
- chan, ci->founderpass);
- }
-#endif
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_sendpass(User * u)
-{
-#ifndef USE_ENCRYPTION
- char *chan = strtok(NULL, " ");
- ChannelInfo *ci;
- NickCore *founder;
-#endif
-
-#ifdef USE_ENCRYPTION
- notice_lang(s_ChanServ, u, CHAN_SENDPASS_UNAVAILABLE);
-#else
- if (!chan) {
- syntax_error(s_ChanServ, u, "SENDPASS", CHAN_SENDPASS_SYNTAX);
- } else if (RestrictMail && !is_oper(u)) {
- notice_lang(s_ChanServ, u, PERMISSION_DENIED);
- } else if (!(ci = cs_findchan(chan)) || !(founder = ci->founder)) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else {
- char buf[BUFSIZE];
- MailInfo *mail;
-
- snprintf(buf, sizeof(buf),
- getstring2(founder, CHAN_SENDPASS_SUBJECT), ci->name);
- mail = MailBegin(u, founder, buf, s_ChanServ);
- if (!mail)
- return MOD_CONT;
-
- fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_HEAD));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_1),
- ci->name);
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_2),
- ci->founderpass);
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_3));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_4));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_5),
- NetworkName);
- fprintf(mail->pipe, "\n.\n");
-
- MailEnd(mail);
-
- alog("%s: %s!%s@%s used SENDPASS on %s", s_ChanServ, u->nick,
- u->username, u->host, chan);
- notice_lang(s_ChanServ, u, CHAN_SENDPASS_OK, chan);
- }
-#endif
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_forbid(User * u)
-{
- ChannelInfo *ci;
- char *chan = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- Channel *c;
-
- /* Assumes that permission checking has already been done. */
- if (!chan || (ForceForbidReason && !reason)) {
- syntax_error(s_ChanServ, u, "FORBID",
- (ForceForbidReason ? CHAN_FORBID_SYNTAX_REASON :
- CHAN_FORBID_SYNTAX));
- return MOD_CONT;
- }
- if (readonly)
- notice_lang(s_ChanServ, u, READ_ONLY_MODE);
- if ((ci = cs_findchan(chan)) != NULL)
- delchan(ci);
- ci = makechan(chan);
- if (ci) {
- ci->flags |= CI_VERBOTEN;
- ci->forbidby = sstrdup(u->nick);
- if (reason)
- ci->forbidreason = sstrdup(reason);
-
- if ((c = findchan(ci->name))) {
- struct c_userlist *cu, *next;
- char *av[3];
-
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
-
- if (is_oper(cu->user))
- continue;
-
- av[0] = c->name;
- av[1] = cu->user->nick;
- av[2] = reason ? reason : "CHAN_FORBID_REASON";
- anope_cmd_kick(s_ChanServ, av[0], av[1], av[2]);
- do_kick(s_ChanServ, 3, av);
- }
- }
-
- if (WallForbid)
- anope_cmd_global(s_ChanServ,
- "\2%s\2 used FORBID on channel \2%s\2",
- u->nick, ci->name);
-
- if (ircd->chansqline) {
- anope_cmd_sqline(ci->name, ((reason) ? reason : "Forbidden"));
- }
-
- alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick,
- ci->name);
- notice_lang(s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan);
- send_event(EVENT_CHAN_FORBIDDEN, chan);
- } else {
- alog("%s: Valid FORBID for %s by %s failed", s_ChanServ, ci->name,
- u->nick);
- notice_lang(s_ChanServ, u, CHAN_FORBID_FAILED, chan);
- }
- return MOD_CONT;
-}
-
- /*************************************************************************/
-
-static int do_suspend(User * u)
-{
- ChannelInfo *ci;
- char *chan = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- Channel *c;
-
- /* Assumes that permission checking has already been done. */
- if (!chan || (ForceForbidReason && !reason)) {
- syntax_error(s_ChanServ, u, "SUSPEND",
- (ForceForbidReason ? CHAN_SUSPEND_SYNTAX_REASON :
- CHAN_SUSPEND_SYNTAX));
- return MOD_CONT;
- }
-
- /* Only SUSPEND existing channels, otherwise use FORBID (bug #54) */
- if ((ci = cs_findchan(chan)) == NULL) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- }
-
- /* You should not SUSPEND a FORBIDEN channel */
- if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
- return MOD_CONT;
- }
-
- if (readonly)
- notice_lang(s_ChanServ, u, READ_ONLY_MODE);
-
- if (ci) {
- ci->flags |= CI_SUSPENDED;
- ci->forbidby = sstrdup(u->nick);
- if (reason)
- ci->forbidreason = sstrdup(reason);
-
- if ((c = findchan(ci->name))) {
- struct c_userlist *cu, *next;
- char *av[3];
-
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
-
- if (is_oper(cu->user))
- continue;
-
- av[0] = c->name;
- av[1] = cu->user->nick;
- av[2] = reason ? reason : "CHAN_SUSPEND_REASON";
- anope_cmd_kick(s_ChanServ, av[0], av[1], av[2]);
- do_kick(s_ChanServ, 3, av);
- }
- }
-
- if (WallForbid)
- anope_cmd_global(s_ChanServ,
- "\2%s\2 used SUSPEND on channel \2%s\2",
- u->nick, ci->name);
-
- alog("%s: %s set SUSPEND for channel %s", s_ChanServ, u->nick,
- ci->name);
- notice_lang(s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan);
- send_event(EVENT_CHAN_SUSPENDED, chan);
- } else {
- alog("%s: Valid SUSPEND for %s by %s failed", s_ChanServ, ci->name,
- u->nick);
- notice_lang(s_ChanServ, u, CHAN_SUSPEND_FAILED, chan);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_unsuspend(User * u)
-{
- ChannelInfo *ci;
- char *chan = strtok(NULL, " ");
-
- /* Assumes that permission checking has already been done. */
- if (!chan) {
- syntax_error(s_ChanServ, u, "UNSUSPEND", CHAN_UNSUSPEND_SYNTAX);
- return MOD_CONT;
- }
- if (chan[0] != '#') {
- notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_ERROR);
- return MOD_CONT;
- }
- if (readonly)
- notice_lang(s_ChanServ, u, READ_ONLY_MODE);
-
- ci = cs_findchan(chan);
-
- if (ci) {
- ci->flags &= ~CI_SUSPENDED;
- ci->forbidreason = NULL;
- ci->forbidby = NULL;
-
- if (WallForbid)
- anope_cmd_global(s_ChanServ,
- "\2%s\2 used UNSUSPEND on channel \2%s\2",
- u->nick, ci->name);
-
- alog("%s: %s set UNSUSPEND for channel %s", s_ChanServ, u->nick,
- ci->name);
- notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan);
- send_event(EVENT_CHAN_UNSUSPEND, chan);
- } else {
- alog("%s: Valid UNSUSPEND for %s by %s failed", s_ChanServ,
- chan, u->nick);
- notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_status(User * u)
-{
- ChannelInfo *ci;
- User *u2;
- char *nick, *chan;
- char *temp;
-
- chan = strtok(NULL, " ");
- nick = strtok(NULL, " ");
- if (!nick || strtok(NULL, " ")) {
- notice_lang(s_ChanServ, u, CHAN_STATUS_SYNTAX);
- return MOD_CONT;
- }
- if (!(ci = cs_findchan(chan))) {
- temp = chan;
- chan = nick;
- nick = temp;
- ci = cs_findchan(chan);
- }
- if (!ci) {
- notice_lang(s_ChanServ, u, CHAN_STATUS_NOT_REGGED, temp);
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_STATUS_FORBIDDEN, chan);
- return MOD_CONT;
- } else if ((u2 = finduser(nick)) != NULL) {
- notice_lang(s_ChanServ, u, CHAN_STATUS_INFO, chan, nick,
- get_access(u2, ci));
- } else { /* !u2 */
- notice_lang(s_ChanServ, u, CHAN_STATUS_NOTONLINE, nick);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
diff --git a/src/commands.c b/src/commands.c
index 4ab6d90f1..0159ee312 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -95,8 +95,8 @@ void do_run_cmd(char *service, User * u, Command * c, const char *cmd)
notice_lang(service, u, OPER_DEFCON_DENIED);
}
} else {
+ mod_current_module_name = c->mod_name;
if ((c->has_priv == NULL) || c->has_priv(u)) {
- mod_current_module_name = c->mod_name;
retVal = c->routine(u);
mod_current_module_name = NULL;
if (retVal == MOD_CONT) {
@@ -108,13 +108,12 @@ void do_run_cmd(char *service, User * u, Command * c, const char *cmd)
current = current->next;
}
}
- }
-
- else {
+ } else {
notice_lang(service, u, ACCESS_DENIED);
alog("Access denied for %s with service %s and command %s",
u->nick, service, cmd);
}
+ mod_current_module_name = NULL;
}
} else {
if ((!checkDefCon(DEFCON_SILENT_OPER_ONLY)) || is_oper(u)) {
@@ -139,9 +138,17 @@ void do_help_cmd(char *service, User * u, Command * c, const char *cmd)
int has_had_help = 0;
int cont = MOD_CONT;
const char *p1 = NULL, *p2 = NULL, *p3 = NULL, *p4 = NULL;
+ Module *calling_module = mod_current_module;
+ char *calling_module_name = mod_current_module_name;
for (current = c; (current) && (cont == MOD_CONT);
current = current->next) {
+ mod_current_module_name = current->mod_name;
+ if (mod_current_module_name)
+ mod_current_module = findModule(mod_current_module_name);
+ else
+ mod_current_module = NULL;
+
p1 = current->help_param1;
p2 = current->help_param2;
p3 = current->help_param3;
@@ -194,6 +201,9 @@ void do_help_cmd(char *service, User * u, Command * c, const char *cmd)
if (has_had_help == 0) {
notice_lang(service, u, NO_HELP_AVAILABLE, cmd);
}
+
+ mod_current_module = calling_module;
+ mod_current_module_name = calling_module_name;
}
/*************************************************************************/
diff --git a/src/config.c b/src/config.c
index 0043e390e..198860138 100644
--- a/src/config.c
+++ b/src/config.c
@@ -18,6 +18,8 @@
/* Configurable variables: */
+char *IRCDModule;
+
char *RemoteServer;
int RemotePort;
char *RemotePassword;
@@ -267,6 +269,8 @@ char *ExceptionDBName;
char *SessionLimitExceeded;
char *SessionLimitDetailsLoc;
+int OSOpersOnly;
+
char *Modules;
char *ModulesDelayed;
char **ModulesAutoload;
@@ -274,6 +278,38 @@ int ModulesNumber;
int ModulesDelayedNumber;
char **ModulesDelayedAutoload;
+/**
+ * Core Module Stuff
+ **/
+char *HostCoreModules;
+char **HostServCoreModules;
+int HostServCoreNumber;
+
+char *MemoCoreModules;
+char **MemoServCoreModules;
+int MemoServCoreNumber;
+
+char *HelpCoreModules;
+char **HelpServCoreModules;
+int HelpServCoreNumber;
+
+char *BotCoreModules;
+char **BotServCoreModules;
+int BotServCoreNumber;
+
+char *OperCoreModules;
+char **OperServCoreModules;
+int OperServCoreNumber;
+
+char *NickCoreModules;
+char **NickServCoreModules;
+int NickServCoreNumber;
+
+char *ChanCoreModules;
+char **ChanServCoreModules;
+int ChanServCoreNumber;
+
+
char *MysqlHost;
char *MysqlUser;
char *MysqlPass;
@@ -316,6 +352,11 @@ int NumUlines;
int UseTS6;
+
+
+
+char **buildStringList(char *src, int *number);
+
/*************************************************************************/
/* Deprecated directive (dep_) and value checking (chk_) functions: */
@@ -324,36 +365,6 @@ int UseTS6;
/*************************************************************************/
-#define MAXPARAMS 8
-
-/* Configuration directives */
-
-typedef struct {
- char *name;
- struct {
- int type; /* PARAM_* below */
- int flags; /* Same */
- void *ptr; /* Pointer to where to store the value */
- } params[MAXPARAMS];
-} Directive;
-
-#define PARAM_NONE 0
-#define PARAM_INT 1
-#define PARAM_POSINT 2 /* Positive integer only */
-#define PARAM_PORT 3 /* 1..65535 only */
-#define PARAM_STRING 4
-#define PARAM_TIME 5
-#define PARAM_STRING_ARRAY 6 /* Array of string */
-#define PARAM_SET -1 /* Not a real parameter; just set the
- * given integer variable to 1 */
-#define PARAM_DEPRECATED -2 /* Set for deprecated directives; `ptr'
- * is a function pointer to call */
-
-/* Flags: */
-#define PARAM_OPTIONAL 0x01
-#define PARAM_FULLONLY 0x02 /* Directive only allowed if !STREAMLINED */
-#define PARAM_RELOAD 0x04 /* Directive is reloadable */
-
Directive directives[] = {
{"AkillOnAdd", {{PARAM_SET, PARAM_RELOAD, &AkillOnAdd}}},
{"AutokillDB", {{PARAM_STRING, PARAM_RELOAD, &AutokillDBName}}},
@@ -361,6 +372,7 @@ Directive directives[] = {
{"ChankillExpiry", {{PARAM_TIME, PARAM_RELOAD, &ChankillExpiry}}},
{"BadPassLimit", {{PARAM_POSINT, PARAM_RELOAD, &BadPassLimit}}},
{"BadPassTimeout", {{PARAM_TIME, PARAM_RELOAD, &BadPassTimeout}}},
+ {"BotCoreModules", {{PARAM_STRING, PARAM_RELOAD, &BotCoreModules}}},
{"BotServDB", {{PARAM_STRING, PARAM_RELOAD, &BotDBName}}},
{"BotServName", {{PARAM_STRING, 0, &s_BotServ},
{PARAM_STRING, 0, &desc_BotServ}}},
@@ -381,6 +393,7 @@ Directive directives[] = {
{"HostServDB", {{PARAM_STRING, PARAM_RELOAD, &HostDBName}}},
{"HostServName", {{PARAM_STRING, 0, &s_HostServ},
{PARAM_STRING, 0, &desc_HostServ}}},
+ {"ChanCoreModules", {{PARAM_STRING, PARAM_RELOAD, &ChanCoreModules}}},
{"ChanServDB", {{PARAM_STRING, PARAM_RELOAD, &ChanDBName}}},
{"ChanServName", {{PARAM_STRING, 0, &s_ChanServ},
{PARAM_STRING, 0, &desc_ChanServ}}},
@@ -448,10 +461,13 @@ Directive directives[] = {
{PARAM_STRING, 0, &desc_GlobalNoticer}}},
{"GlobalAlias", {{PARAM_STRING, 0, &s_GlobalNoticerAlias},
{PARAM_STRING, 0, &desc_GlobalNoticerAlias}}},
+ {"HelpCoreModules", {{PARAM_STRING, PARAM_RELOAD, &HelpCoreModules}}},
{"HelpChannel", {{PARAM_STRING, PARAM_RELOAD, &HelpChannel}}},
+ {"HostCoreModules", {{PARAM_STRING, PARAM_RELOAD, &HostCoreModules}}},
{"HostServAlias", {{PARAM_STRING, 0, &s_HostServAlias},
{PARAM_STRING, 0, &desc_HostServAlias}}},
{"HostSetters", {{PARAM_STRING, PARAM_RELOAD, &HostSetter}}},
+ {"IRCDModule", {{PARAM_STRING, 0, &IRCDModule}}},
{"LogChannel", {{PARAM_STRING, PARAM_RELOAD, &LogChannel}}},
{"LogBot", {{PARAM_SET, PARAM_RELOAD, &LogBot}}},
{"HelpServName", {{PARAM_STRING, 0, &s_HelpServ},
@@ -475,6 +491,7 @@ Directive directives[] = {
{"MailDelay", {{PARAM_TIME, PARAM_RELOAD, &MailDelay}}},
{"MaxSessionKill", {{PARAM_INT, PARAM_RELOAD, &MaxSessionKill}}},
{"MaxSessionLimit", {{PARAM_POSINT, PARAM_RELOAD, &MaxSessionLimit}}},
+ {"MemoCoreModules", {{PARAM_STRING, PARAM_RELOAD, &MemoCoreModules}}},
{"MemoServName", {{PARAM_STRING, 0, &s_MemoServ},
{PARAM_STRING, 0, &desc_MemoServ}}},
{"MemoServAlias", {{PARAM_STRING, 0, &s_MemoServAlias},
@@ -504,6 +521,7 @@ Directive directives[] = {
{"Numeric", {{PARAM_STRING, PARAM_RELOAD, &Numeric}}},
{"PreNickServDB", {{PARAM_STRING, PARAM_RELOAD, &PreNickDBName}}},
{"NSEmailReg", {{PARAM_SET, PARAM_RELOAD, &NSEmailReg}}},
+ {"NickCoreModules", {{PARAM_STRING, PARAM_RELOAD, &NickCoreModules}}},
{"NickRegDelay", {{PARAM_POSINT, PARAM_RELOAD, &NickRegDelay}}},
{"NickServName", {{PARAM_STRING, 0, &s_NickServ},
{PARAM_STRING, 0, &desc_NickServ}}},
@@ -543,6 +561,7 @@ Directive directives[] = {
{"NSRestrictGetPass", {{PARAM_SET, PARAM_RELOAD, &NSRestrictGetPass}}},
{"NSNickTracking", {{PARAM_SET, PARAM_RELOAD, &NSNickTracking}}},
{"NSAddAccessOnReg", {{PARAM_SET, PARAM_RELOAD, &NSAddAccessOnReg}}},
+ {"OperCoreModules", {{PARAM_STRING, PARAM_RELOAD, &OperCoreModules}}},
{"OperServDB", {{PARAM_STRING, PARAM_RELOAD, &OperDBName}}},
{"OperServName", {{PARAM_STRING, 0, &s_OperServ},
{PARAM_STRING, 0, &desc_OperServ}}},
@@ -569,6 +588,7 @@ Directive directives[] = {
{"ServiceUser", {{PARAM_STRING, 0, &temp_userhost}}},
{"SessionLimitDetailsLoc",
{{PARAM_STRING, PARAM_RELOAD, &SessionLimitDetailsLoc}}},
+ {"OSOpersOnly", {{PARAM_SET, PARAM_RELOAD, &OSOpersOnly}}},
{"SessionLimitExceeded",
{{PARAM_STRING, PARAM_RELOAD, &SessionLimitExceeded}}},
{"SessionAutoKillExpiry",
@@ -662,6 +682,125 @@ void error(int linenum, char *message, ...)
* effect.
*/
+int parse_directive(Directive * d, char *dir, int ac, char *av[MAXPARAMS],
+ int linenum, int reload, char *s)
+{
+ int retval = 1;
+ int i;
+ int val;
+ int optind;
+
+ if (stricmp(dir, d->name) != 0)
+ return 1;
+ optind = 0;
+ for (i = 0; i < MAXPARAMS && d->params[i].type != PARAM_NONE; i++) {
+ if (reload && !(d->params[i].flags & PARAM_RELOAD))
+ continue;
+
+ if (d->params[i].type == PARAM_SET) {
+ *(int *) d->params[i].ptr = 1;
+ continue;
+ }
+#ifdef STREAMLINED
+ if (d->params[i].flags & PARAM_FULLONLY) {
+ error(linenum,
+ "Directive `%s' not available in STREAMLINED mode",
+ d->name);
+ break;
+ }
+#endif
+
+ if (d->params[i].type == PARAM_DEPRECATED) {
+ void (*func) (void);
+ error(linenum, "Deprecated directive `%s' used", d->name);
+ func = (void (*)(void)) (d->params[i].ptr);
+ func(); /* For clarity */
+ continue;
+ }
+ if (optind >= ac) {
+ if (!(d->params[i].flags & PARAM_OPTIONAL)) {
+ error(linenum, "Not enough parameters for `%s'", d->name);
+ retval = 0;
+ }
+ break;
+ }
+ switch (d->params[i].type) {
+ case PARAM_INT:
+ val = strtol(av[optind++], &s, 0);
+ if (*s) {
+ error(linenum,
+ "%s: Expected an integer for parameter %d",
+ d->name, optind);
+ retval = 0;
+ break;
+ }
+ *(int *) d->params[i].ptr = val;
+ break;
+ case PARAM_POSINT:
+ val = strtol(av[optind++], &s, 0);
+ if (*s || val <= 0) {
+ error(linenum,
+ "%s: Expected a positive integer for parameter %d",
+ d->name, optind);
+ retval = 0;
+ break;
+ }
+ if (errno == ERANGE && val == LONG_MAX) {
+ /* well the true top off is 2,147,483,647 but lets not give them the real top */
+ error(linenum,
+ "%s: paramter %d is to large, reduce this value (0 to 2,147,483,646)",
+ d->name, optind);
+ }
+ *(int *) d->params[i].ptr = val;
+ break;
+ case PARAM_PORT:
+ val = strtol(av[optind++], &s, 0);
+ if (*s) {
+ error(linenum,
+ "%s: Expected a port number for parameter %d",
+ d->name, optind);
+ retval = 0;
+ break;
+ }
+ if (val < 1 || val > 65535) {
+ error(linenum,
+ "Port numbers must be in the range 1..65535");
+ retval = 0;
+ break;
+ }
+ *(int *) d->params[i].ptr = val;
+ break;
+ case PARAM_STRING:
+/* if (reload && *(char **)d->params[i].ptr)
+ free(*(char **)d->params[i].ptr); */
+ *(char **) d->params[i].ptr = sstrdup(av[optind++]);
+ if (!d->params[i].ptr) {
+ error(linenum, "%s: Out of memory", d->name);
+ return 0;
+ }
+ break;
+ case PARAM_TIME:
+ val = dotime(av[optind++]);
+ if (val < 0) {
+ error(linenum,
+ "%s: Expected a time value for parameter %d",
+ d->name, optind);
+ retval = 0;
+ break;
+ }
+ *(int *) d->params[i].ptr = val;
+ break;
+ default:
+ error(linenum, "%s: Unknown type %d for param %d",
+ d->name, d->params[i].type, i + 1);
+ retval = 0; /* don't bother continuing--something's bizarre */
+ break;
+ }
+ }
+ return retval;;
+}
+
+
int parse(char *buf, int linenum, int reload)
{
char *s, *t, *dir;
@@ -711,124 +850,21 @@ int parse(char *buf, int linenum, int reload)
for (n = 0; n < lenof(directives); n++) {
Directive *d = &directives[n];
- if (stricmp(dir, d->name) != 0)
- continue;
- optind = 0;
- for (i = 0; i < MAXPARAMS && d->params[i].type != PARAM_NONE; i++) {
- if (reload && !(d->params[i].flags & PARAM_RELOAD))
- continue;
-
- if (d->params[i].type == PARAM_SET) {
- *(int *) d->params[i].ptr = 1;
- continue;
- }
-#ifdef STREAMLINED
- if (d->params[i].flags & PARAM_FULLONLY) {
- error(linenum,
- "Directive `%s' not available in STREAMLINED mode",
- d->name);
- break;
- }
-#endif
-
- if (d->params[i].type == PARAM_DEPRECATED) {
- void (*func) (void);
- error(linenum, "Deprecated directive `%s' used", d->name);
- func = (void (*)(void)) (d->params[i].ptr);
- func(); /* For clarity */
- continue;
- }
- if (optind >= ac) {
- if (!(d->params[i].flags & PARAM_OPTIONAL)) {
- error(linenum, "Not enough parameters for `%s'",
- d->name);
- retval = 0;
- }
- break;
- }
- switch (d->params[i].type) {
- case PARAM_INT:
- val = strtol(av[optind++], &s, 0);
- if (*s) {
- error(linenum,
- "%s: Expected an integer for parameter %d",
- d->name, optind);
- retval = 0;
- break;
- }
- *(int *) d->params[i].ptr = val;
- break;
- case PARAM_POSINT:
- val = strtol(av[optind++], &s, 0);
- if (*s || val <= 0) {
- error(linenum,
- "%s: Expected a positive integer for parameter %d",
- d->name, optind);
- retval = 0;
- break;
- }
- if (errno == ERANGE && val == LONG_MAX) {
- /* well the true top off is 2,147,483,647 but lets not give them the real top */
- error(linenum,
- "%s: paramter %d is to large, reduce this value (0 to 2,147,483,646)",
- d->name, optind);
- }
- *(int *) d->params[i].ptr = val;
- break;
- case PARAM_PORT:
- val = strtol(av[optind++], &s, 0);
- if (*s) {
- error(linenum,
- "%s: Expected a port number for parameter %d",
- d->name, optind);
- retval = 0;
- break;
- }
- if (val < 1 || val > 65535) {
- error(linenum,
- "Port numbers must be in the range 1..65535");
- retval = 0;
- break;
- }
- *(int *) d->params[i].ptr = val;
- break;
- case PARAM_STRING:
-/* if (reload && *(char **)d->params[i].ptr)
- free(*(char **)d->params[i].ptr); */
- *(char **) d->params[i].ptr = sstrdup(av[optind++]);
- if (!d->params[i].ptr) {
- error(linenum, "%s: Out of memory", d->name);
- return 0;
- }
- break;
- case PARAM_TIME:
- val = dotime(av[optind++]);
- if (val < 0) {
- error(linenum,
- "%s: Expected a time value for parameter %d",
- d->name, optind);
- retval = 0;
- break;
- }
- *(int *) d->params[i].ptr = val;
- break;
- default:
- error(linenum, "%s: Unknown type %d for param %d",
- d->name, d->params[i].type, i + 1);
- return 0; /* don't bother continuing--something's bizarre */
- }
+ retval = parse_directive(d, dir, ac, av, linenum, reload, s);
+ if (!retval) {
+ break;
}
- break; /* because we found a match */
}
if (n == lenof(directives)) {
- error(linenum, "Unknown directive `%s'", dir);
+/* error(linenum, "Unknown directive `%s'", dir);
return 1; /* don't cause abort */
}
return retval;
}
+
/*************************************************************************/
#define CHECK(v) do { \
@@ -933,6 +969,7 @@ int read_config(int reload)
}
}
+ CHECK(IRCDModule);
CHECK(NetworkName);
if (!reload) {
@@ -1229,48 +1266,31 @@ int read_config(int reload)
}
/* Host Setters building... :P */
- HostNumber = 0; /* always zero it, even if we have no setters */
- if (HostSetter) {
- s = strtok(HostSetter, " ");
- do {
- if (s) {
- HostNumber++;
- HostSetters =
- realloc(HostSetters, sizeof(char *) * HostNumber);
- HostSetters[HostNumber - 1] = sstrdup(s);
- }
- } while ((s = strtok(NULL, " ")));
- }
+ HostSetters = buildStringList(HostSetter, &HostNumber);
/* Modules Autoload building... :P */
- ModulesNumber = 0; /* always zero it, even if we have no setters */
- if (Modules) {
- s = strtok(Modules, " ");
- do {
- if (s) {
- ModulesNumber++;
- ModulesAutoload =
- realloc(ModulesAutoload,
- sizeof(char *) * ModulesNumber);
- ModulesAutoload[ModulesNumber - 1] = sstrdup(s);
- }
- } while ((s = strtok(NULL, " ")));
- }
+ ModulesAutoload = buildStringList(Modules, &ModulesNumber);
+ ModulesDelayedAutoload =
+ buildStringList(ModulesDelayed, &ModulesDelayedNumber);
+ HostServCoreModules =
+ buildStringList(HostCoreModules, &HostServCoreNumber);
+ MemoServCoreModules =
+ buildStringList(MemoCoreModules, &MemoServCoreNumber);
+ HelpServCoreModules =
+ buildStringList(HelpCoreModules, &HelpServCoreNumber);
+
+ BotServCoreModules =
+ buildStringList(BotCoreModules, &BotServCoreNumber);
+
+ OperServCoreModules =
+ buildStringList(OperCoreModules, &OperServCoreNumber);
+
+ ChanServCoreModules =
+ buildStringList(ChanCoreModules, &ChanServCoreNumber);
+
+ NickServCoreModules =
+ buildStringList(NickCoreModules, &NickServCoreNumber);
- ModulesDelayedNumber = 0; /* always zero it, even if we have no setters */
- if (ModulesDelayed) {
- s = strtok(ModulesDelayed, " ");
- do {
- if (s) {
- ModulesDelayedNumber++;
- ModulesDelayedAutoload =
- realloc(ModulesDelayedAutoload,
- sizeof(char *) * ModulesDelayedNumber);
- ModulesDelayedAutoload[ModulesDelayedNumber - 1] =
- sstrdup(s);
- }
- } while ((s = strtok(NULL, " ")));
- }
if (LimitSessions) {
CHECK(DefSessionLimit);
@@ -1379,7 +1399,10 @@ int read_config(int reload)
CHECK(DefconMessage);
}
- if (UseTokens) {
+ /**
+ * Temp. disabled, as ircd-> isnt loaded yet, so we cant check here!
+ **/
+/* if (UseTokens) {
if (!ircd->token) {
alog("Anope does not support TOKENS for this ircd setting unsetting UseToken");
UseTokens = 0;
@@ -1392,7 +1415,7 @@ int read_config(int reload)
"UseTS6 requires the setting of Numeric to be enabled.");
retval = 0;
}
- }
+ }*/
/**
* If they try to enable any email registration option,
@@ -1419,4 +1442,25 @@ int read_config(int reload)
return retval;
}
+
+char **buildStringList(char *src, int *number)
+{
+ char *s;
+ int i = 0;
+ char **list = NULL;
+
+ if (src) {
+ s = strtok(src, " ");
+ do {
+ if (s) {
+ i++;
+ list = realloc(list, sizeof(char *) * i);
+ list[i - 1] = sstrdup(s);
+ }
+ } while ((s = strtok(NULL, " ")));
+ }
+ *number = i; /* always zero it, even if we have no setters */
+ return list;
+}
+
/*************************************************************************/
diff --git a/src/core/Makefile b/src/core/Makefile
new file mode 100644
index 000000000..e73fd7e7c
--- /dev/null
+++ b/src/core/Makefile
@@ -0,0 +1,45 @@
+include ./Makefile.inc
+
+MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \
+ 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \
+ 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \
+ 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \
+ 'RUNGROUP=${RUNGROUP}' 'MODULE_PATH=${MODULE_PATH}' \
+ 'PROFILE=${PROFILE}' 'SHARED=${SHARED}'
+
+OBJECTS= $(SRCS:.c=.o)
+SO_FILES=$(OBJECTS:.o=.s)
+CDEFS= -g -rdynamic -Wall
+CFLAGS=$(CFLAGS) $(CDEFS)
+
+all: modules subs
+
+modules: $(OBJECTS) $(SO_FILES)
+
+install:
+ $(CP) ./*.so $(MODULE_PATH)
+
+distclean: clean spotless
+
+.c.o:
+ $(CC) $(CFLAGS) -I../${INCLUDEDIR} -c $<
+
+.o.s:
+ $(CC) ${SHARED} $< -o $*.so ${PROFILE}
+
+subs:
+ @for i in $(SUBS); do \
+ echo "make all in $$i..."; \
+ (cd $$i; $(MAKE) $(MAKEARGS) all); done
+
+subs_clean:
+ @for i in $(SUBS); do \
+ echo "cleaning in $$i..."; \
+ (cd $$i; $(MAKE) $(MAKEARGS) clean); done
+
+clean: subs_clean
+ rm -f *.o *.so *.c~ core
+
+spotless: clean
+ rm -f *.so Makefile.inc
+
diff --git a/src/core/Makefile.sub b/src/core/Makefile.sub
new file mode 100644
index 000000000..b060ca5b6
--- /dev/null
+++ b/src/core/Makefile.sub
@@ -0,0 +1,30 @@
+MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \
+ 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \
+ 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \
+ 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \
+ 'RUNGROUP=${RUNGROUP}' 'MODULE_PATH=${MODULE_PATH}' \
+ 'PROFILE=${PROFILE}' 'SHARED=${SHARED}'
+
+OBJECTS= $(SRCS:.c=.o)
+SO_FILES=$(OBJECTS:.o=.s)
+CDEFS= -g -rdynamic -Wall
+CFLAGS=$(CFLAGS) $(CDEFS)
+
+all: module
+
+module: $(OBJECTS) so
+
+distclean: clean spotless
+
+.c.o:
+ $(CC) $(CFLAGS) -I../ -I../../${INCLUDEDIR} -c $<
+
+so:
+ $(CC) ${SHARED} $(OBJECTS) -o ../$(TARGET).so ${PROFILE}
+
+clean:
+ rm -f *.o *.so *.c~ core
+
+spotless: clean
+ rm -f *~
+
diff --git a/src/core/Makefile.win32 b/src/core/Makefile.win32
new file mode 100644
index 000000000..e1f4301a3
--- /dev/null
+++ b/src/core/Makefile.win32
@@ -0,0 +1,25 @@
+include ../../Makefile.inc.win32
+
+SRCS=bs_act.c bs_assign.c bs_badwords.c bs_bot.c bs_botlist.c bs_fantasy.c bs_fantasy_kick.c bs_fantasy_kickban.c bs_fantasy_owner.c bs_fantasy_seen.c bs_fantasy_unban.c bs_help.c bs_info.c bs_kick.c bs_say.c bs_set.c bs_unassign.c cs_access.c cs_akick.c cs_ban.c cs_clear.c cs_drop.c cs_forbid.c cs_getkey.c cs_getpass.c cs_help.c cs_identify.c cs_info.c cs_invite.c cs_kick.c cs_list.c cs_logout.c cs_modes.c cs_register.c cs_sendpass.c cs_set.c cs_status.c cs_suspend.c cs_topic.c cs_xop.c he_help.c hs_del.c hs_delall.c hs_group.c hs_help.c hs_list.c hs_off.c hs_on.c hs_set.c hs_setall.c ms_cancel.c ms_check.c ms_del.c ms_help.c ms_info.c ms_list.c ms_read.c ms_rsend.c ms_send.c ms_sendall.c ms_set.c ms_staff.c ns_access.c ns_alist.c ns_drop.c ns_forbid.c ns_getemail.c ns_getpass.c ns_ghost.c ns_group.c ns_help.c ns_identify.c ns_info.c ns_list.c ns_logout.c ns_recover.c ns_register.c ns_release.c ns_sendpass.c ns_set.c ns_status.c ns_suspend.c ns_update.c os_admin.c os_akill.c os_chankill.c os_chanlist.c os_clearmodes.c os_defcon.c os_global.c os_help.c os_ignore.c os_jupe.c os_kick.c os_killclones.c \
+ os_logonnews.c os_mode.c os_modinfo.c os_modlist.c os_modload.c os_modunload.c os_noop.c os_oline.c os_oper.c os_opernews.c os_quit.c os_randomnews.c os_raw.c os_reload.c os_restart.c os_session.c os_set.c os_sgline.c os_shutdown.c os_sqline.c os_staff.c os_stats.c os_svsnick.c os_szline.c os_umode.c os_update.c os_userlist.c
+OBJECTS= $(SRCS:.c=.dll)
+CFLAGS=/LD /MD /D MODULE_COMPILE $(CFLAGS) /I"../../include"
+LFLAGS=/link ../anope.lib wsock32.lib $(LIBS) $(LFLAGS) $(MYSQL_LIB_PATH) /export:AnopeInit /export:AnopeFini
+
+all: $(OBJECTS)
+
+distclean: clean spotless
+
+.c.dll:
+ $(CC) $(CFLAGS) $< $(LFLAGS)
+
+clean:
+ -@del *.obj
+
+spotless: clean
+ -@del *.dll *.lib *.exp
+
+install:
+ -@mkdir ..\..\$(DATDEST)\modules
+ -@mkdir ..\..\$(DATDEST)\modules\runtime
+ -@copy *.dll ..\..\$(DATDEST)\modules
diff --git a/src/core/bs_act.c b/src/core/bs_act.c
new file mode 100644
index 000000000..0929ba716
--- /dev/null
+++ b/src/core/bs_act.c
@@ -0,0 +1,93 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_act(User * u);
+void myBotServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_ACT);
+}
+
+/**
+ * The /bs act command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_act(User * u)
+{
+ ChannelInfo *ci;
+
+ char *chan = strtok(NULL, " ");
+ char *text = strtok(NULL, "");
+
+ if (!chan || !text)
+ syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX);
+ else if (!(ci = cs_findchan(chan)))
+ notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
+ else if (ci->flags & CI_VERBOTEN)
+ notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
+ else if (!ci->bi)
+ notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
+ else if (!ci->c || ci->c->usercount < BSMinUsers)
+ notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name);
+ else if (!check_access(u, ci, CA_SAY))
+ notice_lang(s_BotServ, u, ACCESS_DENIED);
+ else {
+ strnrepl(text, BUFSIZE, "\001", "");
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION %s %c", 1,
+ text, 1);
+ ci->bi->lastmsg = time(NULL);
+ if (logchan && LogBot)
+ anope_cmd_privmsg(ci->bi->nick, LogChannel, "ACT %s %s %s",
+ u->nick, ci->name, text);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c
new file mode 100644
index 000000000..320a615fc
--- /dev/null
+++ b/src/core/bs_assign.c
@@ -0,0 +1,102 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_assign(User * u);
+void myBotServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("ASSIGN", do_assign, NULL, BOT_HELP_ASSIGN, -1, -1,
+ -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_ASSIGN);
+}
+
+/**
+ * The /bs assign command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_assign(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+ BotInfo *bi;
+ ChannelInfo *ci;
+
+ if (readonly)
+ notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY);
+ else if (!chan || !nick)
+ syntax_error(s_BotServ, u, "ASSIGN", BOT_ASSIGN_SYNTAX);
+ else if (!(bi = findbot(nick)))
+ notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick);
+ else if (bi->flags & BI_PRIVATE && !is_oper(u))
+ notice_lang(s_BotServ, u, PERMISSION_DENIED);
+ else if (!(ci = cs_findchan(chan)))
+ notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
+ else if (ci->flags & CI_VERBOTEN)
+ notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
+ else if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0))
+ notice_lang(s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan);
+ else if ((ci->botflags & BS_NOBOT)
+ || (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u)))
+ notice_lang(s_BotServ, u, PERMISSION_DENIED);
+ else {
+ if (ci->bi)
+ unassign(u, ci);
+ ci->bi = bi;
+ bi->chancount++;
+ if (ci->c && ci->c->usercount >= BSMinUsers) {
+ bot_join(ci);
+ }
+ notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name);
+ send_event(EVENT_BOT_ASSIGN, 2, ci->name, bi->nick);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c
new file mode 100644
index 000000000..de42f6355
--- /dev/null
+++ b/src/core/bs_badwords.c
@@ -0,0 +1,290 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_badwords(User * u);
+void myBotServHelp(User * u);
+int badwords_del_callback(User * u, int num, va_list args);
+int badwords_list(User * u, int index, ChannelInfo * ci, int *sent_header);
+int badwords_list_callback(User * u, int num, va_list args);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("BADWORDS", do_badwords, NULL, BOT_HELP_BADWORDS, -1,
+ -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_BADWORDS);
+}
+
+/**
+ * The /bs badwords command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_badwords(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *cmd = strtok(NULL, " ");
+ char *word = strtok(NULL, "");
+ ChannelInfo *ci;
+ BadWord *bw;
+
+ int i;
+ int need_args = (cmd
+ && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR")));
+
+ if (!cmd || (need_args ? 0 : !word)) {
+ syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!check_access(u, ci, CA_BADWORDS)
+ && (!need_args || !is_services_admin(u))) {
+ notice_lang(s_BotServ, u, ACCESS_DENIED);
+ } else if (stricmp(cmd, "ADD") == 0) {
+
+ char *opt, *pos;
+ int type = BW_ANY;
+
+ if (readonly) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED);
+ return MOD_CONT;
+ }
+
+ pos = strrchr(word, ' ');
+ if (pos) {
+ opt = pos + 1;
+ if (*opt) {
+ if (!stricmp(opt, "SINGLE"))
+ type = BW_SINGLE;
+ else if (!stricmp(opt, "START"))
+ type = BW_START;
+ else if (!stricmp(opt, "END"))
+ type = BW_END;
+ if (type != BW_ANY)
+ *pos = 0;
+ }
+ }
+
+ for (bw = ci->badwords, i = 0; i < ci->bwcount; bw++, i++) {
+ if (bw->word && ((BSCaseSensitive && (!strcmp(bw->word, word)))
+ || (!BSCaseSensitive
+ && (!stricmp(bw->word, word))))) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS,
+ bw->word, ci->name);
+ return MOD_CONT;
+ }
+ }
+
+ for (i = 0; i < ci->bwcount; i++) {
+ if (!ci->badwords[i].in_use)
+ break;
+ }
+ if (i == ci->bwcount) {
+ if (i < BSBadWordsMax) {
+ ci->bwcount++;
+ ci->badwords =
+ srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount);
+ } else {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_REACHED_LIMIT,
+ BSBadWordsMax);
+ return MOD_CONT;
+ }
+ }
+ bw = &ci->badwords[i];
+ bw->in_use = 1;
+ bw->word = sstrdup(word);
+ bw->type = type;
+
+ notice_lang(s_BotServ, u, BOT_BADWORDS_ADDED, bw->word, ci->name);
+
+ } else if (stricmp(cmd, "DEL") == 0) {
+
+ if (readonly) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED);
+ return MOD_CONT;
+ }
+
+ /* Special case: is it a number/list? Only do search if it isn't. */
+ if (isdigit(*word) && strspn(word, "1234567890,-") == strlen(word)) {
+ int count, deleted, last = -1;
+ deleted =
+ process_numlist(word, &count, badwords_del_callback, u, ci,
+ &last);
+ if (!deleted) {
+ if (count == 1) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_NO_SUCH_ENTRY,
+ last, ci->name);
+ } else {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH,
+ ci->name);
+ }
+ } else if (deleted == 1) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_ONE,
+ ci->name);
+ } else {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_SEVERAL,
+ deleted, ci->name);
+ }
+ } else {
+ for (i = 0; i < ci->bwcount; i++) {
+ if (ci->badwords[i].in_use
+ && !stricmp(ci->badwords[i].word, word))
+ break;
+ }
+ if (i == ci->bwcount) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word,
+ chan);
+ return MOD_CONT;
+ }
+ bw = &ci->badwords[i];
+ notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED, bw->word,
+ ci->name);
+ if (bw->word)
+ free(bw->word);
+ bw->word = NULL;
+ bw->in_use = 0;
+ }
+
+ } else if (stricmp(cmd, "LIST") == 0) {
+ int sent_header = 0;
+
+ if (ci->bwcount == 0) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, chan);
+ return MOD_CONT;
+ }
+ if (word && strspn(word, "1234567890,-") == strlen(word)) {
+ process_numlist(word, NULL, badwords_list_callback, u, ci,
+ &sent_header);
+ } else {
+ for (i = 0; i < ci->bwcount; i++) {
+ if (!(ci->badwords[i].in_use))
+ continue;
+ if (word && ci->badwords[i].word
+ && !match_wild_nocase(word, ci->badwords[i].word))
+ continue;
+ badwords_list(u, i, ci, &sent_header);
+ }
+ }
+ if (!sent_header)
+ notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, chan);
+
+ } else if (stricmp(cmd, "CLEAR") == 0) {
+
+ if (readonly) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED);
+ return MOD_CONT;
+ }
+
+ for (i = 0; i < ci->bwcount; i++)
+ if (ci->badwords[i].word)
+ free(ci->badwords[i].word);
+
+ free(ci->badwords);
+ ci->badwords = NULL;
+ ci->bwcount = 0;
+
+ notice_lang(s_BotServ, u, BOT_BADWORDS_CLEAR);
+
+ } else {
+ syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int badwords_del_callback(User * u, int num, va_list args)
+{
+ BadWord *bw;
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *last = va_arg(args, int *);
+ if (num < 1 || num > ci->bwcount)
+ return 0;
+ *last = num;
+
+ bw = &ci->badwords[num - 1];
+ if (bw->word)
+ free(bw->word);
+ bw->word = NULL;
+ bw->in_use = 0;
+
+ return 1;
+}
+
+int badwords_list(User * u, int index, ChannelInfo * ci, int *sent_header)
+{
+ BadWord *bw = &ci->badwords[index];
+
+ if (!bw->in_use)
+ return 0;
+ if (!*sent_header) {
+ notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_HEADER, ci->name);
+ *sent_header = 1;
+ }
+
+ notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_FORMAT, index + 1,
+ bw->word,
+ ((bw->type ==
+ BW_SINGLE) ? "(SINGLE)" : ((bw->type ==
+ BW_START) ? "(START)"
+ : ((bw->type ==
+ BW_END) ? "(END)" : "")))
+ );
+ return 1;
+}
+
+int badwords_list_callback(User * u, int num, va_list args)
+{
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *sent_header = va_arg(args, int *);
+ if (num < 1 || num > ci->bwcount)
+ return 0;
+ return badwords_list(u, num - 1, ci, sent_header);
+}
diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c
new file mode 100644
index 000000000..0e604a410
--- /dev/null
+++ b/src/core/bs_bot.c
@@ -0,0 +1,372 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+/**
+ * RFC: defination of a valid nick
+ * nickname = ( letter / special ) *8( letter / digit / special / "-" )
+ * letter = %x41-5A / %x61-7A ; A-Z / a-z
+ * digit = %x30-39 ; 0-9
+ * special = %x5B-60 / %x7B-7D ; "[", "]", "\", "`", "_", "^", "{", "|", "}"
+ **/
+#define isvalidnick(c) ( isalnum(c) || ((c) >='\x5B' && (c) <='\x60') || ((c) >='\x7B' && (c) <='\x7D') || (c)=='-' )
+
+
+int do_bot(User * u);
+int delbot(BotInfo * bi);
+void myBotServHelp(User * u);
+void change_bot_nick(BotInfo * bi, char *newnick);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("BOT", do_bot, is_services_admin, -1, -1, -1,
+ BOT_SERVADMIN_HELP_BOT, BOT_SERVADMIN_HELP_BOT);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_BOT);
+ }
+}
+
+/**
+ * The /bs bot command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_bot(User * u)
+{
+ BotInfo *bi;
+ char *cmd = strtok(NULL, " ");
+ char *ch = NULL;
+
+ if (!cmd)
+ syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
+ else if (!stricmp(cmd, "ADD")) {
+ char *nick = strtok(NULL, " ");
+ char *user = strtok(NULL, " ");
+ char *host = strtok(NULL, " ");
+ char *real = strtok(NULL, "");
+
+ if (!nick || !user || !host || !real)
+ syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
+ else if (readonly)
+ notice_lang(s_BotServ, u, BOT_BOT_READONLY);
+ else if (findbot(nick))
+ notice_lang(s_BotServ, u, BOT_BOT_ALREADY_EXISTS, nick);
+ else {
+ NickAlias *na;
+
+ /**
+ * Check the nick is valid re RFC 2812
+ **/
+ if (isdigit(nick[0]) || nick[0] == '-') {
+ notice_lang(s_BotServ, u, BOT_BAD_NICK);
+ return MOD_CONT;
+ }
+ for (ch = nick; *ch && (ch - nick) < NICKMAX; ch++) {
+ if (!isvalidnick(*ch)) {
+ notice_lang(s_BotServ, u, BOT_BAD_NICK);
+ return MOD_CONT;
+ }
+ }
+
+ /* check for hardcored ircd forbidden nicks */
+ if (!anope_valid_nick(nick)) {
+ notice_lang(s_BotServ, u, BOT_BAD_NICK);
+ return MOD_CONT;
+ }
+
+ if (!isValidHost(host, 3)) {
+ notice_lang(s_BotServ, u, BOT_BAD_HOST);
+ return MOD_CONT;
+ }
+ for (ch = user; *ch && (ch - user) < USERMAX; ch++) {
+ if (!isalnum(*ch)) {
+ notice_lang(s_BotServ, u, BOT_BAD_IDENT);
+ return MOD_CONT;
+ }
+ }
+
+ /**
+ * Check the host is valid re RFC 2812
+ **/
+
+ /* Check whether it's a services client's nick and return if so - Certus */
+ /* use nickIsServices reduce the total number lines of code - TSL */
+
+ if (nickIsServices(nick, 0)) {
+ notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED);
+ return MOD_CONT;
+ }
+
+ /* We check whether the nick is registered, and inform the user
+ * if so. You need to drop the nick manually before you can use
+ * it as a bot nick from now on -GD
+ */
+ if ((na = findnick(nick))) {
+ notice_lang(s_BotServ, u, NICK_ALREADY_REGISTERED, nick);
+ return MOD_CONT;
+ }
+
+ bi = makebot(nick);
+ if (!bi) {
+ notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED);
+ return MOD_CONT;
+ }
+
+ bi->user = sstrdup(user);
+ bi->host = sstrdup(host);
+ bi->real = sstrdup(real);
+ bi->created = time(NULL);
+ bi->chancount = 0;
+
+ /* We check whether user with this nick is online, and kill it if so */
+ EnforceQlinedNick(nick, s_BotServ);
+
+ /* We make the bot online, ready to serve */
+ anope_cmd_bot_nick(bi->nick, bi->user, bi->host, bi->real,
+ ircd->botserv_bot_mode);
+
+ notice_lang(s_BotServ, u, BOT_BOT_ADDED, bi->nick, bi->user,
+ bi->host, bi->real);
+
+ send_event(EVENT_BOT_CREATE, 1, bi->nick);
+ }
+ } else if (!stricmp(cmd, "CHANGE")) {
+ char *oldnick = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+ char *user = strtok(NULL, " ");
+ char *host = strtok(NULL, " ");
+ char *real = strtok(NULL, "");
+
+ if (!oldnick || !nick)
+ syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
+ else if (readonly)
+ notice_lang(s_BotServ, u, BOT_BOT_READONLY);
+ else if (!(bi = findbot(oldnick)))
+ notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, oldnick);
+ else {
+ NickAlias *na;
+
+ /* Checks whether there *are* changes.
+ * Case sensitive because we may want to change just the case.
+ * And we must finally check that the nick is not already
+ * taken by another bot.
+ */
+ if (!strcmp(bi->nick, nick)
+ && ((user) ? !strcmp(bi->user, user) : 1)
+ && ((host) ? !strcmp(bi->host, host) : 1)
+ && ((real) ? !strcmp(bi->real, real) : 1)) {
+ notice_lang(s_BotServ, u, BOT_BOT_ANY_CHANGES);
+ return MOD_CONT;
+ }
+
+ /* Check whether it's a services client's nick and return if so - Certus */
+ /* use nickIsServices() to reduce the number of lines of code - TSL */
+ if (nickIsServices(nick, 0)) {
+ notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED);
+ return MOD_CONT;
+ }
+
+ /**
+ * Check the nick is valid re RFC 2812
+ **/
+ if (isdigit(nick[0]) || nick[0] == '-') {
+ notice_lang(s_BotServ, u, BOT_BAD_NICK);
+ return MOD_CONT;
+ }
+ for (ch = nick; *ch && (ch - nick) < NICKMAX; ch++) {
+ if (!isvalidnick(*ch)) {
+ notice_lang(s_BotServ, u, BOT_BAD_NICK);
+ return MOD_CONT;
+ }
+ }
+
+ /* check for hardcored ircd forbidden nicks */
+ if (!anope_valid_nick(nick)) {
+ notice_lang(s_BotServ, u, BOT_BAD_NICK);
+ return MOD_CONT;
+ }
+
+ if (!isValidHost(host, 3)) {
+ notice_lang(s_BotServ, u, BOT_BAD_HOST);
+ return MOD_CONT;
+ }
+
+ for (ch = user; *ch && (ch - user) < USERMAX; ch++) {
+ if (!isalnum(*ch)) {
+ notice_lang(s_BotServ, u, BOT_BAD_IDENT);
+ return MOD_CONT;
+ }
+ }
+
+ if (stricmp(bi->nick, nick) && findbot(nick)) {
+ notice_lang(s_BotServ, u, BOT_BOT_ALREADY_EXISTS, nick);
+ return MOD_CONT;
+ }
+
+ if (stricmp(bi->nick, nick)) {
+ /* We check whether the nick is registered, and inform the user
+ * if so. You need to drop the nick manually before you can use
+ * it as a bot nick from now on -GD
+ */
+ if ((na = findnick(nick))) {
+ notice_lang(s_BotServ, u, NICK_ALREADY_REGISTERED,
+ nick);
+ return MOD_CONT;
+ }
+
+ /* The new nick is really different, so we remove the Q line for
+ the old nick. */
+ if (ircd->sqline) {
+ anope_cmd_unsqline(bi->nick);
+ }
+
+ /* We check whether user with this nick is online, and kill it if so */
+ EnforceQlinedNick(nick, s_BotServ);
+ }
+
+ if (strcmp(nick, bi->nick))
+ change_bot_nick(bi, nick);
+
+ if (user && strcmp(user, bi->user)) {
+ free(bi->user);
+ bi->user = sstrdup(user);
+ }
+ if (host && strcmp(host, bi->host)) {
+ free(bi->host);
+ bi->host = sstrdup(host);
+ }
+ if (real && strcmp(real, bi->real)) {
+ free(bi->real);
+ bi->real = sstrdup(real);
+ }
+
+ /* If only the nick changes, we just make the bot change his nick,
+ else we must make it quit and rejoin. */
+ if (!user)
+ anope_cmd_chg_nick(oldnick, bi->nick);
+ else {
+ anope_cmd_quit(oldnick, "Quit: Be right back");
+
+ anope_cmd_bot_nick(bi->nick, bi->user, bi->host, bi->real,
+ ircd->botserv_bot_mode);
+ bot_rejoin_all(bi);
+ }
+
+ notice_lang(s_BotServ, u, BOT_BOT_CHANGED, oldnick, bi->nick,
+ bi->user, bi->host, bi->real);
+
+ send_event(EVENT_BOT_CHANGE, 1, bi->nick);
+ }
+ } else if (!stricmp(cmd, "DEL")) {
+ char *nick = strtok(NULL, " ");
+
+ if (!nick)
+ syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
+ else if (readonly)
+ notice_lang(s_BotServ, u, BOT_BOT_READONLY);
+ else if (!(bi = findbot(nick)))
+ notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick);
+ else {
+ send_event(EVENT_BOT_DEL, 1, bi->nick);
+ anope_cmd_quit(bi->nick,
+ "Quit: Help! I'm being deleted by %s!",
+ u->nick);
+ if (ircd->sqline) {
+ anope_cmd_unsqline(bi->nick);
+ }
+ delbot(bi);
+
+ notice_lang(s_BotServ, u, BOT_BOT_DELETED, nick);
+ }
+ } else
+ syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX);
+
+ return MOD_CONT;
+}
+
+int delbot(BotInfo * bi)
+{
+ cs_remove_bot(bi);
+
+ if (bi->next)
+ bi->next->prev = bi->prev;
+ if (bi->prev)
+ bi->prev->next = bi->next;
+ else
+ botlists[tolower(*bi->nick)] = bi->next;
+
+ nbots--;
+
+ free(bi->nick);
+ free(bi->user);
+ free(bi->host);
+ free(bi->real);
+
+ free(bi);
+
+ return 1;
+}
+
+void change_bot_nick(BotInfo * bi, char *newnick)
+{
+ if (bi->next)
+ bi->next->prev = bi->prev;
+ if (bi->prev)
+ bi->prev->next = bi->next;
+ else
+ botlists[tolower(*bi->nick)] = bi->next;
+
+ if (bi->nick)
+ free(bi->nick);
+ bi->nick = sstrdup(newnick);
+
+ insert_bot(bi);
+}
diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c
new file mode 100644
index 000000000..cc510aec0
--- /dev/null
+++ b/src/core/bs_botlist.c
@@ -0,0 +1,108 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_botlist(User * u);
+void myBotServHelp(User * u);
+
+/**
+ * Create the botlist command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("BOTLIST", do_botlist, NULL, BOT_HELP_BOTLIST, -1,
+ -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_BOTLIST);
+}
+
+/**
+ * The /bs botlist command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_botlist(User * u)
+{
+ int i, count = 0;
+ BotInfo *bi;
+
+ if (!nbots) {
+ notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ for (i = 0; i < 256; i++) {
+ for (bi = botlists[i]; bi; bi = bi->next) {
+ if (!(bi->flags & BI_PRIVATE)) {
+ if (!count)
+ notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER);
+ count++;
+ notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick,
+ bi->user, bi->host);
+ }
+ }
+ }
+
+ if (is_oper(u) && count < nbots) {
+ notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER);
+
+ for (i = 0; i < 256; i++) {
+ for (bi = botlists[i]; bi; bi = bi->next) {
+ if (bi->flags & BI_PRIVATE) {
+ notice_user(s_BotServ, u, " %-15s (%s@%s)",
+ bi->nick, bi->user, bi->host);
+ count++;
+ }
+ }
+ }
+ }
+
+ if (!count)
+ notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY);
+ else
+ notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count);
+ return MOD_CONT;
+}
diff --git a/src/core/bs_fantasy.c b/src/core/bs_fantasy.c
new file mode 100644
index 000000000..9ea3fe402
--- /dev/null
+++ b/src/core/bs_fantasy.c
@@ -0,0 +1,80 @@
+/* BotServ core fantasy functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_fantasy(int argc, char **argv);
+
+/**
+ * Create the hook, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ EvtHook *hook;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy);
+ moduleAddEventHook(hook);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Handle all csmodeutils fantasy commands.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT or MOD_STOP
+ **/
+int do_fantasy(int argc, char **argv)
+{
+ User *u;
+ ChannelInfo *ci;
+ CSModeUtil *util = csmodeutils;
+ char *target;
+
+ if (argc < 3)
+ return MOD_CONT;
+
+ do {
+ if (stricmp(argv[0], util->bsname) == 0) {
+ u = finduser(argv[1]);
+ ci = cs_findchan(argv[2]);
+ if (!u || !ci)
+ return MOD_CONT;
+
+ target = ((argc == 4) ? argv[3] : NULL);
+
+ if (!target && check_access(u, ci, util->levelself))
+ bot_raw_mode(u, ci, util->mode, u->nick);
+ else if (target && check_access(u, ci, util->level))
+ bot_raw_mode(u, ci, util->mode, target);
+ }
+ } while ((++util)->name != NULL);
+
+ return MOD_CONT;
+}
diff --git a/src/core/bs_fantasy_kick.c b/src/core/bs_fantasy_kick.c
new file mode 100644
index 000000000..ec1e78ae6
--- /dev/null
+++ b/src/core/bs_fantasy_kick.c
@@ -0,0 +1,87 @@
+/* BotServ core fantasy functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_fantasy(int argc, char **argv);
+
+/**
+ * Create the hook, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ EvtHook *hook;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy);
+ moduleAddEventHook(hook);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Handle kick/k fantasy commands.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT or MOD_STOP
+ **/
+int do_fantasy(int argc, char **argv)
+{
+ User *u;
+ ChannelInfo *ci;
+ char *target = NULL;
+ char *reason = NULL;
+
+ if (argc < 3)
+ return MOD_CONT;
+
+ if ((stricmp(argv[0], "!kick") == 0) || (stricmp(argv[0], "!k") == 0)) {
+ u = finduser(argv[1]);
+ ci = cs_findchan(argv[2]);
+ if (!u || !ci)
+ return MOD_CONT;
+
+ if (argc >= 4) {
+ target = myStrGetToken(argv[3], ' ', 0);
+ reason = myStrGetTokenRemainder(argv[3], ' ', 1);
+ }
+ if (!target && check_access(u, ci, CA_KICKME)) {
+ bot_raw_kick(u, ci, u->nick, "Requested");
+ } else if (target && check_access(u, ci, CA_KICK)) {
+ if (!stricmp(target, ci->bi->nick))
+ bot_raw_kick(u, ci, u->nick, "Oops!");
+ else if (!reason)
+ bot_raw_kick(u, ci, target, "Requested");
+ else
+ bot_raw_kick(u, ci, target, reason);
+ }
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/bs_fantasy_kickban.c b/src/core/bs_fantasy_kickban.c
new file mode 100644
index 000000000..651b0113d
--- /dev/null
+++ b/src/core/bs_fantasy_kickban.c
@@ -0,0 +1,90 @@
+/* BotServ core fantasy functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_fantasy(int argc, char **argv);
+
+/**
+ * Create the hook, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ EvtHook *hook;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy);
+ moduleAddEventHook(hook);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Handle kickban/kb fantasy commands.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT or MOD_STOP
+ **/
+int do_fantasy(int argc, char **argv)
+{
+ User *u;
+ ChannelInfo *ci;
+ char *target = NULL;
+ char *reason = NULL;
+
+ if (argc < 3)
+ return MOD_CONT;
+
+ if ((stricmp(argv[0], "!kickban") == 0)
+ || (stricmp(argv[0], "!kb") == 0)) {
+ u = finduser(argv[1]);
+ ci = cs_findchan(argv[2]);
+ if (!u || !ci)
+ return MOD_CONT;
+
+ if (argc >= 4) {
+ target = myStrGetToken(argv[3], ' ', 0);
+ reason = myStrGetTokenRemainder(argv[3], ' ', 1);
+ }
+ if (!target && check_access(u, ci, CA_BANME)) {
+ bot_raw_ban(u, ci, u->nick, "Requested");
+ } else if (target && check_access(u, ci, CA_BAN)) {
+ if (stricmp(target, ci->bi->nick) == 0) {
+ bot_raw_ban(u, ci, u->nick, "Oops!");
+ } else {
+ if (!reason)
+ bot_raw_ban(u, ci, target, "Requested");
+ else
+ bot_raw_ban(u, ci, target, reason);
+ }
+ }
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/bs_fantasy_owner.c b/src/core/bs_fantasy_owner.c
new file mode 100644
index 000000000..ec88c966b
--- /dev/null
+++ b/src/core/bs_fantasy_owner.c
@@ -0,0 +1,87 @@
+/* BotServ core fantasy functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_fantasy(int argc, char **argv);
+
+/**
+ * Create the hook, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ EvtHook *hook;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ /* No need to load of we don't support owner */
+ if (!ircd->owner) {
+ alog("Your ircd doesn't support the owner channelmode; bs_fantasy_owner won't be loaded");
+ return MOD_STOP;
+ }
+
+ hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy);
+ moduleAddEventHook(hook);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Handle owner/deowner fantasy commands.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT or MOD_STOP
+ **/
+int do_fantasy(int argc, char **argv)
+{
+ User *u;
+ ChannelInfo *ci;
+
+ if (argc < 3)
+ return MOD_CONT;
+
+ if (stricmp(argv[0], "!deowner") == 0) {
+ u = finduser(argv[1]);
+ ci = cs_findchan(argv[2]);
+ if (!u || !ci)
+ return MOD_CONT;
+
+ if (is_founder(u, ci))
+ bot_raw_mode(u, ci, ircd->ownerunset, u->nick);
+ } else if (stricmp(argv[0], "!owner") == 0) {
+ u = finduser(argv[1]);
+ ci = cs_findchan(argv[2]);
+ if (!u || !ci)
+ return MOD_CONT;
+
+ if (is_founder(u, ci))
+ bot_raw_mode(u, ci, ircd->ownerset, u->nick);
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/bs_fantasy_seen.c b/src/core/bs_fantasy_seen.c
new file mode 100644
index 000000000..e218576d6
--- /dev/null
+++ b/src/core/bs_fantasy_seen.c
@@ -0,0 +1,136 @@
+/* BotServ core fantasy functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_fantasy(int argc, char **argv);
+
+/**
+ * Create the hook, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ EvtHook *hook;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy);
+ moduleAddEventHook(hook);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Handle seen fantasy command.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT or MOD_STOP
+ **/
+int do_fantasy(int argc, char **argv)
+{
+ User *u;
+ ChannelInfo *ci;
+ User *u2;
+ NickAlias *na;
+ ChanAccess *access;
+ char buf[BUFSIZE];
+ char *target = NULL;
+
+ if (argc < 4)
+ return MOD_CONT;
+
+ if (stricmp(argv[0], "!seen") == 0) {
+ u = finduser(argv[1]);
+ ci = cs_findchan(argv[2]);
+ if (!u || !ci)
+ return MOD_CONT;
+
+ target = myStrGetToken(argv[3], ' ', 0);
+
+ if (stricmp(ci->bi->nick, target) == 0) {
+ /* If we look for the bot */
+ snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_BOT),
+ u->nick);
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
+ } else if (!(na = findnick(target)) || (na->status & NS_VERBOTEN)) {
+ /* If the nick is not registered or forbidden */
+ snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN),
+ target);
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
+ } else if ((u2 = nc_on_chan(ci->c, na->nc))) {
+ /* If the nick we're looking for is on the channel,
+ * there are three possibilities: it's yourself,
+ * it's the nick we look for, it's an alias of the
+ * nick we look for.
+ */
+ if (u == u2 || (u->na && u->na->nc == na->nc))
+ snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_YOU),
+ u->nick);
+ else if (!stricmp(u2->nick, target))
+ snprintf(buf, sizeof(buf),
+ getstring(u->na, BOT_SEEN_ON_CHANNEL), u2->nick);
+ else
+ snprintf(buf, sizeof(buf),
+ getstring(u->na, BOT_SEEN_ON_CHANNEL_AS), target,
+ u2->nick);
+
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
+ } else if ((access = get_access_entry(na->nc, ci))) {
+ /* User is on the access list but not present actually.
+ Special case: if access->last_seen is 0 it's that we
+ never seen the user.
+ */
+ if (access->last_seen) {
+ char durastr[192];
+ duration(u->na, durastr, sizeof(durastr),
+ time(NULL) - access->last_seen);
+ snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON),
+ target, durastr);
+ } else {
+ snprintf(buf, sizeof(buf),
+ getstring(u->na, BOT_SEEN_NEVER), target);
+ }
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
+ } else if (na->nc == ci->founder) {
+ /* User is the founder of the channel */
+ char durastr[192];
+ duration(u->na, durastr, sizeof(durastr),
+ time(NULL) - na->last_seen);
+ snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON),
+ target, durastr);
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
+ } else {
+ /* All other cases */
+ snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN),
+ target);
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
+ }
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/bs_fantasy_unban.c b/src/core/bs_fantasy_unban.c
new file mode 100644
index 000000000..412b36099
--- /dev/null
+++ b/src/core/bs_fantasy_unban.c
@@ -0,0 +1,78 @@
+/* BotServ core fantasy functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_fantasy(int argc, char **argv);
+
+/**
+ * Create the hook, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ EvtHook *hook;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy);
+ moduleAddEventHook(hook);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Handle unban fantasy command.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT or MOD_STOP
+ **/
+int do_fantasy(int argc, char **argv)
+{
+ User *u;
+ ChannelInfo *ci;
+ char *target = NULL;
+
+ if (argc < 3)
+ return MOD_CONT;
+
+ if (stricmp(argv[0], "!unban") == 0) {
+ u = finduser(argv[1]);
+ ci = cs_findchan(argv[2]);
+ if (!u || !ci || !check_access(u, ci, CA_UNBAN))
+ return MOD_CONT;
+
+ if (argc >= 4)
+ target = myStrGetToken(argv[3], ' ', 0);
+ if (!target)
+ common_unban(ci, u->nick);
+ else
+ common_unban(ci, target);
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/bs_help.c b/src/core/bs_help.c
new file mode 100644
index 000000000..8fea7a5ad
--- /dev/null
+++ b/src/core/bs_help.c
@@ -0,0 +1,67 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_help(User * u);
+
+/**
+ * Create the help command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * The /bs help command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_help(User * u)
+{
+ char *cmd = strtok(NULL, "");
+
+ if (!cmd) {
+ notice_help(s_BotServ, u, BOT_HELP);
+ moduleDisplayHelp(4, u);
+ notice_help(s_BotServ, u, BOT_HELP_FOOTER, BSMinUsers);
+ } else {
+ mod_help_cmd(s_BotServ, u, BOTSERV, cmd);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/bs_info.c b/src/core/bs_info.c
new file mode 100644
index 000000000..3665b2054
--- /dev/null
+++ b/src/core/bs_info.c
@@ -0,0 +1,282 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_info(User * u);
+void send_bot_channels(User * u, BotInfo * bi);
+void myBotServHelp(User * u);
+
+/**
+ * Create the info command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("INFO", do_info, NULL, BOT_HELP_INFO, -1, -1, -1,
+ -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_INFO);
+}
+
+/**
+ * The /bs info command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_info(User * u)
+{
+ BotInfo *bi;
+ ChannelInfo *ci;
+ char *query = strtok(NULL, " ");
+
+ int need_comma = 0, is_servadmin = is_services_admin(u);
+ char buf[BUFSIZE], *end;
+ const char *commastr = getstring(u->na, COMMA_SPACE);
+
+ if (!query)
+ syntax_error(s_BotServ, u, "INFO", BOT_INFO_SYNTAX);
+ else if ((bi = findbot(query))) {
+ char buf[BUFSIZE];
+ struct tm *tm;
+
+ notice_lang(s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick);
+ notice_lang(s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host);
+ notice_lang(s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real);
+ tm = localtime(&bi->created);
+ strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
+ notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf);
+ notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS,
+ getstring(u->na,
+ (bi->
+ flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE :
+ BOT_INFO_OPT_NONE));
+ notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount);
+
+ if (is_services_admin(u))
+ send_bot_channels(u, bi);
+ } else if ((ci = cs_findchan(query))) {
+ if (!is_servadmin && !is_founder(u, ci)) {
+ notice_lang(s_BotServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+ if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, query);
+ return MOD_CONT;
+ }
+
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_HEADER, ci->name);
+ if (ci->bi)
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE);
+
+ if (ci->botflags & BS_KICK_BADWORDS) {
+ if (ci->ttb[TTB_BADWORDS])
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->ttb[TTB_BADWORDS]);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS,
+ getstring(u->na, BOT_INFO_ACTIVE));
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS,
+ getstring(u->na, BOT_INFO_INACTIVE));
+ if (ci->botflags & BS_KICK_BOLDS) {
+ if (ci->ttb[TTB_BOLDS])
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->ttb[TTB_BOLDS]);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS,
+ getstring(u->na, BOT_INFO_ACTIVE));
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS,
+ getstring(u->na, BOT_INFO_INACTIVE));
+ if (ci->botflags & BS_KICK_CAPS) {
+ if (ci->ttb[TTB_CAPS])
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->ttb[TTB_CAPS], ci->capsmin,
+ ci->capspercent);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON,
+ getstring(u->na, BOT_INFO_ACTIVE), ci->capsmin,
+ ci->capspercent);
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF,
+ getstring(u->na, BOT_INFO_INACTIVE));
+ if (ci->botflags & BS_KICK_COLORS) {
+ if (ci->ttb[TTB_COLORS])
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->ttb[TTB_COLORS]);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS,
+ getstring(u->na, BOT_INFO_ACTIVE));
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS,
+ getstring(u->na, BOT_INFO_INACTIVE));
+ if (ci->botflags & BS_KICK_FLOOD) {
+ if (ci->ttb[TTB_FLOOD])
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->ttb[TTB_FLOOD], ci->floodlines,
+ ci->floodsecs);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->floodlines, ci->floodsecs);
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF,
+ getstring(u->na, BOT_INFO_INACTIVE));
+ if (ci->botflags & BS_KICK_REPEAT) {
+ if (ci->ttb[TTB_REPEAT])
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->ttb[TTB_REPEAT], ci->repeattimes);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->repeattimes);
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF,
+ getstring(u->na, BOT_INFO_INACTIVE));
+ if (ci->botflags & BS_KICK_REVERSES) {
+ if (ci->ttb[TTB_REVERSES])
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->ttb[TTB_REVERSES]);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES,
+ getstring(u->na, BOT_INFO_ACTIVE));
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES,
+ getstring(u->na, BOT_INFO_INACTIVE));
+ if (ci->botflags & BS_KICK_UNDERLINES) {
+ if (ci->ttb[TTB_UNDERLINES])
+ notice_lang(s_BotServ, u,
+ BOT_INFO_CHAN_KICK_UNDERLINES_BAN,
+ getstring(u->na, BOT_INFO_ACTIVE),
+ ci->ttb[TTB_UNDERLINES]);
+ else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES,
+ getstring(u->na, BOT_INFO_ACTIVE));
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES,
+ getstring(u->na, BOT_INFO_INACTIVE));
+
+ end = buf;
+ *end = 0;
+ if (ci->botflags & BS_DONTKICKOPS) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s",
+ getstring(u->na, BOT_INFO_OPT_DONTKICKOPS));
+ need_comma = 1;
+ }
+ if (ci->botflags & BS_DONTKICKVOICES) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, BOT_INFO_OPT_DONTKICKVOICES));
+ need_comma = 1;
+ }
+ if (ci->botflags & BS_FANTASY) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, BOT_INFO_OPT_FANTASY));
+ need_comma = 1;
+ }
+ if (ci->botflags & BS_GREET) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, BOT_INFO_OPT_GREET));
+ need_comma = 1;
+ }
+ if (ci->botflags & BS_NOBOT) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, BOT_INFO_OPT_NOBOT));
+ need_comma = 1;
+ }
+ if (ci->botflags & BS_SYMBIOSIS) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, BOT_INFO_OPT_SYMBIOSIS));
+ need_comma = 1;
+ }
+ notice_lang(s_BotServ, u, BOT_INFO_CHAN_OPTIONS,
+ *buf ? buf : getstring(u->na, BOT_INFO_OPT_NONE));
+
+ } else
+ notice_lang(s_BotServ, u, BOT_INFO_NOT_FOUND, query);
+ return MOD_CONT;
+}
+
+void send_bot_channels(User * u, BotInfo * bi)
+{
+ int i;
+ ChannelInfo *ci;
+ char buf[307], *end;
+
+ *buf = 0;
+ end = buf;
+
+ for (i = 0; i < 256; i++) {
+ for (ci = chanlists[i]; ci; ci = ci->next) {
+ if (ci->bi == bi) {
+ if (strlen(buf) + strlen(ci->name) > 300) {
+ notice_user(s_BotServ, u, buf);
+ *buf = 0;
+ end = buf;
+ }
+ end +=
+ snprintf(end, sizeof(buf) - (end - buf), " %s ",
+ ci->name);
+ }
+ }
+ }
+
+ if (*buf)
+ notice_user(s_BotServ, u, buf);
+ return;
+}
diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c
new file mode 100644
index 000000000..abedbd550
--- /dev/null
+++ b/src/core/bs_kick.c
@@ -0,0 +1,377 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_kickcmd(User * u);
+
+void myBotServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("KICK", do_kickcmd, NULL, BOT_HELP_KICK, -1, -1, -1,
+ -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("KICK BADWORDS", NULL, NULL, BOT_HELP_KICK_BADWORDS,
+ -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("KICK BOLDS", NULL, NULL, BOT_HELP_KICK_BOLDS, -1,
+ -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("KICK CAPS", NULL, NULL, BOT_HELP_KICK_CAPS, -1, -1,
+ -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("KICK COLORS", NULL, NULL, BOT_HELP_KICK_COLORS, -1,
+ -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("KICK FLOOD", NULL, NULL, BOT_HELP_KICK_FLOOD, -1,
+ -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("KICK REPEAT", NULL, NULL, BOT_HELP_KICK_REPEAT, -1,
+ -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("KICK REVERSES", NULL, NULL, BOT_HELP_KICK_REVERSES,
+ -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("KICK UNDERLINES", NULL, NULL,
+ BOT_HELP_KICK_UNDERLINES, -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_KICK);
+}
+
+/**
+ * The /bs kick command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_kickcmd(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *option = strtok(NULL, " ");
+ char *value = strtok(NULL, " ");
+ char *ttb = strtok(NULL, " ");
+
+ ChannelInfo *ci;
+
+ if (readonly)
+ notice_lang(s_BotServ, u, BOT_KICK_DISABLED);
+ else if (!chan || !option || !value)
+ syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
+ else if (stricmp(value, "ON") && stricmp(value, "OFF"))
+ syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
+ else if (!(ci = cs_findchan(chan)))
+ notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
+ else if (ci->flags & CI_VERBOTEN)
+ notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
+ else if (!is_services_admin(u) && !check_access(u, ci, CA_SET))
+ notice_lang(s_BotServ, u, ACCESS_DENIED);
+ else {
+ if (!stricmp(option, "BADWORDS")) {
+ if (!stricmp(value, "ON")) {
+ if (ttb) {
+ ci->ttb[TTB_BADWORDS] =
+ strtol(ttb, (char **) NULL, 10);
+ /* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */
+ if (errno == ERANGE || errno == EINVAL
+ || ci->ttb[TTB_BADWORDS] < 0) {
+ /* leaving the debug behind since we might want to know what these are */
+ if (debug) {
+ alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BADWORDS]);
+ }
+ /* reset the value back to 0 - TSL */
+ ci->ttb[TTB_BADWORDS] = 0;
+ notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
+ return MOD_CONT;
+ }
+ } else {
+ ci->ttb[TTB_BADWORDS] = 0;
+ }
+ ci->botflags |= BS_KICK_BADWORDS;
+ if (ci->ttb[TTB_BADWORDS])
+ notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN,
+ ci->ttb[TTB_BADWORDS]);
+ else
+ notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON);
+ } else {
+ ci->botflags &= ~BS_KICK_BADWORDS;
+ notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_OFF);
+ }
+ } else if (!stricmp(option, "BOLDS")) {
+ if (!stricmp(value, "ON")) {
+ if (ttb) {
+ ci->ttb[TTB_BOLDS] = strtol(ttb, (char **) NULL, 10);
+ if (errno == ERANGE || errno == EINVAL
+ || ci->ttb[TTB_BOLDS] < 0) {
+ if (debug) {
+ alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BOLDS]);
+ }
+ ci->ttb[TTB_BOLDS] = 0;
+ notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
+ return MOD_CONT;
+ }
+ } else
+ ci->ttb[TTB_BOLDS] = 0;
+ ci->botflags |= BS_KICK_BOLDS;
+ if (ci->ttb[TTB_BOLDS])
+ notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON_BAN,
+ ci->ttb[TTB_BOLDS]);
+ else
+ notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON);
+ } else {
+ ci->botflags &= ~BS_KICK_BOLDS;
+ notice_lang(s_BotServ, u, BOT_KICK_BOLDS_OFF);
+ }
+ } else if (!stricmp(option, "CAPS")) {
+ if (!stricmp(value, "ON")) {
+ char *min = strtok(NULL, " ");
+ char *percent = strtok(NULL, " ");
+
+ if (ttb) {
+ ci->ttb[TTB_CAPS] = strtol(ttb, (char **) NULL, 10);
+ if (errno == ERANGE || errno == EINVAL
+ || ci->ttb[TTB_CAPS] < 0) {
+ if (debug) {
+ alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_CAPS]);
+ }
+ ci->ttb[TTB_CAPS] = 0;
+ notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
+ return MOD_CONT;
+ }
+ } else
+ ci->ttb[TTB_CAPS] = 0;
+
+ if (!min)
+ ci->capsmin = 10;
+ else
+ ci->capsmin = atol(min);
+ if (ci->capsmin < 1)
+ ci->capsmin = 10;
+
+ if (!percent)
+ ci->capspercent = 25;
+ else
+ ci->capspercent = atol(percent);
+ if (ci->capspercent < 1 || ci->capspercent > 100)
+ ci->capspercent = 25;
+
+ ci->botflags |= BS_KICK_CAPS;
+ if (ci->ttb[TTB_CAPS])
+ notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON_BAN,
+ ci->capsmin, ci->capspercent,
+ ci->ttb[TTB_CAPS]);
+ else
+ notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON,
+ ci->capsmin, ci->capspercent);
+ } else {
+ ci->botflags &= ~BS_KICK_CAPS;
+ notice_lang(s_BotServ, u, BOT_KICK_CAPS_OFF);
+ }
+ } else if (!stricmp(option, "COLORS")) {
+ if (!stricmp(value, "ON")) {
+ if (ttb) {
+ ci->ttb[TTB_COLORS] = strtol(ttb, (char **) NULL, 10);
+ if (errno == ERANGE || errno == EINVAL
+ || ci->ttb[TTB_COLORS] < 0) {
+ if (debug) {
+ alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_COLORS]);
+ }
+ ci->ttb[TTB_COLORS] = 0;
+ notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
+ return MOD_CONT;
+ }
+ } else
+ ci->ttb[TTB_COLORS] = 0;
+ ci->botflags |= BS_KICK_COLORS;
+ if (ci->ttb[TTB_COLORS])
+ notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON_BAN,
+ ci->ttb[TTB_COLORS]);
+ else
+ notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON);
+ } else {
+ ci->botflags &= ~BS_KICK_COLORS;
+ notice_lang(s_BotServ, u, BOT_KICK_COLORS_OFF);
+ }
+ } else if (!stricmp(option, "FLOOD")) {
+ if (!stricmp(value, "ON")) {
+ char *lines = strtok(NULL, " ");
+ char *secs = strtok(NULL, " ");
+
+ if (ttb) {
+ ci->ttb[TTB_FLOOD] = strtol(ttb, (char **) NULL, 10);
+ if (errno == ERANGE || errno == EINVAL
+ || ci->ttb[TTB_FLOOD] < 0) {
+ if (debug) {
+ alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_FLOOD]);
+ }
+ ci->ttb[TTB_FLOOD] = 0;
+ notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
+ return MOD_CONT;
+ }
+ } else
+ ci->ttb[TTB_FLOOD] = 0;
+
+ if (!lines)
+ ci->floodlines = 6;
+ else
+ ci->floodlines = atol(lines);
+ if (ci->floodlines < 2)
+ ci->floodlines = 6;
+
+ if (!secs)
+ ci->floodsecs = 10;
+ else
+ ci->floodsecs = atol(secs);
+ if (ci->floodsecs < 1 || ci->floodsecs > BSKeepData)
+ ci->floodsecs = 10;
+
+ ci->botflags |= BS_KICK_FLOOD;
+ if (ci->ttb[TTB_FLOOD])
+ notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON_BAN,
+ ci->floodlines, ci->floodsecs,
+ ci->ttb[TTB_FLOOD]);
+ else
+ notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON,
+ ci->floodlines, ci->floodsecs);
+ } else {
+ ci->botflags &= ~BS_KICK_FLOOD;
+ notice_lang(s_BotServ, u, BOT_KICK_FLOOD_OFF);
+ }
+ } else if (!stricmp(option, "REPEAT")) {
+ if (!stricmp(value, "ON")) {
+ char *times = strtok(NULL, " ");
+
+ if (ttb) {
+ ci->ttb[TTB_REPEAT] = strtol(ttb, (char **) NULL, 10);
+ if (errno == ERANGE || errno == EINVAL
+ || ci->ttb[TTB_REPEAT] < 0) {
+ if (debug) {
+ alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REPEAT]);
+ }
+ ci->ttb[TTB_REPEAT] = 0;
+ notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
+ return MOD_CONT;
+ }
+ } else
+ ci->ttb[TTB_REPEAT] = 0;
+
+ if (!times)
+ ci->repeattimes = 3;
+ else
+ ci->repeattimes = atol(times);
+ if (ci->repeattimes < 2)
+ ci->repeattimes = 3;
+
+ ci->botflags |= BS_KICK_REPEAT;
+ if (ci->ttb[TTB_REPEAT])
+ notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON_BAN,
+ ci->repeattimes, ci->ttb[TTB_REPEAT]);
+ else
+ notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON,
+ ci->repeattimes);
+ } else {
+ ci->botflags &= ~BS_KICK_REPEAT;
+ notice_lang(s_BotServ, u, BOT_KICK_REPEAT_OFF);
+ }
+ } else if (!stricmp(option, "REVERSES")) {
+ if (!stricmp(value, "ON")) {
+ if (ttb) {
+ ci->ttb[TTB_REVERSES] =
+ strtol(ttb, (char **) NULL, 10);
+ if (errno == ERANGE || errno == EINVAL
+ || ci->ttb[TTB_REVERSES] < 0) {
+ if (debug) {
+ alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REVERSES]);
+ }
+ ci->ttb[TTB_REVERSES] = 0;
+ notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
+ return MOD_CONT;
+ }
+ } else
+ ci->ttb[TTB_REVERSES] = 0;
+ ci->botflags |= BS_KICK_REVERSES;
+ if (ci->ttb[TTB_REVERSES])
+ notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON_BAN,
+ ci->ttb[TTB_REVERSES]);
+ else
+ notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON);
+ } else {
+ ci->botflags &= ~BS_KICK_REVERSES;
+ notice_lang(s_BotServ, u, BOT_KICK_REVERSES_OFF);
+ }
+ } else if (!stricmp(option, "UNDERLINES")) {
+ if (!stricmp(value, "ON")) {
+ if (ttb) {
+ ci->ttb[TTB_UNDERLINES] =
+ strtol(ttb, (char **) NULL, 10);
+ if (errno == ERANGE || errno == EINVAL
+ || ci->ttb[TTB_UNDERLINES] < 0) {
+ if (debug) {
+ alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_UNDERLINES]);
+ }
+ ci->ttb[TTB_UNDERLINES] = 0;
+ notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
+ return MOD_CONT;
+ }
+ } else
+ ci->ttb[TTB_UNDERLINES] = 0;
+ ci->botflags |= BS_KICK_UNDERLINES;
+ if (ci->ttb[TTB_UNDERLINES])
+ notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN,
+ ci->ttb[TTB_UNDERLINES]);
+ else
+ notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON);
+ } else {
+ ci->botflags &= ~BS_KICK_UNDERLINES;
+ notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_OFF);
+ }
+ } else
+ notice_help(s_BotServ, u, BOT_KICK_UNKNOWN, option);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/bs_say.c b/src/core/bs_say.c
new file mode 100644
index 000000000..0330a812d
--- /dev/null
+++ b/src/core/bs_say.c
@@ -0,0 +1,97 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_say(User * u);
+void myBotServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("SAY", do_say, NULL, BOT_HELP_SAY, -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_SAY);
+}
+
+/**
+ * The /bs say command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_say(User * u)
+{
+ ChannelInfo *ci;
+
+ char *chan = strtok(NULL, " ");
+ char *text = strtok(NULL, "");
+
+ if (!chan || !text)
+ syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX);
+ else if (!(ci = cs_findchan(chan)))
+ notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
+ else if (ci->flags & CI_VERBOTEN)
+ notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
+ else if (!ci->bi)
+ notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
+ else if (!ci->c || ci->c->usercount < BSMinUsers)
+ notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name);
+ else if (!check_access(u, ci, CA_SAY))
+ notice_lang(s_BotServ, u, ACCESS_DENIED);
+ else {
+ if (text[0] != '\001') {
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", text);
+ ci->bi->lastmsg = time(NULL);
+ if (logchan && LogBot)
+ anope_cmd_privmsg(ci->bi->nick, LogChannel,
+ "SAY %s %s %s", u->nick, ci->name, text);
+ } else {
+ syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX);
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/bs_set.c b/src/core/bs_set.c
new file mode 100644
index 000000000..5312b0f6c
--- /dev/null
+++ b/src/core/bs_set.c
@@ -0,0 +1,207 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_set(User * u);
+void myBotServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SET", do_set, NULL, BOT_HELP_SET, -1, -1,
+ BOT_SERVADMIN_HELP_SET, BOT_SERVADMIN_HELP_SET);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("SET DONTKICKOPS", NULL, NULL,
+ BOT_HELP_SET_DONTKICKOPS, -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("SET DONTKICKVOICES", NULL, NULL,
+ BOT_HELP_SET_DONTKICKVOICES, -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("SET FANTASY", NULL, NULL, BOT_HELP_SET_FANTASY, -1,
+ -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("SET GREET", NULL, NULL, BOT_HELP_SET_GREET, -1, -1,
+ -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("SET SYMBIOSIS", NULL, NULL, BOT_HELP_SET_SYMBIOSIS,
+ -1, -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("SET NOBOT", NULL, NULL, -1, -1, -1,
+ BOT_SERVADMIN_HELP_SET_NOBOT,
+ BOT_SERVADMIN_HELP_SET_NOBOT);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+ c = createCommand("SET PRIVATE", NULL, NULL, -1, -1, -1,
+ BOT_SERVADMIN_HELP_SET_PRIVATE,
+ BOT_SERVADMIN_HELP_SET_PRIVATE);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_SET);
+}
+
+/**
+ * The /bs set command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_set(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *option = strtok(NULL, " ");
+ char *value = strtok(NULL, " ");
+ int is_servadmin = is_services_admin(u);
+
+ ChannelInfo *ci;
+
+ if (readonly)
+ notice_lang(s_BotServ, u, BOT_SET_DISABLED);
+ else if (!chan || !option || !value)
+ syntax_error(s_BotServ, u, "SET", BOT_SET_SYNTAX);
+ else if (is_servadmin && !stricmp(option, "PRIVATE")) {
+ BotInfo *bi;
+
+ if ((bi = findbot(chan))) {
+ if (!stricmp(value, "ON")) {
+ bi->flags |= BI_PRIVATE;
+ notice_lang(s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick);
+ } else if (!stricmp(value, "OFF")) {
+ bi->flags &= ~BI_PRIVATE;
+ notice_lang(s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick);
+ } else {
+ syntax_error(s_BotServ, u, "SET PRIVATE",
+ BOT_SET_PRIVATE_SYNTAX);
+ }
+ } else {
+ notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, chan);
+ }
+ return MOD_CONT;
+ } else if (!(ci = cs_findchan(chan)))
+ notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
+ else if (ci->flags & CI_VERBOTEN)
+ notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
+ else if (!is_servadmin && !check_access(u, ci, CA_SET))
+ notice_lang(s_BotServ, u, ACCESS_DENIED);
+ else {
+ if (!stricmp(option, "DONTKICKOPS")) {
+ if (!stricmp(value, "ON")) {
+ ci->botflags |= BS_DONTKICKOPS;
+ notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_ON,
+ ci->name);
+ } else if (!stricmp(value, "OFF")) {
+ ci->botflags &= ~BS_DONTKICKOPS;
+ notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_OFF,
+ ci->name);
+ } else {
+ syntax_error(s_BotServ, u, "SET DONTKICKOPS",
+ BOT_SET_DONTKICKOPS_SYNTAX);
+ }
+ } else if (!stricmp(option, "DONTKICKVOICES")) {
+ if (!stricmp(value, "ON")) {
+ ci->botflags |= BS_DONTKICKVOICES;
+ notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_ON,
+ ci->name);
+ } else if (!stricmp(value, "OFF")) {
+ ci->botflags &= ~BS_DONTKICKVOICES;
+ notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF,
+ ci->name);
+ } else {
+ syntax_error(s_BotServ, u, "SET DONTKICKVOICES",
+ BOT_SET_DONTKICKVOICES_SYNTAX);
+ }
+ } else if (!stricmp(option, "FANTASY")) {
+ if (!stricmp(value, "ON")) {
+ ci->botflags |= BS_FANTASY;
+ notice_lang(s_BotServ, u, BOT_SET_FANTASY_ON, ci->name);
+ } else if (!stricmp(value, "OFF")) {
+ ci->botflags &= ~BS_FANTASY;
+ notice_lang(s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name);
+ } else {
+ syntax_error(s_BotServ, u, "SET FANTASY",
+ BOT_SET_FANTASY_SYNTAX);
+ }
+ } else if (!stricmp(option, "GREET")) {
+ if (!stricmp(value, "ON")) {
+ ci->botflags |= BS_GREET;
+ notice_lang(s_BotServ, u, BOT_SET_GREET_ON, ci->name);
+ } else if (!stricmp(value, "OFF")) {
+ ci->botflags &= ~BS_GREET;
+ notice_lang(s_BotServ, u, BOT_SET_GREET_OFF, ci->name);
+ } else {
+ syntax_error(s_BotServ, u, "SET GREET",
+ BOT_SET_GREET_SYNTAX);
+ }
+ } else if (is_servadmin && !stricmp(option, "NOBOT")) {
+ if (!stricmp(value, "ON")) {
+ ci->botflags |= BS_NOBOT;
+ if (ci->bi)
+ unassign(u, ci);
+ notice_lang(s_BotServ, u, BOT_SET_NOBOT_ON, ci->name);
+ } else if (!stricmp(value, "OFF")) {
+ ci->botflags &= ~BS_NOBOT;
+ notice_lang(s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name);
+ } else {
+ syntax_error(s_BotServ, u, "SET NOBOT",
+ BOT_SET_NOBOT_SYNTAX);
+ }
+ } else if (!stricmp(option, "SYMBIOSIS")) {
+ if (!stricmp(value, "ON")) {
+ ci->botflags |= BS_SYMBIOSIS;
+ notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name);
+ } else if (!stricmp(value, "OFF")) {
+ ci->botflags &= ~BS_SYMBIOSIS;
+ notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name);
+ } else {
+ syntax_error(s_BotServ, u, "SET SYMBIOSIS",
+ BOT_SET_SYMBIOSIS_SYNTAX);
+ }
+ } else {
+ notice_help(s_BotServ, u, BOT_SET_UNKNOWN, option);
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/bs_unassign.c b/src/core/bs_unassign.c
new file mode 100644
index 000000000..1789189ba
--- /dev/null
+++ b/src/core/bs_unassign.c
@@ -0,0 +1,88 @@
+/* BotServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_unassign(User * u);
+void myBotServHelp(User * u);
+
+/**
+ * Create the unassign command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("UNASSIGN", do_unassign, NULL, BOT_HELP_UNASSIGN, -1,
+ -1, -1, -1);
+ moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
+
+ moduleSetBotHelp(myBotServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to Anopes /bs help output.
+ * @param u The user who is requesting help
+ **/
+void myBotServHelp(User * u)
+{
+ notice_lang(s_BotServ, u, BOT_HELP_CMD_UNASSIGN);
+}
+
+/**
+ * The /bs unassign command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_unassign(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ ChannelInfo *ci;
+
+ if (readonly)
+ notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY);
+ else if (!chan)
+ syntax_error(s_BotServ, u, "UNASSIGN", BOT_UNASSIGN_SYNTAX);
+ else if (!(ci = cs_findchan(chan)))
+ notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
+ else if (ci->flags & CI_VERBOTEN)
+ notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
+ else if (!is_services_admin(u) && !check_access(u, ci, CA_ASSIGN))
+ notice_lang(s_BotServ, u, ACCESS_DENIED);
+ else {
+ if (ci->bi)
+ unassign(u, ci);
+ notice_lang(s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/configure b/src/core/configure
new file mode 100755
index 000000000..119c7c887
--- /dev/null
+++ b/src/core/configure
@@ -0,0 +1,35 @@
+#!/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
+
+echo -n "SUBS=" >> ./Makefile.inc
+FIRST=1
+for dir in *
+do
+ if [ -d $dir ] ; then
+ if [ -f $dir/Makefile ] ; then
+ if [ "$FIRST" = 1 ] ; then
+ echo -n " "$dir >> ./Makefile.inc
+ else
+ echo "\\" >> ./Makefile.inc
+ echo -n " " $dir >> ./Makefile.inc
+ fi
+ FIRST=0
+ fi
+ fi
+done
+
+exit 0
+
diff --git a/src/core/cs_access.c b/src/core/cs_access.c
new file mode 100644
index 000000000..e5d621972
--- /dev/null
+++ b/src/core/cs_access.c
@@ -0,0 +1,507 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+
+int do_access(User * u);
+int do_levels(User * u);
+
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("ACCESS", do_access, NULL, CHAN_HELP_ACCESS, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("ACCESS LEVELS", NULL, NULL, CHAN_HELP_ACCESS_LEVELS,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("LEVELS", do_levels, NULL, CHAN_HELP_LEVELS, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_ACCESS);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LEVELS);
+}
+
+
+static int access_del(User * u, ChanAccess * access, int *perm, int uacc)
+{
+ if (!access->in_use)
+ return 0;
+ if (!is_services_admin(u) && uacc <= access->level) {
+ (*perm)++;
+ return 0;
+ }
+ access->nc = NULL;
+ access->in_use = 0;
+ return 1;
+}
+
+static int access_del_callback(User * u, int num, va_list args)
+{
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *last = va_arg(args, int *);
+ int *perm = va_arg(args, int *);
+ int uacc = va_arg(args, int);
+ if (num < 1 || num > ci->accesscount)
+ return 0;
+ *last = num;
+ return access_del(u, &ci->access[num - 1], perm, uacc);
+}
+
+
+static int access_list(User * u, int index, ChannelInfo * ci,
+ int *sent_header)
+{
+ ChanAccess *access = &ci->access[index];
+ char *xop;
+
+ if (!access->in_use)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_HEADER, ci->name);
+ *sent_header = 1;
+ }
+
+ if (ci->flags & CI_XOP) {
+ xop = get_xop_level(access->level);
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_XOP_FORMAT, index + 1,
+ xop, access->nc->display);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_AXS_FORMAT, index + 1,
+ access->level, access->nc->display);
+ }
+ return 1;
+}
+
+static int access_list_callback(User * u, int num, va_list args)
+{
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *sent_header = va_arg(args, int *);
+ if (num < 1 || num > ci->accesscount)
+ return 0;
+ return access_list(u, num - 1, ci, sent_header);
+}
+
+
+/**
+ * The /cs access command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_access(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *cmd = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+ char *s = strtok(NULL, " ");
+
+ ChannelInfo *ci;
+ NickAlias *na;
+ NickCore *nc;
+ ChanAccess *access;
+
+ int i;
+ int level = 0, ulev;
+ int is_list = (cmd && stricmp(cmd, "LIST") == 0);
+ int is_servadmin = is_services_admin(u);
+
+ /* If LIST, we don't *require* any parameters, but we can take any.
+ * If DEL, we require a nick and no level.
+ * Else (ADD), we require a level (which implies a nick). */
+ if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 :
+ (stricmp(cmd, "DEL") == 0) ? (!nick || s) : !s)) {
+ syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ /* We still allow LIST in xOP mode, but not others */
+ } else if ((ci->flags & CI_XOP) && !is_list) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP, s_ChanServ);
+ } else if (((is_list && !check_access(u, ci, CA_ACCESS_LIST))
+ || (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE)))
+ && !is_servadmin) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (stricmp(cmd, "ADD") == 0) {
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED);
+ return MOD_CONT;
+ }
+
+ level = atoi(s);
+ ulev = get_access(u, ci);
+
+ if (!is_servadmin && level >= ulev) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (level == 0) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_NONZERO);
+ return MOD_CONT;
+ } else if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_RANGE,
+ ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
+ return MOD_CONT;
+ }
+
+ na = findnick(nick);
+ if (!na) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_NICKS_ONLY);
+ return MOD_CONT;
+ }
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, nick);
+ return MOD_CONT;
+ }
+
+ nc = na->nc;
+ for (access = ci->access, i = 0; i < ci->accesscount;
+ access++, i++) {
+ if (access->nc == nc) {
+ /* Don't allow lowering from a level >= ulev */
+ if (!is_servadmin && access->level >= ulev) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+ if (access->level == level) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_UNCHANGED,
+ access->nc->display, chan, level);
+ return MOD_CONT;
+ }
+ access->level = level;
+ alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, access->level, na->nick, nc->display, ci->name);
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_CHANGED,
+ access->nc->display, chan, level);
+ return MOD_CONT;
+ }
+ }
+
+ for (i = 0; i < ci->accesscount; i++) {
+ if (!ci->access[i].in_use)
+ break;
+ }
+ if (i == ci->accesscount) {
+ if (i < CSAccessMax) {
+ ci->accesscount++;
+ ci->access =
+ srealloc(ci->access,
+ sizeof(ChanAccess) * ci->accesscount);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_REACHED_LIMIT,
+ CSAccessMax);
+ return MOD_CONT;
+ }
+ }
+
+ access = &ci->access[i];
+ access->nc = nc;
+ access->in_use = 1;
+ access->level = level;
+ access->last_seen = 0;
+
+ alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, access->level, na->nick, nc->display, ci->name);
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display,
+ ci->name, access->level);
+ } else if (stricmp(cmd, "DEL") == 0) {
+ int deleted, a, b;
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (ci->accesscount == 0) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
+ return MOD_CONT;
+ }
+
+ /* Special case: is it a number/list? Only do search if it isn't. */
+ if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) {
+ int count, last = -1, perm = 0;
+ deleted = process_numlist(nick, &count, access_del_callback, u,
+ ci, &last, &perm, get_access(u, ci));
+ if (!deleted) {
+ if (perm) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else if (count == 1) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_SUCH_ENTRY,
+ last, ci->name);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_MATCH,
+ ci->name);
+ }
+ } else if (deleted == 1) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED_ONE,
+ ci->name);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED_SEVERAL,
+ deleted, ci->name);
+ }
+ } else {
+ na = findnick(nick);
+ if (!na) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, nick);
+ return MOD_CONT;
+ }
+ nc = na->nc;
+ for (i = 0; i < ci->accesscount; i++) {
+ if (ci->access[i].nc == nc)
+ break;
+ }
+ if (i == ci->accesscount) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_NOT_FOUND, nick,
+ chan);
+ return MOD_CONT;
+ }
+ access = &ci->access[i];
+ if (!is_servadmin && get_access(u, ci) <= access->level) {
+ deleted = 0;
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED,
+ access->nc->display, ci->name);
+ alog("%s: %s!%s@%s (level %d) deleted access of %s (group %s) on %s", s_ChanServ, u->nick, u->username, u->host, get_access(u, ci), na->nick, access->nc->display, chan);
+ access->nc = NULL;
+ access->in_use = 0;
+ deleted = 1;
+ }
+ }
+
+ if (deleted) {
+ /* Reordering - DrStein */
+ for (b = 0; b < ci->accesscount; b++) {
+ if (ci->access[b].in_use) {
+ for (a = 0; a < ci->accesscount; a++) {
+ if (a > b)
+ break;
+ if (!ci->access[a].in_use) {
+ ci->access[a].in_use = 1;
+ ci->access[a].level = ci->access[b].level;
+ ci->access[a].nc = ci->access[b].nc;
+ ci->access[a].last_seen =
+ ci->access[b].last_seen;
+ ci->access[b].nc = NULL;
+ ci->access[b].in_use = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ } else if (stricmp(cmd, "LIST") == 0) {
+ int sent_header = 0;
+
+ if (ci->accesscount == 0) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
+ return MOD_CONT;
+ }
+ if (nick && strspn(nick, "1234567890,-") == strlen(nick)) {
+ process_numlist(nick, NULL, access_list_callback, u, ci,
+ &sent_header);
+ } else {
+ for (i = 0; i < ci->accesscount; i++) {
+ if (nick && ci->access[i].nc
+ && !match_wild_nocase(nick, ci->access[i].nc->display))
+ continue;
+ access_list(u, i, ci, &sent_header);
+ }
+ }
+ if (!sent_header) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_MATCH, chan);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_FOOTER, ci->name);
+ }
+ } else if (stricmp(cmd, "CLEAR") == 0) {
+
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (!is_servadmin && !is_founder(u, ci)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ free(ci->access);
+ ci->access = NULL;
+ ci->accesscount = 0;
+
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_CLEAR, ci->name);
+ alog("%s: %s!%s@%s (level %d) cleared access list on %s",
+ s_ChanServ, u->nick, u->username, u->host,
+ get_access(u, ci), chan);
+
+ } else {
+ syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+
+int do_levels(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *cmd = strtok(NULL, " ");
+ char *what = strtok(NULL, " ");
+ char *s = strtok(NULL, " ");
+ char *error;
+
+ ChannelInfo *ci;
+ int level;
+ int i;
+
+ /* If SET, we want two extra parameters; if DIS[ABLE] or FOUNDER, we want only
+ * one; else, we want none.
+ */
+ if (!cmd
+ || ((stricmp(cmd, "SET") == 0) ? !s
+ : ((strnicmp(cmd, "DIS", 3) == 0)) ? (!what || s) : !!what)) {
+ syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (ci->flags & CI_XOP) {
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_XOP);
+ } else if (!is_founder(u, ci) && !is_services_admin(u)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (stricmp(cmd, "SET") == 0) {
+ level = strtol(s, &error, 10);
+
+ if (*error != '\0') {
+ syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) {
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_RANGE,
+ ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
+ return MOD_CONT;
+ }
+
+ for (i = 0; levelinfo[i].what >= 0; i++) {
+ if (stricmp(levelinfo[i].name, what) == 0) {
+ ci->levels[levelinfo[i].what] = level;
+
+ alog("%s: %s!%s@%s set level %s on channel %s to %d",
+ s_ChanServ, u->nick, u->username, u->host,
+ levelinfo[i].name, ci->name, level);
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_CHANGED,
+ levelinfo[i].name, chan, level);
+ return MOD_CONT;
+ }
+ }
+
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ);
+
+ } else if (stricmp(cmd, "DIS") == 0 || stricmp(cmd, "DISABLE") == 0) {
+ for (i = 0; levelinfo[i].what >= 0; i++) {
+ if (stricmp(levelinfo[i].name, what) == 0) {
+ ci->levels[levelinfo[i].what] = ACCESS_INVALID;
+
+ alog("%s: %s!%s@%s disabled level %s on channel %s",
+ s_ChanServ, u->nick, u->username, u->host,
+ levelinfo[i].name, ci->name);
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_DISABLED,
+ levelinfo[i].name, chan);
+ return MOD_CONT;
+ }
+ }
+
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ);
+ } else if (stricmp(cmd, "LIST") == 0) {
+ int i;
+
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_HEADER, chan);
+
+ if (!levelinfo_maxwidth) {
+ for (i = 0; levelinfo[i].what >= 0; i++) {
+ int len = strlen(levelinfo[i].name);
+ if (len > levelinfo_maxwidth)
+ levelinfo_maxwidth = len;
+ }
+ }
+
+ for (i = 0; levelinfo[i].what >= 0; i++) {
+ int j = ci->levels[levelinfo[i].what];
+
+ if (j == ACCESS_INVALID) {
+ j = levelinfo[i].what;
+
+ if (j == CA_AUTOOP || j == CA_AUTODEOP || j == CA_AUTOVOICE
+ || j == CA_NOJOIN) {
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED,
+ levelinfo_maxwidth, levelinfo[i].name);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED,
+ levelinfo_maxwidth, levelinfo[i].name);
+ }
+ } else if (j == ACCESS_FOUNDER) {
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_FOUNDER,
+ levelinfo_maxwidth, levelinfo[i].name);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_NORMAL,
+ levelinfo_maxwidth, levelinfo[i].name, j);
+ }
+ }
+
+ } else if (stricmp(cmd, "RESET") == 0) {
+ reset_levels(ci);
+
+ alog("%s: %s!%s@%s reset levels definitions on channel %s",
+ s_ChanServ, u->nick, u->username, u->host, ci->name);
+ notice_lang(s_ChanServ, u, CHAN_LEVELS_RESET, chan);
+ } else {
+ syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c
new file mode 100644
index 000000000..dd729da98
--- /dev/null
+++ b/src/core/cs_akick.c
@@ -0,0 +1,584 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+
+int do_akick(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("AKICK", do_akick, NULL, CHAN_HELP_AKICK, -1, -1, -1,
+ -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_AKICK);
+}
+
+/**
+ * The /cs akick command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+ /* `last' is set to the last index this routine was called with */
+int akick_del(User * u, AutoKick * akick)
+{
+ if (!(akick->flags & AK_USED))
+ return 0;
+ if (akick->flags & AK_ISNICK) {
+ akick->u.nc = NULL;
+ } else {
+ free(akick->u.mask);
+ akick->u.mask = NULL;
+ }
+ if (akick->reason) {
+ free(akick->reason);
+ akick->reason = NULL;
+ }
+ if (akick->creator) {
+ free(akick->creator);
+ akick->creator = NULL;
+ }
+ akick->addtime = 0;
+ akick->flags = 0;
+ return 1;
+}
+
+int akick_del_callback(User * u, int num, va_list args)
+{
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *last = va_arg(args, int *);
+ if (num < 1 || num > ci->akickcount)
+ return 0;
+ *last = num;
+ return akick_del(u, &ci->akick[num - 1]);
+}
+
+
+int akick_list(User * u, int index, ChannelInfo * ci, int *sent_header)
+{
+ AutoKick *akick = &ci->akick[index];
+
+ if (!(akick->flags & AK_USED))
+ return 0;
+ if (!*sent_header) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name);
+ *sent_header = 1;
+ }
+
+ notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1,
+ ((akick->flags & AK_ISNICK) ? akick->u.nc->
+ display : akick->u.mask),
+ (akick->reason ? akick->
+ reason : getstring(u->na, NO_REASON)));
+ return 1;
+}
+
+int akick_list_callback(User * u, int num, va_list args)
+{
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *sent_header = va_arg(args, int *);
+ if (num < 1 || num > ci->akickcount)
+ return 0;
+ return akick_list(u, num - 1, ci, sent_header);
+}
+
+int akick_view(User * u, int index, ChannelInfo * ci, int *sent_header)
+{
+ AutoKick *akick = &ci->akick[index];
+ char timebuf[64];
+ struct tm tm;
+
+ if (!(akick->flags & AK_USED))
+ return 0;
+ if (!*sent_header) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name);
+ *sent_header = 1;
+ }
+
+ if (akick->addtime) {
+ tm = *localtime(&akick->addtime);
+ strftime_lang(timebuf, sizeof(timebuf), u,
+ STRFTIME_SHORT_DATE_FORMAT, &tm);
+ } else {
+ snprintf(timebuf, sizeof(timebuf), getstring(u->na, UNKNOWN));
+ }
+
+ notice_lang(s_ChanServ, u,
+ ((akick->
+ flags & AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK :
+ CHAN_AKICK_VIEW_FORMAT), index + 1,
+ ((akick->flags & AK_ISNICK) ? akick->u.nc->
+ display : akick->u.mask),
+ akick->creator ? akick->creator : getstring(u->na,
+ UNKNOWN),
+ timebuf,
+ (akick->reason ? akick->
+ reason : getstring(u->na, NO_REASON)));
+ return 1;
+}
+
+int akick_view_callback(User * u, int num, va_list args)
+{
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *sent_header = va_arg(args, int *);
+ if (num < 1 || num > ci->akickcount)
+ return 0;
+ return akick_view(u, num - 1, ci, sent_header);
+}
+
+
+
+int do_akick(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *cmd = strtok(NULL, " ");
+ char *mask = strtok(NULL, " ");
+ char *reason = strtok(NULL, "");
+ ChannelInfo *ci;
+ AutoKick *akick;
+ int i;
+ Channel *c;
+ struct c_userlist *cu = NULL;
+ struct c_userlist *next;
+ char *argv[3];
+ int count = 0;
+
+ if (!cmd || (!mask && (!stricmp(cmd, "ADD") || !stricmp(cmd, "STICK")
+ || !stricmp(cmd, "UNSTICK")
+ || !stricmp(cmd, "DEL")))) {
+
+ syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!check_access(u, ci, CA_AKICK) && !is_services_admin(u)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (stricmp(cmd, "ADD") == 0) {
+
+ NickAlias *na = findnick(mask);
+ NickCore *nc = NULL;
+ char *nick, *user, *host;
+
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (!na) {
+ split_usermask(mask, &nick, &user, &host);
+ mask =
+ scalloc(strlen(nick) + strlen(user) + strlen(host) + 3, 1);
+ sprintf(mask, "%s!%s@%s", nick, user, host);
+ free(nick);
+ free(user);
+ free(host);
+ } else {
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, mask);
+ return MOD_CONT;
+ }
+ nc = na->nc;
+ }
+
+ /* Check excepts BEFORE we get this far */
+ if (ircd->except) {
+ if (is_excepted_mask(ci, mask) == 1) {
+ notice_lang(s_ChanServ, u, CHAN_EXCEPTED, mask, chan);
+ return MOD_CONT;
+ }
+ }
+
+ for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) {
+ if (!(akick->flags & AK_USED))
+ continue;
+ if ((akick->flags & AK_ISNICK) ? akick->u.nc == nc
+ : stricmp(akick->u.mask, mask) == 0) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS,
+ (akick->flags & AK_ISNICK) ? akick->u.nc->
+ display : akick->u.mask, chan);
+ return MOD_CONT;
+ }
+ }
+
+ for (i = 0; i < ci->akickcount; i++) {
+ if (!(ci->akick[i].flags & AK_USED))
+ break;
+ }
+ if (i == ci->akickcount) {
+ if (ci->akickcount >= CSAutokickMax) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT,
+ CSAutokickMax);
+ return MOD_CONT;
+ }
+ ci->akickcount++;
+ ci->akick =
+ srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount);
+ }
+ akick = &ci->akick[i];
+ akick->flags = AK_USED;
+ if (nc) {
+ akick->flags |= AK_ISNICK;
+ akick->u.nc = nc;
+ } else {
+ akick->u.mask = mask;
+ }
+ akick->creator = sstrdup(u->nick);
+ akick->addtime = time(NULL);
+ if (reason) {
+ if (strlen(reason) > 200)
+ reason[200] = '\0';
+ akick->reason = sstrdup(reason);
+ } else {
+ akick->reason = NULL;
+ }
+
+ /* Auto ENFORCE #63 */
+ c = findchan(ci->name);
+ if (c) {
+ cu = c->users;
+ while (cu) {
+ next = cu->next;
+ if (check_kick(cu->user, c->name)) {
+ argv[0] = sstrdup(c->name);
+ argv[1] = sstrdup(cu->user->nick);
+ if (akick->reason)
+ argv[2] = sstrdup(akick->reason);
+ else
+ argv[2] = sstrdup("none");
+
+ do_kick(s_ChanServ, 3, argv);
+
+ free(argv[2]);
+ free(argv[1]);
+ free(argv[0]);
+ count++;
+
+ }
+ cu = next;
+ }
+ }
+ notice_lang(s_ChanServ, u, CHAN_AKICK_ADDED, mask, chan);
+
+ if (count)
+ notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan,
+ count);
+
+ } else if (stricmp(cmd, "STICK") == 0) {
+ NickAlias *na;
+ NickCore *nc;
+
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (ci->akickcount == 0) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name);
+ return MOD_CONT;
+ }
+
+ na = findnick(mask);
+ nc = (na ? na->nc : NULL);
+
+ for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) {
+ if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK))
+ continue;
+ if (!stricmp(akick->u.mask, mask))
+ break;
+ }
+
+ if (i == ci->akickcount) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask,
+ ci->name);
+ return MOD_CONT;
+ }
+
+ akick->flags |= AK_STUCK;
+ notice_lang(s_ChanServ, u, CHAN_AKICK_STUCK, akick->u.mask,
+ ci->name);
+
+ if (ci->c)
+ stick_mask(ci, akick);
+ } else if (stricmp(cmd, "UNSTICK") == 0) {
+ NickAlias *na;
+ NickCore *nc;
+
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (ci->akickcount == 0) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name);
+ return MOD_CONT;
+ }
+
+ na = findnick(mask);
+ nc = (na ? na->nc : NULL);
+
+ for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) {
+ if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK))
+ continue;
+ if (!stricmp(akick->u.mask, mask))
+ break;
+ }
+
+ if (i == ci->akickcount) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask,
+ ci->name);
+ return MOD_CONT;
+ }
+
+ akick->flags &= ~AK_STUCK;
+ notice_lang(s_ChanServ, u, CHAN_AKICK_UNSTUCK, akick->u.mask,
+ ci->name);
+
+ } else if (stricmp(cmd, "DEL") == 0) {
+ int deleted, a, b;
+
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (ci->akickcount == 0) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan);
+ return MOD_CONT;
+ }
+
+ /* Special case: is it a number/list? Only do search if it isn't. */
+ if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
+ int count, last = -1;
+ deleted = process_numlist(mask, &count, akick_del_callback, u,
+ ci, &last);
+ if (!deleted) {
+ if (count == 1) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_NO_SUCH_ENTRY,
+ last, ci->name);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH,
+ ci->name);
+ }
+ } else if (deleted == 1) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_ONE,
+ ci->name);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_SEVERAL,
+ deleted, ci->name);
+ }
+ } else {
+ NickAlias *na = findnick(mask);
+ NickCore *nc = (na ? na->nc : NULL);
+
+ for (akick = ci->akick, i = 0; i < ci->akickcount;
+ akick++, i++) {
+ if (!(akick->flags & AK_USED))
+ continue;
+ if (((akick->flags & AK_ISNICK) && akick->u.nc == nc)
+ || (!(akick->flags & AK_ISNICK)
+ && stricmp(akick->u.mask, mask) == 0))
+ break;
+ }
+ if (i == ci->akickcount) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask,
+ chan);
+ return MOD_CONT;
+ }
+ notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED, mask, chan);
+ akick_del(u, akick);
+ deleted = 1;
+ }
+ if (deleted) {
+ /* Reordering - DrStein */
+ for (b = 0; b < ci->akickcount; b++) {
+ if (ci->akick[b].flags & AK_USED) {
+ for (a = 1; a < ci->akickcount; a++) {
+ if (a > b)
+ break;
+ if (!(ci->akick[a].flags & AK_USED)) {
+ ci->akick[a].flags = ci->akick[b].flags;
+ if (ci->akick[b].flags & AK_ISNICK) {
+ ci->akick[a].u.nc = ci->akick[b].u.nc;
+ } else {
+ ci->akick[a].u.mask =
+ sstrdup(ci->akick[b].u.mask);
+ }
+ ci->akick[a].reason =
+ sstrdup(ci->akick[b].reason);
+ ci->akick[a].creator =
+ sstrdup(ci->akick[b].creator);
+ ci->akick[a].addtime = ci->akick[b].addtime;
+
+ akick_del(u, &ci->akick[b]);
+ break;
+ }
+ }
+ }
+ }
+ }
+ } else if (stricmp(cmd, "LIST") == 0) {
+ int sent_header = 0;
+
+ if (ci->akickcount == 0) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan);
+ return MOD_CONT;
+ }
+ if (mask && isdigit(*mask) &&
+ strspn(mask, "1234567890,-") == strlen(mask)) {
+ process_numlist(mask, NULL, akick_list_callback, u, ci,
+ &sent_header);
+ } else {
+ for (akick = ci->akick, i = 0; i < ci->akickcount;
+ akick++, i++) {
+ if (!(akick->flags & AK_USED))
+ continue;
+ if (mask) {
+ if (!(akick->flags & AK_ISNICK)
+ && !match_wild_nocase(mask, akick->u.mask))
+ continue;
+ if ((akick->flags & AK_ISNICK)
+ && !match_wild_nocase(mask, akick->u.nc->display))
+ continue;
+ }
+ akick_list(u, i, ci, &sent_header);
+ }
+ }
+ if (!sent_header)
+ notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan);
+
+ } else if (stricmp(cmd, "VIEW") == 0) {
+ int sent_header = 0;
+
+ if (ci->akickcount == 0) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan);
+ return MOD_CONT;
+ }
+ if (mask && isdigit(*mask) &&
+ strspn(mask, "1234567890,-") == strlen(mask)) {
+ process_numlist(mask, NULL, akick_view_callback, u, ci,
+ &sent_header);
+ } else {
+ for (akick = ci->akick, i = 0; i < ci->akickcount;
+ akick++, i++) {
+ if (!(akick->flags & AK_USED))
+ continue;
+ if (mask) {
+ if (!(akick->flags & AK_ISNICK)
+ && !match_wild_nocase(mask, akick->u.mask))
+ continue;
+ if ((akick->flags & AK_ISNICK)
+ && !match_wild_nocase(mask, akick->u.nc->display))
+ continue;
+ }
+ akick_view(u, i, ci, &sent_header);
+ }
+ }
+ if (!sent_header)
+ notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan);
+
+ } else if (stricmp(cmd, "ENFORCE") == 0) {
+ Channel *c = findchan(ci->name);
+ struct c_userlist *cu = NULL;
+ struct c_userlist *next;
+ char *argv[3];
+ int count = 0;
+
+ if (!c) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, ci->name);
+ return MOD_CONT;
+ }
+
+ cu = c->users;
+
+ while (cu) {
+ next = cu->next;
+ if (check_kick(cu->user, c->name)) {
+ argv[0] = sstrdup(c->name);
+ argv[1] = sstrdup(cu->user->nick);
+ argv[2] = sstrdup(CSAutokickReason);
+
+ do_kick(s_ChanServ, 3, argv);
+
+ free(argv[2]);
+ free(argv[1]);
+ free(argv[0]);
+
+ count++;
+ }
+ cu = next;
+ }
+
+ notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan, count);
+
+ } else if (stricmp(cmd, "CLEAR") == 0) {
+
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
+ return MOD_CONT;
+ }
+
+ for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) {
+ if (!(akick->flags & AK_USED))
+ continue;
+ akick_del(u, akick);
+ }
+
+ free(ci->akick);
+ ci->akick = NULL;
+ ci->akickcount = 0;
+
+ notice_lang(s_ChanServ, u, CHAN_AKICK_CLEAR, ci->name);
+
+ } else {
+ syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c
new file mode 100644
index 000000000..eaf25597d
--- /dev/null
+++ b/src/core/cs_ban.c
@@ -0,0 +1,227 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_unban(User * u);
+int do_ban(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("BAN", do_ban, NULL, CHAN_HELP_BAN, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("UNBAN", do_unban, NULL, CHAN_HELP_UNBAN, -1, -1, -1,
+ -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_BAN);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_UNBAN);
+}
+
+/**
+ * The /cs ban command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_ban(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *params = strtok(NULL, " ");
+ char *reason = strtok(NULL, "");
+
+ Channel *c;
+ ChannelInfo *ci;
+ User *u2;
+
+ int is_same;
+
+ if (!reason) {
+ reason = "Requested";
+ } else {
+ if (strlen(reason) > 200)
+ reason[200] = '\0';
+ }
+
+ if (!chan) {
+ struct u_chanlist *uc, *next;
+
+ /* Bans the user on every channels he is on. */
+
+ for (uc = u->chans; uc; uc = next) {
+ next = uc->next;
+ if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
+ && check_access(u, ci, CA_BANME)) {
+ char *av[3];
+ char mask[BUFSIZE];
+
+ /*
+ * Dont ban/kick the user on channels where he is excepted
+ * to prevent services <-> server wars.
+ */
+ if (ircd->except) {
+ if (is_excepted(ci, u))
+ notice_lang(s_ChanServ, u, CHAN_EXCEPTED,
+ u->nick, ci->name);
+ continue;
+ }
+ if (is_protected(u)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ continue;
+ }
+
+ av[0] = sstrdup("+b");
+ get_idealban(ci, u, mask, sizeof(mask));
+ av[1] = mask;
+ anope_cmd_mode(whosends(ci), uc->chan->name, "+b %s",
+ av[1]);
+ chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
+ free(av[0]);
+
+ if ((ci->flags & CI_SIGNKICK)
+ || ((ci->flags & CI_SIGNKICK_LEVEL)
+ && !check_access(u, ci, CA_SIGNKICK)))
+ anope_cmd_kick(whosends(ci), ci->name, u->nick,
+ "%s (%s)", reason, u->nick);
+ else
+ anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s",
+ reason);
+ av[0] = ci->name;
+ av[1] = u->nick;
+ av[2] = reason;
+ do_kick(s_ChanServ, 3, av);
+ }
+ }
+
+ return MOD_CONT;
+ } else if (!params) {
+ params = u->nick;
+ }
+
+ is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0);
+
+ if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params);
+ } else if (!is_same ? !check_access(u, ci, CA_BAN) :
+ !check_access(u, ci, CA_BANME)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (!is_same && (ci->flags & CI_PEACE)
+ && (get_access(u2, ci) >= get_access(u, ci))) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ /*
+ * Dont ban/kick the user on channels where he is excepted
+ * to prevent services <-> server wars.
+ */
+ } else if (ircd->except && is_excepted(ci, u2)) {
+ notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
+ } else if (ircd->protectedumode && is_protected(u2)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ char *av[3];
+ char mask[BUFSIZE];
+
+ av[0] = sstrdup("+b");
+ get_idealban(ci, u2, mask, sizeof(mask));
+ av[1] = mask;
+ anope_cmd_mode(whosends(ci), c->name, "+b %s", av[1]);
+ chan_set_modes(s_ChanServ, c, 2, av, 1);
+ free(av[0]);
+
+ /* We still allow host banning while not allowing to kick */
+ if (!is_on_chan(c, u2))
+ return MOD_CONT;
+
+ if ((ci->flags & CI_SIGNKICK)
+ || ((ci->flags & CI_SIGNKICK_LEVEL)
+ && !check_access(u, ci, CA_SIGNKICK)))
+ anope_cmd_kick(whosends(ci), ci->name, params, "%s (%s)",
+ reason, u->nick);
+ else
+ anope_cmd_kick(whosends(ci), ci->name, params, "%s", reason);
+
+ av[0] = ci->name;
+ av[1] = params;
+ av[2] = reason;
+ do_kick(s_ChanServ, 3, av);
+ }
+ return MOD_CONT;
+}
+
+/**
+ * The /cs unban command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_unban(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ Channel *c;
+ ChannelInfo *ci;
+
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "UNBAN", CHAN_UNBAN_SYNTAX);
+ } else if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!check_access(u, ci, CA_UNBAN)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ common_unban(ci, u->nick);
+ notice_lang(s_ChanServ, u, CHAN_UNBANNED, chan);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c
new file mode 100644
index 000000000..8bf4c8e67
--- /dev/null
+++ b/src/core/cs_clear.c
@@ -0,0 +1,375 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_clear(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("CLEAR", do_clear, NULL, CHAN_HELP_CLEAR, -1, -1, -1,
+ -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_CLEAR);
+}
+
+/**
+ * The /cs clear command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_clear(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *what = strtok(NULL, " ");
+ char tmp[BUFSIZE];
+ Channel *c;
+ ChannelInfo *ci;
+
+ if (!what) {
+ syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX);
+ } else if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!u || !check_access(u, ci, CA_CLEAR)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else if (stricmp(what, "bans") == 0) {
+ char *av[2];
+ int i;
+
+ /* Save original ban info */
+ int count = c->bancount;
+ char **bans = scalloc(sizeof(char *) * count, 1);
+ for (i = 0; i < count; i++)
+ bans[i] = sstrdup(c->bans[i]);
+
+ for (i = 0; i < count; i++) {
+ av[0] = sstrdup("-b");
+ av[1] = bans[i];
+ anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
+ chan_set_modes(whosends(ci), c, 2, av, 0);
+ free(av[1]);
+ free(av[0]);
+ }
+ notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan);
+ free(bans);
+ } else if (ircd->except && stricmp(what, "excepts") == 0) {
+ char *av[2];
+ int i;
+
+ /* Save original except info */
+ int count = c->exceptcount;
+ char **excepts = scalloc(sizeof(char *) * count, 1);
+ for (i = 0; i < count; i++)
+ excepts[i] = sstrdup(c->excepts[i]);
+
+ for (i = 0; i < count; i++) {
+ av[0] = sstrdup("-e");
+ av[1] = excepts[i];
+ anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
+ chan_set_modes(whosends(ci), c, 2, av, 0);
+ free(av[1]);
+ free(av[0]);
+ }
+ notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan);
+ free(excepts);
+
+ } else if (ircd->invitemode && stricmp(what, "invites") == 0) {
+ char *av[2];
+ int i;
+
+ /* Save original except info */
+ int count = c->invitecount;
+ char **invites = scalloc(sizeof(char *) * count, 1);
+ for (i = 0; i < count; i++)
+ invites[i] = sstrdup(c->invite[i]);
+
+ for (i = 0; i < count; i++) {
+ av[0] = sstrdup("-I");
+ av[1] = invites[i];
+ anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
+ chan_set_modes(whosends(ci), c, 2, av, 0);
+ free(av[1]);
+ free(av[0]);
+ }
+ notice_lang(s_ChanServ, u, CHAN_CLEARED_INVITES, chan);
+ free(invites);
+
+ } else if (stricmp(what, "modes") == 0) {
+ char buf[BUFSIZE], *end = buf;
+ char *argv[2];
+
+ if (c->mode) {
+ /* Clear modes the bulk of the modes */
+ anope_cmd_mode(whosends(ci), c->name, "%s",
+ ircd->modestoremove);
+ argv[0] = sstrdup(ircd->modestoremove);
+ chan_set_modes(whosends(ci), c, 1, argv, 0);
+ free(argv[0]);
+
+ /* to prevent the internals from complaining send -k, -L, -f by themselves if we need
+ to send them - TSL */
+ if (c->key) {
+ anope_cmd_mode(whosends(ci), c->name, "-k %s", c->key);
+ argv[0] = sstrdup("-k");
+ argv[1] = c->key;
+ chan_set_modes(whosends(ci), c, 2, argv, 0);
+ free(argv[0]);
+ }
+ if (ircd->Lmode && c->redirect) {
+ anope_cmd_mode(whosends(ci), c->name, "-L %s",
+ c->redirect);
+ argv[0] = sstrdup("-L");
+ argv[1] = c->redirect;
+ chan_set_modes(whosends(ci), c, 2, argv, 0);
+ free(argv[0]);
+ }
+ if (ircd->fmode && c->flood) {
+ if (flood_mode_char_remove) {
+ anope_cmd_mode(whosends(ci), c->name, "%s %s",
+ flood_mode_char_remove, c->flood);
+ argv[0] = sstrdup(flood_mode_char_remove);
+ argv[1] = c->flood;
+ chan_set_modes(whosends(ci), c, 2, argv, 0);
+ free(argv[0]);
+ } else {
+ if (debug) {
+ alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes");
+ }
+ }
+ }
+ check_modes(c);
+ }
+
+
+
+ /* TODO: decide if the above implementation is better than this one. */
+
+ if (0) {
+ CBModeInfo *cbmi = cbmodeinfos;
+ CBMode *cbm;
+
+ do {
+ if (c->mode & cbmi->flag)
+ *end++ = cbmi->mode;
+ } while ((++cbmi)->flag != 0);
+
+ cbmi = cbmodeinfos;
+
+ do {
+ if (cbmi->getvalue && (c->mode & cbmi->flag)
+ && !(cbmi->flags & CBM_MINUS_NO_ARG)) {
+ char *value = cbmi->getvalue(c);
+
+ if (value) {
+ *end++ = ' ';
+ while (*value)
+ *end++ = *value++;
+
+ /* Free the value */
+ cbm = &cbmodes[(int) cbmi->mode];
+ cbm->setvalue(c, NULL);
+ }
+ }
+ } while ((++cbmi)->flag != 0);
+
+ *end = 0;
+
+ anope_cmd_mode(whosends(ci), c->name, "-%s", buf);
+ c->mode = 0;
+ check_modes(c);
+ }
+ notice_lang(s_ChanServ, u, CHAN_CLEARED_MODES, chan);
+ } else if (stricmp(what, "ops") == 0) {
+ char *av[3];
+ struct c_userlist *cu, *next;
+
+ if (ircd->svsmode_ucmode) {
+ av[0] = sstrdup(chan);
+ anope_cmd_svsmode_chan(av[0], "-o", NULL);
+ if (ircd->owner) {
+ anope_cmd_svsmode_chan(av[0], ircd->ownerunset, NULL);
+ }
+ if (ircd->protect || ircd->admin) {
+ anope_cmd_svsmode_chan(av[0], ircd->adminunset, NULL);
+ }
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ av[0] = sstrdup(chan);
+ if (!chan_has_user_status(c, cu->user, CUS_OP)) {
+ if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) {
+ if (!chan_has_user_status(c, cu->user, CUS_OWNER)) {
+ continue;
+ } else {
+ snprintf(tmp, BUFSIZE, "%so",
+ ircd->ownerunset);
+ av[1] = sstrdup(tmp);
+
+ }
+ } else {
+ snprintf(tmp, BUFSIZE, "%so", ircd->adminunset);
+ av[1] = sstrdup(tmp);
+ }
+ } else {
+ av[1] = sstrdup("-o");
+ }
+ av[2] = sstrdup(cu->user->nick);
+ do_cmode(s_ChanServ, 3, av);
+ free(av[2]);
+ free(av[1]);
+ free(av[0]);
+ }
+ } else {
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ av[0] = sstrdup(chan);
+ if (!chan_has_user_status(c, cu->user, CUS_OP)) {
+ if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) {
+ if (!chan_has_user_status(c, cu->user, CUS_OWNER)) {
+ continue;
+ } else {
+ snprintf(tmp, BUFSIZE, "%so",
+ ircd->ownerunset);
+ av[1] = sstrdup(tmp);
+ }
+ } else {
+ snprintf(tmp, BUFSIZE, "%so", ircd->adminunset);
+ av[1] = sstrdup(tmp);
+ }
+ } else {
+ av[1] = sstrdup("-o");
+ }
+ av[2] = sstrdup(cu->user->nick);
+ anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
+ av[2]);
+ do_cmode(s_ChanServ, 3, av);
+ free(av[2]);
+ free(av[1]);
+ free(av[0]);
+ }
+ }
+ notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan);
+ } else if (ircd->halfop && stricmp(what, "hops") == 0) {
+ char *av[3];
+ struct c_userlist *cu, *next;
+
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_HALFOP))
+ continue;
+ av[0] = sstrdup(chan);
+ av[1] = sstrdup("-h");
+ av[2] = sstrdup(cu->user->nick);
+ if (ircd->svsmode_ucmode) {
+ anope_cmd_svsmode_chan(av[0], av[1], NULL);
+ do_cmode(s_ChanServ, 3, av);
+ break;
+ } else {
+ anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
+ av[2]);
+ }
+ do_cmode(s_ChanServ, 3, av);
+ free(av[2]);
+ free(av[1]);
+ free(av[0]);
+ }
+ notice_lang(s_ChanServ, u, CHAN_CLEARED_HOPS, chan);
+ } else if (stricmp(what, "voices") == 0) {
+ char *av[3];
+ struct c_userlist *cu, *next;
+
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_VOICE))
+ continue;
+ av[0] = sstrdup(chan);
+ av[1] = sstrdup("-v");
+ av[2] = sstrdup(cu->user->nick);
+ if (ircd->svsmode_ucmode) {
+ anope_cmd_svsmode_chan(av[0], av[1], NULL);
+ do_cmode(s_ChanServ, 3, av);
+ break;
+ } else {
+ anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
+ av[2]);
+ }
+ do_cmode(s_ChanServ, 3, av);
+ free(av[2]);
+ free(av[1]);
+ free(av[0]);
+ }
+ notice_lang(s_ChanServ, u, CHAN_CLEARED_VOICES, chan);
+ } else if (stricmp(what, "users") == 0) {
+ char *av[3];
+ struct c_userlist *cu, *next;
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "CLEAR USERS command from %s", u->nick);
+
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ av[0] = sstrdup(chan);
+ av[1] = sstrdup(cu->user->nick);
+ av[2] = sstrdup(buf);
+ anope_cmd_kick(whosends(ci), av[0], av[1], av[2]);
+ do_kick(s_ChanServ, 3, av);
+ free(av[2]);
+ free(av[1]);
+ free(av[0]);
+ }
+ notice_lang(s_ChanServ, u, CHAN_CLEARED_USERS, chan);
+ } else {
+ syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c
new file mode 100644
index 000000000..e53aa2037
--- /dev/null
+++ b/src/core/cs_drop.c
@@ -0,0 +1,128 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_drop(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("DROP", do_drop, NULL, -1, CHAN_HELP_DROP, -1,
+ CHAN_SERVADMIN_HELP_DROP, CHAN_SERVADMIN_HELP_DROP);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DROP);
+}
+
+/**
+ * The /cs command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_drop(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ ChannelInfo *ci;
+ int is_servadmin = is_services_admin(u);
+
+ if (readonly && !is_servadmin) {
+ notice_lang(s_ChanServ, u, CHAN_DROP_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "DROP", CHAN_DROP_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!is_servadmin && (ci->flags & CI_SUSPENDED)) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!is_servadmin
+ && (ci->
+ flags & CI_SECUREFOUNDER ? !is_real_founder(u,
+ ci) :
+ !is_founder(u, ci))) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else {
+ int level = get_access(u, ci);
+
+ if (readonly) /* in this case we know they're a Services admin */
+ notice_lang(s_ChanServ, u, READ_ONLY_MODE);
+
+ if (ci->c) {
+ if (ircd->regmode) {
+ ci->c->mode &= ~ircd->regmode;
+ anope_cmd_mode(whosends(ci), ci->name, "-r");
+ }
+ }
+
+ if (ircd->chansqline && (ci->flags & CI_VERBOTEN)) {
+ anope_cmd_unsqline(ci->name);
+ }
+
+ alog("%s: Channel %s dropped by %s!%s@%s (founder: %s)",
+ s_ChanServ, ci->name, u->nick, u->username,
+ u->host, (ci->founder ? ci->founder->display : "(none)"));
+
+ delchan(ci);
+
+ /* We must make sure that the Services admin has not normally the right to
+ * drop the channel before issuing the wallops.
+ */
+ if (WallDrop && is_servadmin && level < ACCESS_FOUNDER)
+ anope_cmd_global(s_ChanServ,
+ "\2%s\2 used DROP on channel \2%s\2", u->nick,
+ chan);
+
+ notice_lang(s_ChanServ, u, CHAN_DROPPED, chan);
+ send_event(EVENT_CHAN_DROP, 1, chan);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c
new file mode 100644
index 000000000..e7efd39d5
--- /dev/null
+++ b/src/core/cs_forbid.c
@@ -0,0 +1,132 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_forbid(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("FORBID", do_forbid, is_services_admin, -1, -1, -1,
+ CHAN_SERVADMIN_HELP_FORBID,
+ CHAN_SERVADMIN_HELP_FORBID);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_FORBID);
+ }
+}
+
+/**
+ * The /cs forbid command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_forbid(User * u)
+{
+ ChannelInfo *ci;
+ char *chan = strtok(NULL, " ");
+ char *reason = strtok(NULL, "");
+
+ Channel *c;
+
+ /* Assumes that permission checking has already been done. */
+ if (!chan || (ForceForbidReason && !reason)) {
+ syntax_error(s_ChanServ, u, "FORBID",
+ (ForceForbidReason ? CHAN_FORBID_SYNTAX_REASON :
+ CHAN_FORBID_SYNTAX));
+ return MOD_CONT;
+ }
+ if (readonly)
+ notice_lang(s_ChanServ, u, READ_ONLY_MODE);
+ if ((ci = cs_findchan(chan)) != NULL)
+ delchan(ci);
+ ci = makechan(chan);
+ if (ci) {
+ ci->flags |= CI_VERBOTEN;
+ ci->forbidby = sstrdup(u->nick);
+ if (reason)
+ ci->forbidreason = sstrdup(reason);
+
+ if ((c = findchan(ci->name))) {
+ struct c_userlist *cu, *next;
+ char *av[3];
+
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+
+ if (is_oper(cu->user))
+ continue;
+
+ av[0] = c->name;
+ av[1] = cu->user->nick;
+ av[2] = reason ? reason : "CHAN_FORBID_REASON";
+ anope_cmd_kick(s_ChanServ, av[0], av[1], av[2]);
+ do_kick(s_ChanServ, 3, av);
+ }
+ }
+
+ if (WallForbid)
+ anope_cmd_global(s_ChanServ,
+ "\2%s\2 used FORBID on channel \2%s\2",
+ u->nick, ci->name);
+
+ if (ircd->chansqline) {
+ anope_cmd_sqline(ci->name, ((reason) ? reason : "Forbidden"));
+ }
+
+ alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick,
+ ci->name);
+ notice_lang(s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan);
+ send_event(EVENT_CHAN_FORBIDDEN, 1, chan);
+ } else {
+ alog("%s: Valid FORBID for %s by %s failed", s_ChanServ, ci->name,
+ u->nick);
+ notice_lang(s_ChanServ, u, CHAN_FORBID_FAILED, chan);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_getkey.c b/src/core/cs_getkey.c
new file mode 100644
index 000000000..c7ff77fea
--- /dev/null
+++ b/src/core/cs_getkey.c
@@ -0,0 +1,88 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_getkey(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("GETKEY", do_getkey, NULL, CHAN_HELP_GETKEY, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_GETKEY);
+}
+
+/**
+ * The /cs getkey command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_getkey(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ ChannelInfo *ci;
+
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "GETKEY", CHAN_GETKEY_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!check_access(u, ci, CA_GETKEY)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (!ci->c || !ci->c->key) {
+ notice_lang(s_ChanServ, u, CHAN_GETKEY_NOKEY, chan);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_GETKEY_KEY, chan, ci->c->key);
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/cs_getpass.c b/src/core/cs_getpass.c
new file mode 100644
index 000000000..403b21403
--- /dev/null
+++ b/src/core/cs_getpass.c
@@ -0,0 +1,100 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_getpass(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("GETPASS", do_getpass, is_services_admin, -1, -1, -1,
+ CHAN_SERVADMIN_HELP_GETPASS,
+ CHAN_SERVADMIN_HELP_GETPASS);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+#ifdef USE_ENCRYPTION
+
+#else
+ return MOD_CONT;
+#endif
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_GETPASS);
+ }
+}
+
+/**
+ * The /cs getpass command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+
+int do_getpass(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ ChannelInfo *ci;
+
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "GETPASS", CHAN_GETPASS_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (CSRestrictGetPass && !is_services_root(u)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ alog("%s: %s!%s@%s used GETPASS on %s",
+ s_ChanServ, u->nick, u->username, u->host, ci->name);
+ if (WallGetpass) {
+ anope_cmd_global(s_ChanServ,
+ "\2%s\2 used GETPASS on channel \2%s\2",
+ u->nick, chan);
+ }
+ notice_lang(s_ChanServ, u, CHAN_GETPASS_PASSWORD_IS,
+ chan, ci->founderpass);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_help.c b/src/core/cs_help.c
new file mode 100644
index 000000000..8f1910d2a
--- /dev/null
+++ b/src/core/cs_help.c
@@ -0,0 +1,84 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_help(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * The /cs help command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_help(User * u)
+{
+ char *cmd = strtok(NULL, "");
+
+ if (!cmd) {
+ notice_help(s_ChanServ, u, CHAN_HELP);
+ moduleDisplayHelp(2, u);
+ if (CSExpire >= 86400)
+ notice_help(s_ChanServ, u, CHAN_HELP_EXPIRES,
+ CSExpire / 86400);
+ if (is_services_oper(u))
+ notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP);
+ } else if (stricmp(cmd, "LEVELS DESC") == 0) {
+ int i;
+ notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC);
+ if (!levelinfo_maxwidth) {
+ for (i = 0; levelinfo[i].what >= 0; i++) {
+ int len = strlen(levelinfo[i].name);
+ if (len > levelinfo_maxwidth)
+ levelinfo_maxwidth = len;
+ }
+ }
+ for (i = 0; levelinfo[i].what >= 0; i++) {
+ notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC_FORMAT,
+ levelinfo_maxwidth, levelinfo[i].name,
+ getstring(u->na, levelinfo[i].desc));
+ }
+ } else {
+ mod_help_cmd(s_ChanServ, u, CHANSERV, cmd);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_identify.c b/src/core/cs_identify.c
new file mode 100644
index 000000000..0df40f127
--- /dev/null
+++ b/src/core/cs_identify.c
@@ -0,0 +1,118 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_identify(User * u);
+void myChanServHelp(User * u);
+extern MDE int check_password(const char *plaintext, const char *password);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("IDENTIFY", do_identify, NULL, CHAN_HELP_IDENTIFY,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ c = createCommand("ID", do_identify, NULL, CHAN_HELP_IDENTIFY, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_IDENTIFY);
+}
+
+/**
+ * The /cs command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_identify(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *pass = strtok(NULL, " ");
+ ChannelInfo *ci;
+ struct u_chaninfolist *uc;
+
+ if (!pass) {
+ syntax_error(s_ChanServ, u, "IDENTIFY", CHAN_IDENTIFY_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!nick_identified(u)) {
+ notice_lang(s_ChanServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ } else if (is_founder(u, ci)) {
+ notice_lang(s_ChanServ, u, NICK_ALREADY_IDENTIFIED);
+ } else {
+ int res;
+
+ if ((res = check_password(pass, ci->founderpass)) == 1) {
+ if (!is_identified(u, ci)) {
+ uc = scalloc(sizeof(*uc), 1);
+ uc->next = u->founder_chans;
+ if (u->founder_chans)
+ u->founder_chans->prev = uc;
+ u->founder_chans = uc;
+ uc->chan = ci;
+ alog("%s: %s!%s@%s identified for %s", s_ChanServ, u->nick,
+ u->username, u->host, ci->name);
+ }
+
+ notice_lang(s_ChanServ, u, CHAN_IDENTIFY_SUCCEEDED, chan);
+ } else if (res < 0) {
+ alog("%s: check_password failed for %s", s_ChanServ, ci->name);
+ notice_lang(s_ChanServ, u, CHAN_IDENTIFY_FAILED);
+ } else {
+ alog("%s: Failed IDENTIFY for %s by %s!%s@%s",
+ s_ChanServ, ci->name, u->nick, u->username, u->host);
+ notice_lang(s_ChanServ, u, PASSWORD_INCORRECT);
+ bad_password(u);
+ }
+
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_info.c b/src/core/cs_info.c
new file mode 100644
index 000000000..5450980de
--- /dev/null
+++ b/src/core/cs_info.c
@@ -0,0 +1,249 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_info(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("INFO", do_info, NULL, CHAN_HELP_INFO, -1,
+ CHAN_SERVADMIN_HELP_INFO, CHAN_SERVADMIN_HELP_INFO,
+ CHAN_SERVADMIN_HELP_INFO);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_INFO);
+}
+
+/**
+ * The /cs info command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_info(User * u)
+{
+/* SADMINS and users, who have identified for a channel, can now cause it's
+ * Enstry Message and Successor to be displayed by supplying the ALL parameter.
+ * Syntax: INFO channel [ALL]
+ * -TheShadow (29 Mar 1999)
+ */
+ char *chan = strtok(NULL, " ");
+ char *param = strtok(NULL, " ");
+ ChannelInfo *ci;
+ char buf[BUFSIZE], *end;
+ struct tm *tm;
+ int need_comma = 0;
+ const char *commastr = getstring(u->na, COMMA_SPACE);
+ int is_servadmin = is_services_admin(u);
+ int show_all = 0;
+ time_t expt;
+
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "INFO", CHAN_INFO_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ if (is_oper(u) && ci->forbidby)
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan,
+ ci->forbidby,
+ (ci->forbidreason ? ci->
+ forbidreason : getstring(u->na, NO_REASON)));
+ else
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!ci->founder) {
+ /* Paranoia... this shouldn't be able to happen */
+ delchan(ci);
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else {
+
+ /* Should we show all fields? Only for sadmins and identified users */
+ if (param && stricmp(param, "ALL") == 0 &&
+ (check_access(u, ci, CA_INFO) || is_servadmin))
+ show_all = 1;
+
+ notice_lang(s_ChanServ, u, CHAN_INFO_HEADER, chan);
+ notice_lang(s_ChanServ, u, CHAN_INFO_NO_FOUNDER,
+ ci->founder->display);
+
+ if (show_all && ci->successor)
+ notice_lang(s_ChanServ, u, CHAN_INFO_NO_SUCCESSOR,
+ ci->successor->display);
+
+ notice_lang(s_ChanServ, u, CHAN_INFO_DESCRIPTION, ci->desc);
+ tm = localtime(&ci->time_registered);
+ strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
+ notice_lang(s_ChanServ, u, CHAN_INFO_TIME_REGGED, buf);
+ tm = localtime(&ci->last_used);
+ strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
+ notice_lang(s_ChanServ, u, CHAN_INFO_LAST_USED, buf);
+ if (ci->last_topic
+ && (show_all || (!(ci->mlock_on & anope_get_secret_mode())
+ && (!ci->c
+ || !(ci->c->
+ mode & anope_get_secret_mode()))))) {
+ notice_lang(s_ChanServ, u, CHAN_INFO_LAST_TOPIC,
+ ci->last_topic);
+ notice_lang(s_ChanServ, u, CHAN_INFO_TOPIC_SET_BY,
+ ci->last_topic_setter);
+ }
+
+ if (ci->entry_message && show_all)
+ notice_lang(s_ChanServ, u, CHAN_INFO_ENTRYMSG,
+ ci->entry_message);
+ if (ci->url)
+ notice_lang(s_ChanServ, u, CHAN_INFO_URL, ci->url);
+ if (ci->email)
+ notice_lang(s_ChanServ, u, CHAN_INFO_EMAIL, ci->email);
+
+ if (show_all) {
+ notice_lang(s_ChanServ, u, CHAN_INFO_BANTYPE, ci->bantype);
+
+ end = buf;
+ *end = 0;
+ if (ci->flags & CI_KEEPTOPIC) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s",
+ getstring(u->na, CHAN_INFO_OPT_KEEPTOPIC));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_OPNOTICE) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, CHAN_INFO_OPT_OPNOTICE));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_PEACE) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, CHAN_INFO_OPT_PEACE));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_PRIVATE) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, CHAN_INFO_OPT_PRIVATE));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_RESTRICTED) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na,
+ CHAN_INFO_OPT_RESTRICTED));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_SECURE) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, CHAN_INFO_OPT_SECURE));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_SECUREOPS) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, CHAN_INFO_OPT_SECUREOPS));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_SECUREFOUNDER) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na,
+ CHAN_INFO_OPT_SECUREFOUNDER));
+ need_comma = 1;
+ }
+ if ((ci->flags & CI_SIGNKICK)
+ || (ci->flags & CI_SIGNKICK_LEVEL)) {
+ end +=
+ snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "", getstring(u->na,
+ CHAN_INFO_OPT_SIGNKICK));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_TOPICLOCK) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, CHAN_INFO_OPT_TOPICLOCK));
+ need_comma = 1;
+ }
+ if (ci->flags & CI_XOP) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, CHAN_INFO_OPT_XOP));
+ need_comma = 1;
+ }
+ notice_lang(s_ChanServ, u, CHAN_INFO_OPTIONS,
+ *buf ? buf : getstring(u->na, CHAN_INFO_OPT_NONE));
+ notice_lang(s_ChanServ, u, CHAN_INFO_MODE_LOCK,
+ get_mlock_modes(ci, 1));
+
+ }
+ if (show_all) {
+ if (ci->flags & CI_NO_EXPIRE) {
+ notice_lang(s_ChanServ, u, CHAN_INFO_NO_EXPIRE);
+ } else {
+ if (is_servadmin) {
+ expt = ci->last_used + CSExpire;
+ tm = localtime(&expt);
+ strftime_lang(buf, sizeof(buf), u,
+ STRFTIME_DATE_TIME_FORMAT, tm);
+ notice_lang(s_ChanServ, u, CHAN_INFO_EXPIRE, buf);
+ }
+ }
+ }
+ if (ci->flags & CI_SUSPENDED) {
+ notice_lang(s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby,
+ (ci->forbidreason ? ci->
+ forbidreason : getstring(u->na, NO_REASON)));
+ }
+
+ if (!show_all && (check_access(u, ci, CA_INFO) || is_servadmin))
+ notice_lang(s_ChanServ, u, NICK_INFO_FOR_MORE, s_ChanServ,
+ ci->name);
+
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_invite.c b/src/core/cs_invite.c
new file mode 100644
index 000000000..bd3bb8e2b
--- /dev/null
+++ b/src/core/cs_invite.c
@@ -0,0 +1,88 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+void myChanServHelp(User * u);
+int do_invite(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("INVITE", do_invite, NULL, CHAN_HELP_INVITE, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_INVITE);
+}
+
+/**
+ * The /cs invite command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_invite(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ Channel *c;
+ ChannelInfo *ci;
+
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "INVITE", CHAN_INVITE_SYNTAX);
+ } else if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!u || !check_access(u, ci, CA_INVITE)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ anope_cmd_invite(whosends(ci), chan, u->nick);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c
new file mode 100644
index 000000000..caaf6b9a9
--- /dev/null
+++ b/src/core/cs_kick.c
@@ -0,0 +1,152 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_cs_kick(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("KICK", do_cs_kick, NULL, CHAN_HELP_KICK, -1, -1, -1,
+ -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_KICK);
+}
+
+/**
+ * The /cs kick command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_cs_kick(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *params = strtok(NULL, " ");
+ char *reason = strtok(NULL, "");
+
+ Channel *c;
+ ChannelInfo *ci;
+ User *u2;
+
+ int is_same;
+
+ if (!reason) {
+ reason = "Requested";
+ } else {
+ if (strlen(reason) > 200)
+ reason[200] = '\0';
+ }
+
+ if (!chan) {
+ struct u_chanlist *uc, *next;
+
+ /* Kicks the user on every channels he is on. */
+
+ for (uc = u->chans; uc; uc = next) {
+ next = uc->next;
+ if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
+ && check_access(u, ci, CA_KICKME)) {
+ char *av[3];
+
+ if ((ci->flags & CI_SIGNKICK)
+ || ((ci->flags & CI_SIGNKICK_LEVEL)
+ && !check_access(u, ci, CA_SIGNKICK)))
+ anope_cmd_kick(whosends(ci), ci->name, u->nick,
+ "%s (%s)", reason, u->nick);
+ else
+ anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s",
+ reason);
+ av[0] = ci->name;
+ av[1] = u->nick;
+ av[2] = reason;
+ do_kick(s_ChanServ, 3, av);
+ }
+ }
+
+ return MOD_CONT;
+ } else if (!params) {
+ params = u->nick;
+ }
+
+ is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0);
+
+ if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params);
+ } else if (!is_on_chan(c, u2)) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
+ } else if (!is_same ? !check_access(u, ci, CA_KICK) :
+ !check_access(u, ci, CA_KICKME)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (!is_same && (ci->flags & CI_PEACE)
+ && (get_access(u2, ci) >= get_access(u, ci))) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else if (is_protected(u2)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ char *av[3];
+
+ if ((ci->flags & CI_SIGNKICK)
+ || ((ci->flags & CI_SIGNKICK_LEVEL)
+ && !check_access(u, ci, CA_SIGNKICK)))
+ anope_cmd_kick(whosends(ci), ci->name, params, "%s (%s)",
+ reason, u->nick);
+ else
+ anope_cmd_kick(whosends(ci), ci->name, params, "%s", reason);
+ av[0] = ci->name;
+ av[1] = params;
+ av[2] = reason;
+ do_kick(s_ChanServ, 3, av);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_list.c b/src/core/cs_list.c
new file mode 100644
index 000000000..fa33f2947
--- /dev/null
+++ b/src/core/cs_list.c
@@ -0,0 +1,172 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_list(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("LIST", do_list, NULL, -1, CHAN_HELP_LIST,
+ CHAN_SERVADMIN_HELP_LIST, CHAN_SERVADMIN_HELP_LIST,
+ CHAN_SERVADMIN_HELP_LIST);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LIST);
+}
+
+/**
+ * The /cs list command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_list(User * u)
+{
+ char *pattern = strtok(NULL, " ");
+ ChannelInfo *ci;
+ int nchans, i;
+ char buf[BUFSIZE];
+ int is_servadmin = is_services_admin(u);
+ int count = 0, from = 0, to = 0;
+ char *tmp = NULL;
+ char *s = NULL;
+ char *keyword;
+ int32 matchflags = 0;
+
+
+ if (CSListOpersOnly && (!u || !is_oper(u))) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (!pattern) {
+ syntax_error(s_ChanServ, u, "LIST",
+ is_servadmin ? CHAN_LIST_SERVADMIN_SYNTAX :
+ CHAN_LIST_SYNTAX);
+ } else {
+
+ if (pattern) {
+ if (pattern[0] == '#') {
+ tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */
+ if (!tmp) {
+ return MOD_CONT;
+ }
+ for (s = tmp; *s; s++) {
+ if (!isdigit(*s)) {
+ return MOD_CONT;
+ }
+ }
+ from = atoi(tmp);
+ tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */
+ if (!tmp) {
+ return MOD_CONT;
+ }
+ for (s = tmp; *s; s++) {
+ if (!isdigit(*s)) {
+ return MOD_CONT;
+ }
+ }
+ to = atoi(tmp);
+ pattern = sstrdup("*");
+ }
+ }
+
+ nchans = 0;
+
+ while (is_servadmin && (keyword = strtok(NULL, " "))) {
+ if (stricmp(keyword, "FORBIDDEN") == 0)
+ matchflags |= CI_VERBOTEN;
+ if (stricmp(keyword, "SUSPENDED") == 0)
+ matchflags |= CI_SUSPENDED;
+ if (stricmp(keyword, "NOEXPIRE") == 0)
+ matchflags |= CI_NO_EXPIRE;
+ }
+
+ notice_lang(s_ChanServ, u, CHAN_LIST_HEADER, pattern);
+ for (i = 0; i < 256; i++) {
+ for (ci = chanlists[i]; ci; ci = ci->next) {
+ if (!is_servadmin && ((ci->flags & CI_PRIVATE)
+ || (ci->flags & CI_VERBOTEN)))
+ continue;
+ if ((matchflags != 0) && !(ci->flags & matchflags))
+ continue;
+
+ if (stricmp(pattern, ci->name) == 0
+ || match_wild_nocase(pattern, ci->name)) {
+ if ((((count + 1 >= from) && (count + 1 <= to))
+ || ((from == 0) && (to == 0)))
+ && (++nchans <= CSListMax)) {
+ char noexpire_char = ' ';
+ if (is_servadmin && (ci->flags & CI_NO_EXPIRE))
+ noexpire_char = '!';
+
+ if (ci->flags & CI_VERBOTEN) {
+ snprintf(buf, sizeof(buf),
+ "%-20s [Forbidden]", ci->name);
+ } else if (ci->flags & CI_SUSPENDED) {
+ snprintf(buf, sizeof(buf),
+ "%-20s [Suspended]", ci->name);
+ } else {
+ snprintf(buf, sizeof(buf), "%-20s %s",
+ ci->name, ci->desc ? ci->desc : "");
+ }
+
+ notice_user(s_ChanServ, u, " %c%s",
+ noexpire_char, buf);
+ }
+ count++;
+ }
+ }
+ }
+ notice_lang(s_ChanServ, u, CHAN_LIST_END,
+ nchans > CSListMax ? CSListMax : nchans, nchans);
+ }
+ return MOD_CONT;
+
+}
diff --git a/src/core/cs_logout.c b/src/core/cs_logout.c
new file mode 100644
index 000000000..2d143fc4b
--- /dev/null
+++ b/src/core/cs_logout.c
@@ -0,0 +1,128 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_logout(User * u);
+void myChanServHelp(User * u);
+void make_unidentified(User * u, ChannelInfo * ci);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("LOGOUT", do_logout, NULL, -1, CHAN_HELP_LOGOUT, -1,
+ CHAN_SERVADMIN_HELP_LOGOUT,
+ CHAN_SERVADMIN_HELP_LOGOUT);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LOGOUT);
+}
+
+/**
+ * The /cs command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_logout(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+ ChannelInfo *ci;
+ User *u2 = NULL;
+ int is_servadmin = is_services_admin(u);
+
+ if (!chan || (!nick && !is_servadmin)) {
+ syntax_error(s_ChanServ, u, "LOGOUT",
+ (!is_servadmin ? CHAN_LOGOUT_SYNTAX :
+ CHAN_LOGOUT_SERVADMIN_SYNTAX));
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (nick && !(u2 = finduser(nick))) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
+ } else if (!is_servadmin && u2 != u && !is_real_founder(u, ci)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else {
+ if (u2) {
+ make_unidentified(u2, ci);
+ notice_lang(s_ChanServ, u, CHAN_LOGOUT_SUCCEEDED, nick, chan);
+ alog("%s: User %s!%s@%s has been logged out of channel %s.",
+ s_ChanServ, u2->nick, u2->username, u2->host, chan);
+ } else {
+ int i;
+ for (i = 0; i < 1024; i++)
+ for (u2 = userlist[i]; u2; u2 = u2->next)
+ make_unidentified(u2, ci);
+ notice_lang(s_ChanServ, u, CHAN_LOGOUT_ALL_SUCCEEDED, chan);
+ alog("%s: All users identified have been logged out of channel %s.", s_ChanServ, chan);
+ }
+
+ }
+ return MOD_CONT;
+}
+
+void make_unidentified(User * u, ChannelInfo * ci)
+{
+ struct u_chaninfolist *uci;
+
+ if (!u || !ci)
+ return;
+
+ for (uci = u->founder_chans; uci; uci = uci->next) {
+ if (uci->chan == ci) {
+ if (uci->next)
+ uci->next->prev = uci->prev;
+ if (uci->prev)
+ uci->prev->next = uci->next;
+ else
+ u->founder_chans = uci->next;
+ free(uci);
+ break;
+ }
+ }
+}
diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c
new file mode 100644
index 000000000..c2696a108
--- /dev/null
+++ b/src/core/cs_modes.c
@@ -0,0 +1,392 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+void myChanServHelp(User * u);
+int do_util(User * u, CSModeUtil * util);
+int do_op(User * u);
+int do_deop(User * u);
+int do_voice(User * u);
+int do_devoice(User * u);
+int do_halfop(User * u);
+int do_dehalfop(User * u);
+int do_protect(User * u);
+int do_deprotect(User * u);
+int do_owner(User * u);
+int do_deowner(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("OP", do_op, NULL, CHAN_HELP_OP, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("DEOP", do_deop, NULL, CHAN_HELP_DEOP, -1, -1, -1,
+ -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("VOICE", do_voice, NULL, CHAN_HELP_VOICE, -1, -1, -1,
+ -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("DEVOICE", do_devoice, NULL, CHAN_HELP_DEVOICE, -1,
+ -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ if (ircd->halfop) {
+ c = createCommand("HALFOP", do_halfop, NULL, CHAN_HELP_HALFOP, -1,
+ -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("DEHALFOP", do_dehalfop, NULL,
+ CHAN_HELP_DEHALFOP, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ }
+ if (ircd->protect) {
+ c = createCommand("PROTECT", do_protect, NULL, CHAN_HELP_PROTECT,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("DEPROTECT", do_deprotect, NULL,
+ CHAN_HELP_DEPROTECT, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ }
+ if (ircd->owner) {
+ c = createCommand("OWNER", do_owner, NULL, CHAN_HELP_OWNER, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("DEOWNER", do_deowner, NULL, CHAN_HELP_DEOWNER,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ }
+ if (ircd->admin) {
+ c = createCommand("ADMIN", do_protect, NULL, CHAN_HELP_PROTECT, -1,
+ -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("DEADMIN", do_deprotect, NULL,
+ CHAN_HELP_DEPROTECT, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ }
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ if (ircd->owner) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_OWNER);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEOWNER);
+ }
+ if (ircd->protect) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_PROTECT);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEPROTECT);
+ } else if (ircd->admin) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_ADMIN);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEADMIN);
+ }
+
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_OP);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEOP);
+ if (ircd->halfop) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_HALFOP);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEHALFOP);
+ }
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_VOICE);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEVOICE);
+}
+
+/**
+ * The /cs op/deop/voice/devoice etc.. commands.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+
+int do_op(User * u)
+{
+ return do_util(u, &csmodeutils[MUT_OP]);
+}
+
+/*************************************************************************/
+
+int do_deop(User * u)
+{
+ return do_util(u, &csmodeutils[MUT_DEOP]);
+}
+
+/*************************************************************************/
+
+int do_voice(User * u)
+{
+ return do_util(u, &csmodeutils[MUT_VOICE]);
+}
+
+/*************************************************************************/
+
+int do_devoice(User * u)
+{
+ return do_util(u, &csmodeutils[MUT_DEVOICE]);
+}
+
+/*************************************************************************/
+
+int do_halfop(User * u)
+{
+ if (ircd->halfop) {
+ return do_util(u, &csmodeutils[MUT_HALFOP]);
+ } else {
+ return MOD_CONT;
+ }
+}
+
+/*************************************************************************/
+
+int do_dehalfop(User * u)
+{
+ if (ircd->halfop) {
+ return do_util(u, &csmodeutils[MUT_DEHALFOP]);
+ } else {
+ return MOD_CONT;
+ }
+}
+
+/*************************************************************************/
+
+int do_protect(User * u)
+{
+ if (ircd->protect || ircd->admin) {
+ return do_util(u, &csmodeutils[MUT_PROTECT]);
+ } else {
+ return MOD_CONT;
+ }
+}
+
+/*************************************************************************/
+
+int do_deprotect(User * u)
+{
+ if (ircd->protect || ircd->admin) {
+ return do_util(u, &csmodeutils[MUT_DEPROTECT]);
+ } else {
+ return MOD_CONT;
+ }
+}
+
+/*************************************************************************/
+
+int do_owner(User * u)
+{
+ char *av[2];
+ char *chan = strtok(NULL, " ");
+
+ Channel *c;
+ ChannelInfo *ci;
+ struct u_chanlist *uc;
+
+ if (!ircd->owner) {
+ return MOD_CONT;
+ }
+
+ if (!chan) {
+ av[0] = sstrdup(ircd->ownerset);
+ av[1] = u->nick;
+
+ /* Sets the mode to the user on every channels he is on. */
+
+ for (uc = u->chans; uc; uc = uc->next) {
+ if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
+ && is_founder(u, ci)) {
+ anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
+ av[0], u->nick);
+ chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
+ }
+ }
+
+ free(av[0]);
+ return MOD_CONT;
+ }
+
+ if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
+ } else if (!is_on_chan(c, u)) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name);
+ } else if (!is_founder(u, ci)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else {
+ anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerset,
+ u->nick);
+
+ av[0] = sstrdup(ircd->ownerset);
+ av[1] = u->nick;
+ chan_set_modes(s_ChanServ, c, 2, av, 1);
+ free(av[0]);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_deowner(User * u)
+{
+ char *av[2];
+ char *chan = strtok(NULL, " ");
+
+ Channel *c;
+ ChannelInfo *ci;
+ struct u_chanlist *uc;
+
+ if (!ircd->owner) {
+ return MOD_CONT;
+ }
+
+ if (!chan) {
+ av[0] = sstrdup(ircd->ownerunset);
+ av[1] = u->nick;
+
+ /* Sets the mode to the user on every channels he is on. */
+
+ for (uc = u->chans; uc; uc = uc->next) {
+ if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
+ && is_founder(u, ci)) {
+ anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
+ av[0], u->nick);
+ chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
+ }
+ }
+
+ free(av[0]);
+ return MOD_CONT;
+ }
+
+ if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
+ } else if (!is_on_chan(c, u)) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name);
+ } else if (!is_founder(u, ci)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else {
+ anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerunset,
+ u->nick);
+
+ av[0] = sstrdup(ircd->ownerunset);
+ av[1] = u->nick;
+ chan_set_modes(s_ChanServ, c, 2, av, 1);
+ free(av[0]);
+ }
+ return MOD_CONT;
+}
+
+/* do_util: not a command, but does the job of other */
+
+int do_util(User * u, CSModeUtil * util)
+{
+ char *av[2];
+ char *chan = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+
+ Channel *c;
+ ChannelInfo *ci;
+ User *u2;
+
+ int is_same;
+
+ if (!chan) {
+ struct u_chanlist *uc;
+
+ av[0] = util->mode;
+ av[1] = u->nick;
+
+ /* Sets the mode to the user on every channels he is on. */
+
+ for (uc = u->chans; uc; uc = uc->next) {
+ if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
+ && check_access(u, ci, util->levelself)) {
+ anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
+ util->mode, u->nick);
+ chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
+
+ if (util->notice && ci->flags & util->notice)
+ notice(whosends(ci), uc->chan->name,
+ "%s command used for %s by %s", util->name,
+ u->nick, u->nick);
+ }
+ }
+
+ return MOD_CONT;
+ } else if (!nick) {
+ nick = u->nick;
+ }
+
+ is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0);
+
+ if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
+ } else if (is_same ? !(u2 = u) : !(u2 = finduser(nick))) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
+ } else if (!is_on_chan(c, u2)) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
+ } else if (is_same ? !check_access(u, ci, util->levelself) :
+ !check_access(u, ci, util->level)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (*util->mode == '-' && !is_same && (ci->flags & CI_PEACE)
+ && (get_access(u2, ci) >= get_access(u, ci))) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else if (*util->mode == '-' && is_protected(u2)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ anope_cmd_mode(whosends(ci), c->name, "%s %s", util->mode,
+ u2->nick);
+
+ av[0] = util->mode;
+ av[1] = u2->nick;
+ chan_set_modes(s_ChanServ, c, 2, av, 1);
+
+ if (util->notice && ci->flags & util->notice)
+ notice(whosends(ci), c->name, "%s command used for %s by %s",
+ util->name, u2->nick, u->nick);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_register.c b/src/core/cs_register.c
new file mode 100644
index 000000000..892f51290
--- /dev/null
+++ b/src/core/cs_register.c
@@ -0,0 +1,199 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_register(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("REGISTER", do_register, NULL, CHAN_HELP_REGISTER,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_REGISTER);
+}
+
+/**
+ * The /cs register command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_register(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *pass = strtok(NULL, " ");
+ char *desc = strtok(NULL, "");
+ NickCore *nc;
+ Channel *c;
+ ChannelInfo *ci;
+ struct u_chaninfolist *uc;
+ int is_servadmin = is_services_admin(u);
+#ifdef USE_ENCRYPTION
+ char founderpass[PASSMAX + 1];
+#endif
+
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_REGISTER_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) {
+ notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED);
+ return MOD_CONT;
+ }
+
+ if (!desc) {
+ syntax_error(s_ChanServ, u, "REGISTER", CHAN_REGISTER_SYNTAX);
+ } else if (*chan == '&') {
+ notice_lang(s_ChanServ, u, CHAN_REGISTER_NOT_LOCAL);
+ } else if (*chan != '#') {
+ notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED);
+ } else if (!u->na || !(nc = u->na->nc)) {
+ notice_lang(s_ChanServ, u, CHAN_MUST_REGISTER_NICK, s_NickServ);
+ } else if (!nick_recognized(u)) {
+ notice_lang(s_ChanServ, u, CHAN_MUST_IDENTIFY_NICK, s_NickServ,
+ s_NickServ);
+ } else if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_REGISTER_NONE_CHANNEL, chan);
+ } else if ((ci = cs_findchan(chan)) != NULL) {
+ if (ci->flags & CI_VERBOTEN) {
+ alog("%s: Attempt to register FORBIDden channel %s by %s!%s@%s", s_ChanServ, ci->name, u->nick, u->username, u->host);
+ notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_ALREADY_REGISTERED, chan);
+ }
+ } else if (!stricmp(chan, "#")) {
+ notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
+ } else if (!chan_has_user_status(c, u, CUS_OP)) {
+ notice_lang(s_ChanServ, u, CHAN_MUST_BE_CHANOP);
+
+ } else if (!is_servadmin && nc->channelmax > 0
+ && nc->channelcount >= nc->channelmax) {
+ notice_lang(s_ChanServ, u,
+ nc->channelcount >
+ nc->
+ channelmax ? CHAN_EXCEEDED_CHANNEL_LIMIT :
+ CHAN_REACHED_CHANNEL_LIMIT, nc->channelmax);
+ } else if (stricmp(u->nick, pass) == 0
+ || (StrictPasswords && strlen(pass) < 5)) {
+ notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD);
+ } else if (!(ci = makechan(chan))) {
+ alog("%s: makechan() failed for REGISTER %s", s_ChanServ, chan);
+ notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED);
+
+#ifdef USE_ENCRYPTION
+ } else if (strscpy(founderpass, pass, PASSMAX + 1),
+ encrypt_in_place(founderpass, PASSMAX) < 0) {
+ alog("%s: Couldn't encrypt password for %s (REGISTER)",
+ s_ChanServ, chan);
+ notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED);
+ delchan(ci);
+#endif
+
+ } else {
+ c->ci = ci;
+ ci->c = c;
+ ci->bantype = CSDefBantype;
+ ci->flags = CSDefFlags;
+ ci->mlock_on = ircd->defmlock;
+ ci->memos.memomax = MSMaxMemos;
+ ci->last_used = ci->time_registered;
+ ci->founder = nc;
+#ifdef USE_ENCRYPTION
+ if (strlen(pass) > PASSMAX)
+ notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX);
+ memset(pass, 0, strlen(pass));
+ memcpy(ci->founderpass, founderpass, PASSMAX);
+ ci->flags |= CI_ENCRYPTEDPW;
+#else
+ if (strlen(pass) > PASSMAX - 1) /* -1 for null byte */
+ notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX - 1);
+ strscpy(ci->founderpass, pass, PASSMAX);
+#endif
+ ci->desc = sstrdup(desc);
+ if (c->topic) {
+ ci->last_topic = sstrdup(c->topic);
+ strscpy(ci->last_topic_setter, c->topic_setter, NICKMAX);
+ ci->last_topic_time = c->topic_time;
+ } else {
+ /* Set this to something, otherwise it will maliform the topic */
+ strscpy(ci->last_topic_setter, s_ChanServ, NICKMAX);
+ }
+ ci->bi = NULL;
+ ci->botflags = BSDefFlags;
+ ci->founder->channelcount++;
+ alog("%s: Channel '%s' registered by %s!%s@%s", s_ChanServ, chan,
+ u->nick, u->username, u->host);
+ notice_lang(s_ChanServ, u, CHAN_REGISTERED, chan, u->nick);
+#ifndef USE_ENCRYPTION
+ notice_lang(s_ChanServ, u, CHAN_PASSWORD_IS, ci->founderpass);
+#endif
+ uc = scalloc(sizeof(*uc), 1);
+ uc->next = u->founder_chans;
+ uc->prev = NULL;
+ if (u->founder_chans)
+ u->founder_chans->prev = uc;
+ u->founder_chans = uc;
+ uc->chan = ci;
+ /* Implement new mode lock */
+ check_modes(c);
+ /* On most ircds you do not receive the admin/owner mode till its registered */
+ if (ircd->admin) {
+ anope_cmd_mode(s_ChanServ, chan, "%s %s", ircd->adminset,
+ u->nick);
+ }
+ if (ircd->owner && ircd->ownerset) {
+ anope_cmd_mode(s_ChanServ, chan, "%s %s", ircd->ownerset,
+ u->nick);
+ }
+ send_event(EVENT_CHAN_REGISTERED, 1, chan);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_sendpass.c b/src/core/cs_sendpass.c
new file mode 100644
index 000000000..61eb70524
--- /dev/null
+++ b/src/core/cs_sendpass.c
@@ -0,0 +1,123 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_sendpass(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SENDPASS", do_sendpass, NULL, CHAN_HELP_SENDPASS,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+#ifdef USE_ENCRYPTION
+ return MOD_STOP;
+#else
+ if (UseMail) {
+ return MOD_CONT;
+ } else {
+ return MOD_STOP;
+ }
+#endif
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SENDPASS);
+}
+
+/**
+ * The /cs sendpass command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_sendpass(User * u)
+{
+
+ char *chan = strtok(NULL, " ");
+ ChannelInfo *ci;
+ NickCore *founder;
+
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "SENDPASS", CHAN_SENDPASS_SYNTAX);
+ } else if (RestrictMail && !is_oper(u)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else if (!(ci = cs_findchan(chan)) || !(founder = ci->founder)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else {
+ char buf[BUFSIZE];
+ MailInfo *mail;
+
+ snprintf(buf, sizeof(buf),
+ getstring2(founder, CHAN_SENDPASS_SUBJECT), ci->name);
+ mail = MailBegin(u, founder, buf, s_ChanServ);
+ if (!mail)
+ return MOD_CONT;
+
+ fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_HEAD));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_1),
+ ci->name);
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_2),
+ ci->founderpass);
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_3));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_4));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_5),
+ NetworkName);
+ fprintf(mail->pipe, "\n.\n");
+
+ MailEnd(mail);
+
+ alog("%s: %s!%s@%s used SENDPASS on %s", s_ChanServ, u->nick,
+ u->username, u->host, chan);
+ notice_lang(s_ChanServ, u, CHAN_SENDPASS_OK, chan);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_set.c b/src/core/cs_set.c
new file mode 100644
index 000000000..7916a93b4
--- /dev/null
+++ b/src/core/cs_set.c
@@ -0,0 +1,839 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_set(User * u);
+int do_set_founder(User * u, ChannelInfo * ci, char *param);
+int do_set_successor(User * u, ChannelInfo * ci, char *param);
+int do_set_password(User * u, ChannelInfo * ci, char *param);
+int do_set_desc(User * u, ChannelInfo * ci, char *param);
+int do_set_url(User * u, ChannelInfo * ci, char *param);
+int do_set_email(User * u, ChannelInfo * ci, char *param);
+int do_set_entrymsg(User * u, ChannelInfo * ci, char *param);
+int do_set_bantype(User * u, ChannelInfo * ci, char *param);
+int do_set_mlock(User * u, ChannelInfo * ci, char *param);
+int do_set_keeptopic(User * u, ChannelInfo * ci, char *param);
+int do_set_topiclock(User * u, ChannelInfo * ci, char *param);
+int do_set_private(User * u, ChannelInfo * ci, char *param);
+int do_set_secureops(User * u, ChannelInfo * ci, char *param);
+int do_set_securefounder(User * u, ChannelInfo * ci, char *param);
+int do_set_restricted(User * u, ChannelInfo * ci, char *param);
+int do_set_secure(User * u, ChannelInfo * ci, char *param);
+int do_set_signkick(User * u, ChannelInfo * ci, char *param);
+int do_set_opnotice(User * u, ChannelInfo * ci, char *param);
+int do_set_xop(User * u, ChannelInfo * ci, char *param);
+int do_set_peace(User * u, ChannelInfo * ci, char *param);
+int do_set_noexpire(User * u, ChannelInfo * ci, char *param);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SET", do_set, NULL, CHAN_HELP_SET, -1, -1,
+ CHAN_SERVADMIN_HELP_SET, CHAN_SERVADMIN_HELP_SET);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET FOUNDER", NULL, NULL, CHAN_HELP_SET_FOUNDER, -1,
+ -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET SUCCESSOR", NULL, NULL, CHAN_HELP_SET_SUCCESSOR,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET PASSWORD", NULL, NULL, CHAN_HELP_SET_PASSWORD,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET DESC", NULL, NULL, CHAN_HELP_SET_DESC, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET URL", NULL, NULL, CHAN_HELP_SET_URL, -1, -1, -1,
+ -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET EMAIL", NULL, NULL, CHAN_HELP_SET_EMAIL, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET ENTRYMSG", NULL, NULL, CHAN_HELP_SET_ENTRYMSG,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET BANTYPE", NULL, NULL, CHAN_HELP_SET_BANTYPE, -1,
+ -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET PRIVATE", NULL, NULL, CHAN_HELP_SET_PRIVATE, -1,
+ -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET KEEPTOPIC", NULL, NULL, CHAN_HELP_SET_KEEPTOPIC,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET TOPICLOCK", NULL, NULL, CHAN_HELP_SET_TOPICLOCK,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET MLOCK", NULL, NULL, CHAN_HELP_SET_MLOCK, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET RESTRICTED", NULL, NULL,
+ CHAN_HELP_SET_RESTRICTED, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET SECURE", NULL, NULL, CHAN_HELP_SET_SECURE, -1,
+ -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET SECUREOPS", NULL, NULL, CHAN_HELP_SET_SECUREOPS,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET SECUREFOUNDER", NULL, NULL,
+ CHAN_HELP_SET_SECUREFOUNDER, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET SIGNKICK", NULL, NULL, CHAN_HELP_SET_SIGNKICK,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET OPNOTICE", NULL, NULL, CHAN_HELP_SET_OPNOTICE,
+ -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET XOP", NULL, NULL, CHAN_HELP_SET_XOP, -1, -1, -1,
+ -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET PEACE", NULL, NULL, CHAN_HELP_SET_PEACE, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SET NOEXPIRE", NULL, NULL, -1, -1, -1,
+ CHAN_SERVADMIN_HELP_SET_NOEXPIRE,
+ CHAN_SERVADMIN_HELP_SET_NOEXPIRE);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SET);
+}
+
+/**
+ * The /cs set command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+
+/* Main SET routine. Calls other routines as follows:
+ * do_set_command(User *command_sender, ChannelInfo *ci, char *param);
+ * The parameter passed is the first space-delimited parameter after the
+ * option name, except in the case of DESC, TOPIC, and ENTRYMSG, in which
+ * it is the entire remainder of the line. Additional parameters beyond
+ * the first passed in the function call can be retrieved using
+ * strtok(NULL, toks).
+ */
+int do_set(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *cmd = strtok(NULL, " ");
+ char *param;
+ ChannelInfo *ci;
+ int is_servadmin = is_services_admin(u);
+
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_SET_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (cmd) {
+ if (stricmp(cmd, "DESC") == 0 || stricmp(cmd, "ENTRYMSG") == 0)
+ param = strtok(NULL, "");
+ else
+ param = strtok(NULL, " ");
+ } else {
+ param = NULL;
+ }
+
+ if (!param && (!cmd || (stricmp(cmd, "SUCCESSOR") != 0 &&
+ stricmp(cmd, "URL") != 0 &&
+ stricmp(cmd, "EMAIL") != 0 &&
+ stricmp(cmd, "ENTRYMSG") != 0))) {
+ syntax_error(s_ChanServ, u, "SET", CHAN_SET_SYNTAX);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!is_servadmin && !check_access(u, ci, CA_SET)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (stricmp(cmd, "FOUNDER") == 0) {
+ if (!is_servadmin
+ && (ci->
+ flags & CI_SECUREFOUNDER ? !is_real_founder(u,
+ ci) :
+ !is_founder(u, ci))) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else {
+ do_set_founder(u, ci, param);
+ }
+ } else if (stricmp(cmd, "SUCCESSOR") == 0) {
+ if (!is_servadmin
+ && (ci->
+ flags & CI_SECUREFOUNDER ? !is_real_founder(u,
+ ci) :
+ !is_founder(u, ci))) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else {
+ do_set_successor(u, ci, param);
+ }
+ } else if (stricmp(cmd, "PASSWORD") == 0) {
+ if (!is_servadmin
+ && (ci->
+ flags & CI_SECUREFOUNDER ? !is_real_founder(u,
+ ci) :
+ !is_founder(u, ci))) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else {
+ do_set_password(u, ci, param);
+ }
+ } else if (stricmp(cmd, "DESC") == 0) {
+ do_set_desc(u, ci, param);
+ } else if (stricmp(cmd, "URL") == 0) {
+ do_set_url(u, ci, param);
+ } else if (stricmp(cmd, "EMAIL") == 0) {
+ do_set_email(u, ci, param);
+ } else if (stricmp(cmd, "ENTRYMSG") == 0) {
+ do_set_entrymsg(u, ci, param);
+ } else if (stricmp(cmd, "TOPIC") == 0) {
+ notice_lang(s_ChanServ, u, OBSOLETE_COMMAND, "TOPIC");
+ } else if (stricmp(cmd, "BANTYPE") == 0) {
+ do_set_bantype(u, ci, param);
+ } else if (stricmp(cmd, "MLOCK") == 0) {
+ do_set_mlock(u, ci, param);
+ } else if (stricmp(cmd, "KEEPTOPIC") == 0) {
+ do_set_keeptopic(u, ci, param);
+ } else if (stricmp(cmd, "TOPICLOCK") == 0) {
+ do_set_topiclock(u, ci, param);
+ } else if (stricmp(cmd, "PRIVATE") == 0) {
+ do_set_private(u, ci, param);
+ } else if (stricmp(cmd, "SECUREOPS") == 0) {
+ do_set_secureops(u, ci, param);
+ } else if (stricmp(cmd, "SECUREFOUNDER") == 0) {
+ if (!is_servadmin
+ && (ci->
+ flags & CI_SECUREFOUNDER ? !is_real_founder(u,
+ ci) :
+ !is_founder(u, ci))) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else {
+ do_set_securefounder(u, ci, param);
+ }
+ } else if (stricmp(cmd, "RESTRICTED") == 0) {
+ do_set_restricted(u, ci, param);
+ } else if (stricmp(cmd, "SECURE") == 0) {
+ do_set_secure(u, ci, param);
+ } else if (stricmp(cmd, "SIGNKICK") == 0) {
+ do_set_signkick(u, ci, param);
+ } else if (stricmp(cmd, "OPNOTICE") == 0) {
+ do_set_opnotice(u, ci, param);
+ } else if (stricmp(cmd, "XOP") == 0) {
+ do_set_xop(u, ci, param);
+ } else if (stricmp(cmd, "PEACE") == 0) {
+ do_set_peace(u, ci, param);
+ } else if (stricmp(cmd, "NOEXPIRE") == 0) {
+ do_set_noexpire(u, ci, param);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_SET_UNKNOWN_OPTION, cmd);
+ notice_lang(s_ChanServ, u, MORE_INFO, s_ChanServ, "SET");
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_founder(User * u, ChannelInfo * ci, char *param)
+{
+ NickAlias *na = findnick(param);
+ NickCore *nc, *nc0 = ci->founder;
+
+ if (!na) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param);
+ return MOD_CONT;
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param);
+ return MOD_CONT;
+ }
+
+ nc = na->nc;
+ if (nc->channelmax > 0 && nc->channelcount >= nc->channelmax
+ && !is_services_admin(u)) {
+ notice_lang(s_ChanServ, u, CHAN_SET_FOUNDER_TOO_MANY_CHANS, param);
+ return MOD_CONT;
+ }
+
+ alog("%s: Changing founder of %s from %s to %s by %s!%s@%s",
+ s_ChanServ, ci->name, ci->founder->display, nc->display, u->nick,
+ u->username, u->host);
+
+ /* Founder and successor must not be the same group */
+ if (nc == ci->successor)
+ ci->successor = NULL;
+
+ nc0->channelcount--;
+ ci->founder = nc;
+ nc->channelcount++;
+
+ notice_lang(s_ChanServ, u, CHAN_FOUNDER_CHANGED, ci->name, param);
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_successor(User * u, ChannelInfo * ci, char *param)
+{
+ NickAlias *na;
+ NickCore *nc;
+
+ if (param) {
+ na = findnick(param);
+
+ if (!na) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param);
+ return MOD_CONT;
+ }
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param);
+ return MOD_CONT;
+ }
+ if (na->nc == ci->founder) {
+ notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_IS_FOUNDER, param,
+ ci->name);
+ return MOD_CONT;
+ }
+ nc = na->nc;
+
+ } else {
+ nc = NULL;
+ }
+
+ alog("%s: Changing successor of %s from %s to %s by %s!%s@%s",
+ s_ChanServ, ci->name,
+ (ci->successor ? ci->successor->display : "none"),
+ (nc ? nc->display : "none"), u->nick, u->username, u->host);
+
+ ci->successor = nc;
+
+ if (nc)
+ notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_CHANGED, ci->name,
+ param);
+ else
+ notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_UNSET, ci->name);
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_password(User * u, ChannelInfo * ci, char *param)
+{
+ int len = strlen(param);
+
+ if (stricmp(u->nick, param) == 0 || (StrictPasswords && len < 5)) {
+ notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD);
+ return MOD_CONT;
+ }
+#ifdef USE_ENCRYPTION
+ if (len > PASSMAX) {
+ len = PASSMAX;
+ param[len] = 0;
+ notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX);
+ }
+
+ if (encrypt(param, len, ci->founderpass, PASSMAX) < 0) {
+ memset(param, 0, strlen(param));
+ alog("%s: Failed to encrypt password for %s (set)", s_ChanServ,
+ ci->name);
+ notice_lang(s_ChanServ, u, CHAN_SET_PASSWORD_FAILED);
+ return MOD_CONT;
+ }
+
+ memset(param, 0, strlen(param));
+ notice_lang(s_ChanServ, u, CHAN_PASSWORD_CHANGED, ci->name);
+
+#else /* !USE_ENCRYPTION */
+ if (strlen(param) > PASSMAX - 1) /* -1 for null byte */
+ notice_lang(s_ChanServ, u, PASSWORD_TRUNCATED, PASSMAX - 1);
+ strscpy(ci->founderpass, param, PASSMAX);
+ notice_lang(s_ChanServ, u, CHAN_PASSWORD_CHANGED_TO, ci->name,
+ ci->founderpass);
+#endif /* USE_ENCRYPTION */
+
+ if (get_access(u, ci) < ACCESS_FOUNDER) {
+ alog("%s: %s!%s@%s set password as Services admin for %s",
+ s_ChanServ, u->nick, u->username, u->host, ci->name);
+ if (WallSetpass)
+ anope_cmd_global(s_ChanServ,
+ "\2%s\2 set password as Services admin for channel \2%s\2",
+ u->nick, ci->name);
+ } else {
+ alog("%s: %s!%s@%s changed password of %s (founder: %s)",
+ s_ChanServ, u->nick, u->username, u->host,
+ ci->name, ci->founder->display);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_desc(User * u, ChannelInfo * ci, char *param)
+{
+ if (ci->desc)
+ free(ci->desc);
+ ci->desc = sstrdup(param);
+ notice_lang(s_ChanServ, u, CHAN_DESC_CHANGED, ci->name, param);
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_url(User * u, ChannelInfo * ci, char *param)
+{
+ if (ci->url)
+ free(ci->url);
+ if (param) {
+ ci->url = sstrdup(param);
+ notice_lang(s_ChanServ, u, CHAN_URL_CHANGED, ci->name, param);
+ } else {
+ ci->url = NULL;
+ notice_lang(s_ChanServ, u, CHAN_URL_UNSET, ci->name);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_email(User * u, ChannelInfo * ci, char *param)
+{
+ if (ci->email)
+ free(ci->email);
+ if (param) {
+ ci->email = sstrdup(param);
+ notice_lang(s_ChanServ, u, CHAN_EMAIL_CHANGED, ci->name, param);
+ } else {
+ ci->email = NULL;
+ notice_lang(s_ChanServ, u, CHAN_EMAIL_UNSET, ci->name);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_entrymsg(User * u, ChannelInfo * ci, char *param)
+{
+ if (ci->entry_message)
+ free(ci->entry_message);
+ if (param) {
+ ci->entry_message = sstrdup(param);
+ notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_CHANGED, ci->name,
+ param);
+ } else {
+ ci->entry_message = NULL;
+ notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_UNSET, ci->name);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_mlock(User * u, ChannelInfo * ci, char *param)
+{
+ int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */
+ unsigned char mode;
+ CBMode *cbm;
+
+ if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) {
+ notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED);
+ return MOD_CONT;
+ }
+
+ /* Reinitialize everything */
+ if (ircd->chanreg) {
+ ci->mlock_on = ircd->regmode;
+ } else {
+ ci->mlock_on = 0;
+ }
+ ci->mlock_off = ci->mlock_limit = 0;
+ ci->mlock_key = NULL;
+ if (ircd->fmode) {
+ ci->mlock_flood = NULL;
+ }
+ if (ircd->Lmode) {
+ ci->mlock_redirect = NULL;
+ }
+
+ while ((mode = *param++)) {
+ switch (mode) {
+ case '+':
+ add = 1;
+ continue;
+ case '-':
+ add = 0;
+ continue;
+ default:
+ if (add < 0)
+ continue;
+ }
+
+ if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) {
+ if ((cbm->flags & CBM_NO_MLOCK)
+ || ((cbm->flags & CBM_NO_USER_MLOCK) && !is_oper(u))) {
+ notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR,
+ mode);
+ } else if (add) {
+ ci->mlock_on |= cbm->flag;
+ ci->mlock_off &= ~cbm->flag;
+ if (cbm->cssetvalue)
+ cbm->cssetvalue(ci, strtok(NULL, " "));
+ } else {
+ ci->mlock_off |= cbm->flag;
+ if (ci->mlock_on & cbm->flag) {
+ ci->mlock_on &= ~cbm->flag;
+ if (cbm->cssetvalue)
+ cbm->cssetvalue(ci, NULL);
+ }
+ }
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_UNKNOWN_CHAR, mode);
+ }
+ } /* while (*param) */
+
+ if (ircd->Lmode) {
+ /* We can't mlock +L if +l is not mlocked as well. */
+ if ((ci->mlock_on & ircd->chan_lmode)
+ && !(ci->mlock_on & anope_get_limit_mode())) {
+ ci->mlock_on &= ~ircd->chan_lmode;
+ free(ci->mlock_redirect);
+ notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED);
+ }
+ }
+
+ /* Some ircd we can't set NOKNOCK without INVITE */
+ /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */
+ if (ircd->noknock && ircd->knock_needs_i) {
+ if ((ci->mlock_on & ircd->noknock)
+ && !(ci->mlock_on & anope_get_invite_mode())) {
+ ci->mlock_on &= ~ircd->noknock;
+ notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED);
+ }
+ }
+
+ /* Since we always enforce mode r there is no way to have no
+ * mode lock at all.
+ */
+ if (get_mlock_modes(ci, 0)) {
+ notice_lang(s_ChanServ, u, CHAN_MLOCK_CHANGED, ci->name,
+ get_mlock_modes(ci, 0));
+ }
+
+ /* Implement the new lock. */
+ if (ci->c)
+ check_modes(ci->c);
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_bantype(User * u, ChannelInfo * ci, char *param)
+{
+ char *endptr;
+
+ int16 bantype = strtol(param, &endptr, 10);
+
+ if (*endptr != 0 || bantype < 0 || bantype > 3) {
+ notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_INVALID, param);
+ } else {
+ ci->bantype = bantype;
+ notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_CHANGED, ci->name,
+ ci->bantype);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_keeptopic(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_KEEPTOPIC;
+ notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_KEEPTOPIC;
+ notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET KEEPTOPIC",
+ CHAN_SET_KEEPTOPIC_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_topiclock(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_TOPICLOCK;
+ notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_TOPICLOCK;
+ notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET TOPICLOCK",
+ CHAN_SET_TOPICLOCK_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_private(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_PRIVATE;
+ notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_PRIVATE;
+ notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET PRIVATE",
+ CHAN_SET_PRIVATE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_secureops(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_SECUREOPS;
+ notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_SECUREOPS;
+ notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET SECUREOPS",
+ CHAN_SET_SECUREOPS_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_securefounder(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_SECUREFOUNDER;
+ notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_SECUREFOUNDER;
+ notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET SECUREFOUNDER",
+ CHAN_SET_SECUREFOUNDER_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_restricted(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_RESTRICTED;
+ if (ci->levels[CA_NOJOIN] < 0)
+ ci->levels[CA_NOJOIN] = 0;
+ notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_RESTRICTED;
+ if (ci->levels[CA_NOJOIN] >= 0)
+ ci->levels[CA_NOJOIN] = -2;
+ notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET RESTRICTED",
+ CHAN_SET_RESTRICTED_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_secure(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_SECURE;
+ notice_lang(s_ChanServ, u, CHAN_SET_SECURE_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_SECURE;
+ notice_lang(s_ChanServ, u, CHAN_SET_SECURE_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET SECURE", CHAN_SET_SECURE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_signkick(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_SIGNKICK;
+ ci->flags &= ~CI_SIGNKICK_LEVEL;
+ notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_ON, ci->name);
+ } else if (stricmp(param, "LEVEL") == 0) {
+ ci->flags |= CI_SIGNKICK_LEVEL;
+ ci->flags &= ~CI_SIGNKICK;
+ notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_LEVEL, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~(CI_SIGNKICK | CI_SIGNKICK_LEVEL);
+ notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET SIGNKICK",
+ CHAN_SET_SIGNKICK_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_opnotice(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_OPNOTICE;
+ notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_OPNOTICE;
+ notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET OPNOTICE",
+ CHAN_SET_OPNOTICE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+#define CHECKLEV(lev) ((ci->levels[(lev)] != ACCESS_INVALID) && (access->level >= ci->levels[(lev)]))
+
+int do_set_xop(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ if (!(ci->flags & CI_XOP)) {
+ int i;
+ ChanAccess *access;
+
+ for (access = ci->access, i = 0; i < ci->accesscount;
+ access++, i++) {
+ if (!access->in_use)
+ continue;
+ /* This will probably cause wrong levels to be set, but hey,
+ * it's better than losing it altogether.
+ */
+ if (CHECKLEV(CA_AKICK) || CHECKLEV(CA_SET)) {
+ access->level = ACCESS_SOP;
+ } else if (CHECKLEV(CA_AUTOOP) || CHECKLEV(CA_OPDEOP)
+ || CHECKLEV(CA_OPDEOPME)) {
+ access->level = ACCESS_AOP;
+ } else if (ircd->halfop) {
+ if (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP)
+ || CHECKLEV(CA_HALFOPME)) {
+ access->level = ACCESS_HOP;
+ }
+ } else if (CHECKLEV(CA_AUTOVOICE) || CHECKLEV(CA_VOICE)
+ || CHECKLEV(CA_VOICEME)) {
+ access->level = ACCESS_VOP;
+ } else {
+ access->in_use = 0;
+ access->nc = NULL;
+ }
+ }
+
+ reset_levels(ci);
+ ci->flags |= CI_XOP;
+ }
+
+ alog("%s: %s!%s@%s enabled XOP for %s", s_ChanServ, u->nick,
+ u->username, u->host, ci->name);
+ notice_lang(s_ChanServ, u, CHAN_SET_XOP_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_XOP;
+
+ alog("%s: %s!%s@%s disabled XOP for %s", s_ChanServ, u->nick,
+ u->username, u->host, ci->name);
+ notice_lang(s_ChanServ, u, CHAN_SET_XOP_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET XOP", CHAN_SET_XOP_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+#undef CHECKLEV
+
+/*************************************************************************/
+
+int do_set_peace(User * u, ChannelInfo * ci, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_PEACE;
+ notice_lang(s_ChanServ, u, CHAN_SET_PEACE_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_PEACE;
+ notice_lang(s_ChanServ, u, CHAN_SET_PEACE_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET PEACE", CHAN_SET_PEACE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_set_noexpire(User * u, ChannelInfo * ci, char *param)
+{
+ if (!is_services_admin(u)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+ if (stricmp(param, "ON") == 0) {
+ ci->flags |= CI_NO_EXPIRE;
+ notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_ON, ci->name);
+ } else if (stricmp(param, "OFF") == 0) {
+ ci->flags &= ~CI_NO_EXPIRE;
+ notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_OFF, ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, "SET NOEXPIRE",
+ CHAN_SET_NOEXPIRE_SYNTAX);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_status.c b/src/core/cs_status.c
new file mode 100644
index 000000000..a8a847ff1
--- /dev/null
+++ b/src/core/cs_status.c
@@ -0,0 +1,102 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_status(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("STATUS", do_status, is_services_admin, -1, -1, -1,
+ CHAN_SERVADMIN_HELP_STATUS,
+ CHAN_SERVADMIN_HELP_STATUS);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_STATUS);
+ }
+}
+
+/**
+ * The /cs status command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_status(User * u)
+{
+ ChannelInfo *ci;
+ User *u2;
+ char *nick, *chan;
+ char *temp;
+
+ chan = strtok(NULL, " ");
+ nick = strtok(NULL, " ");
+ if (!nick || strtok(NULL, " ")) {
+ notice_lang(s_ChanServ, u, CHAN_STATUS_SYNTAX);
+ return MOD_CONT;
+ }
+ if (!(ci = cs_findchan(chan))) {
+ temp = chan;
+ chan = nick;
+ nick = temp;
+ ci = cs_findchan(chan);
+ }
+ if (!ci) {
+ notice_lang(s_ChanServ, u, CHAN_STATUS_NOT_REGGED, temp);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_STATUS_FORBIDDEN, chan);
+ return MOD_CONT;
+ } else if ((u2 = finduser(nick)) != NULL) {
+ notice_lang(s_ChanServ, u, CHAN_STATUS_INFO, chan, nick,
+ get_access(u2, ci));
+ } else { /* !u2 */
+ notice_lang(s_ChanServ, u, CHAN_STATUS_NOTONLINE, nick);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c
new file mode 100644
index 000000000..7abf9e730
--- /dev/null
+++ b/src/core/cs_suspend.c
@@ -0,0 +1,188 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_suspend(User * u);
+int do_unsuspend(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SUSPEND", do_suspend, is_services_admin, -1, -1, -1,
+ CHAN_SERVADMIN_HELP_SUSPEND,
+ CHAN_SERVADMIN_HELP_SUSPEND);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("UNSUSPEND", do_unsuspend, is_services_admin, -1, -1,
+ -1, CHAN_SERVADMIN_HELP_UNSUSPEND,
+ CHAN_SERVADMIN_HELP_UNSUSPEND);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SUSPEND);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_UNSUSPEND);
+ }
+}
+
+/**
+ * The /cs (un)suspend command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_suspend(User * u)
+{
+ ChannelInfo *ci;
+ char *chan = strtok(NULL, " ");
+ char *reason = strtok(NULL, "");
+
+ Channel *c;
+
+ /* Assumes that permission checking has already been done. */
+ if (!chan || (ForceForbidReason && !reason)) {
+ syntax_error(s_ChanServ, u, "SUSPEND",
+ (ForceForbidReason ? CHAN_SUSPEND_SYNTAX_REASON :
+ CHAN_SUSPEND_SYNTAX));
+ return MOD_CONT;
+ }
+
+ /* Only SUSPEND existing channels, otherwise use FORBID (bug #54) */
+ if ((ci = cs_findchan(chan)) == NULL) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ return MOD_CONT;
+ }
+
+ /* You should not SUSPEND a FORBIDEN channel */
+ if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
+ return MOD_CONT;
+ }
+
+ if (readonly)
+ notice_lang(s_ChanServ, u, READ_ONLY_MODE);
+
+ if (ci) {
+ ci->flags |= CI_SUSPENDED;
+ ci->forbidby = sstrdup(u->nick);
+ if (reason)
+ ci->forbidreason = sstrdup(reason);
+
+ if ((c = findchan(ci->name))) {
+ struct c_userlist *cu, *next;
+ char *av[3];
+
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+
+ if (is_oper(cu->user))
+ continue;
+
+ av[0] = c->name;
+ av[1] = cu->user->nick;
+ av[2] = reason ? reason : "CHAN_SUSPEND_REASON";
+ anope_cmd_kick(s_ChanServ, av[0], av[1], av[2]);
+ do_kick(s_ChanServ, 3, av);
+ }
+ }
+
+ if (WallForbid)
+ anope_cmd_global(s_ChanServ,
+ "\2%s\2 used SUSPEND on channel \2%s\2",
+ u->nick, ci->name);
+
+ alog("%s: %s set SUSPEND for channel %s", s_ChanServ, u->nick,
+ ci->name);
+ notice_lang(s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan);
+ send_event(EVENT_CHAN_SUSPENDED, 1, chan);
+ } else {
+ alog("%s: Valid SUSPEND for %s by %s failed", s_ChanServ, ci->name,
+ u->nick);
+ notice_lang(s_ChanServ, u, CHAN_SUSPEND_FAILED, chan);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_unsuspend(User * u)
+{
+ ChannelInfo *ci;
+ char *chan = strtok(NULL, " ");
+
+ /* Assumes that permission checking has already been done. */
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "UNSUSPEND", CHAN_UNSUSPEND_SYNTAX);
+ return MOD_CONT;
+ }
+ if (chan[0] != '#') {
+ notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_ERROR);
+ return MOD_CONT;
+ }
+ if (readonly)
+ notice_lang(s_ChanServ, u, READ_ONLY_MODE);
+
+ ci = cs_findchan(chan);
+
+ if (ci) {
+ ci->flags &= ~CI_SUSPENDED;
+ ci->forbidreason = NULL;
+ ci->forbidby = NULL;
+
+ if (WallForbid)
+ anope_cmd_global(s_ChanServ,
+ "\2%s\2 used UNSUSPEND on channel \2%s\2",
+ u->nick, ci->name);
+
+ alog("%s: %s set UNSUSPEND for channel %s", s_ChanServ, u->nick,
+ ci->name);
+ notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan);
+ send_event(EVENT_CHAN_UNSUSPEND, 1, chan);
+ } else {
+ alog("%s: Valid UNSUSPEND for %s by %s failed", s_ChanServ,
+ chan, u->nick);
+ notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_topic.c b/src/core/cs_topic.c
new file mode 100644
index 000000000..bd175cafe
--- /dev/null
+++ b/src/core/cs_topic.c
@@ -0,0 +1,119 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_cs_topic(User * u);
+void myChanServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("TOPIC", do_cs_topic, NULL, CHAN_HELP_TOPIC, -1, -1,
+ -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_TOPIC);
+}
+
+/**
+ * The /cs topic command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_cs_topic(User * u)
+{
+ char *chan = strtok(NULL, " ");
+ char *topic = strtok(NULL, "");
+
+ Channel *c;
+ ChannelInfo *ci;
+
+ if (!chan) {
+ syntax_error(s_ChanServ, u, "TOPIC", CHAN_TOPIC_SYNTAX);
+ } else if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
+ } else if (!is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ if (ci->last_topic)
+ free(ci->last_topic);
+ ci->last_topic = topic ? sstrdup(topic) : NULL;
+ strscpy(ci->last_topic_setter, u->nick, NICKMAX);
+ ci->last_topic_time = time(NULL);
+
+ if (c->topic)
+ free(c->topic);
+ c->topic = topic ? sstrdup(topic) : NULL;
+ strscpy(c->topic_setter, u->nick, NICKMAX);
+ if (ircd->topictsbackward) {
+ c->topic_time = c->topic_time - 1;
+ } else {
+ c->topic_time = ci->last_topic_time;
+ }
+
+ if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC))
+ alog("%s: %s!%s@%s changed topic of %s as services admin.",
+ s_ChanServ, u->nick, u->username, u->host, c->name);
+ if (ircd->join2set) {
+ if (whosends(ci) == s_ChanServ) {
+ anope_cmd_join(s_ChanServ, c->name, time(NULL));
+ anope_cmd_mode(NULL, c->name, "+o %s", s_ChanServ);
+ }
+ }
+ anope_cmd_topic(whosends(ci), c->name, u->nick, topic ? topic : "",
+ c->topic_time);
+ if (ircd->join2set) {
+ if (whosends(ci) == s_ChanServ) {
+ anope_cmd_part(s_ChanServ, c->name, NULL);
+ }
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c
new file mode 100644
index 000000000..9116d165c
--- /dev/null
+++ b/src/core/cs_xop.c
@@ -0,0 +1,474 @@
+/* ChanServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_xop(User * u, char *xname, int xlev, int *xmsgs);
+int do_aop(User * u);
+int do_hop(User * u);
+int do_sop(User * u);
+int do_vop(User * u);
+
+void myChanServHelp(User * u);
+
+int xop_msgs[4][14] = {
+ {CHAN_AOP_SYNTAX,
+ CHAN_AOP_DISABLED,
+ CHAN_AOP_NICKS_ONLY,
+ CHAN_AOP_ADDED,
+ CHAN_AOP_MOVED,
+ CHAN_AOP_NO_SUCH_ENTRY,
+ CHAN_AOP_NOT_FOUND,
+ CHAN_AOP_NO_MATCH,
+ CHAN_AOP_DELETED,
+ CHAN_AOP_DELETED_ONE,
+ CHAN_AOP_DELETED_SEVERAL,
+ CHAN_AOP_LIST_EMPTY,
+ CHAN_AOP_LIST_HEADER,
+ CHAN_AOP_CLEAR},
+ {CHAN_SOP_SYNTAX,
+ CHAN_SOP_DISABLED,
+ CHAN_SOP_NICKS_ONLY,
+ CHAN_SOP_ADDED,
+ CHAN_SOP_MOVED,
+ CHAN_SOP_NO_SUCH_ENTRY,
+ CHAN_SOP_NOT_FOUND,
+ CHAN_SOP_NO_MATCH,
+ CHAN_SOP_DELETED,
+ CHAN_SOP_DELETED_ONE,
+ CHAN_SOP_DELETED_SEVERAL,
+ CHAN_SOP_LIST_EMPTY,
+ CHAN_SOP_LIST_HEADER,
+ CHAN_SOP_CLEAR},
+ {CHAN_VOP_SYNTAX,
+ CHAN_VOP_DISABLED,
+ CHAN_VOP_NICKS_ONLY,
+ CHAN_VOP_ADDED,
+ CHAN_VOP_MOVED,
+ CHAN_VOP_NO_SUCH_ENTRY,
+ CHAN_VOP_NOT_FOUND,
+ CHAN_VOP_NO_MATCH,
+ CHAN_VOP_DELETED,
+ CHAN_VOP_DELETED_ONE,
+ CHAN_VOP_DELETED_SEVERAL,
+ CHAN_VOP_LIST_EMPTY,
+ CHAN_VOP_LIST_HEADER,
+ CHAN_VOP_CLEAR},
+ {CHAN_HOP_SYNTAX,
+ CHAN_HOP_DISABLED,
+ CHAN_HOP_NICKS_ONLY,
+ CHAN_HOP_ADDED,
+ CHAN_HOP_MOVED,
+ CHAN_HOP_NO_SUCH_ENTRY,
+ CHAN_HOP_NOT_FOUND,
+ CHAN_HOP_NO_MATCH,
+ CHAN_HOP_DELETED,
+ CHAN_HOP_DELETED_ONE,
+ CHAN_HOP_DELETED_SEVERAL,
+ CHAN_HOP_LIST_EMPTY,
+ CHAN_HOP_LIST_HEADER,
+ CHAN_HOP_CLEAR}
+};
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("AOP", do_aop, NULL, CHAN_HELP_AOP, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("HOP", do_hop, NULL, CHAN_HELP_HOP, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("SOP", do_sop, NULL, CHAN_HELP_SOP, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+ c = createCommand("VOP", do_vop, NULL, CHAN_HELP_VOP, -1, -1, -1, -1);
+ moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
+
+ moduleSetChanHelp(myChanServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /cs help output.
+ * @param u The user who is requesting help
+ **/
+void myChanServHelp(User * u)
+{
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SOP);
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_AOP);
+ if (ircd->halfop) {
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_HOP);
+ }
+ notice_lang(s_ChanServ, u, CHAN_HELP_CMD_VOP);
+}
+
+/**
+ * The /cs xop command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_aop(User * u)
+{
+ return do_xop(u, "AOP", ACCESS_AOP, xop_msgs[0]);
+}
+
+/*************************************************************************/
+
+int do_hop(User * u)
+{
+ return do_xop(u, "HOP", ACCESS_HOP, xop_msgs[3]);
+}
+
+/*************************************************************************/
+
+int do_sop(User * u)
+{
+ return do_xop(u, "SOP", ACCESS_SOP, xop_msgs[1]);
+}
+
+/*************************************************************************/
+
+int do_vop(User * u)
+{
+ return do_xop(u, "VOP", ACCESS_VOP, xop_msgs[2]);
+}
+
+/* `last' is set to the last index this routine was called with
+ * `perm' is incremented whenever a permission-denied error occurs
+ */
+
+int xop_del(User * u, ChanAccess * access, int *perm, int uacc, int xlev)
+{
+ if (!access->in_use || access->level != xlev)
+ return 0;
+ if (!is_services_admin(u) && uacc <= access->level) {
+ (*perm)++;
+ return 0;
+ }
+ access->nc = NULL;
+ access->in_use = 0;
+ return 1;
+}
+
+int xop_del_callback(User * u, int num, va_list args)
+{
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *last = va_arg(args, int *);
+ int *perm = va_arg(args, int *);
+ int uacc = va_arg(args, int);
+ int xlev = va_arg(args, int);
+
+ if (num < 1 || num > ci->accesscount)
+ return 0;
+ *last = num;
+
+ return xop_del(u, &ci->access[num - 1], perm, uacc, xlev);
+}
+
+
+int xop_list(User * u, int index, ChannelInfo * ci,
+ int *sent_header, int xlev, int xmsg)
+{
+ ChanAccess *access = &ci->access[index];
+
+ if (!access->in_use || access->level != xlev)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_ChanServ, u, xmsg, ci->name);
+ *sent_header = 1;
+ }
+
+ notice_lang(s_ChanServ, u, CHAN_XOP_LIST_FORMAT, index + 1,
+ access->nc->display);
+ return 1;
+}
+
+int xop_list_callback(User * u, int num, va_list args)
+{
+ ChannelInfo *ci = va_arg(args, ChannelInfo *);
+ int *sent_header = va_arg(args, int *);
+ int xlev = va_arg(args, int);
+ int xmsg = va_arg(args, int);
+
+ if (num < 1 || num > ci->accesscount)
+ return 0;
+
+ return xop_list(u, num - 1, ci, sent_header, xlev, xmsg);
+}
+
+
+int do_xop(User * u, char *xname, int xlev, int *xmsgs)
+{
+ char *chan = strtok(NULL, " ");
+ char *cmd = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+
+ ChannelInfo *ci;
+ NickAlias *na;
+ NickCore *nc;
+
+ int i;
+ int change = 0;
+ short ulev;
+ int is_list = (cmd && stricmp(cmd, "LIST") == 0);
+ int is_servadmin = is_services_admin(u);
+ ChanAccess *access;
+
+ /* If CLEAR, we don't need any parameters.
+ * If LIST, we don't *require* any parameters, but we can take any.
+ * If DEL or ADD we require a nick. */
+ if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 : !nick)) {
+ syntax_error(s_ChanServ, u, xname, xmsgs[0]);
+ } else if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
+ } else if (!(ci->flags & CI_XOP)) {
+ notice_lang(s_ChanServ, u, CHAN_XOP_ACCESS, s_ChanServ);
+ } else if (stricmp(cmd, "ADD") == 0) {
+ if (readonly) {
+ notice_lang(s_ChanServ, u, xmsgs[1]);
+ return MOD_CONT;
+ }
+
+ ulev = get_access(u, ci);
+
+ if ((xlev >= ulev || ulev < ACCESS_AOP) && !is_servadmin) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ na = findnick(nick);
+ if (!na) {
+ notice_lang(s_ChanServ, u, xmsgs[2]);
+ return MOD_CONT;
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, na->nick);
+ return MOD_CONT;
+ }
+
+ nc = na->nc;
+ for (access = ci->access, i = 0; i < ci->accesscount;
+ access++, i++) {
+ if (access->nc == nc) {
+ /**
+ * Patch provided by PopCorn to prevert AOP's reducing SOP's levels
+ **/
+ if ((access->level >= ulev) && (!is_servadmin)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+ change++;
+ break;
+ }
+ }
+
+ if (!change) {
+ for (i = 0; i < ci->accesscount; i++)
+ if (!ci->access[i].in_use)
+ break;
+
+ if (i == ci->accesscount) {
+ if (i < CSAccessMax) {
+ ci->accesscount++;
+ ci->access =
+ srealloc(ci->access,
+ sizeof(ChanAccess) * ci->accesscount);
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_XOP_REACHED_LIMIT,
+ CSAccessMax);
+ return MOD_CONT;
+ }
+ }
+
+ access = &ci->access[i];
+ access->nc = nc;
+ }
+
+ access->in_use = 1;
+ access->level = xlev;
+ access->last_seen = 0;
+
+ alog("%s: %s!%s@%s (level %d) %s access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, change ? "changed" : "set", access->level, na->nick, nc->display, ci->name);
+
+ if (!change) {
+ notice_lang(s_ChanServ, u, xmsgs[3], access->nc->display,
+ ci->name);
+ } else {
+ notice_lang(s_ChanServ, u, xmsgs[4], access->nc->display,
+ ci->name);
+ }
+
+ } else if (stricmp(cmd, "DEL") == 0) {
+ int deleted, a, b;
+ if (readonly) {
+ notice_lang(s_ChanServ, u, xmsgs[1]);
+ return MOD_CONT;
+ }
+
+ if (ci->accesscount == 0) {
+ notice_lang(s_ChanServ, u, xmsgs[11], chan);
+ return MOD_CONT;
+ }
+
+ ulev = get_access(u, ci);
+
+ /* Special case: is it a number/list? Only do search if it isn't. */
+ if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) {
+ int count, last = -1, perm = 0;
+ deleted =
+ process_numlist(nick, &count, xop_del_callback, u, ci,
+ &last, &perm, ulev, xlev);
+ if (!deleted) {
+ if (perm) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else if (count == 1) {
+ notice_lang(s_ChanServ, u, xmsgs[5], last, ci->name);
+ } else {
+ notice_lang(s_ChanServ, u, xmsgs[7], ci->name);
+ }
+ } else if (deleted == 1) {
+ notice_lang(s_ChanServ, u, xmsgs[9], ci->name);
+ } else {
+ notice_lang(s_ChanServ, u, xmsgs[10], deleted, ci->name);
+ }
+ } else {
+ na = findnick(nick);
+ if (!na) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, nick);
+ return MOD_CONT;
+ }
+ nc = na->nc;
+
+ for (i = 0; i < ci->accesscount; i++)
+ if (ci->access[i].nc == nc && ci->access[i].level == xlev)
+ break;
+
+ if (i == ci->accesscount) {
+ notice_lang(s_ChanServ, u, xmsgs[6], nick, chan);
+ return MOD_CONT;
+ }
+
+ access = &ci->access[i];
+ if (!is_servadmin && ulev <= access->level) {
+ deleted = 0;
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ notice_lang(s_ChanServ, u, xmsgs[8], access->nc->display,
+ ci->name);
+ access->nc = NULL;
+ access->in_use = 0;
+ deleted = 1;
+ }
+ }
+ if (deleted) {
+ /* Reordering - DrStein */
+ for (b = 0; b < ci->accesscount; b++) {
+ if (ci->access[b].in_use) {
+ for (a = 0; a < ci->accesscount; a++) {
+ if (a > b)
+ break;
+ if (!ci->access[a].in_use) {
+ ci->access[a].in_use = 1;
+ ci->access[a].level = ci->access[b].level;
+ ci->access[a].nc = ci->access[b].nc;
+ ci->access[a].last_seen =
+ ci->access[b].last_seen;
+ ci->access[b].nc = NULL;
+ ci->access[b].in_use = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ } else if (stricmp(cmd, "LIST") == 0) {
+ int sent_header = 0;
+
+ ulev = get_access(u, ci);
+
+ if (!is_servadmin && ulev < ACCESS_AOP) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ return MOD_CONT;
+ }
+
+ if (ci->accesscount == 0) {
+ notice_lang(s_ChanServ, u, xmsgs[11], ci->name);
+ return MOD_CONT;
+ }
+
+ if (nick && strspn(nick, "1234567890,-") == strlen(nick)) {
+ process_numlist(nick, NULL, xop_list_callback, u, ci,
+ &sent_header, xlev, xmsgs[12]);
+ } else {
+ for (i = 0; i < ci->accesscount; i++) {
+ if (nick && ci->access[i].nc
+ && !match_wild_nocase(nick, ci->access[i].nc->display))
+ continue;
+ xop_list(u, i, ci, &sent_header, xlev, xmsgs[12]);
+ }
+ }
+ if (!sent_header)
+ notice_lang(s_ChanServ, u, xmsgs[7], chan);
+ } else if (stricmp(cmd, "CLEAR") == 0) {
+ if (readonly) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (ci->accesscount == 0) {
+ notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
+ return MOD_CONT;
+ }
+
+ if (!is_servadmin && !is_founder(u, ci)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ for (i = 0; i < ci->accesscount; i++) {
+ if (ci->access[i].in_use && ci->access[i].level == xlev) {
+ ci->access[i].nc = NULL;
+ ci->access[i].in_use = 0;
+ }
+ }
+
+ notice_lang(s_ChanServ, u, xmsgs[13], ci->name);
+ } else {
+ syntax_error(s_ChanServ, u, xname, xmsgs[0]);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/he_help.c b/src/core/he_help.c
new file mode 100644
index 000000000..0a96507ab
--- /dev/null
+++ b/src/core/he_help.c
@@ -0,0 +1,76 @@
+/* HelpServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_help(User * u);
+
+/**
+ * Create the help command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(HELPSERV, c, MOD_UNIQUE);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Display the HelpServ help.
+ * This core function has been embed in the source for a long time, but
+ * it moved into it's own file so we now all can enjoy the joy of
+ * modules for HelpServ.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ */
+int do_help(User * u)
+{
+ char *cmd = strtok(NULL, "");
+
+ if (!cmd) {
+ notice_help(s_HelpServ, u, HELP_HELP, s_NickServ, s_ChanServ,
+ s_MemoServ);
+ if (s_BotServ) {
+ notice_help(s_HelpServ, u, HELP_HELP_BOT, s_BotServ);
+ }
+ if (s_HostServ) {
+ notice_help(s_HelpServ, u, HELP_HELP_HOST, s_HostServ);
+ }
+ moduleDisplayHelp(7, u);
+ } else {
+ mod_help_cmd(s_HelpServ, u, HELPSERV, cmd);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/hs_del.c b/src/core/hs_del.c
new file mode 100644
index 000000000..93bc09551
--- /dev/null
+++ b/src/core/hs_del.c
@@ -0,0 +1,91 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_del(User * u);
+void myHostServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("DEL", do_del, is_host_remover, HOST_HELP_DEL, -1,
+ -1, -1, -1);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+
+ moduleSetHostHelp(myHostServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myHostServHelp(User * u)
+{
+ if (is_host_remover(u)) {
+ notice_lang(s_HostServ, u, HOST_HELP_CMD_DEL);
+ }
+}
+
+/**
+ * The /hs del command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_del(User * u)
+{
+ NickAlias *na;
+ char *nick = strtok(NULL, " ");
+ if (nick) {
+ if ((na = findnick(nick))) {
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
+ return MOD_CONT;
+ }
+ alog("vHost for user \002%s\002 deleted by oper \002%s\002",
+ nick, u->nick);
+ delHostCore(nick);
+ notice_lang(s_HostServ, u, HOST_DEL, nick);
+ } else {
+ notice_lang(s_HostServ, u, HOST_NOREG, nick);
+ }
+ } else {
+ notice_lang(s_HostServ, u, HOST_DEL_SYNTAX, s_HostServ);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/hs_delall.c b/src/core/hs_delall.c
new file mode 100644
index 000000000..4571c5aca
--- /dev/null
+++ b/src/core/hs_delall.c
@@ -0,0 +1,96 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_delall(User * u);
+void myHostServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("DELALL", do_delall, is_host_remover,
+ HOST_HELP_DELALL, -1, -1, -1, -1);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+
+ moduleSetHostHelp(myHostServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myHostServHelp(User * u)
+{
+ if (is_host_remover(u)) {
+ notice_lang(s_HostServ, u, HOST_HELP_CMD_DELALL);
+ }
+}
+
+/**
+ * The /hs delall command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_delall(User * u)
+{
+ int i;
+ char *nick = strtok(NULL, " ");
+ NickAlias *na;
+ NickCore *nc;
+ if (!nick) {
+ notice_lang(s_HostServ, u, HOST_DELALL_SYNTAX, s_HostServ);
+ return MOD_CONT;
+ }
+ if ((na = findnick(nick))) {
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
+ return MOD_CONT;
+ }
+ nc = na->nc;
+ for (i = 0; i < nc->aliases.count; i++) {
+ na = nc->aliases.list[i];
+ delHostCore(na->nick);
+ }
+ alog("vHosts for all nicks in group \002%s\002 deleted by oper \002%s\002", nc->display, u->nick);
+ notice_lang(s_HostServ, u, HOST_DELALL, nc->display);
+ } else {
+ notice_lang(s_HostServ, u, HOST_NOREG, nick);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/hs_group.c b/src/core/hs_group.c
new file mode 100644
index 000000000..db034a948
--- /dev/null
+++ b/src/core/hs_group.c
@@ -0,0 +1,121 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_group(User * u);
+void myHostServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("GROUP", do_group, NULL, HOST_HELP_GROUP, -1, -1, -1,
+ -1);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+
+ moduleSetHostHelp(myHostServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myHostServHelp(User * u)
+{
+ notice_lang(s_HostServ, u, HOST_HELP_CMD_GROUP);
+}
+
+/**
+ * The /hs group command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_group(User * u)
+{
+ NickAlias *na;
+ HostCore *tmp;
+ char *vHost = NULL;
+ char *vIdent = NULL;
+ char *creator = NULL;
+ HostCore *head = NULL;
+ time_t time;
+ boolean found = false;
+
+ head = hostCoreListHead();
+
+ if ((na = findnick(u->nick))) {
+ if (na->status & NS_IDENTIFIED) {
+
+ tmp = findHostCore(head, u->nick, &found);
+ if (found) {
+ if (tmp == NULL) {
+ tmp = head; /* incase first in list */
+ } else if (tmp->next) { /* we dont want the previous entry were not inserting! */
+ tmp = tmp->next; /* jump to the next */
+ }
+
+ vHost = sstrdup(tmp->vHost);
+ if (tmp->vIdent)
+ vIdent = sstrdup(tmp->vIdent);
+ creator = sstrdup(tmp->creator);
+ time = tmp->time;
+
+ do_hs_sync(na->nc, vIdent, vHost, creator, time);
+ if (tmp->vIdent) {
+ notice_lang(s_HostServ, u, HOST_IDENT_GROUP,
+ na->nc->display, vIdent, vHost);
+ } else {
+ notice_lang(s_HostServ, u, HOST_GROUP, na->nc->display,
+ vHost);
+ }
+ free(vHost);
+ if (vIdent)
+ free(vIdent);
+ free(creator);
+
+ } else {
+ notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
+ }
+ } else {
+ notice_lang(s_HostServ, u, HOST_ID);
+ }
+ } else {
+ notice_lang(s_HostServ, u, HOST_NOT_REGED);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/hs_help.c b/src/core/hs_help.c
new file mode 100644
index 000000000..084bd3434
--- /dev/null
+++ b/src/core/hs_help.c
@@ -0,0 +1,66 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_help(User * u);
+
+/**
+ * Create the help command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * The /hs help command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_help(User * u)
+{
+ char *cmd = strtok(NULL, "");
+
+ if (!cmd) {
+ notice_help(s_HostServ, u, HOST_HELP, s_HostServ);
+ moduleDisplayHelp(6, u);
+ } else {
+ mod_help_cmd(s_HostServ, u, HOSTSERV, cmd);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/hs_list.c b/src/core/hs_list.c
new file mode 100644
index 000000000..c8d096db7
--- /dev/null
+++ b/src/core/hs_list.c
@@ -0,0 +1,179 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int listOut(User * u);
+void myHostServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("LIST", listOut, is_services_oper, -1, -1,
+ HOST_HELP_LIST, HOST_HELP_LIST, HOST_HELP_LIST);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+ moduleSetHostHelp(myHostServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myHostServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_HostServ, u, HOST_HELP_CMD_LIST);
+ }
+}
+
+/**
+ * The /hs list command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int listOut(User * u)
+{
+ char *key = strtok(NULL, "");
+ struct tm *tm;
+ char buf[BUFSIZE];
+ int counter = 1;
+ int from = 0, to = 0;
+ char *tmp = NULL;
+ char *s = NULL;
+ int display_counter = 0;
+ HostCore *head = NULL;
+ HostCore *current;
+
+ head = hostCoreListHead();
+
+ current = head;
+ if (current == NULL)
+ notice_lang(s_HostServ, u, HOST_EMPTY);
+ else {
+ /**
+ * Do a check for a range here, then in the next loop
+ * we'll only display what has been requested..
+ **/
+ if (key) {
+ if (key[0] == '#') {
+ tmp = myStrGetOnlyToken((key + 1), '-', 0); /* Read FROM out */
+ if (!tmp) {
+ return MOD_CONT;
+ }
+ for (s = tmp; *s; s++) {
+ if (!isdigit(*s)) {
+ return MOD_CONT;
+ }
+ }
+ from = atoi(tmp);
+ tmp = myStrGetTokenRemainder(key, '-', 1); /* Read TO out */
+ if (!tmp) {
+ return MOD_CONT;
+ }
+ for (s = tmp; *s; s++) {
+ if (!isdigit(*s)) {
+ return MOD_CONT;
+ }
+ }
+ to = atoi(tmp);
+ key = NULL;
+ }
+ }
+
+ while (current != NULL) {
+ if (key) {
+ if (((match_wild_nocase(key, current->nick))
+ || (match_wild_nocase(key, current->vHost)))
+ && (display_counter < NSListMax)) {
+ display_counter++;
+ tm = localtime(&current->time);
+ strftime_lang(buf, sizeof(buf), u,
+ STRFTIME_DATE_TIME_FORMAT, tm);
+ if (current->vIdent) {
+ notice_lang(s_HostServ, u, HOST_IDENT_ENTRY,
+ counter, current->nick,
+ current->vIdent, current->vHost,
+ current->creator, buf);
+ } else {
+ notice_lang(s_HostServ, u, HOST_ENTRY, counter,
+ current->nick, current->vHost,
+ current->creator, buf);
+ }
+ }
+ } else {
+ /**
+ * List the host if its in the display range, and not more
+ * than NSListMax records have been displayed...
+ **/
+ if ((((counter >= from) && (counter <= to))
+ || ((from == 0) && (to == 0)))
+ && (display_counter < NSListMax)) {
+ display_counter++;
+ tm = localtime(&current->time);
+ strftime_lang(buf, sizeof(buf), u,
+ STRFTIME_DATE_TIME_FORMAT, tm);
+ if (current->vIdent) {
+ notice_lang(s_HostServ, u, HOST_IDENT_ENTRY,
+ counter, current->nick,
+ current->vIdent, current->vHost,
+ current->creator, buf);
+ } else {
+ notice_lang(s_HostServ, u, HOST_ENTRY, counter,
+ current->nick, current->vHost,
+ current->creator, buf);
+ }
+ }
+ }
+ counter++;
+ current = current->next;
+ }
+ if (key) {
+ notice_lang(s_HostServ, u, HOST_LIST_KEY_FOOTER, key,
+ display_counter);
+ } else {
+ if (from != 0) {
+ notice_lang(s_HostServ, u, HOST_LIST_RANGE_FOOTER, from,
+ to);
+ } else {
+ notice_lang(s_HostServ, u, HOST_LIST_FOOTER,
+ display_counter);
+ }
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/hs_off.c b/src/core/hs_off.c
new file mode 100644
index 000000000..e3785e7ad
--- /dev/null
+++ b/src/core/hs_off.c
@@ -0,0 +1,87 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_off(User * u);
+void myHostServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("OFF", do_off, NULL, HOST_HELP_OFF, -1, -1, -1, -1);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+
+ moduleSetHostHelp(myHostServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myHostServHelp(User * u)
+{
+ notice_lang(s_HostServ, u, HOST_HELP_CMD_OFF);
+}
+
+/**
+ * The /hs off command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_off(User * u)
+{
+ NickAlias *na;
+ char *vhost;
+ char *vident = NULL;
+ if ((na = findnick(u->nick))) {
+ if (na->status & NS_IDENTIFIED) {
+ vhost = getvHost(u->nick);
+ vident = getvIdent(u->nick);
+ if (vhost == NULL && vident == NULL)
+ notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
+ else
+ anope_cmd_vhost_off(u);
+ } else {
+ notice_lang(s_HostServ, u, HOST_ID);
+ }
+ } else {
+ notice_lang(s_HostServ, u, HOST_NOT_REGED);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/hs_on.c b/src/core/hs_on.c
new file mode 100644
index 000000000..7421eec7d
--- /dev/null
+++ b/src/core/hs_on.c
@@ -0,0 +1,102 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_on(User * u);
+void myHostServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("ON", do_on, NULL, HOST_HELP_ON, -1, -1, -1, -1);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+
+ moduleSetHostHelp(myHostServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myHostServHelp(User * u)
+{
+ notice_lang(s_HostServ, u, HOST_HELP_CMD_ON);
+}
+
+/**
+ * The /hs on command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_on(User * u)
+{
+ NickAlias *na;
+ char *vHost;
+ char *vIdent = NULL;
+ if ((na = findnick(u->nick))) {
+ if (na->status & NS_IDENTIFIED) {
+ vHost = getvHost(u->nick);
+ vIdent = getvIdent(u->nick);
+ if (vHost == NULL) {
+ notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
+ } else {
+ if (vIdent) {
+ notice_lang(s_HostServ, u, HOST_IDENT_ACTIVATED,
+ vIdent, vHost);
+ } else {
+ notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost);
+ }
+ anope_cmd_vhost_on(u->nick, vIdent, vHost);
+ if (ircd->vhost) {
+ u->vhost = sstrdup(vHost);
+ }
+ if (ircd->vident) {
+ if (vIdent)
+ u->vident = sstrdup(vIdent);
+ }
+ set_lastmask(u);
+ }
+ } else {
+ notice_lang(s_HostServ, u, HOST_ID);
+ }
+ } else {
+ notice_lang(s_HostServ, u, HOST_NOT_REGED);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/hs_set.c b/src/core/hs_set.c
new file mode 100644
index 000000000..f62491414
--- /dev/null
+++ b/src/core/hs_set.c
@@ -0,0 +1,147 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int myDoSet(User * u);
+void myHostServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SET", myDoSet, is_host_setter, HOST_HELP_SET, -1,
+ -1, -1, -1);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+
+ moduleSetHostHelp(myHostServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myHostServHelp(User * u)
+{
+ if (is_host_setter(u)) {
+ notice_lang(s_HostServ, u, HOST_HELP_CMD_SET);
+ }
+}
+
+/**
+ * The /hs set command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int myDoSet(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ char *rawhostmask = strtok(NULL, " ");
+ char *hostmask = smalloc(HOSTMAX);
+
+ NickAlias *na;
+ int32 tmp_time;
+ char *s;
+
+ char *vIdent = NULL;
+
+ if (!nick || !rawhostmask) {
+ notice_lang(s_HostServ, u, HOST_SET_SYNTAX, s_HostServ);
+ return MOD_CONT;
+ }
+
+ vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */
+ if (vIdent) {
+ rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */
+ if (!rawhostmask) {
+ notice_lang(s_HostServ, u, HOST_SET_SYNTAX, s_HostServ);
+ return MOD_CONT;
+ }
+ if (strlen(vIdent) > USERMAX - 1) {
+ notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX);
+ return MOD_CONT;
+ } else {
+ for (s = vIdent; *s; s++) {
+ if (!isvalidchar(*s)) {
+ notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR);
+ return MOD_CONT;
+ }
+ }
+ }
+ if (!ircd->vident) {
+ notice_lang(s_HostServ, u, HOST_NO_VIDENT);
+ return MOD_CONT;
+ }
+ }
+ if (strlen(rawhostmask) < HOSTMAX - 1)
+ snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask);
+ else {
+ notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX);
+ return MOD_CONT;
+ }
+
+ if (!isValidHost(hostmask, 3)) {
+ notice_lang(s_HostServ, u, HOST_SET_ERROR);
+ return MOD_CONT;
+ }
+
+
+ tmp_time = time(NULL);
+
+ if ((na = findnick(nick))) {
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
+ return MOD_CONT;
+ }
+ if (vIdent && ircd->vident) {
+ alog("vHost for user \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick);
+ } else {
+ alog("vHost for user \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick);
+ }
+ addHostCore(nick, vIdent, hostmask, u->nick, tmp_time);
+ if (vIdent) {
+ notice_lang(s_HostServ, u, HOST_IDENT_SET, nick, vIdent,
+ hostmask);
+ } else {
+ notice_lang(s_HostServ, u, HOST_SET, nick, hostmask);
+ }
+ } else {
+ notice_lang(s_HostServ, u, HOST_NOREG, nick);
+ }
+ free(hostmask);
+ return MOD_CONT;
+}
diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c
new file mode 100644
index 000000000..a0685a89f
--- /dev/null
+++ b/src/core/hs_setall.c
@@ -0,0 +1,150 @@
+/* HostServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_setall(User * u);
+void myHostServHelp(User * u);
+
+/**
+ * Create the off command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SETALL", do_setall, is_host_setter,
+ HOST_HELP_SETALL, -1, -1, -1, -1);
+ moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
+ moduleSetHostHelp(myHostServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myHostServHelp(User * u)
+{
+ if (is_host_setter(u)) {
+ notice_lang(s_HostServ, u, HOST_HELP_CMD_SETALL);
+ }
+}
+
+/**
+ * The /hs setall command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_setall(User * u)
+{
+
+ char *nick = strtok(NULL, " ");
+ char *rawhostmask = strtok(NULL, " ");
+ char *hostmask = smalloc(HOSTMAX);
+
+ NickAlias *na;
+ int32 tmp_time;
+ char *s;
+
+ char *vIdent = NULL;
+
+ if (!nick || !rawhostmask) {
+ notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ);
+ return MOD_CONT;
+ }
+
+ vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */
+ if (vIdent) {
+ rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */
+ if (!rawhostmask) {
+ notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ);
+ return MOD_CONT;
+ }
+ if (strlen(vIdent) > USERMAX - 1) {
+ notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX);
+ return MOD_CONT;
+ } else {
+ for (s = vIdent; *s; s++) {
+ if (!isvalidchar(*s)) {
+ notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR);
+ return MOD_CONT;
+ }
+ }
+ }
+ if (!ircd->vident) {
+ notice_lang(s_HostServ, u, HOST_NO_VIDENT);
+ return MOD_CONT;
+ }
+ }
+
+ if (strlen(rawhostmask) < HOSTMAX - 1)
+ snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask);
+ else {
+ notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX);
+ return MOD_CONT;
+ }
+
+ if (!isValidHost(hostmask, 3)) {
+ notice_lang(s_HostServ, u, HOST_SET_ERROR);
+ free(hostmask);
+ return MOD_CONT;
+ }
+
+ tmp_time = time(NULL);
+
+ if ((na = findnick(nick))) {
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
+ free(hostmask);
+ return MOD_CONT;
+ }
+ if (vIdent && ircd->vident) {
+ alog("vHost for all nicks in group \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick);
+ } else {
+ alog("vHost for all nicks in group \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick);
+ }
+ do_hs_sync(na->nc, vIdent, hostmask, u->nick, tmp_time);
+ if (vIdent) {
+ notice_lang(s_HostServ, u, HOST_IDENT_SETALL, nick, vIdent,
+ hostmask);
+ } else {
+ notice_lang(s_HostServ, u, HOST_SETALL, nick, hostmask);
+ }
+ } else {
+ notice_lang(s_HostServ, u, HOST_NOREG, nick);
+ }
+
+ free(hostmask);
+ return MOD_CONT;
+}
diff --git a/src/core/ms_cancel.c b/src/core/ms_cancel.c
new file mode 100644
index 000000000..8def3b2da
--- /dev/null
+++ b/src/core/ms_cancel.c
@@ -0,0 +1,105 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_cancel(User * u);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the cancel command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("CANCEL", do_cancel, NULL, MEMO_HELP_CANCEL, -1, -1,
+ -1, -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_CANCEL);
+}
+
+/**
+ * The /ms cancel command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_cancel(User * u)
+{
+ int ischan;
+ int isforbid;
+ char *name = strtok(NULL, " ");
+ MemoInfo *mi;
+
+ if (!name) {
+ syntax_error(s_MemoServ, u, "CANCEL", MEMO_CANCEL_SYNTAX);
+
+ } else if (!nick_recognized(u)) {
+ notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+
+ } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) {
+ if (isforbid) {
+ notice_lang(s_MemoServ, u,
+ ischan ? CHAN_X_FORBIDDEN :
+ NICK_X_FORBIDDEN, name);
+ } else {
+ notice_lang(s_MemoServ, u,
+ ischan ? CHAN_X_NOT_REGISTERED :
+ NICK_X_NOT_REGISTERED, name);
+ }
+ } else {
+ int i;
+
+ for (i = mi->memocount - 1; i >= 0; i--) {
+ if ((mi->memos[i].flags & MF_UNREAD)
+ && !stricmp(mi->memos[i].sender, u->na->nc->display)
+ && (!(mi->memos[i].flags & MF_NOTIFYS))) {
+ delmemo(mi, mi->memos[i].number);
+ notice_lang(s_MemoServ, u, MEMO_CANCELLED, name);
+ return MOD_CONT;
+ }
+ }
+
+ notice_lang(s_MemoServ, u, MEMO_CANCEL_NONE);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ms_check.c b/src/core/ms_check.c
new file mode 100644
index 000000000..a236ae0a5
--- /dev/null
+++ b/src/core/ms_check.c
@@ -0,0 +1,118 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_memocheck(User * u);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("CHECK", do_memocheck, NULL, MEMO_HELP_CHECK, -1, -1,
+ -1, -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_CHECK);
+}
+
+/**
+ * The /ms check command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_memocheck(User * u)
+{
+ NickAlias *na = NULL;
+ MemoInfo *mi = NULL;
+ int i, found = 0;
+ char *recipient = strtok(NULL, "");
+ struct tm *tm;
+ char timebuf[64];
+
+ if (!recipient) {
+ syntax_error(s_MemoServ, u, "CHECK", MEMO_CHECK_SYNTAX);
+ return MOD_CONT;
+ } else if (!nick_recognized(u)) {
+ notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ return MOD_CONT;
+ } else if (!(na = findnick(recipient))) {
+ notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, recipient);
+ return MOD_CONT;
+ }
+
+ if ((na->status & NS_VERBOTEN)) {
+ notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, recipient);
+ return MOD_CONT;
+ }
+
+ mi = &na->nc->memos;
+
+/* Okay, I know this looks strange but we wanna get the LAST memo, so we
+ have to loop backwards */
+
+ for (i = (mi->memocount - 1); i >= 0; i--) {
+ if (!stricmp(mi->memos[i].sender, u->na->nc->display)) {
+ found = 1; /* Yes, we've found the memo */
+
+ tm = localtime(&mi->memos[i].time);
+ strftime_lang(timebuf, sizeof(timebuf), u,
+ STRFTIME_DATE_TIME_FORMAT, tm);
+
+ if (mi->memos[i].flags & MF_UNREAD)
+ notice_lang(s_MemoServ, u, MEMO_CHECK_NOT_READ, na->nick,
+ timebuf);
+ else
+ notice_lang(s_MemoServ, u, MEMO_CHECK_READ, na->nick,
+ timebuf);
+ break;
+ }
+ }
+
+ if (!found)
+ notice_lang(s_MemoServ, u, MEMO_CHECK_NO_MEMO, na->nick);
+
+ return MOD_CONT;
+}
diff --git a/src/core/ms_del.c b/src/core/ms_del.c
new file mode 100644
index 000000000..1fc3557c0
--- /dev/null
+++ b/src/core/ms_del.c
@@ -0,0 +1,199 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_del(User * u);
+int del_memo_callback(User * u, int num, va_list args);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("DEL", do_del, NULL, MEMO_HELP_DEL, -1, -1, -1, -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_DEL);
+}
+
+/**
+ * The /ms del command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_del(User * u)
+{
+ MemoInfo *mi;
+ ChannelInfo *ci;
+ char *numstr = strtok(NULL, ""), *chan = NULL;
+ int last, last0, i;
+ char buf[BUFSIZE], *end;
+ int delcount, count, left;
+
+ if (numstr && *numstr == '#') {
+ chan = strtok(numstr, " ");
+ numstr = strtok(NULL, "");
+ if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
+ return MOD_CONT;
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan);
+ return MOD_CONT;
+ } else if (!check_access(u, ci, CA_MEMO)) {
+ notice_lang(s_MemoServ, u, ACCESS_DENIED);
+ return MOD_CONT;
+ }
+ mi = &ci->memos;
+ } else {
+ if (!nick_identified(u)) {
+ notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ return MOD_CONT;
+ }
+ mi = &u->na->nc->memos;
+ }
+ if (!numstr
+ || (!isdigit(*numstr) && stricmp(numstr, "ALL") != 0
+ && stricmp(numstr, "LAST") != 0)) {
+ syntax_error(s_MemoServ, u, "DEL", MEMO_DEL_SYNTAX);
+ } else if (mi->memocount == 0) {
+ if (chan)
+ notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan);
+ else
+ notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS);
+ } else {
+ if (isdigit(*numstr)) {
+ /* Delete a specific memo or memos. */
+ last = -1; /* Last memo deleted */
+ last0 = -1; /* Beginning of range of last memos deleted */
+ end = buf;
+ left = sizeof(buf);
+ delcount =
+ process_numlist(numstr, &count, del_memo_callback, u, mi,
+ &last, &last0, &end, &left);
+ if (last != -1) {
+ /* Some memos got deleted; tell them which ones. */
+ if (delcount > 1) {
+ if (last0 != last)
+ end += snprintf(end, sizeof(buf) - (end - buf),
+ ",%d-%d", last0, last);
+ else
+ end += snprintf(end, sizeof(buf) - (end - buf),
+ ",%d", last);
+ /* "buf+1" here because *buf == ',' */
+ notice_lang(s_MemoServ, u, MEMO_DELETED_SEVERAL,
+ buf + 1);
+ } else {
+ notice_lang(s_MemoServ, u, MEMO_DELETED_ONE, last);
+ }
+ } else {
+ /* No memos were deleted. Tell them so. */
+ if (count == 1)
+ notice_lang(s_MemoServ, u, MEMO_DOES_NOT_EXIST,
+ atoi(numstr));
+ else
+ notice_lang(s_MemoServ, u, MEMO_DELETED_NONE);
+ }
+ } else if (stricmp(numstr, "LAST") == 0) {
+ /* Delete last memo. */
+ for (i = 0; i < mi->memocount; i++)
+ last = mi->memos[i].number;
+ delmemo(mi, last);
+ notice_lang(s_MemoServ, u, MEMO_DELETED_ONE, last);
+ } else {
+ /* Delete all memos. */
+ for (i = 0; i < mi->memocount; i++) {
+ free(mi->memos[i].text);
+ moduleCleanStruct(&mi->memos[i].moduleData);
+ }
+ free(mi->memos);
+ mi->memos = NULL;
+ mi->memocount = 0;
+ if (chan)
+ notice_lang(s_MemoServ, u, MEMO_CHAN_DELETED_ALL, chan);
+ else
+ notice_lang(s_MemoServ, u, MEMO_DELETED_ALL);
+ }
+
+ /* Reset the order */
+ for (i = 0; i < mi->memocount; i++)
+ mi->memos[i].number = i + 1;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Delete a single memo from a MemoInfo. callback function
+ * @param u User Struct
+ * @param int Number
+ * @param va_list Variable Arguemtns
+ * @return 1 if successful, 0 if it fails
+ */
+int del_memo_callback(User * u, int num, va_list args)
+{
+ MemoInfo *mi = va_arg(args, MemoInfo *);
+ int *last = va_arg(args, int *);
+ int *last0 = va_arg(args, int *);
+ char **end = va_arg(args, char **);
+ int *left = va_arg(args, int *);
+
+ if (delmemo(mi, num)) {
+ if (num != (*last) + 1) {
+ if (*last != -1) {
+ int len;
+ if (*last0 != *last)
+ len = snprintf(*end, *left, ",%d-%d", *last0, *last);
+ else
+ len = snprintf(*end, *left, ",%d", *last);
+ *end += len;
+ *left -= len;
+ }
+ *last0 = num;
+ }
+ *last = num;
+ return 1;
+ } else {
+ return 0;
+ }
+}
diff --git a/src/core/ms_help.c b/src/core/ms_help.c
new file mode 100644
index 000000000..d4e3bb4d2
--- /dev/null
+++ b/src/core/ms_help.c
@@ -0,0 +1,66 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_help(User * u);
+
+/**
+ * Create the help command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * The /ms help command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_help(User * u)
+{
+ char *cmd = strtok(NULL, "");
+
+ if (!cmd) {
+ notice_help(s_MemoServ, u, MEMO_HELP_HEADER);
+ moduleDisplayHelp(3, u);
+ notice_help(s_MemoServ, u, MEMO_HELP_FOOTER, s_ChanServ);
+ } else {
+ mod_help_cmd(s_MemoServ, u, MEMOSERV, cmd);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ms_info.c b/src/core/ms_info.c
new file mode 100644
index 000000000..92255256a
--- /dev/null
+++ b/src/core/ms_info.c
@@ -0,0 +1,231 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_info(User * u);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("INFO", do_info, NULL, -1, MEMO_HELP_INFO, -1,
+ MEMO_SERVADMIN_HELP_INFO, MEMO_SERVADMIN_HELP_INFO);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_INFO);
+}
+
+/**
+ * The /ms info command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_info(User * u)
+{
+ MemoInfo *mi;
+ NickAlias *na = NULL;
+ ChannelInfo *ci = NULL;
+ char *name = strtok(NULL, " ");
+ int is_servadmin = is_services_admin(u);
+ int hardmax = 0;
+
+ if (is_servadmin && name && *name != '#') {
+ na = findnick(name);
+ if (!na) {
+ notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name);
+ return MOD_CONT;
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, name);
+ return MOD_CONT;
+ }
+ mi = &na->nc->memos;
+ hardmax = na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0;
+ } else if (name && *name == '#') {
+ ci = cs_findchan(name);
+ if (!ci) {
+ notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, name);
+ return MOD_CONT;
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, name);
+ return MOD_CONT;
+ } else if (!check_access(u, ci, CA_MEMO)) {
+ notice_lang(s_MemoServ, u, ACCESS_DENIED);
+ return MOD_CONT;
+ }
+ mi = &ci->memos;
+ hardmax = ci->flags & CI_MEMO_HARDMAX ? 1 : 0;
+ } else if (name) { /* It's not a chan and we aren't services admin */
+ notice_lang(s_MemoServ, u, ACCESS_DENIED);
+ return MOD_CONT;
+ } else { /* !name */
+ if (!nick_identified(u)) {
+ notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ return MOD_CONT;
+ }
+ mi = &u->na->nc->memos;
+ hardmax = u->na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0;
+ }
+
+ if (name && (ci || na->nc != u->na->nc)) {
+
+ if (!mi->memocount) {
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_MEMOS, name);
+ } else if (mi->memocount == 1) {
+ if (mi->memos[0].flags & MF_UNREAD)
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO_UNREAD, name);
+ else
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO, name);
+ } else {
+ int count = 0, i;
+ for (i = 0; i < mi->memocount; i++) {
+ if (mi->memos[i].flags & MF_UNREAD)
+ count++;
+ }
+ if (count == mi->memocount)
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_ALL_UNREAD,
+ name, count);
+ else if (count == 0)
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS, name,
+ mi->memocount);
+ else if (count == 1)
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_ONE_UNREAD,
+ name, mi->memocount);
+ else
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_SOME_UNREAD,
+ name, mi->memocount, count);
+ }
+ if (mi->memomax == 0) {
+ if (hardmax)
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name,
+ mi->memomax);
+ else
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_LIMIT, name,
+ mi->memomax);
+ } else if (mi->memomax > 0) {
+ if (hardmax)
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name,
+ mi->memomax);
+ else
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_LIMIT, name,
+ mi->memomax);
+ } else {
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_LIMIT, name);
+ }
+
+ /* I ripped this code out of ircservices 4.4.5, since I didn't want
+ to rewrite the whole thing (it pisses me off). */
+ if (na) {
+ if ((na->nc->flags & NI_MEMO_RECEIVE)
+ && (na->nc->flags & NI_MEMO_SIGNON)) {
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_ON, name);
+ } else if (na->nc->flags & NI_MEMO_RECEIVE) {
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_RECEIVE,
+ name);
+ } else if (na->nc->flags & NI_MEMO_SIGNON) {
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_SIGNON,
+ name);
+ } else {
+ notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_OFF, name);
+ }
+ }
+
+ } else { /* !name || (!ci || na->nc == u->na->nc) */
+
+ if (!mi->memocount) {
+ notice_lang(s_MemoServ, u, MEMO_INFO_NO_MEMOS);
+ } else if (mi->memocount == 1) {
+ if (mi->memos[0].flags & MF_UNREAD)
+ notice_lang(s_MemoServ, u, MEMO_INFO_MEMO_UNREAD);
+ else
+ notice_lang(s_MemoServ, u, MEMO_INFO_MEMO);
+ } else {
+ int count = 0, i;
+ for (i = 0; i < mi->memocount; i++) {
+ if (mi->memos[i].flags & MF_UNREAD)
+ count++;
+ }
+ if (count == mi->memocount)
+ notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_ALL_UNREAD,
+ count);
+ else if (count == 0)
+ notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS, mi->memocount);
+ else if (count == 1)
+ notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_ONE_UNREAD,
+ mi->memocount);
+ else
+ notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_SOME_UNREAD,
+ mi->memocount, count);
+ }
+
+ if (mi->memomax == 0) {
+ if (!is_servadmin && hardmax)
+ notice_lang(s_MemoServ, u, MEMO_INFO_HARD_LIMIT_ZERO);
+ else
+ notice_lang(s_MemoServ, u, MEMO_INFO_LIMIT_ZERO);
+ } else if (mi->memomax > 0) {
+ if (!is_servadmin && hardmax)
+ notice_lang(s_MemoServ, u, MEMO_INFO_HARD_LIMIT,
+ mi->memomax);
+ else
+ notice_lang(s_MemoServ, u, MEMO_INFO_LIMIT, mi->memomax);
+ } else {
+ notice_lang(s_MemoServ, u, MEMO_INFO_NO_LIMIT);
+ }
+
+ /* Ripped too. But differently because of a seg fault (loughs) */
+ if ((u->na->nc->flags & NI_MEMO_RECEIVE)
+ && (u->na->nc->flags & NI_MEMO_SIGNON)) {
+ notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_ON);
+ } else if (u->na->nc->flags & NI_MEMO_RECEIVE) {
+ notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_RECEIVE);
+ } else if (u->na->nc->flags & NI_MEMO_SIGNON) {
+ notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_SIGNON);
+ } else {
+ notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_OFF);
+ }
+ }
+ return MOD_CONT; /* if (name && (ci || na->nc != u->na->nc)) */
+}
diff --git a/src/core/ms_list.c b/src/core/ms_list.c
new file mode 100644
index 000000000..fa6a9f95b
--- /dev/null
+++ b/src/core/ms_list.c
@@ -0,0 +1,197 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+int do_list(User * u);
+int list_memo_callback(User * u, int num, va_list args);
+int list_memo(User * u, int index, MemoInfo * mi, int *sent_header,
+ int new, const char *chan);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("LIST", do_list, NULL, MEMO_HELP_LIST, -1, -1, -1,
+ -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_LIST);
+}
+
+/**
+ * List the memos (if any) for the source nick or given channel.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_list(User * u)
+{
+ char *param = strtok(NULL, " "), *chan = NULL;
+ ChannelInfo *ci;
+ MemoInfo *mi;
+ Memo *m;
+ int i;
+
+ if (param && *param == '#') {
+ chan = param;
+ param = strtok(NULL, " ");
+ if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
+ return MOD_CONT;
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan);
+ return MOD_CONT;
+ } else if (!check_access(u, ci, CA_MEMO)) {
+ notice_lang(s_MemoServ, u, ACCESS_DENIED);
+ return MOD_CONT;
+ }
+ mi = &ci->memos;
+ } else {
+ if (!nick_identified(u)) {
+ notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ return MOD_CONT;
+ }
+ mi = &u->na->nc->memos;
+ }
+ if (param && !isdigit(*param) && stricmp(param, "NEW") != 0) {
+ syntax_error(s_MemoServ, u, "LIST", MEMO_LIST_SYNTAX);
+ } else if (mi->memocount == 0) {
+ if (chan)
+ notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan);
+ else
+ notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS);
+ } else {
+ int sent_header = 0;
+ if (param && isdigit(*param)) {
+ process_numlist(param, NULL, list_memo_callback, u,
+ mi, &sent_header, chan);
+ } else {
+ if (param) {
+ for (i = 0, m = mi->memos; i < mi->memocount; i++, m++) {
+ if (m->flags & MF_UNREAD)
+ break;
+ }
+ if (i == mi->memocount) {
+ if (chan)
+ notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_NEW_MEMOS,
+ chan);
+ else
+ notice_lang(s_MemoServ, u, MEMO_HAVE_NO_NEW_MEMOS);
+ return MOD_CONT;
+ }
+ }
+ for (i = 0, m = mi->memos; i < mi->memocount; i++, m++) {
+ if (param && !(m->flags & MF_UNREAD))
+ continue;
+ list_memo(u, i, mi, &sent_header, param != NULL, chan);
+ }
+ }
+ }
+ return MOD_CONT;
+}
+
+/**
+ * list memno callback function
+ * @param u User Struct
+ * @param int Memo number
+ * @param va_list List of arguements
+ * @return result form list_memo()
+ */
+int list_memo_callback(User * u, int num, va_list args)
+{
+ MemoInfo *mi = va_arg(args, MemoInfo *);
+ int *sent_header = va_arg(args, int *);
+ const char *chan = va_arg(args, const char *);
+ int i;
+
+ for (i = 0; i < mi->memocount; i++) {
+ if (mi->memos[i].number == num)
+ break;
+ }
+ /* Range checking done by list_memo() */
+ return list_memo(u, i, mi, sent_header, 0, chan);
+}
+
+/**
+ * Display a single memo entry, possibly printing the header first.
+ * @param u User Struct
+ * @param int Memo index
+ * @param mi MemoInfo Struct
+ * @param send_header If we are to send the headers
+ * @param new If we are listing new memos
+ * @param chan Channel name
+ * @return MOD_CONT
+ */
+int list_memo(User * u, int index, MemoInfo * mi, int *sent_header,
+ int new, const char *chan)
+{
+ Memo *m;
+ char timebuf[64];
+ struct tm tm;
+
+ if (index < 0 || index >= mi->memocount)
+ return 0;
+ if (!*sent_header) {
+ if (chan) {
+ notice_lang(s_MemoServ, u,
+ new ? MEMO_LIST_CHAN_NEW_MEMOS :
+ MEMO_LIST_CHAN_MEMOS, chan, s_MemoServ, chan);
+ } else {
+ notice_lang(s_MemoServ, u,
+ new ? MEMO_LIST_NEW_MEMOS : MEMO_LIST_MEMOS,
+ u->nick, s_MemoServ);
+ }
+ notice_lang(s_MemoServ, u, MEMO_LIST_HEADER);
+ *sent_header = 1;
+ }
+ m = &mi->memos[index];
+ tm = *localtime(&m->time);
+ strftime_lang(timebuf, sizeof(timebuf),
+ u, STRFTIME_DATE_TIME_FORMAT, &tm);
+ timebuf[sizeof(timebuf) - 1] = 0; /* just in case */
+ notice_lang(s_MemoServ, u, MEMO_LIST_FORMAT,
+ (m->flags & MF_UNREAD) ? '*' : ' ',
+ m->number, m->sender, timebuf);
+ return 1;
+}
diff --git a/src/core/ms_read.c b/src/core/ms_read.c
new file mode 100644
index 000000000..4c650f5e1
--- /dev/null
+++ b/src/core/ms_read.c
@@ -0,0 +1,201 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_read(User * u);
+int read_memo_callback(User * u, int num, va_list args);
+int read_memo(User * u, int index, MemoInfo * mi, const char *chan);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("READ", do_read, NULL, MEMO_HELP_READ, -1, -1, -1,
+ -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_READ);
+}
+
+/**
+ * The /ms read command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_read(User * u)
+{
+ MemoInfo *mi;
+ ChannelInfo *ci;
+ char *numstr = strtok(NULL, " "), *chan = NULL;
+ int num, count;
+
+ if (numstr && *numstr == '#') {
+ chan = numstr;
+ numstr = strtok(NULL, " ");
+ if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
+ return MOD_CONT;
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan);
+ return MOD_CONT;
+ } else if (!check_access(u, ci, CA_MEMO)) {
+ notice_lang(s_MemoServ, u, ACCESS_DENIED);
+ return MOD_CONT;
+ }
+ mi = &ci->memos;
+ } else {
+ if (!nick_identified(u)) {
+ notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ return MOD_CONT;
+ }
+ mi = &u->na->nc->memos;
+ }
+ num = numstr ? atoi(numstr) : -1;
+ if (!numstr
+ || (stricmp(numstr, "LAST") != 0 && stricmp(numstr, "NEW") != 0
+ && num <= 0)) {
+ syntax_error(s_MemoServ, u, "READ", MEMO_READ_SYNTAX);
+
+ } else if (mi->memocount == 0) {
+ if (chan)
+ notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan);
+ else
+ notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS);
+
+ } else {
+ int i;
+
+ if (stricmp(numstr, "NEW") == 0) {
+ int readcount = 0;
+ for (i = 0; i < mi->memocount; i++) {
+ if (mi->memos[i].flags & MF_UNREAD) {
+ read_memo(u, i, mi, chan);
+ readcount++;
+ }
+ }
+ if (!readcount) {
+ if (chan)
+ notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_NEW_MEMOS,
+ chan);
+ else
+ notice_lang(s_MemoServ, u, MEMO_HAVE_NO_NEW_MEMOS);
+ }
+ } else if (stricmp(numstr, "LAST") == 0) {
+ for (i = 0; i < mi->memocount - 1; i++);
+ read_memo(u, i, mi, chan);
+ } else { /* number[s] */
+ if (!process_numlist(numstr, &count, read_memo_callback, u,
+ mi, chan)) {
+ if (count == 1)
+ notice_lang(s_MemoServ, u, MEMO_DOES_NOT_EXIST, num);
+ else
+ notice_lang(s_MemoServ, u, MEMO_LIST_NOT_FOUND,
+ numstr);
+ }
+ }
+
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Read a memo callback function
+ * @param u User Struct
+ * @param int Index number
+ * @param va_list variable arguements
+ * @return result of read_memo()
+ */
+int read_memo_callback(User * u, int num, va_list args)
+{
+ MemoInfo *mi = va_arg(args, MemoInfo *);
+ const char *chan = va_arg(args, const char *);
+ int i;
+
+ for (i = 0; i < mi->memocount; i++) {
+ if (mi->memos[i].number == num)
+ break;
+ }
+ /* Range check done in read_memo */
+ return read_memo(u, i, mi, chan);
+}
+
+/**
+ * Read a memo
+ * @param u User Struct
+ * @param int Index number
+ * @param mi MemoInfo struct
+ * @param chan Channel Name
+ * @return 1 on success, 0 if failed
+ */
+int read_memo(User * u, int index, MemoInfo * mi, const char *chan)
+{
+ Memo *m;
+ char timebuf[64];
+ struct tm tm;
+
+ if (index < 0 || index >= mi->memocount)
+ return 0;
+ m = &mi->memos[index];
+ tm = *localtime(&m->time);
+ strftime_lang(timebuf, sizeof(timebuf),
+ u, STRFTIME_DATE_TIME_FORMAT, &tm);
+ timebuf[sizeof(timebuf) - 1] = 0;
+ if (chan)
+ notice_lang(s_MemoServ, u, MEMO_CHAN_HEADER, m->number,
+ m->sender, timebuf, s_MemoServ, chan, m->number);
+ else
+ notice_lang(s_MemoServ, u, MEMO_HEADER, m->number,
+ m->sender, timebuf, s_MemoServ, m->number);
+ notice_lang(s_MemoServ, u, MEMO_TEXT, m->text);
+ m->flags &= ~MF_UNREAD;
+
+ /* Check if a receipt notification was requested */
+ if (m->flags & MF_RECEIPT) {
+ rsend_notify(u, m, chan);
+ }
+
+ return 1;
+}
diff --git a/src/core/ms_rsend.c b/src/core/ms_rsend.c
new file mode 100644
index 000000000..b712f4af1
--- /dev/null
+++ b/src/core/ms_rsend.c
@@ -0,0 +1,119 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_rsend(User * u);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("RSEND", do_rsend, NULL, MEMO_HELP_RSEND, -1, -1, -1,
+ -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ if (!MSMemoReceipt) {
+ return MOD_STOP;
+ }
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ if (((MSMemoReceipt == 1) && (is_services_oper(u)))
+ || (MSMemoReceipt == 2)) {
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_RSEND);
+ }
+}
+
+/**
+ * The /ms rsend command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_rsend(User * u)
+{
+ char *name = strtok(NULL, " ");
+ char *text = strtok(NULL, "");
+ NickAlias *na = NULL;
+ int z = 3;
+
+
+
+ /* check if the variables are here */
+ if (!name || !text) {
+ notice_lang(s_MemoServ, u, MEMO_RSEND_SYNTAX);
+ return MOD_CONT;
+ }
+
+ /* prevent user from rsend to themselves */
+ if ((na = findnick(name))) {
+ if (u->na) {
+ if (stricmp(na->nc->display, u->na->nc->display) == 0) {
+ notice_lang(s_MemoServ, u, MEMO_NO_RSEND_SELF);
+ return MOD_CONT;
+ }
+ } else {
+ notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name);
+ return MOD_CONT;
+ }
+ }
+
+ if (MSMemoReceipt == 1) {
+ /* Services opers and above can use rsend */
+ if (is_services_oper(u)) {
+ memo_send(u, name, text, z);
+ } else {
+ notice_lang(s_MemoServ, u, ACCESS_DENIED);
+ }
+ } else if (MSMemoReceipt == 2) {
+ /* Everybody can use rsend */
+ memo_send(u, name, text, z);
+ } else {
+ /* rsend has been disabled */
+ if (debug) {
+ alog("debug: MSMemoReceipt is set misconfigured to %d",
+ MSMemoReceipt);
+ }
+ notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED);
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/ms_send.c b/src/core/ms_send.c
new file mode 100644
index 000000000..c366072a4
--- /dev/null
+++ b/src/core/ms_send.c
@@ -0,0 +1,73 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_send(User * u);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("SEND", do_send, NULL, MEMO_HELP_SEND, -1, -1, -1,
+ -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SEND);
+}
+
+/**
+ * The /ms send command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_send(User * u)
+{
+ char *name = strtok(NULL, " ");
+ char *text = strtok(NULL, "");
+ int z = 0;
+ memo_send(u, name, text, z);
+ return MOD_CONT;
+}
diff --git a/src/core/ms_sendall.c b/src/core/ms_sendall.c
new file mode 100644
index 000000000..36eae983f
--- /dev/null
+++ b/src/core/ms_sendall.c
@@ -0,0 +1,95 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_sendall(User * u);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("SENDALL", do_sendall, is_services_admin, -1, -1, -1,
+ MEMO_HELP_SENDALL, MEMO_HELP_SENDALL);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SENDALL);
+ }
+}
+
+/**
+ * The /ms sendall command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_sendall(User * u)
+{
+ int i, z = 1;
+ NickCore *nc;
+ char *text = strtok(NULL, "");
+
+ if (readonly) {
+ notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED);
+ return MOD_CONT;
+ } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) {
+ notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED);
+ return MOD_CONT;
+ } else if (!text) {
+ syntax_error(s_MemoServ, u, "SENDALL", MEMO_SEND_SYNTAX);
+ return MOD_CONT;
+ }
+
+
+ for (i = 0; i < 1024; i++) {
+ for (nc = nclists[i]; nc; nc = nc->next) {
+ if (stricmp(u->nick, nc->display) != 0)
+ memo_send(u, nc->display, text, z);
+ } /* /nc */
+ } /* /i */
+
+ notice_lang(s_MemoServ, u, MEMO_MASS_SENT);
+ return MOD_CONT;
+}
diff --git a/src/core/ms_set.c b/src/core/ms_set.c
new file mode 100644
index 000000000..6d89818ba
--- /dev/null
+++ b/src/core/ms_set.c
@@ -0,0 +1,265 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_set(User * u);
+int do_set_notify(User * u, MemoInfo * mi, char *param);
+int do_set_limit(User * u, MemoInfo * mi, char *param);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SET", do_set, NULL, MEMO_HELP_SET, -1, -1, -1, -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+
+ c = createCommand("SET NOTIFY", NULL, NULL, MEMO_HELP_SET_NOTIFY, -1,
+ -1, -1, -1);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+
+ c = createCommand("SET LIMIT", NULL, NULL, -1, MEMO_HELP_SET_LIMIT,
+ MEMO_SERVADMIN_HELP_SET_LIMIT,
+ MEMO_SERVADMIN_HELP_SET_LIMIT,
+ MEMO_SERVADMIN_HELP_SET_LIMIT);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /hs help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SET);
+}
+
+/**
+ * The /ms set command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_set(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+ char *param = strtok(NULL, "");
+ MemoInfo *mi = &u->na->nc->memos;
+
+ if (readonly) {
+ notice_lang(s_MemoServ, u, MEMO_SET_DISABLED);
+ return MOD_CONT;
+ }
+ if (!param) {
+ syntax_error(s_MemoServ, u, "SET", MEMO_SET_SYNTAX);
+ } else if (!nick_identified(u)) {
+ notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ return MOD_CONT;
+ } else if (stricmp(cmd, "NOTIFY") == 0) {
+ do_set_notify(u, mi, param);
+ } else if (stricmp(cmd, "LIMIT") == 0) {
+ do_set_limit(u, mi, param);
+ } else {
+ notice_lang(s_MemoServ, u, MEMO_SET_UNKNOWN_OPTION, cmd);
+ notice_lang(s_MemoServ, u, MORE_INFO, s_MemoServ, "SET");
+ }
+ return MOD_CONT;
+}
+
+/**
+ * The /ms set notify command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_set_notify(User * u, MemoInfo * mi, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ u->na->nc->flags |= NI_MEMO_SIGNON | NI_MEMO_RECEIVE;
+ notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_ON, s_MemoServ);
+ } else if (stricmp(param, "LOGON") == 0) {
+ u->na->nc->flags |= NI_MEMO_SIGNON;
+ u->na->nc->flags &= ~NI_MEMO_RECEIVE;
+ notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_LOGON, s_MemoServ);
+ } else if (stricmp(param, "NEW") == 0) {
+ u->na->nc->flags &= ~NI_MEMO_SIGNON;
+ u->na->nc->flags |= NI_MEMO_RECEIVE;
+ notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NEW, s_MemoServ);
+ } else if (stricmp(param, "MAIL") == 0) {
+ if (u->na->nc->email) {
+ u->na->nc->flags |= NI_MEMO_MAIL;
+ notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_MAIL);
+ } else {
+ notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_INVALIDMAIL);
+ }
+ } else if (stricmp(param, "NOMAIL") == 0) {
+ u->na->nc->flags &= ~NI_MEMO_MAIL;
+ notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NOMAIL);
+ } else if (stricmp(param, "OFF") == 0) {
+ u->na->nc->flags &= ~(NI_MEMO_SIGNON | NI_MEMO_RECEIVE);
+ notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_OFF, s_MemoServ);
+ } else {
+ syntax_error(s_MemoServ, u, "SET NOTIFY", MEMO_SET_NOTIFY_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/**
+ * The /ms set limit command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_set_limit(User * u, MemoInfo * mi, char *param)
+{
+ char *p1 = strtok(param, " ");
+ char *p2 = strtok(NULL, " ");
+ char *p3 = strtok(NULL, " ");
+ char *user = NULL, *chan = NULL;
+ int32 limit;
+ NickAlias *na = u->na;
+ ChannelInfo *ci = NULL;
+ int is_servadmin = is_services_admin(u);
+
+ if (p1 && *p1 == '#') {
+ chan = p1;
+ p1 = p2;
+ p2 = p3;
+ p3 = strtok(NULL, " ");
+ if (!(ci = cs_findchan(chan))) {
+ notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
+ return MOD_CONT;
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan);
+ return MOD_CONT;
+ } else if (!is_servadmin && !check_access(u, ci, CA_MEMO)) {
+ notice_lang(s_MemoServ, u, ACCESS_DENIED);
+ return MOD_CONT;
+ }
+ mi = &ci->memos;
+ }
+ if (is_servadmin) {
+ if (p2 && stricmp(p2, "HARD") != 0 && !chan) {
+ if (!(na = findnick(p1))) {
+ notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, p1);
+ return MOD_CONT;
+ }
+ user = p1;
+ mi = &na->nc->memos;
+ p1 = p2;
+ p2 = p3;
+ } else if (!p1) {
+ syntax_error(s_MemoServ, u, "SET LIMIT",
+ MEMO_SET_LIMIT_SERVADMIN_SYNTAX);
+ return MOD_CONT;
+ }
+ if ((!isdigit(*p1) && stricmp(p1, "NONE") != 0) ||
+ (p2 && stricmp(p2, "HARD") != 0)) {
+ syntax_error(s_MemoServ, u, "SET LIMIT",
+ MEMO_SET_LIMIT_SERVADMIN_SYNTAX);
+ return MOD_CONT;
+ }
+ if (chan) {
+ if (p2)
+ ci->flags |= CI_MEMO_HARDMAX;
+ else
+ ci->flags &= ~CI_MEMO_HARDMAX;
+ } else {
+ if (p2)
+ na->nc->flags |= NI_MEMO_HARDMAX;
+ else
+ na->nc->flags &= ~NI_MEMO_HARDMAX;
+ }
+ limit = atoi(p1);
+ if (limit < 0 || limit > 32767) {
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767);
+ limit = 32767;
+ }
+ if (stricmp(p1, "NONE") == 0)
+ limit = -1;
+ } else {
+ if (!p1 || p2 || !isdigit(*p1)) {
+ syntax_error(s_MemoServ, u, "SET LIMIT",
+ MEMO_SET_LIMIT_SYNTAX);
+ return MOD_CONT;
+ }
+ if (chan && (ci->flags & CI_MEMO_HARDMAX)) {
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_FORBIDDEN, chan);
+ return MOD_CONT;
+ } else if (!chan && (na->nc->flags & NI_MEMO_HARDMAX)) {
+ notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_FORBIDDEN);
+ return MOD_CONT;
+ }
+ limit = atoi(p1);
+ /* The first character is a digit, but we could still go negative
+ * from overflow... watch out! */
+ if (limit < 0 || (MSMaxMemos > 0 && limit > MSMaxMemos)) {
+ if (chan) {
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_TOO_HIGH,
+ chan, MSMaxMemos);
+ } else {
+ notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_TOO_HIGH,
+ MSMaxMemos);
+ }
+ return MOD_CONT;
+ } else if (limit > 32767) {
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767);
+ limit = 32767;
+ }
+ }
+ mi->memomax = limit;
+ if (limit > 0) {
+ if (!chan && na->nc == u->na->nc)
+ notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT, limit);
+ else
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT,
+ chan ? chan : user, limit);
+ } else if (limit == 0) {
+ if (!chan && na->nc == u->na->nc)
+ notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_ZERO);
+ else
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_ZERO,
+ chan ? chan : user);
+ } else {
+ if (!chan && na->nc == u->na->nc)
+ notice_lang(s_MemoServ, u, MEMO_UNSET_YOUR_LIMIT);
+ else
+ notice_lang(s_MemoServ, u, MEMO_UNSET_LIMIT,
+ chan ? chan : user);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ms_staff.c b/src/core/ms_staff.c
new file mode 100644
index 000000000..091a23ce5
--- /dev/null
+++ b/src/core/ms_staff.c
@@ -0,0 +1,92 @@
+/* MemoServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_staff(User * u);
+void myMemoServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("STAFF", do_staff, is_services_oper, -1, -1,
+ MEMO_HELP_STAFF, MEMO_HELP_STAFF, MEMO_HELP_STAFF);
+ moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
+ moduleSetMemoHelp(myMemoServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ms help output.
+ * @param u The user who is requesting help
+ **/
+void myMemoServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_MemoServ, u, MEMO_HELP_CMD_STAFF);
+ }
+}
+
+/**
+ * The /ms staff command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_staff(User * u)
+{
+ NickCore *nc;
+ int i, z = 0;
+ char *text = strtok(NULL, "");
+
+ if (readonly) {
+ notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED);
+ return MOD_CONT;
+ } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) {
+ notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED);
+ return MOD_CONT;
+ } else if (text == NULL) {
+ syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX);
+ return MOD_CONT;
+ }
+
+ for (i = 0; i < 1024; i++) {
+ for (nc = nclists[i]; nc; nc = nc->next) {
+ if (nick_is_services_oper(nc))
+ memo_send(u, nc->display, text, z);
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_access.c b/src/core/ns_access.c
new file mode 100644
index 000000000..25c6bf8cd
--- /dev/null
+++ b/src/core/ns_access.c
@@ -0,0 +1,189 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_access(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("ACCESS", do_access, NULL, NICK_HELP_ACCESS, -1, -1,
+ -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_ACCESS);
+}
+
+/**
+ * The /ns access command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_access(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+ char *mask = strtok(NULL, " ");
+ NickAlias *na;
+ int i;
+ char **access;
+
+ if (cmd && stricmp(cmd, "LIST") == 0 && mask && is_services_admin(u)
+ && (na = findnick(mask))) {
+
+ if (na->nc->accesscount == 0) {
+ notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X_EMPTY, na->nick);
+ return MOD_CONT;
+ }
+
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ return MOD_CONT;
+ }
+
+ if (na->nc->flags & NI_SUSPENDED) {
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
+ return MOD_CONT;
+ }
+
+
+ notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X, mask);
+ mask = strtok(NULL, " ");
+ for (access = na->nc->access, i = 0; i < na->nc->accesscount;
+ access++, i++) {
+ if (mask && !match_wild(mask, *access))
+ continue;
+ notice_user(s_NickServ, u, " %s", *access);
+ }
+
+ } else if (!cmd || ((stricmp(cmd, "LIST") == 0) ? !!mask : !mask)) {
+ syntax_error(s_NickServ, u, "ACCESS", NICK_ACCESS_SYNTAX);
+
+ } else if (mask && !strchr(mask, '@')) {
+ notice_lang(s_NickServ, u, BAD_USERHOST_MASK);
+ notice_lang(s_NickServ, u, MORE_INFO, s_NickServ, "ACCESS");
+
+ } else if (!(na = u->na)) {
+ notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
+
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+
+ } else if (na->nc->flags & NI_SUSPENDED) {
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
+
+ } else if (!nick_identified(u)) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+
+ } else if (stricmp(cmd, "ADD") == 0) {
+ if (na->nc->accesscount >= NSAccessMax) {
+ notice_lang(s_NickServ, u, NICK_ACCESS_REACHED_LIMIT,
+ NSAccessMax);
+ return MOD_CONT;
+ }
+
+ for (access = na->nc->access, i = 0; i < na->nc->accesscount;
+ access++, i++) {
+ if (strcmp(*access, mask) == 0) {
+ notice_lang(s_NickServ, u, NICK_ACCESS_ALREADY_PRESENT,
+ *access);
+ return MOD_CONT;
+ }
+ }
+
+ na->nc->accesscount++;
+ na->nc->access =
+ srealloc(na->nc->access, sizeof(char *) * na->nc->accesscount);
+ na->nc->access[na->nc->accesscount - 1] = sstrdup(mask);
+ notice_lang(s_NickServ, u, NICK_ACCESS_ADDED, mask);
+
+ } else if (stricmp(cmd, "DEL") == 0) {
+
+ for (access = na->nc->access, i = 0; i < na->nc->accesscount;
+ access++, i++) {
+ if (stricmp(*access, mask) == 0)
+ break;
+ }
+ if (i == na->nc->accesscount) {
+ notice_lang(s_NickServ, u, NICK_ACCESS_NOT_FOUND, mask);
+ return MOD_CONT;
+ }
+
+ notice_lang(s_NickServ, u, NICK_ACCESS_DELETED, *access);
+ free(*access);
+ na->nc->accesscount--;
+ if (i < na->nc->accesscount) /* if it wasn't the last entry... */
+ memmove(access, access + 1,
+ (na->nc->accesscount - i) * sizeof(char *));
+ if (na->nc->accesscount) /* if there are any entries left... */
+ na->nc->access =
+ srealloc(na->nc->access,
+ na->nc->accesscount * sizeof(char *));
+ else {
+ free(na->nc->access);
+ na->nc->access = NULL;
+ }
+ } else if (stricmp(cmd, "LIST") == 0) {
+ if (na->nc->accesscount == 0) {
+ notice_lang(s_NickServ, u, NICK_ACCESS_LIST_EMPTY, u->nick);
+ return MOD_CONT;
+ }
+
+ notice_lang(s_NickServ, u, NICK_ACCESS_LIST);
+ for (access = na->nc->access, i = 0; i < na->nc->accesscount;
+ access++, i++) {
+ if (mask && !match_wild(mask, *access))
+ continue;
+ notice_user(s_NickServ, u, " %s", *access);
+ }
+ } else {
+ syntax_error(s_NickServ, u, "ACCESS", NICK_ACCESS_SYNTAX);
+
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_alist.c b/src/core/ns_alist.c
new file mode 100644
index 000000000..f7a913f8f
--- /dev/null
+++ b/src/core/ns_alist.c
@@ -0,0 +1,186 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_alist(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("ALIST", do_alist, NULL, -1, NICK_HELP_ALIST, -1,
+ NICK_SERVADMIN_HELP_ALIST,
+ NICK_SERVADMIN_HELP_ALIST);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_ALIST);
+}
+
+/**
+ * The /ns alist command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_alist(User * u)
+{
+
+/*
+ * List the channels that the given nickname has access on
+ *
+ * /ns ALIST [level]
+ * /ns ALIST [nickname] [level]
+ *
+ * -jester
+ */
+
+ char *nick = NULL;
+ char *lev = NULL;
+
+ NickAlias *na;
+
+ int min_level = 0;
+ int is_servadmin = is_services_admin(u);
+
+ if (!is_servadmin) {
+ /* Non service admins can only see their own levels */
+ na = u->na;
+ } else {
+ /* Services admins can request ALIST on nicks.
+ * The first argument for service admins must
+ * always be a nickname.
+ */
+ nick = strtok(NULL, " ");
+
+ /* If an argument was passed, use it as the nick to see levels
+ * for, else check levels for the user calling the command */
+ if (nick) {
+ na = findnick(nick);
+ } else {
+ na = u->na;
+ }
+ }
+
+ /* If available, get level from arguments */
+ lev = strtok(NULL, " ");
+
+ /* if a level was given, make sure it's an int for later */
+ if (lev) {
+ if (stricmp(lev, "FOUNDER") == 0) {
+ min_level = ACCESS_FOUNDER;
+ } else if (stricmp(lev, "SOP") == 0) {
+ min_level = ACCESS_SOP;
+ } else if (stricmp(lev, "AOP") == 0) {
+ min_level = ACCESS_AOP;
+ } else if (stricmp(lev, "HOP") == 0) {
+ min_level = ACCESS_HOP;
+ } else if (stricmp(lev, "VOP") == 0) {
+ min_level = ACCESS_VOP;
+ } else {
+ min_level = atoi(lev);
+ }
+ }
+
+ if (!nick_identified(u)) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ } else if (is_servadmin && nick && !na) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else if (min_level <= ACCESS_INVALID || min_level >= ACCESS_FOUNDER) {
+ notice_lang(s_NickServ, u, CHAN_ACCESS_LEVEL_RANGE,
+ ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
+ } else {
+ int i, level;
+ int chan_count = 0;
+ int match_count = 0;
+ ChannelInfo *ci;
+
+ notice_lang(s_NickServ, u, (is_servadmin ? NICK_ALIST_HEADER_X :
+ NICK_ALIST_HEADER), na->nick);
+
+ for (i = 0; i < 256; i++) {
+ for ((ci = chanlists[i]); ci; (ci = ci->next)) {
+
+ if ((level = get_access_level(ci, na))) {
+ chan_count++;
+
+ if (min_level > level) {
+ continue;
+ }
+
+ match_count++;
+
+ if ((ci->flags & CI_XOP) || (level == ACCESS_FOUNDER)) {
+ char *xop;
+
+ xop = get_xop_level(level);
+
+ notice_lang(s_NickServ, u, NICK_ALIST_XOP_FORMAT,
+ match_count,
+ ((ci->
+ flags & CI_NO_EXPIRE) ? '!' : ' '),
+ ci->name, xop,
+ (ci->desc ? ci->desc : ""));
+ } else {
+ notice_lang(s_NickServ, u,
+ NICK_ALIST_ACCESS_FORMAT, match_count,
+ ((ci->
+ flags & CI_NO_EXPIRE) ? '!' : ' '),
+ ci->name, level,
+ (ci->desc ? ci->desc : ""));
+
+ }
+ }
+ }
+ }
+
+ notice_lang(s_NickServ, u, NICK_ALIST_FOOTER, match_count,
+ chan_count);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_drop.c b/src/core/ns_drop.c
new file mode 100644
index 000000000..e48849dff
--- /dev/null
+++ b/src/core/ns_drop.c
@@ -0,0 +1,156 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_drop(User * u);
+int do_unlink(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("DROP", do_drop, NULL, -1, NICK_HELP_DROP, -1,
+ NICK_SERVADMIN_HELP_DROP, NICK_SERVADMIN_HELP_DROP);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("UNLINK", do_unlink, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_DROP);
+}
+
+/**
+ * The /ns drop command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_drop(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ NickAlias *na;
+ NickRequest *nr = NULL;
+ int is_servadmin = is_services_admin(u);
+ int is_mine; /* Does the nick being dropped belong to the user that is dropping? */
+ char *my_nick = NULL;
+
+ if (readonly && !is_servadmin) {
+ notice_lang(s_NickServ, u, NICK_DROP_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (!(na = (nick ? findnick(nick) : u->na))) {
+ if (nick) {
+ if ((nr = findrequestnick(nick)) && is_servadmin) {
+ if (readonly)
+ notice_lang(s_NickServ, u, READ_ONLY_MODE);
+ if (WallDrop)
+ anope_cmd_global(s_NickServ,
+ "\2%s\2 used DROP on \2%s\2", u->nick,
+ nick);
+ alog("%s: %s!%s@%s dropped nickname %s (e-mail: %s)",
+ s_NickServ, u->nick, u->username, u->host,
+ nr->nick, nr->email);
+ delnickrequest(nr);
+ notice_lang(s_NickServ, u, NICK_X_DROPPED, nick);
+ } else {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ }
+ } else
+ notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
+ return MOD_CONT;
+ }
+
+ is_mine = (u->na && (u->na->nc == na->nc));
+ if (is_mine && !nick)
+ my_nick = sstrdup(na->nick);
+
+ if (is_mine && !nick_identified(u)) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ } else if (!is_mine && !is_servadmin) {
+ notice_lang(s_NickServ, u, ACCESS_DENIED);
+ } else if (NSSecureAdmins && !is_mine && nick_is_services_admin(na->nc)
+ && !is_services_root(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ } else {
+ if (readonly)
+ notice_lang(s_NickServ, u, READ_ONLY_MODE);
+
+ if (ircd->sqline && (na->status & NS_VERBOTEN)) {
+ anope_cmd_unsqline(na->nick);
+ }
+
+ alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)",
+ s_NickServ, u->nick, u->username, u->host,
+ na->nick, na->nc->display,
+ (na->nc->email ? na->nc->email : "none"));
+ delnick(na);
+ send_event(EVENT_NICK_DROPPED, 1, (my_nick ? my_nick : nick));
+
+ if (!is_mine) {
+ if (WallDrop)
+ anope_cmd_global(s_NickServ, "\2%s\2 used DROP on \2%s\2",
+ u->nick, nick);
+ notice_lang(s_NickServ, u, NICK_X_DROPPED, nick);
+ } else {
+ if (nick)
+ notice_lang(s_NickServ, u, NICK_X_DROPPED, nick);
+ else
+ notice_lang(s_NickServ, u, NICK_DROPPED);
+ if (my_nick) {
+ free(my_nick);
+ }
+ }
+ }
+ return MOD_CONT;
+}
+
+
+int do_unlink(User * u)
+{
+ notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "DROP");
+ return MOD_CONT;
+}
diff --git a/src/core/ns_forbid.c b/src/core/ns_forbid.c
new file mode 100644
index 000000000..adf620ff4
--- /dev/null
+++ b/src/core/ns_forbid.c
@@ -0,0 +1,151 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_forbid(User * u);
+void myNickServHelp(User * u);
+NickAlias *makenick(const char *nick);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("FORBID", do_forbid, is_services_admin, -1, -1, -1,
+ NICK_SERVADMIN_HELP_FORBID,
+ NICK_SERVADMIN_HELP_FORBID);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_FORBID);
+ }
+}
+
+/**
+ * The /ns forbid command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_forbid(User * u)
+{
+ NickAlias *na;
+ char *nick = strtok(NULL, " ");
+ char *reason = strtok(NULL, "");
+
+ /* Assumes that permission checking has already been done. */
+ if (!nick || (ForceForbidReason && !reason)) {
+ syntax_error(s_NickServ, u, "FORBID",
+ (ForceForbidReason ? NICK_FORBID_SYNTAX_REASON :
+ NICK_FORBID_SYNTAX));
+ return MOD_CONT;
+ }
+
+ if (readonly)
+ notice_lang(s_NickServ, u, READ_ONLY_MODE);
+ if ((na = findnick(nick)) != NULL) {
+ if (NSSecureAdmins && nick_is_services_admin(na->nc)
+ && !is_services_root(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+ delnick(na);
+ }
+ na = makenick(nick);
+ if (na) {
+ na->status |= NS_VERBOTEN;
+ na->last_usermask = sstrdup(u->nick);
+ if (reason)
+ na->last_realname = sstrdup(reason);
+
+ na->u = finduser(na->nick);
+ if (na->u)
+ na->u->na = na;
+
+ if (na->u) {
+ notice_lang(s_NickServ, na->u, FORCENICKCHANGE_NOW);
+ collide(na, 0);
+ }
+
+
+ if (ircd->sqline) {
+ anope_cmd_sqline(na->nick, ((reason) ? reason : "Forbidden"));
+ }
+
+ if (WallForbid)
+ anope_cmd_global(s_NickServ, "\2%s\2 used FORBID on \2%s\2",
+ u->nick, nick);
+
+ alog("%s: %s set FORBID for nick %s", s_NickServ, u->nick, nick);
+ notice_lang(s_NickServ, u, NICK_FORBID_SUCCEEDED, nick);
+ send_event(EVENT_NICK_FORBIDDEN, 1, nick);
+ } else {
+ alog("%s: Valid FORBID for %s by %s failed", s_NickServ, nick,
+ u->nick);
+ notice_lang(s_NickServ, u, NICK_FORBID_FAILED, nick);
+ }
+ return MOD_CONT;
+}
+
+NickAlias *makenick(const char *nick)
+{
+ NickAlias *na;
+ NickCore *nc;
+
+ /* First make the core */
+ nc = scalloc(1, sizeof(NickCore));
+ nc->display = sstrdup(nick);
+ slist_init(&nc->aliases);
+ insert_core(nc);
+ alog("%s: group %s has been created", s_NickServ, nc->display);
+
+ /* Then make the alias */
+ na = scalloc(1, sizeof(NickAlias));
+ na->nick = sstrdup(nick);
+ na->nc = nc;
+ slist_add(&nc->aliases, na);
+ alpha_insert_alias(na);
+ return na;
+}
diff --git a/src/core/ns_getemail.c b/src/core/ns_getemail.c
new file mode 100644
index 000000000..24d463bb6
--- /dev/null
+++ b/src/core/ns_getemail.c
@@ -0,0 +1,102 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ * A simple call to check for all emails that a user may have registered
+ * with. It returns the nicks that match the email you provide. Wild
+ * Cards are not excepted. Must use user@email-host.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_getemail(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("GETEMAIL", do_getemail, is_services_admin, -1, -1,
+ -1, NICK_SERVADMIN_HELP_GETEMAIL,
+ NICK_SERVADMIN_HELP_GETEMAIL);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_GETEMAIL);
+ }
+}
+
+/**
+ * The /ns getemail command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_getemail(User * u)
+{
+ char *email = strtok(NULL, " ");
+ int i, j = 0;
+ NickCore *nc;
+
+ if (!email) {
+ syntax_error(s_NickServ, u, "GETMAIL", NICK_GETEMAIL_SYNTAX);
+ return MOD_CONT;
+ }
+ alog("%s: %s!%s@%s used GETEMAIL on %s", s_NickServ, u->nick,
+ u->username, u->host, email);
+ for (i = 0; i < 1024; i++) {
+ for (nc = nclists[i]; nc; nc = nc->next) {
+ if (nc->email) {
+ if (stricmp(nc->email, email) == 0) {
+ j++;
+ notice_lang(s_NickServ, u, NICK_GETEMAIL_EMAILS_ARE,
+ nc->display, email);
+ }
+ }
+ }
+ }
+ if (j <= 0) {
+ notice_lang(s_NickServ, u, NICK_GETEMAIL_NOT_USED, email);
+ return MOD_CONT;
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_getpass.c b/src/core/ns_getpass.c
new file mode 100644
index 000000000..afacd63a9
--- /dev/null
+++ b/src/core/ns_getpass.c
@@ -0,0 +1,111 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_getpass(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("GETPASS", do_getpass, is_services_admin, -1, -1, -1,
+ NICK_SERVADMIN_HELP_GETPASS,
+ NICK_SERVADMIN_HELP_GETPASS);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+#ifdef USE_ENCRYPTION
+ return MOD_STOP;
+#else
+ return MOD_CONT;
+#endif
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_GETPASS);
+ }
+}
+
+/**
+ * The /ns getpass command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_getpass(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ NickAlias *na;
+ NickRequest *nr = NULL;
+
+ if (!nick) {
+ syntax_error(s_NickServ, u, "GETPASS", NICK_GETPASS_SYNTAX);
+ } else if (!(na = findnick(nick))) {
+ if ((nr = findrequestnick(nick))) {
+ alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick,
+ u->username, u->host, nick);
+ if (WallGetpass)
+ anope_cmd_global(s_NickServ,
+ "\2%s\2 used GETPASS on \2%s\2", u->nick,
+ nick);
+ notice_lang(s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick,
+ nr->passcode);
+ } else {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ }
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else if (NSSecureAdmins && nick_is_services_admin(na->nc)
+ && !is_services_root(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ } else if (NSRestrictGetPass && !is_services_root(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ } else {
+ alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick,
+ u->username, u->host, nick);
+ if (WallGetpass)
+ anope_cmd_global(s_NickServ, "\2%s\2 used GETPASS on \2%s\2",
+ u->nick, nick);
+ notice_lang(s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick,
+ na->nc->pass);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_ghost.c b/src/core/ns_ghost.c
new file mode 100644
index 000000000..d97cc39ff
--- /dev/null
+++ b/src/core/ns_ghost.c
@@ -0,0 +1,122 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_ghost(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("GHOST", do_ghost, NULL, NICK_HELP_GHOST, -1, -1, -1,
+ -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_GHOST);
+}
+
+/**
+ * The /ns ghost command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_ghost(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ char *pass = strtok(NULL, " ");
+ NickAlias *na;
+ User *u2;
+
+ if (!nick) {
+ syntax_error(s_NickServ, u, "GHOST", NICK_GHOST_SYNTAX);
+ } else if (!(u2 = finduser(nick))) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
+ } else if (!(na = u2->na)) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else if (na->nc->flags & NI_SUSPENDED) {
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
+ } else if (stricmp(nick, u->nick) == 0) {
+ notice_lang(s_NickServ, u, NICK_NO_GHOST_SELF);
+ } else if (pass) {
+ int res = check_password(pass, na->nc->pass);
+ if (res == 1) {
+ char buf[NICKMAX + 32];
+ snprintf(buf, sizeof(buf), "GHOST command used by %s",
+ u->nick);
+ if (LimitSessions) {
+ del_session(u2->host);
+ }
+ kill_user(s_NickServ, nick, buf);
+ notice_lang(s_NickServ, u, NICK_GHOST_KILLED, nick);
+ } else {
+ notice_lang(s_NickServ, u, ACCESS_DENIED);
+ if (res == 0) {
+ alog("%s: GHOST: invalid password for %s by %s!%s@%s",
+ s_NickServ, nick, u->nick, u->username, u->host);
+ bad_password(u);
+ }
+ }
+ } else {
+ if (group_identified(u, na->nc)
+ || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) {
+ char buf[NICKMAX + 32];
+ snprintf(buf, sizeof(buf), "GHOST command used by %s",
+ u->nick);
+ if (LimitSessions) {
+ del_session(u2->host);
+ }
+ kill_user(s_NickServ, nick, buf);
+ notice_lang(s_NickServ, u, NICK_GHOST_KILLED, nick);
+ } else {
+ notice_lang(s_NickServ, u, ACCESS_DENIED);
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_group.c b/src/core/ns_group.c
new file mode 100644
index 000000000..f652547a9
--- /dev/null
+++ b/src/core/ns_group.c
@@ -0,0 +1,326 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_group(User * u);
+void myNickServHelp(User * u);
+int do_glist(User * u);
+int do_listlinks(User * u);
+
+NickAlias *makealias(const char *nick, NickCore * nc);
+
+/* Obsolete commands */
+int do_link(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("GROUP", do_group, NULL, NICK_HELP_GROUP, -1, -1, -1,
+ -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ c = createCommand("LINK", do_link, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ c = createCommand("GLIST", do_glist, NULL, -1, NICK_HELP_GLIST, -1,
+ NICK_SERVADMIN_HELP_GLIST,
+ NICK_SERVADMIN_HELP_GLIST);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ c = createCommand("LISTLINKS", do_listlinks, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_GROUP);
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_GLIST);
+}
+
+/**
+ * The /ns group command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+/* Register a nick in a specified group. */
+
+int do_group(User * u)
+{
+ NickAlias *na, *target;
+ NickCore *nc;
+ char *nick = strtok(NULL, " ");
+ char *pass = strtok(NULL, " ");
+ int i;
+ char tsbuf[16];
+
+ if (NSEmailReg && (findrequestnick(u->nick))) {
+ notice_lang(s_NickServ, u, NICK_REQUESTED);
+ return MOD_CONT;
+ }
+
+ if (readonly) {
+ notice_lang(s_NickServ, u, NICK_GROUP_DISABLED);
+ return MOD_CONT;
+ }
+ if (checkDefCon(DEFCON_NO_NEW_NICKS)) {
+ notice_lang(s_NickServ, u, OPER_DEFCON_DENIED);
+ return MOD_CONT;
+ }
+
+ if (RestrictOperNicks) {
+ for (i = 0; i < RootNumber; i++) {
+ if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) {
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
+ u->nick);
+ return MOD_CONT;
+ }
+ }
+ for (i = 0; i < servadmins.count && (nc = servadmins.list[i]); i++) {
+ if (stristr(u->nick, nc->display) && !is_oper(u)) {
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
+ u->nick);
+ return MOD_CONT;
+ }
+ }
+ for (i = 0; i < servopers.count && (nc = servopers.list[i]); i++) {
+ if (stristr(u->nick, nc->display) && !is_oper(u)) {
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
+ u->nick);
+ return MOD_CONT;
+ }
+ }
+ }
+
+ if (!nick || !pass) {
+ syntax_error(s_NickServ, u, "GROUP", NICK_GROUP_SYNTAX);
+ } else if (!(target = findnick(nick))) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ } else if (time(NULL) < u->lastnickreg + NSRegDelay) {
+ notice_lang(s_NickServ, u, NICK_GROUP_PLEASE_WAIT, NSRegDelay);
+ } else if (u->na && (u->na->status & NS_VERBOTEN)) {
+ alog("%s: %s@%s tried to use GROUP from FORBIDden nick %s",
+ s_NickServ, u->username, u->host, u->nick);
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u->nick);
+ } else if (u->na && (u->na->nc->flags & NI_SUSPENDED)) {
+ alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s",
+ s_NickServ, u->nick, u->username, u->host, target->nick);
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick);
+ } else if (u->na && NSNoGroupChange) {
+ notice_lang(s_NickServ, u, NICK_GROUP_CHANGE_DISABLED, s_NickServ);
+ } else if (u->na && !nick_identified(u)) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ } else if (target && (target->nc->flags & NI_SUSPENDED)) {
+ alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s",
+ s_NickServ, u->nick, u->username, u->host, target->nick);
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, target->nick);
+ } else if (target->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
+ } else if (u->na && target->nc == u->na->nc) {
+ notice_lang(s_NickServ, u, NICK_GROUP_SAME, target->nick);
+ } else if (NSMaxAliases && (target->nc->aliases.count >= NSMaxAliases)
+ && !nick_is_services_admin(target->nc)) {
+ notice_lang(s_NickServ, u, NICK_GROUP_TOO_MANY, target->nick,
+ s_NickServ, s_NickServ);
+ } else if (check_password(pass, target->nc->pass) != 1) {
+ alog("%s: Failed GROUP for %s!%s@%s (invalid password)",
+ s_NickServ, u->nick, u->username, u->host);
+ notice_lang(s_NickServ, u, PASSWORD_INCORRECT);
+ bad_password(u);
+ } else {
+ /* If the nick is already registered, drop it.
+ * If not, check that it is valid.
+ */
+ if (u->na) {
+ delnick(u->na);
+ } else {
+ int prefixlen = strlen(NSGuestNickPrefix);
+ int nicklen = strlen(u->nick);
+
+ if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1
+ && stristr(u->nick, NSGuestNickPrefix) == u->nick
+ && strspn(u->nick + prefixlen,
+ "1234567890") == nicklen - prefixlen) {
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
+ u->nick);
+ return MOD_CONT;
+ }
+ }
+ na = makealias(u->nick, target->nc);
+
+ if (na) {
+ na->last_usermask =
+ scalloc(strlen(common_get_vident(u)) +
+ strlen(common_get_vhost(u)) + 2, 1);
+ sprintf(na->last_usermask, "%s@%s", common_get_vident(u),
+ common_get_vhost(u));
+ na->last_realname = sstrdup(u->realname);
+ na->time_registered = na->last_seen = time(NULL);
+ na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED);
+
+ if (!(na->nc->flags & NI_SERVICES_ROOT)) {
+ for (i = 0; i < RootNumber; i++) {
+ if (!stricmp(ServicesRoots[i], u->nick)) {
+ na->nc->flags |= NI_SERVICES_ROOT;
+ break;
+ }
+ }
+ }
+
+ u->na = na;
+ na->u = u;
+
+#ifdef USE_RDB
+ /* Is this really needed? Since this is a new alias it will get
+ * its unique id on the next update, since it was previously
+ * deleted by delnick. Must observe...
+ */
+ if (rdb_open()) {
+ rdb_save_ns_alias(na);
+ rdb_close();
+ }
+#endif
+ send_event(EVENT_GROUP, 1, u->nick);
+ alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, u->nick, target->nick, target->nc->display, (target->nc->email ? target->nc->email : "none"));
+ notice_lang(s_NickServ, u, NICK_GROUP_JOINED, target->nick);
+
+ u->lastnickreg = time(NULL);
+ snprintf(tsbuf, sizeof(tsbuf), "%lu",
+ (unsigned long int) u->timestamp);
+ if (ircd->modeonreg) {
+ if (ircd->tsonmode) {
+ common_svsmode(u, ircd->modeonreg, tsbuf);
+ } else {
+ common_svsmode(u, ircd->modeonreg, NULL);
+ }
+ }
+
+ check_memos(u);
+ } else {
+ alog("%s: makealias(%s) failed", s_NickServ, u->nick);
+ notice_lang(s_NickServ, u, NICK_GROUP_FAILED);
+ }
+ }
+ return MOD_CONT;
+}
+
+
+/* Creates a new alias in NickServ database. */
+
+NickAlias *makealias(const char *nick, NickCore * nc)
+{
+ NickAlias *na;
+
+ /* Just need to make the alias */
+ na = scalloc(1, sizeof(NickAlias));
+ na->nick = sstrdup(nick);
+ na->nc = nc;
+ slist_add(&nc->aliases, na);
+ alpha_insert_alias(na);
+ return na;
+}
+
+
+int do_link(User * u)
+{
+ notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "GROUP");
+ return MOD_CONT;
+}
+
+int do_glist(User * u)
+{
+ char *nick = strtok(NULL, " ");
+
+ NickAlias *na, *na2;
+ int is_servadmin = is_services_admin(u);
+ int nick_ided = nick_identified(u);
+ int i;
+
+ if ((nick ? (stricmp(nick, u->nick) ? !is_servadmin : !nick_ided)
+ : !nick_ided)) {
+ notice_lang(s_NickServ, u,
+ (nick_ided ? ACCESS_DENIED :
+ NICK_IDENTIFY_REQUIRED), s_NickServ);
+ } else if ((!nick ? !(na = u->na) : !(na = findnick(nick)))) {
+ notice_lang(s_NickServ, u,
+ (!nick ? NICK_NOT_REGISTERED : NICK_X_NOT_REGISTERED),
+ nick);
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else {
+ time_t expt;
+ struct tm *tm;
+ char buf[BUFSIZE];
+ int wont_expire;
+
+ notice_lang(s_NickServ, u,
+ nick ? NICK_GLIST_HEADER_X : NICK_GLIST_HEADER,
+ na->nc->display);
+ for (i = 0; i < na->nc->aliases.count; i++) {
+ na2 = na->nc->aliases.list[i];
+ if (na2->nc == na->nc) {
+ if (!(wont_expire = na2->status & NS_NO_EXPIRE)) {
+ expt = na2->last_seen + NSExpire;
+ tm = localtime(&expt);
+ strftime_lang(buf, sizeof(buf), na2->u,
+ STRFTIME_DATE_TIME_FORMAT, tm);
+ }
+ notice_lang(s_NickServ, u,
+ ((is_services_admin(u) && !wont_expire)
+ ? NICK_GLIST_REPLY_ADMIN : NICK_GLIST_REPLY),
+ (wont_expire ? '!' : ' '), na2->nick, buf);
+ }
+ }
+ notice_lang(s_NickServ, u, NICK_GLIST_FOOTER,
+ na->nc->aliases.count);
+ }
+ return MOD_CONT;
+}
+
+
+int do_listlinks(User * u)
+{
+ notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "GLIST");
+ return MOD_CONT;
+}
diff --git a/src/core/ns_help.c b/src/core/ns_help.c
new file mode 100644
index 000000000..579dfec7c
--- /dev/null
+++ b/src/core/ns_help.c
@@ -0,0 +1,77 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_help(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * The /ns help command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_help(User * u)
+{
+ char *cmd = strtok(NULL, "");
+
+ if (!cmd) {
+ notice_help(s_NickServ, u, NICK_HELP);
+ moduleDisplayHelp(1, u);
+ if (is_services_admin(u)) {
+ notice_help(s_NickServ, u, NICK_SERVADMIN_HELP);
+ }
+ if (NSExpire >= 86400)
+ notice_help(s_NickServ, u, NICK_HELP_EXPIRES,
+ NSExpire / 86400);
+ notice_help(s_NickServ, u, NICK_HELP_FOOTER);
+ } else if (stricmp(cmd, "SET LANGUAGE") == 0) {
+ int i;
+ notice_help(s_NickServ, u, NICK_HELP_SET_LANGUAGE);
+ for (i = 0; i < NUM_LANGS && langlist[i] >= 0; i++)
+ notice_user(s_NickServ, u, " %2d) %s", i + 1,
+ langnames[langlist[i]]);
+ } else {
+ mod_help_cmd(s_NickServ, u, NICKSERV, cmd);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c
new file mode 100644
index 000000000..362cd4488
--- /dev/null
+++ b/src/core/ns_identify.c
@@ -0,0 +1,160 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+#define TO_COLLIDE 0 /* Collide the user with this nick */
+#define TO_RELEASE 1 /* Release a collided nick */
+
+int do_identify(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("ID", do_identify, NULL, NICK_HELP_IDENTIFY, -1, -1,
+ -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("IDENTIFY", do_identify, NULL, NICK_HELP_IDENTIFY,
+ -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SIDENTIFY", do_identify, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_IDENTIFY);
+}
+
+/**
+ * The /ns identify command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_identify(User * u)
+{
+ char *pass = strtok(NULL, " ");
+ NickAlias *na;
+ NickRequest *nr;
+ int res;
+ char tsbuf[16];
+
+ if (!pass) {
+ syntax_error(s_NickServ, u, "IDENTIFY", NICK_IDENTIFY_SYNTAX);
+ } else if (!(na = u->na)) {
+ if ((nr = findrequestnick(u->nick))) {
+ notice_lang(s_NickServ, u, NICK_IS_PREREG);
+ } else {
+ notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
+ }
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else if (na->nc->flags & NI_SUSPENDED) {
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
+ } else if (nick_identified(u)) {
+ notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED);
+ } else if (!(res = check_password(pass, na->nc->pass))) {
+ alog("%s: Failed IDENTIFY for %s!%s@%s", s_NickServ, u->nick,
+ u->username, u->host);
+ notice_lang(s_NickServ, u, PASSWORD_INCORRECT);
+ bad_password(u);
+ } else if (res == -1) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_FAILED);
+ } else {
+ if (!(na->status & NS_IDENTIFIED) && !(na->status & NS_RECOGNIZED)) {
+ if (na->last_usermask)
+ free(na->last_usermask);
+ na->last_usermask =
+ scalloc(strlen(common_get_vident(u)) +
+ strlen(common_get_vhost(u)) + 2, 1);
+ sprintf(na->last_usermask, "%s@%s", common_get_vident(u),
+ common_get_vhost(u));
+ if (na->last_realname)
+ free(na->last_realname);
+ na->last_realname = sstrdup(u->realname);
+ }
+
+ na->status |= NS_IDENTIFIED;
+ na->last_seen = time(NULL);
+ snprintf(tsbuf, sizeof(tsbuf), "%lu",
+ (unsigned long int) u->timestamp);
+
+ if (ircd->modeonreg) {
+ if (ircd->tsonmode) {
+ common_svsmode(u, ircd->modeonreg, tsbuf);
+ } else {
+ common_svsmode(u, ircd->modeonreg, "");
+ }
+ }
+ send_event(EVENT_NICK_IDENTIFY, 1, u->nick);
+ alog("%s: %s!%s@%s identified for nick %s", s_NickServ, u->nick,
+ u->username, u->host, u->nick);
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_SUCCEEDED);
+ if (ircd->vhost) {
+ do_on_id(u);
+ }
+ if (NSModeOnID) {
+ do_setmodes(u);
+ }
+
+ if (NSForceEmail && u->na && !u->na->nc->email) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_EMAIL_REQUIRED);
+ notice_help(s_NickServ, u, NICK_IDENTIFY_EMAIL_HOWTO);
+ }
+
+ if (!(na->status & NS_RECOGNIZED))
+ check_memos(u);
+
+ /* Enable nick tracking if enabled */
+ if (NSNickTracking)
+ nsStartNickTracking(u);
+
+ /* Clear any timers */
+ if (na->nc->flags & NI_KILLPROTECT) {
+ del_ns_timeout(na, TO_COLLIDE);
+ }
+
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_info.c b/src/core/ns_info.c
new file mode 100644
index 000000000..1f150b7c3
--- /dev/null
+++ b/src/core/ns_info.c
@@ -0,0 +1,272 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+static int do_info(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("INFO", do_info, NULL, NICK_HELP_INFO, -1,
+ NICK_HELP_INFO, NICK_SERVADMIN_HELP_INFO,
+ NICK_SERVADMIN_HELP_INFO);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_INFO);
+}
+
+/**
+ * The /ns info command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_info(User * u)
+{
+
+/* Show hidden info to nick owners and sadmins when the "ALL" parameter is
+ * supplied. If a nick is online, the "Last seen address" changes to "Is
+ * online from".
+ * Syntax: INFO <nick> {ALL}
+ * -TheShadow (13 Mar 1999)
+ */
+
+ char *nick = strtok(NULL, " ");
+ char *param = strtok(NULL, " ");
+
+ NickAlias *na;
+ NickRequest *nr = NULL;
+ int is_servadmin = is_services_admin(u);
+
+ if (!nick) {
+ syntax_error(s_NickServ, u, "INFO", NICK_INFO_SYNTAX);
+ } else if (!(na = findnick(nick))) {
+ if ((nr = findrequestnick(nick))) {
+ notice_lang(s_NickServ, u, NICK_IS_PREREG);
+ if (param && stricmp(param, "ALL") == 0 && is_servadmin) {
+ notice_lang(s_NickServ, u, NICK_INFO_EMAIL, nr->email);
+ } else {
+ if (is_servadmin) {
+ notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE,
+ s_NickServ, nr->nick);
+ }
+ }
+ } else if (nickIsServices(nick, 1)) {
+ notice_lang(s_NickServ, u, NICK_X_IS_SERVICES, nick);
+ } else {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ }
+ } else if (na->status & NS_VERBOTEN) {
+ if (is_oper(u) && na->last_usermask)
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN_OPER, nick,
+ na->last_usermask,
+ (na->last_realname ? na->
+ last_realname : getstring(u->na, NO_REASON)));
+ else
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
+ } else {
+ struct tm *tm;
+ char buf[BUFSIZE], *end;
+ const char *commastr = getstring(u->na, COMMA_SPACE);
+ int need_comma = 0;
+ int nick_online = 0;
+ int show_hidden = 0;
+ time_t expt;
+
+ /* Is the real owner of the nick we're looking up online? -TheShadow */
+ if (na->status & (NS_RECOGNIZED | NS_IDENTIFIED))
+ nick_online = 1;
+
+ /* Only show hidden fields to owner and sadmins and only when the ALL
+ * parameter is used. -TheShadow */
+ if (param && stricmp(param, "ALL") == 0 && u->na
+ && ((nick_identified(u) && (na->nc == u->na->nc))
+ || is_servadmin))
+ show_hidden = 1;
+
+ notice_lang(s_NickServ, u, NICK_INFO_REALNAME, na->nick,
+ na->last_realname);
+
+ if ((nick_identified(u) && (na->nc == u->na->nc)) || is_servadmin) {
+
+ if (nick_is_services_root(na->nc))
+ notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ROOT,
+ na->nick);
+ else if (nick_is_services_admin(na->nc))
+ notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ADMIN,
+ na->nick);
+ else if (nick_is_services_oper(na->nc))
+ notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPER,
+ na->nick);
+
+ } else {
+
+ if (nick_is_services_root(na->nc)
+ && !(na->nc->flags & NI_HIDE_STATUS))
+ notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ROOT,
+ na->nick);
+ else if (nick_is_services_admin(na->nc)
+ && !(na->nc->flags & NI_HIDE_STATUS))
+ notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ADMIN,
+ na->nick);
+ else if (nick_is_services_oper(na->nc)
+ && !(na->nc->flags & NI_HIDE_STATUS))
+ notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPER,
+ na->nick);
+
+ }
+
+
+ if (nick_online) {
+ if (show_hidden || !(na->nc->flags & NI_HIDE_MASK))
+ notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE,
+ na->last_usermask);
+ else
+ notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE_NOHOST,
+ na->nick);
+ } else {
+ if (show_hidden || !(na->nc->flags & NI_HIDE_MASK))
+ notice_lang(s_NickServ, u, NICK_INFO_ADDRESS,
+ na->last_usermask);
+ }
+
+ tm = localtime(&na->time_registered);
+ strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
+ notice_lang(s_NickServ, u, NICK_INFO_TIME_REGGED, buf);
+
+ if (!nick_online) {
+ tm = localtime(&na->last_seen);
+ strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT,
+ tm);
+ notice_lang(s_NickServ, u, NICK_INFO_LAST_SEEN, buf);
+ }
+
+ if (na->last_quit
+ && (show_hidden || !(na->nc->flags & NI_HIDE_QUIT)))
+ notice_lang(s_NickServ, u, NICK_INFO_LAST_QUIT, na->last_quit);
+
+ if (na->nc->url)
+ notice_lang(s_NickServ, u, NICK_INFO_URL, na->nc->url);
+ if (na->nc->email
+ && (show_hidden || !(na->nc->flags & NI_HIDE_EMAIL)))
+ notice_lang(s_NickServ, u, NICK_INFO_EMAIL, na->nc->email);
+ if (na->nc->icq)
+ notice_lang(s_NickServ, u, NICK_INFO_ICQ, na->nc->icq);
+
+ if (show_hidden) {
+ if (s_HostServ && ircd->vhost) {
+ if (getvHost(na->nick) != NULL) {
+ if (ircd->vident && getvIdent(na->nick) != NULL) {
+ notice_lang(s_NickServ, u, NICK_INFO_VHOST2,
+ getvIdent(na->nick),
+ getvHost(na->nick));
+ } else {
+ notice_lang(s_NickServ, u, NICK_INFO_VHOST,
+ getvHost(na->nick));
+ }
+ }
+ }
+ if (na->nc->greet)
+ notice_lang(s_NickServ, u, NICK_INFO_GREET, na->nc->greet);
+
+ *buf = 0;
+ end = buf;
+
+ if (na->nc->flags & NI_KILLPROTECT) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s",
+ getstring(u->na, NICK_INFO_OPT_KILL));
+ need_comma = 1;
+ }
+ if (na->nc->flags & NI_SECURE) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, NICK_INFO_OPT_SECURE));
+ need_comma = 1;
+ }
+ if (na->nc->flags & NI_PRIVATE) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, NICK_INFO_OPT_PRIVATE));
+ need_comma = 1;
+ }
+ if (na->nc->flags & NI_MSG) {
+ end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
+ need_comma ? commastr : "",
+ getstring(u->na, NICK_INFO_OPT_MSG));
+ need_comma = 1;
+ }
+
+ notice_lang(s_NickServ, u, NICK_INFO_OPTIONS,
+ *buf ? buf : getstring(u->na, NICK_INFO_OPT_NONE));
+
+ if (na->nc->flags & NI_SUSPENDED) {
+ notice_lang(s_NickServ, u, NICK_INFO_SUSPENDED,
+ na->last_quit);
+ }
+
+ if (na->status & NS_NO_EXPIRE) {
+ notice_lang(s_NickServ, u, NICK_INFO_NO_EXPIRE);
+ } else {
+ if (is_services_admin(u)) {
+ expt = na->last_seen + NSExpire;
+ tm = localtime(&expt);
+ strftime_lang(buf, sizeof(buf), na->u,
+ STRFTIME_DATE_TIME_FORMAT, tm);
+ notice_lang(s_NickServ, u, NICK_INFO_EXPIRE, buf);
+ }
+ }
+ }
+
+ if (!show_hidden
+ && ((u->na && (na->nc == u->na->nc) && nick_identified(u))
+ || is_servadmin))
+ notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE, s_NickServ,
+ na->nick);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_list.c b/src/core/ns_list.c
new file mode 100644
index 000000000..d04d7f2ec
--- /dev/null
+++ b/src/core/ns_list.c
@@ -0,0 +1,230 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_list(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ if (NSListOpersOnly) {
+ c = createCommand("LIST", do_list, is_oper, -1, NICK_HELP_LIST, -1,
+ NICK_SERVADMIN_HELP_LIST,
+ NICK_SERVADMIN_HELP_LIST);
+ } else {
+ c = createCommand("LIST", do_list, NULL, -1, NICK_HELP_LIST, -1,
+ NICK_SERVADMIN_HELP_LIST,
+ NICK_SERVADMIN_HELP_LIST);
+ }
+
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ if (NSListOpersOnly && !(is_oper(u))) {
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_LIST);
+ }
+}
+
+/**
+ * The /ns list command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_list(User * u)
+{
+
+/* SADMINS can search for nicks based on their NS_VERBOTEN and NS_NO_EXPIRE
+ * status. The keywords FORBIDDEN and NOEXPIRE represent these two states
+ * respectively. These keywords should be included after the search pattern.
+ * Multiple keywords are accepted and should be separated by spaces. Only one
+ * of the keywords needs to match a nick's state for the nick to be displayed.
+ * Forbidden nicks can be identified by "[Forbidden]" appearing in the last
+ * seen address field. Nicks with NOEXPIRE set are preceeded by a "!". Only
+ * SADMINS will be shown forbidden nicks and the "!" indicator.
+ * Syntax for sadmins: LIST pattern [FORBIDDEN] [NOEXPIRE]
+ * -TheShadow
+ */
+
+
+ char *pattern = strtok(NULL, " ");
+ char *keyword;
+ NickAlias *na;
+ NickCore *mync;
+ int nnicks, i;
+ char buf[BUFSIZE];
+ int is_servadmin = is_services_admin(u);
+ int16 matchflags = 0;
+ NickRequest *nr = NULL;
+ int nronly = 0;
+ char noexpire_char = ' ';
+ int count = 0, from = 0, to = 0;
+ char *tmp = NULL;
+ char *s = NULL;
+
+
+
+ if (!pattern) {
+ syntax_error(s_NickServ, u, "LIST",
+ is_servadmin ? NICK_LIST_SERVADMIN_SYNTAX :
+ NICK_LIST_SYNTAX);
+ } else {
+
+ if (pattern) {
+ if (pattern[0] == '#') {
+ tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */
+ if (!tmp) {
+ return MOD_CONT;
+ }
+ for (s = tmp; *s; s++) {
+ if (!isdigit(*s)) {
+ return MOD_CONT;
+ }
+ }
+ from = atoi(tmp);
+ tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */
+ if (!tmp) {
+ return MOD_CONT;
+ }
+ for (s = tmp; *s; s++) {
+ if (!isdigit(*s)) {
+ return MOD_CONT;
+ }
+ }
+ to = atoi(tmp);
+ pattern = sstrdup("*");
+ }
+ }
+
+ nnicks = 0;
+
+ while (is_servadmin && (keyword = strtok(NULL, " "))) {
+ if (stricmp(keyword, "FORBIDDEN") == 0)
+ matchflags |= NS_VERBOTEN;
+ if (stricmp(keyword, "NOEXPIRE") == 0)
+ matchflags |= NS_NO_EXPIRE;
+ if (stricmp(keyword, "UNCONFIRMED") == 0)
+ nronly = 1;
+ }
+
+ mync = (nick_identified(u) ? u->na->nc : NULL);
+
+ notice_lang(s_NickServ, u, NICK_LIST_HEADER, pattern);
+ if (nronly != 1) {
+ for (i = 0; i < 1024; i++) {
+ for (na = nalists[i]; na; na = na->next) {
+ /* Don't show private and forbidden nicks to non-services admins. */
+ if ((na->status & NS_VERBOTEN) && !is_servadmin)
+ continue;
+ if ((na->nc->flags & NI_PRIVATE) && !is_servadmin
+ && na->nc != mync)
+ continue;
+ if ((matchflags != 0) && !(na->status & matchflags))
+ continue;
+
+ /* We no longer compare the pattern against the output buffer.
+ * Instead we build a nice nick!user@host buffer to compare.
+ * The output is then generated separately. -TheShadow */
+ snprintf(buf, sizeof(buf), "%s!%s", na->nick,
+ (na->last_usermask
+ && !(na->status & NS_VERBOTEN)) ? na->
+ last_usermask : "*@*");
+ if (stricmp(pattern, na->nick) == 0
+ || match_wild_nocase(pattern, buf)) {
+
+ if ((((count + 1 >= from) && (count + 1 <= to))
+ || ((from == 0) && (to == 0)))
+ && (++nnicks <= NSListMax)) {
+ if (is_servadmin
+ && (na->status & NS_NO_EXPIRE))
+ noexpire_char = '!';
+ else {
+ noexpire_char = ' ';
+ }
+ if ((na->nc->flags & NI_HIDE_MASK)
+ && !is_servadmin && na->nc != mync) {
+ snprintf(buf, sizeof(buf),
+ "%-20s [Hostname Hidden]",
+ na->nick);
+ } else if (na->status & NS_VERBOTEN) {
+ snprintf(buf, sizeof(buf),
+ "%-20s [Forbidden]", na->nick);
+ } else {
+ snprintf(buf, sizeof(buf), "%-20s %s",
+ na->nick, na->last_usermask);
+ }
+ notice_user(s_NickServ, u, " %c%s",
+ noexpire_char, buf);
+ }
+ count++;
+ }
+ }
+ }
+ }
+
+ if (nronly == 1 || (is_servadmin && matchflags == 0)) {
+ noexpire_char = ' ';
+ for (i = 0; i < 1024; i++) {
+ for (nr = nrlists[i]; nr; nr = nr->next) {
+ snprintf(buf, sizeof(buf), "%s!*@*", nr->nick);
+ if (stricmp(pattern, nr->nick) == 0
+ || match_wild_nocase(pattern, buf)) {
+ if (++nnicks <= NSListMax) {
+ snprintf(buf, sizeof(buf),
+ "%-20s [UNCONFIRMED]", nr->nick);
+ notice_user(s_NickServ, u, " %c%s",
+ noexpire_char, buf);
+ }
+ }
+ }
+ }
+ }
+ notice_lang(s_NickServ, u, NICK_LIST_RESULTS,
+ nnicks > NSListMax ? NSListMax : nnicks, nnicks);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_logout.c b/src/core/ns_logout.c
new file mode 100644
index 000000000..ef91b75a9
--- /dev/null
+++ b/src/core/ns_logout.c
@@ -0,0 +1,125 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+#define TO_COLLIDE 0 /* Collide the user with this nick */
+#define TO_RELEASE 1 /* Release a collided nick */
+
+int do_logout(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("LOGOUT", do_logout, NULL, -1, NICK_HELP_LOGOUT, -1,
+ NICK_SERVADMIN_HELP_LOGOUT,
+ NICK_SERVADMIN_HELP_LOGOUT);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_LOGOUT);
+}
+
+/**
+ * The /ns logout command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_logout(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ char *param = strtok(NULL, " ");
+ User *u2;
+
+ if (!is_services_admin(u) && nick) {
+ syntax_error(s_NickServ, u, "LOGOUT", NICK_LOGOUT_SYNTAX);
+ } else if (!(u2 = (nick ? finduser(nick) : u))) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
+ } else if (!u2->na) {
+ if (nick)
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ else
+ notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
+ } else if (u2->na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u2->na->nick);
+ } else if (!nick && !nick_identified(u)) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ } else if (nick && is_services_admin(u2)) {
+ notice_lang(s_NickServ, u, NICK_LOGOUT_SERVICESADMIN, nick);
+ } else {
+ if (nick && param && !stricmp(param, "REVALIDATE")) {
+ cancel_user(u2);
+ validate_user(u2);
+ } else {
+ u2->na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED);
+ }
+
+ if (ircd->modeonreg) {
+ common_svsmode(u2, ircd->modeonunreg, "1");
+ }
+
+ u->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */
+ alog("%s: %s!%s@%s logged out nickname %s", s_NickServ, u->nick,
+ u->username, u->host, u2->nick);
+
+ if (nick)
+ notice_lang(s_NickServ, u, NICK_LOGOUT_X_SUCCEEDED, nick);
+ else
+ notice_lang(s_NickServ, u, NICK_LOGOUT_SUCCEEDED);
+
+ /* Stop nick tracking if enabled */
+ if (NSNickTracking)
+ nsStopNickTracking(u);
+
+ /* Clear any timers again */
+ if (u->na->nc->flags & NI_KILLPROTECT) {
+ del_ns_timeout(u->na, TO_COLLIDE);
+ }
+
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_recover.c b/src/core/ns_recover.c
new file mode 100644
index 000000000..2b72d94fb
--- /dev/null
+++ b/src/core/ns_recover.c
@@ -0,0 +1,111 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_recover(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("RECOVER", do_recover, NULL, NICK_HELP_RECOVER, -1,
+ -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_RECOVER);
+}
+
+/**
+ * The /ns recover command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_recover(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ char *pass = strtok(NULL, " ");
+ NickAlias *na;
+ User *u2;
+
+ if (!nick) {
+ syntax_error(s_NickServ, u, "RECOVER", NICK_RECOVER_SYNTAX);
+ } else if (!(u2 = finduser(nick))) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
+ } else if (!(na = u2->na)) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else if (na->nc->flags & NI_SUSPENDED) {
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
+ } else if (stricmp(nick, u->nick) == 0) {
+ notice_lang(s_NickServ, u, NICK_NO_RECOVER_SELF);
+ } else if (pass) {
+ int res = check_password(pass, na->nc->pass);
+
+ if (res == 1) {
+ notice_lang(s_NickServ, u2, FORCENICKCHANGE_NOW);
+ collide(na, 0);
+ notice_lang(s_NickServ, u, NICK_RECOVERED, s_NickServ, nick);
+ } else {
+ notice_lang(s_NickServ, u, ACCESS_DENIED);
+ if (res == 0) {
+ alog("%s: RECOVER: invalid password for %s by %s!%s@%s",
+ s_NickServ, nick, u->nick, u->username, u->host);
+ bad_password(u);
+ }
+ }
+ } else {
+ if (group_identified(u, na->nc)
+ || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) {
+ notice_lang(s_NickServ, u2, FORCENICKCHANGE_NOW);
+ collide(na, 0);
+ notice_lang(s_NickServ, u, NICK_RECOVERED, s_NickServ, nick);
+ } else {
+ notice_lang(s_NickServ, u, ACCESS_DENIED);
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_register.c b/src/core/ns_register.c
new file mode 100644
index 000000000..92f4f0589
--- /dev/null
+++ b/src/core/ns_register.c
@@ -0,0 +1,486 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_confirm(User * u);
+int do_register(User * u);
+int do_resend(User * u);
+void myNickServHelp(User * u);
+NickRequest *makerequest(const char *nick);
+NickAlias *makenick(const char *nick);
+int do_sendregmail(User * u, NickRequest * nr);
+int ns_do_register(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("REGISTER", do_register, NULL, NICK_HELP_REGISTER,
+ -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ c = createCommand("CONFIRM", do_confirm, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ c = createCommand("RESEND", do_resend, NULL, -1, -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_REGISTER);
+ if (NSEmailReg) {
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_CONFIRM);
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_RESEND);
+ }
+}
+
+/**
+ * The /ns register command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_register(User * u)
+{
+ NickRequest *nr = NULL, *anr = NULL;
+ NickCore *nc = NULL;
+ int prefixlen = strlen(NSGuestNickPrefix);
+ int nicklen = strlen(u->nick);
+ char *pass = strtok(NULL, " ");
+ char *email = strtok(NULL, " ");
+ char passcode[11];
+ int idx, min = 1, max = 62, i = 0;
+ int chars[] =
+ { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
+ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
+ 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
+ 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
+ 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
+ };
+
+ if (readonly) {
+ notice_lang(s_NickServ, u, NICK_REGISTRATION_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (checkDefCon(DEFCON_NO_NEW_NICKS)) {
+ notice_lang(s_NickServ, u, OPER_DEFCON_DENIED);
+ return MOD_CONT;
+ }
+
+ if (!is_oper(u) && NickRegDelay
+ && ((time(NULL) - u->my_signon) < NickRegDelay)) {
+ notice_lang(s_NickServ, u, NICK_REG_DELAY, NickRegDelay);
+ return MOD_CONT;
+ }
+
+ if ((anr = findrequestnick(u->nick))) {
+ notice_lang(s_NickServ, u, NICK_REQUESTED);
+ return MOD_CONT;
+ }
+ /* Prevent "Guest" nicks from being registered. -TheShadow */
+
+ /* Guest nick can now have a series of between 1 and 7 digits.
+ * --lara
+ */
+ if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 &&
+ stristr(u->nick, NSGuestNickPrefix) == u->nick &&
+ strspn(u->nick + prefixlen, "1234567890") == nicklen - prefixlen) {
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick);
+ return MOD_CONT;
+ }
+
+ if (RestrictOperNicks) {
+ for (i = 0; i < RootNumber; i++) {
+ if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) {
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
+ u->nick);
+ return MOD_CONT;
+ }
+ }
+ for (i = 0; i < servadmins.count && (nc = servadmins.list[i]); i++) {
+ if (stristr(u->nick, nc->display) && !is_oper(u)) {
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
+ u->nick);
+ return MOD_CONT;
+ }
+ }
+ for (i = 0; i < servopers.count && (nc = servopers.list[i]); i++) {
+ if (stristr(u->nick, nc->display) && !is_oper(u)) {
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
+ u->nick);
+ return MOD_CONT;
+ }
+ }
+ }
+
+ if (!pass) {
+ if (NSForceEmail) {
+ syntax_error(s_NickServ, u, "REGISTER",
+ NICK_REGISTER_SYNTAX_EMAIL);
+ } else {
+ syntax_error(s_NickServ, u, "REGISTER", NICK_REGISTER_SYNTAX);
+ }
+ } else if (NSForceEmail && !email) {
+ syntax_error(s_NickServ, u, "REGISTER",
+ NICK_REGISTER_SYNTAX_EMAIL);
+ } else if (time(NULL) < u->lastnickreg + NSRegDelay) {
+ notice_lang(s_NickServ, u, NICK_REG_PLEASE_WAIT, NSRegDelay);
+ } else if (u->na) { /* i.e. there's already such a nick regged */
+ if (u->na->status & NS_VERBOTEN) {
+ alog("%s: %s@%s tried to register FORBIDden nick %s",
+ s_NickServ, u->username, u->host, u->nick);
+ notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick);
+ } else {
+ notice_lang(s_NickServ, u, NICK_ALREADY_REGISTERED, u->nick);
+ }
+ } else if (stricmp(u->nick, pass) == 0
+ || (StrictPasswords && strlen(pass) < 5)) {
+ notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD);
+ } else if (email && !MailValidate(email)) {
+ notice_lang(s_NickServ, u, MAIL_X_INVALID, email);
+ } else {
+#ifdef USE_ENCRYPTION
+ if (strlen(pass) > PASSMAX) {
+ pass[PASSMAX] = 0;
+ notice_lang(s_NickServ, u, PASSWORD_TRUNCATED, PASSMAX);
+ }
+#else
+ if (strlen(pass) > PASSMAX - 1) { /* -1 for null byte */
+ pass[PASSMAX] = 0;
+ notice_lang(s_NickServ, u, PASSWORD_TRUNCATED, PASSMAX - 1);
+ }
+#endif
+ for (idx = 0; idx < 9; idx++) {
+ passcode[idx] =
+ chars[(1 +
+ (int) (((float) (max - min)) * getrandom16() /
+ (65535 + 1.0)) + min)];
+ } passcode[idx] = '\0';
+ nr = makerequest(u->nick);
+ nr->passcode = sstrdup(passcode);
+ nr->password = sstrdup(pass);
+ if (email) {
+ nr->email = sstrdup(email);
+ }
+ nr->requested = time(NULL);
+ if (NSEmailReg) {
+ if (do_sendregmail(u, nr) == 0) {
+ notice_lang(s_NickServ, u, NICK_ENTER_REG_CODE, email,
+ s_NickServ);
+ alog("%s: sent registration verification code to %s",
+ s_NickServ, nr->email);
+ } else {
+ alog("%s: Unable to send registration verification mail",
+ s_NickServ);
+ notice_lang(s_NickServ, u, NICK_REG_UNABLE);
+ delnickrequest(nr); /* Delete the NickRequest if we couldnt send the mail */
+ return MOD_CONT;
+ }
+ } else {
+ do_confirm(u);
+ }
+
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int ns_do_register(User * u)
+{
+ return do_register(u);
+}
+
+
+int do_confirm(User * u)
+{
+
+ NickRequest *nr = NULL;
+ NickAlias *na = NULL;
+ char *passcode = strtok(NULL, " ");
+ char *pass = NULL;
+ char *email = NULL;
+ int forced = 0;
+ User *utmp = NULL;
+#ifdef USE_ENCRYPTION
+ int len;
+#endif
+ nr = findrequestnick(u->nick);
+
+ if (NSEmailReg) {
+ if (!passcode) {
+ notice_lang(s_NickServ, u, NICK_CONFIRM_INVALID);
+ return MOD_CONT;
+ }
+
+ if (!nr) {
+ if (is_services_admin(u)) {
+/* If an admin, thier nick is obviously already regged, so look at the passcode to get the nick
+ of the user they are trying to validate, and push that user through regardless of passcode */
+ nr = findrequestnick(passcode);
+ if (nr) {
+ utmp = finduser(passcode);
+ if (utmp) {
+ sprintf(passcode,
+ "FORCE_ACTIVATION_DUE_TO_OPER_CONFIRM %s",
+ nr->passcode);
+ passcode = strtok(passcode, " ");
+ notice_lang(s_NickServ, u, NICK_FORCE_REG,
+ nr->nick);
+ do_confirm(utmp);
+ return MOD_CONT;
+ } else {
+ passcode = sstrdup(nr->passcode);
+ forced = 1;
+ }
+ } else {
+ notice_lang(s_NickServ, u, NICK_CONFIRM_NOT_FOUND,
+ s_NickServ);
+ return MOD_CONT;
+ }
+ } else {
+ notice_lang(s_NickServ, u, NICK_CONFIRM_NOT_FOUND,
+ s_NickServ);
+ return MOD_CONT;
+ }
+ }
+
+ if (stricmp(nr->passcode, passcode) != 0) {
+ notice_lang(s_NickServ, u, NICK_CONFIRM_INVALID);
+ return MOD_CONT;
+ }
+ }
+
+ if (!nr) {
+ notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED);
+ return MOD_CONT;
+ }
+ pass = sstrdup(nr->password);
+
+ if (nr->email) {
+ email = sstrdup(nr->email);
+ }
+ na = makenick(nr->nick);
+
+ if (na) {
+ int i;
+ char tsbuf[16];
+
+#ifdef USE_ENCRYPTION
+ len = strlen(pass);
+ na->nc->pass = smalloc(PASSMAX);
+ if (encrypt(pass, len, na->nc->pass, PASSMAX) < 0) {
+ memset(pass, 0, strlen(pass));
+ alog("%s: Failed to encrypt password for %s (register)",
+ s_NickServ, nr->nick);
+ notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED);
+ return MOD_CONT;
+ }
+ memset(pass, 0, strlen(pass));
+ na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED);
+ na->nc->flags |= NI_ENCRYPTEDPW;
+#else
+ na->nc->pass = sstrdup(pass);
+ na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED);
+#endif
+ na->nc->flags |= NSDefFlags;
+ for (i = 0; i < RootNumber; i++) {
+ if (!stricmp(ServicesRoots[i], nr->nick)) {
+ na->nc->flags |= NI_SERVICES_ROOT;
+ break;
+ }
+ }
+ na->nc->memos.memomax = MSMaxMemos;
+ na->nc->channelmax = CSMaxReg;
+ if (forced == 1) {
+ na->last_usermask = sstrdup("*@*");
+ na->last_realname = sstrdup("unknown");
+ } else {
+ na->last_usermask =
+ scalloc(strlen(common_get_vident(u)) +
+ strlen(common_get_vhost(u)) + 2, 1);
+ sprintf(na->last_usermask, "%s@%s", common_get_vident(u),
+ common_get_vhost(u));
+ na->last_realname = sstrdup(u->realname);
+ }
+ na->time_registered = na->last_seen = time(NULL);
+ if (NSAddAccessOnReg) {
+ na->nc->accesscount = 1;
+ na->nc->access = scalloc(sizeof(char *), 1);
+ na->nc->access[0] = create_mask(u);
+ } else {
+ na->nc->accesscount = 0;
+ na->nc->access = NULL;
+ }
+ na->nc->language = NSDefLanguage;
+ if (email)
+ na->nc->email = sstrdup(email);
+ if (forced != 1) {
+ u->na = na;
+ na->u = u;
+ alog("%s: '%s' registered by %s@%s (e-mail: %s)", s_NickServ,
+ u->nick, u->username, u->host, (email ? email : "none"));
+ if (NSAddAccessOnReg)
+ notice_lang(s_NickServ, u, NICK_REGISTERED, u->nick,
+ na->nc->access[0]);
+ else
+ notice_lang(s_NickServ, u, NICK_REGISTERED_NO_MASK,
+ u->nick);
+ send_event(EVENT_NICK_REGISTERED, 1, u->nick);
+#ifndef USE_ENCRYPTION
+ notice_lang(s_NickServ, u, NICK_PASSWORD_IS, na->nc->pass);
+#endif
+ u->lastnickreg = time(NULL);
+ if (ircd->modeonreg) {
+ if (ircd->tsonmode) {
+ snprintf(tsbuf, sizeof(tsbuf), "%lu",
+ (unsigned long int) u->timestamp);
+ common_svsmode(u, ircd->modeonreg, tsbuf);
+ } else {
+ common_svsmode(u, ircd->modeonreg, NULL);
+ }
+ }
+
+ } else {
+ notice_lang(s_NickServ, u, NICK_FORCE_REG, nr->nick);
+ }
+ delnickrequest(nr); /* remove the nick request */
+ } else {
+ alog("%s: makenick(%s) failed", s_NickServ, u->nick);
+ notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED);
+ }
+
+ /* Enable nick tracking if enabled */
+ if (NSNickTracking)
+ nsStartNickTracking(u);
+
+ return MOD_CONT;
+}
+
+NickRequest *makerequest(const char *nick)
+{
+ NickRequest *nr;
+
+ nr = scalloc(1, sizeof(NickRequest));
+ nr->nick = sstrdup(nick);
+ insert_requestnick(nr);
+ alog("%s: Nick %s has been requested", s_NickServ, nr->nick);
+ return nr;
+}
+
+/* Creates a full new nick (alias + core) in NickServ database. */
+
+NickAlias *makenick(const char *nick)
+{
+ NickAlias *na;
+ NickCore *nc;
+
+ /* First make the core */
+ nc = scalloc(1, sizeof(NickCore));
+ nc->display = sstrdup(nick);
+ slist_init(&nc->aliases);
+ insert_core(nc);
+ alog("%s: group %s has been created", s_NickServ, nc->display);
+
+ /* Then make the alias */
+ na = scalloc(1, sizeof(NickAlias));
+ na->nick = sstrdup(nick);
+ na->nc = nc;
+ slist_add(&nc->aliases, na);
+ alpha_insert_alias(na);
+ return na;
+}
+
+/* Register a nick. */
+
+int do_resend(User * u)
+{
+ NickRequest *nr = NULL;
+ if (NSEmailReg) {
+ if ((nr = findrequestnick(u->nick))) {
+ if (do_sendregmail(u, nr) == 0) {
+ notice_lang(s_NickServ, u, NICK_REG_RESENT, nr->email);
+ alog("%s: re-sent registration verification code for %s to %s", s_NickServ, nr->nick, nr->email);
+ } else {
+ alog("%s: Unable to re-send registration verification mail for %s", s_NickServ, nr->nick);
+ return MOD_CONT;
+ }
+ }
+ }
+ return MOD_CONT;
+}
+
+int do_sendregmail(User * u, NickRequest * nr)
+{
+ MailInfo *mail = NULL;
+ char buf[BUFSIZE];
+
+ if (!(nr || u)) {
+ return -1;
+ }
+ snprintf(buf, sizeof(buf), getstring2(NULL, NICK_REG_MAIL_SUBJECT),
+ nr->nick);
+ mail = MailRegBegin(u, nr, buf, s_NickServ);
+ if (!mail) {
+ return -1;
+ }
+ fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_HEAD));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_1), nr->nick);
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_2), s_NickServ,
+ nr->passcode);
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_3));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_4));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_5),
+ NetworkName);
+ fprintf(mail->pipe, "\n.\n");
+ MailEnd(mail);
+ return 0;
+}
diff --git a/src/core/ns_release.c b/src/core/ns_release.c
new file mode 100644
index 000000000..4112c4606
--- /dev/null
+++ b/src/core/ns_release.c
@@ -0,0 +1,107 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_release(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("RELEASE", do_release, NULL, NICK_HELP_RELEASE, -1,
+ -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_RELEASE);
+}
+
+/**
+ * The /ns release command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_release(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ char *pass = strtok(NULL, " ");
+ NickAlias *na;
+
+ if (!nick) {
+ syntax_error(s_NickServ, u, "RELEASE", NICK_RELEASE_SYNTAX);
+ } else if (!(na = findnick(nick))) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else if (na->nc->flags & NI_SUSPENDED) {
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
+ } else if (!(na->status & NS_KILL_HELD)) {
+ notice_lang(s_NickServ, u, NICK_RELEASE_NOT_HELD, nick);
+ } else if (pass) {
+ int res = check_password(pass, na->nc->pass);
+ if (res == 1) {
+ release(na, 0);
+ notice_lang(s_NickServ, u, NICK_RELEASED);
+ } else {
+ notice_lang(s_NickServ, u, ACCESS_DENIED);
+ if (res == 0) {
+ alog("%s: RELEASE: invalid password for %s by %s!%s@%s",
+ s_NickServ, nick, u->nick, u->username, u->host);
+ bad_password(u);
+ }
+ }
+ } else {
+ if (group_identified(u, na->nc)
+ || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) {
+ release(na, 0);
+ notice_lang(s_NickServ, u, NICK_RELEASED);
+ } else {
+ notice_lang(s_NickServ, u, ACCESS_DENIED);
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_sendpass.c b/src/core/ns_sendpass.c
new file mode 100644
index 000000000..14f766252
--- /dev/null
+++ b/src/core/ns_sendpass.c
@@ -0,0 +1,120 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_sendpass(User * u);
+
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SENDPASS", do_sendpass, NULL, NICK_HELP_SENDPASS,
+ -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+ if (!UseMail) {
+ return MOD_STOP;
+ }
+#ifdef USE_ENCRYPTION
+ return MOD_STOP;
+#else
+ return MOD_CONT;
+#endif
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_SENDPASS);
+}
+
+/**
+ * The /ns sendpass command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_sendpass(User * u)
+{
+
+ char *nick = strtok(NULL, " ");
+ NickAlias *na;
+
+ if (!nick) {
+ syntax_error(s_NickServ, u, "SENDPASS", NICK_SENDPASS_SYNTAX);
+ } else if (RestrictMail && !is_oper(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ } else if (!(na = findnick(nick))) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else {
+ char buf[BUFSIZE];
+ MailInfo *mail;
+
+ snprintf(buf, sizeof(buf), getstring(na, NICK_SENDPASS_SUBJECT),
+ na->nick);
+ mail = MailBegin(u, na->nc, buf, s_NickServ);
+ if (!mail)
+ return MOD_CONT;
+
+ fprintf(mail->pipe, getstring(na, NICK_SENDPASS_HEAD));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_1), na->nick);
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_2),
+ na->nc->pass);
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_3));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_4));
+ fprintf(mail->pipe, "\n\n");
+ fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_5),
+ NetworkName);
+ fprintf(mail->pipe, "\n.\n");
+
+ MailEnd(mail);
+
+ alog("%s: %s!%s@%s used SENDPASS on %s", s_NickServ, u->nick,
+ u->username, u->host, nick);
+ notice_lang(s_NickServ, u, NICK_SENDPASS_OK, nick);
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/ns_set.c b/src/core/ns_set.c
new file mode 100644
index 000000000..091a7fe42
--- /dev/null
+++ b/src/core/ns_set.c
@@ -0,0 +1,519 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_set(User * u);
+int do_set_display(User * u, NickCore * nc, char *param);
+int do_set_password(User * u, NickCore * nc, char *param);
+int do_set_language(User * u, NickCore * nc, char *param);
+int do_set_url(User * u, NickCore * nc, char *param);
+int do_set_email(User * u, NickCore * nc, char *param);
+int do_set_greet(User * u, NickCore * nc, char *param);
+int do_set_icq(User * u, NickCore * nc, char *param);
+int do_set_kill(User * u, NickCore * nc, char *param);
+int do_set_secure(User * u, NickCore * nc, char *param);
+int do_set_private(User * u, NickCore * nc, char *param);
+int do_set_msg(User * u, NickCore * nc, char *param);
+int do_set_hide(User * u, NickCore * nc, char *param);
+int do_set_noexpire(User * u, NickAlias * nc, char *param);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SET", do_set, NULL, NICK_HELP_SET, -1, -1,
+ NICK_SERVADMIN_HELP_SET, NICK_SERVADMIN_HELP_SET);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET DISPLAY", NULL, NULL, NICK_HELP_SET_DISPLAY, -1,
+ -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET PASSWORD", NULL, NULL, NICK_HELP_SET_PASSWORD,
+ -1, -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET URL", NULL, NULL, NICK_HELP_SET_URL, -1, -1, -1,
+ -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET EMAIL", NULL, NULL, NICK_HELP_SET_EMAIL, -1, -1,
+ -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET ICQ", NULL, NULL, NICK_HELP_SET_ICQ, -1, -1, -1,
+ -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET GREET", NULL, NULL, NICK_HELP_SET_GREET, -1, -1,
+ -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET KILL", NULL, NULL, NICK_HELP_SET_KILL, -1, -1,
+ -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET SECURE", NULL, NULL, NICK_HELP_SET_SECURE, -1,
+ -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET PRIVATE", NULL, NULL, NICK_HELP_SET_PRIVATE, -1,
+ -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET MSG", NULL, NULL, NICK_HELP_SET_MSG, -1, -1, -1,
+ -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET HIDE", NULL, NULL, NICK_HELP_SET_HIDE, -1, -1,
+ -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("SET NOEXPIRE", NULL, NULL, -1, -1, -1,
+ NICK_SERVADMIN_HELP_SET_NOEXPIRE,
+ NICK_SERVADMIN_HELP_SET_NOEXPIRE);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_SET);
+}
+
+/**
+ * The /ns set command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_set(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+ char *param = strtok(NULL, " ");
+
+ NickAlias *na;
+ int is_servadmin = is_services_admin(u);
+ int set_nick = 0;
+
+ if (readonly) {
+ notice_lang(s_NickServ, u, NICK_SET_DISABLED);
+ return MOD_CONT;
+ }
+
+ if (is_servadmin && cmd && (na = findnick(cmd))) {
+ cmd = param;
+ param = strtok(NULL, " ");
+ set_nick = 1;
+ } else {
+ na = u->na;
+ }
+
+ if (!param
+ && (!cmd
+ || (stricmp(cmd, "URL") != 0 && stricmp(cmd, "EMAIL") != 0
+ && stricmp(cmd, "GREET") != 0
+ && stricmp(cmd, "ICQ") != 0))) {
+ if (is_servadmin) {
+ syntax_error(s_NickServ, u, "SET", NICK_SET_SERVADMIN_SYNTAX);
+ } else {
+ syntax_error(s_NickServ, u, "SET", NICK_SET_SYNTAX);
+ }
+ } else if (!na) {
+ notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
+ } else if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ } else if (na->nc->flags & NI_SUSPENDED) {
+ notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
+ } else if (!is_servadmin && !nick_identified(u)) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ } else if (stricmp(cmd, "DISPLAY") == 0) {
+ do_set_display(u, na->nc, param);
+ } else if (stricmp(cmd, "PASSWORD") == 0) {
+ do_set_password(u, na->nc, param);
+ } else if (stricmp(cmd, "LANGUAGE") == 0) {
+ do_set_language(u, na->nc, param);
+ } else if (stricmp(cmd, "URL") == 0) {
+ do_set_url(u, na->nc, param);
+ } else if (stricmp(cmd, "EMAIL") == 0) {
+ do_set_email(u, na->nc, param);
+ } else if (stricmp(cmd, "ICQ") == 0) {
+ do_set_icq(u, na->nc, param);
+ } else if (stricmp(cmd, "GREET") == 0) {
+ do_set_greet(u, na->nc, param);
+ } else if (stricmp(cmd, "KILL") == 0) {
+ do_set_kill(u, na->nc, param);
+ } else if (stricmp(cmd, "SECURE") == 0) {
+ do_set_secure(u, na->nc, param);
+ } else if (stricmp(cmd, "PRIVATE") == 0) {
+ do_set_private(u, na->nc, param);
+ } else if (stricmp(cmd, "MSG") == 0) {
+ do_set_msg(u, na->nc, param);
+ } else if (stricmp(cmd, "HIDE") == 0) {
+ do_set_hide(u, na->nc, param);
+ } else if (stricmp(cmd, "NOEXPIRE") == 0) {
+ do_set_noexpire(u, na, param);
+ } else {
+ if (is_servadmin)
+ notice_lang(s_NickServ, u, NICK_SET_UNKNOWN_OPTION_OR_BAD_NICK,
+ cmd);
+ else
+ notice_lang(s_NickServ, u, NICK_SET_UNKNOWN_OPTION, cmd);
+ }
+ return MOD_CONT;
+}
+
+int do_set_display(User * u, NickCore * nc, char *param)
+{
+ int i;
+ NickAlias *na;
+
+ /* First check whether param is a valid nick of the group */
+ for (i = 0; i < nc->aliases.count; i++) {
+ na = nc->aliases.list[i];
+ if (!stricmp(na->nick, param)) {
+ param = na->nick; /* Because case may differ */
+ break;
+ }
+ }
+
+ if (i == nc->aliases.count) {
+ notice_lang(s_NickServ, u, NICK_SET_DISPLAY_INVALID);
+ return MOD_CONT;
+ }
+
+ change_core_display(nc, param);
+ notice_lang(s_NickServ, u, NICK_SET_DISPLAY_CHANGED, nc->display);
+
+ /* Enable nick tracking if enabled */
+ if (NSNickTracking)
+ nsStartNickTracking(u);
+
+ return MOD_CONT;
+}
+
+int do_set_password(User * u, NickCore * nc, char *param)
+{
+ int len = strlen(param);
+
+ if (NSSecureAdmins && u->na->nc != nc && nick_is_services_admin(nc)
+ && !is_services_root(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ } else if (stricmp(nc->display, param) == 0
+ || (StrictPasswords && len < 5)) {
+ notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD);
+ return MOD_CONT;
+ }
+
+ if (nc->pass)
+ free(nc->pass);
+
+#ifdef USE_ENCRYPTION
+ nc->pass = smalloc(PASSMAX);
+
+ if (encrypt(param, len, nc->pass, PASSMAX) < 0) {
+ memset(param, 0, len);
+ alog("%s: Failed to encrypt password for %s (set)", s_NickServ,
+ nc->display);
+ notice_lang(s_NickServ, u, NICK_SET_PASSWORD_FAILED);
+ return MOD_CONT;
+ }
+
+ memset(param, 0, len);
+ notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED);
+#else
+ nc->pass = sstrdup(param);
+ notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED_TO, nc->pass);
+#endif
+
+ if (u->na && u->na->nc != nc && is_services_admin(u)) {
+ alog("%s: %s!%s@%s used SET PASSWORD as Services admin on %s (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, nc->display, (nc->email ? nc->email : "none"));
+ if (WallSetpass)
+ anope_cmd_global(s_NickServ,
+ "\2%s\2 used SET PASSWORD as Services admin on \2%s\2",
+ u->nick, nc->display);
+ } else {
+ alog("%s: %s!%s@%s (e-mail: %s) changed its password.", s_NickServ,
+ u->nick, u->username, u->host,
+ (nc->email ? nc->email : "none"));
+ }
+ return MOD_CONT;
+}
+
+int do_set_language(User * u, NickCore * nc, char *param)
+{
+ int langnum;
+
+ if (param[strspn(param, "0123456789")] != 0) { /* i.e. not a number */
+ syntax_error(s_NickServ, u, "SET LANGUAGE",
+ NICK_SET_LANGUAGE_SYNTAX);
+ return MOD_CONT;
+ }
+ langnum = atoi(param) - 1;
+ if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0) {
+ notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_UNKNOWN, langnum + 1,
+ s_NickServ);
+ return MOD_CONT;
+ }
+ nc->language = langlist[langnum];
+ notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_CHANGED);
+ return MOD_CONT;
+}
+
+int do_set_url(User * u, NickCore * nc, char *param)
+{
+ if (nc->url)
+ free(nc->url);
+
+ if (param) {
+ nc->url = sstrdup(param);
+ notice_lang(s_NickServ, u, NICK_SET_URL_CHANGED, param);
+ } else {
+ nc->url = NULL;
+ notice_lang(s_NickServ, u, NICK_SET_URL_UNSET);
+ }
+ return MOD_CONT;
+}
+
+int do_set_email(User * u, NickCore * nc, char *param)
+{
+ if (!param && NSForceEmail) {
+ notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNSET_IMPOSSIBLE);
+ return MOD_CONT;
+ } else if (NSSecureAdmins && u->na->nc != nc
+ && nick_is_services_admin(nc)
+ && !is_services_root(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ } else if (param && !MailValidate(param)) {
+ notice_lang(s_NickServ, u, MAIL_X_INVALID, param);
+ return MOD_CONT;
+ }
+
+ if (u->na && u->na->nc != nc && is_services_admin(u)) {
+ alog("%s: %s!%s@%s used SET EMAIL as Services admin on %s (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, nc->display, (nc->email ? nc->email : "none"));
+ } else {
+ alog("%s: %s!%s@%s (e-mail: %s) changed its e-mail to %s.",
+ s_NickServ, u->nick, u->username, u->host,
+ (nc->email ? nc->email : "none"), (param ? param : "none"));
+ }
+ if (nc->email)
+ free(nc->email);
+
+ if (param) {
+ nc->email = sstrdup(param);
+ notice_lang(s_NickServ, u, NICK_SET_EMAIL_CHANGED, param);
+ } else {
+ nc->email = NULL;
+ notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNSET);
+ }
+ return MOD_CONT;
+}
+
+int do_set_icq(User * u, NickCore * nc, char *param)
+{
+ if (param) {
+ int32 tmp = atol(param);
+ if (!tmp) {
+ notice_lang(s_NickServ, u, NICK_SET_ICQ_INVALID, param);
+ } else {
+ nc->icq = tmp;
+ notice_lang(s_NickServ, u, NICK_SET_ICQ_CHANGED, param);
+ }
+ } else {
+ nc->icq = 0;
+ notice_lang(s_NickServ, u, NICK_SET_ICQ_UNSET);
+ }
+ return MOD_CONT;
+}
+
+int do_set_greet(User * u, NickCore * nc, char *param)
+{
+ if (nc->greet)
+ free(nc->greet);
+
+ if (param) {
+ char buf[BUFSIZE];
+ char *end = strtok(NULL, "");
+
+ snprintf(buf, sizeof(buf), "%s%s%s", param, (end ? " " : ""),
+ (end ? end : ""));
+
+ nc->greet = sstrdup(buf);
+ notice_lang(s_NickServ, u, NICK_SET_GREET_CHANGED, buf);
+ } else {
+ nc->greet = NULL;
+ notice_lang(s_NickServ, u, NICK_SET_GREET_UNSET);
+ }
+ return MOD_CONT;
+}
+
+int do_set_kill(User * u, NickCore * nc, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ nc->flags |= NI_KILLPROTECT;
+ nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED);
+ notice_lang(s_NickServ, u, NICK_SET_KILL_ON);
+ } else if (stricmp(param, "QUICK") == 0) {
+ nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK;
+ nc->flags &= ~NI_KILL_IMMED;
+ notice_lang(s_NickServ, u, NICK_SET_KILL_QUICK);
+ } else if (stricmp(param, "IMMED") == 0) {
+ if (NSAllowKillImmed) {
+ nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED;
+ nc->flags &= ~NI_KILL_QUICK;
+ notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED);
+ } else {
+ notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED_DISABLED);
+ }
+ } else if (stricmp(param, "OFF") == 0) {
+ nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED);
+ notice_lang(s_NickServ, u, NICK_SET_KILL_OFF);
+ } else {
+ syntax_error(s_NickServ, u, "SET KILL",
+ NSAllowKillImmed ? NICK_SET_KILL_IMMED_SYNTAX :
+ NICK_SET_KILL_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int do_set_secure(User * u, NickCore * nc, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ nc->flags |= NI_SECURE;
+ notice_lang(s_NickServ, u, NICK_SET_SECURE_ON);
+ } else if (stricmp(param, "OFF") == 0) {
+ nc->flags &= ~NI_SECURE;
+ notice_lang(s_NickServ, u, NICK_SET_SECURE_OFF);
+ } else {
+ syntax_error(s_NickServ, u, "SET SECURE", NICK_SET_SECURE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int do_set_private(User * u, NickCore * nc, char *param)
+{
+ if (stricmp(param, "ON") == 0) {
+ nc->flags |= NI_PRIVATE;
+ notice_lang(s_NickServ, u, NICK_SET_PRIVATE_ON);
+ } else if (stricmp(param, "OFF") == 0) {
+ nc->flags &= ~NI_PRIVATE;
+ notice_lang(s_NickServ, u, NICK_SET_PRIVATE_OFF);
+ } else {
+ syntax_error(s_NickServ, u, "SET PRIVATE",
+ NICK_SET_PRIVATE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int do_set_msg(User * u, NickCore * nc, char *param)
+{
+ if (!UsePrivmsg) {
+ notice_lang(s_NickServ, u, NICK_SET_OPTION_DISABLED, "MSG");
+ return MOD_CONT;
+ }
+
+ if (stricmp(param, "ON") == 0) {
+ nc->flags |= NI_MSG;
+ notice_lang(s_NickServ, u, NICK_SET_MSG_ON);
+ } else if (stricmp(param, "OFF") == 0) {
+ nc->flags &= ~NI_MSG;
+ notice_lang(s_NickServ, u, NICK_SET_MSG_OFF);
+ } else {
+ syntax_error(s_NickServ, u, "SET MSG", NICK_SET_MSG_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int do_set_hide(User * u, NickCore * nc, char *param)
+{
+ int flag, onmsg, offmsg;
+
+ if (stricmp(param, "EMAIL") == 0) {
+ flag = NI_HIDE_EMAIL;
+ onmsg = NICK_SET_HIDE_EMAIL_ON;
+ offmsg = NICK_SET_HIDE_EMAIL_OFF;
+ } else if (stricmp(param, "USERMASK") == 0) {
+ flag = NI_HIDE_MASK;
+ onmsg = NICK_SET_HIDE_MASK_ON;
+ offmsg = NICK_SET_HIDE_MASK_OFF;
+ } else if (stricmp(param, "STATUS") == 0) {
+ flag = NI_HIDE_STATUS;
+ onmsg = NICK_SET_HIDE_STATUS_ON;
+ offmsg = NICK_SET_HIDE_STATUS_OFF;
+ } else if (stricmp(param, "QUIT") == 0) {
+ flag = NI_HIDE_QUIT;
+ onmsg = NICK_SET_HIDE_QUIT_ON;
+ offmsg = NICK_SET_HIDE_QUIT_OFF;
+ } else {
+ syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
+ return MOD_CONT;
+ }
+
+ param = strtok(NULL, " ");
+ if (!param) {
+ syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
+ } else if (stricmp(param, "ON") == 0) {
+ nc->flags |= flag;
+ notice_lang(s_NickServ, u, onmsg, s_NickServ);
+ } else if (stricmp(param, "OFF") == 0) {
+ nc->flags &= ~flag;
+ notice_lang(s_NickServ, u, offmsg, s_NickServ);
+ } else {
+ syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int do_set_noexpire(User * u, NickAlias * na, char *param)
+{
+ if (!is_services_admin(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+ if (!param) {
+ syntax_error(s_NickServ, u, "SET NOEXPIRE",
+ NICK_SET_NOEXPIRE_SYNTAX);
+ return MOD_CONT;
+ }
+ if (stricmp(param, "ON") == 0) {
+ na->status |= NS_NO_EXPIRE;
+ notice_lang(s_NickServ, u, NICK_SET_NOEXPIRE_ON, na->nick);
+ } else if (stricmp(param, "OFF") == 0) {
+ na->status &= ~NS_NO_EXPIRE;
+ notice_lang(s_NickServ, u, NICK_SET_NOEXPIRE_OFF, na->nick);
+ } else {
+ syntax_error(s_NickServ, u, "SET NOEXPIRE",
+ NICK_SET_NOEXPIRE_SYNTAX);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_status.c b/src/core/ns_status.c
new file mode 100644
index 000000000..865329204
--- /dev/null
+++ b/src/core/ns_status.c
@@ -0,0 +1,94 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_status(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("STATUS", do_status, NULL, NICK_HELP_STATUS, -1, -1,
+ -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_STATUS);
+}
+
+/**
+ * The /ns status command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_status(User * u)
+{
+ User *u2;
+ NickAlias *na = NULL;
+ int i = 0;
+ char *nick = strtok(NULL, " ");
+
+ /* If no nickname is given, we assume that the user
+ * is asking for himself */
+ if (!nick)
+ nick = u->nick;
+
+ while (nick && (i++ < 16)) {
+ if (!(u2 = finduser(nick))) /* Nick is not online */
+ notice_lang(s_NickServ, u, NICK_STATUS_0, nick);
+ else if (nick_identified(u2)) /* Nick is identified */
+ notice_lang(s_NickServ, u, NICK_STATUS_3, nick);
+ else if (nick_recognized(u2)) /* Nick is recognised, but NOT identified */
+ notice_lang(s_NickServ, u, NICK_STATUS_2, nick);
+ else if ((na = findnick(nick)) == NULL) /* Nick is online, but NOT a registered */
+ notice_lang(s_NickServ, u, NICK_STATUS_0, nick);
+ else
+ notice_lang(s_NickServ, u, NICK_STATUS_1, nick);
+
+ /* Get the next nickname */
+ nick = strtok(NULL, " ");
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/ns_suspend.c b/src/core/ns_suspend.c
new file mode 100644
index 000000000..ba48c2175
--- /dev/null
+++ b/src/core/ns_suspend.c
@@ -0,0 +1,193 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_suspend(User * u);
+int do_unsuspend(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SUSPEND", do_suspend, is_services_admin, -1, -1, -1,
+ NICK_SERVADMIN_HELP_SUSPEND,
+ NICK_SERVADMIN_HELP_SUSPEND);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+ c = createCommand("UNSUSPEND", do_unsuspend, is_services_admin, -1, -1,
+ -1, NICK_SERVADMIN_HELP_UNSUSPEND,
+ NICK_SERVADMIN_HELP_UNSUSPEND);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_SUSPEND);
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_UNSUSPEND);
+ }
+}
+
+/**
+ * The /ns suspend command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_suspend(User * u)
+{
+ NickAlias *na, *na2;
+ char *nick = strtok(NULL, " ");
+ char *reason = strtok(NULL, "");
+ int i;
+
+ if (!nick || !reason) {
+ syntax_error(s_NickServ, u, "SUSPEND", NICK_SUSPEND_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (readonly) {
+ notice_lang(s_NickServ, u, READ_ONLY_MODE);
+ return MOD_CONT;
+ }
+
+ if ((na = findnick(nick)) == NULL) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ return MOD_CONT;
+ }
+
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ return MOD_CONT;
+ }
+
+ if (NSSecureAdmins && nick_is_services_admin(na->nc)
+ && !is_services_root(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (na) {
+ na->nc->flags |= NI_SUSPENDED;
+ na->nc->flags |= NI_SECURE;
+ na->nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED);
+
+ for (i = 0; i < na->nc->aliases.count; i++) {
+ na2 = na->nc->aliases.list[i];
+ if (na2->nc == na->nc) {
+ na2->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED);
+ na2->last_quit = sstrdup(reason);
+ }
+ }
+
+ if (WallForbid)
+ anope_cmd_global(s_NickServ, "\2%s\2 used SUSPEND on \2%s\2",
+ u->nick, nick);
+
+ alog("%s: %s set SUSPEND for nick %s", s_NickServ, u->nick, nick);
+ notice_lang(s_NickServ, u, NICK_SUSPEND_SUCCEEDED, nick);
+ send_event(EVENT_NICK_SUSPENDED, 1, nick);
+
+ } else {
+
+ alog("%s: Valid SUSPEND for %s by %s failed", s_NickServ, nick,
+ u->nick);
+ notice_lang(s_NickServ, u, NICK_SUSPEND_FAILED, nick);
+
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+int do_unsuspend(User * u)
+{
+ NickAlias *na;
+ char *nick = strtok(NULL, " ");
+
+ if (!nick) {
+ syntax_error(s_NickServ, u, "UNSUSPEND", NICK_UNSUSPEND_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (readonly) {
+ notice_lang(s_NickServ, u, READ_ONLY_MODE);
+ return MOD_CONT;
+ }
+
+ if ((na = findnick(nick)) == NULL) {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
+ return MOD_CONT;
+ }
+
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ return MOD_CONT;
+ }
+ if (NSSecureAdmins && nick_is_services_admin(na->nc)
+ && !is_services_root(u)) {
+ notice_lang(s_NickServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (na) {
+ na->nc->flags &= ~NI_SUSPENDED;
+
+ if (WallForbid)
+ anope_cmd_global(s_NickServ, "\2%s\2 used UNSUSPEND on \2%s\2",
+ u->nick, nick);
+
+ alog("%s: %s set UNSUSPEND for nick %s", s_NickServ, u->nick,
+ nick);
+ notice_lang(s_NickServ, u, NICK_UNSUSPEND_SUCCEEDED, nick);
+ send_event(EVENT_NICK_UNSUSPEND, 1, nick);
+
+ } else {
+
+ alog("%s: Valid UNSUSPEND for %s by %s failed", s_NickServ, nick,
+ u->nick);
+ notice_lang(s_NickServ, u, NICK_UNSUSPEND_FAILED, nick);
+
+ }
+
+ return MOD_CONT;
+
+}
diff --git a/src/core/ns_update.c b/src/core/ns_update.c
new file mode 100644
index 000000000..0ec8b176a
--- /dev/null
+++ b/src/core/ns_update.c
@@ -0,0 +1,90 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_nickupdate(User * u);
+void myNickServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("UPDATE", do_nickupdate, NULL, NICK_HELP_UPDATE, -1,
+ -1, -1, -1);
+ moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
+
+ moduleSetNickHelp(myNickServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /ns help output.
+ * @param u The user who is requesting help
+ **/
+void myNickServHelp(User * u)
+{
+ notice_lang(s_NickServ, u, NICK_HELP_CMD_UPDATE);
+}
+
+/**
+ * The /ns update command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_nickupdate(User * u)
+{
+ NickAlias *na;
+
+ if (!nick_identified(u)) {
+ notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
+ } else {
+ na = u->na;
+ if (NSModeOnID)
+ do_setmodes(u);
+ check_memos(u);
+ if (na->last_realname)
+ free(na->last_realname);
+ na->last_realname = sstrdup(u->realname);
+ na->status |= NS_IDENTIFIED;
+ na->last_seen = time(NULL);
+ if (ircd->vhost) {
+ do_on_id(u);
+ }
+ notice_lang(s_NickServ, u, NICK_UPDATE_SUCCESS, s_NickServ);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_admin.c b/src/core/os_admin.c
new file mode 100644
index 000000000..56df4b195
--- /dev/null
+++ b/src/core/os_admin.c
@@ -0,0 +1,250 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_admin(User * u);
+int admin_list_callback(SList * slist, int number, void *item,
+ va_list args);
+int admin_list(int number, NickCore * nc, User * u, int *sent_header);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("ADMIN", do_admin, is_oper, OPER_HELP_ADMIN, -1, -1,
+ -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_ADMIN);
+ }
+}
+
+/**
+ * The /os admin command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_admin(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+ NickAlias *na;
+ int res = 0;
+
+ if (skeleton) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_SKELETON);
+ return MOD_CONT;
+ }
+
+ if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) {
+ syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX);
+ } else if (!stricmp(cmd, "ADD")) {
+ if (!is_services_root(u)) {
+ notice_lang(s_OperServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (!(na = findnick(nick))) {
+ notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
+ return MOD_CONT;
+ }
+
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick);
+ return MOD_CONT;
+ }
+
+ if (na->nc->flags & NI_SERVICES_ADMIN
+ || slist_indexof(&servadmins, na->nc) != -1) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_EXISTS, nick);
+ return MOD_CONT;
+ }
+
+ res = slist_add(&servadmins, na->nc);
+ if (res == -2) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_REACHED_LIMIT, nick);
+ return MOD_CONT;
+ } else {
+ if (na->nc->flags & NI_SERVICES_OPER
+ && (res = slist_indexof(&servopers, na->nc)) != -1) {
+ slist_delete(&servopers, res);
+ na->nc->flags |= NI_SERVICES_ADMIN;
+ notice_lang(s_OperServ, u, OPER_ADMIN_MOVED, nick);
+ } else {
+ na->nc->flags |= NI_SERVICES_ADMIN;
+ notice_lang(s_OperServ, u, OPER_ADMIN_ADDED, nick);
+ }
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+ } else if (!stricmp(cmd, "DEL")) {
+ if (!is_services_root(u)) {
+ notice_lang(s_OperServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (servadmins.count == 0) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) {
+ /* Deleting a range */
+ res = slist_delete_range(&servadmins, nick, NULL);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH);
+ return MOD_CONT;
+ } else if (res == 1) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_ONE);
+ } else {
+ notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_SEVERAL,
+ res);
+ }
+ } else {
+ if (!(na = findnick(nick))) {
+ notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
+ return MOD_CONT;
+ }
+
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick);
+ return MOD_CONT;
+ }
+
+ if (!(na->nc->flags & NI_SERVICES_ADMIN)
+ || (res = slist_indexof(&servadmins, na->nc)) == -1) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_NOT_FOUND, nick);
+ return MOD_CONT;
+ }
+
+ slist_delete(&servadmins, res);
+ notice_lang(s_OperServ, u, OPER_ADMIN_DELETED, nick);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+ } else if (!stricmp(cmd, "LIST")) {
+ int sent_header = 0;
+
+ if (servadmins.count == 0) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ if (!nick || (isdigit(*nick)
+ && strspn(nick, "1234567890,-") == strlen(nick))) {
+ res =
+ slist_enum(&servadmins, nick, &admin_list_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH);
+ return MOD_CONT;
+ } else {
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin");
+ }
+ } else {
+ int i;
+
+ for (i = 0; i < servadmins.count; i++)
+ if (!stricmp
+ (nick, ((NickCore *) servadmins.list[i])->display)
+ || match_wild_nocase(nick,
+ ((NickCore *) servadmins.
+ list[i])->display))
+ admin_list(i + 1, servadmins.list[i], u, &sent_header);
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH);
+ else {
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin");
+ }
+ }
+ } else if (!stricmp(cmd, "CLEAR")) {
+ if (!is_services_root(u)) {
+ notice_lang(s_OperServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (servadmins.count == 0) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ slist_clear(&servadmins, 1);
+ notice_lang(s_OperServ, u, OPER_ADMIN_CLEAR);
+ } else {
+ syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int admin_list_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return admin_list(number, item, u, sent_header);
+}
+
+int admin_list(int number, NickCore * nc, User * u, int *sent_header)
+{
+ if (!nc)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_ADMIN_LIST_HEADER);
+ *sent_header = 1;
+ }
+
+ notice_lang(s_OperServ, u, OPER_ADMIN_LIST_FORMAT, number,
+ nc->display);
+ return 1;
+}
diff --git a/src/core/os_akill.c b/src/core/os_akill.c
new file mode 100644
index 000000000..97a974e7f
--- /dev/null
+++ b/src/core/os_akill.c
@@ -0,0 +1,378 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_akill(User * u);
+int akill_view_callback(SList * slist, int number, void *item,
+ va_list args);
+int akill_view(int number, Akill * ak, User * u, int *sent_header);
+int akill_list_callback(SList * slist, int number, void *item,
+ va_list args);
+int akill_list(int number, Akill * ak, User * u, int *sent_header);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("AKILL", do_akill, is_services_oper, OPER_HELP_AKILL,
+ -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_AKILL);
+ }
+}
+
+/**
+ * The /os command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+/* Manage the AKILL list. */
+
+int do_akill(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+ char breason[BUFSIZE];
+
+ if (!cmd)
+ cmd = "";
+
+ if (!stricmp(cmd, "ADD")) {
+ int deleted = 0;
+ char *expiry, *mask, *reason;
+ time_t expires;
+
+ mask = strtok(NULL, " ");
+ if (mask && *mask == '+') {
+ expiry = mask;
+ mask = strtok(NULL, " ");
+ } else {
+ expiry = NULL;
+ }
+
+ expires = expiry ? dotime(expiry) : AutokillExpiry;
+ /* If the expiry given does not contain a final letter, it's in days,
+ * said the doc. Ah well.
+ */
+ if (expiry && isdigit(expiry[strlen(expiry) - 1]))
+ expires *= 86400;
+ /* Do not allow less than a minute expiry time */
+ if (expires != 0 && expires < 60) {
+ notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
+ return MOD_CONT;
+ } else if (expires > 0) {
+ expires += time(NULL);
+ }
+
+ if (mask && (reason = strtok(NULL, ""))) {
+ /* We first do some sanity check on the proposed mask. */
+ if (strchr(mask, '!')) {
+ notice_lang(s_OperServ, u, OPER_AKILL_NO_NICK);
+ return MOD_CONT;
+ }
+
+ if (!strchr(mask, '@')) {
+ notice_lang(s_OperServ, u, BAD_USERHOST_MASK);
+ return MOD_CONT;
+ }
+
+ if (mask && strspn(mask, "~@.*?") == strlen(mask)) {
+ notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask);
+ return MOD_CONT;
+ }
+
+ /**
+ * Changed sprintf() to snprintf()and increased the size of
+ * breason to match bufsize
+ * -Rob
+ **/
+ if (AddAkiller) {
+ snprintf(breason, sizeof(breason), "[%s] %s", u->nick,
+ reason);
+ reason = sstrdup(breason);
+ }
+
+ deleted = add_akill(u, mask, u->nick, expires, reason);
+ if (deleted < 0)
+ return MOD_CONT;
+ else if (deleted)
+ notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL,
+ deleted);
+ notice_lang(s_OperServ, u, OPER_AKILL_ADDED, mask);
+
+ if (WallOSAkill) {
+ char buf[128];
+
+ if (!expires) {
+ strcpy(buf, "does not expire");
+ } else {
+ int wall_expiry = expires - time(NULL);
+ char *s = NULL;
+
+ if (wall_expiry >= 86400) {
+ wall_expiry /= 86400;
+ s = "day";
+ } else if (wall_expiry >= 3600) {
+ wall_expiry /= 3600;
+ s = "hour";
+ } else if (wall_expiry >= 60) {
+ wall_expiry /= 60;
+ s = "minute";
+ }
+
+ snprintf(buf, sizeof(buf), "expires in %d %s%s",
+ wall_expiry, s,
+ (wall_expiry == 1) ? "" : "s");
+ }
+
+ anope_cmd_global(s_OperServ,
+ "%s added an AKILL for %s (%s) (%s)",
+ u->nick, mask, reason, buf);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+
+ } else {
+ syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX);
+ }
+
+ } else if (!stricmp(cmd, "DEL")) {
+
+ char *mask;
+ int res = 0;
+
+ mask = strtok(NULL, " ");
+
+ if (!mask) {
+ syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (akills.count == 0) {
+ notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
+ /* Deleting a range */
+ res = slist_delete_range(&akills, mask, NULL);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
+ return MOD_CONT;
+ } else if (res == 1) {
+ notice_lang(s_OperServ, u, OPER_AKILL_DELETED_ONE);
+ } else {
+ notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL,
+ res);
+ }
+ } else {
+ if ((res = slist_indexof(&akills, mask)) == -1) {
+ notice_lang(s_OperServ, u, OPER_AKILL_NOT_FOUND, mask);
+ return MOD_CONT;
+ }
+
+ slist_delete(&akills, res);
+ notice_lang(s_OperServ, u, OPER_AKILL_DELETED, mask);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+
+ } else if (!stricmp(cmd, "LIST")) {
+ char *mask;
+ int res, sent_header = 0;
+
+ if (akills.count == 0) {
+ notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ mask = strtok(NULL, " ");
+
+ if (!mask || (isdigit(*mask)
+ && strspn(mask, "1234567890,-") == strlen(mask))) {
+ res =
+ slist_enum(&akills, mask, &akill_list_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
+ return MOD_CONT;
+ } else {
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill");
+ }
+ } else {
+ int i;
+ char amask[BUFSIZE];
+
+ for (i = 0; i < akills.count; i++) {
+ snprintf(amask, sizeof(amask), "%s@%s",
+ ((Akill *) akills.list[i])->user,
+ ((Akill *) akills.list[i])->host);
+ if (!stricmp(mask, amask)
+ || match_wild_nocase(mask, amask))
+ akill_list(i + 1, akills.list[i], u, &sent_header);
+ }
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
+ else {
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill");
+ }
+ }
+ } else if (!stricmp(cmd, "VIEW")) {
+ char *mask;
+ int res, sent_header = 0;
+
+ if (akills.count == 0) {
+ notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ mask = strtok(NULL, " ");
+
+ if (!mask || (isdigit(*mask)
+ && strspn(mask, "1234567890,-") == strlen(mask))) {
+ res =
+ slist_enum(&akills, mask, &akill_view_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
+ return MOD_CONT;
+ }
+ } else {
+ int i;
+ char amask[BUFSIZE];
+
+ for (i = 0; i < akills.count; i++) {
+ snprintf(amask, sizeof(amask), "%s@%s",
+ ((Akill *) akills.list[i])->user,
+ ((Akill *) akills.list[i])->host);
+ if (!stricmp(mask, amask)
+ || match_wild_nocase(mask, amask))
+ akill_view(i + 1, akills.list[i], u, &sent_header);
+ }
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
+ }
+ } else if (!stricmp(cmd, "CLEAR")) {
+ slist_clear(&akills, 1);
+ notice_lang(s_OperServ, u, OPER_AKILL_CLEAR);
+ } else {
+ syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int akill_view(int number, Akill * ak, User * u, int *sent_header)
+{
+ char mask[BUFSIZE];
+ char timebuf[32], expirebuf[256];
+ struct tm tm;
+
+ if (!ak)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_AKILL_VIEW_HEADER);
+ *sent_header = 1;
+ }
+
+ snprintf(mask, sizeof(mask), "%s@%s", ak->user, ak->host);
+ tm = *localtime(&ak->seton);
+ strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT,
+ &tm);
+ expire_left(u->na, expirebuf, sizeof(expirebuf), ak->expires);
+ notice_lang(s_OperServ, u, OPER_AKILL_VIEW_FORMAT, number, mask,
+ ak->by, timebuf, expirebuf, ak->reason);
+
+ return 1;
+}
+
+/* Lists an AKILL entry, prefixing it with the header if needed */
+
+int akill_list_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return akill_list(number, item, u, sent_header);
+}
+
+/* Callback for enumeration purposes */
+
+int akill_view_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return akill_view(number, item, u, sent_header);
+}
+
+/* Lists an AKILL entry, prefixing it with the header if needed */
+int akill_list(int number, Akill * ak, User * u, int *sent_header)
+{
+ char mask[BUFSIZE];
+
+ if (!ak)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_AKILL_LIST_HEADER);
+ *sent_header = 1;
+ }
+
+ snprintf(mask, sizeof(mask), "%s@%s", ak->user, ak->host);
+ notice_lang(s_OperServ, u, OPER_AKILL_LIST_FORMAT, number, mask,
+ ak->reason);
+
+ return 1;
+}
diff --git a/src/core/os_chankill.c b/src/core/os_chankill.c
new file mode 100644
index 000000000..c391390e0
--- /dev/null
+++ b/src/core/os_chankill.c
@@ -0,0 +1,130 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_chankill(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("CHANKILL", do_chankill, is_services_admin,
+ OPER_HELP_CHANKILL, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_CHANKILL);
+ }
+}
+
+/**
+ * ChanKill - Akill an entire channel (got botnet?)
+ *
+ * /msg OperServ ChanKill +expire #channel reason
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ *
+ **/
+int do_chankill(User * u)
+{
+ char *expiry, *channel, *reason;
+ time_t expires;
+ char breason[BUFSIZE];
+ char mask[USERMAX + HOSTMAX + 2];
+ struct c_userlist *cu, *next;
+ Channel *c;
+
+ channel = strtok(NULL, " ");
+ if (channel && *channel == '+') {
+ expiry = channel;
+ channel = strtok(NULL, " ");
+ } else {
+ expiry = NULL;
+ }
+
+ expires = expiry ? dotime(expiry) : ChankillExpiry;
+ if (expiry && isdigit(expiry[strlen(expiry) - 1]))
+ expires *= 86400;
+ if (expires != 0 && expires < 60) {
+ notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
+ return MOD_CONT;
+ } else if (expires > 0) {
+ expires += time(NULL);
+ }
+
+ if (channel && (reason = strtok(NULL, ""))) {
+
+ if (AddAkiller) {
+ snprintf(breason, sizeof(breason), "[%s] %s", u->nick, reason);
+ reason = sstrdup(breason);
+ }
+
+ if ((c = findchan(channel))) {
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (is_oper(cu->user)) {
+ continue;
+ }
+ strncpy(mask, "*@", 3); /* Use *@" for the akill's, */
+ strncat(mask, cu->user->host, HOSTMAX);
+ add_akill(NULL, mask, s_OperServ, expires, reason);
+ check_akill(cu->user->nick, cu->user->username,
+ cu->user->host, NULL, NULL);
+ }
+ if (WallOSAkill) {
+ anope_cmd_global(s_OperServ, "%s used CHANKILL on %s (%s)",
+ u->nick, channel, reason);
+ }
+ } else {
+ notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, channel);
+ }
+ } else {
+ syntax_error(s_OperServ, u, "CHANKILL", OPER_CHANKILL_SYNTAX);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_chanlist.c b/src/core/os_chanlist.c
new file mode 100644
index 000000000..6a25c3bc9
--- /dev/null
+++ b/src/core/os_chanlist.c
@@ -0,0 +1,116 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_chanlist(User * u);
+void myOperServHelp(User * u);
+extern MDE int anope_get_private_mode();
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("CHANLIST", do_chanlist, is_services_admin,
+ OPER_HELP_CHANLIST, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_CHANLIST);
+ }
+}
+
+/**
+ * The /os chanlist command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_chanlist(User * u)
+{
+ char *pattern = strtok(NULL, " ");
+ char *opt = strtok(NULL, " ");
+
+ int modes = 0;
+ User *u2;
+
+ if (opt && !stricmp(opt, "SECRET"))
+ modes |= (anope_get_secret_mode() | anope_get_private_mode());
+
+ if (pattern && (u2 = finduser(pattern))) {
+ struct u_chanlist *uc;
+
+ notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick);
+
+ for (uc = u2->chans; uc; uc = uc->next) {
+ if (modes && !(uc->chan->mode & modes))
+ continue;
+ notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD,
+ uc->chan->name, uc->chan->usercount,
+ chan_get_modes(uc->chan, 1, 1),
+ (uc->chan->topic ? uc->chan->topic : ""));
+ }
+ } else {
+ int i;
+ Channel *c;
+
+ notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER);
+
+ for (i = 0; i < 1024; i++) {
+ for (c = chanlist[i]; c; c = c->next) {
+ if (pattern && !match_wild_nocase(pattern, c->name))
+ continue;
+ if (modes && !(c->mode & modes))
+ continue;
+ notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, c->name,
+ c->usercount, chan_get_modes(c, 1, 1),
+ (c->topic ? c->topic : ""));
+ }
+ }
+ }
+
+ notice_lang(s_OperServ, u, OPER_CHANLIST_END);
+ return MOD_CONT;
+}
diff --git a/src/core/os_clearmodes.c b/src/core/os_clearmodes.c
new file mode 100644
index 000000000..9ec37a421
--- /dev/null
+++ b/src/core/os_clearmodes.c
@@ -0,0 +1,356 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_clearmodes(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("CLEARMODES", do_clearmodes, is_services_oper,
+ OPER_HELP_CLEARMODES, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_CLEARMODES);
+ }
+}
+
+/**
+ * The /os clearmodes command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_clearmodes(User * u)
+{
+ char *s;
+ int i;
+ char *argv[2];
+ char *chan = strtok(NULL, " ");
+ Channel *c;
+ int all = 0;
+ int count; /* For saving ban info */
+ char **bans; /* For saving ban info */
+ int exceptcount; /* For saving except info */
+ char **excepts; /* For saving except info */
+ int invitecount; /* For saving invite info */
+ char **invites; /* For saving invite info */
+ struct c_userlist *cu, *next;
+
+ if (!chan) {
+ syntax_error(s_OperServ, u, "CLEARMODES", OPER_CLEARMODES_SYNTAX);
+ return MOD_CONT;
+ } else if (!(c = findchan(chan))) {
+ notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
+ return MOD_CONT;
+ } else if (c->bouncy_modes) {
+ notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
+ return MOD_CONT;
+ } else {
+ s = strtok(NULL, " ");
+ if (s) {
+ if (stricmp(s, "ALL") == 0) {
+ all = 1;
+ } else {
+ syntax_error(s_OperServ, u, "CLEARMODES",
+ OPER_CLEARMODES_SYNTAX);
+ return MOD_CONT;
+ }
+ }
+
+ if (WallOSClearmodes) {
+ anope_cmd_global(s_OperServ, "%s used CLEARMODES%s on %s",
+ u->nick, all ? " ALL" : "", chan);
+ }
+ if (all) {
+ /* Clear mode +o */
+ if (ircd->svsmode_ucmode) {
+ anope_cmd_svsmode_chan(c->name, "-o", NULL);
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_OP)) {
+ continue;
+ }
+ argv[0] = sstrdup("-o");
+ argv[1] = cu->user->nick;
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ } else {
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_OP))
+ continue;
+ argv[0] = sstrdup("-o");
+ argv[1] = cu->user->nick;
+ anope_cmd_mode(s_OperServ, c->name, "-o %s",
+ cu->user->nick);
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ }
+
+ if (ircd->svsmode_ucmode) {
+ anope_cmd_svsmode_chan(c->name, "-v", NULL);
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_VOICE)) {
+ continue;
+ }
+ argv[0] = sstrdup("-v");
+ argv[1] = cu->user->nick;
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ } else {
+ /* Clear mode +v */
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_VOICE))
+ continue;
+ argv[0] = sstrdup("-v");
+ argv[1] = sstrdup(cu->user->nick);
+ anope_cmd_mode(s_OperServ, c->name, "-v %s",
+ cu->user->nick);
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ }
+
+ /* Clear mode +h */
+ if (ircd->svsmode_ucmode && ircd->halfop) {
+ anope_cmd_svsmode_chan(c->name, "-h", NULL);
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) {
+ continue;
+ }
+ argv[0] = sstrdup("-h");
+ argv[1] = cu->user->nick;
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ } else {
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_HALFOP))
+ continue;
+ argv[0] = sstrdup("-h");
+ argv[1] = sstrdup(cu->user->nick);
+ anope_cmd_mode(s_OperServ, c->name, "-h %s",
+ cu->user->nick);
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ }
+ /* Clear mode Owners */
+ if (ircd->svsmode_ucmode && ircd->owner) {
+ anope_cmd_svsmode_chan(c->name, ircd->ownerunset, NULL);
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) {
+ continue;
+ }
+ argv[0] = sstrdup(ircd->ownerunset);
+ argv[1] = cu->user->nick;
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ } else {
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_OWNER))
+ continue;
+ argv[0] = sstrdup(ircd->ownerunset);
+ argv[1] = sstrdup(cu->user->nick);
+ anope_cmd_mode(s_OperServ, c->name, "%s %s",
+ ircd->ownerunset, cu->user->nick);
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ }
+ /* Clear mode protected or admins */
+ if (ircd->svsmode_ucmode && (ircd->protect || ircd->admin)) {
+
+ anope_cmd_svsmode_chan(c->name, ircd->adminunset, NULL);
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) {
+ continue;
+ }
+ argv[0] = sstrdup(ircd->adminunset);
+ argv[1] = cu->user->nick;
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ } else {
+ for (cu = c->users; cu; cu = next) {
+ next = cu->next;
+ if (!chan_has_user_status(c, cu->user, CUS_PROTECT))
+ continue;
+ argv[0] = sstrdup(ircd->adminunset);
+ argv[1] = sstrdup(cu->user->nick);
+ anope_cmd_mode(s_OperServ, c->name, "%s %s",
+ ircd->adminunset, cu->user->nick);
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ }
+
+
+ }
+
+ if (c->mode) {
+ /* Clear modes the bulk of the modes */
+ anope_cmd_mode(s_OperServ, c->name, "%s", ircd->modestoremove);
+ argv[0] = sstrdup(ircd->modestoremove);
+ chan_set_modes(s_OperServ, c, 1, argv, 0);
+ free(argv[0]);
+
+ /* to prevent the internals from complaining send -k, -L, -f by themselves if we need
+ to send them - TSL */
+ if (c->key) {
+ anope_cmd_mode(s_OperServ, c->name, "-k %s", c->key);
+ argv[0] = sstrdup("-k");
+ argv[1] = c->key;
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ if (ircd->Lmode && c->redirect) {
+ anope_cmd_mode(s_OperServ, c->name, "-L %s", c->redirect);
+ argv[0] = sstrdup("-L");
+ argv[1] = c->redirect;
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ }
+ if (ircd->fmode && c->flood) {
+ if (flood_mode_char_remove) {
+ anope_cmd_mode(s_OperServ, c->name, "%s %s",
+ flood_mode_char_remove, c->flood);
+ argv[0] = sstrdup(flood_mode_char_remove);
+ argv[1] = c->flood;
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[0]);
+ } else {
+ if (debug) {
+ alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes");
+ }
+ }
+ }
+ }
+
+ /* Clear bans */
+ count = c->bancount;
+ bans = scalloc(sizeof(char *) * count, 1);
+
+ for (i = 0; i < count; i++)
+ bans[i] = sstrdup(c->bans[i]);
+
+ for (i = 0; i < count; i++) {
+ argv[0] = sstrdup("-b");
+ argv[1] = bans[i];
+ anope_cmd_mode(s_OperServ, c->name, "-b %s", argv[1]);
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[1]);
+ free(argv[0]);
+ }
+
+ free(bans);
+
+ excepts = NULL;
+
+ if (ircd->except) {
+ /* Clear excepts */
+ exceptcount = c->exceptcount;
+ excepts = scalloc(sizeof(char *) * exceptcount, 1);
+
+ for (i = 0; i < exceptcount; i++)
+ excepts[i] = sstrdup(c->excepts[i]);
+
+ for (i = 0; i < exceptcount; i++) {
+ argv[0] = sstrdup("-e");
+ argv[1] = excepts[i];
+ anope_cmd_mode(s_OperServ, c->name, "-e %s", argv[1]);
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[1]);
+ free(argv[0]);
+ }
+ if (excepts) {
+ free(excepts);
+ }
+ }
+
+ if (ircd->invitemode) {
+ /* Clear invites */
+ invitecount = c->invitecount;
+ invites = scalloc(sizeof(char *) * invitecount, 1);
+
+ for (i = 0; i < invitecount; i++)
+ invites[i] = sstrdup(c->invite[i]);
+
+ for (i = 0; i < invitecount; i++) {
+ argv[0] = sstrdup("-I");
+ argv[1] = excepts[i];
+ anope_cmd_mode(s_OperServ, c->name, "-I %s", argv[1]);
+ chan_set_modes(s_OperServ, c, 2, argv, 0);
+ free(argv[1]);
+ free(argv[0]);
+ }
+
+ free(invites);
+ }
+
+ }
+
+ if (all) {
+ notice_lang(s_OperServ, u, OPER_CLEARMODES_ALL_DONE, chan);
+ } else {
+ notice_lang(s_OperServ, u, OPER_CLEARMODES_DONE, chan);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c
new file mode 100644
index 000000000..3517f32d3
--- /dev/null
+++ b/src/core/os_defcon.c
@@ -0,0 +1,167 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+extern MDE time_t DefContimer;
+extern MDE void runDefCon(void);
+int do_defcon(User * u);
+void defcon_sendlvls(User * u);
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("DEFCON", do_defcon, is_services_admin,
+ OPER_HELP_DEFCON, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_DEFCON);
+ }
+}
+
+/**
+ * Defcon - A method of impelemting various stages of securty, the hope is this will help serives
+ * protect a network during an attack, allowing admins to choose the precautions taken at each
+ * level.
+ *
+ * /msg OperServ DefCon [level]
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ *
+ **/
+int do_defcon(User * u)
+{
+ char *lvl = strtok(NULL, " ");
+ int newLevel = 0;
+ char *langglobal;
+ langglobal = getstring(NULL, DEFCON_GLOBAL);
+
+ if (!DefConLevel) { /* If we dont have a .conf setting! */
+ notice_lang(s_OperServ, u, OPER_DEFCON_NO_CONF);
+ return MOD_CONT;
+ }
+
+ if (!lvl) {
+ notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel);
+ defcon_sendlvls(u);
+ return MOD_CONT;
+ }
+ newLevel = atoi(lvl);
+ if (newLevel < 1 || newLevel > 5) {
+ notice_lang(s_OperServ, u, OPER_DEFCON_SYNTAX);
+ return MOD_CONT;
+ }
+ DefConLevel = newLevel;
+ send_event(EVENT_DEFCON_LEVEL, 1, lvl);
+ DefContimer = time(NULL);
+ notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel);
+ defcon_sendlvls(u);
+ alog("Defcon level changed to %d by Oper %s", newLevel, u->nick);
+ anope_cmd_global(s_OperServ, getstring2(NULL, OPER_DEFCON_WALL),
+ u->nick, newLevel);
+ /* Global notice the user what is happening. Also any Message that
+ the Admin would like to add. Set in config file. */
+ if (GlobalOnDefcon) {
+ if ((DefConLevel == 5) && (DefConOffMessage)) {
+ oper_global(NULL, "%s", DefConOffMessage);
+ } else {
+ oper_global(NULL, langglobal, DefConLevel);
+ }
+ }
+ if (GlobalOnDefconMore) {
+ if ((DefConOffMessage) && DefConLevel == 5) {
+ } else {
+ oper_global(NULL, "%s", DefconMessage);
+ }
+ }
+ /* Run any defcon functions, e.g. FORCE CHAN MODE */
+ runDefCon();
+ return MOD_CONT;
+}
+
+
+
+/**
+ * Send a message to the oper about which precautions are "active" for this level
+ **/
+void defcon_sendlvls(User * u)
+{
+ if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_CHANNELS);
+ }
+ if (checkDefCon(DEFCON_NO_NEW_NICKS)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_NICKS);
+ }
+ if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_MLOCK_CHANGE);
+ }
+ if (checkDefCon(DEFCON_FORCE_CHAN_MODES) && (DefConChanModes)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_FORCE_CHAN_MODES,
+ DefConChanModes);
+ }
+ if (checkDefCon(DEFCON_REDUCE_SESSION)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_REDUCE_SESSION,
+ DefConSessionLimit);
+ }
+ if (checkDefCon(DEFCON_NO_NEW_CLIENTS)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_CLIENTS);
+ }
+ if (checkDefCon(DEFCON_OPER_ONLY)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_OPER_ONLY);
+ }
+ if (checkDefCon(DEFCON_SILENT_OPER_ONLY)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_SILENT_OPER_ONLY);
+ }
+ if (checkDefCon(DEFCON_AKILL_NEW_CLIENTS)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_AKILL_NEW_CLIENTS);
+ }
+ if (checkDefCon(DEFCON_NO_NEW_MEMOS)) {
+ notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_MEMOS);
+ }
+}
diff --git a/src/core/os_global.c b/src/core/os_global.c
new file mode 100644
index 000000000..37ddcca78
--- /dev/null
+++ b/src/core/os_global.c
@@ -0,0 +1,81 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_global(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("GLOBAL", do_global, is_services_oper,
+ OPER_HELP_GLOBAL, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_GLOBAL);
+ }
+}
+
+/**
+ * The /os global command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_global(User * u)
+{
+ char *msg = strtok(NULL, "");
+
+ if (!msg) {
+ syntax_error(s_OperServ, u, "GLOBAL", OPER_GLOBAL_SYNTAX);
+ return MOD_CONT;
+ }
+ if (WallOSGlobal)
+ anope_cmd_global(s_OperServ, "\2%s\2 just used GLOBAL command.",
+ u->nick);
+ oper_global(u->nick, "%s", msg);
+ return MOD_CONT;
+}
diff --git a/src/core/os_help.c b/src/core/os_help.c
new file mode 100644
index 000000000..481e3e424
--- /dev/null
+++ b/src/core/os_help.c
@@ -0,0 +1,66 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_help(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("HELP", do_help, is_oper, -1, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+
+/**
+ * The /os help command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_help(User * u)
+{
+ const char *cmd = strtok(NULL, "");
+
+ if (!cmd) {
+ notice_help(s_OperServ, u, OPER_HELP);
+ moduleDisplayHelp(5, u);
+ notice_help(s_OperServ, u, OPER_HELP_LOGGED);
+ } else {
+ mod_help_cmd(s_OperServ, u, OPERSERV, cmd);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_ignore.c b/src/core/os_ignore.c
new file mode 100644
index 000000000..a4d73d649
--- /dev/null
+++ b/src/core/os_ignore.c
@@ -0,0 +1,200 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_ignorelist(User * u);
+void myOperServHelp(User * u);
+int do_ignoreuser(User * u);
+int do_clearignore(User * u);
+void delete_ignore(const char *nick);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("IGNORE", do_ignoreuser, is_services_admin,
+ OPER_HELP_IGNORE, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_IGNORE);
+ }
+}
+
+/**
+ * The /os ignore command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_ignoreuser(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+ int t;
+
+ if (!cmd) {
+ notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (!stricmp(cmd, "ADD")) {
+
+ char *time = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+ char *rest = strtok(NULL, "");
+
+ if (!nick) {
+ notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
+ return MOD_CONT;
+ } else if (!time) {
+ notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
+ return MOD_CONT;
+ } else {
+ t = dotime(time);
+ rest = NULL;
+
+ if (t <= -1) {
+ notice_lang(s_OperServ, u, OPER_IGNORE_VALID_TIME);
+ return MOD_CONT;
+ } else if (t == 0) {
+ t = 157248000; /* if 0 is given, we set time to 157248000 seconds == 5 years (let's hope the next restart will be before that time ;-)) */
+ add_ignore(nick, t);
+ notice_lang(s_OperServ, u, OPER_IGNORE_PERM_DONE, nick);
+ } else {
+ add_ignore(nick, t);
+ notice_lang(s_OperServ, u, OPER_IGNORE_TIME_DONE, nick,
+ time);
+ }
+ }
+ } else if (!stricmp(cmd, "LIST")) {
+ do_ignorelist(u);
+ }
+
+ else if (!stricmp(cmd, "DEL")) {
+ char *nick = strtok(NULL, " ");
+ if (!nick) {
+ notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
+ } else {
+ if (get_ignore(nick) == 0) {
+ notice_lang(s_OperServ, u, OPER_IGNORE_LIST_NOMATCH, nick);
+ return MOD_CONT;
+ } else {
+ delete_ignore(nick);
+ notice_lang(s_OperServ, u, OPER_IGNORE_DEL_DONE, nick);
+ }
+ }
+ } else if (!stricmp(cmd, "CLEAR")) {
+ do_clearignore(u);
+
+ } else
+ notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
+ return MOD_CONT;
+}
+
+/* shows the Services ignore list */
+
+int do_ignorelist(User * u)
+{
+ int sent_header = 0;
+ IgnoreData *id;
+ int i;
+
+ for (i = 0; i < 256; i++) {
+ for (id = ignore[i]; id; id = id->next) {
+ if (!sent_header) {
+ notice_lang(s_OperServ, u, OPER_IGNORE_LIST);
+ sent_header = 1;
+ }
+ notice_user(s_OperServ, u, "%s", id->who);
+ }
+ }
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_IGNORE_LIST_EMPTY);
+ return MOD_CONT;
+}
+
+/* deletes a nick from the ignore list */
+
+void delete_ignore(const char *nick)
+{
+ IgnoreData *ign, *prev;
+ IgnoreData **whichlist;
+
+ if (!nick || !*nick) {
+ return;
+ }
+
+ whichlist = &ignore[tolower(nick[0])];
+
+ for (ign = *whichlist, prev = NULL; ign; prev = ign, ign = ign->next) {
+ if (stricmp(ign->who, nick) == 0)
+ break;
+ }
+ if (prev)
+ prev->next = ign->next;
+ else
+ *whichlist = ign->next;
+ free(ign);
+ ign = NULL;
+}
+
+/**************************************************************************/
+/* Cleares the Services ignore list */
+
+int do_clearignore(User * u)
+{
+ IgnoreData *id = NULL, *next = NULL;
+ int i;
+ for (i = 0; i < 256; i++) {
+ for (id = ignore[i]; id; id = next) {
+ next = id->next;
+ free(id);
+ if (!next) {
+ ignore[i] = NULL;
+ }
+ }
+ }
+ notice_lang(s_OperServ, u, OPER_IGNORE_LIST_CLEARED);
+ return MOD_CONT;
+}
diff --git a/src/core/os_jupe.c b/src/core/os_jupe.c
new file mode 100644
index 000000000..faaa55122
--- /dev/null
+++ b/src/core/os_jupe.c
@@ -0,0 +1,88 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_jupe(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("JUPE", do_jupe, is_services_admin, OPER_HELP_JUPE,
+ -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_JUPE);
+ }
+}
+
+/**
+ * The /os jupe command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_jupe(User * u)
+{
+ char *jserver = strtok(NULL, " ");
+ char *reason = strtok(NULL, "");
+
+ if (!jserver) {
+ syntax_error(s_OperServ, u, "JUPE", OPER_JUPE_SYNTAX);
+ } else {
+ if (!isValidHost(jserver, 3)) {
+ notice_lang(s_OperServ, u, OPER_JUPE_HOST_ERROR);
+ } else {
+ anope_cmd_jupe(jserver, u->nick, reason);
+
+ if (WallOSJupe)
+ anope_cmd_global(s_OperServ, "\2%s\2 used JUPE on \2%s\2",
+ u->nick, jserver);
+ }
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_kick.c b/src/core/os_kick.c
new file mode 100644
index 000000000..fa0edc440
--- /dev/null
+++ b/src/core/os_kick.c
@@ -0,0 +1,100 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_os_kick(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("KICK", do_os_kick, is_services_oper, OPER_HELP_KICK,
+ -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_KICK);
+ }
+}
+
+/**
+ * The /os kick command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_os_kick(User * u)
+{
+ char *argv[3];
+ char *chan, *nick, *s;
+ Channel *c;
+
+ chan = strtok(NULL, " ");
+ nick = strtok(NULL, " ");
+ s = strtok(NULL, "");
+ if (!chan || !nick || !s) {
+ syntax_error(s_OperServ, u, "KICK", OPER_KICK_SYNTAX);
+ return MOD_CONT;
+ }
+ if (!(c = findchan(chan))) {
+ notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (c->bouncy_modes) {
+ notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
+ return MOD_CONT;
+ }
+ anope_cmd_kick(s_OperServ, chan, nick, "%s (%s)", u->nick, s);
+ if (WallOSKick)
+ anope_cmd_global(s_OperServ, "%s used KICK on %s/%s", u->nick,
+ nick, chan);
+ argv[0] = sstrdup(chan);
+ argv[1] = sstrdup(nick);
+ argv[2] = sstrdup(s);
+ do_kick(s_OperServ, 3, argv);
+ free(argv[2]);
+ free(argv[1]);
+ free(argv[0]);
+ return MOD_CONT;
+}
diff --git a/src/core/os_killclones.c b/src/core/os_killclones.c
new file mode 100644
index 000000000..8f1ac3cbc
--- /dev/null
+++ b/src/core/os_killclones.c
@@ -0,0 +1,129 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_killclones(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("KILLCLONES", do_killclones, is_services_oper,
+ OPER_HELP_KILLCLONES, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_KILLCLONES);
+ }
+}
+
+/** Kill all users matching a certain host. The host is obtained from the
+ * supplied nick. The raw hostmsk is not supplied with the command in an effort
+ * to prevent abuse and mistakes from being made - which might cause *.com to
+ * be killed. It also makes it very quick and simple to use - which is usually
+ * what you want when someone starts loading numerous clones. In addition to
+ * killing the clones, we add a temporary AKILL to prevent them from
+ * immediately reconnecting.
+ * Syntax: KILLCLONES nick
+ * -TheShadow (29 Mar 1999)
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_killclones(User * u)
+{
+ char *clonenick = strtok(NULL, " ");
+ int count = 0;
+ User *cloneuser, *user, *tempuser;
+ char *clonemask, *akillmask;
+ char killreason[NICKMAX + 32];
+ char akillreason[] = "Temporary KILLCLONES akill.";
+
+ if (!clonenick) {
+ notice_lang(s_OperServ, u, OPER_KILLCLONES_SYNTAX);
+
+ } else if (!(cloneuser = finduser(clonenick))) {
+ notice_lang(s_OperServ, u, OPER_KILLCLONES_UNKNOWN_NICK,
+ clonenick);
+
+ } else {
+ clonemask = smalloc(strlen(cloneuser->host) + 5);
+ sprintf(clonemask, "*!*@%s", cloneuser->host);
+
+ akillmask = smalloc(strlen(cloneuser->host) + 3);
+ sprintf(akillmask, "*@%s", cloneuser->host);
+
+ user = firstuser();
+ while (user) {
+ if (match_usermask(clonemask, user) != 0) {
+ tempuser = nextuser();
+ count++;
+ snprintf(killreason, sizeof(killreason),
+ "Cloning [%d]", count);
+ kill_user(NULL, user->nick, killreason);
+ user = tempuser;
+ } else {
+ user = nextuser();
+ }
+ }
+
+ add_akill(u, akillmask, u->nick,
+ time(NULL) + KillClonesAkillExpire, akillreason);
+
+ anope_cmd_global(s_OperServ,
+ "\2%s\2 used KILLCLONES for \2%s\2 killing "
+ "\2%d\2 clones. A temporary AKILL has been added "
+ "for \2%s\2.", u->nick, clonemask, count,
+ akillmask);
+
+ alog("%s: KILLCLONES: %d clone(s) matching %s killed.",
+ s_OperServ, count, clonemask);
+
+ free(akillmask);
+ free(clonemask);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_logonnews.c b/src/core/os_logonnews.c
new file mode 100644
index 000000000..31d482574
--- /dev/null
+++ b/src/core/os_logonnews.c
@@ -0,0 +1,65 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ /**
+ * For some unknown reason, do_logonnews is actaully defined in news.c
+ * we can look at moving it here later
+ **/
+ c = createCommand("LOGONNEWS", do_logonnews, is_services_oper,
+ NEWS_HELP_LOGON, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_LOGONNEWS);
+ }
+}
diff --git a/src/core/os_mode.c b/src/core/os_mode.c
new file mode 100644
index 000000000..b926d16a4
--- /dev/null
+++ b/src/core/os_mode.c
@@ -0,0 +1,101 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_os_mode(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("MODE", do_os_mode, is_services_oper, OPER_HELP_MODE,
+ -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_MODE);
+ }
+}
+
+/**
+ * The /os mode command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_os_mode(User * u)
+{
+ int ac;
+ char **av;
+ char *chan = strtok(NULL, " "), *modes = strtok(NULL, "");
+ Channel *c;
+
+ if (!chan || !modes) {
+ syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (!(c = findchan(chan))) {
+ notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (c->bouncy_modes) {
+ notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
+ return MOD_CONT;
+ } else if ((ircd->adminmode) && (!is_services_admin(u))
+ && (c->mode & ircd->adminmode)) {
+ notice_lang(s_OperServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ } else {
+ anope_cmd_mode(s_OperServ, chan, "%s", modes);
+
+ ac = split_buf(modes, &av, 1);
+ chan_set_modes(s_OperServ, c, ac, av, -1);
+
+ if (WallOSMode)
+ anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick,
+ modes, chan);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_modinfo.c b/src/core/os_modinfo.c
new file mode 100644
index 000000000..c8bba7f92
--- /dev/null
+++ b/src/core/os_modinfo.c
@@ -0,0 +1,149 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_modinfo(User * u);
+void myOperServHelp(User * u);
+int showModuleMsgLoaded(MessageHash * msgList, char *mod_name, User * u);
+int showModuleCmdLoaded(CommandHash * cmdList, char *mod_name, User * u);
+extern MDE Module *findModule(char *name);
+
+extern MDE Module *mod_current_module;
+extern MDE int mod_current_op;
+extern MDE User *mod_current_user;
+extern MDE ModuleHash *MODULE_HASH[MAX_CMD_HASH];
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("MODINFO", do_modinfo, is_oper, -1, -1, -1, -1,
+ OPER_HELP_MODINFO);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_MODINFO);
+ }
+}
+
+/**
+ * The /os command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_modinfo(User * u)
+{
+ char *file;
+ struct tm tm;
+ char timebuf[64];
+ Module *m;
+ int idx = 0;
+ int display = 0;
+
+ file = strtok(NULL, "");
+ if (!file) {
+ syntax_error(s_OperServ, u, "MODINFO", OPER_MODULE_INFO_SYNTAX);
+ return MOD_CONT;
+ }
+ m = findModule(file);
+ if (m) {
+ tm = *localtime(&m->time);
+ strftime_lang(timebuf, sizeof(timebuf), u,
+ STRFTIME_DATE_TIME_FORMAT, &tm);
+ notice_lang(s_OperServ, u, OPER_MODULE_INFO_LIST, m->name,
+ m->version ? m->version : "?",
+ m->author ? m->author : "?", timebuf);
+ for (idx = 0; idx < MAX_CMD_HASH; idx++) {
+ display += showModuleCmdLoaded(HOSTSERV[idx], m->name, u);
+ display += showModuleCmdLoaded(OPERSERV[idx], m->name, u);
+ display += showModuleCmdLoaded(NICKSERV[idx], m->name, u);
+ display += showModuleCmdLoaded(CHANSERV[idx], m->name, u);
+ display += showModuleCmdLoaded(BOTSERV[idx], m->name, u);
+ display += showModuleCmdLoaded(MEMOSERV[idx], m->name, u);
+ display += showModuleCmdLoaded(HELPSERV[idx], m->name, u);
+ display += showModuleMsgLoaded(IRCD[idx], m->name, u);
+
+ }
+ }
+ if (display == 0) {
+ notice_lang(s_OperServ, u, OPER_MODULE_NO_INFO, file);
+ }
+ return MOD_CONT;
+}
+
+int showModuleCmdLoaded(CommandHash * cmdList, char *mod_name, User * u)
+{
+ Command *c;
+ CommandHash *current;
+ int display = 0;
+
+ for (current = cmdList; current; current = current->next) {
+ for (c = current->c; c; c = c->next) {
+ if ((c->mod_name) && (stricmp(c->mod_name, mod_name) == 0)) {
+ notice_lang(s_OperServ, u, OPER_MODULE_CMD_LIST,
+ c->service, c->name);
+ display++;
+ }
+ }
+ }
+ return display;
+}
+
+int showModuleMsgLoaded(MessageHash * msgList, char *mod_name, User * u)
+{
+ Message *msg;
+ MessageHash *mcurrent;
+ int display = 0;
+ for (mcurrent = msgList; mcurrent; mcurrent = mcurrent->next) {
+ for (msg = mcurrent->m; msg; msg = msg->next) {
+ if ((msg->mod_name) && (stricmp(msg->mod_name, mod_name) == 0)) {
+ notice_lang(s_OperServ, u, OPER_MODULE_MSG_LIST,
+ msg->name);
+ display++;
+ }
+ }
+ }
+ return display;
+}
diff --git a/src/core/os_modlist.c b/src/core/os_modlist.c
new file mode 100644
index 000000000..2a56983ea
--- /dev/null
+++ b/src/core/os_modlist.c
@@ -0,0 +1,182 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+extern MDE Module *mod_current_module;
+extern MDE int mod_current_op;
+extern MDE User *mod_current_user;
+extern MDE ModuleHash *MODULE_HASH[MAX_CMD_HASH];
+
+extern MDE Module *createModule(char *filename);
+
+int do_modlist(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("MODLIST", do_modlist, is_oper, -1, -1, -1, -1,
+ OPER_HELP_MODLIST);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_MODLIST);
+ }
+}
+
+/**
+ * The /os modlist command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_modlist(User * u)
+{
+ int idx;
+ int count = 0;
+ int showCore = 0;
+ int showThird = 1;
+ int showProto = 1;
+ int showSupported = 1;
+ int showQA = 1;
+
+ char *param;
+ ModuleHash *current = NULL;
+
+ char core[] = "Core";
+ char third[] = "3rd";
+ char proto[] = "Protocol";
+ char supported[] = "Supported";
+ char qa[] = "QATested";
+
+ param = strtok(NULL, "");
+ if (param) {
+ if (stricmp(param, core) == 0) {
+ showCore = 1;
+ showThird = 0;
+ showProto = 0;
+ showSupported = 0;
+ showQA = 0;
+ } else if (stricmp(param, third) == 0) {
+ showCore = 0;
+ showThird = 1;
+ showSupported = 0;
+ showQA = 0;
+ showProto = 0;
+ } else if (stricmp(param, proto) == 0) {
+ showCore = 0;
+ showThird = 0;
+ showProto = 1;
+ showSupported = 0;
+ showQA = 0;
+ } else if (stricmp(param, supported) == 0) {
+ showCore = 0;
+ showThird = 0;
+ showProto = 0;
+ showSupported = 1;
+ showQA = 0;
+ } else if (stricmp(param, qa) == 0) {
+ showCore = 0;
+ showThird = 0;
+ showProto = 0;
+ showSupported = 0;
+ showQA = 1;
+ }
+ }
+
+ notice_lang(s_OperServ, u, OPER_MODULE_LIST_HEADER);
+
+ for (idx = 0; idx != MAX_CMD_HASH; idx++) {
+ for (current = MODULE_HASH[idx]; current; current = current->next) {
+ switch (current->m->type) {
+ case CORE:
+ if (showCore) {
+ notice_lang(s_OperServ, u, OPER_MODULE_LIST,
+ current->name, current->m->version, core);
+ count++;
+ }
+ break;
+ case THIRD:
+ if (showThird) {
+ notice_lang(s_OperServ, u, OPER_MODULE_LIST,
+ current->name, current->m->version, third);
+ count++;
+ }
+ break;
+ case PROTOCOL:
+ if (showProto) {
+ notice_lang(s_OperServ, u, OPER_MODULE_LIST,
+ current->name, current->m->version, proto);
+ count++;
+ }
+ break;
+ case SUPPORTED:
+ if (showSupported) {
+ notice_lang(s_OperServ, u, OPER_MODULE_LIST,
+ current->name, current->m->version,
+ supported);
+ count++;
+ }
+ break;
+ case QATESTED:
+ if (showQA) {
+ notice_lang(s_OperServ, u, OPER_MODULE_LIST,
+ current->name, current->m->version, qa);
+ count++;
+ }
+ break;
+ }
+
+ }
+ }
+ if (count == 0) {
+ notice_lang(s_OperServ, u, OPER_MODULE_NO_LIST);
+ } else {
+ notice_lang(s_OperServ, u, OPER_MODULE_LIST_FOOTER, count);
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/core/os_modload.c b/src/core/os_modload.c
new file mode 100644
index 000000000..732d629f4
--- /dev/null
+++ b/src/core/os_modload.c
@@ -0,0 +1,96 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+extern MDE Module *mod_current_module;
+extern MDE int mod_current_op;
+extern MDE User *mod_current_user;
+extern MDE ModuleHash *MODULE_HASH[MAX_CMD_HASH];
+
+extern MDE Module *createModule(char *filename);
+
+int do_modload(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("MODLOAD", do_modload, is_services_root, -1, -1, -1,
+ -1, OPER_HELP_MODLOAD);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_root(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_MODLOAD);
+ }
+}
+
+/**
+ * The /os modload command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_modload(User * u)
+{
+ char *name;
+ Module *m;
+
+ name = strtok(NULL, "");
+ if (!name) {
+ syntax_error(s_OperServ, u, "MODLOAD", OPER_MODULE_LOAD_SYNTAX);
+ return MOD_CONT;
+ }
+ m = findModule(name);
+ if (!m) {
+ m = createModule(name);
+ mod_current_module = m;
+ mod_current_user = u;
+ mod_current_op = 1;
+ } else {
+ notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, name);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_modunload.c b/src/core/os_modunload.c
new file mode 100644
index 000000000..315c7a7c4
--- /dev/null
+++ b/src/core/os_modunload.c
@@ -0,0 +1,95 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+extern MDE Module *mod_current_module;
+extern MDE int mod_current_op;
+extern MDE User *mod_current_user;
+extern MDE ModuleHash *MODULE_HASH[MAX_CMD_HASH];
+
+int do_modunload(User * u);
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("MODUNLOAD", do_modunload, is_services_root, -1, -1,
+ -1, -1, OPER_HELP_MODUNLOAD);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_root(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_MODUNLOAD);
+ }
+}
+
+/**
+ * The /os modunload command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_modunload(User * u)
+{
+ char *name;
+ Module *m;
+
+ name = strtok(NULL, "");
+ if (!name) {
+ syntax_error(s_OperServ, u, "MODUNLOAD",
+ OPER_MODULE_UNLOAD_SYNTAX);
+ return MOD_CONT;
+ }
+ m = findModule(name);
+ if (m) {
+ mod_current_user = u;
+ mod_current_module = m;
+ mod_current_op = 2;
+ } else {
+ notice_lang(s_OperServ, u, OPER_MODULE_REMOVE_FAIL, name);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_noop.c b/src/core/os_noop.c
new file mode 100644
index 000000000..774433a34
--- /dev/null
+++ b/src/core/os_noop.c
@@ -0,0 +1,106 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_noop(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("NOOP", do_noop, is_services_admin, OPER_HELP_NOOP,
+ -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_NOOP);
+ }
+}
+
+/**
+ * The /os noop command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_noop(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+ char *server = strtok(NULL, " ");
+
+ if (!cmd || !server) {
+ syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX);
+ } else if (!stricmp(cmd, "SET")) {
+ User *u2;
+ User *u3 = NULL;
+ char reason[NICKMAX + 32];
+
+ /* Remove the O:lines */
+ anope_cmd_svsnoop(server, 1);
+
+ snprintf(reason, sizeof(reason), "NOOP command used by %s",
+ u->nick);
+ if (WallOSNoOp)
+ anope_cmd_global(s_OperServ, "\2%s\2 used NOOP on \2%s\2",
+ u->nick, server);
+ notice_lang(s_OperServ, u, OPER_NOOP_SET, server);
+
+ /* Kill all the IRCops of the server */
+ for (u2 = firstuser(); u2; u2 = u3) {
+ u3 = nextuser();
+ if ((u2) && is_oper(u2) && (u2->server->name)
+ && match_wild(server, u2->server->name)) {
+ kill_user(s_OperServ, u2->nick, reason);
+ }
+ }
+ } else if (!stricmp(cmd, "REVOKE")) {
+ anope_cmd_svsnoop(server, 0);
+ notice_lang(s_OperServ, u, OPER_NOOP_REVOKE, server);
+ } else {
+ syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_oline.c b/src/core/os_oline.c
new file mode 100644
index 000000000..39ae5ae49
--- /dev/null
+++ b/src/core/os_oline.c
@@ -0,0 +1,111 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+int do_operoline(User * u);
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("OLINE", do_operoline, is_services_admin,
+ OPER_HELP_OLINE, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ if (!ircd->omode) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u) && u->isSuperAdmin) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_OLINE);
+ }
+}
+
+/**
+ * The /os oline command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_operoline(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ char *flags = strtok(NULL, "");
+ User *u2 = NULL;
+
+ /* Only allow this if SuperAdmin is enabled */
+ if (!u->isSuperAdmin) {
+ notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
+ return MOD_CONT;
+ }
+
+ if (!nick || !flags) {
+ syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
+ return MOD_CONT;
+ } else {
+ u2 = finduser(nick);
+
+/* let's check whether the user is online */
+
+ if (!finduser(nick)) {
+ notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
+ } else if (u2 && flags[0] == '+') {
+ anope_cmd_svso(s_OperServ, nick, flags);
+ anope_cmd_mode(s_OperServ, nick, "+o");
+ common_svsmode(u2, "+o", NULL);
+ notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP);
+ notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
+ anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
+ u->nick, nick);
+ } else if (u2 && flags[0] == '-') {
+ anope_cmd_svso(s_OperServ, nick, flags);
+ notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
+ anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
+ u->nick, nick);
+ } else
+ syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_oper.c b/src/core/os_oper.c
new file mode 100644
index 000000000..4df712036
--- /dev/null
+++ b/src/core/os_oper.c
@@ -0,0 +1,244 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_oper(User * u);
+int oper_list_callback(SList * slist, int number, void *item,
+ va_list args);
+int oper_list(int number, NickCore * nc, User * u, int *sent_header);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("OPER", do_oper, is_oper, OPER_HELP_OPER, -1, -1, -1,
+ -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_OPER);
+ }
+}
+
+/**
+ * The /os oper command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_oper(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+ char *nick = strtok(NULL, " ");
+ NickAlias *na;
+ int res = 0;
+
+ if (skeleton) {
+ notice_lang(s_OperServ, u, OPER_OPER_SKELETON);
+ return MOD_CONT;
+ }
+
+ if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) {
+ syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX);
+ } else if (!stricmp(cmd, "ADD")) {
+ if (!is_services_admin(u)) {
+ notice_lang(s_OperServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (!(na = findnick(nick))) {
+ notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
+ return MOD_CONT;
+ }
+
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick);
+ return MOD_CONT;
+ }
+
+ if (na->nc->flags & NI_SERVICES_OPER
+ || slist_indexof(&servopers, na->nc) != -1) {
+ notice_lang(s_OperServ, u, OPER_OPER_EXISTS, nick);
+ return MOD_CONT;
+ }
+
+ res = slist_add(&servopers, na->nc);
+ if (res == -2) {
+ notice_lang(s_OperServ, u, OPER_OPER_REACHED_LIMIT, nick);
+ return MOD_CONT;
+ } else {
+ if (na->nc->flags & NI_SERVICES_ADMIN
+ && (res = slist_indexof(&servadmins, na->nc)) != -1) {
+ slist_delete(&servadmins, res);
+ na->nc->flags |= NI_SERVICES_OPER;
+ notice_lang(s_OperServ, u, OPER_OPER_MOVED, nick);
+ } else {
+ na->nc->flags |= NI_SERVICES_OPER;
+ notice_lang(s_OperServ, u, OPER_OPER_ADDED, nick);
+ }
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+ } else if (!stricmp(cmd, "DEL")) {
+ if (!is_services_admin(u)) {
+ notice_lang(s_OperServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) {
+ /* Deleting a range */
+ res = slist_delete_range(&servopers, nick, NULL);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH);
+ return MOD_CONT;
+ } else if (res == 1) {
+ notice_lang(s_OperServ, u, OPER_OPER_DELETED_ONE);
+ } else {
+ notice_lang(s_OperServ, u, OPER_OPER_DELETED_SEVERAL, res);
+ }
+ } else {
+ if (!(na = findnick(nick))) {
+ notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
+ return MOD_CONT;
+ }
+
+ if (na->status & NS_VERBOTEN) {
+ notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick);
+ return MOD_CONT;
+ }
+
+ if (!(na->nc->flags & NI_SERVICES_OPER)
+ || (res = slist_indexof(&servopers, na->nc)) == -1) {
+ notice_lang(s_OperServ, u, OPER_OPER_NOT_FOUND, nick);
+ return MOD_CONT;
+ }
+
+ slist_delete(&servopers, res);
+ notice_lang(s_OperServ, u, OPER_OPER_DELETED, nick);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+ } else if (!stricmp(cmd, "LIST")) {
+ int sent_header = 0;
+
+ if (servopers.count == 0) {
+ notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ if (!nick || (isdigit(*nick)
+ && strspn(nick, "1234567890,-") == strlen(nick))) {
+ res =
+ slist_enum(&servopers, nick, &oper_list_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH);
+ return MOD_CONT;
+ } else {
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Oper");
+ }
+ } else {
+ int i;
+
+ for (i = 0; i < servopers.count; i++)
+ if (!stricmp
+ (nick, ((NickCore *) servopers.list[i])->display)
+ || match_wild_nocase(nick,
+ ((NickCore *) servopers.list[i])->
+ display))
+ oper_list(i + 1, servopers.list[i], u, &sent_header);
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH);
+ else {
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Oper");
+ }
+ }
+ } else if (!stricmp(cmd, "CLEAR")) {
+ if (!is_services_admin(u)) {
+ notice_lang(s_OperServ, u, PERMISSION_DENIED);
+ return MOD_CONT;
+ }
+
+ if (servopers.count == 0) {
+ notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ slist_clear(&servopers, 1);
+ notice_lang(s_OperServ, u, OPER_OPER_CLEAR);
+ } else {
+ syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/* Lists an oper entry, prefixing it with the header if needed */
+
+int oper_list(int number, NickCore * nc, User * u, int *sent_header)
+{
+ if (!nc)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_OPER_LIST_HEADER);
+ *sent_header = 1;
+ }
+
+ notice_lang(s_OperServ, u, OPER_OPER_LIST_FORMAT, number, nc->display);
+ return 1;
+}
+
+/* Callback for enumeration purposes */
+
+int oper_list_callback(SList * slist, int number, void *item, va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return oper_list(number, item, u, sent_header);
+}
diff --git a/src/core/os_opernews.c b/src/core/os_opernews.c
new file mode 100644
index 000000000..706357893
--- /dev/null
+++ b/src/core/os_opernews.c
@@ -0,0 +1,65 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ /**
+ * For some unknown reason, do_opernews is actaully defined in news.c
+ * we can look at moving it here later
+ **/
+ c = createCommand("OPERNEWS", do_opernews, is_services_oper,
+ NEWS_HELP_LOGON, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_OPERNEWS);
+ }
+}
diff --git a/src/core/os_quit.c b/src/core/os_quit.c
new file mode 100644
index 000000000..6b7fe8f79
--- /dev/null
+++ b/src/core/os_quit.c
@@ -0,0 +1,82 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_os_quit(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("QUIT", do_os_quit, is_services_admin,
+ OPER_HELP_QUIT, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_QUIT);
+ }
+}
+
+/**
+ * The /os quit command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_os_quit(User * u)
+{
+ quitmsg = calloc(28 + strlen(u->nick), 1);
+ if (!quitmsg)
+ quitmsg = "QUIT command received, but out of memory!";
+ else
+ sprintf(quitmsg, "QUIT command received from %s", u->nick);
+
+ if (GlobalOnCycle) {
+ oper_global(NULL, "%s", GlobalOnCycleMessage);
+ }
+ quitting = 1;
+ return MOD_CONT;
+}
diff --git a/src/core/os_randomnews.c b/src/core/os_randomnews.c
new file mode 100644
index 000000000..cf5ab6b3a
--- /dev/null
+++ b/src/core/os_randomnews.c
@@ -0,0 +1,65 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ /**
+ * For some unknown reason, do_randomnews is actaully defined in news.c
+ * we can look at moving it here later
+ **/
+ c = createCommand("RANDOMNEWS", do_randomnews, is_services_oper,
+ NEWS_HELP_OPER, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_RANDOMNEWS);
+ }
+}
diff --git a/src/core/os_raw.c b/src/core/os_raw.c
new file mode 100644
index 000000000..64e85dadd
--- /dev/null
+++ b/src/core/os_raw.c
@@ -0,0 +1,77 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_raw(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("RAW", do_raw, is_services_admin, OPER_HELP_RAW, -1,
+ -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ if (DisableRaw) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * The /os raw command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_raw(User * u)
+{
+ char *text = strtok(NULL, "");
+ if (!text)
+ syntax_error(s_OperServ, u, "RAW", OPER_RAW_SYNTAX);
+ else {
+ send_cmd(NULL, "%s", text);
+ if (WallOSRaw) {
+ char *kw = strtok(text, " ");
+ while (kw && *kw == ':')
+ kw = strtok(NULL, " ");
+ anope_cmd_global(s_OperServ,
+ "\2%s\2 used RAW command for \2%s\2",
+ u->nick,
+ (kw ? kw : "\2non RFC compliant message\2"));
+ }
+ alog("%s used RAW command for %s", u->nick, text);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_reload.c b/src/core/os_reload.c
new file mode 100644
index 000000000..2ea882b6c
--- /dev/null
+++ b/src/core/os_reload.c
@@ -0,0 +1,84 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_reload(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("RELOAD", do_reload, is_services_admin,
+ OPER_HELP_RELOAD, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_RELOAD);
+ }
+}
+
+/**
+ * The /os relaod command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_reload(User * u)
+{
+ if (!read_config(1)) {
+ quitmsg = calloc(28 + strlen(u->nick), 1);
+ if (!quitmsg)
+ quitmsg =
+ "Error during the reload of the configuration file, but out of memory!";
+ else
+ sprintf(quitmsg,
+ "Error during the reload of the configuration file!");
+ quitting = 1;
+ }
+ send_event(EVENT_RELOAD, 1, EVENT_START);
+ notice_lang(s_OperServ, u, OPER_RELOAD);
+ return MOD_CONT;
+}
diff --git a/src/core/os_restart.c b/src/core/os_restart.c
new file mode 100644
index 000000000..eb4bd7e2c
--- /dev/null
+++ b/src/core/os_restart.c
@@ -0,0 +1,89 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+/* OperServ restart needs access to this if were gonna avoid sending ourself a signal */
+extern MDE void do_restart_services(void);
+
+int do_restart(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+ c = createCommand("RESTART", do_restart, is_services_admin,
+ OPER_HELP_RESTART, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_RESTART);
+ }
+}
+
+/**
+ * The /os restart command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_restart(User * u)
+{
+#ifdef SERVICES_BIN
+ quitmsg = calloc(31 + strlen(u->nick), 1);
+ if (!quitmsg)
+ quitmsg = "RESTART command received, but out of memory!";
+ else
+ sprintf(quitmsg, "RESTART command received from %s", u->nick);
+
+ if (GlobalOnCycle) {
+ oper_global(NULL, "%s", GlobalOnCycleMessage);
+ }
+ /* raise(SIGHUP); */
+ do_restart_services();
+#else
+ notice_lang(s_OperServ, u, OPER_CANNOT_RESTART);
+#endif
+ return MOD_CONT;
+}
diff --git a/src/core/os_session.c b/src/core/os_session.c
new file mode 100644
index 000000000..6be2dfb26
--- /dev/null
+++ b/src/core/os_session.c
@@ -0,0 +1,68 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ /**
+ * do_session/do_exception are exported from sessions.c - we just want to provide an interface.
+ **/
+ c = createCommand("SESSION", do_session, is_services_admin,
+ OPER_HELP_SESSION, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("EXCEPTION", do_exception, is_services_admin,
+ OPER_HELP_EXCEPTION, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_SESSION);
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_EXCEPTION);
+ }
+}
diff --git a/src/core/os_set.c b/src/core/os_set.c
new file mode 100644
index 000000000..616d65a57
--- /dev/null
+++ b/src/core/os_set.c
@@ -0,0 +1,262 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_set(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SET", do_set, is_services_admin, OPER_HELP_SET, -1,
+ -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("SET LIST", NULL, NULL, OPER_HELP_SET_LIST, -1, -1,
+ -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("SET READONLY", NULL, NULL, OPER_HELP_SET_READONLY,
+ -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("SET LOGCHAN", NULL, NULL, OPER_HELP_SET_LOGCHAN, -1,
+ -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("SET DEBUG", NULL, NULL, OPER_HELP_SET_DEBUG, -1, -1,
+ -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("SET NOEXPIRE", NULL, NULL, OPER_HELP_SET_NOEXPIRE,
+ -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("SET IGNORE", NULL, NULL, OPER_HELP_SET_IGNORE, -1,
+ -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("SET SUPERADMIN", NULL, NULL,
+ OPER_HELP_SET_SUPERADMIN, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+#ifdef USE_MYSQL
+ c = createCommand("SET SQL", NULL, NULL, OPER_HELP_SET_SQL, -1, -1, -1,
+ -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+#endif
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_SET);
+ }
+}
+
+/**
+ * The /os set command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_set(User * u)
+{
+ char *option = strtok(NULL, " ");
+ char *setting = strtok(NULL, " ");
+ int index;
+
+ if (!option) {
+ syntax_error(s_OperServ, u, "SET", OPER_SET_SYNTAX);
+ } else if (stricmp(option, "LIST") == 0) {
+ index =
+ (allow_ignore ? OPER_SET_LIST_OPTION_ON :
+ OPER_SET_LIST_OPTION_OFF);
+ notice_lang(s_OperServ, u, index, "IGNORE");
+ index =
+ (readonly ? OPER_SET_LIST_OPTION_ON :
+ OPER_SET_LIST_OPTION_OFF);
+ notice_lang(s_OperServ, u, index, "READONLY");
+ index =
+ (logchan ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF);
+ notice_lang(s_OperServ, u, index, "LOGCHAN");
+ index =
+ (debug ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF);
+ notice_lang(s_OperServ, u, index, "DEBUG");
+ index =
+ (noexpire ? OPER_SET_LIST_OPTION_ON :
+ OPER_SET_LIST_OPTION_OFF);
+ notice_lang(s_OperServ, u, index, "NOEXPIRE");
+#ifdef USE_MYSQL
+ index =
+ (do_mysql ? OPER_SET_LIST_OPTION_ON :
+ OPER_SET_LIST_OPTION_OFF);
+ notice_lang(s_OperServ, u, index, "SQL");
+#endif
+ } else if (!setting) {
+ syntax_error(s_OperServ, u, "SET", OPER_SET_SYNTAX);
+ } else if (stricmp(option, "IGNORE") == 0) {
+ if (stricmp(setting, "on") == 0) {
+ allow_ignore = 1;
+ notice_lang(s_OperServ, u, OPER_SET_IGNORE_ON);
+ } else if (stricmp(setting, "off") == 0) {
+ allow_ignore = 0;
+ notice_lang(s_OperServ, u, OPER_SET_IGNORE_OFF);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SET_IGNORE_ERROR);
+ }
+#ifdef USE_MYSQL
+ } else if (stricmp(option, "SQL") == 0) {
+ if (stricmp(setting, "on") == 0) {
+ if (!MysqlHost) {
+ notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_DISABLED);
+ } else {
+ if (rdb_init()) {
+ notice_lang(s_OperServ, u, OPER_SET_SQL_ON);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_INIT);
+ }
+ }
+ } else if (stricmp(setting, "off") == 0) {
+ if (!MysqlHost) {
+ notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_DISABLED);
+ } else {
+ /* could call rdb_close() but that does nothing - TSL */
+ do_mysql = 0;
+ notice_lang(s_OperServ, u, OPER_SET_SQL_OFF);
+ }
+ } else {
+ notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR);
+ }
+#endif
+ } else if (stricmp(option, "READONLY") == 0) {
+ if (stricmp(setting, "on") == 0) {
+ readonly = 1;
+ alog("Read-only mode activated");
+ close_log();
+ notice_lang(s_OperServ, u, OPER_SET_READONLY_ON);
+ } else if (stricmp(setting, "off") == 0) {
+ readonly = 0;
+ open_log();
+ alog("Read-only mode deactivated");
+ notice_lang(s_OperServ, u, OPER_SET_READONLY_OFF);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SET_READONLY_ERROR);
+ }
+
+ } else if (stricmp(option, "LOGCHAN") == 0) {
+ /* Unlike the other SET commands where only stricmp is necessary,
+ * we also have to ensure that LogChannel is defined or we can't
+ * send to it.
+ *
+ * -jester
+ */
+ if (LogChannel && (stricmp(setting, "on") == 0)) {
+ if (ircd->join2msg) {
+ anope_cmd_join(s_GlobalNoticer, LogChannel, time(NULL));
+ }
+ logchan = 1;
+ alog("Now sending log messages to %s", LogChannel);
+ notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_ON, LogChannel);
+ } else if (LogChannel && (stricmp(setting, "off") == 0)) {
+ alog("No longer sending log messages to a channel");
+ if (ircd->join2msg) {
+ anope_cmd_part(s_GlobalNoticer, LogChannel, NULL);
+ }
+ logchan = 0;
+ notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_OFF);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_ERROR);
+ }
+ /**
+ * Allow the user to turn super admin on/off
+ *
+ * Rob
+ **/
+ } else if (stricmp(option, "SUPERADMIN") == 0) {
+ if (!SuperAdmin) {
+ notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_NOT_ENABLED);
+ } else if (stricmp(setting, "on") == 0) {
+ u->isSuperAdmin = 1;
+ notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ON);
+ alog("%s: %s is a SuperAdmin ", s_OperServ, u->nick);
+ anope_cmd_global(s_OperServ,
+ getstring2(NULL, OPER_SUPER_ADMIN_WALL_ON),
+ u->nick);
+ } else if (stricmp(setting, "off") == 0) {
+ u->isSuperAdmin = 0;
+ notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_OFF);
+ alog("%s: %s is no longer a SuperAdmin", s_OperServ, u->nick);
+ anope_cmd_global(s_OperServ,
+ getstring2(NULL, OPER_SUPER_ADMIN_WALL_OFF),
+ u->nick);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_SYNTAX);
+ }
+ } else if (stricmp(option, "DEBUG") == 0) {
+ if (stricmp(setting, "on") == 0) {
+ debug = 1;
+ alog("Debug mode activated");
+ notice_lang(s_OperServ, u, OPER_SET_DEBUG_ON);
+ } else if (stricmp(setting, "off") == 0 ||
+ (*setting == '0' && atoi(setting) == 0)) {
+ alog("Debug mode deactivated");
+ debug = 0;
+ notice_lang(s_OperServ, u, OPER_SET_DEBUG_OFF);
+ } else if (isdigit(*setting) && atoi(setting) > 0) {
+ debug = atoi(setting);
+ alog("Debug mode activated (level %d)", debug);
+ notice_lang(s_OperServ, u, OPER_SET_DEBUG_LEVEL, debug);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SET_DEBUG_ERROR);
+ }
+
+ } else if (stricmp(option, "NOEXPIRE") == 0) {
+ if (stricmp(setting, "ON") == 0) {
+ noexpire = 1;
+ alog("No expire mode activated");
+ notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_ON);
+ } else if (stricmp(setting, "OFF") == 0) {
+ noexpire = 0;
+ alog("No expire mode deactivated");
+ notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_OFF);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_ERROR);
+ }
+ } else {
+ notice_lang(s_OperServ, u, OPER_SET_UNKNOWN_OPTION, option);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_sgline.c b/src/core/os_sgline.c
new file mode 100644
index 000000000..aa1520e24
--- /dev/null
+++ b/src/core/os_sgline.c
@@ -0,0 +1,355 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int sgline_view_callback(SList * slist, int number, void *item,
+ va_list args);
+int sgline_view(int number, SXLine * sx, User * u, int *sent_header);
+int sgline_list_callback(SList * slist, int number, void *item,
+ va_list args);
+int sgline_list(int number, SXLine * sx, User * u, int *sent_header);
+int do_sgline(User * u);
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SGLINE", do_sgline, is_services_oper,
+ OPER_HELP_SGLINE, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ if (!ircd->sgline) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_SGLINE);
+ }
+}
+
+/**
+ * The /os sgline command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_sgline(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+
+ if (!cmd)
+ cmd = "";
+
+ if (!stricmp(cmd, "ADD")) {
+ int deleted = 0;
+ char *expiry, *mask, *reason;
+ time_t expires;
+
+ mask = strtok(NULL, ":");
+ if (mask && *mask == '+') {
+ expiry = mask;
+ mask = strchr(expiry, ' ');
+ if (mask) {
+ *mask = 0;
+ mask++;
+ }
+ } else {
+ expiry = NULL;
+ }
+
+ expires = expiry ? dotime(expiry) : SGLineExpiry;
+ /* If the expiry given does not contain a final letter, it's in days,
+ * said the doc. Ah well.
+ */
+ if (expiry && isdigit(expiry[strlen(expiry) - 1]))
+ expires *= 86400;
+ /* Do not allow less than a minute expiry time */
+ if (expires != 0 && expires < 60) {
+ notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
+ return MOD_CONT;
+ } else if (expires > 0) {
+ expires += time(NULL);
+ }
+
+ if (mask && (reason = strtok(NULL, ""))) {
+ /* We first do some sanity check on the proposed mask. */
+
+ if (mask && strspn(mask, "*?") == strlen(mask)) {
+ notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask);
+ return MOD_CONT;
+ }
+
+ deleted = add_sgline(u, mask, u->nick, expires, reason);
+ if (deleted < 0)
+ return MOD_CONT;
+ else if (deleted)
+ notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL,
+ deleted);
+ notice_lang(s_OperServ, u, OPER_SGLINE_ADDED, mask);
+
+ if (WallOSSGLine) {
+ char buf[128];
+
+ if (!expires) {
+ strcpy(buf, "does not expire");
+ } else {
+ int wall_expiry = expires - time(NULL);
+ char *s = NULL;
+
+ if (wall_expiry >= 86400) {
+ wall_expiry /= 86400;
+ s = "day";
+ } else if (wall_expiry >= 3600) {
+ wall_expiry /= 3600;
+ s = "hour";
+ } else if (wall_expiry >= 60) {
+ wall_expiry /= 60;
+ s = "minute";
+ }
+
+ snprintf(buf, sizeof(buf), "expires in %d %s%s",
+ wall_expiry, s,
+ (wall_expiry == 1) ? "" : "s");
+ }
+
+ anope_cmd_global(s_OperServ,
+ "%s added an SGLINE for %s (%s)", u->nick,
+ mask, buf);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+
+ } else {
+ syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX);
+ }
+
+ } else if (!stricmp(cmd, "DEL")) {
+
+ char *mask;
+ int res = 0;
+
+ mask = strtok(NULL, "");
+
+ if (!mask) {
+ syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (sglines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
+ /* Deleting a range */
+ res = slist_delete_range(&sglines, mask, NULL);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
+ return MOD_CONT;
+ } else if (res == 1) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_ONE);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL,
+ res);
+ }
+ } else {
+ if ((res = slist_indexof(&sglines, mask)) == -1) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_NOT_FOUND, mask);
+ return MOD_CONT;
+ }
+
+ slist_delete(&sglines, res);
+ notice_lang(s_OperServ, u, OPER_SGLINE_DELETED, mask);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+
+ } else if (!stricmp(cmd, "LIST")) {
+ char *mask;
+ int res, sent_header = 0;
+
+ if (sglines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ mask = strtok(NULL, "");
+
+ if (!mask || (isdigit(*mask)
+ && strspn(mask, "1234567890,-") == strlen(mask))) {
+ res =
+ slist_enum(&sglines, mask, &sgline_list_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
+ return MOD_CONT;
+ }
+ } else {
+ int i;
+ char *amask;
+
+ for (i = 0; i < sglines.count; i++) {
+ amask = ((SXLine *) sglines.list[i])->mask;
+ if (!stricmp(mask, amask)
+ || match_wild_nocase(mask, amask))
+ sgline_list(i + 1, sglines.list[i], u, &sent_header);
+ }
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
+ else {
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SGLine");
+ }
+ }
+ } else if (!stricmp(cmd, "VIEW")) {
+ char *mask;
+ int res, sent_header = 0;
+
+ if (sglines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ mask = strtok(NULL, "");
+
+ if (!mask || (isdigit(*mask)
+ && strspn(mask, "1234567890,-") == strlen(mask))) {
+ res =
+ slist_enum(&sglines, mask, &sgline_view_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
+ return MOD_CONT;
+ }
+ } else {
+ int i;
+ char *amask;
+
+ for (i = 0; i < sglines.count; i++) {
+ amask = ((SXLine *) sglines.list[i])->mask;
+ if (!stricmp(mask, amask)
+ || match_wild_nocase(mask, amask))
+ sgline_view(i + 1, sglines.list[i], u, &sent_header);
+ }
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
+ }
+ } else if (!stricmp(cmd, "CLEAR")) {
+ slist_clear(&sglines, 1);
+ notice_lang(s_OperServ, u, OPER_SGLINE_CLEAR);
+ } else {
+ syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+/* Lists an SGLINE entry, prefixing it with the header if needed */
+
+int sgline_view(int number, SXLine * sx, User * u, int *sent_header)
+{
+ char timebuf[32], expirebuf[256];
+ struct tm tm;
+
+ if (!sx)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_VIEW_HEADER);
+ *sent_header = 1;
+ }
+
+ tm = *localtime(&sx->seton);
+ strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT,
+ &tm);
+ expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires);
+ notice_lang(s_OperServ, u, OPER_SGLINE_VIEW_FORMAT, number, sx->mask,
+ sx->by, timebuf, expirebuf, sx->reason);
+
+ return 1;
+}
+
+/* Callback for enumeration purposes */
+
+int sgline_view_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return sgline_view(number, item, u, sent_header);
+}
+
+/* Lists an SGLINE entry, prefixing it with the header if needed */
+
+int sgline_list(int number, SXLine * sx, User * u, int *sent_header)
+{
+ if (!sx)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_SGLINE_LIST_HEADER);
+ *sent_header = 1;
+ }
+
+ notice_lang(s_OperServ, u, OPER_SGLINE_LIST_FORMAT, number, sx->mask,
+ sx->reason);
+
+ return 1;
+}
+
+/* Callback for enumeration purposes */
+
+int sgline_list_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return sgline_list(number, item, u, sent_header);
+}
diff --git a/src/core/os_shutdown.c b/src/core/os_shutdown.c
new file mode 100644
index 000000000..74e61436c
--- /dev/null
+++ b/src/core/os_shutdown.c
@@ -0,0 +1,83 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_shutdown(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SHUTDOWN", do_shutdown, is_services_admin,
+ OPER_HELP_SHUTDOWN, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_SHUTDOWN);
+ }
+}
+
+/**
+ * The /os shutdown command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_shutdown(User * u)
+{
+ quitmsg = calloc(32 + strlen(u->nick), 1);
+ if (!quitmsg)
+ quitmsg = "SHUTDOWN command received, but out of memory!";
+ else
+ sprintf(quitmsg, "SHUTDOWN command received from %s", u->nick);
+
+ if (GlobalOnCycle) {
+ oper_global(NULL, "%s", GlobalOnCycleMessage);
+ }
+ save_data = 1;
+ delayed_quit = 1;
+ return MOD_CONT;
+}
diff --git a/src/core/os_sqline.c b/src/core/os_sqline.c
new file mode 100644
index 000000000..9e9bc63d7
--- /dev/null
+++ b/src/core/os_sqline.c
@@ -0,0 +1,355 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_sqline(User * u);
+int sqline_view_callback(SList * slist, int number, void *item,
+ va_list args);
+int sqline_view(int number, SXLine * sx, User * u, int *sent_header);
+int sqline_list_callback(SList * slist, int number, void *item,
+ va_list args);
+int sqline_list(int number, SXLine * sx, User * u, int *sent_header);
+
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SQLINE", do_sqline, is_services_oper,
+ OPER_HELP_SQLINE, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+ if (!ircd->sqline) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_SQLINE);
+ }
+}
+
+/**
+ * The /os sqline command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_sqline(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+
+ if (!cmd)
+ cmd = "";
+
+ if (!stricmp(cmd, "ADD")) {
+ int deleted = 0;
+ char *expiry, *mask, *reason;
+ time_t expires;
+
+ mask = strtok(NULL, " ");
+ if (mask && *mask == '+') {
+ expiry = mask;
+ mask = strtok(NULL, " ");
+ } else {
+ expiry = NULL;
+ }
+
+ expires = expiry ? dotime(expiry) : SQLineExpiry;
+ /* If the expiry given does not contain a final letter, it's in days,
+ * said the doc. Ah well.
+ */
+ if (expiry && isdigit(expiry[strlen(expiry) - 1]))
+ expires *= 86400;
+ /* Do not allow less than a minute expiry time */
+ if (expires != 0 && expires < 60) {
+ notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
+ return MOD_CONT;
+ } else if (expires > 0) {
+ expires += time(NULL);
+ }
+
+ if (mask && (reason = strtok(NULL, ""))) {
+
+ /* We first do some sanity check on the proposed mask. */
+ if (strspn(mask, "*") == strlen(mask)) {
+ notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask);
+ return MOD_CONT;
+ }
+
+ /* Channel SQLINEs are only supported on Bahamut servers */
+ if (*mask == '#' && !ircd->chansqline) {
+ notice_lang(s_OperServ, u,
+ OPER_SQLINE_CHANNELS_UNSUPPORTED);
+ return MOD_CONT;
+ }
+
+ deleted = add_sqline(u, mask, u->nick, expires, reason);
+ if (deleted < 0)
+ return MOD_CONT;
+ else if (deleted)
+ notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL,
+ deleted);
+ notice_lang(s_OperServ, u, OPER_SQLINE_ADDED, mask);
+
+ if (WallOSSQLine) {
+ char buf[128];
+
+ if (!expires) {
+ strcpy(buf, "does not expire");
+ } else {
+ int wall_expiry = expires - time(NULL);
+ char *s = NULL;
+
+ if (wall_expiry >= 86400) {
+ wall_expiry /= 86400;
+ s = "day";
+ } else if (wall_expiry >= 3600) {
+ wall_expiry /= 3600;
+ s = "hour";
+ } else if (wall_expiry >= 60) {
+ wall_expiry /= 60;
+ s = "minute";
+ }
+
+ snprintf(buf, sizeof(buf), "expires in %d %s%s",
+ wall_expiry, s,
+ (wall_expiry == 1) ? "" : "s");
+ }
+
+ anope_cmd_global(s_OperServ,
+ "%s added an SQLINE for %s (%s)", u->nick,
+ mask, buf);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+
+ } else {
+ syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX);
+ }
+
+ } else if (!stricmp(cmd, "DEL")) {
+
+ char *mask;
+ int res = 0;
+
+ mask = strtok(NULL, "");
+
+ if (!mask) {
+ syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (sqlines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
+ /* Deleting a range */
+ res = slist_delete_range(&sqlines, mask, NULL);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
+ return MOD_CONT;
+ } else if (res == 1) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_ONE);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL,
+ res);
+ }
+ } else {
+ if ((res = slist_indexof(&sqlines, mask)) == -1) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_NOT_FOUND, mask);
+ return MOD_CONT;
+ }
+
+ slist_delete(&sqlines, res);
+ notice_lang(s_OperServ, u, OPER_SQLINE_DELETED, mask);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+
+ } else if (!stricmp(cmd, "LIST")) {
+ char *mask;
+ int res, sent_header = 0;
+
+ if (sqlines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ mask = strtok(NULL, "");
+
+ if (!mask || (isdigit(*mask)
+ && strspn(mask, "1234567890,-") == strlen(mask))) {
+ res =
+ slist_enum(&sqlines, mask, &sqline_list_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
+ return MOD_CONT;
+ }
+ } else {
+ int i;
+ char *amask;
+
+ for (i = 0; i < sqlines.count; i++) {
+ amask = ((SXLine *) sqlines.list[i])->mask;
+ if (!stricmp(mask, amask)
+ || match_wild_nocase(mask, amask))
+ sqline_list(i + 1, sqlines.list[i], u, &sent_header);
+ }
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
+ else {
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SQLine");
+ }
+ }
+ } else if (!stricmp(cmd, "VIEW")) {
+ char *mask;
+ int res, sent_header = 0;
+
+ if (sqlines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ mask = strtok(NULL, "");
+
+ if (!mask || (isdigit(*mask)
+ && strspn(mask, "1234567890,-") == strlen(mask))) {
+ res =
+ slist_enum(&sqlines, mask, &sqline_view_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
+ return MOD_CONT;
+ }
+ } else {
+ int i;
+ char *amask;
+
+ for (i = 0; i < sqlines.count; i++) {
+ amask = ((SXLine *) sqlines.list[i])->mask;
+ if (!stricmp(mask, amask)
+ || match_wild_nocase(mask, amask))
+ sqline_view(i + 1, sqlines.list[i], u, &sent_header);
+ }
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
+ }
+ } else if (!stricmp(cmd, "CLEAR")) {
+ slist_clear(&sqlines, 1);
+ notice_lang(s_OperServ, u, OPER_SQLINE_CLEAR);
+ } else {
+ syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+int sqline_view(int number, SXLine * sx, User * u, int *sent_header)
+{
+ char timebuf[32], expirebuf[256];
+ struct tm tm;
+
+ if (!sx)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_VIEW_HEADER);
+ *sent_header = 1;
+ }
+
+ tm = *localtime(&sx->seton);
+ strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT,
+ &tm);
+ expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires);
+ notice_lang(s_OperServ, u, OPER_SQLINE_VIEW_FORMAT, number, sx->mask,
+ sx->by, timebuf, expirebuf, sx->reason);
+
+ return 1;
+}
+
+/* Callback for enumeration purposes */
+
+int sqline_view_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return sqline_view(number, item, u, sent_header);
+}
+
+/* Lists an SQLINE entry, prefixing it with the header if needed */
+
+int sqline_list(int number, SXLine * sx, User * u, int *sent_header)
+{
+ if (!sx)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_SQLINE_LIST_HEADER);
+ *sent_header = 1;
+ }
+
+ notice_lang(s_OperServ, u, OPER_SQLINE_LIST_FORMAT, number, sx->mask,
+ sx->reason);
+
+ return 1;
+}
+
+/* Callback for enumeration purposes */
+
+int sqline_list_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return sqline_list(number, item, u, sent_header);
+}
diff --git a/src/core/os_staff.c b/src/core/os_staff.c
new file mode 100644
index 000000000..67d07a94e
--- /dev/null
+++ b/src/core/os_staff.c
@@ -0,0 +1,158 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_staff(User * u);
+void myOperServHelp(User * u);
+int opers_list_callback(SList * slist, int number, void *item,
+ va_list args);
+int opers_list(int number, NickCore * nc, User * u, char *level);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("STAFF", do_staff, is_oper, OPER_HELP_STAFF, -1, -1,
+ -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_STAFF);
+ }
+}
+
+/**
+ * The /os staff command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_staff(User * u)
+{
+ int idx = 0;
+ User *au = NULL;
+ NickCore *nc;
+ NickAlias *na;
+ int found;
+ int i;
+
+ notice_lang(s_OperServ, u, OPER_STAFF_LIST_HEADER);
+ slist_enum(&servopers, NULL, &opers_list_callback, u, "OPER");
+ slist_enum(&servadmins, NULL, &opers_list_callback, u, "ADMN");
+
+ for (idx = 0; idx < RootNumber; idx++) {
+ found = 0;
+ if ((au = finduser(ServicesRoots[idx]))) { /* see if user is online */
+ found = 1;
+ notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', "ROOT",
+ ServicesRoots[idx]);
+ } else if ((nc = findcore(ServicesRoots[idx]))) {
+ for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */
+ na = nc->aliases.list[i];
+ if ((au = finduser(na->nick))) { /* see if user is online */
+ found = 1;
+ notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT,
+ '*', "ROOT", ServicesRoots[idx], na->nick);
+ }
+ }
+ }
+
+ if (!found)
+ notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', "ROOT",
+ ServicesRoots[idx]);
+
+ }
+ notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Staff");
+ return MOD_CONT;
+}
+
+/**
+ * Function for the enumerator to call
+ **/
+int opers_list_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ char *level = va_arg(args, char *);
+
+ return opers_list(number, item, u, level);
+}
+
+
+/**
+ * Display an Opers list Entry
+ **/
+int opers_list(int number, NickCore * nc, User * u, char *level)
+{
+ User *au = NULL;
+ NickAlias *na;
+ int found;
+ int i;
+
+ if (!nc)
+ return 0;
+
+ found = 0;
+ if ((au = finduser(nc->display))) { /* see if user is online */
+ found = 1;
+ notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', level,
+ nc->display);
+ } else {
+ for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */
+ na = nc->aliases.list[i];
+ if ((au = finduser(na->nick))) { /* see if user is online */
+ found = 1;
+ notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, '*', level,
+ nc->display, na->nick);
+ }
+ }
+ }
+
+ if (!found)
+ notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', level,
+ nc->display);
+
+ return 1;
+}
diff --git a/src/core/os_stats.c b/src/core/os_stats.c
new file mode 100644
index 000000000..f621c56d1
--- /dev/null
+++ b/src/core/os_stats.c
@@ -0,0 +1,400 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+
+
+int do_stats(User * u);
+void get_operserv_stats(long *nrec, long *memuse);
+void myOperServHelp(User * u);
+
+extern MDE struct clone clonelist[CLONE_DETECT_SIZE];
+extern MDE struct clone warnings[CLONE_DETECT_SIZE];
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("STATS", do_stats, is_services_oper, OPER_HELP_STATS,
+ -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+ c = createCommand("UPTIME", do_stats, is_services_oper,
+ OPER_HELP_STATS, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_STATS);
+ }
+}
+
+/**
+ * The /os stats command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_stats(User * u)
+{
+ time_t uptime = time(NULL) - start_time;
+ char *extra = strtok(NULL, "");
+ int days = uptime / 86400, hours = (uptime / 3600) % 24,
+ mins = (uptime / 60) % 60, secs = uptime % 60;
+ struct tm *tm;
+ char timebuf[64];
+
+ if (extra && stricmp(extra, "ALL") != 0) {
+ if (stricmp(extra, "AKILL") == 0) {
+ int timeout;
+ /* AKILLs */
+ notice_lang(s_OperServ, u, OPER_STATS_AKILL_COUNT,
+ akills.count);
+ timeout = AutokillExpiry + 59;
+ if (timeout >= 172800)
+ notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAYS,
+ timeout / 86400);
+ else if (timeout >= 86400)
+ notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAY);
+ else if (timeout >= 7200)
+ notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOURS,
+ timeout / 3600);
+ else if (timeout >= 3600)
+ notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOUR);
+ else if (timeout >= 120)
+ notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MINS,
+ timeout / 60);
+ else if (timeout >= 60)
+ notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MIN);
+ else
+ notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_NONE);
+ if (ircd->sgline) {
+ /* SGLINEs */
+ notice_lang(s_OperServ, u, OPER_STATS_SGLINE_COUNT,
+ sglines.count);
+ timeout = SGLineExpiry + 59;
+ if (timeout >= 172800)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SGLINE_EXPIRE_DAYS,
+ timeout / 86400);
+ else if (timeout >= 86400)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SGLINE_EXPIRE_DAY);
+ else if (timeout >= 7200)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SGLINE_EXPIRE_HOURS,
+ timeout / 3600);
+ else if (timeout >= 3600)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SGLINE_EXPIRE_HOUR);
+ else if (timeout >= 120)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SGLINE_EXPIRE_MINS,
+ timeout / 60);
+ else if (timeout >= 60)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SGLINE_EXPIRE_MIN);
+ else
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SGLINE_EXPIRE_NONE);
+ }
+ if (ircd->sqline) {
+ /* SQLINEs */
+ notice_lang(s_OperServ, u, OPER_STATS_SQLINE_COUNT,
+ sqlines.count);
+ timeout = SQLineExpiry + 59;
+ if (timeout >= 172800)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SQLINE_EXPIRE_DAYS,
+ timeout / 86400);
+ else if (timeout >= 86400)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SQLINE_EXPIRE_DAY);
+ else if (timeout >= 7200)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SQLINE_EXPIRE_HOURS,
+ timeout / 3600);
+ else if (timeout >= 3600)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SQLINE_EXPIRE_HOUR);
+ else if (timeout >= 120)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SQLINE_EXPIRE_MINS,
+ timeout / 60);
+ else if (timeout >= 60)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SQLINE_EXPIRE_MIN);
+ else
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SQLINE_EXPIRE_NONE);
+ }
+ if (ircd->szline) {
+ /* SZLINEs */
+ notice_lang(s_OperServ, u, OPER_STATS_SZLINE_COUNT,
+ szlines.count);
+ timeout = SZLineExpiry + 59;
+ if (timeout >= 172800)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SZLINE_EXPIRE_DAYS,
+ timeout / 86400);
+ else if (timeout >= 86400)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SZLINE_EXPIRE_DAY);
+ else if (timeout >= 7200)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SZLINE_EXPIRE_HOURS,
+ timeout / 3600);
+ else if (timeout >= 3600)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SZLINE_EXPIRE_HOUR);
+ else if (timeout >= 120)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SZLINE_EXPIRE_MINS,
+ timeout / 60);
+ else if (timeout >= 60)
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SZLINE_EXPIRE_MIN);
+ else
+ notice_lang(s_OperServ, u,
+ OPER_STATS_SZLINE_EXPIRE_NONE);
+ }
+ return MOD_CONT;
+ } else if (!stricmp(extra, "RESET")) {
+ if (is_services_admin(u)) {
+ maxusercnt = usercnt;
+ notice_lang(s_OperServ, u, OPER_STATS_RESET);
+ } else {
+ notice_lang(s_OperServ, u, PERMISSION_DENIED);
+ }
+ return MOD_CONT;
+ } else {
+ notice_lang(s_OperServ, u, OPER_STATS_UNKNOWN_OPTION, extra);
+ }
+ }
+
+ notice_lang(s_OperServ, u, OPER_STATS_CURRENT_USERS, usercnt, opcnt);
+ tm = localtime(&maxusertime);
+ strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT,
+ tm);
+ notice_lang(s_OperServ, u, OPER_STATS_MAX_USERS, maxusercnt, timebuf);
+ if (days > 1) {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_DHMS,
+ days, hours, mins, secs);
+ } else if (days == 1) {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1DHMS,
+ days, hours, mins, secs);
+ } else {
+ if (hours > 1) {
+ if (mins != 1) {
+ if (secs != 1) {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HMS,
+ hours, mins, secs);
+ } else {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HM1S,
+ hours, mins, secs);
+ }
+ } else {
+ if (secs != 1) {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1MS,
+ hours, mins, secs);
+ } else {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1M1S,
+ hours, mins, secs);
+ }
+ }
+ } else if (hours == 1) {
+ if (mins != 1) {
+ if (secs != 1) {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HMS,
+ hours, mins, secs);
+ } else {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HM1S,
+ hours, mins, secs);
+ }
+ } else {
+ if (secs != 1) {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1MS,
+ hours, mins, secs);
+ } else {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1M1S,
+ hours, mins, secs);
+ }
+ }
+ } else {
+ if (mins != 1) {
+ if (secs != 1) {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_MS,
+ mins, secs);
+ } else {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_M1S,
+ mins, secs);
+ }
+ } else {
+ if (secs != 1) {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1MS,
+ mins, secs);
+ } else {
+ notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1M1S,
+ mins, secs);
+ }
+ }
+ }
+ }
+
+ if (extra && stricmp(extra, "ALL") == 0 && is_services_admin(u)) {
+ long count, mem;
+
+ notice_lang(s_OperServ, u, OPER_STATS_BYTES_READ,
+ total_read / 1024);
+ notice_lang(s_OperServ, u, OPER_STATS_BYTES_WRITTEN,
+ total_written / 1024);
+
+ get_user_stats(&count, &mem);
+ notice_lang(s_OperServ, u, OPER_STATS_USER_MEM, count,
+ (mem + 512) / 1024);
+ get_channel_stats(&count, &mem);
+ notice_lang(s_OperServ, u, OPER_STATS_CHANNEL_MEM, count,
+ (mem + 512) / 1024);
+ get_core_stats(&count, &mem);
+ notice_lang(s_OperServ, u, OPER_STATS_GROUPS_MEM, count,
+ (mem + 512) / 1024);
+ get_aliases_stats(&count, &mem);
+ notice_lang(s_OperServ, u, OPER_STATS_ALIASES_MEM, count,
+ (mem + 512) / 1024);
+ get_chanserv_stats(&count, &mem);
+ notice_lang(s_OperServ, u, OPER_STATS_CHANSERV_MEM, count,
+ (mem + 512) / 1024);
+ get_botserv_stats(&count, &mem);
+ notice_lang(s_OperServ, u, OPER_STATS_BOTSERV_MEM, count,
+ (mem + 512) / 1024);
+ get_operserv_stats(&count, &mem);
+ notice_lang(s_OperServ, u, OPER_STATS_OPERSERV_MEM, count,
+ (mem + 512) / 1024);
+ get_session_stats(&count, &mem);
+ notice_lang(s_OperServ, u, OPER_STATS_SESSIONS_MEM, count,
+ (mem + 512) / 1024);
+ }
+ return MOD_CONT;
+}
+
+void get_operserv_stats(long *nrec, long *memuse)
+{
+ int i;
+ long mem = 0, count = 0, mem2 = 0, count2 = 0;
+ Akill *ak;
+ SXLine *sx;
+
+ if (CheckClones) {
+ mem = sizeof(struct clone) * CLONE_DETECT_SIZE * 2;
+ for (i = 0; i < CLONE_DETECT_SIZE; i++) {
+ if (clonelist[i].host) {
+ count++;
+ mem += strlen(clonelist[i].host) + 1;
+ }
+ if (warnings[i].host) {
+ count++;
+ mem += strlen(warnings[i].host) + 1;
+ }
+ }
+ }
+
+ count += akills.count;
+ mem += akills.capacity;
+ mem += akills.count * sizeof(Akill);
+
+ for (i = 0; i < akills.count; i++) {
+ ak = akills.list[i];
+ mem += strlen(ak->user) + 1;
+ mem += strlen(ak->host) + 1;
+ mem += strlen(ak->by) + 1;
+ mem += strlen(ak->reason) + 1;
+ }
+
+ if (ircd->sgline) {
+ count += sglines.count;
+ mem += sglines.capacity;
+ mem += sglines.count * sizeof(SXLine);
+
+ for (i = 0; i < sglines.count; i++) {
+ sx = sglines.list[i];
+ mem += strlen(sx->mask) + 1;
+ mem += strlen(sx->by) + 1;
+ mem += strlen(sx->reason) + 1;
+ }
+ }
+ if (ircd->sqline) {
+ count += sqlines.count;
+ mem += sqlines.capacity;
+ mem += sqlines.count * sizeof(SXLine);
+
+ for (i = 0; i < sqlines.count; i++) {
+ sx = sqlines.list[i];
+ mem += strlen(sx->mask) + 1;
+ mem += strlen(sx->by) + 1;
+ mem += strlen(sx->reason) + 1;
+ }
+ }
+ if (ircd->szline) {
+ count += szlines.count;
+ mem += szlines.capacity;
+ mem += szlines.count * sizeof(SXLine);
+
+ for (i = 0; i < szlines.count; i++) {
+ sx = szlines.list[i];
+ mem += strlen(sx->mask) + 1;
+ mem += strlen(sx->by) + 1;
+ mem += strlen(sx->reason) + 1;
+ }
+ }
+
+
+ get_news_stats(&count2, &mem2);
+ count += count2;
+ mem += mem2;
+ get_exception_stats(&count2, &mem2);
+ count += count2;
+ mem += mem2;
+
+ *nrec = count;
+ *memuse = mem;
+}
diff --git a/src/core/os_svsnick.c b/src/core/os_svsnick.c
new file mode 100644
index 000000000..9c0af28ca
--- /dev/null
+++ b/src/core/os_svsnick.c
@@ -0,0 +1,126 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_svsnick(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SVSNICK", do_svsnick, is_services_admin,
+ OPER_HELP_SVSNICK, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+ if (!ircd->svsnick) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u) && u->isSuperAdmin) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_SVSNICK);
+ }
+}
+
+/**
+ * The /os svsnick command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+/* Forcefully change a user's nickname */
+
+int do_svsnick(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ char *newnick = strtok(NULL, " ");
+
+ NickAlias *na;
+ char *c;
+
+ /* Only allow this if SuperAdmin is enabled */
+ if (!u->isSuperAdmin) {
+ notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
+ return MOD_CONT;
+ }
+
+ if (!nick || !newnick) {
+ syntax_error(s_OperServ, u, "SVSNICK", OPER_SVSNICK_SYNTAX);
+ return MOD_CONT;
+ }
+
+ /* Truncate long nicknames to NICKMAX-2 characters */
+ if (strlen(newnick) > (NICKMAX - 2)) {
+ notice_lang(s_NickServ, u, NICK_X_TRUNCATED,
+ newnick, NICKMAX - 2, newnick);
+ newnick[NICKMAX - 2] = '\0';
+ }
+
+ /* Check for valid characters */
+ if (*newnick == '-' || isdigit(*newnick)) {
+ notice_lang(s_OperServ, u, NICK_X_ILLEGAL, newnick);
+ return MOD_CONT;
+ }
+#define isvalid(c) (((c) >= 'A' && (c) <= '~') || isdigit(c) || (c) == '-')
+ for (c = newnick; *c && (c - newnick) < NICKMAX; c++) {
+ if (!isvalid(*c) || isspace(*c)) {
+ notice_lang(s_OperServ, u, NICK_X_ILLEGAL, nick);
+ return MOD_CONT;
+ }
+ }
+
+ /* Check for a nick in use or a forbidden/suspended nick */
+ if (!finduser(nick)) {
+ notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
+ } else if (finduser(newnick)) {
+ notice_lang(s_NickServ, u, NICK_X_IN_USE, newnick);
+ } else if ((na = findnick(newnick)) && (na->status & NS_VERBOTEN)) {
+ notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, newnick);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SVSNICK_NEWNICK, nick, newnick);
+ anope_cmd_global(s_OperServ, "%s used SVSNICK to change %s to %s",
+ u->nick, nick, newnick);
+ anope_cmd_svsnick(nick, newnick, time(NULL));
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_szline.c b/src/core/os_szline.c
new file mode 100644
index 000000000..379bbbfdc
--- /dev/null
+++ b/src/core/os_szline.c
@@ -0,0 +1,350 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_szline(User * u);
+void myOperServHelp(User * u);
+int szline_view_callback(SList * slist, int number, void *item,
+ va_list args);
+int szline_list_callback(SList * slist, int number, void *item,
+ va_list args);
+int szline_view(int number, SXLine * sx, User * u, int *sent_header);
+int szline_list(int number, SXLine * sx, User * u, int *sent_header);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("SZLINE", do_szline, is_services_oper,
+ OPER_HELP_SZLINE, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+ if (!ircd->szline) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_oper(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_SZLINE);
+ }
+}
+
+/**
+ * The /os szline command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_szline(User * u)
+{
+ char *cmd = strtok(NULL, " ");
+
+ if (!cmd)
+ cmd = "";
+
+ if (!stricmp(cmd, "ADD")) {
+ int deleted = 0;
+ char *expiry, *mask, *reason;
+ time_t expires;
+
+ mask = strtok(NULL, " ");
+ if (mask && *mask == '+') {
+ expiry = mask;
+ mask = strtok(NULL, " ");
+ } else {
+ expiry = NULL;
+ }
+
+ expires = expiry ? dotime(expiry) : SZLineExpiry;
+ /* If the expiry given does not contain a final letter, it's in days,
+ * said the doc. Ah well.
+ */
+ if (expiry && isdigit(expiry[strlen(expiry) - 1]))
+ expires *= 86400;
+ /* Do not allow less than a minute expiry time */
+ if (expires != 0 && expires < 60) {
+ notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
+ return MOD_CONT;
+ } else if (expires > 0) {
+ expires += time(NULL);
+ }
+
+ if (mask && (reason = strtok(NULL, ""))) {
+ /* We first do some sanity check on the proposed mask. */
+
+ if (strchr(mask, '!') || strchr(mask, '@')) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_ONLY_IPS);
+ return MOD_CONT;
+ }
+
+ if (strspn(mask, "*?") == strlen(mask)) {
+ notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask);
+ return MOD_CONT;
+ }
+
+ deleted = add_szline(u, mask, u->nick, expires, reason);
+ if (deleted < 0)
+ return MOD_CONT;
+ else if (deleted)
+ notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_SEVERAL,
+ deleted);
+ notice_lang(s_OperServ, u, OPER_SZLINE_ADDED, mask);
+
+ if (WallOSSZLine) {
+ char buf[128];
+
+ if (!expires) {
+ strcpy(buf, "does not expire");
+ } else {
+ int wall_expiry = expires - time(NULL);
+ char *s = NULL;
+
+ if (wall_expiry >= 86400) {
+ wall_expiry /= 86400;
+ s = "day";
+ } else if (wall_expiry >= 3600) {
+ wall_expiry /= 3600;
+ s = "hour";
+ } else if (wall_expiry >= 60) {
+ wall_expiry /= 60;
+ s = "minute";
+ }
+
+ snprintf(buf, sizeof(buf), "expires in %d %s%s",
+ wall_expiry, s,
+ (wall_expiry == 1) ? "" : "s");
+ }
+
+ anope_cmd_global(s_OperServ,
+ "%s added an SZLINE for %s (%s)", u->nick,
+ mask, buf);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+
+ } else {
+ syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX);
+ }
+
+ } else if (!stricmp(cmd, "DEL")) {
+
+ char *mask;
+ int res = 0;
+
+ mask = strtok(NULL, " ");
+
+ if (!mask) {
+ syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX);
+ return MOD_CONT;
+ }
+
+ if (szlines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
+ /* Deleting a range */
+ res = slist_delete_range(&szlines, mask, NULL);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
+ return MOD_CONT;
+ } else if (res == 1) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_ONE);
+ } else {
+ notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_SEVERAL,
+ res);
+ }
+ } else {
+ if ((res = slist_indexof(&szlines, mask)) == -1) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_NOT_FOUND, mask);
+ return MOD_CONT;
+ }
+
+ slist_delete(&szlines, res);
+ notice_lang(s_OperServ, u, OPER_SZLINE_DELETED, mask);
+ }
+
+ if (readonly)
+ notice_lang(s_OperServ, u, READ_ONLY_MODE);
+
+ } else if (!stricmp(cmd, "LIST")) {
+ char *mask;
+ int res, sent_header = 0;
+
+ if (szlines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ mask = strtok(NULL, " ");
+
+ if (!mask || (isdigit(*mask)
+ && strspn(mask, "1234567890,-") == strlen(mask))) {
+ res =
+ slist_enum(&szlines, mask, &szline_list_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
+ return MOD_CONT;
+ }
+ } else {
+ int i;
+ char *amask;
+
+ for (i = 0; i < szlines.count; i++) {
+ amask = ((SXLine *) szlines.list[i])->mask;
+ if (!stricmp(mask, amask)
+ || match_wild_nocase(mask, amask))
+ szline_list(i + 1, szlines.list[i], u, &sent_header);
+ }
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
+ }
+ } else if (!stricmp(cmd, "VIEW")) {
+ char *mask;
+ int res, sent_header = 0;
+
+ if (szlines.count == 0) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY);
+ return MOD_CONT;
+ }
+
+ mask = strtok(NULL, " ");
+
+ if (!mask || (isdigit(*mask)
+ && strspn(mask, "1234567890,-") == strlen(mask))) {
+ res =
+ slist_enum(&szlines, mask, &szline_view_callback, u,
+ &sent_header);
+ if (res == 0) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
+ return MOD_CONT;
+ }
+ } else {
+ int i;
+ char *amask;
+
+ for (i = 0; i < szlines.count; i++) {
+ amask = ((SXLine *) szlines.list[i])->mask;
+ if (!stricmp(mask, amask)
+ || match_wild_nocase(mask, amask))
+ szline_view(i + 1, szlines.list[i], u, &sent_header);
+ }
+
+ if (!sent_header)
+ notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
+ }
+ } else if (!stricmp(cmd, "CLEAR")) {
+ slist_clear(&szlines, 1);
+ notice_lang(s_OperServ, u, OPER_SZLINE_CLEAR);
+ } else {
+ syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX);
+ }
+ return MOD_CONT;
+}
+
+
+int szline_view(int number, SXLine * sx, User * u, int *sent_header)
+{
+ char timebuf[32], expirebuf[256];
+ struct tm tm;
+
+ if (!sx)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_VIEW_HEADER);
+ *sent_header = 1;
+ }
+
+ tm = *localtime(&sx->seton);
+ strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT,
+ &tm);
+ expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires);
+ notice_lang(s_OperServ, u, OPER_SZLINE_VIEW_FORMAT, number, sx->mask,
+ sx->by, timebuf, expirebuf, sx->reason);
+
+ return 1;
+}
+
+/* Callback for enumeration purposes */
+
+int szline_view_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return szline_view(number, item, u, sent_header);
+}
+
+/* Callback for enumeration purposes */
+
+int szline_list_callback(SList * slist, int number, void *item,
+ va_list args)
+{
+ User *u = va_arg(args, User *);
+ int *sent_header = va_arg(args, int *);
+
+ return szline_list(number, item, u, sent_header);
+}
+
+/* Lists an SZLINE entry, prefixing it with the header if needed */
+
+int szline_list(int number, SXLine * sx, User * u, int *sent_header)
+{
+ if (!sx)
+ return 0;
+
+ if (!*sent_header) {
+ notice_lang(s_OperServ, u, OPER_SZLINE_LIST_HEADER);
+ *sent_header = 1;
+ }
+
+ notice_lang(s_OperServ, u, OPER_SZLINE_LIST_FORMAT, number, sx->mask,
+ sx->reason);
+
+ return 1;
+}
diff --git a/src/core/os_umode.c b/src/core/os_umode.c
new file mode 100644
index 000000000..ecd8006d9
--- /dev/null
+++ b/src/core/os_umode.c
@@ -0,0 +1,116 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_operumodes(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("UMODE", do_operumodes, is_services_admin,
+ OPER_HELP_UMODE, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ if (!ircd->umode) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u) && u->isSuperAdmin) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_UMODE);
+ }
+}
+
+/**
+ * Change any user's UMODES
+ *
+ * modified to be part of the SuperAdmin directive -jester
+ * check user flag for SuperAdmin -rob
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ */
+int do_operumodes(User * u)
+{
+ char *nick = strtok(NULL, " ");
+ char *modes = strtok(NULL, "");
+
+ User *u2;
+
+ /* Only allow this if SuperAdmin is enabled */
+ if (!u->isSuperAdmin) {
+ notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
+ return MOD_CONT;
+ }
+
+ if (!nick || !modes) {
+ syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX);
+ return MOD_CONT;
+ }
+
+ /**
+ * Only accept a +/- mode string
+ *-rob
+ **/
+ if ((modes[0] != '+') && (modes[0] != '-')) {
+ syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX);
+ return MOD_CONT;
+ }
+ if (!(u2 = finduser(nick))) {
+ notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
+ } else {
+ anope_cmd_mode(s_OperServ, nick, "%s", modes);
+
+ common_svsmode(u2, modes, NULL);
+
+ notice_lang(s_OperServ, u, OPER_UMODE_SUCCESS, nick);
+ notice_lang(s_OperServ, u2, OPER_UMODE_CHANGED, u->nick);
+
+ if (WallOSMode)
+ anope_cmd_global(s_OperServ, "\2%s\2 used UMODE on %s",
+ u->nick, nick);
+ }
+ return MOD_CONT;
+}
diff --git a/src/core/os_update.c b/src/core/os_update.c
new file mode 100644
index 000000000..2ec18ebde
--- /dev/null
+++ b/src/core/os_update.c
@@ -0,0 +1,74 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_update(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("UPDATE", do_update, is_services_admin,
+ OPER_HELP_UPDATE, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_UPDATE);
+ }
+}
+
+/**
+ * The /os update command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+int do_update(User * u)
+{
+ notice_lang(s_OperServ, u, OPER_UPDATING);
+ save_data = 1;
+ return MOD_CONT;
+}
diff --git a/src/core/os_userlist.c b/src/core/os_userlist.c
new file mode 100644
index 000000000..7d7b75bc1
--- /dev/null
+++ b/src/core/os_userlist.c
@@ -0,0 +1,121 @@
+/* OperServ core functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+extern MDE int anope_get_invite_mode();
+extern MDE int anope_get_invis_mode();
+
+int do_userlist(User * u);
+void myOperServHelp(User * u);
+
+/**
+ * Create the command, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(CORE);
+
+ c = createCommand("USERLIST", do_userlist, is_services_admin,
+ OPER_HELP_USERLIST, -1, -1, -1, -1);
+ moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
+
+ moduleSetOperHelp(myOperServHelp);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+
+/**
+ * Add the help response to anopes /os help output.
+ * @param u The user who is requesting help
+ **/
+void myOperServHelp(User * u)
+{
+ if (is_services_admin(u)) {
+ notice_lang(s_OperServ, u, OPER_HELP_CMD_USERLIST);
+ }
+}
+
+/**
+ * The /os userlist command.
+ * @param u The user who issued the command
+ * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
+ **/
+
+int do_userlist(User * u)
+{
+ char *pattern = strtok(NULL, " ");
+ char *opt = strtok(NULL, " ");
+
+ Channel *c;
+ int modes = 0;
+
+ if (opt && !stricmp(opt, "INVISIBLE"))
+ modes |= anope_get_invis_mode();
+
+ if (pattern && (c = findchan(pattern))) {
+ struct c_userlist *cu;
+
+ notice_lang(s_OperServ, u, OPER_USERLIST_HEADER_CHAN, pattern);
+
+ for (cu = c->users; cu; cu = cu->next) {
+ if (modes && !(cu->user->mode & modes))
+ continue;
+ notice_lang(s_OperServ, u, OPER_USERLIST_RECORD,
+ cu->user->nick, common_get_vident(cu->user),
+ common_get_vhost(cu->user));
+ }
+ } else {
+ char mask[BUFSIZE];
+ int i;
+ User *u2;
+
+ notice_lang(s_OperServ, u, OPER_USERLIST_HEADER);
+
+ for (i = 0; i < 1024; i++) {
+ for (u2 = userlist[i]; u2; u2 = u2->next) {
+ if (pattern) {
+ snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick,
+ common_get_vident(u2), common_get_vhost(u2));
+ if (!match_wild_nocase(pattern, mask))
+ continue;
+ if (modes && !(u2->mode & modes))
+ continue;
+ }
+ notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, u2->nick,
+ common_get_vident(u2), common_get_vhost(u2));
+ }
+ }
+ }
+
+ notice_lang(s_OperServ, u, OPER_USERLIST_END);
+ return MOD_CONT;
+}
diff --git a/src/datafiles.c b/src/datafiles.c
index a95ca1686..d8dd30654 100644
--- a/src/datafiles.c
+++ b/src/datafiles.c
@@ -674,7 +674,7 @@ void backup_databases(void)
char ext[9];
- send_event(EVENT_DB_BACKUP, EVENT_START);
+ send_event(EVENT_DB_BACKUP, 1, EVENT_START);
alog("Backing up databases");
remove_backups();
@@ -696,6 +696,6 @@ void backup_databases(void)
rename_database(OperDBName, ext);
rename_database(NewsDBName, ext);
rename_database(ExceptionDBName, ext);
- send_event(EVENT_DB_BACKUP, EVENT_STOP);
+ send_event(EVENT_DB_BACKUP, 1, EVENT_STOP);
}
}
diff --git a/src/encrypt.c b/src/encrypt.c
index 2904180ec..31f43ce75 100644
--- a/src/encrypt.c
+++ b/src/encrypt.c
@@ -95,7 +95,7 @@ static unsigned char PADDING[64] = {
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
+#define MD5_I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits.
*/
@@ -120,7 +120,7 @@ Rotation is separate from addition to prevent recomputation.
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) += MD5_I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
diff --git a/src/events.c b/src/events.c
index e4735efbf..d0712520e 100644
--- a/src/events.c
+++ b/src/events.c
@@ -36,18 +36,33 @@ EvtHook *find_eventhook(const char *name)
return m;
}
-void send_event(char *name, const char *fmt, ...)
+void send_event(char *name, int argc, ...)
{
- va_list args;
- char buf[16384]; /* Really huge, to try and avoid truncation */
- *buf = '\0';
+ va_list va;
+ char *a;
+ int idx = 0;
+ char **argv;
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
+ argv = (char **) malloc(sizeof(char *) * argc);
+ va_start(va, argc);
+ for (idx = 0; idx < argc; idx++) {
+ a = va_arg(va, char *);
+ argv[idx] = sstrdup(a);
}
- event_process_hook(name, buf);
+ va_end(va);
+
+ if (debug)
+ alog("Emitting event \"%s\" (%d args)", name, argc);
+
+ event_process_hook(name, argc, argv);
+
+ /**
+ * Now that the events have seen the message, free it up
+ **/
+ for (idx = 0; idx < argc; idx++) {
+ free(argv[idx]);
+ }
+ free(argv);
}
void eventprintf(char *fmt, ...)
@@ -133,7 +148,7 @@ void event_message_process(char *eventbuf)
free(av);
}
-void event_process_hook(char *name, char *eventbuf)
+void event_process_hook(char *name, int argc, char **argv)
{
int retVal = 0;
EvtHook *current = NULL;
@@ -141,23 +156,18 @@ void event_process_hook(char *name, char *eventbuf)
if (mod_current_evtbuffer) {
free(mod_current_evtbuffer);
}
- if (eventbuf) {
- mod_current_evtbuffer = sstrdup(eventbuf);
- } else {
- mod_current_evtbuffer = NULL;
- }
/* Do something with the message. */
evh = find_eventhook(name);
if (evh) {
if (evh->func) {
mod_current_module_name = evh->mod_name;
- retVal = evh->func(eventbuf);
+ retVal = evh->func(argc, argv);
mod_current_module_name = NULL;
if (retVal == MOD_CONT) {
current = evh->next;
while (current && current->func && retVal == MOD_CONT) {
mod_current_module_name = current->mod_name;
- retVal = current->func(eventbuf);
+ retVal = current->func(argc, argv);
mod_current_module_name = NULL;
current = current->next;
}
@@ -286,7 +296,7 @@ EvtMessage *createEventHandler(char *name,
* @param func a pointer to the function to call when we recive this message
* @return a new Message object
**/
-EvtHook *createEventHook(char *name, int (*func) (char *message))
+EvtHook *createEventHook(char *name, int (*func) (int argc, char **argv))
{
EvtHook *evh = NULL;
if (!func) {
@@ -685,7 +695,7 @@ int delEventHook(EvtHookHash * hookEvtTable[], EvtHook * evh,
index = CMD_HASH(evh->name);
for (current = hookEvtTable[index]; current; current = current->next) {
- if (stricmp(evh->name, current->name)) {
+ if (stricmp(evh->name, current->name) == 0) {
if (!lastHash) {
tail = current->evh;
if (tail->next) {
diff --git a/src/helpserv.c b/src/helpserv.c
index 7b69996e1..f1e4bff35 100644
--- a/src/helpserv.c
+++ b/src/helpserv.c
@@ -16,7 +16,6 @@
#include "services.h"
#include "pseudo.h"
-static int do_help(User * u);
void moduleAddHelpServCmds(void);
/*************************************************************************/
@@ -27,9 +26,7 @@ void moduleAddHelpServCmds(void);
*/
void moduleAddHelpServCmds(void)
{
- Command *c;
- c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
- addCoreCommand(HELPSERV, c);
+ modules_core_init(HelpServCoreNumber, HelpServCoreModules);
}
/*************************************************************************/
@@ -70,31 +67,3 @@ void helpserv(User * u, char *buf)
}
/*************************************************************************/
-
-/**
- * Display the HelpServ help.
- * This core function has been embed in the source for a long time, but
- * it moved into it's own file so we now all can enjoy the joy of
- * modules for HelpServ.
- * @param u User Struct of the user looking for help
- * @return MOD_CONT
- */
-static int do_help(User * u)
-{
- char *cmd = strtok(NULL, "");
-
- if (!cmd) {
- notice_help(s_HelpServ, u, HELP_HELP, s_NickServ, s_ChanServ,
- s_MemoServ);
- if (s_BotServ) {
- notice_help(s_HelpServ, u, HELP_HELP_BOT, s_BotServ);
- }
- if (s_HostServ) {
- notice_help(s_HelpServ, u, HELP_HELP_HOST, s_HostServ);
- }
- moduleDisplayHelp(7, u);
- } else {
- mod_help_cmd(s_HelpServ, u, HELPSERV, cmd);
- }
- return MOD_CONT;
-}
diff --git a/src/hostserv.c b/src/hostserv.c
index e6cf50f86..3fde7ba3a 100644
--- a/src/hostserv.c
+++ b/src/hostserv.c
@@ -32,51 +32,20 @@ HostCore *insertHostCore(HostCore * head, HostCore * prev, char *nick,
HostCore *deleteHostCore(HostCore * head, HostCore * prev);
void delHostCore(char *nick);
-int is_host_setter(User * u);
-int is_host_remover(User * u);
-
-static int do_help(User * u);
-static int do_set(User * u);
-static int do_on(User * u);
-int do_on_id(User * u);
-static void set_lastmask(User * u);
-static int do_off(User * u);
-static int do_del(User * u);
-static int do_group(User * u);
-static int listOut(User * u);
-int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask, char *creator,
- time_t time);
-int do_setall(User * u);
-int do_delall(User * u);
-void moduleAddHostServCmds(void);
+E int is_host_setter(User * u);
+E int is_host_remover(User * u);
+
+E int do_on_id(User * u);
+E void set_lastmask(User * u);
+
+E int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask,
+ char *creator, time_t time);
+
+E void moduleAddHostServCmds(void);
/*************************************************************************/
void moduleAddHostServCmds(void)
{
- Command *c;
- c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
- addCoreCommand(HOSTSERV, c);
- c = createCommand("SET", do_set, is_host_setter, HOST_HELP_SET, -1, -1,
- -1, -1);
- addCoreCommand(HOSTSERV, c);
- c = createCommand("GROUP", do_group, NULL, HOST_HELP_GROUP, -1, -1, -1,
- -1);
- addCoreCommand(HOSTSERV, c);
- c = createCommand("SETALL", do_setall, is_host_setter,
- HOST_HELP_SETALL, -1, -1, -1, -1);
- addCoreCommand(HOSTSERV, c);
- c = createCommand("DELALL", do_delall, is_host_remover,
- HOST_HELP_DELALL, -1, -1, -1, -1);
- addCoreCommand(HOSTSERV, c);
- c = createCommand("ON", do_on, NULL, HOST_HELP_ON, -1, -1, -1, -1);
- addCoreCommand(HOSTSERV, c);
- c = createCommand("OFF", do_off, NULL, HOST_HELP_OFF, -1, -1, -1, -1);
- addCoreCommand(HOSTSERV, c);
- c = createCommand("DEL", do_del, is_host_remover, HOST_HELP_DEL, -1,
- -1, -1, -1);
- addCoreCommand(HOSTSERV, c);
- c = createCommand("LIST", listOut, is_services_oper, -1,
- -1, HOST_HELP_LIST, HOST_HELP_LIST, HOST_HELP_LIST);
- addCoreCommand(HOSTSERV, c);
+ modules_core_init(HostServCoreNumber, HostServCoreModules);
}
/*************************************************************************/
@@ -88,6 +57,7 @@ void moduleAddHostServCmds(void)
void hostserv_init(void)
{
moduleAddHostServCmds();
+
}
/*************************************************************************/
@@ -126,6 +96,11 @@ void hostserv(User * u, char *buf)
/* Start of Linked List routines */
/*************************************************************************/
+HostCore *hostCoreListHead()
+{
+ return head;
+}
+
/**
* Create HostCore list member
* @param next HostCore next slot
@@ -177,7 +152,6 @@ HostCore *createHostCorelist(HostCore * next, char *nick, char *vIdent,
}
/*************************************************************************/
-
/**
* Returns either NULL for the head, or the location of the *PREVIOUS*
* record, this is where we need to insert etc..
@@ -188,7 +162,6 @@ HostCore *createHostCorelist(HostCore * next, char *nick, char *vIdent,
*/
HostCore *findHostCore(HostCore * head, char *nick, boolean * found)
{
-
HostCore *previous, *current;
*found = false;
@@ -352,117 +325,6 @@ char *getvIdent(char *nick)
}
/*************************************************************************/
-int listOut(User * u)
-{
- char *key = strtok(NULL, "");
- struct tm *tm;
- char buf[BUFSIZE];
- int counter = 1;
- int from = 0, to = 0;
- char *tmp = NULL;
- char *s = NULL;
- int display_counter = 0;
-
- HostCore *current;
-
- current = head;
- if (current == NULL)
- notice_lang(s_HostServ, u, HOST_EMPTY);
- else {
- /**
- * Do a check for a range here, then in the next loop
- * we'll only display what has been requested..
- **/
- if (key) {
- if (key[0] == '#') {
- tmp = myStrGetOnlyToken((key + 1), '-', 0); /* Read FROM out */
- if (!tmp) {
- return MOD_CONT;
- }
- for (s = tmp; *s; s++) {
- if (!isdigit(*s)) {
- return MOD_CONT;
- }
- }
- from = atoi(tmp);
- tmp = myStrGetTokenRemainder(key, '-', 1); /* Read TO out */
- if (!tmp) {
- return MOD_CONT;
- }
- for (s = tmp; *s; s++) {
- if (!isdigit(*s)) {
- return MOD_CONT;
- }
- }
- to = atoi(tmp);
- key = NULL;
- }
- }
-
- while (current != NULL) {
- if (key) {
- if (((match_wild_nocase(key, current->nick))
- || (match_wild_nocase(key, current->vHost)))
- && (display_counter < NSListMax)) {
- display_counter++;
- tm = localtime(&current->time);
- strftime_lang(buf, sizeof(buf), u,
- STRFTIME_DATE_TIME_FORMAT, tm);
- if (current->vIdent) {
- notice_lang(s_HostServ, u, HOST_IDENT_ENTRY,
- counter, current->nick,
- current->vIdent, current->vHost,
- current->creator, buf);
- } else {
- notice_lang(s_HostServ, u, HOST_ENTRY, counter,
- current->nick, current->vHost,
- current->creator, buf);
- }
- }
- } else {
- /**
- * List the host if its in the display range, and not more
- * than NSListMax records have been displayed...
- **/
- if ((((counter >= from) && (counter <= to))
- || ((from == 0) && (to == 0)))
- && (display_counter < NSListMax)) {
- display_counter++;
- tm = localtime(&current->time);
- strftime_lang(buf, sizeof(buf), u,
- STRFTIME_DATE_TIME_FORMAT, tm);
- if (current->vIdent) {
- notice_lang(s_HostServ, u, HOST_IDENT_ENTRY,
- counter, current->nick,
- current->vIdent, current->vHost,
- current->creator, buf);
- } else {
- notice_lang(s_HostServ, u, HOST_ENTRY, counter,
- current->nick, current->vHost,
- current->creator, buf);
- }
- }
- }
- counter++;
- current = current->next;
- }
- if (key) {
- notice_lang(s_HostServ, u, HOST_LIST_KEY_FOOTER, key,
- display_counter);
- } else {
- if (from != 0) {
- notice_lang(s_HostServ, u, HOST_LIST_RANGE_FOOTER, from,
- to);
- } else {
- notice_lang(s_HostServ, u, HOST_LIST_FOOTER,
- display_counter);
- }
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
void delHostCore(char *nick)
{
#ifdef USE_RDB
@@ -670,116 +532,6 @@ void save_hs_rdb_dbase(void)
/*************************************************************************/
/* Start of Generic Functions */
/*************************************************************************/
-int do_setall(User * u)
-{
-
- char *nick = strtok(NULL, " ");
- char *rawhostmask = strtok(NULL, " ");
- char *hostmask = smalloc(HOSTMAX);
-
- NickAlias *na;
- int32 tmp_time;
- char *s;
-
- char *vIdent = NULL;
-
- if (!nick || !rawhostmask) {
- notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ);
- return MOD_CONT;
- }
-
- vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */
- if (vIdent) {
- rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */
- if (!rawhostmask) {
- notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ);
- return MOD_CONT;
- }
- if (strlen(vIdent) > USERMAX - 1) {
- notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX);
- return MOD_CONT;
- } else {
- for (s = vIdent; *s; s++) {
- if (!isvalidchar(*s)) {
- notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR);
- return MOD_CONT;
- }
- }
- }
- if (!ircd->vident) {
- notice_lang(s_HostServ, u, HOST_NO_VIDENT);
- return MOD_CONT;
- }
- }
-
- if (strlen(rawhostmask) < HOSTMAX - 1)
- snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask);
- else {
- notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX);
- return MOD_CONT;
- }
-
- if (!isValidHost(hostmask, 3)) {
- notice_lang(s_HostServ, u, HOST_SET_ERROR);
- free(hostmask);
- return MOD_CONT;
- }
-
- tmp_time = time(NULL);
-
- if ((na = findnick(nick))) {
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
- free(hostmask);
- return MOD_CONT;
- }
- if (vIdent && ircd->vident) {
- alog("vHost for all nicks in group \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick);
- } else {
- alog("vHost for all nicks in group \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick);
- }
- do_hs_sync(na->nc, vIdent, hostmask, u->nick, tmp_time);
- if (vIdent) {
- notice_lang(s_HostServ, u, HOST_IDENT_SETALL, nick, vIdent,
- hostmask);
- } else {
- notice_lang(s_HostServ, u, HOST_SETALL, nick, hostmask);
- }
- } else {
- notice_lang(s_HostServ, u, HOST_NOREG, nick);
- }
-
- free(hostmask);
- return MOD_CONT;
-}
-
-int do_delall(User * u)
-{
- int i;
- char *nick = strtok(NULL, " ");
- NickAlias *na;
- NickCore *nc;
- if (!nick) {
- notice_lang(s_HostServ, u, HOST_DELALL_SYNTAX, s_HostServ);
- return MOD_CONT;
- }
- if ((na = findnick(nick))) {
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
- return MOD_CONT;
- }
- nc = na->nc;
- for (i = 0; i < nc->aliases.count; i++) {
- na = nc->aliases.list[i];
- delHostCore(na->nick);
- }
- alog("vHosts for all nicks in group \002%s\002 deleted by oper \002%s\002", nc->display, u->nick);
- notice_lang(s_HostServ, u, HOST_DELALL, nc->display);
- } else {
- notice_lang(s_HostServ, u, HOST_NOREG, nick);
- }
- return MOD_CONT;
-}
int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask, char *creator,
time_t time)
@@ -794,193 +546,6 @@ int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask, char *creator,
return MOD_CONT;
}
-static int do_group(User * u)
-{
- NickAlias *na;
- HostCore *tmp;
- char *vHost = NULL;
- char *vIdent = NULL;
- char *creator = NULL;
- time_t time;
- boolean found = false;
-
- if ((na = findnick(u->nick))) {
- if (na->status & NS_IDENTIFIED) {
- tmp = findHostCore(head, u->nick, &found);
- if (found) {
- if (tmp == NULL) {
- tmp = head; /* incase first in list */
- } else if (tmp->next) { /* we dont want the previous entry were not inserting! */
- tmp = tmp->next; /* jump to the next */
- }
-
- vHost = sstrdup(tmp->vHost);
- if (tmp->vIdent)
- vIdent = sstrdup(tmp->vIdent);
- creator = sstrdup(tmp->creator);
- time = tmp->time;
-
- do_hs_sync(na->nc, vIdent, vHost, creator, time);
- if (tmp->vIdent) {
- notice_lang(s_HostServ, u, HOST_IDENT_GROUP,
- na->nc->display, vIdent, vHost);
- } else {
- notice_lang(s_HostServ, u, HOST_GROUP, na->nc->display,
- vHost);
- }
- free(vHost);
- if (vIdent)
- free(vIdent);
- free(creator);
-
- } else {
- notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
- }
- } else {
- notice_lang(s_HostServ, u, HOST_ID);
- }
- } else {
- notice_lang(s_HostServ, u, HOST_NOT_REGED);
- }
- return MOD_CONT;
-}
-
-static int do_help(User * u)
-{
- char *cmd = strtok(NULL, "");
-
- if (!cmd) {
- notice_help(s_HostServ, u, HOST_HELP, s_HostServ);
- if ((is_services_oper(u)) || (is_host_setter(u)))
- notice_help(s_HostServ, u, HOST_OPER_HELP);
- /* Removed as atm, there is no admin only help */
-/* if (is_services_admin(u))
- notice_help(s_HostServ, u, HOST_ADMIN_HELP);*/
- moduleDisplayHelp(6, u);
- } else {
- mod_help_cmd(s_HostServ, u, HOSTSERV, cmd);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-int do_set(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *rawhostmask = strtok(NULL, " ");
- char *hostmask = smalloc(HOSTMAX);
-
- NickAlias *na;
- int32 tmp_time;
- char *s;
-
- char *vIdent = NULL;
-
- if (!nick || !rawhostmask) {
- notice_lang(s_HostServ, u, HOST_SET_SYNTAX, s_HostServ);
- return MOD_CONT;
- }
-
- vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */
- if (vIdent) {
- rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */
- if (!rawhostmask) {
- notice_lang(s_HostServ, u, HOST_SET_SYNTAX, s_HostServ);
- return MOD_CONT;
- }
- if (strlen(vIdent) > USERMAX - 1) {
- notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX);
- return MOD_CONT;
- } else {
- for (s = vIdent; *s; s++) {
- if (!isvalidchar(*s)) {
- notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR);
- return MOD_CONT;
- }
- }
- }
- if (!ircd->vident) {
- notice_lang(s_HostServ, u, HOST_NO_VIDENT);
- return MOD_CONT;
- }
- }
- if (strlen(rawhostmask) < HOSTMAX - 1)
- snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask);
- else {
- notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX);
- return MOD_CONT;
- }
-
- if (!isValidHost(hostmask, 3)) {
- notice_lang(s_HostServ, u, HOST_SET_ERROR);
- return MOD_CONT;
- }
-
-
- tmp_time = time(NULL);
-
- if ((na = findnick(nick))) {
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
- return MOD_CONT;
- }
- if (vIdent && ircd->vident) {
- alog("vHost for user \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick);
- } else {
- alog("vHost for user \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick);
- }
- addHostCore(nick, vIdent, hostmask, u->nick, tmp_time);
- if (vIdent) {
- notice_lang(s_HostServ, u, HOST_IDENT_SET, nick, vIdent,
- hostmask);
- } else {
- notice_lang(s_HostServ, u, HOST_SET, nick, hostmask);
- }
- } else {
- notice_lang(s_HostServ, u, HOST_NOREG, nick);
- }
- free(hostmask);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-int do_on(User * u)
-{
- NickAlias *na;
- char *vHost;
- char *vIdent = NULL;
- if ((na = findnick(u->nick))) {
- if (na->status & NS_IDENTIFIED) {
- vHost = getvHost(u->nick);
- vIdent = getvIdent(u->nick);
- if (vHost == NULL) {
- notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
- } else {
- if (vIdent) {
- notice_lang(s_HostServ, u, HOST_IDENT_ACTIVATED,
- vIdent, vHost);
- } else {
- notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost);
- }
- anope_cmd_vhost_on(u->nick, vIdent, vHost);
- if (ircd->vhost) {
- u->vhost = sstrdup(vHost);
- }
- if (ircd->vident) {
- if (vIdent)
- u->vident = sstrdup(vIdent);
- }
- set_lastmask(u);
- }
- } else {
- notice_lang(s_HostServ, u, HOST_ID);
- }
- } else {
- notice_lang(s_HostServ, u, HOST_NOT_REGED);
- }
- return MOD_CONT;
-}
-
/*************************************************************************/
int do_on_id(User * u)
{ /* we've assumed that the user exists etc.. */
@@ -1009,52 +574,6 @@ int do_on_id(User * u)
}
/*************************************************************************/
-int do_del(User * u)
-{
- NickAlias *na;
- char *nick = strtok(NULL, " ");
- if (nick) {
- if ((na = findnick(nick))) {
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
- return MOD_CONT;
- }
- alog("vHost for user \002%s\002 deleted by oper \002%s\002",
- nick, u->nick);
- delHostCore(nick);
- notice_lang(s_HostServ, u, HOST_DEL, nick);
- } else {
- notice_lang(s_HostServ, u, HOST_NOREG, nick);
- }
- } else {
- notice_lang(s_HostServ, u, HOST_DEL_SYNTAX, s_HostServ);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-int do_off(User * u)
-{
- NickAlias *na;
- char *vhost;
- char *vident = NULL;
- if ((na = findnick(u->nick))) {
- if (na->status & NS_IDENTIFIED) {
- vhost = getvHost(u->nick);
- vident = getvIdent(u->nick);
- if (vhost == NULL && vident == NULL)
- notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
- else
- anope_cmd_vhost_off(u);
- } else {
- notice_lang(s_HostServ, u, HOST_ID);
- }
- } else {
- notice_lang(s_HostServ, u, HOST_NOT_REGED);
- }
- return MOD_CONT;
-}
-
int is_host_setter(User * u)
{
int i, j;
@@ -1100,11 +619,3 @@ void set_lastmask(User * u)
common_get_vhost(u));
}
-
-/*************************************************************************/
-/* End of Generic Functions */
-/*************************************************************************/
-
-/*************************************************************************/
-/* End of Server Functions */
-/*************************************************************************/
diff --git a/src/init.c b/src/init.c
index 87a2e91fb..33c4b3dcd 100644
--- a/src/init.c
+++ b/src/init.c
@@ -18,6 +18,7 @@ int servernum = 0;
extern void moduleAddMsgs(void);
extern void moduleAddIRCDMsgs(void);
+extern int protocol_module_init(void);
/*************************************************************************/
void introduce_user(const char *user)
@@ -319,8 +320,8 @@ static int parse_options(int ac, char **av)
} else if (!strcmp(s, "noexpire")) {
noexpire = 1;
} else if (!strcmp(s, "version")) {
- fprintf(stdout, "Anope-%s %s %s -- %s\n", version_number,
- ircd->name, version_flags, version_build);
+ fprintf(stdout, "Anope-%s %s -- %s\n", version_number,
+ version_flags, version_build);
exit(EXIT_SUCCESS);
} else if (!strcmp(s, "help")) {
fprintf(stdout, "Anope-%s %s -- %s\n", version_number,
@@ -437,8 +438,6 @@ int init(int ac, char **av)
return -1;
}
- /* Add IRCD Message handlers */
- moduleAddIRCDMsgs();
/* Add Core MSG handles */
moduleAddMsgs();
@@ -446,6 +445,10 @@ int init(int ac, char **av)
/* Parse all remaining command-line options. */
parse_options(ac, av);
+ /* Add IRCD Protocol Module; exit if there are errors */
+ if (protocol_module_init()) {
+ return -1;
+ }
#ifndef _WIN32
if (!nofork) {
if ((i = fork()) < 0) {
@@ -485,16 +488,18 @@ int init(int ac, char **av)
/* Announce ourselves to the logfile. */
if (debug || readonly || skeleton) {
- alog("Anope %s (compiled for %s) starting up (options:%s%s%s)",
+ alog("Anope %s (ircd protocol: %s) starting up (options:%s%s%s)",
version_number, version_protocol,
debug ? " debug" : "", readonly ? " readonly" : "",
skeleton ? " skeleton" : "");
} else {
- alog("Anope %s (compiled for %s) starting up",
+ alog("Anope %s (ircd protocol: %s) starting up",
version_number, version_protocol);
}
start_time = time(NULL);
+
+
/* If in read-only mode, close the logfile again. */
if (readonly)
close_log();
@@ -562,6 +567,7 @@ int init(int ac, char **av)
if (debug)
alog("debug: Loaded languages");
+
/* Initialize subservices */
ns_init();
cs_init();
@@ -658,7 +664,7 @@ int init(int ac, char **av)
alog("Info: Not reflecting database records.");
}
#endif
- send_event(EVENT_CONNECT, EVENT_START);
+ send_event(EVENT_CONNECT, 1, EVENT_START);
/* Connect to the remote server */
servsock = conn(RemoteServer, RemotePort, LocalHost, LocalPort);
@@ -692,7 +698,7 @@ int init(int ac, char **av)
}
anope_cmd_connect(servernum);
- send_event(EVENT_CONNECT, EVENT_STOP);
+ send_event(EVENT_CONNECT, 1, EVENT_STOP);
sgets2(inbuf, sizeof(inbuf), servsock);
if (strnicmp(inbuf, "ERROR", 5) == 0) {
diff --git a/src/ircd.c b/src/ircd.c
new file mode 100644
index 000000000..67b336b47
--- /dev/null
+++ b/src/ircd.c
@@ -0,0 +1,1114 @@
+#include "services.h"
+#include "extern.h"
+
+IRCDProto ircdproto;
+IRCDModes ircd_modes;
+
+/**
+ * Globals we want from the protocol file
+ **/
+IRCDVar *ircd;
+IRCDCAPAB *ircdcap;
+char *version_protocol;
+CBModeInfo *cbmodeinfos;
+CUMode cumodes[128];
+char *flood_mode_char_set;
+char *flood_mode_char_remove;
+CBMode cbmodes[128];
+CMMode cmmodes[128];
+char csmodes[128];
+int UseTSMODE;
+
+/**
+ * Initiate a protocol struct ready for use
+ **/
+void initIrcdProto()
+{
+ ircdproto.ircd_set_umode = NULL;
+ ircdproto.ircd_cmd_svsnoop = NULL;
+ ircdproto.ircd_cmd_remove_akill = NULL;
+ ircdproto.ircd_cmd_topic = NULL;
+ ircdproto.ircd_cmd_vhost_off = NULL;
+ ircdproto.ircd_cmd_akill = NULL;
+ ircdproto.ircd_cmd_svskill = NULL;
+ ircdproto.ircd_cmd_svsmode = NULL;
+ ircdproto.ircd_cmd_372 = NULL;
+ ircdproto.ircd_cmd_372_error = NULL;
+ ircdproto.ircd_cmd_375 = NULL;
+ ircdproto.ircd_cmd_376 = NULL;
+ ircdproto.ircd_cmd_nick = NULL;
+ ircdproto.ircd_cmd_guest_nick = NULL;
+ ircdproto.ircd_cmd_mode = NULL;
+ ircdproto.ircd_cmd_bot_nick = NULL;
+ ircdproto.ircd_cmd_kick = NULL;
+ ircdproto.ircd_cmd_notice_ops = NULL;
+ ircdproto.ircd_cmd_notice = NULL;
+ ircdproto.ircd_cmd_notice2 = NULL;
+ ircdproto.ircd_cmd_privmsg = NULL;
+ ircdproto.ircd_cmd_privmsg2 = NULL;
+ ircdproto.ircd_cmd_serv_notice = NULL;
+ ircdproto.ircd_cmd_serv_privmsg = NULL;
+ ircdproto.ircd_cmd_bot_chan_mode = NULL;
+ ircdproto.ircd_cmd_351 = NULL;
+ ircdproto.ircd_cmd_quit = NULL;
+ ircdproto.ircd_cmd_pong = NULL;
+ ircdproto.ircd_cmd_join = NULL;
+ ircdproto.ircd_cmd_unsqline = NULL;
+ ircdproto.ircd_cmd_invite = NULL;
+ ircdproto.ircd_cmd_part = NULL;
+ ircdproto.ircd_cmd_391 = NULL;
+ ircdproto.ircd_cmd_250 = NULL;
+ ircdproto.ircd_cmd_307 = NULL;
+ ircdproto.ircd_cmd_311 = NULL;
+ ircdproto.ircd_cmd_312 = NULL;
+ ircdproto.ircd_cmd_317 = NULL;
+ ircdproto.ircd_cmd_219 = NULL;
+ ircdproto.ircd_cmd_401 = NULL;
+ ircdproto.ircd_cmd_318 = NULL;
+ ircdproto.ircd_cmd_242 = NULL;
+ ircdproto.ircd_cmd_243 = NULL;
+ ircdproto.ircd_cmd_211 = NULL;
+ ircdproto.ircd_cmd_global = NULL;
+ ircdproto.ircd_cmd_global_legacy = NULL;
+ ircdproto.ircd_cmd_sqline = NULL;
+ ircdproto.ircd_cmd_squit = NULL;
+ ircdproto.ircd_cmd_svso = NULL;
+ ircdproto.ircd_cmd_chg_nick = NULL;
+ ircdproto.ircd_cmd_svsnick = NULL;
+ ircdproto.ircd_cmd_vhost_on = NULL;
+ ircdproto.ircd_cmd_connect = NULL;
+ ircdproto.ircd_cmd_svshold = NULL;
+ ircdproto.ircd_cmd_release_svshold = NULL;
+ ircdproto.ircd_cmd_unsgline = NULL;
+ ircdproto.ircd_cmd_unszline = NULL;
+ ircdproto.ircd_cmd_szline = NULL;
+ ircdproto.ircd_cmd_sgline = NULL;
+ ircdproto.ircd_cmd_unban = NULL;
+ ircdproto.ircd_cmd_svsmode_chan = NULL;
+ ircdproto.ircd_cmd_svid_umode = NULL;
+ ircdproto.ircd_cmd_nc_change = NULL;
+ ircdproto.ircd_cmd_svid_umode2 = NULL;
+ ircdproto.ircd_cmd_svid_umode3 = NULL;
+ ircdproto.ircd_cmd_eob = NULL;
+ ircdproto.ircd_flood_mode_check = NULL;
+ ircdproto.ircd_cmd_jupe = NULL;
+ ircdproto.ircd_valid_nick = NULL;
+ ircdproto.ircd_cmd_ctcp = NULL;
+}
+
+void anope_set_umode(User * user, int ac, char **av)
+{
+ ircdproto.ircd_set_umode(user, ac, av);
+}
+
+void anope_cmd_svsnoop(char *server, int set)
+{
+ ircdproto.ircd_cmd_svsnoop(server, set);
+}
+
+void anope_cmd_remove_akill(char *user, char *host)
+{
+ ircdproto.ircd_cmd_remove_akill(user, host);
+}
+
+void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
+{
+ ircdproto.ircd_cmd_topic(whosets, chan, whosetit, topic, when);
+}
+
+void anope_cmd_vhost_off(User * u)
+{
+ ircdproto.ircd_cmd_vhost_off(u);
+}
+
+void anope_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
+{
+ ircdproto.ircd_cmd_akill(user, host, who, when, expires, reason);
+}
+
+void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_svskill(source, user, buf);
+}
+
+void anope_cmd_svsmode(User * u, int ac, char **av)
+{
+ ircdproto.ircd_cmd_svsmode(u, ac, av);
+}
+
+void anope_cmd_372(char *source, char *msg)
+{
+ ircdproto.ircd_cmd_372(source, msg);
+}
+
+void anope_cmd_372_error(char *source)
+{
+ ircdproto.ircd_cmd_372_error(source);
+}
+
+void anope_cmd_375(char *source)
+{
+ ircdproto.ircd_cmd_375(source);
+}
+
+void anope_cmd_376(char *source)
+{
+ ircdproto.ircd_cmd_376(source);
+}
+
+void anope_cmd_nick(char *nick, char *name, char *modes)
+{
+ ircdproto.ircd_cmd_nick(nick, name, modes);
+}
+
+void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
+{
+ ircdproto.ircd_cmd_guest_nick(nick, user, host, real, modes);
+}
+
+void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_mode(source, dest, buf);
+}
+
+void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
+{
+ ircdproto.ircd_cmd_bot_nick(nick, user, host, real, modes);
+}
+
+void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
+ ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_kick(source, chan, user, buf);
+}
+
+void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_notice_ops(source, dest, buf);
+}
+
+void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_notice(source, dest, buf);
+}
+
+void anope_cmd_notice2(char *source, char *dest, char *msg)
+{
+ ircdproto.ircd_cmd_notice2(source, dest, msg);
+}
+
+void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_privmsg(source, dest, buf);
+}
+
+void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+{
+ ircdproto.ircd_cmd_privmsg2(source, dest, msg);
+}
+
+void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+{
+ ircdproto.ircd_cmd_serv_notice(source, dest, msg);
+}
+
+void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+{
+ ircdproto.ircd_cmd_serv_privmsg(source, dest, msg);
+}
+
+void anope_cmd_bot_chan_mode(char *nick, char *chan)
+{
+ ircdproto.ircd_cmd_bot_chan_mode(nick, chan);
+}
+
+void anope_cmd_351(char *source)
+{
+ ircdproto.ircd_cmd_351(source);
+}
+
+void anope_cmd_quit(char *source, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_quit(source, buf);
+}
+
+void anope_cmd_pong(char *servname, char *who)
+{
+ ircdproto.ircd_cmd_pong(servname, who);
+}
+
+void anope_cmd_join(char *user, char *channel, time_t chantime)
+{
+ ircdproto.ircd_cmd_join(user, channel, chantime);
+}
+
+void anope_cmd_unsqline(char *user)
+{
+ ircdproto.ircd_cmd_unsqline(user);
+}
+
+void anope_cmd_invite(char *source, char *chan, char *nick)
+{
+ ircdproto.ircd_cmd_invite(source, chan, nick);
+}
+
+void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_part(nick, chan, buf);
+}
+
+void anope_cmd_391(char *source, char *timestr)
+{
+ ircdproto.ircd_cmd_391(source, timestr);
+}
+
+void anope_cmd_250(const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_250(buf);
+}
+
+void anope_cmd_307(const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_307(buf);
+}
+
+void anope_cmd_311(const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_311(buf);
+}
+
+void anope_cmd_312(const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_312(buf);
+}
+
+void anope_cmd_317(const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_317(buf);
+}
+
+void anope_cmd_219(char *source, char *letter)
+{
+ ircdproto.ircd_cmd_219(source, letter);
+}
+
+void anope_cmd_401(char *source, char *who)
+{
+ ircdproto.ircd_cmd_401(source, who);
+}
+
+void anope_cmd_318(char *source, char *who)
+{
+ ircdproto.ircd_cmd_318(source, who);
+}
+
+void anope_cmd_242(const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_242(buf);
+}
+
+void anope_cmd_243(const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_243(buf);
+}
+
+void anope_cmd_211(const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_211(buf);
+}
+
+void anope_cmd_global(char *source, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_global(source, buf);
+}
+
+void anope_cmd_global_legacy(char *source, char *fmt)
+{
+ ircdproto.ircd_cmd_global_legacy(source, fmt);
+}
+
+void anope_cmd_sqline(char *mask, char *reason)
+{
+ ircdproto.ircd_cmd_sqline(mask, reason);
+}
+
+void anope_cmd_squit(char *servname, char *message)
+{
+ ircdproto.ircd_cmd_squit(servname, message);
+}
+
+void anope_cmd_svso(char *source, char *nick, char *flag)
+{
+ ircdproto.ircd_cmd_svso(source, nick, flag);
+}
+
+void anope_cmd_chg_nick(char *oldnick, char *newnick)
+{
+ ircdproto.ircd_cmd_chg_nick(oldnick, newnick);
+}
+
+void anope_cmd_svsnick(char *source, char *guest, time_t when)
+{
+ ircdproto.ircd_cmd_svsnick(source, guest, when);
+}
+
+void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+{
+ ircdproto.ircd_cmd_vhost_on(nick, vIdent, vhost);
+}
+
+void anope_cmd_connect(int servernum)
+{
+ ircdproto.ircd_cmd_connect(servernum);
+}
+
+void anope_cmd_svshold(char *nick)
+{
+ ircdproto.ircd_cmd_svshold(nick);
+}
+
+void anope_cmd_release_svshold(char *nick)
+{
+ ircdproto.ircd_cmd_release_svshold(nick);
+}
+
+void anope_cmd_unsgline(char *mask)
+{
+ ircdproto.ircd_cmd_unsgline(mask);
+}
+
+void anope_cmd_unszline(char *mask)
+{
+ ircdproto.ircd_cmd_unszline(mask);
+}
+
+void anope_cmd_szline(char *mask, char *reason, char *whom)
+{
+ ircdproto.ircd_cmd_szline(mask, reason, whom);
+}
+
+void anope_cmd_sgline(char *mask, char *reason)
+{
+ ircdproto.ircd_cmd_sgline(mask, reason);
+}
+
+void anope_cmd_unban(char *name, char *nick)
+{
+ ircdproto.ircd_cmd_unban(name, nick);
+}
+
+void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+{
+ ircdproto.ircd_cmd_svsmode_chan(name, mode, nick);
+}
+
+void anope_cmd_svid_umode(char *nick, time_t ts)
+{
+ ircdproto.ircd_cmd_svid_umode(nick, ts);
+}
+
+void anope_cmd_nc_change(User * u)
+{
+ ircdproto.ircd_cmd_nc_change(u);
+}
+
+void anope_cmd_svid_umode2(User * u, char *ts)
+{
+ ircdproto.ircd_cmd_svid_umode2(u, ts);
+}
+
+void anope_cmd_svid_umode3(User * u, char *ts)
+{
+ ircdproto.ircd_cmd_svid_umode3(u, ts);
+}
+
+void anope_cmd_eob()
+{
+ ircdproto.ircd_cmd_eob();
+}
+
+int anope_flood_mode_check(char *value)
+{
+ return ircdproto.ircd_flood_mode_check(value);
+}
+
+void anope_cmd_jupe(char *jserver, char *who, char *reason)
+{
+ ircdproto.ircd_cmd_jupe(jserver, who, reason);
+}
+
+int anope_valid_nick(char *nick)
+{
+ return ircdproto.ircd_valid_nick(nick);
+}
+
+void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZE];
+ *buf = '\0';
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buf, BUFSIZE - 1, fmt, args);
+ va_end(args);
+ }
+ ircdproto.ircd_cmd_ctcp(source, dest, buf);
+}
+
+
+
+/**
+ * Set routines for modules to set the prefered function for dealing with things.
+ **/
+
+void pmodule_cmd_svsnoop(void (*func) (char *server, int set))
+{
+ ircdproto.ircd_cmd_svsnoop = func;
+}
+
+void pmodule_cmd_remove_akill(void (*func) (char *user, char *host))
+{
+ ircdproto.ircd_cmd_remove_akill = func;
+}
+
+void pmodule_cmd_topic(void (*func)
+ (char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when))
+{
+ ircdproto.ircd_cmd_topic = func;
+}
+
+void pmodule_cmd_vhost_off(void (*func) (User * u))
+{
+ ircdproto.ircd_cmd_vhost_off = func;
+}
+
+void pmodule_cmd_akill(void (*func)
+ (char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason))
+{
+ ircdproto.ircd_cmd_akill = func;
+}
+
+void
+pmodule_cmd_svskill(void (*func) (char *source, char *user, char *buf))
+{
+ ircdproto.ircd_cmd_svskill = func;
+}
+
+void pmodule_cmd_svsmode(void (*func) (User * u, int ac, char **av))
+{
+ ircdproto.ircd_cmd_svsmode = func;
+}
+
+void pmodule_cmd_372(void (*func) (char *source, char *msg))
+{
+ ircdproto.ircd_cmd_372 = func;
+}
+
+void pmodule_cmd_372_error(void (*func) (char *source))
+{
+ ircdproto.ircd_cmd_372_error = func;
+}
+
+void pmodule_cmd_375(void (*func) (char *source))
+{
+ ircdproto.ircd_cmd_375 = func;
+}
+
+void pmodule_cmd_376(void (*func) (char *source))
+{
+ ircdproto.ircd_cmd_376 = func;
+}
+
+void pmodule_cmd_nick(void (*func) (char *nick, char *name, char *modes))
+{
+ ircdproto.ircd_cmd_nick = func;
+}
+
+void pmodule_cmd_guest_nick(void (*func)
+ (char *nick, char *user, char *host,
+ char *real, char *modes))
+{
+ ircdproto.ircd_cmd_guest_nick = func;
+}
+
+void pmodule_cmd_mode(void (*func) (char *source, char *dest, char *buf))
+{
+ ircdproto.ircd_cmd_mode = func;
+}
+
+void pmodule_cmd_bot_nick(void (*func)
+ (char *nick, char *user, char *host, char *real,
+ char *modes))
+{
+ ircdproto.ircd_cmd_bot_nick = func;
+}
+
+void pmodule_cmd_kick(void (*func)
+ (char *source, char *chan, char *user, char *buf))
+{
+ ircdproto.ircd_cmd_kick = func;
+}
+
+void
+pmodule_cmd_notice_ops(void (*func) (char *source, char *dest, char *buf))
+{
+ ircdproto.ircd_cmd_notice_ops = func;
+}
+
+void pmodule_cmd_notice(void (*func) (char *source, char *dest, char *buf))
+{
+ ircdproto.ircd_cmd_notice = func;
+}
+
+void
+pmodule_cmd_notice2(void (*func) (char *source, char *dest, char *msg))
+{
+ ircdproto.ircd_cmd_notice2 = func;
+}
+
+void
+pmodule_cmd_privmsg(void (*func) (char *source, char *dest, char *buf))
+{
+ ircdproto.ircd_cmd_privmsg = func;
+}
+
+void
+pmodule_cmd_privmsg2(void (*func) (char *source, char *dest, char *msg))
+{
+ ircdproto.ircd_cmd_privmsg2 = func;
+}
+
+void
+pmodule_cmd_serv_notice(void (*func) (char *source, char *dest, char *msg))
+{
+ ircdproto.ircd_cmd_serv_notice = func;
+}
+
+void pmodule_cmd_serv_privmsg(void (*func)
+ (char *source, char *dest, char *msg))
+{
+ ircdproto.ircd_cmd_serv_privmsg = func;
+}
+
+void pmodule_cmd_bot_chan_mode(void (*func) (char *nick, char *chan))
+{
+ ircdproto.ircd_cmd_bot_chan_mode = func;
+}
+
+void pmodule_cmd_351(void (*func) (char *source))
+{
+ ircdproto.ircd_cmd_351 = func;
+}
+
+void pmodule_cmd_quit(void (*func) (char *source, char *buf))
+{
+ ircdproto.ircd_cmd_quit = func;
+}
+
+void pmodule_cmd_pong(void (*func) (char *servname, char *who))
+{
+ ircdproto.ircd_cmd_pong = func;
+}
+
+void
+pmodule_cmd_join(void (*func) (char *user, char *channel, time_t chantime))
+{
+ ircdproto.ircd_cmd_join = func;
+}
+
+void pmodule_cmd_unsqline(void (*func) (char *user))
+{
+ ircdproto.ircd_cmd_unsqline = func;
+}
+
+void
+pmodule_cmd_invite(void (*func) (char *source, char *chan, char *nick))
+{
+ ircdproto.ircd_cmd_invite = func;
+}
+
+void pmodule_cmd_part(void (*func) (char *nick, char *chan, char *buf))
+{
+ ircdproto.ircd_cmd_part = func;
+}
+
+void pmodule_cmd_391(void (*func) (char *source, char *timestr))
+{
+ ircdproto.ircd_cmd_391 = func;
+}
+
+void pmodule_cmd_250(void (*func) (char *buf))
+{
+ ircdproto.ircd_cmd_250 = func;
+}
+
+void pmodule_cmd_307(void (*func) (char *buf))
+{
+ ircdproto.ircd_cmd_307 = func;
+}
+
+void pmodule_cmd_311(void (*func) (char *buf))
+{
+ ircdproto.ircd_cmd_311 = func;
+}
+
+void pmodule_cmd_312(void (*func) (char *buf))
+{
+ ircdproto.ircd_cmd_312 = func;
+}
+
+void pmodule_cmd_317(void (*func) (char *buf))
+{
+ ircdproto.ircd_cmd_317 = func;
+}
+
+void pmodule_cmd_219(void (*func) (char *source, char *letter))
+{
+ ircdproto.ircd_cmd_219 = func;
+}
+
+void pmodule_cmd_401(void (*func) (char *source, char *who))
+{
+ ircdproto.ircd_cmd_401 = func;
+}
+
+void pmodule_cmd_318(void (*func) (char *source, char *who))
+{
+ ircdproto.ircd_cmd_318 = func;
+}
+
+void pmodule_cmd_242(void (*func) (char *buf))
+{
+ ircdproto.ircd_cmd_242 = func;
+}
+
+void pmodule_cmd_243(void (*func) (char *buf))
+{
+ ircdproto.ircd_cmd_243 = func;
+}
+
+void pmodule_cmd_211(void (*func) (char *buf))
+{
+ ircdproto.ircd_cmd_211 = func;
+}
+
+void pmodule_cmd_global(void (*func) (char *source, char *buf))
+{
+ ircdproto.ircd_cmd_global = func;
+}
+
+void pmodule_cmd_global_legacy(void (*func) (char *source, char *fmt))
+{
+ ircdproto.ircd_cmd_global_legacy = func;
+}
+
+void pmodule_cmd_sqline(void (*func) (char *mask, char *reason))
+{
+ ircdproto.ircd_cmd_sqline = func;
+}
+
+void pmodule_cmd_squit(void (*func) (char *servname, char *message))
+{
+ ircdproto.ircd_cmd_squit = func;
+}
+
+void pmodule_cmd_svso(void (*func) (char *source, char *nick, char *flag))
+{
+ ircdproto.ircd_cmd_svso = func;
+}
+
+void pmodule_cmd_chg_nick(void (*func) (char *oldnick, char *newnick))
+{
+ ircdproto.ircd_cmd_chg_nick = func;
+}
+
+void
+pmodule_cmd_svsnick(void (*func) (char *source, char *guest, time_t when))
+{
+ ircdproto.ircd_cmd_svsnick = func;
+}
+
+void
+pmodule_cmd_vhost_on(void (*func) (char *nick, char *vIdent, char *vhost))
+{
+ ircdproto.ircd_cmd_vhost_on = func;
+}
+
+void pmodule_cmd_connect(void (*func) (int servernum))
+{
+ ircdproto.ircd_cmd_connect = func;
+}
+
+void pmodule_cmd_svshold(void (*func) (char *nick))
+{
+ ircdproto.ircd_cmd_svshold = func;
+}
+
+void pmodule_cmd_release_svshold(void (*func) (char *nick))
+{
+ ircdproto.ircd_cmd_release_svshold = func;
+}
+
+void pmodule_cmd_unsgline(void (*func) (char *mask))
+{
+ ircdproto.ircd_cmd_unsgline = func;
+}
+
+void pmodule_cmd_unszline(void (*func) (char *mask))
+{
+ ircdproto.ircd_cmd_unszline = func;
+}
+
+void
+pmodule_cmd_szline(void (*func) (char *mask, char *reason, char *whom))
+{
+ ircdproto.ircd_cmd_szline = func;
+}
+
+void pmodule_cmd_sgline(void (*func) (char *mask, char *reason))
+{
+ ircdproto.ircd_cmd_sgline = func;
+}
+
+void pmodule_cmd_unban(void (*func) (char *name, char *nick))
+{
+ ircdproto.ircd_cmd_unban = func;
+}
+
+void
+pmodule_cmd_svsmode_chan(void (*func) (char *name, char *mode, char *nick))
+{
+ ircdproto.ircd_cmd_svsmode_chan = func;
+}
+
+void pmodule_cmd_svid_umode(void (*func) (char *nick, time_t ts))
+{
+ ircdproto.ircd_cmd_svid_umode = func;
+}
+
+void pmodule_cmd_nc_change(void (*func) (User * u))
+{
+ ircdproto.ircd_cmd_nc_change = func;
+}
+
+void pmodule_cmd_svid_umode2(void (*func) (User * u, char *ts))
+{
+ ircdproto.ircd_cmd_svid_umode2 = func;
+}
+
+void pmodule_cmd_svid_umode3(void (*func) (User * u, char *ts))
+{
+ ircdproto.ircd_cmd_svid_umode3 = func;
+}
+
+void pmodule_cmd_ctcp(void (*func) (char *source, char *dest, char *buf))
+{
+ ircdproto.ircd_cmd_ctcp = func;
+}
+
+void pmodule_cmd_eob(void (*func) ())
+{
+ ircdproto.ircd_cmd_eob = func;
+}
+
+void
+pmodule_cmd_jupe(void (*func) (char *jserver, char *who, char *reason))
+{
+ ircdproto.ircd_cmd_jupe = func;
+}
+
+void pmodule_set_umode(void (*func) (User * user, int ac, char **av))
+{
+ ircdproto.ircd_set_umode = func;
+}
+
+void pmodule_valid_nick(int (*func) (char *nick))
+{
+ ircdproto.ircd_valid_nick = func;
+}
+
+void pmodule_flood_mode_check(int (*func) (char *value))
+{
+ ircdproto.ircd_flood_mode_check = func;
+}
+
+void pmodule_ircd_var(IRCDVar * ircdvar)
+{
+ ircd = ircdvar;
+}
+
+void pmodule_ircd_cap(IRCDCAPAB * cap)
+{
+ ircdcap = cap;
+}
+
+void pmodule_ircd_version(char *version)
+{
+ version_protocol = sstrdup(version);
+}
+
+void pmodule_ircd_cbmodeinfos(CBModeInfo * modeinfos)
+{
+ cbmodeinfos = modeinfos;
+}
+
+void pmodule_ircd_cumodes(CUMode modes[128])
+{
+ int i = 0;
+ for (i = 0; i < 128; i++) {
+ cumodes[i] = modes[i];
+ }
+}
+
+void pmodule_ircd_flood_mode_char_set(char *mode)
+{
+ flood_mode_char_set = sstrdup(mode);
+}
+
+void pmodule_ircd_flood_mode_char_remove(char *mode)
+{
+ flood_mode_char_remove = sstrdup(mode);
+}
+
+void pmodule_ircd_cbmodes(CBMode modes[128])
+{
+ int i = 0;
+ for (i = 0; i < 128; i++) {
+ cbmodes[i] = modes[i];
+ }
+}
+
+void pmodule_ircd_cmmodes(CMMode modes[128])
+{
+ int i = 0;
+ for (i = 0; i < 128; i++) {
+ cmmodes[i] = modes[i];
+ }
+}
+
+void pmodule_ircd_csmodes(char mode[128])
+{
+ int i = 0;
+ for (i = 0; i < 128; i++) {
+ csmodes[i] = mode[i];
+ }
+}
+
+void pmodule_ircd_useTSMode(int use)
+{
+ UseTSMODE = use;
+}
+
+/** mode stuff */
+
+void pmodule_invis_umode(int mode)
+{
+ ircd_modes.user_invis = mode;
+}
+
+void pmodule_oper_umode(int mode)
+{
+ ircd_modes.user_oper = mode;
+}
+
+void pmodule_invite_cmode(int mode)
+{
+ ircd_modes.chan_invite = mode;
+}
+
+void pmodule_secret_cmode(int mode)
+{
+ ircd_modes.chan_secret = mode;
+}
+
+void pmodule_private_cmode(int mode)
+{
+ ircd_modes.chan_private = mode;
+}
+
+void pmodule_key_mode(int mode)
+{
+ ircd_modes.chan_key = mode;
+}
+
+void pmodule_limit_mode(int mode)
+{
+ ircd_modes.chan_limit = mode;
+}
+
+int anope_get_invis_mode()
+{
+ return ircd_modes.user_invis;
+}
+
+int anope_get_oper_mode()
+{
+ return ircd_modes.user_oper;
+}
+
+int anope_get_invite_mode()
+{
+ return ircd_modes.chan_invite;
+}
+
+int anope_get_secret_mode()
+{
+ return ircd_modes.chan_secret;
+}
+
+int anope_get_private_mode()
+{
+ return ircd_modes.chan_private;
+}
+
+int anope_get_key_mode()
+{
+ return ircd_modes.chan_key;
+}
+
+int anope_get_limit_mode()
+{
+ return ircd_modes.chan_limit;
+}
diff --git a/src/main.c b/src/main.c
index 878e12848..6300078a0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -98,7 +98,7 @@ static int started = 0;
extern void expire_all(void)
{
- send_event(EVENT_DB_EXPIRE, EVENT_START);
+ send_event(EVENT_DB_EXPIRE, 1, EVENT_START);
waiting = -3;
if (debug)
alog("debug: Running expire routines");
@@ -125,14 +125,14 @@ extern void expire_all(void)
expire_szlines();
}
expire_exceptions();
- send_event(EVENT_DB_EXPIRE, EVENT_STOP);
+ send_event(EVENT_DB_EXPIRE, 1, EVENT_STOP);
}
/*************************************************************************/
void save_databases(void)
{
- send_event(EVENT_DB_SAVING, EVENT_START);
+ send_event(EVENT_DB_SAVING, 1, EVENT_START);
waiting = -2;
if (debug)
@@ -204,7 +204,7 @@ void save_databases(void)
}
}
#endif
- send_event(EVENT_DB_SAVING, EVENT_STOP);
+ send_event(EVENT_DB_SAVING, 1, EVENT_STOP);
}
/*************************************************************************/
@@ -214,7 +214,7 @@ void save_databases(void)
static void services_restart(void)
{
alog("Restarting");
- send_event(EVENT_RESTART, EVENT_START);
+ send_event(EVENT_RESTART, 1, EVENT_START);
if (!quitmsg)
quitmsg = "Restarting";
anope_cmd_squit(ServerName, quitmsg);
@@ -254,7 +254,7 @@ static void services_shutdown(void)
{
User *u, *next;
- send_event(EVENT_SHUTDOWN, EVENT_START);
+ send_event(EVENT_SHUTDOWN, 1, EVENT_START);
if (!quitmsg)
quitmsg = "Terminating, reason unknown";
@@ -273,7 +273,7 @@ static void services_shutdown(void)
u = next;
}
}
- send_event(EVENT_SHUTDOWN, EVENT_STOP);
+ send_event(EVENT_SHUTDOWN, 1, EVENT_STOP);
disconn(servsock);
}
@@ -317,6 +317,7 @@ void sighandler(int signum)
"Error Reading Configuration File (Received SIGUSR2)");
quitting = 1;
}
+ send_event(EVENT_RELOAD, 1, EVENT_START);
return;
} else
@@ -432,7 +433,8 @@ void sighandler(int signum)
if (signum == SIGSEGV) {
do_backtrace(1);
}
- send_event(EVENT_SIGNAL, quitmsg);
+ /* Should we send the signum here as well? -GD */
+ send_event(EVENT_SIGNAL, 1, quitmsg);
if (started) {
services_shutdown();
diff --git a/src/makefile.win32 b/src/makefile.win32
index 8b60c3474..21a78661b 100644
--- a/src/makefile.win32
+++ b/src/makefile.win32
@@ -19,21 +19,21 @@ include ../Makefile.inc.win32
OBJS = actions.obj base64.obj botserv.obj channels.obj chanserv.obj commands.obj compat.obj \
config.obj datafiles.obj encrypt.obj events.obj helpserv.obj hostserv.obj \
- init.obj language.obj list.obj log.obj mail.obj main.obj memory.obj memoserv.obj \
- messages.obj misc.obj modules.obj news.obj nickserv.obj operserv.obj \
+ init.obj ircd.obj language.obj list.obj log.obj mail.obj main.obj memory.obj \
+ memoserv.obj messages.obj misc.obj modules.obj news.obj nickserv.obj operserv.obj \
process.obj send.obj servers.obj sessions.obj slist.obj sockutil.obj \
- timeout.obj users.obj $(RDB_O) $(MYSQL_O) $(CAPAB_O)
+ timeout.obj users.obj $(RDB_O) $(MYSQL_O)
SRCS = actions.c base64.c botserv.c channels.c chanserv.c commands.c compat.c \
- config.c datafiles.c encrypt.c events.c helpserv.c hostserv.c init.c language.c list.c \
- log.c mail.c main.c memory.c memoserv.c messages.c misc.c modules.c news.c nickserv.c \
- operserv.c process.c send.c servers.obj sessions.c slist.c sockutil.c \
- timeout.c users.c $(RDB_C) $(MYSQL_C) $(CAPAB_C)
+ config.c datafiles.c encrypt.c events.c helpserv.c hostserv.c init.c ircd.c \
+ language.c list.c log.c mail.c main.c memory.c memoserv.c messages.c misc.c \
+ modules.c news.c nickserv.c operserv.c process.c send.c servers.obj sessions.c \
+ slist.c sockutil.c timeout.c users.c $(RDB_C) $(MYSQL_C)
###########################################################################
.c.obj:
- $(CC) $(CFLAGS) $(IRCTYPE) -c $<
+ $(CC) $(CFLAGS) -c $<
all: $(PROGRAM)
@@ -45,7 +45,6 @@ spotless:
install:
-@copy anope.exe ..\anope.exe
- -@copy tools\anopesmtp.exe ..\anopesmtp.exe
-@mkdir ..\$(DATDEST)\bin
-@copy bin\* ..\$(DATDEST)\bin
@@ -68,8 +67,9 @@ compat.obj: compat.c ..\include\services.h
config.obj: config.c ..\include\services.h
datafiles.obj: datafiles.c ..\include\services.h ..\include\datafiles.h
encrypt.obj: encrypt.c ..\include\encrypt.h ..\include\sysconf.h
-events.obj: events.c ..\include\modules.h ..\include\language.h ..\include\version.h
+events.obj: events.c ..\include\modules.h ..\include\language.h ..\include\version.h
init.obj: init.c ..\include\services.h
+ircd.obj: ircd.c ..\include\services.h
hostserv.obj: hostserv.c ..\include\services.h ..\include\pseudo.h
language.obj: language.c ..\include\services.h ..\include\language.h
list.obj: list.c ..\include\services.h
@@ -79,7 +79,7 @@ main.obj: main.c ..\include\services.h ..\include\
memory.obj: memory.c ..\include\services.h
memoserv.obj: memoserv.c ..\include\services.h ..\include\pseudo.h
messages.obj: messages.c ..\include\services.h ..\include\messages.h ..\include\language.h
-modules.obj: modules.c ..\include\modules.h ..\include\language.h ..\include\version.h
+modules.obj: modules.c ..\include\modules.h ..\include\language.h ..\include\version.h
misc.obj: misc.c ..\include\services.h ..\include\language.h
news.obj: news.c ..\include\services.h ..\include\pseudo.h
nickserv.obj: nickserv.c ..\include\services.h ..\include\pseudo.h
diff --git a/src/memoserv.c b/src/memoserv.c
index 479437aa7..af4b4c063 100644
--- a/src/memoserv.c
+++ b/src/memoserv.c
@@ -19,43 +19,15 @@
/* *INDENT-OFF* */
NickCore *nclists[1024];
-static int delmemo(MemoInfo *mi, int num);
-static int do_help(User *u);
-static int do_send(User *u);
-void memo_send(User *u, char *name, char *text, int z);
-static int do_cancel(User *u);
-static int do_list(User *u);
-static int do_read(User *u);
-static int do_del(User *u);
-static int do_set(User *u);
-static int do_set_notify(User *u, MemoInfo *mi, char *param);
-static int do_set_limit(User *u, MemoInfo *mi, char *param);
-static int do_info(User *u);
-static int do_staff(User *u);
-static int do_sendall(User *u);
-void moduleAddMemoServCmds(void);
+E void memo_send(User *u, char *name, char *text, int z);
+E void moduleAddMemoServCmds(void);
static void new_memo_mail(NickCore *nc, Memo *m);
-static int do_rsend(User *u);
-static int do_memocheck(User *u);
-void rsend_notify(User *u, Memo *m, const char *chan);
+E void rsend_notify(User *u, Memo *m, const char *chan);
+E int delmemo(MemoInfo * mi, int num);
/*************************************************************************/
void moduleAddMemoServCmds(void) {
- Command *c;
- c = createCommand("HELP", do_help, NULL, -1, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("SEND", do_send, NULL, MEMO_HELP_SEND, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("CANCEL", do_cancel, NULL, MEMO_HELP_CANCEL, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("LIST", do_list, NULL, MEMO_HELP_LIST, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("READ", do_read, NULL, MEMO_HELP_READ, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("DEL", do_del, NULL, MEMO_HELP_DEL, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("STAFF", do_staff, is_services_oper, -1, -1,MEMO_HELP_STAFF,MEMO_HELP_STAFF,MEMO_HELP_STAFF); addCoreCommand(MEMOSERV,c);
- c = createCommand("SET", do_set, NULL, MEMO_HELP_SET, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("SET NOTIFY", NULL, NULL, MEMO_HELP_SET_NOTIFY, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("SET LIMIT", NULL, NULL, -1,MEMO_HELP_SET_LIMIT, MEMO_SERVADMIN_HELP_SET_LIMIT,MEMO_SERVADMIN_HELP_SET_LIMIT, MEMO_SERVADMIN_HELP_SET_LIMIT); addCoreCommand(MEMOSERV,c);
- c = createCommand("INFO", do_info, NULL, -1,MEMO_HELP_INFO, -1,MEMO_SERVADMIN_HELP_INFO, MEMO_SERVADMIN_HELP_INFO); addCoreCommand(MEMOSERV,c);
- c = createCommand("SENDALL", do_sendall, is_services_admin, -1, -1,-1,MEMO_HELP_SENDALL,MEMO_HELP_SENDALL); addCoreCommand(MEMOSERV,c);
- c = createCommand("RSEND", do_rsend, NULL, MEMO_HELP_RSEND, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
- c = createCommand("CHECK", do_memocheck, NULL, MEMO_HELP_CHECK, -1,-1,-1,-1); addCoreCommand(MEMOSERV,c);
+ modules_core_init(MemoServCoreNumber, MemoServCoreModules);
}
/*************************************************************************/
@@ -176,7 +148,7 @@ void check_memos(User * u)
* @return `ischan' 1 if the name was a channel name, else 0.
* @return `isforbid' 1 if the name is forbidden, else 0.
*/
-static MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid)
+MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid)
{
if (*name == '#') {
ChannelInfo *ci;
@@ -218,84 +190,6 @@ static MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid)
/*************************************************************************/
/**
- * Delete a memo by number.
- * @param mi Memoinfo struct
- * @param num Memo number to delete
- * @return int 1 if the memo was found, else 0.
- */
-static int delmemo(MemoInfo * mi, int num)
-{
- int i;
-
- for (i = 0; i < mi->memocount; i++) {
- if (mi->memos[i].number == num)
- break;
- }
- if (i < mi->memocount) {
- moduleCleanStruct(&mi->memos[i].moduleData);
- free(mi->memos[i].text); /* Deallocate memo text memory */
- mi->memocount--; /* One less memo now */
- if (i < mi->memocount) /* Move remaining memos down a slot */
- memmove(mi->memos + i, mi->memos + i + 1,
- sizeof(Memo) * (mi->memocount - i));
- if (mi->memocount == 0) { /* If no more memos, free array */
- free(mi->memos);
- mi->memos = NULL;
- }
- return 1;
- } else {
- return 0;
- }
-}
-
-/*************************************************************************/
-/*********************** MemoServ command routines ***********************/
-/*************************************************************************/
-
-/**
- * Return a help message.
- * @param u User Struct
- * @return MOD_CONT
- */
-static int do_help(User * u)
-{
- char *cmd = strtok(NULL, "");
-
- if (!cmd) {
- notice_help(s_MemoServ, u, MEMO_HELP);
- if (is_services_oper(u)) {
- notice_help(s_MemoServ, u, MEMO_HELP_OPER);
- }
- if (is_services_admin(u)) {
- notice_help(s_MemoServ, u, MEMO_HELP_ADMIN);
- }
- moduleDisplayHelp(3, u);
- notice_help(s_MemoServ, u, MEMO_HELP_FOOTER, s_ChanServ);
- } else {
- mod_help_cmd(s_MemoServ, u, MEMOSERV, cmd);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * Send a memo to a nick/channel.
- * @param u User Struct
- * @return MOD_CONT
- */
-static int do_send(User * u)
-{
- char *name = strtok(NULL, " ");
- char *text = strtok(NULL, "");
- int z = 0;
- memo_send(u, name, text, z);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
* Split from do_send, this way we can easily send a memo from any point
* @param u User Struct
* @param name Target of the memo
@@ -445,932 +339,35 @@ void memo_send(User * u, char *name, char *text, int z)
}
/*************************************************************************/
-
-/**
- * Cancel the memo
- * @param u User Struct
- * @return MOD_CONT
- */
-static int do_cancel(User * u)
-{
- int ischan;
- int isforbid;
- char *name = strtok(NULL, " ");
- MemoInfo *mi;
-
- if (!name) {
- syntax_error(s_MemoServ, u, "CANCEL", MEMO_CANCEL_SYNTAX);
-
- } else if (!nick_recognized(u)) {
- notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
-
- } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) {
- if (isforbid) {
- notice_lang(s_MemoServ, u,
- ischan ? CHAN_X_FORBIDDEN :
- NICK_X_FORBIDDEN, name);
- } else {
- notice_lang(s_MemoServ, u,
- ischan ? CHAN_X_NOT_REGISTERED :
- NICK_X_NOT_REGISTERED, name);
- }
- } else {
- int i;
-
- for (i = mi->memocount - 1; i >= 0; i--) {
- if ((mi->memos[i].flags & MF_UNREAD)
- && !stricmp(mi->memos[i].sender, u->na->nc->display)
- && (!(mi->memos[i].flags & MF_NOTIFYS))) {
- delmemo(mi, mi->memos[i].number);
- notice_lang(s_MemoServ, u, MEMO_CANCELLED, name);
- return MOD_CONT;
- }
- }
-
- notice_lang(s_MemoServ, u, MEMO_CANCEL_NONE);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * Display a single memo entry, possibly printing the header first.
- * @param u User Struct
- * @param int Memo index
- * @param mi MemoInfo Struct
- * @param send_header If we are to send the headers
- * @param new If we are listing new memos
- * @param chan Channel name
- * @return MOD_CONT
- */
-static int list_memo(User * u, int index, MemoInfo * mi, int *sent_header,
- int new, const char *chan)
-{
- Memo *m;
- char timebuf[64];
- struct tm tm;
-
- if (index < 0 || index >= mi->memocount)
- return 0;
- if (!*sent_header) {
- if (chan) {
- notice_lang(s_MemoServ, u,
- new ? MEMO_LIST_CHAN_NEW_MEMOS :
- MEMO_LIST_CHAN_MEMOS, chan, s_MemoServ, chan);
- } else {
- notice_lang(s_MemoServ, u,
- new ? MEMO_LIST_NEW_MEMOS : MEMO_LIST_MEMOS,
- u->nick, s_MemoServ);
- }
- notice_lang(s_MemoServ, u, MEMO_LIST_HEADER);
- *sent_header = 1;
- }
- m = &mi->memos[index];
- tm = *localtime(&m->time);
- strftime_lang(timebuf, sizeof(timebuf),
- u, STRFTIME_DATE_TIME_FORMAT, &tm);
- timebuf[sizeof(timebuf) - 1] = 0; /* just in case */
- notice_lang(s_MemoServ, u, MEMO_LIST_FORMAT,
- (m->flags & MF_UNREAD) ? '*' : ' ',
- m->number, m->sender, timebuf);
- return 1;
-}
-
-/*************************************************************************/
-
-/**
- * list memno callback function
- * @param u User Struct
- * @param int Memo number
- * @param va_list List of arguements
- * @return result form list_memo()
- */
-static int list_memo_callback(User * u, int num, va_list args)
-{
- MemoInfo *mi = va_arg(args, MemoInfo *);
- int *sent_header = va_arg(args, int *);
- const char *chan = va_arg(args, const char *);
- int i;
-
- for (i = 0; i < mi->memocount; i++) {
- if (mi->memos[i].number == num)
- break;
- }
- /* Range checking done by list_memo() */
- return list_memo(u, i, mi, sent_header, 0, chan);
-}
-
-
-/*************************************************************************/
-
/**
- * List the memos (if any) for the source nick or given channel.
- * @param u User Struct
- * @return MOD_CONT
- */
-static int do_list(User * u)
-{
- char *param = strtok(NULL, " "), *chan = NULL;
- ChannelInfo *ci;
- MemoInfo *mi;
- Memo *m;
- int i;
-
- if (param && *param == '#') {
- chan = param;
- param = strtok(NULL, " ");
- if (!(ci = cs_findchan(chan))) {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan);
- return MOD_CONT;
- } else if (!check_access(u, ci, CA_MEMO)) {
- notice_lang(s_MemoServ, u, ACCESS_DENIED);
- return MOD_CONT;
- }
- mi = &ci->memos;
- } else {
- if (!nick_identified(u)) {
- notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- return MOD_CONT;
- }
- mi = &u->na->nc->memos;
- }
- if (param && !isdigit(*param) && stricmp(param, "NEW") != 0) {
- syntax_error(s_MemoServ, u, "LIST", MEMO_LIST_SYNTAX);
- } else if (mi->memocount == 0) {
- if (chan)
- notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan);
- else
- notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS);
- } else {
- int sent_header = 0;
- if (param && isdigit(*param)) {
- process_numlist(param, NULL, list_memo_callback, u,
- mi, &sent_header, chan);
- } else {
- if (param) {
- for (i = 0, m = mi->memos; i < mi->memocount; i++, m++) {
- if (m->flags & MF_UNREAD)
- break;
- }
- if (i == mi->memocount) {
- if (chan)
- notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_NEW_MEMOS,
- chan);
- else
- notice_lang(s_MemoServ, u, MEMO_HAVE_NO_NEW_MEMOS);
- return MOD_CONT;
- }
- }
- for (i = 0, m = mi->memos; i < mi->memocount; i++, m++) {
- if (param && !(m->flags & MF_UNREAD))
- continue;
- list_memo(u, i, mi, &sent_header, param != NULL, chan);
- }
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * Read a memo
- * @param u User Struct
- * @param int Index number
- * @param mi MemoInfo struct
- * @param chan Channel Name
- * @return 1 on success, 0 if failed
- */
-static int read_memo(User * u, int index, MemoInfo * mi, const char *chan)
-{
- Memo *m;
- char timebuf[64];
- struct tm tm;
-
- if (index < 0 || index >= mi->memocount)
- return 0;
- m = &mi->memos[index];
- tm = *localtime(&m->time);
- strftime_lang(timebuf, sizeof(timebuf),
- u, STRFTIME_DATE_TIME_FORMAT, &tm);
- timebuf[sizeof(timebuf) - 1] = 0;
- if (chan)
- notice_lang(s_MemoServ, u, MEMO_CHAN_HEADER, m->number,
- m->sender, timebuf, s_MemoServ, chan, m->number);
- else
- notice_lang(s_MemoServ, u, MEMO_HEADER, m->number,
- m->sender, timebuf, s_MemoServ, m->number);
- notice_lang(s_MemoServ, u, MEMO_TEXT, m->text);
- m->flags &= ~MF_UNREAD;
-
- /* Check if a receipt notification was requested */
- if (m->flags & MF_RECEIPT) {
- rsend_notify(u, m, chan);
- }
-
- return 1;
-}
-
-/*************************************************************************/
-
-/**
- * Read a memo callback function
- * @param u User Struct
- * @param int Index number
- * @param va_list variable arguements
- * @return result of read_memo()
+ * Delete a memo by number.
+ * @param mi Memoinfo struct
+ * @param num Memo number to delete
+ * @return int 1 if the memo was found, else 0.
*/
-static int read_memo_callback(User * u, int num, va_list args)
+int delmemo(MemoInfo * mi, int num)
{
- MemoInfo *mi = va_arg(args, MemoInfo *);
- const char *chan = va_arg(args, const char *);
int i;
for (i = 0; i < mi->memocount; i++) {
if (mi->memos[i].number == num)
break;
}
- /* Range check done in read_memo */
- return read_memo(u, i, mi, chan);
-}
-
-
-/*************************************************************************/
-
-/**
- * Read memo command
- * @param u User Struct
- * @return MOD_CONT
- */
-static int do_read(User * u)
-{
- MemoInfo *mi;
- ChannelInfo *ci;
- char *numstr = strtok(NULL, " "), *chan = NULL;
- int num, count;
-
- if (numstr && *numstr == '#') {
- chan = numstr;
- numstr = strtok(NULL, " ");
- if (!(ci = cs_findchan(chan))) {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan);
- return MOD_CONT;
- } else if (!check_access(u, ci, CA_MEMO)) {
- notice_lang(s_MemoServ, u, ACCESS_DENIED);
- return MOD_CONT;
- }
- mi = &ci->memos;
- } else {
- if (!nick_identified(u)) {
- notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- return MOD_CONT;
- }
- mi = &u->na->nc->memos;
- }
- num = numstr ? atoi(numstr) : -1;
- if (!numstr
- || (stricmp(numstr, "LAST") != 0 && stricmp(numstr, "NEW") != 0
- && num <= 0)) {
- syntax_error(s_MemoServ, u, "READ", MEMO_READ_SYNTAX);
-
- } else if (mi->memocount == 0) {
- if (chan)
- notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan);
- else
- notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS);
-
- } else {
- int i;
-
- if (stricmp(numstr, "NEW") == 0) {
- int readcount = 0;
- for (i = 0; i < mi->memocount; i++) {
- if (mi->memos[i].flags & MF_UNREAD) {
- read_memo(u, i, mi, chan);
- readcount++;
- }
- }
- if (!readcount) {
- if (chan)
- notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_NEW_MEMOS,
- chan);
- else
- notice_lang(s_MemoServ, u, MEMO_HAVE_NO_NEW_MEMOS);
- }
- } else if (stricmp(numstr, "LAST") == 0) {
- for (i = 0; i < mi->memocount - 1; i++);
- read_memo(u, i, mi, chan);
- } else { /* number[s] */
- if (!process_numlist(numstr, &count, read_memo_callback, u,
- mi, chan)) {
- if (count == 1)
- notice_lang(s_MemoServ, u, MEMO_DOES_NOT_EXIST, num);
- else
- notice_lang(s_MemoServ, u, MEMO_LIST_NOT_FOUND,
- numstr);
- }
- }
-
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * Delete a single memo from a MemoInfo. callback function
- * @param u User Struct
- * @param int Number
- * @param va_list Variable Arguemtns
- * @return 1 if successful, 0 if it fails
- */
-static int del_memo_callback(User * u, int num, va_list args)
-{
- MemoInfo *mi = va_arg(args, MemoInfo *);
- int *last = va_arg(args, int *);
- int *last0 = va_arg(args, int *);
- char **end = va_arg(args, char **);
- int *left = va_arg(args, int *);
-
- if (delmemo(mi, num)) {
- if (num != (*last) + 1) {
- if (*last != -1) {
- int len;
- if (*last0 != *last)
- len = snprintf(*end, *left, ",%d-%d", *last0, *last);
- else
- len = snprintf(*end, *left, ",%d", *last);
- *end += len;
- *left -= len;
- }
- *last0 = num;
- }
- *last = num;
- return 1;
- } else {
- return 0;
- }
-}
-
-/*************************************************************************/
-
-/**
- * Delete memos command.
- * @param u User Struct
- * @return MOD_CONT
- */
-static int do_del(User * u)
-{
- MemoInfo *mi;
- ChannelInfo *ci;
- char *numstr = strtok(NULL, ""), *chan = NULL;
- int last, last0, i;
- char buf[BUFSIZE], *end;
- int delcount, count, left;
-
- if (numstr && *numstr == '#') {
- chan = strtok(numstr, " ");
- numstr = strtok(NULL, "");
- if (!(ci = cs_findchan(chan))) {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan);
- return MOD_CONT;
- } else if (!check_access(u, ci, CA_MEMO)) {
- notice_lang(s_MemoServ, u, ACCESS_DENIED);
- return MOD_CONT;
- }
- mi = &ci->memos;
- } else {
- if (!nick_identified(u)) {
- notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- return MOD_CONT;
- }
- mi = &u->na->nc->memos;
- }
- if (!numstr
- || (!isdigit(*numstr) && stricmp(numstr, "ALL") != 0
- && stricmp(numstr, "LAST") != 0)) {
- syntax_error(s_MemoServ, u, "DEL", MEMO_DEL_SYNTAX);
- } else if (mi->memocount == 0) {
- if (chan)
- notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan);
- else
- notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS);
- } else {
- if (isdigit(*numstr)) {
- /* Delete a specific memo or memos. */
- last = -1; /* Last memo deleted */
- last0 = -1; /* Beginning of range of last memos deleted */
- end = buf;
- left = sizeof(buf);
- delcount =
- process_numlist(numstr, &count, del_memo_callback, u, mi,
- &last, &last0, &end, &left);
- if (last != -1) {
- /* Some memos got deleted; tell them which ones. */
- if (delcount > 1) {
- if (last0 != last)
- end += snprintf(end, sizeof(buf) - (end - buf),
- ",%d-%d", last0, last);
- else
- end += snprintf(end, sizeof(buf) - (end - buf),
- ",%d", last);
- /* "buf+1" here because *buf == ',' */
- notice_lang(s_MemoServ, u, MEMO_DELETED_SEVERAL,
- buf + 1);
- } else {
- notice_lang(s_MemoServ, u, MEMO_DELETED_ONE, last);
- }
- } else {
- /* No memos were deleted. Tell them so. */
- if (count == 1)
- notice_lang(s_MemoServ, u, MEMO_DOES_NOT_EXIST,
- atoi(numstr));
- else
- notice_lang(s_MemoServ, u, MEMO_DELETED_NONE);
- }
- } else if (stricmp(numstr, "LAST") == 0) {
- /* Delete last memo. */
- for (i = 0; i < mi->memocount; i++)
- last = mi->memos[i].number;
- delmemo(mi, last);
- notice_lang(s_MemoServ, u, MEMO_DELETED_ONE, last);
- } else {
- /* Delete all memos. */
- for (i = 0; i < mi->memocount; i++) {
- free(mi->memos[i].text);
- moduleCleanStruct(&mi->memos[i].moduleData);
- }
+ if (i < mi->memocount) {
+ moduleCleanStruct(&mi->memos[i].moduleData);
+ free(mi->memos[i].text); /* Deallocate memo text memory */
+ mi->memocount--; /* One less memo now */
+ if (i < mi->memocount) /* Move remaining memos down a slot */
+ memmove(mi->memos + i, mi->memos + i + 1,
+ sizeof(Memo) * (mi->memocount - i));
+ if (mi->memocount == 0) { /* If no more memos, free array */
free(mi->memos);
mi->memos = NULL;
- mi->memocount = 0;
- if (chan)
- notice_lang(s_MemoServ, u, MEMO_CHAN_DELETED_ALL, chan);
- else
- notice_lang(s_MemoServ, u, MEMO_DELETED_ALL);
- }
-
- /* Reset the order */
- for (i = 0; i < mi->memocount; i++)
- mi->memos[i].number = i + 1;
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * MS SET command.
- * @param u User Struct
- * @return MOD_CONT
- */
-static int do_set(User * u)
-{
- char *cmd = strtok(NULL, " ");
- char *param = strtok(NULL, "");
- MemoInfo *mi = &u->na->nc->memos;
-
- if (readonly) {
- notice_lang(s_MemoServ, u, MEMO_SET_DISABLED);
- return MOD_CONT;
- }
- if (!param) {
- syntax_error(s_MemoServ, u, "SET", MEMO_SET_SYNTAX);
- } else if (!nick_identified(u)) {
- notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- return MOD_CONT;
- } else if (stricmp(cmd, "NOTIFY") == 0) {
- do_set_notify(u, mi, param);
- } else if (stricmp(cmd, "LIMIT") == 0) {
- do_set_limit(u, mi, param);
- } else {
- notice_lang(s_MemoServ, u, MEMO_SET_UNKNOWN_OPTION, cmd);
- notice_lang(s_MemoServ, u, MORE_INFO, s_MemoServ, "SET");
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * MS SET notify
- * @param u User Struct
- * @param mi MemoInfo Struct
- * @param param Parameter
- * @return MOD_CONT
- */
-static int do_set_notify(User * u, MemoInfo * mi, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- u->na->nc->flags |= NI_MEMO_SIGNON | NI_MEMO_RECEIVE;
- notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_ON, s_MemoServ);
- } else if (stricmp(param, "LOGON") == 0) {
- u->na->nc->flags |= NI_MEMO_SIGNON;
- u->na->nc->flags &= ~NI_MEMO_RECEIVE;
- notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_LOGON, s_MemoServ);
- } else if (stricmp(param, "NEW") == 0) {
- u->na->nc->flags &= ~NI_MEMO_SIGNON;
- u->na->nc->flags |= NI_MEMO_RECEIVE;
- notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NEW, s_MemoServ);
- } else if (stricmp(param, "MAIL") == 0) {
- if (u->na->nc->email) {
- u->na->nc->flags |= NI_MEMO_MAIL;
- notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_MAIL);
- } else {
- notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_INVALIDMAIL);
- }
- } else if (stricmp(param, "NOMAIL") == 0) {
- u->na->nc->flags &= ~NI_MEMO_MAIL;
- notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NOMAIL);
- } else if (stricmp(param, "OFF") == 0) {
- u->na->nc->flags &= ~(NI_MEMO_SIGNON | NI_MEMO_RECEIVE);
- notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_OFF, s_MemoServ);
- } else {
- syntax_error(s_MemoServ, u, "SET NOTIFY", MEMO_SET_NOTIFY_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * MS SET limit
- * @param u User Struct
- * @param mi MemoInfo Struct
- * @param param Parameter
- * @return MOD_CONT
- */
-static int do_set_limit(User * u, MemoInfo * mi, char *param)
-{
- char *p1 = strtok(param, " ");
- char *p2 = strtok(NULL, " ");
- char *p3 = strtok(NULL, " ");
- char *user = NULL, *chan = NULL;
- int32 limit;
- NickAlias *na = u->na;
- ChannelInfo *ci = NULL;
- int is_servadmin = is_services_admin(u);
-
- if (p1 && *p1 == '#') {
- chan = p1;
- p1 = p2;
- p2 = p3;
- p3 = strtok(NULL, " ");
- if (!(ci = cs_findchan(chan))) {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
- return MOD_CONT;
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan);
- return MOD_CONT;
- } else if (!is_servadmin && !check_access(u, ci, CA_MEMO)) {
- notice_lang(s_MemoServ, u, ACCESS_DENIED);
- return MOD_CONT;
- }
- mi = &ci->memos;
- }
- if (is_servadmin) {
- if (p2 && stricmp(p2, "HARD") != 0 && !chan) {
- if (!(na = findnick(p1))) {
- notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, p1);
- return MOD_CONT;
- }
- user = p1;
- mi = &na->nc->memos;
- p1 = p2;
- p2 = p3;
- } else if (!p1) {
- syntax_error(s_MemoServ, u, "SET LIMIT",
- MEMO_SET_LIMIT_SERVADMIN_SYNTAX);
- return MOD_CONT;
- }
- if ((!isdigit(*p1) && stricmp(p1, "NONE") != 0) ||
- (p2 && stricmp(p2, "HARD") != 0)) {
- syntax_error(s_MemoServ, u, "SET LIMIT",
- MEMO_SET_LIMIT_SERVADMIN_SYNTAX);
- return MOD_CONT;
}
- if (chan) {
- if (p2)
- ci->flags |= CI_MEMO_HARDMAX;
- else
- ci->flags &= ~CI_MEMO_HARDMAX;
- } else {
- if (p2)
- na->nc->flags |= NI_MEMO_HARDMAX;
- else
- na->nc->flags &= ~NI_MEMO_HARDMAX;
- }
- limit = atoi(p1);
- if (limit < 0 || limit > 32767) {
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767);
- limit = 32767;
- }
- if (stricmp(p1, "NONE") == 0)
- limit = -1;
- } else {
- if (!p1 || p2 || !isdigit(*p1)) {
- syntax_error(s_MemoServ, u, "SET LIMIT",
- MEMO_SET_LIMIT_SYNTAX);
- return MOD_CONT;
- }
- if (chan && (ci->flags & CI_MEMO_HARDMAX)) {
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_FORBIDDEN, chan);
- return MOD_CONT;
- } else if (!chan && (na->nc->flags & NI_MEMO_HARDMAX)) {
- notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_FORBIDDEN);
- return MOD_CONT;
- }
- limit = atoi(p1);
- /* The first character is a digit, but we could still go negative
- * from overflow... watch out! */
- if (limit < 0 || (MSMaxMemos > 0 && limit > MSMaxMemos)) {
- if (chan) {
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_TOO_HIGH,
- chan, MSMaxMemos);
- } else {
- notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_TOO_HIGH,
- MSMaxMemos);
- }
- return MOD_CONT;
- } else if (limit > 32767) {
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767);
- limit = 32767;
- }
- }
- mi->memomax = limit;
- if (limit > 0) {
- if (!chan && na->nc == u->na->nc)
- notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT, limit);
- else
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT,
- chan ? chan : user, limit);
- } else if (limit == 0) {
- if (!chan && na->nc == u->na->nc)
- notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_ZERO);
- else
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_ZERO,
- chan ? chan : user);
+ return 1;
} else {
- if (!chan && na->nc == u->na->nc)
- notice_lang(s_MemoServ, u, MEMO_UNSET_YOUR_LIMIT);
- else
- notice_lang(s_MemoServ, u, MEMO_UNSET_LIMIT,
- chan ? chan : user);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * MS INFO
- * @param u User Struct
- * @return MOD_CONT
- */
-static int do_info(User * u)
-{
- MemoInfo *mi;
- NickAlias *na = NULL;
- ChannelInfo *ci = NULL;
- char *name = strtok(NULL, " ");
- int is_servadmin = is_services_admin(u);
- int hardmax = 0;
-
- if (is_servadmin && name && *name != '#') {
- na = findnick(name);
- if (!na) {
- notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name);
- return MOD_CONT;
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, name);
- return MOD_CONT;
- }
- mi = &na->nc->memos;
- hardmax = na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0;
- } else if (name && *name == '#') {
- ci = cs_findchan(name);
- if (!ci) {
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, name);
- return MOD_CONT;
- } else if (ci->flags & CI_VERBOTEN) {
- notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, name);
- return MOD_CONT;
- } else if (!check_access(u, ci, CA_MEMO)) {
- notice_lang(s_MemoServ, u, ACCESS_DENIED);
- return MOD_CONT;
- }
- mi = &ci->memos;
- hardmax = ci->flags & CI_MEMO_HARDMAX ? 1 : 0;
- } else if (name) { /* It's not a chan and we aren't services admin */
- notice_lang(s_MemoServ, u, ACCESS_DENIED);
- return MOD_CONT;
- } else { /* !name */
- if (!nick_identified(u)) {
- notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- return MOD_CONT;
- }
- mi = &u->na->nc->memos;
- hardmax = u->na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0;
- }
-
- if (name && (ci || na->nc != u->na->nc)) {
-
- if (!mi->memocount) {
- notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_MEMOS, name);
- } else if (mi->memocount == 1) {
- if (mi->memos[0].flags & MF_UNREAD)
- notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO_UNREAD, name);
- else
- notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO, name);
- } else {
- int count = 0, i;
- for (i = 0; i < mi->memocount; i++) {
- if (mi->memos[i].flags & MF_UNREAD)
- count++;
- }
- if (count == mi->memocount)
- notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_ALL_UNREAD,
- name, count);
- else if (count == 0)
- notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS, name,
- mi->memocount);
- else if (count == 1)
- notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_ONE_UNREAD,
- name, mi->memocount);
- else
- notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_SOME_UNREAD,
- name, mi->memocount, count);
- }
- if (mi->memomax == 0) {
- if (hardmax)
- notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name,
- mi->memomax);
- else
- notice_lang(s_MemoServ, u, MEMO_INFO_X_LIMIT, name,
- mi->memomax);
- } else if (mi->memomax > 0) {
- if (hardmax)
- notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name,
- mi->memomax);
- else
- notice_lang(s_MemoServ, u, MEMO_INFO_X_LIMIT, name,
- mi->memomax);
- } else {
- notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_LIMIT, name);
- }
-
- /* I ripped this code out of ircservices 4.4.5, since I didn't want
- to rewrite the whole thing (it pisses me off). */
- if (na) {
- if ((na->nc->flags & NI_MEMO_RECEIVE)
- && (na->nc->flags & NI_MEMO_SIGNON)) {
- notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_ON, name);
- } else if (na->nc->flags & NI_MEMO_RECEIVE) {
- notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_RECEIVE,
- name);
- } else if (na->nc->flags & NI_MEMO_SIGNON) {
- notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_SIGNON,
- name);
- } else {
- notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_OFF, name);
- }
- }
-
- } else { /* !name || (!ci || na->nc == u->na->nc) */
-
- if (!mi->memocount) {
- notice_lang(s_MemoServ, u, MEMO_INFO_NO_MEMOS);
- } else if (mi->memocount == 1) {
- if (mi->memos[0].flags & MF_UNREAD)
- notice_lang(s_MemoServ, u, MEMO_INFO_MEMO_UNREAD);
- else
- notice_lang(s_MemoServ, u, MEMO_INFO_MEMO);
- } else {
- int count = 0, i;
- for (i = 0; i < mi->memocount; i++) {
- if (mi->memos[i].flags & MF_UNREAD)
- count++;
- }
- if (count == mi->memocount)
- notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_ALL_UNREAD,
- count);
- else if (count == 0)
- notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS, mi->memocount);
- else if (count == 1)
- notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_ONE_UNREAD,
- mi->memocount);
- else
- notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_SOME_UNREAD,
- mi->memocount, count);
- }
-
- if (mi->memomax == 0) {
- if (!is_servadmin && hardmax)
- notice_lang(s_MemoServ, u, MEMO_INFO_HARD_LIMIT_ZERO);
- else
- notice_lang(s_MemoServ, u, MEMO_INFO_LIMIT_ZERO);
- } else if (mi->memomax > 0) {
- if (!is_servadmin && hardmax)
- notice_lang(s_MemoServ, u, MEMO_INFO_HARD_LIMIT,
- mi->memomax);
- else
- notice_lang(s_MemoServ, u, MEMO_INFO_LIMIT, mi->memomax);
- } else {
- notice_lang(s_MemoServ, u, MEMO_INFO_NO_LIMIT);
- }
-
- /* Ripped too. But differently because of a seg fault (loughs) */
- if ((u->na->nc->flags & NI_MEMO_RECEIVE)
- && (u->na->nc->flags & NI_MEMO_SIGNON)) {
- notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_ON);
- } else if (u->na->nc->flags & NI_MEMO_RECEIVE) {
- notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_RECEIVE);
- } else if (u->na->nc->flags & NI_MEMO_SIGNON) {
- notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_SIGNON);
- } else {
- notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_OFF);
- }
- }
- return MOD_CONT; /* if (name && (ci || na->nc != u->na->nc)) */
-}
-
-/*************************************************************************/
-/**
- * Allow the easy sending of memo's to all user's on the oper/admin/root lists
- * - Rob
- * Opers in several lists won't get the memo twice from now on
- * - Certus
- **/
-
-static int do_staff(User * u)
-{
- NickCore *nc;
- int i, z = 0;
- char *text = strtok(NULL, "");
-
- if (readonly) {
- notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED);
- return MOD_CONT;
- } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) {
- notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED);
- return MOD_CONT;
- } else if (text == NULL) {
- syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX);
- return MOD_CONT;
- }
-
- for (i = 0; i < 1024; i++) {
- for (nc = nclists[i]; nc; nc = nc->next) {
- if (nick_is_services_oper(nc))
- memo_send(u, nc->display, text, z);
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-/**
- * Send a memo to all registered nicks
- * - Certus - 06/06/2003
- **/
-static int do_sendall(User * u)
-{
- int i, z = 1;
- NickCore *nc;
- char *text = strtok(NULL, "");
-
-
-
- if (readonly) {
- notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED);
- return MOD_CONT;
- } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) {
- notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED);
- return MOD_CONT;
- } else if (!text) {
- syntax_error(s_MemoServ, u, "SENDALL", MEMO_SEND_SYNTAX);
- return MOD_CONT;
+ return 0;
}
-
-
- for (i = 0; i < 1024; i++) {
- for (nc = nclists[i]; nc; nc = nc->next) {
- if (stricmp(u->nick, nc->display) != 0)
- memo_send(u, nc->display, text, z);
- } /* /nc */
- } /* /i */
-
- notice_lang(s_MemoServ, u, MEMO_MASS_SENT);
- return MOD_CONT;
}
/*************************************************************************/
@@ -1399,62 +396,6 @@ static void new_memo_mail(NickCore * nc, Memo * m)
return;
}
-/*************************************************************************/
-/* Send a memo to a nick/channel requesting a receipt. */
-
-static int do_rsend(User * u)
-{
- char *name = strtok(NULL, " ");
- char *text = strtok(NULL, "");
- NickAlias *na = NULL;
- int z = 3;
-
- /* check if RSEND is usable first */
- if (!MSMemoReceipt) {
- notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED);
- return MOD_CONT;
- }
-
- /* check if the variables are here */
- if (!name || !text) {
- notice_lang(s_MemoServ, u, MEMO_RSEND_SYNTAX);
- return MOD_CONT;
- }
-
- /* prevent user from rsend to themselves */
- if ((na = findnick(name))) {
- if (u->na) {
- if (stricmp(na->nc->display, u->na->nc->display) == 0) {
- notice_lang(s_MemoServ, u, MEMO_NO_RSEND_SELF);
- return MOD_CONT;
- }
- } else {
- notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name);
- return MOD_CONT;
- }
- }
-
- if (MSMemoReceipt == 1) {
- /* Services opers and above can use rsend */
- if (is_services_oper(u)) {
- memo_send(u, name, text, z);
- } else {
- notice_lang(s_MemoServ, u, ACCESS_DENIED);
- }
- } else if (MSMemoReceipt == 2) {
- /* Everybody can use rsend */
- memo_send(u, name, text, z);
- } else {
- /* rsend has been disabled */
- if (debug) {
- alog("debug: MSMemoReceipt is set misconfigured to %d",
- MSMemoReceipt);
- }
- notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED);
- }
-
- return MOD_CONT;
-}
/*************************************************************************/
/* Send receipt notification to sender. */
@@ -1507,66 +448,3 @@ void rsend_notify(User * u, Memo * m, const char *chan)
return;
}
-
-
-
-/*************************************************************************/
-/* This function checks whether the last memo you sent to person X has been read
- or not. Note that this function does only work with nicks, NOT with chans. */
-
-static int do_memocheck(User * u)
-{
- NickAlias *na = NULL;
- MemoInfo *mi = NULL;
- int i, found = 0;
- char *recipient = strtok(NULL, "");
- struct tm *tm;
- char timebuf[64];
-
- if (!recipient) {
- syntax_error(s_MemoServ, u, "CHECK", MEMO_CHECK_SYNTAX);
- return MOD_CONT;
- } else if (!nick_recognized(u)) {
- notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- return MOD_CONT;
- } else if (!(na = findnick(recipient))) {
- notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, recipient);
- return MOD_CONT;
- }
-
- if ((na->status & NS_VERBOTEN)) {
- notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, recipient);
- return MOD_CONT;
- }
-
- mi = &na->nc->memos;
-
-/* Okay, I know this looks strange but we wanna get the LAST memo, so we
- have to loop backwards */
-
- for (i = (mi->memocount - 1); i >= 0; i--) {
- if (!stricmp(mi->memos[i].sender, u->na->nc->display)) {
- found = 1; /* Yes, we've found the memo */
-
- tm = localtime(&mi->memos[i].time);
- strftime_lang(timebuf, sizeof(timebuf), u,
- STRFTIME_DATE_TIME_FORMAT, tm);
-
- if (mi->memos[i].flags & MF_UNREAD)
- notice_lang(s_MemoServ, u, MEMO_CHECK_NOT_READ, na->nick,
- timebuf);
- else
- notice_lang(s_MemoServ, u, MEMO_CHECK_READ, na->nick,
- timebuf);
- break;
- }
- }
-
- if (!found)
- notice_lang(s_MemoServ, u, MEMO_CHECK_NO_MEMO, na->nick);
-
- return MOD_CONT;
-}
-
-
-/*************************************************************************/
diff --git a/src/messages.c b/src/messages.c
index 695acbd8b..119200d98 100644
--- a/src/messages.c
+++ b/src/messages.c
@@ -163,16 +163,15 @@ int m_privmsg(char *source, char *receiver, char *msg)
if ((stricmp(receiver, s_OperServ) == 0)
|| (s_OperServAlias
&& (stricmp(receiver, s_OperServAlias) == 0))) {
- if (is_oper(u)) {
- operserv(u, msg);
- } else {
+ if (!is_oper(u) && OSOpersOnly) {
notice_lang(s_OperServ, u, ACCESS_DENIED);
-
if (WallBadOS)
anope_cmd_global(s_OperServ,
"Denied access to %s from %s!%s@%s (non-oper)",
s_OperServ, u->nick, u->username,
u->host);
+ } else {
+ operserv(u, msg);
}
} else if ((stricmp(receiver, s_NickServ) == 0)
|| (s_NickServAlias
diff --git a/src/misc.c b/src/misc.c
index d12351ba0..469e449f1 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -607,7 +607,7 @@ int isValidHost(const char *host, int type)
/**
* Valid character check
- * @param c Charaacter to check
+ * @param c Character to check
* @return 1 if a host is valid, 0 if it isnt.
*/
int isvalidchar(const char c)
diff --git a/src/modules.c b/src/modules.c
index 3d6150a4e..a508cda7e 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -86,6 +86,52 @@ void modules_init(void)
#endif
}
+/**
+ * Load up a list of core modules from the conf.
+ * @param number The number of modules to load
+ * @param list The list of modules to load
+ **/
+void modules_core_init(int number, char **list)
+{
+ int idx;
+ Module *m;
+ int status = 0;
+ for (idx = 0; idx < number; idx++) {
+ m = findModule(list[idx]);
+ if (!m) {
+ m = createModule(list[idx]);
+ mod_current_module = m;
+ mod_current_user = NULL;
+ status = loadModule(mod_current_module, NULL);
+ if (debug || status) {
+ alog("trying to load core module [%s]",
+ mod_current_module->name);
+ alog("status: [%d]", status);
+ }
+ mod_current_module = NULL;
+ mod_current_user = NULL;
+ }
+ }
+}
+
+/**
+ * Load the ircd protocol module up
+ **/
+int protocol_module_init(void)
+{
+ int ret = 0;
+ Module *m;
+ m = createModule(IRCDModule);
+ mod_current_module = m;
+ mod_current_user = NULL;
+ alog("Loading IRCD Protocol Module: [%s]", mod_current_module->name);
+ ret = loadModule(mod_current_module, NULL);
+ moduleSetType(PROTOCOL);
+ alog("status: [%d]", ret);
+ mod_current_module = NULL;
+ return ret;
+}
+
/**
* Automaticaly load modules at startup, delayed.
* This function waits until the IRCD link has been made, and then attempts
@@ -119,12 +165,14 @@ void modules_delayed_init(void)
Module *createModule(char *filename)
{
Module *m;
+ int i = 0;
if (!filename) {
return NULL;
}
if ((m = malloc(sizeof(Module))) == NULL) {
fatal("Out of memory!");
}
+
m->name = sstrdup(filename); /* Our Name */
m->handle = NULL; /* Handle */
m->version = NULL;
@@ -137,6 +185,10 @@ Module *createModule(char *filename)
m->hostHelp = NULL;
m->helpHelp = NULL;
+ m->type = THIRD;
+ for (i = 0; i < NUM_LANGS; i++) {
+ m->lang[i].argc = 0;
+ }
return m; /* return a nice new module */
}
@@ -148,9 +200,16 @@ Module *createModule(char *filename)
*/
int destroyModule(Module * m)
{
+ int i = 0;
if (!m) {
return MOD_ERR_PARAMS;
}
+
+ mod_current_module = m;
+ for (i = 0; i < NUM_LANGS; i++) {
+ moduleDeleteLanguage(i);
+ }
+
if (m->name) {
free(m->name);
}
@@ -165,6 +224,7 @@ int destroyModule(Module * m)
if (m->version) {
free(m->version);
}
+
/* No need to free our cmd/msg list, as they will always be empty by the module is destroyed */
free(m);
return MOD_ERR_OK;
@@ -262,6 +322,25 @@ Module *findModule(char *name)
}
+/**
+ * Search all loaded modules looking for a protocol module.
+ * @return 1 if one is found.
+ **/
+int protocolModuleLoaded()
+{
+ int idx = 0;
+ ModuleHash *current = NULL;
+
+ for (idx = 0; idx != MAX_CMD_HASH; idx++) {
+ for (current = MODULE_HASH[idx]; current; current = current->next) {
+ if (current->m->type == PROTOCOL) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
/**
* Copy the module from the modules folder to the runtime folder.
* This will prevent module updates while the modules is loaded from
@@ -375,7 +454,11 @@ int loadModule(Module * m, User * u)
ano_modclearerr();
func = ano_modsym(m->handle, "AnopeInit");
if ((err = ano_moderr()) != NULL) {
- ano_modclose(m->handle); /* If no AnopeInit - it isnt an Anope Module, close it */
+ ano_modclose(m->handle); /* If no AnopeInit - it isnt an Anope Module, close it */
+ if (u) {
+ notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
+ }
+
return MOD_ERR_NOLOAD;
}
if (func) {
@@ -392,7 +475,14 @@ int loadModule(Module * m, User * u)
if (u) {
free(argv[0]);
}
+ if (m->type == PROTOCOL && protocolModuleLoaded()) {
+ alog("You cannot load have 2 protocol modules.");
+ ret = MOD_STOP;
+ }
if (ret == MOD_STOP) {
+ if (u) {
+ notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
+ }
alog("%s requested unload...", m->name);
unloadModule(m, NULL);
mod_current_module_name = NULL;
@@ -411,6 +501,10 @@ int loadModule(Module * m, User * u)
return MOD_ERR_OK;
#else
+ if (u) {
+ notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
+ }
+
return MOD_ERR_NOLOAD;
#endif
}
@@ -433,6 +527,13 @@ int unloadModule(Module * m, User * u)
return MOD_ERR_PARAMS;
}
+ if (m->type == PROTOCOL) {
+ if (u) {
+ notice_lang(s_OperServ, u, OPER_MODULE_NO_UNLOAD);
+ }
+ return MOD_ERR_NOUNLOAD;
+ }
+
if (prepForUnload(mod_current_module) != MOD_ERR_OK) {
return MOD_ERR_UNKNOWN;
}
@@ -463,6 +564,18 @@ int unloadModule(Module * m, User * u)
}
/**
+ * Module setType()
+ * Lets the module set a type, CORE,PROTOCOL,3RD etc..
+ **/
+void moduleSetType(MODType type)
+{
+ if ((mod_current_module_name) && (!mod_current_module)) {
+ mod_current_module = findModule(mod_current_module_name);
+ }
+ mod_current_module->type = type;
+}
+
+/**
* Prepare a module to be unloaded.
* Remove all commands and messages this module is providing, and delete
* any callbacks which are still pending.
@@ -474,8 +587,14 @@ int prepForUnload(Module * m)
int idx;
CommandHash *current = NULL;
MessageHash *mcurrent = NULL;
+ EvtMessageHash *ecurrent = NULL;
+ EvtHookHash *ehcurrent = NULL;
+
Command *c;
Message *msg;
+ EvtMessage *eMsg;
+ EvtHook *eHook;
+ int status = 0;
if (!m) {
return MOD_ERR_PARAMS;
@@ -555,6 +674,25 @@ int prepForUnload(Module * m)
}
}
}
+
+ for (ecurrent = EVENT[idx]; ecurrent; ecurrent = ecurrent->next) {
+ for (eMsg = ecurrent->evm; eMsg; eMsg = eMsg->next) {
+ if ((eMsg->mod_name)
+ && (stricmp(eMsg->mod_name, m->name) == 0)) {
+ status = delEventHandler(EVENT, eMsg, m->name);
+ }
+ }
+ }
+ for (ehcurrent = EVENTHOOKS[idx]; ehcurrent;
+ ehcurrent = ehcurrent->next) {
+ for (eHook = ehcurrent->evh; eHook; eHook = eHook->next) {
+ if ((eHook->mod_name)
+ && (stricmp(eHook->mod_name, m->name) == 0)) {
+ status = delEventHook(EVENTHOOKS, eHook, m->name);
+ }
+ }
+ }
+
}
return MOD_ERR_OK;
}
@@ -906,7 +1044,7 @@ int addCommand(CommandHash * cmdTable[], Command * c, int pos)
if (!cmdTable || !c || (pos < 0 || pos > 2)) {
return MOD_ERR_PARAMS;
}
-
+
if (mod_current_module_name && !c->mod_name)
return MOD_ERR_NO_MOD_NAME;
@@ -1131,6 +1269,7 @@ int addMessage(MessageHash * msgTable[], Message * m, int pos)
MessageHash *newHash = NULL;
MessageHash *lastHash = NULL;
Message *tail = NULL;
+ int match = 0;
if (!msgTable || !m || (pos < 0 || pos > 2)) {
return MOD_ERR_PARAMS;
@@ -1139,7 +1278,12 @@ int addMessage(MessageHash * msgTable[], Message * m, int pos)
index = CMD_HASH(m->name);
for (current = msgTable[index]; current; current = current->next) {
- if (stricmp(m->name, current->name) == 0) { /* the msg exist's we are a addHead */
+ if ((UseTokens) && (!ircd->tokencaseless)) {
+ match = strcmp(m->name, current->name);
+ } else {
+ match = stricmp(m->name, current->name);
+ }
+ if (match == 0) { /* the msg exist's we are a addHead */
if (pos == 1) {
m->next = current->m;
current->m = m;
@@ -1754,54 +1898,34 @@ void moduleDisplayHelp(int service, User * u)
int idx;
int header_shown = 0;
ModuleHash *current = NULL;
+ Module *calling_module = mod_current_module;
+ char *calling_module_name = mod_current_module_name;
for (idx = 0; idx != MAX_CMD_HASH; idx++) {
for (current = MODULE_HASH[idx]; current; current = current->next) {
+ mod_current_module_name = current->name;
+ mod_current_module = current->m;
+
if ((service == 1) && current->m->nickHelp) {
- if (header_shown == 0) {
- notice_lang(s_NickServ, u, MODULE_HELP_HEADER);
- header_shown = 1;
- }
current->m->nickHelp(u);
} else if ((service == 2) && current->m->chanHelp) {
- if (header_shown == 0) {
- notice_lang(s_ChanServ, u, MODULE_HELP_HEADER);
- header_shown = 1;
- }
current->m->chanHelp(u);
} else if ((service == 3) && current->m->memoHelp) {
- if (header_shown == 0) {
- notice_lang(s_MemoServ, u, MODULE_HELP_HEADER);
- header_shown = 1;
- }
current->m->memoHelp(u);
} else if ((service == 4) && current->m->botHelp) {
- if (header_shown == 0) {
- notice_lang(s_BotServ, u, MODULE_HELP_HEADER);
- header_shown = 1;
- }
current->m->botHelp(u);
} else if ((service == 5) && current->m->operHelp) {
- if (header_shown == 0) {
- notice_lang(s_OperServ, u, MODULE_HELP_HEADER);
- header_shown = 1;
- }
current->m->operHelp(u);
} else if ((service == 6) && current->m->hostHelp) {
- if (header_shown == 0) {
- notice_lang(s_HostServ, u, MODULE_HELP_HEADER);
- header_shown = 1;
- }
current->m->hostHelp(u);
} else if ((service == 7) && current->m->helpHelp) {
- if (header_shown == 0) {
- notice_lang(s_HelpServ, u, MODULE_HELP_HEADER);
- header_shown = 1;
- }
current->m->helpHelp(u);
}
}
}
+
+ mod_current_module = calling_module;
+ mod_current_module_name = calling_module_name;
#endif
}
@@ -1847,7 +1971,7 @@ int moduleAddData(ModuleData ** md, char *key, char *value)
free(mod_name);
return MOD_ERR_PARAMS;
}
-
+
if (mod_current_module_name == NULL) {
alog("moduleAddData() called with mod_current_module_name being NULL");
if (debug)
@@ -1901,8 +2025,9 @@ char *moduleGetData(ModuleData ** md, char *key)
}
while (current) {
- if ((stricmp(current->moduleName, mod_name) == 0) && (stricmp(current->key, key) == 0)) {
- free(mod_name);
+ if ((stricmp(current->moduleName, mod_name) == 0)
+ && (stricmp(current->key, key) == 0)) {
+ free(mod_name);
return sstrdup(current->value);
}
current = current->next;
@@ -1934,7 +2059,8 @@ void moduleDelData(ModuleData ** md, char *key)
if (key) {
while (current) {
next = current->next;
- if ((stricmp(current->moduleName, mod_name) == 0) && (stricmp(current->key, key) == 0)) {
+ if ((stricmp(current->moduleName, mod_name) == 0)
+ && (stricmp(current->key, key) == 0)) {
if (prev) {
prev->next = current->next;
} else {
@@ -2127,35 +2253,216 @@ const char *ano_moderr(void)
/**
* Allow ircd protocol files to update the protect level info tables.
**/
-void updateProtectDetails(char *level_info_protect_word, char *level_info_protectme_word, char *fant_protect_add, char *fant_protect_del, char *level_protect_word, char *protect_set_mode, char *protect_unset_mode) {
- int i = 0;
- CSModeUtil ptr;
- LevelInfo l_ptr;
-
- ptr = csmodeutils[i];
- while(ptr.name) {
- if(strcmp(ptr.name,"PROTECT")==0) {
- csmodeutils[i].bsname = sstrdup(fant_protect_add);
- csmodeutils[i].mode = sstrdup(protect_set_mode);
- } else if(strcmp(ptr.name,"DEPROTECT")==0) {
- csmodeutils[i].bsname = sstrdup(fant_protect_del);
- csmodeutils[i].mode = sstrdup(protect_unset_mode);
- }
- ptr = csmodeutils[++i];
- }
-
- i = 0;
- l_ptr = levelinfo[i];
- while(l_ptr.what != -1) {
- if(l_ptr.what == CA_PROTECT) {
- levelinfo[i].name = sstrdup(level_info_protect_word);
- } else if(l_ptr.what == CA_PROTECTME) {
- levelinfo[i].name = sstrdup(level_info_protectme_word);
- } else if(l_ptr.what == CA_AUTOPROTECT) {
- levelinfo[i].name = sstrdup(level_protect_word);
+void updateProtectDetails(char *level_info_protect_word,
+ char *level_info_protectme_word,
+ char *fant_protect_add, char *fant_protect_del,
+ char *level_protect_word, char *protect_set_mode,
+ char *protect_unset_mode)
+{
+ int i = 0;
+ CSModeUtil ptr;
+ LevelInfo l_ptr;
+
+ ptr = csmodeutils[i];
+ while (ptr.name) {
+ if (strcmp(ptr.name, "PROTECT") == 0) {
+ csmodeutils[i].bsname = sstrdup(fant_protect_add);
+ csmodeutils[i].mode = sstrdup(protect_set_mode);
+ } else if (strcmp(ptr.name, "DEPROTECT") == 0) {
+ csmodeutils[i].bsname = sstrdup(fant_protect_del);
+ csmodeutils[i].mode = sstrdup(protect_unset_mode);
+ }
+ ptr = csmodeutils[++i];
+ }
+
+ i = 0;
+ l_ptr = levelinfo[i];
+ while (l_ptr.what != -1) {
+ if (l_ptr.what == CA_PROTECT) {
+ levelinfo[i].name = sstrdup(level_info_protect_word);
+ } else if (l_ptr.what == CA_PROTECTME) {
+ levelinfo[i].name = sstrdup(level_info_protectme_word);
+ } else if (l_ptr.what == CA_AUTOPROTECT) {
+ levelinfo[i].name = sstrdup(level_protect_word);
+ }
+ l_ptr = levelinfo[++i];
+ }
+}
+
+/**
+ * Deal with modules who want to lookup config directives!
+ * @param h The Directive to lookup in the config file
+ * @return 1 on success, 0 on error
+ **/
+int moduleGetConfigDirective(Directive * d)
+{
+ FILE *config;
+ char *dir;
+ char buf[1024];
+ int linenum = 0;
+ int i;
+ int optind = 0;
+ int ac = 0;
+ char *av[MAXPARAMS];
+ char *s, *t;
+ int retval;
+
+ config = fopen(SERVICES_CONF, "r");
+ if (!config) {
+ alog("Can't open %s", SERVICES_CONF);
+ return 0;
+ }
+ while (fgets(buf, sizeof(buf), config)) {
+ linenum++;
+ if (*buf == '#' || *buf == '\r' || *buf == '\n')
+ continue;
+
+ dir = myStrGetOnlyToken(buf, '\t', 0);
+ if (dir) {
+ s = myStrGetTokenRemainder(buf, '\t', 1);
+ } else {
+ dir = myStrGetOnlyToken(buf, ' ', 0);
+ if (dir) {
+ s = myStrGetTokenRemainder(buf, ' ', 1);
+ } else {
+ continue;
+ }
+ }
+
+ if (stricmp(dir, d->name) == 0) {
+ if (s) {
+ while (isspace(*s))
+ s++;
+ while (*s) {
+ if (ac >= MAXPARAMS) {
+ alog("module error: too many config. params");
+ break;
+ }
+ t = s;
+ if (*s == '"') {
+ t++;
+ s++;
+ while (*s && *s != '"') {
+ if (*s == '\\' && s[1] != 0)
+ s++;
+ s++;
+ }
+ if (!*s)
+ alog("module error: Warning: unterminated double-quoted string");
+ else
+ *s++ = 0;
+ } else {
+ s += strcspn(s, " \t\r\n");
+ if (*s)
+ *s++ = 0;
+ }
+ av[ac++] = t;
+ while (isspace(*s))
+ s++;
}
- l_ptr = levelinfo[++i];
+ }
+ retval = parse_directive(d, dir, ac, av, linenum, 0, s);
+ }
+ }
+ fclose(config);
+ return retval;
+}
+
+/**
+ * Allow a module to add a set of language strings to anope
+ * @param langNumber the language number for the strings
+ * @param ac The language count for the strings
+ * @param av The language sring list.
+ **/
+void moduleInsertLanguage(int langNumber, int ac, char **av)
+{
+ int i;
+
+ if ((mod_current_module_name) && (!mod_current_module)) {
+ mod_current_module = findModule(mod_current_module_name);
+ }
+
+ if (debug)
+ alog("debug: %s Adding %d texts for language %d", mod_current_module->name, ac, langNumber);
+
+ if (mod_current_module->lang[langNumber].argc > 0) {
+ moduleDeleteLanguage(langNumber);
+ }
+
+ mod_current_module->lang[langNumber].argc = ac;
+ mod_current_module->lang[langNumber].argv =
+ malloc(sizeof(char *) * ac);
+ for (i = 0; i < ac; i++) {
+ mod_current_module->lang[langNumber].argv[i] = sstrdup(av[i]);
+ }
+}
+
+/**
+ * Send a notice to the user in the correct language, or english.
+ * @param source Who sends the notice
+ * @param u The user to send the message to
+ * @param number The message number
+ * @param ... The argument list
+ **/
+void moduleNoticeLang(char *source, User * u, int number, ...)
+{
+ va_list va;
+ char buffer[4096], outbuf[4096];
+ char *fmt = NULL;
+ int lang = LANG_EN_US;
+ char *s, *t, *buf;
+
+ if ((mod_current_module_name) && (!mod_current_module)) {
+ mod_current_module = findModule(mod_current_module_name);
+ }
+ /* Find the users lang, and use it if we cant */
+ if (u->na && u->na->nc) {
+ lang = u->na->nc->language;
+ }
+
+ /* If the users lang isnt supported, drop back to enlgish */
+ if (mod_current_module->lang[lang].argc == 0) {
+ lang = LANG_EN_US;
+ }
+
+ /* If the requested lang string exists for the language */
+ if (mod_current_module->lang[lang].argc > number) {
+ fmt = mod_current_module->lang[lang].argv[number];
+
+ buf = sstrdup(fmt);
+ s = buf;
+ while (*s) {
+ t = s;
+ s += strcspn(s, "\n");
+ if (*s)
+ *s++ = '\0';
+ strscpy(outbuf, t, sizeof(outbuf));
+
+ va_start(va, number);
+ vsnprintf(buffer, 4095, outbuf, va);
+ va_end(va);
+ notice(source, u->nick, buffer);
}
+ free(buf);
+ } else {
+ alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name, lang, number);
+ }
+}
+
+/**
+ * Delete a language from a module
+ * @param langNumber the language Number to delete
+ **/
+void moduleDeleteLanguage(int langNumber)
+{
+ int idx = 0;
+ if ((mod_current_module_name) && (!mod_current_module)) {
+ mod_current_module = findModule(mod_current_module_name);
+ }
+ for (idx = 0; idx > mod_current_module->lang[langNumber].argc; idx++) {
+ free(mod_current_module->lang[langNumber].argv[idx]);
+ }
+ mod_current_module->lang[langNumber].argc = 0;
}
/* EOF */
diff --git a/src/modules/configure b/src/modules/configure
index 119c7c887..4ce3dbd32 100755
--- a/src/modules/configure
+++ b/src/modules/configure
@@ -2,16 +2,23 @@
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
+
+LS=`ls *.c 2>/dev/null | wc -l `
+if [ "0" == "$LS" ] ; then
+ echo "*** no modules found"
+else
+ 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
+fi
+
echo "" >> ./Makefile.inc
echo -n "SUBS=" >> ./Makefile.inc
@@ -27,6 +34,9 @@ do
echo -n " " $dir >> ./Makefile.inc
fi
FIRST=0
+ if [ -f $dir/configure ] ; then
+ $dir/configure
+ fi
fi
fi
done
diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c
new file mode 100644
index 000000000..774ba35f1
--- /dev/null
+++ b/src/modules/cs_appendtopic.c
@@ -0,0 +1,188 @@
+#include "module.h"
+
+/* Original module: cs_appendtopic by SGR
+ *
+ * Included in the Anope module pack since 1.7.9
+ * Anope Coder: GeniusDex <geniusdex@anope.org>
+ *
+ * Send bug reports to the Anope Coder instead of the module
+ * author, because any changes since the inclusion into anope
+ * are not supported by the original author.
+ */
+
+#define AUTHOR "SGR"
+#define VERSION "$Id$"
+
+ /* ------------------------------------------------------------
+ * Name: cs_appendtopic
+ * Author: SGR <Alex_SGR@ntlworld.com>
+ * Date: 31/08/2003
+ * ------------------------------------------------------------
+ *
+ * This module has no configurable options. For information on
+ * this module, load it and refer to /ChanServ APPENDTOPIC HELP
+ *
+ * Thanks to dengel, Rob and Certus for all there support.
+ * Especially Rob, who always manages to show me where I have
+ * not allocated any memory. Even if it takes a few weeks of
+ * pestering to get him to look at it.
+ *
+ * ------------------------------------------------------------
+ */
+
+/* ---------------------------------------------------------------------- */
+/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */
+/* ---------------------------------------------------------------------- */
+
+#define LNG_NUM_STRINGS 3
+
+#define LNG_CHAN_HELP 0
+#define LNG_CHAN_HELP_APPENDTOPIC 1
+#define LNG_APPENDTOPIC_SYNTAX 2
+
+int my_cs_appendtopic(User * u);
+void my_cs_help(User * u);
+int my_cs_help_appendtopic(User * u);
+void my_add_languages(void);
+
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+ int status;
+
+ moduleAddAuthor(AUTHOR);
+ moduleAddVersion(VERSION);
+ moduleSetType(SUPPORTED);
+
+ c = createCommand("APPENDTOPIC", my_cs_appendtopic, NULL, -1, -1, -1,
+ -1, -1);
+ if ((status = moduleAddCommand(CHANSERV, c, MOD_HEAD))) {
+ alog("[cs_appendtopic] Unable to create APPENDTOPIC command: %d",
+ status);
+ return MOD_STOP;
+ }
+ moduleAddHelp(c, my_cs_help_appendtopic);
+ moduleSetChanHelp(my_cs_help);
+
+ my_add_languages();
+
+ alog("[cs_appendtopic] Loaded succesfully");
+
+ return MOD_CONT;
+}
+
+void AnopeFini(void)
+{
+ alog("[cs_appendtopic] Unloaded succefully");
+}
+
+void my_cs_help(User * u)
+{
+ moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP);
+}
+
+int my_cs_help_appendtopic(User * u)
+{
+ moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX);
+ notice(s_ChanServ, u->nick, " ");
+ moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_APPENDTOPIC);
+ return MOD_STOP;
+}
+
+int my_cs_appendtopic(User * u)
+{
+ char *cur_buffer;
+ char *chan;
+ char *newtopic;
+ char topic[1024];
+ Channel *c;
+ ChannelInfo *ci;
+
+ cur_buffer = moduleGetLastBuffer();
+ chan = myStrGetToken(cur_buffer, ' ', 0);
+ newtopic = myStrGetTokenRemainder(cur_buffer, ' ', 1);
+
+ if (!chan || !newtopic) {
+ moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX);
+ } else if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
+ } else if (!is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ if (ci->last_topic) {
+ snprintf(topic, sizeof(topic), "%s %s", ci->last_topic,
+ newtopic);
+ free(ci->last_topic);
+ } else {
+ strscpy(topic, newtopic, sizeof(topic));
+ }
+
+ ci->last_topic = topic ? sstrdup(topic) : NULL;
+ strscpy(ci->last_topic_setter, u->nick, NICKMAX);
+ ci->last_topic_time = time(NULL);
+
+ if (c->topic)
+ free(c->topic);
+ c->topic = topic ? sstrdup(topic) : NULL;
+ strscpy(c->topic_setter, u->nick, NICKMAX);
+ if (ircd->topictsbackward)
+ c->topic_time = c->topic_time - 1;
+ else
+ c->topic_time = ci->last_topic_time;
+
+ if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC))
+ alog("%s: %s!%s@%s changed topic of %s as services admin.",
+ s_ChanServ, u->nick, u->username, u->host, c->name);
+ if (ircd->join2set) {
+ if (whosends(ci) == s_ChanServ) {
+ anope_cmd_join(s_ChanServ, c->name, time(NULL));
+ anope_cmd_mode(NULL, c->name, "+o %s", s_ChanServ);
+ }
+ }
+ anope_cmd_topic(whosends(ci), c->name, u->nick, topic ? topic : "",
+ c->topic_time);
+ if (ircd->join2set) {
+ if (whosends(ci) == s_ChanServ) {
+ anope_cmd_part(s_ChanServ, c->name, NULL);
+ }
+ }
+ }
+ return MOD_CONT;
+}
+
+void my_add_languages(void)
+{
+ /* English (US) */
+ char *langtable_en_us[] = {
+ /* LNG_CHAN_HELP */
+ " APPENDTOPIC Add text to a channels topic",
+ /* LNG_CHAN_HELP_APPENDTOPIC */
+ "This command allows users to append text to a currently set\n"
+ "channel topic. When TOPICLOCK is on, the topic is updated and\n"
+ "the new, updated topic is locked.",
+ /* LNG_APPENDTOPIC_SYNTAX */
+ "Syntax: APPENDTOPIC channel text\n"
+ };
+
+ /* Dutch */
+ char *langtable_nl[] = {
+ /* LNG_CHAN_HELP */
+ " APPENDTOPIC Voeg tekst aan een kanaal onderwerp toe",
+ /* LNG_CHAN_HELP_APPENDTOPIC */
+ "Dit command stelt gebruikers in staat om text toe te voegen\n"
+ "achter het huidige onderwerp van een kanaal. Als TOPICLOCK aan\n"
+ "staat, zal het onderwerp worden bijgewerkt en zal het nieuwe,\n"
+ "bijgewerkte topic worden geforceerd.",
+ /* LNG_APPENDTOPIC_SYNTAX */
+ "Gebruik: APPENDTOPIC kanaal tekst\n"
+ };
+
+ moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us);
+ moduleInsertLanguage(LANG_NL, LNG_NUM_STRINGS, langtable_nl);
+}
+
+/* EOF */
diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c
new file mode 100644
index 000000000..9c6f0b796
--- /dev/null
+++ b/src/modules/cs_enforce.c
@@ -0,0 +1,334 @@
+/* cs_enforce - Add a /cs ENFORCE command to enforce various set
+ * options and channelmodes on a channel.
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Included in the Anope module pack since Anope 1.7.9
+ * Anope Coder: GeniusDex <geniusdex@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Send any bug reports to the Anope Coder, as he will be able
+ * to deal with it best.
+ */
+
+#include "module.h"
+
+#define AUTHOR "Anope"
+#define VERSION "$Id$"
+
+int my_cs_enforce(User * u);
+void my_cs_help(User * u);
+int my_cs_help_enforce(User * u);
+void my_add_languages(void);
+
+#define LNG_NUM_STRINGS 5
+
+#define LNG_CHAN_HELP 0
+#define LNG_ENFORCE_SYNTAX 1
+#define LNG_CHAN_HELP_ENFORCE 2
+#define LNG_CHAN_HELP_ENFORCE_R_ENABLED 3
+#define LNG_CHAN_HELP_ENFORCE_R_DISABLED 4
+
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+ int status;
+
+ moduleAddAuthor(AUTHOR);
+ moduleAddVersion(VERSION);
+ moduleSetType(SUPPORTED);
+
+ c = createCommand("ENFORCE", my_cs_enforce, NULL, -1, -1, -1, -1, -1);
+ if ((status = moduleAddCommand(CHANSERV, c, MOD_HEAD))) {
+ alog("[cs_enforce] Unable to create ENFORCE command: %d", status);
+ return MOD_STOP;
+ }
+
+ moduleAddHelp(c, my_cs_help_enforce);
+ moduleSetChanHelp(my_cs_help);
+
+ my_add_languages();
+
+ return MOD_CONT;
+}
+
+void AnopeFini(void)
+{
+ /* Nothing to clean up */
+}
+
+/* Enforcing functions */
+void do_enforce_secureops(Channel * c)
+{
+ struct c_userlist *user;
+ struct c_userlist *next;
+ ChannelInfo *ci;
+ uint32 flags;
+
+ if (!(ci = c->ci))
+ return;
+
+ if (debug)
+ alog("debug: cs_enforce: Enforcing SECUREOPS on %s", c->name);
+
+ /* Dirty hack to allow chan_set_correct_modes to work ok.
+ * We pretend like SECUREOPS is on so it doesn't ignore that
+ * part of the code. This way we can enforce SECUREOPS even
+ * if it's off.
+ */
+ flags = ci->flags;
+ ci->flags |= CI_SECUREOPS;
+
+ user = c->users;
+ do {
+ next = user->next;
+ chan_set_correct_modes(user->user, c, 0);
+ user = next;
+ } while (user);
+
+ ci->flags = flags;
+}
+
+void do_enforce_restricted(Channel * c)
+{
+ struct c_userlist *user;
+ struct c_userlist *next;
+ ChannelInfo *ci;
+ int16 old_nojoin_level;
+ char mask[BUFSIZE];
+ char *reason;
+ char *av[3];
+ User *u;
+
+ if (!(ci = c->ci))
+ return;
+
+ if (debug)
+ alog("debug: cs_enforce: Enforcing RESTRICTED on %s", c->name);
+
+ old_nojoin_level = ci->levels[CA_NOJOIN];
+ if (ci->levels[CA_NOJOIN] < 0)
+ ci->levels[CA_NOJOIN] = 0;
+
+ user = c->users;
+ do {
+ next = user->next;
+ u = user->user;
+ if (check_access(u, c->ci, CA_NOJOIN)) {
+ get_idealban(ci, u, mask, sizeof(mask));
+ reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN);
+ anope_cmd_mode(whosends(ci), ci->name, "+b %s %lu", mask,
+ time(NULL));
+ anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s", reason);
+ av[0] = ci->name;
+ av[1] = u->nick;
+ av[2] = reason;
+ do_kick(s_ChanServ, 3, av);
+ }
+ user = next;
+ } while (user);
+
+ ci->levels[CA_NOJOIN] = old_nojoin_level;
+}
+
+void do_enforce_cmode_R(Channel * c)
+{
+ struct c_userlist *user;
+ struct c_userlist *next;
+ ChannelInfo *ci;
+ char mask[BUFSIZE];
+ char *reason;
+ char *av[3];
+ User *u;
+ CBMode *cbm;
+
+ if (!(ci = c->ci))
+ return;
+
+ if (debug)
+ alog("debug: cs_enforce: Enforcing mode +R on %s", c->name);
+
+ user = c->users;
+ do {
+ next = user->next;
+ u = user->user;
+ if (!nick_identified(u)) {
+ get_idealban(ci, u, mask, sizeof(mask));
+ reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN);
+ if (((cbm = &cbmodes['R'])->flag == 0)
+ || !(c->mode & cbm->flag))
+ anope_cmd_mode(whosends(ci), ci->name, "+b %s %lu", mask,
+ time(NULL));
+ anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s", reason);
+ av[0] = ci->name;
+ av[1] = u->nick;
+ av[2] = reason;
+ do_kick(s_ChanServ, 3, av);
+ }
+ user = next;
+ } while (user);
+}
+
+/* Enforcing Group Functions */
+void do_enforce_set(Channel * c)
+{
+ ChannelInfo *ci;
+
+ if (!(ci = c->ci))
+ return;
+
+ if (ci->flags & CI_SECUREOPS)
+ do_enforce_secureops(c);
+ if (ci->flags & CI_RESTRICTED)
+ do_enforce_restricted(c);
+}
+
+void do_enforce_modes(Channel * c)
+{
+ CBMode *cbm;
+
+ if (((cbm = &cbmodes['R'])->flag != 0) && (c->mode & cbm->flag))
+ do_enforce_cmode_R(c);
+}
+
+/* End of enforcing functions */
+
+int my_cs_enforce(User * u)
+{
+ char *cur_buffer;
+ char *chan;
+ char *what;
+ Channel *c;
+ ChannelInfo *ci;
+
+ cur_buffer = moduleGetLastBuffer();
+ chan = myStrGetToken(cur_buffer, ' ', 0);
+
+ if (!chan) {
+ moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX);
+ } else if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
+ } else if (!is_services_admin(u) && !check_access(u, ci, CA_AKICK)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ what = myStrGetToken(cur_buffer, ' ', 1);
+ if (!what || (stricmp(what, "SET") == 0)) {
+ do_enforce_set(c);
+ } else if (stricmp(what, "MODES") == 0) {
+ do_enforce_modes(c);
+ } else if (stricmp(what, "SECUREOPS") == 0) {
+ do_enforce_secureops(c);
+ } else if (stricmp(what, "RESTRICTED") == 0) {
+ do_enforce_restricted(c);
+ } else if (stricmp(what, "+R") == 0) {
+ do_enforce_cmode_R(c);
+ } else {
+ moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX);
+ }
+ }
+
+ free(chan);
+ free(what);
+
+ return MOD_CONT;
+}
+
+/* Language and response stuff */
+void my_cs_help(User * u)
+{
+ moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP);
+}
+
+int my_cs_help_enforce(User * u)
+{
+ moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX);
+ notice(s_ChanServ, u->nick, " ");
+ moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE);
+ notice(s_ChanServ, u->nick, " ");
+ if (cbmodes['R'].flag != 0)
+ moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_ENABLED);
+ else
+ moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_DISABLED);
+
+ return MOD_STOP;
+}
+
+void my_add_languages(void)
+{
+ /* English (US) */
+ char *langtable_en_us[] = {
+ /* LNG_CHAN_HELP */
+ " ENFORCE Enforce various channel modes and set options",
+ /* LNG_ENFORCE_SYNTAX */
+ "Syntax: \002ENFORCE \037channel\037 [\037what\037]\002",
+ /* LNG_CHAN_HELP_ENFORCE */
+ "Enforce various channel modes and set options. The \037channel\037\n"
+ "option indicates what channel to enforce the modes and options\n"
+ "on. The \037what\037 option indicates what modes and options to\n"
+ "enforce, and can be any of SET, SECUREOPS, RESTRICTED, MODES,\n"
+ "or +R. When left out, it defaults to SET.\n"
+ " \n"
+ "If \037what\037 is SET, it will enforce SECUREOPS and RESTRICTED\n"
+ "on the users currently in the channel, if they are set. Give\n"
+ "SECUREOPS to enforce the SECUREOPS option, even if it is not\n"
+ "enabled. Use RESTRICTED to enfore the RESTRICTED option, also\n"
+ "if it's not enabled.",
+ /* LNG_CHAN_HELP_ENFORCE_R_ENABLED */
+ "If \037what\037 is MODES, it will enforce channelmode +R if it is\n"
+ "set. If +R is specified for \037what\037, the +R channelmode will\n"
+ "also be enforced, but even if it is not set. If it is not set,\n"
+ "users will be banned to ensure they don't just rejoin.",
+ /* LNG_CHAN_HELP_ENFORCE_R_DISABLED */
+ "If \037what\037 is MODES, nothing will be enforced, since it would\n"
+ "enforce modes that the current ircd does not support. If +R is\n"
+ "specified for \037what\037, an equalivant of channelmode +R on\n"
+ "other ircds will be enforced. All users that are in the channel\n"
+ "but have not identified for their nickname will be kicked and\n"
+ "banned from the channel."
+ };
+
+ /* Dutch */
+ char *langtable_nl[] = {
+ /* LNG_CHAN_HELP */
+ " ENFORCE Forceer enkele kanaalmodes en set-opties",
+ /* LNG_ENFORCE_SYNTAX */
+ "Syntax: \002ENFORCE \037kanaal\037 [\037wat\037]\002",
+ /* LNG_CHAN_HELP_ENFORCE */
+ "Forceer enkele kannalmodes en set-opties. De \037kanaal\037 optie\n"
+ "geeft aan op welk kanaal de modes en opties geforceerd moeten\n"
+ "worden. De \037wat\037 optie geeft aan welke modes en opties\n"
+ "geforceerd moeten worden; dit kan SET, SECUREOPS, RESTRICTED,\n"
+ "MODES, of +R zijn. Indien weggelaten is dit standaard SET.\n"
+ " \n"
+ "Als er voor \037wat\037 SET wordt ingevuld, zullen SECUREOPS en\n"
+ "RESTRICTED geforceerd worden op de gebruikers in het kanaal,\n"
+ "maar alleen als die opties aangezet zijn voor het kanaal. Als\n"
+ "SECUREOPS of RESTRICTED wordt gegeven voor \037wat\037 zal die optie\n"
+ "altijd geforceerd worden, ook als die niet is aangezet.",
+ /* LNG_CHAN_HELP_ENFORCE_R_ENABLED */
+ "Als er voor \037wat\037 MODES wordt ingevuld, zal kanaalmode +R worden\n"
+ "geforceerd, als die op het kanaal aan staat. Als +R wordt ingevuld,\n"
+ "zal kanaalmode +R worden geforceerd, maar ook als die niet aan"
+ "staat voor het kanaal. Als +R niet aan staat, zullen alle ook\n"
+ "gebanned worden om te zorgen dat ze niet opnieuw het kanaal binnen\n"
+ "kunnen komen.",
+ /* LNG_CHAN_HELP_ENFORCE_R_DISABLED */
+ "Als er voor \037wat\037 MODES wordt ingevuld, zal er niks gebeuren.\n"
+ "Normaal gesproken wordt er een kanaalmode geforceerd die op deze\n"
+ "server niet ondersteund wordt. Als +R wordt ingevuld voor \037wat\037\n"
+ "zullen alle gebruikers die in het kanaal zitten maar zich niet\n"
+ "hebben geidentificeerd voor hun nick uit het kanaal gekicked en\n"
+ "verbannen worden."
+ };
+
+ moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us);
+ moduleInsertLanguage(LANG_NL, LNG_NUM_STRINGS, langtable_nl);
+}
+
+/* EOF */
diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c
new file mode 100644
index 000000000..9f56211b9
--- /dev/null
+++ b/src/modules/cs_tban.c
@@ -0,0 +1,171 @@
+#include "module.h"
+
+#define AUTHOR "Rob"
+#define VERSION "1"
+
+void myHelp(User *u);
+void myFullHelpSyntax(User *u);
+int myFullHelp(User *u);
+void mySendResponse(User *u, char *channel, char *mask, char *time);
+
+int do_tban(User *u);
+void addBan(Channel *c, time_t timeout, char *banmask);
+int delBan(int argc, char **argv);
+int canBanUser(Channel *c, User *u, User *u2);
+
+void mAddLanguages(void);
+
+#define LANG_NUM_STRINGS 4
+#define TBAN_HELP 0
+#define TBAN_SYNTAX 1
+#define TBAN_HELP_DETAIL 2
+#define TBAN_RESPONSE 3
+
+int AnopeInit(int argc, char **argv) {
+ Command *c;
+ int status = 0;
+
+ moduleSetChanHelp(myHelp);
+ c = createCommand("TBAN", do_tban, NULL, -1,-1,-1,-1,-1);
+ moduleAddHelp(c,myFullHelp);
+ status = moduleAddCommand(CHANSERV, c, MOD_HEAD);
+
+ mAddLanguages();
+
+ if(status!=MOD_ERR_OK) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+void AnopeFini(void)
+{
+ /* module is unloading */
+}
+
+void myHelp(User *u) {
+ moduleNoticeLang(s_ChanServ, u,TBAN_HELP);
+}
+
+void myFullHelpSyntax(User *u) {
+ moduleNoticeLang(s_ChanServ, u,TBAN_SYNTAX);
+}
+
+int myFullHelp(User *u) {
+ myFullHelpSyntax(u);
+ notice(s_ChanServ,u->nick,"");
+ moduleNoticeLang(s_ChanServ, u,TBAN_HELP_DETAIL);
+ return MOD_CONT;
+}
+
+void mySendResponse(User *u, char *channel, char *mask, char *time) {
+ moduleNoticeLang(s_ChanServ, u,TBAN_RESPONSE,mask,channel,time);
+}
+
+int do_tban(User *u) {
+ char mask[BUFSIZE];
+ Channel *c;
+ User *u2=NULL;
+
+ char *buffer = moduleGetLastBuffer();
+ char *chan;
+ char *nick;
+ char *time;
+
+ chan = myStrGetToken(buffer, ' ', 0);
+ nick = myStrGetToken(buffer,' ',1);
+ time = myStrGetToken(buffer,' ',2);
+
+ if(time && chan && nick) {
+
+ if (!(c = findchan(chan))) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
+ } else if (!(u2 = finduser(nick))) {
+ notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
+ } else {
+ if(canBanUser(c,u,u2)) {
+ get_idealban(c->ci, u2, mask, sizeof(mask));
+ addBan(c,dotime(time),mask);
+ mySendResponse(u,chan,mask,time);
+ }
+ }
+ } else {
+ myFullHelpSyntax(u);
+ }
+ if(time) free(time);
+ if(nick) free(nick);
+ if(chan) free(chan);
+
+ return MOD_CONT;
+}
+
+void addBan(Channel *c, time_t timeout, char *banmask) {
+ char *av[3];
+ char *cb[2];
+
+ cb[0] = c->name;
+ cb[1] = banmask;
+
+ av[0] = sstrdup("+b");
+ av[1] = banmask;
+
+ anope_cmd_mode(whosends(c->ci), c->name, "+b %s", av[1]);
+ chan_set_modes(s_ChanServ, c, 2, av, 1);
+
+ free(av[0]);
+ moduleAddCallback("tban",time(NULL)+timeout,delBan,2,cb);
+}
+
+int delBan(int argc, char **argv) {
+ char *av[3];
+ Channel *c;
+
+ av[0] = sstrdup("-b");
+ av[1] = argv[1];
+
+ if((c=findchan(argv[0])) && c->ci ) {
+ anope_cmd_mode(whosends(c->ci), c->name, "-b %s", av[1]);
+ chan_set_modes(s_ChanServ, c, 2, av, 1);
+ }
+
+ free(av[0]);
+
+ return MOD_CONT;
+}
+
+int canBanUser(Channel *c, User *u, User *u2) {
+ ChannelInfo *ci;
+ int ok = 0;
+ if (!(ci = c->ci)) {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
+ } else if (ci->flags & CI_VERBOTEN) {
+ notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, c->name);
+ } else if (!check_access(u, ci, CA_BAN)) {
+ notice_lang(s_ChanServ, u, ACCESS_DENIED);
+ } else if (ircd->except && is_excepted(ci, u2)) {
+ notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
+ } else if (ircd->protectedumode && is_protected(u2)) {
+ notice_lang(s_ChanServ, u, PERMISSION_DENIED);
+ } else {
+ ok = 1;
+ }
+
+ return ok;
+}
+
+
+void mAddLanguages(void) {
+ char *langtable_en_us[] = {
+ " TBAN Bans the user for a given length of time",
+ "Syntax: TBAN channel nick time",
+ "Bans the given user from a channel\n"
+ "for a specified length of time.\n"
+ "If the ban is removed before hand, it will\n"
+ "NOT be replaced.",
+ "%s banned from %s, will auto-expire in %s"
+ };
+ moduleInsertLanguage(LANG_EN_US, LANG_NUM_STRINGS, langtable_en_us);
+}
+
+
+/* EOF */
diff --git a/src/modules/catserv/Makefile b/src/modules/demos/catserv/Makefile
index 5b2f4efa3..5b2f4efa3 100644
--- a/src/modules/catserv/Makefile
+++ b/src/modules/demos/catserv/Makefile
diff --git a/src/modules/catserv/README b/src/modules/demos/catserv/README
index c3d3f7084..c3d3f7084 100644
--- a/src/modules/catserv/README
+++ b/src/modules/demos/catserv/README
diff --git a/src/modules/catserv/catserv_extern.h b/src/modules/demos/catserv/catserv_extern.h
index 02c21addb..02c21addb 100644
--- a/src/modules/catserv/catserv_extern.h
+++ b/src/modules/demos/catserv/catserv_extern.h
diff --git a/src/modules/catserv/catserv_messages.c b/src/modules/demos/catserv/catserv_messages.c
index e11235b4e..e11235b4e 100644
--- a/src/modules/catserv/catserv_messages.c
+++ b/src/modules/demos/catserv/catserv_messages.c
diff --git a/src/modules/catserv/catserv_messages.h b/src/modules/demos/catserv/catserv_messages.h
index bb3f82dd0..bb3f82dd0 100644
--- a/src/modules/catserv/catserv_messages.h
+++ b/src/modules/demos/catserv/catserv_messages.h
diff --git a/src/modules/catserv/ircd_catserv.c b/src/modules/demos/catserv/ircd_catserv.c
index 2fa7b52b3..ae34d6161 100644
--- a/src/modules/catserv/ircd_catserv.c
+++ b/src/modules/demos/catserv/ircd_catserv.c
@@ -10,7 +10,7 @@
#include "catserv_messages.h"
#define AUTHOR "Anope"
-#define VERSION "1.2"
+#define VERSION "$Id$"
int my_privmsg(char *source, int ac, char **av);
diff --git a/src/modules/catserv/makefile.win32 b/src/modules/demos/catserv/makefile.win32
index 638704440..638704440 100644
--- a/src/modules/catserv/makefile.win32
+++ b/src/modules/demos/catserv/makefile.win32
diff --git a/src/modules/catserv/meow.c b/src/modules/demos/catserv/meow.c
index 9279eec0b..9279eec0b 100644
--- a/src/modules/catserv/meow.c
+++ b/src/modules/demos/catserv/meow.c
diff --git a/src/modules/catserv/meow.h b/src/modules/demos/catserv/meow.h
index 0f28673a0..0f28673a0 100644
--- a/src/modules/catserv/meow.h
+++ b/src/modules/demos/catserv/meow.h
diff --git a/src/modules/catserv/purr.c b/src/modules/demos/catserv/purr.c
index 5a39dc26e..5a39dc26e 100644
--- a/src/modules/catserv/purr.c
+++ b/src/modules/demos/catserv/purr.c
diff --git a/src/modules/catserv/purr.h b/src/modules/demos/catserv/purr.h
index a92e421f6..a92e421f6 100644
--- a/src/modules/catserv/purr.h
+++ b/src/modules/demos/catserv/purr.h
diff --git a/src/modules/demos/events.c b/src/modules/demos/events.c
new file mode 100644
index 000000000..c61d62985
--- /dev/null
+++ b/src/modules/demos/events.c
@@ -0,0 +1,82 @@
+/**
+ * Simple module to show the usage of event messages and hooks
+ * 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 "$Id$"
+
+int my_nick(char *source, int ac, char **av);
+int my_save(int argc, char **argv);
+int do_moo(int argc, char **argv);
+
+int AnopeInit(int argc, char **argv)
+{
+ EvtMessage *msg = NULL;
+ EvtHook *hook = NULL;
+ int status;
+ msg = createEventHandler("NICK", my_nick);
+ status = moduleAddEventHandler(msg);
+
+ hook = createEventHook(EVENT_DB_SAVING, my_save);
+ status = moduleAddEventHook(hook);
+
+
+ hook = createEventHook(EVENT_BOT_FANTASY, do_moo);
+ status = moduleAddEventHook(hook);
+
+ moduleAddAuthor(AUTHOR);
+ moduleAddVersion(VERSION);
+ return MOD_CONT;
+}
+
+void AnopeFini(void)
+{
+ /* unloading */
+}
+
+int my_nick(char *source, int ac, char **av)
+{
+ alog("Internal Event - nick is %s",av[0]);
+ return MOD_CONT;
+}
+
+int my_save(int argc, char **argv)
+{
+ if(argc>=1) {
+ if (!stricmp(argv[0], EVENT_START)) {
+ alog("Saving the databases! has started");
+ } else {
+ alog("Saving the databases is complete");
+ }
+ }
+ return MOD_CONT;
+}
+
+/**
+ * command to be called when a EVENT_BOT_FANTASY event is recived.
+ * @param argc The paramater count for this event.
+ * @param argv[0] The cmd used.
+ * @param argv[1] The nick of the command user.
+ * @param argv[2] The channel name the command was used in.
+ * @param argv[3] The rest of the text after the command.
+ * @return MOD_CONT or MOD_STOP
+ **/
+int do_moo(int argc, char **argv) {
+ ChannelInfo *ci;
+ if(argc>=3) { /* We need at least 3 arguments */
+ if(stricmp(argv[0],"!moo")==0) { /* is it meant for us? */
+ if((ci = cs_findchan(argv[2]))) { /* channel should always exist */
+ anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION moo's at %s %c",1,argv[1],1);
+ return MOD_STOP; /* We've dealt with it, dont let others */
+ }
+ }
+ }
+ return MOD_CONT; /* guess it wasnt for us, pass it on */
+}
+
diff --git a/src/modules/demos/hs_conf.c b/src/modules/demos/hs_conf.c
new file mode 100644
index 000000000..45b4bb330
--- /dev/null
+++ b/src/modules/demos/hs_conf.c
@@ -0,0 +1,74 @@
+#include "module.h"
+
+#define AUTHOR "Anope"
+#define VERSION "1"
+
+/**
+ * Default setting to be used if no confing value is found
+ **/
+#define DEFAULT_SETTING "moo"
+
+int mShowSetting(User *u);
+int mReadConfig(int argc, char **argv);
+
+char *setting;
+
+int AnopeInit(int argc, char **argv) {
+ Command *c;
+ EvtHook *hook;
+ int status = 0;
+
+ setting = NULL;
+
+ mReadConfig(0,NULL);
+
+ c = createCommand("SHOW",mShowSetting,NULL,-1,-1,-1,-1,-1);
+ status = moduleAddCommand(HOSTSERV, c, MOD_HEAD);
+
+ hook = createEventHook(EVENT_RELOAD, mReadConfig);
+ status = moduleAddEventHook(hook);
+
+ if(status!=MOD_ERR_OK) {
+ return MOD_STOP;
+ }
+ return MOD_CONT;
+}
+
+/**
+ * free the globals when we close
+ **/
+void AnopeFini(void) {
+ if(setting)
+ free(setting);
+}
+
+/**
+ * Simple function to show the user the current config setting
+ **/
+int mShowSetting(User *u) {
+ notice(s_HostServ,u->nick,"Setting in use is [%s]",setting);
+ return MOD_CONT;
+}
+
+/**
+ * Load the config setting up, this will be called whenever
+ * the EVENT_RELOAD event is recived.
+ **/
+int mReadConfig(int argc, char **argv) {
+ char *tmp=NULL;
+ Directive d[] = {{"HSConfigSetting", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}};
+ moduleGetConfigDirective(d);
+
+ if(setting) {
+ free(setting);
+ }
+ if(tmp) {
+ setting = tmp;
+ } else {
+ setting = sstrdup(DEFAULT_SETTING);
+ }
+ return MOD_CONT;
+}
+
+
+/* EOF */
diff --git a/src/modules/hs_moo.c b/src/modules/demos/hs_moo.c
index 0c3070036..b65e83bb6 100644
--- a/src/modules/hs_moo.c
+++ b/src/modules/demos/hs_moo.c
@@ -9,7 +9,7 @@
#include "module.h"
#define AUTHOR "Anope" /* Set the Author for a modinfo reply */
-#define VERSION "1.1" /* Set the version for a modinfo reply */
+#define VERSION "$Id$" /* 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);
diff --git a/src/modules/events.c b/src/modules/events.c
deleted file mode 100644
index af53a3d40..000000000
--- a/src/modules/events.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Simple module to show the usage of event messages and hooks
- * 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_nick(char *source, int ac, char **av);
-int my_save(char *message);
-
-int AnopeInit(int argc, char **argv)
-{
- EvtMessage *msg = NULL;
- EvtHook *hook = NULL;
- int status;
- msg = createEventHandler("NICK", my_nick);
- status = moduleAddEventHandler(msg);
-
- hook = createEventHook(EVENT_DB_SAVING, my_save);
- status = moduleAddEventHook(hook);
-
- moduleAddAuthor(AUTHOR);
- moduleAddVersion(VERSION);
- return MOD_CONT;
-}
-
-void AnopeFini(void)
-{
- /* unloading */
-}
-
-int my_nick(char *source, int ac, char **av)
-{
- alog("Internal Event - nick is %s",av[0]);
- return MOD_CONT;
-}
-
-int my_save(char *message)
-{
- if (!stricmp(message, EVENT_START)) {
- alog("Saving the databases! has started");
- } else {
- alog("Saving the databases is complete");
- }
- return MOD_CONT;
-}
-
diff --git a/src/modules/makefile.inc.win32 b/src/modules/makefile.inc.win32
index f069be350..9b933f4a5 100644
--- a/src/modules/makefile.inc.win32
+++ b/src/modules/makefile.inc.win32
@@ -1,2 +1,2 @@
-SRCS=hs_moo.c events.c
-SUBS=catserv
+SRCS=cs_appendtopic.c cs_enforce.c cs_tban.c ns_maxemail.c ns_noop.c os_info.c
+SUBS=test
diff --git a/src/modules/makefile.win32 b/src/modules/makefile.win32
index f7a827ec8..61a3e250a 100644
--- a/src/modules/makefile.win32
+++ b/src/modules/makefile.win32
@@ -12,7 +12,6 @@ distclean: clean spotless
.c.dll:
$(CC) $(CFLAGS) $(IRCTYPE) $< $(LFLAGS)
-
subs:
@for %i in ( $(SUBS) ); do \
@if exist %i; @cd %i && $(MAKE) $(MAKEARGS) && cd ..
diff --git a/src/modules/module.h b/src/modules/module.h
deleted file mode 100644
index 3f341c0aa..000000000
--- a/src/modules/module.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "services.h"
-#include "commands.h"
-#include "language.h"
-#include "modules.h"
-#include "depricated.h"
-
-#define MOD_UNIQUE 0
-#define MOD_HEAD 1
-#define MOD_TAIL 2
-
diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c
new file mode 100644
index 000000000..ac51d3d5c
--- /dev/null
+++ b/src/modules/ns_maxemail.c
@@ -0,0 +1,190 @@
+/* ns_maxemail.c - Limit the amount of times an email address
+ * can be used for a NickServ account.
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Included in the Anope module pack since Anope 1.7.9
+ * Anope Coder: GeniusDex <geniusdex@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Send any bug reports to the Anope Coder, as he will be able
+ * to deal with it best.
+ */
+
+#include "module.h"
+
+#define AUTHOR "Anope"
+#define VERSION "$Id$"
+
+void my_load_config(void);
+void my_add_languages(void);
+int my_ns_register(User * u);
+int my_ns_set(User * u);
+int my_event_reload(int argc, char **argv);
+
+int NSEmailMax = 0;
+
+#define LNG_NUM_STRINGS 2
+#define LNG_NSEMAILMAX_REACHED 0
+#define LNG_NSEMAILMAX_REACHED_ONE 1
+
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+ EvtHook *evt;
+ int status;
+
+ moduleAddAuthor(AUTHOR);
+ moduleAddVersion(VERSION);
+ moduleSetType(SUPPORTED);
+
+ c = createCommand("REGISTER", my_ns_register, NULL, -1, -1, -1, -1,
+ -1);
+ if ((status = moduleAddCommand(NICKSERV, c, MOD_HEAD))) {
+ alog("[ns_maxemail] Unable to create REGISTER command: %d",
+ status);
+ return MOD_STOP;
+ }
+
+ c = createCommand("SET", my_ns_set, NULL, -1, -1, -1, -1, -1);
+ if ((status = moduleAddCommand(NICKSERV, c, MOD_HEAD))) {
+ alog("[ns_maxemail] Unable to create SET command: %d", status);
+ return MOD_STOP;
+ }
+
+ evt = createEventHook(EVENT_RELOAD, my_event_reload);
+ if ((status = moduleAddEventHook(evt))) {
+ alog("[ns_maxemail] Unable to hook to EVENT_RELOAD: %d", status);
+ return MOD_STOP;
+ }
+
+ my_load_config();
+ my_add_languages();
+
+ return MOD_CONT;
+}
+
+void AnopeFini(void)
+{
+ /* Nothing to do while unloading */
+}
+
+int count_email_in_use(char *email, User * u)
+{
+ NickCore *nc;
+ int i;
+ int count = 0;
+
+ if (!email)
+ return 0;
+
+ for (i = 0; i < 1024; i++) {
+ for (nc = nclists[i]; nc; nc = nc->next) {
+ if (!(u->na && u->na->nc && u->na->nc == nc)
+ && (stricmp(nc->email, email) == 0))
+ count++;
+ }
+ }
+
+ return count;
+}
+
+int check_email_limit_reached(char *email, User * u)
+{
+ if ((NSEmailMax < 1) || !email || is_services_admin(u))
+ return MOD_CONT;
+
+ if (count_email_in_use(email, u) < NSEmailMax)
+ return MOD_CONT;
+
+ if (NSEmailMax == 1)
+ moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED_ONE);
+ else
+ moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED,
+ NSEmailMax);
+
+ return MOD_STOP;
+}
+
+int my_ns_register(User * u)
+{
+ char *cur_buffer;
+ char *email;
+ int ret;
+
+ cur_buffer = moduleGetLastBuffer();
+ email = myStrGetToken(cur_buffer, ' ', 1);
+
+ ret = check_email_limit_reached(email, u);
+ free(email);
+
+ return ret;
+}
+
+int my_ns_set(User * u)
+{
+ char *cur_buffer;
+ char *set;
+ char *email;
+ int ret;
+
+ cur_buffer = moduleGetLastBuffer();
+ set = myStrGetToken(cur_buffer, ' ', 0);
+
+ if (stricmp(set, "email") != 0) {
+ free(set);
+ return MOD_CONT;
+ }
+
+ free(set);
+ email = myStrGetToken(cur_buffer, ' ', 1);
+
+ ret = check_email_limit_reached(email, u);
+ free(email);
+
+ return ret;
+}
+
+int my_event_reload(int argc, char **argv)
+{
+ if ((argc > 0) && (stricmp(argv[0], EVENT_START) == 0))
+ my_load_config();
+
+ return MOD_CONT;
+}
+
+void my_load_config(void)
+{
+ Directive confvalues[] = {
+ {"NSEmailMax", {{PARAM_INT, PARAM_RELOAD, &NSEmailMax}}}
+ };
+
+ moduleGetConfigDirective(confvalues);
+
+ if (debug)
+ alog("debug: [ns_maxemail] NSEmailMax set to %d", NSEmailMax);
+}
+
+void my_add_languages(void)
+{
+ char *langtable_en_us[] = {
+ /* LNG_NSEMAILMAX_REACHED */
+ "The given email address has reached it's usage limit of %d users.",
+ /* LNG_NSEMAILMAX_REACHED_ONE */
+ "The given email address has reached it's usage limit of 1 user."
+ };
+
+ char *langtable_nl[] = {
+ /* LNG_NSEMAILMAX_REACHED */
+ "Het gegeven email adres heeft de limiet van %d gebruikers bereikt.",
+ /* LNG_NSEMAILMAX_REACHED_ONE */
+ "Het gegeven email adres heeft de limiet van 1 gebruiker bereikt."
+ };
+
+ moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us);
+ moduleInsertLanguage(LANG_NL, LNG_NUM_STRINGS, langtable_nl);
+}
+
+/* EOF */
diff --git a/src/modules/ns_noop.c b/src/modules/ns_noop.c
new file mode 100644
index 000000000..14662596b
--- /dev/null
+++ b/src/modules/ns_noop.c
@@ -0,0 +1,483 @@
+/* ns_noop.c - Allows users to optionaly set autoop to off
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Based on the original module by Rob <rob@anope.org>
+ * Included in the Anope module pack since Anope 1.7.9
+ * Anope Coder: DrStein <drstein@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Send bug reports to the Anope Coder instead of the module
+ * author, because any changes since the inclusion into anope
+ * are not supported by the original author.
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+#define AUTHOR "Rob"
+#define VERSION "$Id$"
+
+/* The name of the default database to save info to */
+#define DEFAULT_DB_NAME "autoop.db"
+
+/* Multi-language stuff */
+#define LANG_NUM_STRINGS 8
+
+#define AUTOOP_SYNTAX 0
+#define AUTOOP_STATUS_ON 1
+#define AUTOOP_STATUS_OFF 2
+#define AUTOOP_NO_NICK 3
+#define AUTOOP_ON 4
+#define AUTOOP_OFF 5
+#define AUTOOP_DESC 6
+#define AUTOOP_HELP 7
+
+/*************************************************************************/
+
+User *currentUser;
+int m_isIRCop = 0;
+
+char *NSAutoOPDBName;
+
+int myNickServAutoOpHelp(User * u);
+void myNickServHelp(User * u);
+
+int noop(User * u);
+int mEventJoin(int argc, char **argv);
+int setAutoOp(User * u);
+int UnsetAutoOp(User * u);
+
+int mLoadData(void);
+int mSaveData(int argc, char **argv);
+int mLoadConfig(int argc, char **argv);
+
+void m_AddLanguages(void);
+void delete_ignore(const char *nick);
+
+/*************************************************************************/
+
+/**
+ * AnopeInit is called when the module is loaded
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c = NULL;
+ EvtHook *hook = NULL;
+
+ int status;
+
+ NSAutoOPDBName = NULL;
+
+ moduleAddAuthor(AUTHOR);
+ moduleAddVersion(VERSION);
+ moduleSetType(SUPPORTED);
+
+ alog("ns_noop: Loading configuration directives");
+ if (mLoadConfig(0, NULL))
+ return MOD_STOP;
+
+ c = createCommand("autoop", noop, NULL, -1, -1, -1, -1, -1);
+ status = moduleAddCommand(NICKSERV, c, MOD_HEAD);
+
+ hook = createEventHook(EVENT_JOIN_CHANNEL, mEventJoin);
+ status = moduleAddEventHook(hook);
+
+ hook = createEventHook(EVENT_DB_SAVING, mSaveData);
+ status = moduleAddEventHook(hook);
+
+ hook = createEventHook(EVENT_RELOAD, mLoadConfig);
+ status = moduleAddEventHook(hook);
+
+ moduleAddHelp(c, myNickServAutoOpHelp);
+ moduleSetNickHelp(myNickServHelp);
+
+ mLoadData();
+ m_AddLanguages();
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+ char *av[1];
+
+ av[0] = sstrdup(EVENT_START);
+ mSaveData(1, av);
+ free(av[0]);
+
+ if (NSAutoOPDBName)
+ free(NSAutoOPDBName);
+}
+
+/*************************************************************************/
+
+/**
+ * Provide de user interface to set autoop on/off
+ * @param u The user who executed this command
+ * @return MOD_CONT
+ **/
+int noop(User * u)
+{
+ NickAlias *na = NULL;
+ char *toggleStr = strtok(NULL, "");
+
+ if (!nick_identified(u)) {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_NO_NICK);
+ } else if (!toggleStr) {
+ if ((na = findnick(u->nick))) {
+ if (moduleGetData(&na->nc->moduleData, "autoop")) {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_STATUS_OFF);
+ } else {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_STATUS_ON);
+ }
+ } else {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_SYNTAX);
+ }
+ } else {
+ if (strcasecmp(toggleStr, "on") == 0) {
+ setAutoOp(u);
+ moduleNoticeLang(s_NickServ, u, AUTOOP_ON);
+ } else if (strcasecmp(toggleStr, "off") == 0) {
+ UnsetAutoOp(u);
+ moduleNoticeLang(s_NickServ, u, AUTOOP_OFF);
+ } else {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_SYNTAX);
+ }
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Toggle on/off the autoop feature by adding or
+ * deleting moduleData.
+ * @param u The user who executed this command
+ * @return 0 On success
+ **/
+int setAutoOp(User * u)
+{
+ NickAlias *na = NULL;
+
+ if ((na = findnick(u->nick))) {
+ /* Remove the module data */
+ moduleDelData(&na->nc->moduleData, "autoop");
+ /* NickCore not found! */
+ } else {
+ alog("ns_autoop.so: WARNING: Can not find NickAlias for %s",
+ u->nick);
+ }
+
+ return 0;
+}
+
+int UnsetAutoOp(User * u)
+{
+ NickAlias *na = NULL;
+
+ if ((na = findnick(u->nick))) {
+ /* Add the module data to the user */
+ moduleAddData(&na->nc->moduleData, "autoop", "off");
+ /* NickCore not found! */
+ } else {
+ alog("ns_autoop.so: WARNING: Can not find NickAlias for %s",
+ u->nick);
+ }
+
+ return 0;
+}
+
+/*************************************************************************/
+
+/**
+ * Manage the JOIN_CHANNEL EVENT
+ * @return MOD_CONT
+ **/
+int mEventJoin(int argc, char **argv)
+{
+ User *user;
+ NickAlias *na = NULL;
+
+ if (argc != 3)
+ return MOD_CONT;
+
+ user = finduser(argv[1]);
+ /* Blame Rob if this user->na should be findnick(user->nick); -GD */
+ if (user && (na = user->na)) {
+ if (strcmp(argv[0], EVENT_START) == 0) {
+ if (moduleGetData(&na->nc->moduleData, "autoop")) {
+ currentUser = user;
+ if (is_oper(user)) {
+ user->mode &= ~(anope_get_oper_mode());
+ m_isIRCop = 1;
+ }
+ add_ignore(user->nick, 120);
+ }
+ } else {
+ /* Does the user have the autoop info in his moduleData? */
+ if (moduleGetData(&na->nc->moduleData, "autoop")) {
+ /* The most dirty solution ever! - doc */
+ if (m_isIRCop)
+ user->mode |= anope_get_oper_mode();
+ delete_ignore(user->nick);
+ }
+ }
+ }
+
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * Load data from the db file, and populate the autoop setting
+ * @return 0 for success
+ **/
+int mLoadData(void)
+{
+ int ret = 0;
+ int len = 0;
+
+ char *name = NULL;
+
+ NickAlias *na = NULL;
+ FILE *in;
+
+ /* will _never_ be this big thanks to the 512 limit of a message */
+ char buffer[2000];
+ if ((in = fopen(NSAutoOPDBName, "r")) == NULL) {
+ alog("ns_noop: WARNING: Can not open database file! (it might not exist, this is not fatal)");
+ ret = 1;
+ } else {
+ while (!feof(in)) {
+ fgets(buffer, 1500, in);
+ name = myStrGetToken(buffer, ' ', 0);
+ if (name) {
+ len = strlen(name);
+ /* Take the \n from the end of the line */
+ name[len - 1] = '\0';
+ if ((na = findnick(name))) {
+ moduleAddData(&na->nc->moduleData, "autoop", "off");
+ }
+ free(name);
+ }
+ }
+ }
+ return ret;
+}
+
+/**
+ * Save all our data to our db file
+ * First walk through the nick CORE list, and any nick core which has
+ * the autoop setting, write to the file.
+ * @return 0 for success
+ **/
+int mSaveData(int argc, char **argv)
+{
+ NickCore *nc = NULL;
+ int i = 0;
+ int ret = 0;
+ FILE *out;
+
+ if (argc >= 1) {
+ if (stricmp(argv[0], EVENT_START) == 0) {
+ alog("ns_noop: Saving the databases has started!");
+ if ((out = fopen(NSAutoOPDBName, "w")) == NULL) {
+ alog("ns_noop: ERROR: can not open the database file!");
+ anope_cmd_global(s_NickServ,
+ "ns_noop: ERROR: can not open the database file!");
+ ret = 1;
+ } else {
+ for (i = 0; i < 1024; i++) {
+ for (nc = nclists[i]; nc; nc = nc->next) {
+ /* If we have any info on this user */
+ if (moduleGetData(&nc->moduleData, "autoop")) {
+ fprintf(out, "%s\n", nc->display);
+ }
+ }
+ }
+ fclose(out);
+ }
+ } else {
+ alog("ns_noop: Saving the databases is complete");
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
+/*************************************************************************/
+
+/**
+ * Load the configuration directives from Services configuration file.
+ * @return 0 for success
+ **/
+int mLoadConfig(int argc, char **argv)
+{
+ char *tmp = NULL;
+
+ Directive d[] = {
+ {"NSAutoOPDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}},
+ };
+
+ moduleGetConfigDirective(d);
+
+ if (NSAutoOPDBName)
+ free(NSAutoOPDBName);
+
+ if (tmp) {
+ NSAutoOPDBName = tmp;
+ } else {
+ NSAutoOPDBName = sstrdup(DEFAULT_DB_NAME);
+ alog("ns_noop: NSAutoOPDBName is not defined in Services configuration file, using default %s", NSAutoOPDBName);
+ }
+
+ if (!NSAutoOPDBName) {
+ alog("ns_noop: FATAL: Can't read required configuration directives!");
+ return MOD_STOP;
+ } else {
+ alog("ns_noop: Directive NSAutoOPDBName loaded (%s)...",
+ NSAutoOPDBName);
+ }
+
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * Below are the help funcitons :)
+ **/
+void myNickServHelp(User * u)
+{
+ moduleNoticeLang(s_NickServ, u, AUTOOP_DESC);
+}
+
+int myNickServAutoOpHelp(User * u)
+{
+ moduleNoticeLang(s_NickServ, u, AUTOOP_SYNTAX);
+ moduleNoticeLang(s_NickServ, u, AUTOOP_HELP, s_ChanServ);
+
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * manages the multilanguage stuff
+ **/
+void m_AddLanguages(void)
+{
+ /* English (US) */
+ char *langtable_en_us[] = {
+ /* AUTOOP_SYNTAX */
+ "Syntax: AUTOOP [ON|OFF]",
+ /* AUTOOP_STATUS_ON */
+ "Your current AUTOOP setting is ON",
+ /* AUTOOP_STATUS_OFF */
+ "Your current AUTOOP setting is OFF",
+ /* AUTOOP_NO_NICK */
+ "Only registered and identified nicknames can set this option",
+ /* AUTOOP_ON */
+ "You will now be auto op'ed in channels when you join",
+ /* AUTOOP_OFF */
+ "You will no longer be auto op'ed in channels when you join them",
+ /* AUTOOP_DESC */
+ " AUTOOP Toggles auto-op'ing when joining rooms",
+ /* AUTOOP_HELP */
+ "When set to ON, this command will prevent %s setting any\n"
+ "modes on you when you join any channel. This command requires\n"
+ "you to be identified."
+ };
+
+ /* Spanish */
+ char *langtable_es[] = {
+ /* AUTOOP_SYNTAX */
+ "Sintaxis: AUTOOP [ON|OFF]",
+ /* AUTOOP_STATUS_ON */
+ "Tu configuracion actual de AUTOOP es ON",
+ /* AUTOOP_STATUS_OFF */
+ "Tu configuracion actual de AUTOOP es OFF",
+ /* AUTOOP_NO_NICK */
+ "Solo nicknames registrados e identificados pueden usar esta opcion",
+ /* AUTOOP_ON */
+ "Recibiras OP automaticamente cuando entres a un canal.",
+ /* AUTOOP_OFF */
+ "Ya no recibiras OP automaticamente.",
+ /* AUTOOP_DESC */
+ " AUTOOP Cambia la opcion de auto-op cuando entras a un canal",
+ /* AUTOOP_HELP */
+ "Cuando esta en ON, evitaras que ChanServ/BotServ\n"
+ "cambien tus modos en el canal que tengas acceso.\n",
+ "(Debes estar identificado para usar esta opcion)"
+ };
+
+ /* Dutch */
+ char *langtable_nl[] = {
+ /* AUTOOP_SYNTAX */
+ "Gebruik: AUTOOP [ON|OFF]",
+ /* AUTOOP_STATUS_ON */
+ "Je huidige AUTOOP instelling is AAN",
+ /* AUTOOP_STATUS_OFF */
+ "Je huidige AUTOOP instelling is UIT",
+ /* AUTOOP_NO_NICK */
+ "Alleen geregistreerd en geidentificeerde nicks kunnen deze optie gebruiken",
+ /* AUTOOP_ON */
+ "Je zal nu kanaal-op worden in kanalen wanneer je die binnen komt",
+ /* AUTOOP_OFF */
+ "Je zal nu geen kanaal-op meer worden in kanalen wanneer je die binnen komt",
+ /* AUTOOP_DESC */
+ " AUTOOP Zet auto-op aan of uit",
+ /* AUTOOP_HELP */
+ "Wanner dit aan (ON) staat, zal dit commando er voor zorgen dat\n"
+ "%s geen kanaalmodes aan jou zal geven wanneer je een\n"
+ "kanaal binnen komt. Voor dit command is het vereist dat je\n"
+ "geidentificeerd bent."
+ };
+
+ moduleInsertLanguage(LANG_EN_US, LANG_NUM_STRINGS, langtable_en_us);
+ moduleInsertLanguage(LANG_ES, LANG_NUM_STRINGS, langtable_es);
+ moduleInsertLanguage(LANG_NL, LANG_NUM_STRINGS, langtable_nl);
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes a nick from the ignore list
+ * @param nick nickname to unignore.
+ **/
+void delete_ignore(const char *nick)
+{
+ IgnoreData *ign, *prev;
+ IgnoreData **whichlist;
+
+ if (!nick || !*nick) {
+ return;
+ }
+
+ whichlist = &ignore[tolower(nick[0])];
+
+ for (ign = *whichlist, prev = NULL; ign; prev = ign, ign = ign->next) {
+ if (stricmp(ign->who, nick) == 0)
+ break;
+ }
+ if (ign) {
+ if (prev)
+ prev->next = ign->next;
+ else
+ *whichlist = ign->next;
+ free(ign);
+ ign = NULL;
+ }
+}
+
+/* EOF */
diff --git a/src/modules/os_info.c b/src/modules/os_info.c
new file mode 100644
index 000000000..1e29d0822
--- /dev/null
+++ b/src/modules/os_info.c
@@ -0,0 +1,639 @@
+/* os_info.c - Adds oper information lines to nicks/channels
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Based on the original module by Rob <rob@anope.org>
+ * Included in the Anope module pack since Anope 1.7.9
+ * Anope Coder: DrStein <drstein@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Send bug reports to the Anope Coder instead of the module
+ * author, because any changes since the inclusion into anope
+ * are not supported by the original author.
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+#define AUTHOR "Rob"
+#define VERSION "$Id$"
+
+/* Default database name */
+#define DEFAULT_DB_NAME "os_info.db"
+
+/* Multi-language stuff */
+#define LANG_NUM_STRINGS 16
+
+#define OINFO_SYNTAX 0
+#define OINFO_ADD_SUCCESS 1
+#define OINFO_DEL_SUCCESS 2
+#define OCINFO_SYNTAX 3
+#define OCINFO_ADD_SUCCESS 4
+#define OCINFO_DEL_SUCCESS 5
+#define OINFO_HELP_1 6
+#define OINFO_HELP_2 7
+#define OINFO_HELP_3 8
+#define OINFO_HELP_4 9
+#define OCINFO_HELP_1 10
+#define OCINFO_HELP_2 11
+#define OCINFO_HELP_3 12
+#define OCINFO_HELP_4 13
+#define OINFO_HELP 14
+#define OCINFO_HELP 15
+
+/*************************************************************************/
+
+char *OSInfoDBName = NULL;
+
+int myAddNickInfo(User * u);
+int myAddChanInfo(User * u);
+int myNickInfo(User * u);
+int myChanInfo(User * u);
+
+int mNickHelp(User * u);
+int mChanHelp(User * u);
+void mMainChanHelp(User * u);
+void mMainNickHelp(User * u);
+void m_AddLanguages(void);
+
+int mLoadData(void);
+int mSaveData(int argc, char **argv);
+int mLoadConfig();
+int mEventReload(int argc, char **argv);
+
+/*************************************************************************/
+
+/**
+ * AnopeInit is called when the module is loaded
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ Command *c;
+ EvtHook *hook = NULL;
+
+ int status;
+
+ moduleAddAuthor(AUTHOR);
+ moduleAddVersion(VERSION);
+ moduleSetType(SUPPORTED);
+
+ alog("os_info: Loading configuration directives...");
+ if (mLoadConfig()) {
+ return MOD_STOP;
+ }
+
+ c = createCommand("oInfo", myAddNickInfo, is_oper, -1, -1, -1, -1, -1);
+ moduleAddHelp(c, mNickHelp);
+ status = moduleAddCommand(NICKSERV, c, MOD_HEAD);
+
+ c = createCommand("Info", myNickInfo, NULL, -1, -1, -1, -1, -1);
+ status = moduleAddCommand(NICKSERV, c, MOD_TAIL);
+
+ c = createCommand("oInfo", myAddChanInfo, is_oper, -1, -1, -1, -1, -1);
+ moduleAddHelp(c, mChanHelp);
+ status = moduleAddCommand(CHANSERV, c, MOD_HEAD);
+
+ c = createCommand("Info", myChanInfo, NULL, -1, -1, -1, -1, -1);
+ status = moduleAddCommand(CHANSERV, c, MOD_TAIL);
+
+ hook = createEventHook(EVENT_DB_SAVING, mSaveData);
+ status = moduleAddEventHook(hook);
+
+ hook = createEventHook(EVENT_RELOAD, mEventReload);
+ status = moduleAddEventHook(hook);
+
+ moduleSetNickHelp(mMainNickHelp);
+ moduleSetChanHelp(mMainChanHelp);
+
+ mLoadData();
+ m_AddLanguages();
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+ if (OSInfoDBName)
+ free(OSInfoDBName);
+}
+
+/*************************************************************************/
+
+/**
+ * Provide the user interface to add/remove/update oper information
+ * about a nick.
+ * We are going to assume that anyone who gets this far is an oper;
+ * the createCommand should have handled this checking for us and its
+ * tedious / a waste to do it twice.
+ * @param u The user who executed this command
+ * @return MOD_CONT if we want to process other commands in this command
+ * stack, MOD_STOP if we dont
+ **/
+int myAddNickInfo(User * u)
+{
+ char *text = NULL;
+ char *cmd = NULL;
+ char *nick = NULL;
+ char *info = NULL;
+ NickAlias *na = NULL;
+
+ /* Get the last buffer anope recived */
+ text = moduleGetLastBuffer();
+ if (text) {
+ cmd = myStrGetToken(text, ' ', 0);
+ nick = myStrGetToken(text, ' ', 1);
+ info = myStrGetTokenRemainder(text, ' ', 2);
+ if (cmd && nick) {
+ if (strcasecmp(cmd, "ADD") == 0) {
+ /* Syntax error, again! */
+ if (info) {
+ /* ok we've found the user */
+ if ((na = findnick(nick))) {
+ /* Add the module data to the user */
+ moduleAddData(&na->nc->moduleData, "info", info);
+ moduleNoticeLang(s_NickServ, u,
+ OINFO_ADD_SUCCESS, nick);
+ /* NickCore not found! */
+ } else {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED,
+ nick);
+ }
+ free(info);
+ }
+ } else if (strcasecmp(cmd, "DEL") == 0) {
+ /* ok we've found the user */
+ if ((na = findnick(nick))) {
+ moduleDelData(&na->nc->moduleData, "info");
+ moduleNoticeLang(s_NickServ, u,
+ OINFO_DEL_SUCCESS, nick);
+ /* NickCore not found! */
+ } else {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED,
+ nick);
+ }
+ /* another syntax error! */
+ } else {
+ moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX);
+ }
+ free(cmd);
+ free(nick);
+ /* Syntax error */
+ } else if (cmd) {
+ moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX);
+ free(cmd);
+ /* Syntax error */
+ } else {
+ moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX);
+ }
+ free(text);
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Provide the user interface to add/remove/update oper information
+ * about a channel.
+ * We are going to assume that anyone who gets this far is an oper;
+ * the createCommand should have handled this checking for us and
+ * its tedious / a waste to do it twice.
+ * @param u The user who executed this command
+ * @return MOD_CONT if we want to process other commands in this command
+ * stack, MOD_STOP if we dont
+ **/
+int myAddChanInfo(User * u)
+{
+ char *text = NULL;
+ char *cmd = NULL;
+ char *chan = NULL;
+ char *info = NULL;
+ ChannelInfo *ci = NULL;
+
+ /* Get the last buffer anope recived */
+ text = moduleGetLastBuffer();
+ if (text) {
+ cmd = myStrGetToken(text, ' ', 0);
+ chan = myStrGetToken(text, ' ', 1);
+ info = myStrGetTokenRemainder(text, ' ', 2);
+ if (cmd && chan) {
+ if (strcasecmp(cmd, "ADD") == 0) {
+ if (info) {
+ if ((ci = cs_findchan(chan))) {
+ /* Add the module data to the channel */
+ moduleAddData(&ci->moduleData, "info", info);
+ moduleNoticeLang(s_ChanServ, u,
+ OCINFO_ADD_SUCCESS, chan);
+ /* ChanInfo */
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED,
+ chan);
+ }
+ free(info);
+ }
+ } else if (strcasecmp(cmd, "DEL") == 0) {
+ if ((ci = cs_findchan(chan))) {
+ /* Del the module data from the channel */
+ moduleDelData(&ci->moduleData, "info");
+ moduleNoticeLang(s_ChanServ, u,
+ OCINFO_DEL_SUCCESS, chan);
+ /* ChanInfo */
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED,
+ chan);
+ }
+ /* another syntax error! */
+ } else {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX);
+ }
+ free(cmd);
+ free(chan);
+ /* Syntax error */
+ } else if (cmd) {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX);
+ free(cmd);
+ /* Syntax error */
+ } else {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX);
+ }
+ free(text);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * Called after a user does a /msg nickserv info [nick]
+ * @param u The user who requested info
+ * @return MOD_CONT to continue processing commands or MOD_STOP to stop
+ **/
+int myNickInfo(User * u)
+{
+ char *text = NULL;
+ char *nick = NULL;
+ NickAlias *na = NULL;
+
+ /* Only show our goodies to opers */
+ if (is_oper(u)) {
+ /* Get the last buffer anope recived */
+ text = moduleGetLastBuffer();
+ if (text) {
+ nick = myStrGetToken(text, ' ', 0);
+ if (nick) {
+ /* ok we've found the user */
+ if ((na = findnick(nick))) {
+ /* If we have any info on this user */
+ if (moduleGetData(&na->nc->moduleData, "info")) {
+ notice_user(s_NickServ, u, " OperInfo: %s",
+ moduleGetData(&na->nc->moduleData,
+ "info"));
+ }
+ /* NickCore not found! */
+ } else {
+ /* we dont care! */
+ }
+ free(nick);
+ }
+ free(text);
+ }
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Called after a user does a /msg chanserv info chan
+ * @param u The user who requested info
+ * @return MOD_CONT to continue processing commands or MOD_STOP to stop
+ **/
+int myChanInfo(User * u)
+{
+ char *text = NULL;
+ char *chan = NULL;
+ ChannelInfo *ci = NULL;
+
+ /* Only show our goodies to opers */
+ if (is_oper(u)) {
+ /* Get the last buffer anope recived */
+ text = moduleGetLastBuffer();
+ if (text) {
+ chan = myStrGetToken(text, ' ', 0);
+ if (chan) {
+ if ((ci = cs_findchan(chan))) {
+ /* If we have any info on this channel */
+ if (moduleGetData(&ci->moduleData, "info")) {
+ notice_user(s_ChanServ, u, " OperInfo: %s",
+ moduleGetData(&ci->moduleData,
+ "info"));
+ }
+ }
+ free(chan);
+ }
+ free(text);
+ }
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * Load data from the db file, and populate our OperInfo lines
+ * @return 0 for success
+ **/
+int mLoadData(void)
+{
+ int ret = 0;
+ FILE *in;
+
+ char *type = NULL;
+ char *name = NULL;
+ char *info = NULL;
+ int len = 0;
+
+ ChannelInfo *ci = NULL;
+ NickAlias *na = NULL;
+
+ /* will _never_ be this big thanks to the 512 limit of a message */
+ char buffer[2000];
+ if ((in = fopen(OSInfoDBName, "r")) == NULL) {
+ alog("os_info: WARNING: can not open the database file! (it might not exist, this is not fatal)");
+ ret = 1;
+ } else {
+ while (!feof(in)) {
+ fgets(buffer, 1500, in);
+ type = myStrGetToken(buffer, ' ', 0);
+ name = myStrGetToken(buffer, ' ', 1);
+ info = myStrGetTokenRemainder(buffer, ' ', 2);
+ if (type) {
+ if (name) {
+ if (info) {
+ len = strlen(info);
+ /* Take the \n from the end of the line */
+ info[len - 1] = '\0';
+ if (stricmp(type, "C") == 0) {
+ if ((ci = cs_findchan(name))) {
+ moduleAddData(&ci->moduleData, "info",
+ info);
+ }
+ } else if (stricmp(type, "N") == 0) {
+ if ((na = findnick(name))) {
+ moduleAddData(&na->nc->moduleData, "info",
+ info);
+ }
+ }
+ free(info);
+ }
+ free(name);
+ }
+ free(type);
+ }
+ }
+ }
+ return ret;
+}
+
+/**
+ * Save all our data to our db file
+ * First walk through the nick CORE list, and any nick core which has
+ * oper info attached to it, write to the file.
+ * Next do the same again for ChannelInfos
+ * @return 0 for success
+ **/
+int mSaveData(int argc, char **argv)
+{
+ ChannelInfo *ci = NULL;
+ NickCore *nc = NULL;
+ int i = 0;
+ int ret = 0;
+ FILE *out;
+
+ if (argc >= 1) {
+ if (!stricmp(argv[0], EVENT_START)) {
+ alog("os_info: Saving the databases has started!");
+ if ((out = fopen(OSInfoDBName, "w")) == NULL) {
+ alog("os_info: ERROR: can not open the database file!");
+ anope_cmd_global(s_OperServ,
+ "os_info: ERROR: can not open the database file!");
+ ret = 1;
+ } else {
+ for (i = 0; i < 1024; i++) {
+ for (nc = nclists[i]; nc; nc = nc->next) {
+ /* If we have any info on this user */
+ if (moduleGetData(&nc->moduleData, "info")) {
+ fprintf(out, "N %s %s\n", nc->display,
+ moduleGetData(&nc->moduleData,
+ "info"));
+ }
+ }
+ }
+
+
+ for (i = 0; i < 256; i++) {
+ for (ci = chanlists[i]; ci; ci = ci->next) {
+ /* If we have any info on this channel */
+ if (moduleGetData(&ci->moduleData, "info")) {
+ fprintf(out, "C %s %s\n", ci->name,
+ moduleGetData(&ci->moduleData,
+ "info"));
+ }
+ }
+ }
+ fclose(out);
+ }
+ } else {
+ alog("os_info: Saving the databases is complete");
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * Load the configuration directives from Services configuration file.
+ * @return 0 for success
+ **/
+int mLoadConfig(void)
+{
+ char *tmp = NULL;
+
+ Directive directivas[] = {
+ {"OSInfoDBName", {{PARAM_SET, PARAM_RELOAD, &tmp}}},
+ };
+
+ Directive *d = &directivas[0];
+ moduleGetConfigDirective(d);
+
+ if (OSInfoDBName)
+ free(OSInfoDBName);
+
+ if (tmp) {
+ OSInfoDBName = tmp;
+ } else {
+ OSInfoDBName = sstrdup(DEFAULT_DB_NAME);
+ alog("os_info: OSInfoDBName is not defined in Services configuration file, using default %s", OSInfoDBName);
+ }
+
+ alog("os_info: Directive OSInfoDBName loaded (%s)...", OSInfoDBName);
+
+ return 0;
+}
+
+/**
+ * Manage the RELOAD EVENT
+ * @return MOD_CONT
+ **/
+int mEventReload(int argc, char **argv)
+{
+ int ret = 0;
+ if (argc >= 1) {
+ if (!stricmp(argv[0], EVENT_START)) {
+ alog("os_info: Reloading configuration directives...");
+ ret = mLoadConfig();
+ } else {
+ /* Nothing for now */
+ }
+ }
+
+ if (ret)
+ alog("os_info.c: ERROR: An error has occured while reloading the configuration file");
+
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * manages the multilanguage stuff
+ **/
+void m_AddLanguages(void)
+{
+ char *langtable_en_us[] = {
+ /* OINFO_SYNTAX */
+ "Syntax: OINFO [ADD|DEL] nick <info>",
+ /* OINFO_ADD_SUCCESS */
+ "OperInfo line has been added to nick %s",
+ /* OINFO_DEL_SUCCESS */
+ "OperInfo line has been removed from nick %s",
+ /* OCINFO_SYNTAX */
+ "Syntax: OINFO [ADD|DEL] chan <info>",
+ /* OCINFO_ADD_SUCCESS */
+ "OperInfo line has been added to channel %s",
+ /* OCINFO_DEL_SUCCESS */
+ "OperInfo line has been removed from channel %s",
+ /* OINFO_HELP_1 */
+ "Syntax: OINFO [ADD|DEL] nick <info>",
+ /* OINFO_HELP_2 */
+ "Add or Delete Oper information for the given nick ",
+ /* OINFO_HELP_3 */
+ "This will show up when any oper /ns info nick's the user.",
+ /* OINFO_HELP_4 */
+ "and can be used for 'tagging' users etc....",
+ /* OCINFO_HELP_1 */
+ "Syntax: OINFO [ADD|DEL] chan <info>",
+ /* OCINFO_HELP_2 */
+ "Add or Delete Oper information for the given channel",
+ /* OCINFO_HELP_3 */
+ "This will show up when any oper /ns info's the channel.",
+ /* OCINFO_HELP_4 */
+ "and can be used for 'tagging' channels etc....",
+ /* OINFO_HELP */
+ " OINFO Add / Del an OperInfo line to a nick",
+ /* OCINFO_HELP */
+ " OINFO Add / Del an OperInfo line to a channel"
+ };
+
+ char *langtable_es[] = {
+ /* OINFO_SYNTAX */
+ "Sintaxis: OINFO [ADD|DEL] nick <info>",
+ /* OINFO_ADD_SUCCESS */
+ "Una linea OperInfo ha sido agregada al nick %s",
+ /* OINFO_DEL_SUCCESS */
+ "La linea OperInfo ha sido removida del nick %s",
+ /* OCINFO_SYNTAX */
+ "Sintaxis: OINFO [ADD|DEL] chan <info>",
+ /* OCINFO_ADD_SUCCESS */
+ "Linea OperInfo ha sido agregada al canal %s",
+ /* OCINFO_DEL_SUCCESS */
+ "La linea OperInfo ha sido removida del canal %s",
+ /* OINFO_HELP_1 */
+ "Sintaxis: OINFO [ADD|DEL] nick <info>",
+ /* OINFO_HELP_2 */
+ "Agrega o elimina informacion para Operadores al nick dado",
+ /* OINFO_HELP_3 */
+ "Esto se mostrara cuando cualquier operador haga /ns info nick",
+ /* OINFO_HELP_4 */
+ "y puede ser usado para 'marcado' de usuarios, etc....",
+ /* OCINFO_HELP_1 */
+ "Sintaxis: OINFO [ADD|DEL] chan <info>",
+ /* OCINFO_HELP_2 */
+ "Agrega o elimina informacion para Operadores al canal dado",
+ /* OCINFO_HELP_3 */
+ "Esto se mostrara cuando cualquier operador haga /cs info canal",
+ /* OCINFO_HELP_4 */
+ "y puede ser usado para 'marcado' de canales, etc....",
+ /* OINFO_HELP */
+ " OINFO Agrega / Elimina una linea OperInfo al nick",
+ /* OCINFO_HELP */
+ " OINFO Agrega / Elimina una linea OperInfo al canal"
+ };
+
+ moduleInsertLanguage(LANG_EN_US, LANG_NUM_STRINGS, langtable_en_us);
+ moduleInsertLanguage(LANG_ES, LANG_NUM_STRINGS, langtable_es);
+}
+
+/*************************************************************************/
+
+int mNickHelp(User * u)
+{
+ if (is_oper(u)) {
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP_1);
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP_2);
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP_3);
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP_4);
+ } else {
+ notice_lang(s_NickServ, u, NO_HELP_AVAILABLE, "OINFO");
+ }
+ return MOD_CONT;
+}
+
+int mChanHelp(User * u)
+{
+ if (is_oper(u)) {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_1);
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_2);
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_3);
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_4);
+ } else {
+ notice_lang(s_ChanServ, u, NO_HELP_AVAILABLE, "OINFO");
+ }
+ return MOD_CONT;
+}
+
+/* This help will be added to the main NickServ list */
+void mMainNickHelp(User * u)
+{
+ if (is_oper(u)) {
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP);
+ }
+}
+
+/* This help will be added to the main NickServ list */
+void mMainChanHelp(User * u)
+{
+ if (is_oper(u)) {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP);
+ }
+}
+
+/*************************************************************************/
+
+/* EOF */
diff --git a/src/news.c b/src/news.c
index a85fbe4fa..1ea907226 100644
--- a/src/news.c
+++ b/src/news.c
@@ -321,7 +321,6 @@ void display_news(User * u, int16 type)
/*************************************************************************/
/***************************** News editing ******************************/
/*************************************************************************/
-
/* Declared in extern.h */
int do_logonnews(User * u)
{
@@ -329,6 +328,7 @@ int do_logonnews(User * u)
return MOD_CONT;
}
+
/* Declared in extern.h */
int do_opernews(User * u)
{
diff --git a/src/nickserv.c b/src/nickserv.c
index 76dfcf21f..ac0cdd0ae 100644
--- a/src/nickserv.c
+++ b/src/nickserv.c
@@ -36,111 +36,21 @@ extern char *getvHost(char *nick);
void alpha_insert_alias(NickAlias * na);
void insert_core(NickCore * nc);
void insert_requestnick(NickRequest * nr);
-static NickAlias *makenick(const char *nick);
-static NickRequest *makerequest(const char *nick);
-static NickAlias *makealias(const char *nick, NickCore * nc);
-static void change_core_display(NickCore * nc, char *newdisplay);
+void change_core_display(NickCore * nc, char *newdisplay);
-static void collide(NickAlias * na, int from_timeout);
-static void release(NickAlias * na, int from_timeout);
+void collide(NickAlias * na, int from_timeout);
+void release(NickAlias * na, int from_timeout);
static void add_ns_timeout(NickAlias * na, int type, time_t delay);
-static void del_ns_timeout(NickAlias * na, int type);
+void del_ns_timeout(NickAlias * na, int type);
int delnickrequest(NickRequest * nr);
NickRequest *findrequestnick(const char *nick);
-static int do_sendregmail(User * u, NickRequest * nr);
-static int do_setmodes(User * u);
-
-static int do_help(User * u);
-static int do_register(User * u);
-static int do_confirm(User * u);
-static int do_group(User * u);
-static int do_nickupdate(User * u);
-static int do_identify(User * u);
-static int do_logout(User * u);
-static int do_drop(User * u);
-static int do_set(User * u);
-static int do_set_display(User * u, NickCore * nc, char *param);
-static int do_set_password(User * u, NickCore * nc, char *param);
-static int do_set_language(User * u, NickCore * nc, char *param);
-static int do_set_url(User * u, NickCore * nc, char *param);
-static int do_set_email(User * u, NickCore * nc, char *param);
-static int do_set_greet(User * u, NickCore * nc, char *param);
-static int do_set_icq(User * u, NickCore * nc, char *param);
-static int do_set_kill(User * u, NickCore * nc, char *param);
-static int do_set_secure(User * u, NickCore * nc, char *param);
-static int do_set_private(User * u, NickCore * nc, char *param);
-static int do_set_msg(User * u, NickCore * nc, char *param);
-static int do_set_hide(User * u, NickCore * nc, char *param);
-static int do_set_noexpire(User * u, NickAlias * nc, char *param);
-static int do_access(User * u);
-static int do_info(User * u);
-static int do_list(User * u);
-static int do_alist(User * u);
-static int do_glist(User * u);
-static int do_recover(User * u);
-static int do_release(User * u);
-static int do_ghost(User * u);
-static int do_status(User * u);
-static int do_getpass(User * u);
-static int do_getemail(User * u);
-static int do_sendpass(User * u);
-static int do_forbid(User * u);
-static int do_resend(User * u);
-static int do_suspend(User * u);
-static int do_unsuspend(User * u);
-
-/* Obsolete commands */
-static int do_link(User * u);
-static int do_unlink(User * u);
-static int do_listlinks(User * u);
+int do_setmodes(User * u);
/*************************************************************************/
/* *INDENT-OFF* */
void moduleAddNickServCmds(void) {
- Command *c;
- c = createCommand("HELP", do_help, NULL, -1, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("REGISTER", do_register, NULL, NICK_HELP_REGISTER, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("RESEND", do_resend, NULL, -1, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("CONFIRM", do_confirm, NULL, -1, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("GROUP", do_group, NULL, NICK_HELP_GROUP, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("UPDATE", do_nickupdate, NULL, NICK_HELP_UPDATE, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("ID", do_identify, NULL, NICK_HELP_IDENTIFY, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("IDENTIFY", do_identify, NULL, NICK_HELP_IDENTIFY, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SIDENTIFY",do_identify, NULL, -1, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("LOGOUT", do_logout, NULL, -1,NICK_HELP_LOGOUT, -1,NICK_SERVADMIN_HELP_LOGOUT, NICK_SERVADMIN_HELP_LOGOUT); addCoreCommand(NICKSERV,c);
- c = createCommand("DROP", do_drop, NULL, -1,NICK_HELP_DROP, -1,NICK_SERVADMIN_HELP_DROP, NICK_SERVADMIN_HELP_DROP); addCoreCommand(NICKSERV,c);
- c = createCommand("LINK", do_link, NULL, -1, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("UNLINK", do_unlink, NULL, -1, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("LISTLINKS",do_listlinks, NULL, -1, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("ACCESS", do_access, NULL, NICK_HELP_ACCESS, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET", do_set, NULL, NICK_HELP_SET,-1, -1,NICK_SERVADMIN_HELP_SET, NICK_SERVADMIN_HELP_SET); addCoreCommand(NICKSERV,c);
- c = createCommand("SET DISPLAY", NULL, NULL, NICK_HELP_SET_DISPLAY, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET PASSWORD", NULL, NULL, NICK_HELP_SET_PASSWORD, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET URL", NULL, NULL, NICK_HELP_SET_URL, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET EMAIL", NULL, NULL, NICK_HELP_SET_EMAIL, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET ICQ", NULL, NULL, NICK_HELP_SET_ICQ, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET GREET", NULL, NULL, NICK_HELP_SET_GREET, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET KILL", NULL, NULL, NICK_HELP_SET_KILL, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET SECURE", NULL, NULL, NICK_HELP_SET_SECURE, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET PRIVATE", NULL, NULL, NICK_HELP_SET_PRIVATE, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET MSG", NULL, NULL, NICK_HELP_SET_MSG, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET HIDE", NULL, NULL, NICK_HELP_SET_HIDE, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SET NOEXPIRE", NULL, NULL, -1, -1,-1,NICK_SERVADMIN_HELP_SET_NOEXPIRE,NICK_SERVADMIN_HELP_SET_NOEXPIRE); addCoreCommand(NICKSERV,c);
- c = createCommand("RECOVER", do_recover, NULL, NICK_HELP_RECOVER, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("RELEASE", do_release, NULL, NICK_HELP_RELEASE, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("GHOST", do_ghost, NULL, NICK_HELP_GHOST, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("INFO", do_info, NULL, NICK_HELP_INFO,-1, NICK_HELP_INFO, NICK_SERVADMIN_HELP_INFO,NICK_SERVADMIN_HELP_INFO); addCoreCommand(NICKSERV,c);
- c = createCommand("LIST", do_list, NULL, -1,NICK_HELP_LIST, -1,NICK_SERVADMIN_HELP_LIST, NICK_SERVADMIN_HELP_LIST); addCoreCommand(NICKSERV,c);
- c = createCommand("ALIST", do_alist, NULL, -1,NICK_HELP_ALIST, -1,NICK_SERVADMIN_HELP_ALIST, NICK_SERVADMIN_HELP_ALIST); addCoreCommand(NICKSERV,c);
- c = createCommand("GLIST", do_glist, NULL, -1,NICK_HELP_GLIST, -1,NICK_SERVADMIN_HELP_GLIST, NICK_SERVADMIN_HELP_GLIST); addCoreCommand(NICKSERV,c);
- c = createCommand("STATUS", do_status, NULL, NICK_HELP_STATUS, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("SENDPASS", do_sendpass, NULL, NICK_HELP_SENDPASS, -1,-1,-1,-1); addCoreCommand(NICKSERV,c);
- c = createCommand("GETPASS", do_getpass, is_services_admin, -1,-1, -1,NICK_SERVADMIN_HELP_GETPASS, NICK_SERVADMIN_HELP_GETPASS); addCoreCommand(NICKSERV,c);
- c = createCommand("GETEMAIL", do_getemail, is_services_admin, -1,-1, -1,NICK_SERVADMIN_HELP_GETEMAIL, NICK_SERVADMIN_HELP_GETEMAIL); addCoreCommand(NICKSERV,c);
- c = createCommand("FORBID", do_forbid, is_services_admin, -1,-1, -1,NICK_SERVADMIN_HELP_FORBID, NICK_SERVADMIN_HELP_FORBID); addCoreCommand(NICKSERV,c);
- c = createCommand("SUSPEND", do_suspend, is_services_admin, -1,-1, -1,NICK_SERVADMIN_HELP_SUSPEND, NICK_SERVADMIN_HELP_SUSPEND); addCoreCommand(NICKSERV,c);
- c = createCommand("UNSUSPEND",do_unsuspend,is_services_admin, -1,-1, -1,NICK_SERVADMIN_HELP_UNSUSPEND, NICK_SERVADMIN_HELP_UNSUSPEND); addCoreCommand(NICKSERV,c);
+ modules_core_init(NickServCoreNumber, NickServCoreModules);
}
/* *INDENT-ON* */
/*************************************************************************/
@@ -1240,7 +1150,7 @@ void expire_nicks()
(na->nc->email ? na->nc->email : "none"));
tmpnick = sstrdup(na->nick);
delnick(na);
- send_event(EVENT_NICK_EXPIRE, tmpnick);
+ send_event(EVENT_NICK_EXPIRE, 1, tmpnick);
free(tmpnick);
}
}
@@ -1451,67 +1361,12 @@ void insert_requestnick(NickRequest * nr)
}
/*************************************************************************/
-/* Creates a new Nick Request */
-static NickRequest *makerequest(const char *nick)
-{
- NickRequest *nr;
-
- nr = scalloc(1, sizeof(NickRequest));
- nr->nick = sstrdup(nick);
- insert_requestnick(nr);
- alog("%s: Nick %s has been requested", s_NickServ, nr->nick);
- return nr;
-}
-
-
-
-/* Creates a full new nick (alias + core) in NickServ database. */
-
-static NickAlias *makenick(const char *nick)
-{
- NickAlias *na;
- NickCore *nc;
-
- /* First make the core */
- nc = scalloc(1, sizeof(NickCore));
- nc->display = sstrdup(nick);
- slist_init(&nc->aliases);
- insert_core(nc);
- alog("%s: group %s has been created", s_NickServ, nc->display);
-
- /* Then make the alias */
- na = scalloc(1, sizeof(NickAlias));
- na->nick = sstrdup(nick);
- na->nc = nc;
- slist_add(&nc->aliases, na);
- alpha_insert_alias(na);
- return na;
-}
-
-/*************************************************************************/
-
-/* Creates a new alias in NickServ database. */
-
-static NickAlias *makealias(const char *nick, NickCore * nc)
-{
- NickAlias *na;
-
- /* Just need to make the alias */
- na = scalloc(1, sizeof(NickAlias));
- na->nick = sstrdup(nick);
- na->nc = nc;
- slist_add(&nc->aliases, na);
- alpha_insert_alias(na);
- return na;
-}
-
-/*************************************************************************/
/* Sets nc->display to newdisplay. If newdisplay is NULL, it will change
* it to the first alias in the list.
*/
-static void change_core_display(NickCore * nc, char *newdisplay)
+void change_core_display(NickCore * nc, char *newdisplay)
{
if (!newdisplay) {
NickAlias *na;
@@ -1745,7 +1600,7 @@ int delnick(NickAlias * na)
* This is watched for and done in cancel_user(). -TheShadow
*/
-static void collide(NickAlias * na, int from_timeout)
+void collide(NickAlias * na, int from_timeout)
{
char guestnick[NICKMAX];
@@ -1779,7 +1634,7 @@ static void collide(NickAlias * na, int from_timeout)
/* Release hold on a nick. */
-static void release(NickAlias * na, int from_timeout)
+void release(NickAlias * na, int from_timeout)
{
if (!from_timeout)
del_ns_timeout(na, TO_RELEASE);
@@ -1905,7 +1760,7 @@ void add_ns_timeout(NickAlias * na, int type, time_t delay)
/* Delete a collide/release timeout. */
-static void del_ns_timeout(NickAlias * na, int type)
+void del_ns_timeout(NickAlias * na, int type)
{
struct my_timeout *t, *t2;
@@ -1962,675 +1817,6 @@ void clean_ns_timeouts(NickAlias * na)
/*************************************************************************/
/*********************** NickServ command routines ***********************/
/*************************************************************************/
-
-/* Return a help message. */
-
-static int do_help(User * u)
-{
- char *cmd = strtok(NULL, "");
-
- if (!cmd) {
- notice_help(s_NickServ, u, NICK_HELP);
- if (NSExpire >= 86400)
- notice_help(s_NickServ, u, NICK_HELP_EXPIRES,
- NSExpire / 86400);
- if (is_services_oper(u))
- notice_help(s_NickServ, u, NICK_SERVADMIN_HELP);
- moduleDisplayHelp(1, u);
- } else if (stricmp(cmd, "SET LANGUAGE") == 0) {
- int i;
- notice_help(s_NickServ, u, NICK_HELP_SET_LANGUAGE);
- for (i = 0; i < NUM_LANGS && langlist[i] >= 0; i++)
- notice_user(s_NickServ, u, " %2d) %s", i + 1,
- langnames[langlist[i]]);
- } else {
- mod_help_cmd(s_NickServ, u, NICKSERV, cmd);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Register a nick. */
-
-static int do_register(User * u)
-{
- NickRequest *nr = NULL, *anr = NULL;
- NickCore *nc = NULL;
- int prefixlen = strlen(NSGuestNickPrefix);
- int nicklen = strlen(u->nick);
- char *pass = strtok(NULL, " ");
- char *email = strtok(NULL, " ");
- char passcode[11];
- int idx, min = 1, max = 62, i = 0;
- int chars[] =
- { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
- 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
- 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
- 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
- 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
- };
-
- if (readonly) {
- notice_lang(s_NickServ, u, NICK_REGISTRATION_DISABLED);
- return MOD_CONT;
- }
-
- if (checkDefCon(DEFCON_NO_NEW_NICKS)) {
- notice_lang(s_NickServ, u, OPER_DEFCON_DENIED);
- return MOD_CONT;
- }
-
- if (!is_oper(u) && NickRegDelay
- && ((time(NULL) - u->my_signon) < NickRegDelay)) {
- notice_lang(s_NickServ, u, NICK_REG_DELAY, NickRegDelay);
- return MOD_CONT;
- }
-
- if ((anr = findrequestnick(u->nick))) {
- notice_lang(s_NickServ, u, NICK_REQUESTED);
- return MOD_CONT;
- }
- /* Prevent "Guest" nicks from being registered. -TheShadow */
-
- /* Guest nick can now have a series of between 1 and 7 digits.
- * --lara
- */
- if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 &&
- stristr(u->nick, NSGuestNickPrefix) == u->nick &&
- strspn(u->nick + prefixlen, "1234567890") == nicklen - prefixlen) {
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick);
- return MOD_CONT;
- }
-
- if (RestrictOperNicks) {
- for (i = 0; i < RootNumber; i++) {
- if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) {
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
- u->nick);
- return MOD_CONT;
- }
- }
- for (i = 0; i < servadmins.count && (nc = servadmins.list[i]); i++) {
- if (stristr(u->nick, nc->display) && !is_oper(u)) {
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
- u->nick);
- return MOD_CONT;
- }
- }
- for (i = 0; i < servopers.count && (nc = servopers.list[i]); i++) {
- if (stristr(u->nick, nc->display) && !is_oper(u)) {
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
- u->nick);
- return MOD_CONT;
- }
- }
- }
-
- if (!pass) {
- if (NSForceEmail) {
- syntax_error(s_NickServ, u, "REGISTER",
- NICK_REGISTER_SYNTAX_EMAIL);
- } else {
- syntax_error(s_NickServ, u, "REGISTER", NICK_REGISTER_SYNTAX);
- }
- } else if (NSForceEmail && !email) {
- syntax_error(s_NickServ, u, "REGISTER",
- NICK_REGISTER_SYNTAX_EMAIL);
- } else if (time(NULL) < u->lastnickreg + NSRegDelay) {
- notice_lang(s_NickServ, u, NICK_REG_PLEASE_WAIT, NSRegDelay);
- } else if (u->na) { /* i.e. there's already such a nick regged */
- if (u->na->status & NS_VERBOTEN) {
- alog("%s: %s@%s tried to register FORBIDden nick %s",
- s_NickServ, u->username, u->host, u->nick);
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick);
- } else {
- notice_lang(s_NickServ, u, NICK_ALREADY_REGISTERED, u->nick);
- }
- } else if (stricmp(u->nick, pass) == 0
- || (StrictPasswords && strlen(pass) < 5)) {
- notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD);
- } else if (email && !MailValidate(email)) {
- notice_lang(s_NickServ, u, MAIL_X_INVALID, email);
- } else {
-#ifdef USE_ENCRYPTION
- if (strlen(pass) > PASSMAX) {
- pass[PASSMAX] = 0;
- notice_lang(s_NickServ, u, PASSWORD_TRUNCATED, PASSMAX);
- }
-#else
- if (strlen(pass) > PASSMAX - 1) { /* -1 for null byte */
- pass[PASSMAX] = 0;
- notice_lang(s_NickServ, u, PASSWORD_TRUNCATED, PASSMAX - 1);
- }
-#endif
- for (idx = 0; idx < 9; idx++) {
- passcode[idx] =
- chars[(1 +
- (int) (((float) (max - min)) * getrandom16() /
- (65535 + 1.0)) + min)];
- } passcode[idx] = '\0';
- nr = makerequest(u->nick);
- nr->passcode = sstrdup(passcode);
- nr->password = sstrdup(pass);
- if (email) {
- nr->email = sstrdup(email);
- }
- nr->requested = time(NULL);
- if (NSEmailReg) {
- if (do_sendregmail(u, nr) == 0) {
- notice_lang(s_NickServ, u, NICK_ENTER_REG_CODE, email,
- s_NickServ);
- alog("%s: sent registration verification code to %s",
- s_NickServ, nr->email);
- } else {
- alog("%s: Unable to send registration verification mail",
- s_NickServ);
- notice_lang(s_NickServ, u, NICK_REG_UNABLE);
- delnickrequest(nr); /* Delete the NickRequest if we couldnt send the mail */
- return MOD_CONT;
- }
- } else {
- do_confirm(u);
- }
-
- }
- return MOD_CONT;
-}
-
-
-static int do_resend(User * u)
-{
- NickRequest *nr = NULL;
- if (NSEmailReg) {
- if ((nr = findrequestnick(u->nick))) {
- if (do_sendregmail(u, nr) == 0) {
- notice_lang(s_NickServ, u, NICK_REG_RESENT, nr->email);
- alog("%s: re-sent registration verification code for %s to %s", s_NickServ, nr->nick, nr->email);
- } else {
- alog("%s: Unable to re-send registration verification mail for %s", s_NickServ, nr->nick);
- return MOD_CONT;
- }
- }
- }
- return MOD_CONT;
-}
-
-static int do_sendregmail(User * u, NickRequest * nr)
-{
- MailInfo *mail = NULL;
- char buf[BUFSIZE];
-
- if (!(nr || u)) {
- return -1;
- }
- snprintf(buf, sizeof(buf), getstring2(NULL, NICK_REG_MAIL_SUBJECT),
- nr->nick);
- mail = MailRegBegin(u, nr, buf, s_NickServ);
- if (!mail) {
- return -1;
- }
- fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_HEAD));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_1), nr->nick);
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_2), s_NickServ,
- nr->passcode);
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_3));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_4));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_5),
- NetworkName);
- fprintf(mail->pipe, "\n.\n");
- MailEnd(mail);
- return 0;
-}
-
-static int do_confirm(User * u)
-{
-
- NickRequest *nr = NULL;
- NickAlias *na = NULL;
- char *passcode = strtok(NULL, " ");
- char *pass = NULL;
- char *email = NULL;
- int forced = 0;
- User *utmp = NULL;
-#ifdef USE_ENCRYPTION
- int len;
-#endif
- nr = findrequestnick(u->nick);
-
- if (NSEmailReg) {
- if (!passcode) {
- notice_lang(s_NickServ, u, NICK_CONFIRM_INVALID);
- return MOD_CONT;
- }
-
- if (!nr) {
- if (is_services_admin(u)) {
-/* If an admin, thier nick is obviously already regged, so look at the passcode to get the nick
- of the user they are trying to validate, and push that user through regardless of passcode */
- nr = findrequestnick(passcode);
- if (nr) {
- utmp = finduser(passcode);
- if (utmp) {
- sprintf(passcode,
- "FORCE_ACTIVATION_DUE_TO_OPER_CONFIRM %s",
- nr->passcode);
- passcode = strtok(passcode, " ");
- notice_lang(s_NickServ, u, NICK_FORCE_REG,
- nr->nick);
- do_confirm(utmp);
- return MOD_CONT;
- } else {
- passcode = sstrdup(nr->passcode);
- forced = 1;
- }
- } else {
- notice_lang(s_NickServ, u, NICK_CONFIRM_NOT_FOUND,
- s_NickServ);
- return MOD_CONT;
- }
- } else {
- notice_lang(s_NickServ, u, NICK_CONFIRM_NOT_FOUND,
- s_NickServ);
- return MOD_CONT;
- }
- }
-
- if (stricmp(nr->passcode, passcode) != 0) {
- notice_lang(s_NickServ, u, NICK_CONFIRM_INVALID);
- return MOD_CONT;
- }
- }
-
- if (!nr) {
- notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED);
- return MOD_CONT;
- }
- pass = sstrdup(nr->password);
-
- if (nr->email) {
- email = sstrdup(nr->email);
- }
- na = makenick(nr->nick);
-
- if (na) {
- int i;
- char tsbuf[16];
-
-#ifdef USE_ENCRYPTION
- len = strlen(pass);
- na->nc->pass = smalloc(PASSMAX);
- if (encrypt(pass, len, na->nc->pass, PASSMAX) < 0) {
- memset(pass, 0, strlen(pass));
- alog("%s: Failed to encrypt password for %s (register)",
- s_NickServ, nr->nick);
- notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED);
- return MOD_CONT;
- }
- memset(pass, 0, strlen(pass));
- na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED);
- na->nc->flags |= NI_ENCRYPTEDPW;
-#else
- na->nc->pass = sstrdup(pass);
- na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED);
-#endif
- na->nc->flags |= NSDefFlags;
- for (i = 0; i < RootNumber; i++) {
- if (!stricmp(ServicesRoots[i], nr->nick)) {
- na->nc->flags |= NI_SERVICES_ROOT;
- break;
- }
- }
- na->nc->memos.memomax = MSMaxMemos;
- na->nc->channelmax = CSMaxReg;
- if (forced == 1) {
- na->last_usermask = sstrdup("*@*");
- na->last_realname = sstrdup("unknown");
- } else {
- na->last_usermask =
- scalloc(strlen(common_get_vident(u)) +
- strlen(common_get_vhost(u)) + 2, 1);
- sprintf(na->last_usermask, "%s@%s", common_get_vident(u),
- common_get_vhost(u));
- na->last_realname = sstrdup(u->realname);
- }
- na->time_registered = na->last_seen = time(NULL);
- if (NSAddAccessOnReg) {
- na->nc->accesscount = 1;
- na->nc->access = scalloc(sizeof(char *), 1);
- na->nc->access[0] = create_mask(u);
- } else {
- na->nc->accesscount = 0;
- na->nc->access = NULL;
- }
- na->nc->language = NSDefLanguage;
- if (email)
- na->nc->email = sstrdup(email);
- if (forced != 1) {
- u->na = na;
- na->u = u;
- alog("%s: '%s' registered by %s@%s (e-mail: %s)", s_NickServ,
- u->nick, u->username, u->host, (email ? email : "none"));
- if (NSAddAccessOnReg)
- notice_lang(s_NickServ, u, NICK_REGISTERED, u->nick,
- na->nc->access[0]);
- else
- notice_lang(s_NickServ, u, NICK_REGISTERED_NO_MASK,
- u->nick);
- send_event(EVENT_NICK_REGISTERED, u->nick);
-#ifndef USE_ENCRYPTION
- notice_lang(s_NickServ, u, NICK_PASSWORD_IS, na->nc->pass);
-#endif
- u->lastnickreg = time(NULL);
- if (ircd->modeonreg) {
- if (ircd->tsonmode) {
- snprintf(tsbuf, sizeof(tsbuf), "%lu",
- (unsigned long int) u->timestamp);
- common_svsmode(u, ircd->modeonreg, tsbuf);
- } else {
- common_svsmode(u, ircd->modeonreg, NULL);
- }
- }
-
- } else {
- notice_lang(s_NickServ, u, NICK_FORCE_REG, nr->nick);
- }
- delnickrequest(nr); /* remove the nick request */
- } else {
- alog("%s: makenick(%s) failed", s_NickServ, u->nick);
- notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED);
- }
-
- /* Enable nick tracking if enabled */
- if (NSNickTracking)
- nsStartNickTracking(u);
-
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Register a nick in a specified group. */
-
-static int do_group(User * u)
-{
- NickAlias *na, *target;
- NickCore *nc;
- char *nick = strtok(NULL, " ");
- char *pass = strtok(NULL, " ");
- int i;
- char tsbuf[16];
-
- if (NSEmailReg && (findrequestnick(u->nick))) {
- notice_lang(s_NickServ, u, NICK_REQUESTED);
- return MOD_CONT;
- }
-
- if (readonly) {
- notice_lang(s_NickServ, u, NICK_GROUP_DISABLED);
- return MOD_CONT;
- }
- if (checkDefCon(DEFCON_NO_NEW_NICKS)) {
- notice_lang(s_NickServ, u, OPER_DEFCON_DENIED);
- return MOD_CONT;
- }
-
- if (RestrictOperNicks) {
- for (i = 0; i < RootNumber; i++) {
- if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) {
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
- u->nick);
- return MOD_CONT;
- }
- }
- for (i = 0; i < servadmins.count && (nc = servadmins.list[i]); i++) {
- if (stristr(u->nick, nc->display) && !is_oper(u)) {
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
- u->nick);
- return MOD_CONT;
- }
- }
- for (i = 0; i < servopers.count && (nc = servopers.list[i]); i++) {
- if (stristr(u->nick, nc->display) && !is_oper(u)) {
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
- u->nick);
- return MOD_CONT;
- }
- }
- }
-
- if (!nick || !pass) {
- syntax_error(s_NickServ, u, "GROUP", NICK_GROUP_SYNTAX);
- } else if (time(NULL) < u->lastnickreg + NSRegDelay) {
- notice_lang(s_NickServ, u, NICK_GROUP_PLEASE_WAIT, NSRegDelay);
- } else if (u->na && (u->na->status & NS_VERBOTEN)) {
- alog("%s: %s@%s tried to use GROUP from FORBIDden nick %s",
- s_NickServ, u->username, u->host, u->nick);
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u->nick);
- } else if (u->na && (u->na->nc->flags & NI_SUSPENDED)) {
- alog("%s: %s@%s tried to use GROUP from SUSPENDED nick %s",
- s_NickServ, u->username, u->host, u->nick);
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick);
- } else if (u->na && NSNoGroupChange) {
- notice_lang(s_NickServ, u, NICK_GROUP_CHANGE_DISABLED, s_NickServ);
- } else if (u->na && !nick_identified(u)) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else if (!(target = findnick(nick))) {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- } else if (target && (target->nc->flags & NI_SUSPENDED)) {
- alog("%s: %s@%s tried to use GROUP from SUSPENDED nick %s",
- s_NickServ, u->username, u->host, u->nick);
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, target->nick);
- } else if (target->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
- } else if (u->na && target->nc == u->na->nc) {
- notice_lang(s_NickServ, u, NICK_GROUP_SAME, target->nick);
- } else if (NSMaxAliases && (target->nc->aliases.count >= NSMaxAliases)
- && !nick_is_services_admin(target->nc)) {
- notice_lang(s_NickServ, u, NICK_GROUP_TOO_MANY, target->nick,
- s_NickServ, s_NickServ);
- } else if (check_password(pass, target->nc->pass) != 1) {
- alog("%s: Failed GROUP for %s!%s@%s (invalid password)",
- s_NickServ, u->nick, u->username, u->host);
- notice_lang(s_NickServ, u, PASSWORD_INCORRECT);
- bad_password(u);
- } else {
- /* If the nick is already registered, drop it.
- * If not, check that it is valid.
- */
- if (u->na) {
- delnick(u->na);
- } else {
- int prefixlen = strlen(NSGuestNickPrefix);
- int nicklen = strlen(u->nick);
-
- if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1
- && stristr(u->nick, NSGuestNickPrefix) == u->nick
- && strspn(u->nick + prefixlen,
- "1234567890") == nicklen - prefixlen) {
- notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED,
- u->nick);
- return MOD_CONT;
- }
- }
- na = makealias(u->nick, target->nc);
-
- if (na) {
- na->last_usermask =
- scalloc(strlen(common_get_vident(u)) +
- strlen(common_get_vhost(u)) + 2, 1);
- sprintf(na->last_usermask, "%s@%s", common_get_vident(u),
- common_get_vhost(u));
- na->last_realname = sstrdup(u->realname);
- na->time_registered = na->last_seen = time(NULL);
- na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED);
-
- if (!(na->nc->flags & NI_SERVICES_ROOT)) {
- for (i = 0; i < RootNumber; i++) {
- if (!stricmp(ServicesRoots[i], u->nick)) {
- na->nc->flags |= NI_SERVICES_ROOT;
- break;
- }
- }
- }
-
- u->na = na;
- na->u = u;
-
-#ifdef USE_RDB
- /* Is this really needed? Since this is a new alias it will get
- * its unique id on the next update, since it was previously
- * deleted by delnick. Must observe...
- */
- if (rdb_open()) {
- rdb_save_ns_alias(na);
- rdb_close();
- }
-#endif
- send_event(EVENT_GROUP, u->nick);
- alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, u->nick, target->nick, target->nc->display, (target->nc->email ? target->nc->email : "none"));
- notice_lang(s_NickServ, u, NICK_GROUP_JOINED, target->nick);
-
- u->lastnickreg = time(NULL);
- snprintf(tsbuf, sizeof(tsbuf), "%lu",
- (unsigned long int) u->timestamp);
- if (ircd->modeonreg) {
- if (ircd->tsonmode) {
- common_svsmode(u, ircd->modeonreg, tsbuf);
- } else {
- common_svsmode(u, ircd->modeonreg, NULL);
- }
- }
-
- check_memos(u);
- } else {
- alog("%s: makealias(%s) failed", s_NickServ, u->nick);
- notice_lang(s_NickServ, u, NICK_GROUP_FAILED);
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_nickupdate(User * u)
-{
- NickAlias *na;
-
- if (!nick_identified(u)) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else {
- na = u->na;
- if (NSModeOnID)
- do_setmodes(u);
- check_memos(u);
- if (na->last_realname)
- free(na->last_realname);
- na->last_realname = sstrdup(u->realname);
- na->status |= NS_IDENTIFIED;
- na->last_seen = time(NULL);
- if (ircd->vhost) {
- do_on_id(u);
- }
- notice_lang(s_NickServ, u, NICK_UPDATE_SUCCESS, s_NickServ);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_identify(User * u)
-{
- char *pass = strtok(NULL, " ");
- NickAlias *na;
- NickRequest *nr;
- int res;
- char tsbuf[16];
-
- if (!pass) {
- syntax_error(s_NickServ, u, "IDENTIFY", NICK_IDENTIFY_SYNTAX);
- } else if (!(na = u->na)) {
- if ((nr = findrequestnick(u->nick))) {
- notice_lang(s_NickServ, u, NICK_IS_PREREG);
- } else {
- notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
- }
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else if (na->nc->flags & NI_SUSPENDED) {
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
- } else if (nick_identified(u)) {
- notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED);
- } else if (!(res = check_password(pass, na->nc->pass))) {
- alog("%s: Failed IDENTIFY for %s!%s@%s", s_NickServ, u->nick,
- u->username, u->host);
- notice_lang(s_NickServ, u, PASSWORD_INCORRECT);
- bad_password(u);
- } else if (res == -1) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_FAILED);
- } else {
- if (!(na->status & NS_IDENTIFIED) && !(na->status & NS_RECOGNIZED)) {
- if (na->last_usermask)
- free(na->last_usermask);
- na->last_usermask =
- scalloc(strlen(common_get_vident(u)) +
- strlen(common_get_vhost(u)) + 2, 1);
- sprintf(na->last_usermask, "%s@%s", common_get_vident(u),
- common_get_vhost(u));
- if (na->last_realname)
- free(na->last_realname);
- na->last_realname = sstrdup(u->realname);
- }
-
- na->status |= NS_IDENTIFIED;
- na->last_seen = time(NULL);
- snprintf(tsbuf, sizeof(tsbuf), "%lu",
- (unsigned long int) u->timestamp);
-
- if (ircd->modeonreg) {
- if (ircd->tsonmode) {
- common_svsmode(u, ircd->modeonreg, tsbuf);
- } else {
- common_svsmode(u, ircd->modeonreg, "");
- }
- }
- send_event(EVENT_NICK_IDENTIFY, u->nick);
- alog("%s: %s!%s@%s identified for nick %s", s_NickServ, u->nick,
- u->username, u->host, u->nick);
- notice_lang(s_NickServ, u, NICK_IDENTIFY_SUCCEEDED);
- if (ircd->vhost) {
- do_on_id(u);
- }
- if (NSModeOnID) {
- do_setmodes(u);
- }
-
- if (NSForceEmail && u->na && !u->na->nc->email) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_EMAIL_REQUIRED);
- notice_help(s_NickServ, u, NICK_IDENTIFY_EMAIL_HOWTO);
- }
-
- if (!(na->status & NS_RECOGNIZED))
- check_memos(u);
-
- /* Enable nick tracking if enabled */
- if (NSNickTracking)
- nsStartNickTracking(u);
-
- /* Clear any timers */
- if (na->nc->flags & NI_KILLPROTECT) {
- del_ns_timeout(na, TO_COLLIDE);
- }
-
- }
- return MOD_CONT;
-}
-
int should_mode_change(int16 status, int16 mode)
{
switch (mode) {
@@ -2678,7 +1864,9 @@ int should_mode_change(int16 status, int16 mode)
return 1;
}
-static int do_setmodes(User * u)
+/*************************************************************************/
+
+int do_setmodes(User * u)
{
struct u_chanlist *uc;
Channel *c;
@@ -2692,1765 +1880,6 @@ static int do_setmodes(User * u)
}
/*************************************************************************/
-
-static int do_logout(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *param = strtok(NULL, " ");
- User *u2;
-
- if (!is_services_admin(u) && nick) {
- syntax_error(s_NickServ, u, "LOGOUT", NICK_LOGOUT_SYNTAX);
- } else if (!(u2 = (nick ? finduser(nick) : u))) {
- notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
- } else if (!u2->na) {
- if (nick)
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- else
- notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
- } else if (u2->na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u2->na->nick);
- } else if (!nick && !nick_identified(u)) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else if (nick && is_services_admin(u2)) {
- notice_lang(s_NickServ, u, NICK_LOGOUT_SERVICESADMIN, nick);
- } else {
- if (nick && param && !stricmp(param, "REVALIDATE")) {
- cancel_user(u2);
- validate_user(u2);
- } else {
- u2->na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED);
- }
-
- if (ircd->modeonreg) {
- common_svsmode(u2, ircd->modeonunreg, "1");
- }
-
- u->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */
- alog("%s: %s!%s@%s logged out nickname %s", s_NickServ, u->nick,
- u->username, u->host, u2->nick);
-
- if (nick)
- notice_lang(s_NickServ, u, NICK_LOGOUT_X_SUCCEEDED, nick);
- else
- notice_lang(s_NickServ, u, NICK_LOGOUT_SUCCEEDED);
-
- /* Stop nick tracking if enabled */
- if (NSNickTracking)
- nsStopNickTracking(u);
-
- /* Clear any timers again */
- if (u->na->nc->flags & NI_KILLPROTECT) {
- del_ns_timeout(u->na, TO_COLLIDE);
- }
-
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_drop(User * u)
-{
- char *nick = strtok(NULL, " ");
- NickAlias *na;
- NickRequest *nr = NULL;
- int is_servadmin = is_services_admin(u);
- int is_mine; /* Does the nick being dropped belong to the user that is dropping? */
- char *my_nick = NULL;
-
- if (readonly && !is_servadmin) {
- notice_lang(s_NickServ, u, NICK_DROP_DISABLED);
- return MOD_CONT;
- }
-
- if (!(na = (nick ? findnick(nick) : u->na))) {
- if (nick) {
- if ((nr = findrequestnick(nick)) && is_servadmin) {
- if (readonly)
- notice_lang(s_NickServ, u, READ_ONLY_MODE);
- if (WallDrop)
- anope_cmd_global(s_NickServ,
- "\2%s\2 used DROP on \2%s\2", u->nick,
- nick);
- alog("%s: %s!%s@%s dropped nickname %s (e-mail: %s)",
- s_NickServ, u->nick, u->username, u->host,
- nr->nick, nr->email);
- delnickrequest(nr);
- notice_lang(s_NickServ, u, NICK_X_DROPPED, nick);
- } else {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- }
- } else
- notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
- return MOD_CONT;
- }
-
- is_mine = (u->na && (u->na->nc == na->nc));
- if (is_mine && !nick)
- my_nick = sstrdup(na->nick);
-
- if (is_mine && !nick_identified(u)) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else if (!is_mine && !is_servadmin) {
- notice_lang(s_NickServ, u, ACCESS_DENIED);
- } else if (NSSecureAdmins && !is_mine && nick_is_services_admin(na->nc)
- && !is_services_root(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- } else {
- if (readonly)
- notice_lang(s_NickServ, u, READ_ONLY_MODE);
-
- if (ircd->sqline && (na->status & NS_VERBOTEN)) {
- anope_cmd_unsqline(na->nick);
- }
-
- alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)",
- s_NickServ, u->nick, u->username, u->host,
- na->nick, na->nc->display,
- (na->nc->email ? na->nc->email : "none"));
- delnick(na);
- send_event(EVENT_NICK_DROPPED, (my_nick ? my_nick : nick));
-
- if (!is_mine) {
- if (WallDrop)
- anope_cmd_global(s_NickServ, "\2%s\2 used DROP on \2%s\2",
- u->nick, nick);
- notice_lang(s_NickServ, u, NICK_X_DROPPED, nick);
- } else {
- if (nick)
- notice_lang(s_NickServ, u, NICK_X_DROPPED, nick);
- else
- notice_lang(s_NickServ, u, NICK_DROPPED);
- if (my_nick) {
- free(my_nick);
- }
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set(User * u)
-{
- char *cmd = strtok(NULL, " ");
- char *param = strtok(NULL, " ");
-
- NickAlias *na;
- int is_servadmin = is_services_admin(u);
- int set_nick = 0;
-
- if (readonly) {
- notice_lang(s_NickServ, u, NICK_SET_DISABLED);
- return MOD_CONT;
- }
-
- if (is_servadmin && cmd && (na = findnick(cmd))) {
- cmd = param;
- param = strtok(NULL, " ");
- set_nick = 1;
- } else {
- na = u->na;
- }
-
- if (!param
- && (!cmd
- || (stricmp(cmd, "URL") != 0 && stricmp(cmd, "EMAIL") != 0
- && stricmp(cmd, "GREET") != 0
- && stricmp(cmd, "ICQ") != 0))) {
- if (is_servadmin) {
- syntax_error(s_NickServ, u, "SET", NICK_SET_SERVADMIN_SYNTAX);
- } else {
- syntax_error(s_NickServ, u, "SET", NICK_SET_SYNTAX);
- }
- } else if (!na) {
- notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else if (na->nc->flags & NI_SUSPENDED) {
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
- } else if (!is_servadmin && !nick_identified(u)) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else if (stricmp(cmd, "DISPLAY") == 0) {
- do_set_display(u, na->nc, param);
- } else if (stricmp(cmd, "PASSWORD") == 0) {
- do_set_password(u, na->nc, param);
- } else if (stricmp(cmd, "LANGUAGE") == 0) {
- do_set_language(u, na->nc, param);
- } else if (stricmp(cmd, "URL") == 0) {
- do_set_url(u, na->nc, param);
- } else if (stricmp(cmd, "EMAIL") == 0) {
- do_set_email(u, na->nc, param);
- } else if (stricmp(cmd, "ICQ") == 0) {
- do_set_icq(u, na->nc, param);
- } else if (stricmp(cmd, "GREET") == 0) {
- do_set_greet(u, na->nc, param);
- } else if (stricmp(cmd, "KILL") == 0) {
- do_set_kill(u, na->nc, param);
- } else if (stricmp(cmd, "SECURE") == 0) {
- do_set_secure(u, na->nc, param);
- } else if (stricmp(cmd, "PRIVATE") == 0) {
- do_set_private(u, na->nc, param);
- } else if (stricmp(cmd, "MSG") == 0) {
- do_set_msg(u, na->nc, param);
- } else if (stricmp(cmd, "HIDE") == 0) {
- do_set_hide(u, na->nc, param);
- } else if (stricmp(cmd, "NOEXPIRE") == 0) {
- do_set_noexpire(u, na, param);
- } else {
- if (is_servadmin)
- notice_lang(s_NickServ, u, NICK_SET_UNKNOWN_OPTION_OR_BAD_NICK,
- cmd);
- else
- notice_lang(s_NickServ, u, NICK_SET_UNKNOWN_OPTION, cmd);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_display(User * u, NickCore * nc, char *param)
-{
- int i;
- NickAlias *na;
-
- /* First check whether param is a valid nick of the group */
- for (i = 0; i < nc->aliases.count; i++) {
- na = nc->aliases.list[i];
- if (!stricmp(na->nick, param)) {
- param = na->nick; /* Because case may differ */
- break;
- }
- }
-
- if (i == nc->aliases.count) {
- notice_lang(s_NickServ, u, NICK_SET_DISPLAY_INVALID);
- return MOD_CONT;
- }
-
- change_core_display(nc, param);
- notice_lang(s_NickServ, u, NICK_SET_DISPLAY_CHANGED, nc->display);
-
- /* Enable nick tracking if enabled */
- if (NSNickTracking)
- nsStartNickTracking(u);
-
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_password(User * u, NickCore * nc, char *param)
-{
- int len = strlen(param);
-
- if (NSSecureAdmins && u->na->nc != nc && nick_is_services_admin(nc)
- && !is_services_root(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- } else if (stricmp(nc->display, param) == 0
- || (StrictPasswords && len < 5)) {
- notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD);
- return MOD_CONT;
- }
-
- if (nc->pass)
- free(nc->pass);
-
-#ifdef USE_ENCRYPTION
- nc->pass = smalloc(PASSMAX);
-
- if (encrypt(param, len, nc->pass, PASSMAX) < 0) {
- memset(param, 0, len);
- alog("%s: Failed to encrypt password for %s (set)", s_NickServ,
- nc->display);
- notice_lang(s_NickServ, u, NICK_SET_PASSWORD_FAILED);
- return MOD_CONT;
- }
-
- memset(param, 0, len);
- notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED);
-#else
- nc->pass = sstrdup(param);
- notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED_TO, nc->pass);
-#endif
-
- if (u->na && u->na->nc != nc && is_services_admin(u)) {
- alog("%s: %s!%s@%s used SET PASSWORD as Services admin on %s (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, nc->display, (nc->email ? nc->email : "none"));
- if (WallSetpass)
- anope_cmd_global(s_NickServ,
- "\2%s\2 used SET PASSWORD as Services admin on \2%s\2",
- u->nick, nc->display);
- } else {
- alog("%s: %s!%s@%s (e-mail: %s) changed its password.", s_NickServ,
- u->nick, u->username, u->host,
- (nc->email ? nc->email : "none"));
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_language(User * u, NickCore * nc, char *param)
-{
- int langnum;
-
- if (param[strspn(param, "0123456789")] != 0) { /* i.e. not a number */
- syntax_error(s_NickServ, u, "SET LANGUAGE",
- NICK_SET_LANGUAGE_SYNTAX);
- return MOD_CONT;
- }
- langnum = atoi(param) - 1;
- if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0) {
- notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_UNKNOWN, langnum + 1,
- s_NickServ);
- return MOD_CONT;
- }
- nc->language = langlist[langnum];
- notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_CHANGED);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_url(User * u, NickCore * nc, char *param)
-{
- if (nc->url)
- free(nc->url);
-
- if (param) {
- nc->url = sstrdup(param);
- notice_lang(s_NickServ, u, NICK_SET_URL_CHANGED, param);
- } else {
- nc->url = NULL;
- notice_lang(s_NickServ, u, NICK_SET_URL_UNSET);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_email(User * u, NickCore * nc, char *param)
-{
- if (!param && NSForceEmail) {
- notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNSET_IMPOSSIBLE);
- return MOD_CONT;
- } else if (NSSecureAdmins && u->na->nc != nc
- && nick_is_services_admin(nc)
- && !is_services_root(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- } else if (param && !MailValidate(param)) {
- notice_lang(s_NickServ, u, MAIL_X_INVALID, param);
- return MOD_CONT;
- }
-
- if (u->na && u->na->nc != nc && is_services_admin(u)) {
- alog("%s: %s!%s@%s used SET EMAIL as Services admin on %s (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, nc->display, (nc->email ? nc->email : "none"));
- } else {
- alog("%s: %s!%s@%s (e-mail: %s) changed its e-mail to %s.",
- s_NickServ, u->nick, u->username, u->host,
- (nc->email ? nc->email : "none"), (param ? param : "none"));
- }
- if (nc->email)
- free(nc->email);
-
- if (param) {
- nc->email = sstrdup(param);
- notice_lang(s_NickServ, u, NICK_SET_EMAIL_CHANGED, param);
- } else {
- nc->email = NULL;
- notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNSET);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_icq(User * u, NickCore * nc, char *param)
-{
- if (param) {
- int32 tmp = atol(param);
- if (!tmp) {
- notice_lang(s_NickServ, u, NICK_SET_ICQ_INVALID, param);
- } else {
- nc->icq = tmp;
- notice_lang(s_NickServ, u, NICK_SET_ICQ_CHANGED, param);
- }
- } else {
- nc->icq = 0;
- notice_lang(s_NickServ, u, NICK_SET_ICQ_UNSET);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_greet(User * u, NickCore * nc, char *param)
-{
- if (nc->greet)
- free(nc->greet);
-
- if (param) {
- char buf[BUFSIZE];
- char *end = strtok(NULL, "");
-
- snprintf(buf, sizeof(buf), "%s%s%s", param, (end ? " " : ""),
- (end ? end : ""));
-
- nc->greet = sstrdup(buf);
- notice_lang(s_NickServ, u, NICK_SET_GREET_CHANGED, buf);
- } else {
- nc->greet = NULL;
- notice_lang(s_NickServ, u, NICK_SET_GREET_UNSET);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_kill(User * u, NickCore * nc, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- nc->flags |= NI_KILLPROTECT;
- nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED);
- notice_lang(s_NickServ, u, NICK_SET_KILL_ON);
- } else if (stricmp(param, "QUICK") == 0) {
- nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK;
- nc->flags &= ~NI_KILL_IMMED;
- notice_lang(s_NickServ, u, NICK_SET_KILL_QUICK);
- } else if (stricmp(param, "IMMED") == 0) {
- if (NSAllowKillImmed) {
- nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED;
- nc->flags &= ~NI_KILL_QUICK;
- notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED);
- } else {
- notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED_DISABLED);
- }
- } else if (stricmp(param, "OFF") == 0) {
- nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED);
- notice_lang(s_NickServ, u, NICK_SET_KILL_OFF);
- } else {
- syntax_error(s_NickServ, u, "SET KILL",
- NSAllowKillImmed ? NICK_SET_KILL_IMMED_SYNTAX :
- NICK_SET_KILL_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_secure(User * u, NickCore * nc, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- nc->flags |= NI_SECURE;
- notice_lang(s_NickServ, u, NICK_SET_SECURE_ON);
- } else if (stricmp(param, "OFF") == 0) {
- nc->flags &= ~NI_SECURE;
- notice_lang(s_NickServ, u, NICK_SET_SECURE_OFF);
- } else {
- syntax_error(s_NickServ, u, "SET SECURE", NICK_SET_SECURE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_private(User * u, NickCore * nc, char *param)
-{
- if (stricmp(param, "ON") == 0) {
- nc->flags |= NI_PRIVATE;
- notice_lang(s_NickServ, u, NICK_SET_PRIVATE_ON);
- } else if (stricmp(param, "OFF") == 0) {
- nc->flags &= ~NI_PRIVATE;
- notice_lang(s_NickServ, u, NICK_SET_PRIVATE_OFF);
- } else {
- syntax_error(s_NickServ, u, "SET PRIVATE",
- NICK_SET_PRIVATE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_msg(User * u, NickCore * nc, char *param)
-{
- if (!UsePrivmsg) {
- notice_lang(s_NickServ, u, NICK_SET_OPTION_DISABLED, "MSG");
- return MOD_CONT;
- }
-
- if (stricmp(param, "ON") == 0) {
- nc->flags |= NI_MSG;
- notice_lang(s_NickServ, u, NICK_SET_MSG_ON);
- } else if (stricmp(param, "OFF") == 0) {
- nc->flags &= ~NI_MSG;
- notice_lang(s_NickServ, u, NICK_SET_MSG_OFF);
- } else {
- syntax_error(s_NickServ, u, "SET MSG", NICK_SET_MSG_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_hide(User * u, NickCore * nc, char *param)
-{
- int flag, onmsg, offmsg;
-
- if (stricmp(param, "EMAIL") == 0) {
- flag = NI_HIDE_EMAIL;
- onmsg = NICK_SET_HIDE_EMAIL_ON;
- offmsg = NICK_SET_HIDE_EMAIL_OFF;
- } else if (stricmp(param, "USERMASK") == 0) {
- flag = NI_HIDE_MASK;
- onmsg = NICK_SET_HIDE_MASK_ON;
- offmsg = NICK_SET_HIDE_MASK_OFF;
- } else if (stricmp(param, "STATUS") == 0) {
- flag = NI_HIDE_STATUS;
- onmsg = NICK_SET_HIDE_STATUS_ON;
- offmsg = NICK_SET_HIDE_STATUS_OFF;
- } else if (stricmp(param, "QUIT") == 0) {
- flag = NI_HIDE_QUIT;
- onmsg = NICK_SET_HIDE_QUIT_ON;
- offmsg = NICK_SET_HIDE_QUIT_OFF;
- } else {
- syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
- return MOD_CONT;
- }
-
- param = strtok(NULL, " ");
- if (!param) {
- syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
- } else if (stricmp(param, "ON") == 0) {
- nc->flags |= flag;
- notice_lang(s_NickServ, u, onmsg, s_NickServ);
- } else if (stricmp(param, "OFF") == 0) {
- nc->flags &= ~flag;
- notice_lang(s_NickServ, u, offmsg, s_NickServ);
- } else {
- syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_set_noexpire(User * u, NickAlias * na, char *param)
-{
- if (!is_services_admin(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
- if (!param) {
- syntax_error(s_NickServ, u, "SET NOEXPIRE",
- NICK_SET_NOEXPIRE_SYNTAX);
- return MOD_CONT;
- }
- if (stricmp(param, "ON") == 0) {
- na->status |= NS_NO_EXPIRE;
- notice_lang(s_NickServ, u, NICK_SET_NOEXPIRE_ON, na->nick);
- } else if (stricmp(param, "OFF") == 0) {
- na->status &= ~NS_NO_EXPIRE;
- notice_lang(s_NickServ, u, NICK_SET_NOEXPIRE_OFF, na->nick);
- } else {
- syntax_error(s_NickServ, u, "SET NOEXPIRE",
- NICK_SET_NOEXPIRE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_link(User * u)
-{
- notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "GROUP");
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_unlink(User * u)
-{
- notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "DROP");
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_listlinks(User * u)
-{
- notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "GLIST");
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_access(User * u)
-{
- char *cmd = strtok(NULL, " ");
- char *mask = strtok(NULL, " ");
- NickAlias *na;
- int i;
- char **access;
-
- if (cmd && stricmp(cmd, "LIST") == 0 && mask && is_services_admin(u)
- && (na = findnick(mask))) {
-
- if (na->nc->accesscount == 0) {
- notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X_EMPTY, na->nick);
- return MOD_CONT;
- }
-
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- return MOD_CONT;
- }
-
- if (na->nc->flags & NI_SUSPENDED) {
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
- return MOD_CONT;
- }
-
-
- notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X, mask);
- mask = strtok(NULL, " ");
- for (access = na->nc->access, i = 0; i < na->nc->accesscount;
- access++, i++) {
- if (mask && !match_wild(mask, *access))
- continue;
- notice_user(s_NickServ, u, " %s", *access);
- }
-
- } else if (!cmd || ((stricmp(cmd, "LIST") == 0) ? !!mask : !mask)) {
- syntax_error(s_NickServ, u, "ACCESS", NICK_ACCESS_SYNTAX);
-
- } else if (mask && !strchr(mask, '@')) {
- notice_lang(s_NickServ, u, BAD_USERHOST_MASK);
- notice_lang(s_NickServ, u, MORE_INFO, s_NickServ, "ACCESS");
-
- } else if (!(na = u->na)) {
- notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
-
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
-
- } else if (na->nc->flags & NI_SUSPENDED) {
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
-
- } else if (!nick_identified(u)) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
-
- } else if (stricmp(cmd, "ADD") == 0) {
- if (na->nc->accesscount >= NSAccessMax) {
- notice_lang(s_NickServ, u, NICK_ACCESS_REACHED_LIMIT,
- NSAccessMax);
- return MOD_CONT;
- }
-
- for (access = na->nc->access, i = 0; i < na->nc->accesscount;
- access++, i++) {
- if (strcmp(*access, mask) == 0) {
- notice_lang(s_NickServ, u, NICK_ACCESS_ALREADY_PRESENT,
- *access);
- return MOD_CONT;
- }
- }
-
- na->nc->accesscount++;
- na->nc->access =
- srealloc(na->nc->access, sizeof(char *) * na->nc->accesscount);
- na->nc->access[na->nc->accesscount - 1] = sstrdup(mask);
- notice_lang(s_NickServ, u, NICK_ACCESS_ADDED, mask);
-
- } else if (stricmp(cmd, "DEL") == 0) {
-
- for (access = na->nc->access, i = 0; i < na->nc->accesscount;
- access++, i++) {
- if (stricmp(*access, mask) == 0)
- break;
- }
- if (i == na->nc->accesscount) {
- notice_lang(s_NickServ, u, NICK_ACCESS_NOT_FOUND, mask);
- return MOD_CONT;
- }
-
- notice_lang(s_NickServ, u, NICK_ACCESS_DELETED, *access);
- free(*access);
- na->nc->accesscount--;
- if (i < na->nc->accesscount) /* if it wasn't the last entry... */
- memmove(access, access + 1,
- (na->nc->accesscount - i) * sizeof(char *));
- if (na->nc->accesscount) /* if there are any entries left... */
- na->nc->access =
- srealloc(na->nc->access,
- na->nc->accesscount * sizeof(char *));
- else {
- free(na->nc->access);
- na->nc->access = NULL;
- }
- } else if (stricmp(cmd, "LIST") == 0) {
- if (na->nc->accesscount == 0) {
- notice_lang(s_NickServ, u, NICK_ACCESS_LIST_EMPTY, u->nick);
- return MOD_CONT;
- }
-
- notice_lang(s_NickServ, u, NICK_ACCESS_LIST);
- for (access = na->nc->access, i = 0; i < na->nc->accesscount;
- access++, i++) {
- if (mask && !match_wild(mask, *access))
- continue;
- notice_user(s_NickServ, u, " %s", *access);
- }
- } else {
- syntax_error(s_NickServ, u, "ACCESS", NICK_ACCESS_SYNTAX);
-
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Show hidden info to nick owners and sadmins when the "ALL" parameter is
- * supplied. If a nick is online, the "Last seen address" changes to "Is
- * online from".
- * Syntax: INFO <nick> {ALL}
- * -TheShadow (13 Mar 1999)
- */
-
-static int do_info(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *param = strtok(NULL, " ");
-
- NickAlias *na;
- NickRequest *nr = NULL;
- int is_servadmin = is_services_admin(u);
-
- if (!nick) {
- syntax_error(s_NickServ, u, "INFO", NICK_INFO_SYNTAX);
- } else if (!(na = findnick(nick))) {
- if ((nr = findrequestnick(nick))) {
- notice_lang(s_NickServ, u, NICK_IS_PREREG);
- if (param && stricmp(param, "ALL") == 0 && is_servadmin) {
- notice_lang(s_NickServ, u, NICK_INFO_EMAIL, nr->email);
- } else {
- if (is_servadmin) {
- notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE,
- s_NickServ, nr->nick);
- }
- }
- } else if (nickIsServices(nick, 1)) {
- notice_lang(s_NickServ, u, NICK_X_IS_SERVICES, nick);
- } else {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- }
- } else if (na->status & NS_VERBOTEN) {
- if (is_oper(u) && na->last_usermask)
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN_OPER, nick,
- na->last_usermask,
- (na->last_realname ? na->
- last_realname : getstring(u->na, NO_REASON)));
- else
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
- } else {
- struct tm *tm;
- char buf[BUFSIZE], *end;
- const char *commastr = getstring(u->na, COMMA_SPACE);
- int need_comma = 0;
- int nick_online = 0;
- int show_hidden = 0;
- time_t expt;
-
- /* Is the real owner of the nick we're looking up online? -TheShadow */
- if (na->status & (NS_RECOGNIZED | NS_IDENTIFIED))
- nick_online = 1;
-
- /* Only show hidden fields to owner and sadmins and only when the ALL
- * parameter is used. -TheShadow */
- if (param && stricmp(param, "ALL") == 0 && u->na
- && ((nick_identified(u) && (na->nc == u->na->nc))
- || is_servadmin))
- show_hidden = 1;
-
- notice_lang(s_NickServ, u, NICK_INFO_REALNAME, na->nick,
- na->last_realname);
-
- if ((nick_identified(u) && (na->nc == u->na->nc)) || is_servadmin) {
-
- if (nick_is_services_root(na->nc))
- notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ROOT,
- na->nick);
- else if (nick_is_services_admin(na->nc))
- notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ADMIN,
- na->nick);
- else if (nick_is_services_oper(na->nc))
- notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPER,
- na->nick);
-
- } else {
-
- if (nick_is_services_root(na->nc)
- && !(na->nc->flags & NI_HIDE_STATUS))
- notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ROOT,
- na->nick);
- else if (nick_is_services_admin(na->nc)
- && !(na->nc->flags & NI_HIDE_STATUS))
- notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ADMIN,
- na->nick);
- else if (nick_is_services_oper(na->nc)
- && !(na->nc->flags & NI_HIDE_STATUS))
- notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPER,
- na->nick);
-
- }
-
-
- if (nick_online) {
- if (show_hidden || !(na->nc->flags & NI_HIDE_MASK))
- notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE,
- na->last_usermask);
- else
- notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE_NOHOST,
- na->nick);
- } else {
- if (show_hidden || !(na->nc->flags & NI_HIDE_MASK))
- notice_lang(s_NickServ, u, NICK_INFO_ADDRESS,
- na->last_usermask);
- }
-
- tm = localtime(&na->time_registered);
- strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
- notice_lang(s_NickServ, u, NICK_INFO_TIME_REGGED, buf);
-
- if (!nick_online) {
- tm = localtime(&na->last_seen);
- strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT,
- tm);
- notice_lang(s_NickServ, u, NICK_INFO_LAST_SEEN, buf);
- }
-
- if (na->last_quit
- && (show_hidden || !(na->nc->flags & NI_HIDE_QUIT)))
- notice_lang(s_NickServ, u, NICK_INFO_LAST_QUIT, na->last_quit);
-
- if (na->nc->url)
- notice_lang(s_NickServ, u, NICK_INFO_URL, na->nc->url);
- if (na->nc->email
- && (show_hidden || !(na->nc->flags & NI_HIDE_EMAIL)))
- notice_lang(s_NickServ, u, NICK_INFO_EMAIL, na->nc->email);
- if (na->nc->icq)
- notice_lang(s_NickServ, u, NICK_INFO_ICQ, na->nc->icq);
-
- if (show_hidden) {
- if (s_HostServ && ircd->vhost) {
- if (getvHost(na->nick) != NULL) {
- if (ircd->vident && getvIdent(na->nick) != NULL) {
- notice_lang(s_NickServ, u, NICK_INFO_VHOST2,
- getvIdent(na->nick),
- getvHost(na->nick));
- } else {
- notice_lang(s_NickServ, u, NICK_INFO_VHOST,
- getvHost(na->nick));
- }
- }
- }
- if (na->nc->greet)
- notice_lang(s_NickServ, u, NICK_INFO_GREET, na->nc->greet);
-
- *buf = 0;
- end = buf;
-
- if (na->nc->flags & NI_KILLPROTECT) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s",
- getstring(u->na, NICK_INFO_OPT_KILL));
- need_comma = 1;
- }
- if (na->nc->flags & NI_SECURE) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, NICK_INFO_OPT_SECURE));
- need_comma = 1;
- }
- if (na->nc->flags & NI_PRIVATE) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, NICK_INFO_OPT_PRIVATE));
- need_comma = 1;
- }
- if (na->nc->flags & NI_MSG) {
- end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
- need_comma ? commastr : "",
- getstring(u->na, NICK_INFO_OPT_MSG));
- need_comma = 1;
- }
-
- notice_lang(s_NickServ, u, NICK_INFO_OPTIONS,
- *buf ? buf : getstring(u->na, NICK_INFO_OPT_NONE));
-
- if (na->nc->flags & NI_SUSPENDED) {
- notice_lang(s_NickServ, u, NICK_INFO_SUSPENDED,
- na->last_quit);
- }
-
- if (na->status & NS_NO_EXPIRE) {
- notice_lang(s_NickServ, u, NICK_INFO_NO_EXPIRE);
- } else {
- if (is_services_admin(u)) {
- expt = na->last_seen + NSExpire;
- tm = localtime(&expt);
- strftime_lang(buf, sizeof(buf), na->u,
- STRFTIME_DATE_TIME_FORMAT, tm);
- notice_lang(s_NickServ, u, NICK_INFO_EXPIRE, buf);
- }
- }
- }
-
- if (!show_hidden
- && ((u->na && (na->nc == u->na->nc) && nick_identified(u))
- || is_servadmin))
- notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE, s_NickServ,
- na->nick);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* SADMINS can search for nicks based on their NS_VERBOTEN and NS_NO_EXPIRE
- * status. The keywords FORBIDDEN and NOEXPIRE represent these two states
- * respectively. These keywords should be included after the search pattern.
- * Multiple keywords are accepted and should be separated by spaces. Only one
- * of the keywords needs to match a nick's state for the nick to be displayed.
- * Forbidden nicks can be identified by "[Forbidden]" appearing in the last
- * seen address field. Nicks with NOEXPIRE set are preceeded by a "!". Only
- * SADMINS will be shown forbidden nicks and the "!" indicator.
- * Syntax for sadmins: LIST pattern [FORBIDDEN] [NOEXPIRE]
- * -TheShadow
- */
-
-static int do_list(User * u)
-{
- char *pattern = strtok(NULL, " ");
- char *keyword;
- NickAlias *na;
- NickCore *mync;
- int nnicks, i;
- char buf[BUFSIZE];
- int is_servadmin = is_services_admin(u);
- int16 matchflags = 0;
- NickRequest *nr = NULL;
- int nronly = 0;
- char noexpire_char = ' ';
- int count = 0, from = 0, to = 0;
- char *tmp = NULL;
- char *s = NULL;
-
- if (NSListOpersOnly && !(is_oper(u))) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (!pattern) {
- syntax_error(s_NickServ, u, "LIST",
- is_servadmin ? NICK_LIST_SERVADMIN_SYNTAX :
- NICK_LIST_SYNTAX);
- } else {
-
- if (pattern) {
- if (pattern[0] == '#') {
- tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */
- if (!tmp) {
- return MOD_CONT;
- }
- for (s = tmp; *s; s++) {
- if (!isdigit(*s)) {
- return MOD_CONT;
- }
- }
- from = atoi(tmp);
- tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */
- if (!tmp) {
- return MOD_CONT;
- }
- for (s = tmp; *s; s++) {
- if (!isdigit(*s)) {
- return MOD_CONT;
- }
- }
- to = atoi(tmp);
- pattern = sstrdup("*");
- }
- }
-
- nnicks = 0;
-
- while (is_servadmin && (keyword = strtok(NULL, " "))) {
- if (stricmp(keyword, "FORBIDDEN") == 0)
- matchflags |= NS_VERBOTEN;
- if (stricmp(keyword, "NOEXPIRE") == 0)
- matchflags |= NS_NO_EXPIRE;
- if (stricmp(keyword, "UNCONFIRMED") == 0)
- nronly = 1;
- }
-
- mync = (nick_identified(u) ? u->na->nc : NULL);
-
- notice_lang(s_NickServ, u, NICK_LIST_HEADER, pattern);
- if (nronly != 1) {
- for (i = 0; i < 1024; i++) {
- for (na = nalists[i]; na; na = na->next) {
- /* Don't show private and forbidden nicks to non-services admins. */
- if ((na->status & NS_VERBOTEN) && !is_servadmin)
- continue;
- if ((na->nc->flags & NI_PRIVATE) && !is_servadmin
- && na->nc != mync)
- continue;
- if ((matchflags != 0) && !(na->status & matchflags))
- continue;
-
- /* We no longer compare the pattern against the output buffer.
- * Instead we build a nice nick!user@host buffer to compare.
- * The output is then generated separately. -TheShadow */
- snprintf(buf, sizeof(buf), "%s!%s", na->nick,
- (na->last_usermask
- && !(na->status & NS_VERBOTEN)) ? na->
- last_usermask : "*@*");
- if (stricmp(pattern, na->nick) == 0
- || match_wild_nocase(pattern, buf)) {
-
- if ((((count + 1 >= from) && (count + 1 <= to))
- || ((from == 0) && (to == 0)))
- && (++nnicks <= NSListMax)) {
- if (is_servadmin
- && (na->status & NS_NO_EXPIRE))
- noexpire_char = '!';
- else {
- noexpire_char = ' ';
- }
- if ((na->nc->flags & NI_HIDE_MASK)
- && !is_servadmin && na->nc != mync) {
- snprintf(buf, sizeof(buf),
- "%-20s [Hostname Hidden]",
- na->nick);
- } else if (na->status & NS_VERBOTEN) {
- snprintf(buf, sizeof(buf),
- "%-20s [Forbidden]", na->nick);
- } else {
- snprintf(buf, sizeof(buf), "%-20s %s",
- na->nick, na->last_usermask);
- }
- notice_user(s_NickServ, u, " %c%s",
- noexpire_char, buf);
- }
- count++;
- }
- }
- }
- }
-
- if (nronly == 1 || (is_servadmin && matchflags == 0)) {
- noexpire_char = ' ';
- for (i = 0; i < 1024; i++) {
- for (nr = nrlists[i]; nr; nr = nr->next) {
- snprintf(buf, sizeof(buf), "%s!*@*", nr->nick);
- if (stricmp(pattern, nr->nick) == 0
- || match_wild_nocase(pattern, buf)) {
- if (++nnicks <= NSListMax) {
- snprintf(buf, sizeof(buf),
- "%-20s [UNCONFIRMED]", nr->nick);
- notice_user(s_NickServ, u, " %c%s",
- noexpire_char, buf);
- }
- }
- }
- }
- }
- notice_lang(s_NickServ, u, NICK_LIST_RESULTS,
- nnicks > NSListMax ? NSListMax : nnicks, nnicks);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_glist(User * u)
-{
- char *nick = strtok(NULL, " ");
-
- NickAlias *na, *na2;
- int is_servadmin = is_services_admin(u);
- int nick_ided = nick_identified(u);
- int i;
-
- if ((nick ? (stricmp(nick, u->nick) ? !is_servadmin : !nick_ided)
- : !nick_ided)) {
- notice_lang(s_NickServ, u,
- (nick_ided ? ACCESS_DENIED :
- NICK_IDENTIFY_REQUIRED), s_NickServ);
- } else if ((!nick ? !(na = u->na) : !(na = findnick(nick)))) {
- notice_lang(s_NickServ, u,
- (!nick ? NICK_NOT_REGISTERED : NICK_X_NOT_REGISTERED),
- nick);
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else {
- time_t expt;
- struct tm *tm;
- char buf[BUFSIZE];
- int wont_expire;
-
- notice_lang(s_NickServ, u,
- nick ? NICK_GLIST_HEADER_X : NICK_GLIST_HEADER,
- na->nc->display);
- for (i = 0; i < na->nc->aliases.count; i++) {
- na2 = na->nc->aliases.list[i];
- if (na2->nc == na->nc) {
- if (!(wont_expire = na2->status & NS_NO_EXPIRE)) {
- expt = na2->last_seen + NSExpire;
- tm = localtime(&expt);
- strftime_lang(buf, sizeof(buf), na2->u,
- STRFTIME_DATE_TIME_FORMAT, tm);
- }
- notice_lang(s_NickServ, u,
- ((is_services_admin(u) && !wont_expire)
- ? NICK_GLIST_REPLY_ADMIN : NICK_GLIST_REPLY),
- (wont_expire ? '!' : ' '), na2->nick, buf);
- }
- }
- notice_lang(s_NickServ, u, NICK_GLIST_FOOTER,
- na->nc->aliases.count);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/**
- * List the channels that the given nickname has access on
- *
- * /ns ALIST [level]
- * /ns ALIST [nickname] [level]
- *
- * -jester
- */
-static int do_alist(User * u)
-{
- char *nick = NULL;
- char *lev = NULL;
-
- NickAlias *na;
-
- int min_level = 0;
- int is_servadmin = is_services_admin(u);
-
- if (!is_servadmin) {
- /* Non service admins can only see their own levels */
- na = u->na;
- } else {
- /* Services admins can request ALIST on nicks.
- * The first argument for service admins must
- * always be a nickname.
- */
- nick = strtok(NULL, " ");
-
- /* If an argument was passed, use it as the nick to see levels
- * for, else check levels for the user calling the command */
- if (nick) {
- na = findnick(nick);
- } else {
- na = u->na;
- }
- }
-
- /* If available, get level from arguments */
- lev = strtok(NULL, " ");
-
- /* if a level was given, make sure it's an int for later */
- if (lev) {
- if (stricmp(lev, "FOUNDER") == 0) {
- min_level = ACCESS_FOUNDER;
- } else if (stricmp(lev, "SOP") == 0) {
- min_level = ACCESS_SOP;
- } else if (stricmp(lev, "AOP") == 0) {
- min_level = ACCESS_AOP;
- } else if (stricmp(lev, "HOP") == 0) {
- min_level = ACCESS_HOP;
- } else if (stricmp(lev, "VOP") == 0) {
- min_level = ACCESS_VOP;
- } else {
- min_level = atoi(lev);
- }
- }
-
- if (!nick_identified(u)) {
- notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
- } else if (is_servadmin && nick && !na) {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else if (min_level <= ACCESS_INVALID || min_level >= ACCESS_FOUNDER) {
- notice_lang(s_NickServ, u, CHAN_ACCESS_LEVEL_RANGE,
- ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
- } else {
- int i, level;
- int chan_count = 0;
- int match_count = 0;
- ChannelInfo *ci;
-
- notice_lang(s_NickServ, u, (is_servadmin ? NICK_ALIST_HEADER_X :
- NICK_ALIST_HEADER), na->nick);
-
- for (i = 0; i < 256; i++) {
- for ((ci = chanlists[i]); ci; (ci = ci->next)) {
-
- if ((level = get_access_level(ci, na))) {
- chan_count++;
-
- if (min_level > level) {
- continue;
- }
-
- match_count++;
-
- if ((ci->flags & CI_XOP) || (level == ACCESS_FOUNDER)) {
- char *xop;
-
- xop = get_xop_level(level);
-
- notice_lang(s_NickServ, u, NICK_ALIST_XOP_FORMAT,
- match_count,
- ((ci->
- flags & CI_NO_EXPIRE) ? '!' : ' '),
- ci->name, xop,
- (ci->desc ? ci->desc : ""));
- } else {
- notice_lang(s_NickServ, u,
- NICK_ALIST_ACCESS_FORMAT, match_count,
- ((ci->
- flags & CI_NO_EXPIRE) ? '!' : ' '),
- ci->name, level,
- (ci->desc ? ci->desc : ""));
-
- }
- }
- }
- }
-
- notice_lang(s_NickServ, u, NICK_ALIST_FOOTER, match_count,
- chan_count);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_recover(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *pass = strtok(NULL, " ");
- NickAlias *na;
- User *u2;
-
- if (!nick) {
- syntax_error(s_NickServ, u, "RECOVER", NICK_RECOVER_SYNTAX);
- } else if (!(u2 = finduser(nick))) {
- notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
- } else if (!(na = u2->na)) {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else if (na->nc->flags & NI_SUSPENDED) {
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
- } else if (stricmp(nick, u->nick) == 0) {
- notice_lang(s_NickServ, u, NICK_NO_RECOVER_SELF);
- } else if (pass) {
- int res = check_password(pass, na->nc->pass);
-
- if (res == 1) {
- notice_lang(s_NickServ, u2, FORCENICKCHANGE_NOW);
- collide(na, 0);
- notice_lang(s_NickServ, u, NICK_RECOVERED, s_NickServ, nick);
- } else {
- notice_lang(s_NickServ, u, ACCESS_DENIED);
- if (res == 0) {
- alog("%s: RECOVER: invalid password for %s by %s!%s@%s",
- s_NickServ, nick, u->nick, u->username, u->host);
- bad_password(u);
- }
- }
- } else {
- if (group_identified(u, na->nc)
- || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) {
- notice_lang(s_NickServ, u2, FORCENICKCHANGE_NOW);
- collide(na, 0);
- notice_lang(s_NickServ, u, NICK_RECOVERED, s_NickServ, nick);
- } else {
- notice_lang(s_NickServ, u, ACCESS_DENIED);
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_release(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *pass = strtok(NULL, " ");
- NickAlias *na;
-
- if (!nick) {
- syntax_error(s_NickServ, u, "RELEASE", NICK_RELEASE_SYNTAX);
- } else if (!(na = findnick(nick))) {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else if (na->nc->flags & NI_SUSPENDED) {
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
- } else if (!(na->status & NS_KILL_HELD)) {
- notice_lang(s_NickServ, u, NICK_RELEASE_NOT_HELD, nick);
- } else if (pass) {
- int res = check_password(pass, na->nc->pass);
- if (res == 1) {
- release(na, 0);
- notice_lang(s_NickServ, u, NICK_RELEASED);
- } else {
- notice_lang(s_NickServ, u, ACCESS_DENIED);
- if (res == 0) {
- alog("%s: RELEASE: invalid password for %s by %s!%s@%s",
- s_NickServ, nick, u->nick, u->username, u->host);
- bad_password(u);
- }
- }
- } else {
- if (group_identified(u, na->nc)
- || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) {
- release(na, 0);
- notice_lang(s_NickServ, u, NICK_RELEASED);
- } else {
- notice_lang(s_NickServ, u, ACCESS_DENIED);
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_ghost(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *pass = strtok(NULL, " ");
- NickAlias *na;
- User *u2;
-
- if (!nick) {
- syntax_error(s_NickServ, u, "GHOST", NICK_GHOST_SYNTAX);
- } else if (!(u2 = finduser(nick))) {
- notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
- } else if (!(na = u2->na)) {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else if (na->nc->flags & NI_SUSPENDED) {
- notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
- } else if (stricmp(nick, u->nick) == 0) {
- notice_lang(s_NickServ, u, NICK_NO_GHOST_SELF);
- } else if (pass) {
- int res = check_password(pass, na->nc->pass);
- if (res == 1) {
- char buf[NICKMAX + 32];
- snprintf(buf, sizeof(buf), "GHOST command used by %s",
- u->nick);
- if (LimitSessions) {
- del_session(u2->host);
- }
- kill_user(s_NickServ, nick, buf);
- notice_lang(s_NickServ, u, NICK_GHOST_KILLED, nick);
- } else {
- notice_lang(s_NickServ, u, ACCESS_DENIED);
- if (res == 0) {
- alog("%s: GHOST: invalid password for %s by %s!%s@%s",
- s_NickServ, nick, u->nick, u->username, u->host);
- bad_password(u);
- }
- }
- } else {
- if (group_identified(u, na->nc)
- || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) {
- char buf[NICKMAX + 32];
- snprintf(buf, sizeof(buf), "GHOST command used by %s",
- u->nick);
- if (LimitSessions) {
- del_session(u2->host);
- }
- kill_user(s_NickServ, nick, buf);
- notice_lang(s_NickServ, u, NICK_GHOST_KILLED, nick);
- } else {
- notice_lang(s_NickServ, u, ACCESS_DENIED);
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_status(User * u)
-{
- User *u2;
- NickAlias *na = NULL;
- int i = 0;
- char *nick = strtok(NULL, " ");
-
- /* If no nickname is given, we assume that the user
- * is asking for himself */
- if (!nick)
- nick = u->nick;
-
- while (nick && (i++ < 16)) {
- if (!(u2 = finduser(nick))) /* Nick is not online */
- notice_lang(s_NickServ, u, NICK_STATUS_0, nick);
- else if (nick_identified(u2)) /* Nick is identified */
- notice_lang(s_NickServ, u, NICK_STATUS_3, nick);
- else if (nick_recognized(u2)) /* Nick is recognised, but NOT identified */
- notice_lang(s_NickServ, u, NICK_STATUS_2, nick);
- else if ((na = findnick(nick)) == NULL) /* Nick is online, but NOT a registered */
- notice_lang(s_NickServ, u, NICK_STATUS_0, nick);
- else
- notice_lang(s_NickServ, u, NICK_STATUS_1, nick);
-
- /* Get the next nickname */
- nick = strtok(NULL, " ");
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-/* A simple call to check for all emails that a user may have registered */
-/* with. It returns the nicks that match the email you provide. Wild */
-/* Cards are not excepted. Must use user@email-host. */
-/*************************************************************************/
-static int do_getemail(User * u)
-{
- char *email = strtok(NULL, " ");
- int i, j = 0;
- NickCore *nc;
-
- if (!email) {
- syntax_error(s_NickServ, u, "GETMAIL", NICK_GETEMAIL_SYNTAX);
- return MOD_CONT;
- }
- alog("%s: %s!%s@%s used GETEMAIL on %s", s_NickServ, u->nick,
- u->username, u->host, email);
- for (i = 0; i < 1024; i++) {
- for (nc = nclists[i]; nc; nc = nc->next) {
- if (nc->email) {
- if (stricmp(nc->email, email) == 0) {
- j++;
- notice_lang(s_NickServ, u, NICK_GETEMAIL_EMAILS_ARE,
- nc->display, email);
- }
- }
- }
- }
- if (j <= 0) {
- notice_lang(s_NickServ, u, NICK_GETEMAIL_NOT_USED, email);
- return MOD_CONT;
- }
- return MOD_CONT;
-}
-
-/**************************************************************************/
-
-static int do_getpass(User * u)
-{
-#ifndef USE_ENCRYPTION
- char *nick = strtok(NULL, " ");
- NickAlias *na;
- NickRequest *nr = NULL;
-#endif
-
- /* Assumes that permission checking has already been done. */
-#ifdef USE_ENCRYPTION
- notice_lang(s_NickServ, u, NICK_GETPASS_UNAVAILABLE);
-#else
- if (!nick) {
- syntax_error(s_NickServ, u, "GETPASS", NICK_GETPASS_SYNTAX);
- } else if (!(na = findnick(nick))) {
- if ((nr = findrequestnick(nick))) {
- alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick,
- u->username, u->host, nick);
- if (WallGetpass)
- anope_cmd_global(s_NickServ,
- "\2%s\2 used GETPASS on \2%s\2", u->nick,
- nick);
- notice_lang(s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick,
- nr->passcode);
- } else {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- }
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else if (NSSecureAdmins && nick_is_services_admin(na->nc)
- && !is_services_root(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- } else if (NSRestrictGetPass && !is_services_root(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- } else {
- alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick,
- u->username, u->host, nick);
- if (WallGetpass)
- anope_cmd_global(s_NickServ, "\2%s\2 used GETPASS on \2%s\2",
- u->nick, nick);
- notice_lang(s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick,
- na->nc->pass);
- }
-#endif
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_sendpass(User * u)
-{
-#ifndef USE_ENCRYPTION
- char *nick = strtok(NULL, " ");
- NickAlias *na;
-#endif
-
-#ifdef USE_ENCRYPTION
- notice_lang(s_NickServ, u, NICK_SENDPASS_UNAVAILABLE);
-#else
- if (!nick) {
- syntax_error(s_NickServ, u, "SENDPASS", NICK_SENDPASS_SYNTAX);
- } else if (RestrictMail && !is_oper(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- } else if (!(na = findnick(nick))) {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- } else if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- } else {
- char buf[BUFSIZE];
- MailInfo *mail;
-
- snprintf(buf, sizeof(buf), getstring(na, NICK_SENDPASS_SUBJECT),
- na->nick);
- mail = MailBegin(u, na->nc, buf, s_NickServ);
- if (!mail)
- return MOD_CONT;
-
- fprintf(mail->pipe, getstring(na, NICK_SENDPASS_HEAD));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_1), na->nick);
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_2),
- na->nc->pass);
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_3));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_4));
- fprintf(mail->pipe, "\n\n");
- fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_5),
- NetworkName);
- fprintf(mail->pipe, "\n.\n");
-
- MailEnd(mail);
-
- alog("%s: %s!%s@%s used SENDPASS on %s", s_NickServ, u->nick,
- u->username, u->host, nick);
- notice_lang(s_NickServ, u, NICK_SENDPASS_OK, nick);
- }
-#endif
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_forbid(User * u)
-{
- NickAlias *na;
- char *nick = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- /* Assumes that permission checking has already been done. */
- if (!nick || (ForceForbidReason && !reason)) {
- syntax_error(s_NickServ, u, "FORBID",
- (ForceForbidReason ? NICK_FORBID_SYNTAX_REASON :
- NICK_FORBID_SYNTAX));
- return MOD_CONT;
- }
-
- if (readonly)
- notice_lang(s_NickServ, u, READ_ONLY_MODE);
- if ((na = findnick(nick)) != NULL) {
- if (NSSecureAdmins && nick_is_services_admin(na->nc)
- && !is_services_root(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
- delnick(na);
- }
- na = makenick(nick);
- if (na) {
- na->status |= NS_VERBOTEN;
- na->last_usermask = sstrdup(u->nick);
- if (reason)
- na->last_realname = sstrdup(reason);
-
- na->u = finduser(na->nick);
- if (na->u)
- na->u->na = na;
-
- if (na->u) {
- notice_lang(s_NickServ, na->u, FORCENICKCHANGE_NOW);
- collide(na, 0);
- }
-
-
- if (ircd->sqline) {
- anope_cmd_sqline(na->nick, ((reason) ? reason : "Forbidden"));
- }
-
- if (WallForbid)
- anope_cmd_global(s_NickServ, "\2%s\2 used FORBID on \2%s\2",
- u->nick, nick);
-
- alog("%s: %s set FORBID for nick %s", s_NickServ, u->nick, nick);
- notice_lang(s_NickServ, u, NICK_FORBID_SUCCEEDED, nick);
- send_event(EVENT_NICK_FORBIDDEN, nick);
- } else {
- alog("%s: Valid FORBID for %s by %s failed", s_NickServ, nick,
- u->nick);
- notice_lang(s_NickServ, u, NICK_FORBID_FAILED, nick);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_suspend(User * u)
-{
-
- NickAlias *na;
- char *nick = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- if (!nick || !reason) {
- syntax_error(s_NickServ, u, "SUSPEND", NICK_SUSPEND_SYNTAX);
- return MOD_CONT;
- }
-
- if (readonly) {
- notice_lang(s_NickServ, u, READ_ONLY_MODE);
- return MOD_CONT;
- }
-
- if ((na = findnick(nick)) == NULL) {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- return MOD_CONT;
- }
-
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- return MOD_CONT;
- }
-
- if (NSSecureAdmins && nick_is_services_admin(na->nc)
- && !is_services_root(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (na) {
- na->nc->flags |= NI_SUSPENDED;
- na->nc->flags |= NI_SECURE;
- na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED);
- na->nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED);
- na->last_quit = sstrdup(reason);
-
- if (WallForbid)
- anope_cmd_global(s_NickServ, "\2%s\2 used SUSPEND on \2%s\2",
- u->nick, nick);
-
- alog("%s: %s set SUSPEND for nick %s", s_NickServ, u->nick, nick);
- notice_lang(s_NickServ, u, NICK_SUSPEND_SUCCEEDED, nick);
- send_event(EVENT_NICK_SUSPENDED, nick);
-
- } else {
-
- alog("%s: Valid SUSPEND for %s by %s failed", s_NickServ, nick,
- u->nick);
- notice_lang(s_NickServ, u, NICK_SUSPEND_FAILED, nick);
-
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_unsuspend(User * u)
-{
- NickAlias *na;
- char *nick = strtok(NULL, " ");
-
- if (!nick) {
- syntax_error(s_NickServ, u, "UNSUSPEND", NICK_UNSUSPEND_SYNTAX);
- return MOD_CONT;
- }
-
- if (readonly) {
- notice_lang(s_NickServ, u, READ_ONLY_MODE);
- return MOD_CONT;
- }
-
- if ((na = findnick(nick)) == NULL) {
- notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- return MOD_CONT;
- }
-
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- return MOD_CONT;
- }
- if (NSSecureAdmins && nick_is_services_admin(na->nc)
- && !is_services_root(u)) {
- notice_lang(s_NickServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (na) {
- na->nc->flags &= ~NI_SUSPENDED;
-
- if (WallForbid)
- anope_cmd_global(s_NickServ, "\2%s\2 used UNSUSPEND on \2%s\2",
- u->nick, nick);
-
- alog("%s: %s set UNSUSPEND for nick %s", s_NickServ, u->nick,
- nick);
- notice_lang(s_NickServ, u, NICK_UNSUSPEND_SUCCEEDED, nick);
- send_event(EVENT_NICK_UNSUSPEND, nick);
-
- } else {
-
- alog("%s: Valid UNSUSPEND for %s by %s failed", s_NickServ, nick,
- u->nick);
- notice_lang(s_NickServ, u, NICK_UNSUSPEND_FAILED, nick);
-
- }
-
- return MOD_CONT;
-
-}
-
-/*************************************************************************/
-
-int ns_do_register(User * u)
-{
- return do_register(u);
-}
-
-/*************************************************************************/
/*
* Nick tracking
*/
diff --git a/src/operserv.c b/src/operserv.c
index 42b1b94b5..08b42ad15 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -15,23 +15,16 @@
#include "services.h"
#include "pseudo.h"
-extern Module *mod_current_module;
-extern int mod_current_op;
-extern User *mod_current_user;
-extern ModuleHash *MODULE_HASH[MAX_CMD_HASH];
/*************************************************************************/
-struct clone {
- char *host;
- long time;
-};
+
/* List of most recent users - statically initialized to zeros */
-static struct clone clonelist[CLONE_DETECT_SIZE];
+struct clone clonelist[CLONE_DETECT_SIZE];
/* Which hosts have we warned about, and when? This is used to keep us
* from sending out notices over and over for clones from the same host. */
-static struct clone warnings[CLONE_DETECT_SIZE];
+struct clone warnings[CLONE_DETECT_SIZE];
/* List of Services administrators */
SList servadmins;
@@ -42,8 +35,6 @@ SList akills, sglines, sqlines, szlines;
/*************************************************************************/
-static void get_operserv_stats(long *nrec, long *memuse);
-
static int compare_adminlist_entries(SList * slist, void *item1,
void *item2);
static int compare_operlist_entries(SList * slist, void *item1,
@@ -60,66 +51,20 @@ static void free_sqline_entry(SList * slist, void *item);
static int is_szline_entry_equal(SList * slist, void *item1, void *item2);
static void free_szline_entry(SList * slist, void *item);
-static int do_help(User * u);
-static int do_global(User * u);
-static int do_stats(User * u);
-static int do_admin(User * u);
-static int do_oper(User * u);
-static int do_os_mode(User * u);
-static int do_clearmodes(User * u);
-static int do_os_kick(User * u);
-static int do_akill(User * u);
-static int do_sgline(User * u);
-static int do_sqline(User * u);
-static int do_szline(User * u);
-static int do_set(User * u);
-static int do_noop(User * u);
-static int do_jupe(User * u);
-static int do_raw(User * u);
-static int do_update(User * u);
-static int do_reload(User * u);
-static int do_os_quit(User * u);
-static int do_shutdown(User * u);
-static int do_restart(User * u);
-static int do_ignorelist(User * u);
-static int do_clearignore(User * u);
-static int do_killclones(User * u);
-static int do_chanlist(User * u);
-static int do_userlist(User * u);
-static int do_ignoreuser(User * u);
-static int do_staff(User * u);
-static int do_defcon(User * u);
-static int do_chankill(User * u);
-static void defcon_sendlvls(User * u);
-char *defconReverseModes(const char *modes);
-int DefConModesSet = 0;
+void resetDefCon(int level);
+
time_t DefContimer;
+int DefConModesSet = 0;
void runDefCon(void);
-void resetDefCon(int level);
+char *defconReverseModes(const char *modes);
void oper_global(char *nick, char *fmt, ...);
-#ifdef USE_MODULES
-int do_modload(User * u);
-int do_modunload(User * u);
-int do_modlist(User * u);
-int do_modinfo(User * u);
-static int showModuleCmdLoaded(CommandHash * cmdList, char *mod_name,
- User * u);
-static int showModuleMsgLoaded(MessageHash * msgList, char *mod_name,
- User * u);
-#endif
-
-static int do_operumodes(User * u);
-static int do_svsnick(User * u);
-static int do_operoline(User * u);
#ifdef DEBUG_COMMANDS
static int send_clone_lists(User * u);
static int do_matchwild(User * u);
#endif
-/* OperServ restart needs access to this if were gonna avoid sending ourself a signal */
-extern int do_restart_services(void);
void moduleAddOperServCmds(void);
/*************************************************************************/
@@ -140,70 +85,9 @@ SListOpts szopts = { 0, NULL, &is_szline_entry_equal, &free_szline_entry };
/* *INDENT-OFF* */
void moduleAddOperServCmds(void) {
Command *c;
- c = createCommand("HELP", do_help, NULL, -1, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("GLOBAL", do_global, NULL, OPER_HELP_GLOBAL, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("STATS", do_stats, NULL, OPER_HELP_STATS, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("UPTIME", do_stats, NULL, OPER_HELP_STATS, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-
- /* Anyone can use the LIST option to the ADMIN and OPER commands; those
- * routines check privileges to ensure that only authorized users
- * modify the list. */
- c = createCommand("ADMIN", do_admin, NULL, OPER_HELP_ADMIN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("OPER", do_oper, NULL, OPER_HELP_OPER, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("STAFF", do_staff, NULL, OPER_HELP_STAFF, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- /* Similarly, anyone can use *NEWS LIST, but *NEWS {ADD,DEL} are
- * reserved for Services admins. */
- c = createCommand("LOGONNEWS", do_logonnews, NULL, NEWS_HELP_LOGON, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("OPERNEWS", do_opernews, NULL, NEWS_HELP_OPER, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("RANDOMNEWS", do_randomnews, NULL, NEWS_HELP_RANDOM, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-
- /* Commands for Services opers: */
- c = createCommand("MODE", do_os_mode, is_services_oper,OPER_HELP_MODE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("CLEARMODES", do_clearmodes, is_services_oper,OPER_HELP_CLEARMODES, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("KICK", do_os_kick, is_services_oper,OPER_HELP_KICK, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("KILLCLONES", do_killclones, is_services_oper,OPER_HELP_KILLCLONES, -1,-1,-1, -1); addCoreCommand(OPERSERV,c);
- c = createCommand("AKILL", do_akill, is_services_oper,OPER_HELP_AKILL, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SGLINE", do_sgline, is_services_oper,OPER_HELP_SGLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SQLINE", do_sqline, is_services_oper,OPER_HELP_SQLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SZLINE", do_szline, is_services_oper,OPER_HELP_SZLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-
- /* Commands for Services admins: */
- c = createCommand("SET", do_set, is_services_admin,OPER_HELP_SET, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET LIST", NULL, NULL,OPER_HELP_SET_LIST, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET READONLY", NULL, NULL,OPER_HELP_SET_READONLY, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET LOGCHAN", NULL, NULL,OPER_HELP_SET_LOGCHAN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET DEBUG", NULL, NULL,OPER_HELP_SET_DEBUG, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET NOEXPIRE", NULL, NULL,OPER_HELP_SET_NOEXPIRE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET IGNORE", NULL, NULL,OPER_HELP_SET_IGNORE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET SUPERADMIN", NULL, NULL,OPER_HELP_SET_SUPERADMIN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-#ifdef USE_MYSQL
- c = createCommand("SET SQL", NULL, NULL,OPER_HELP_SET_SQL, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-#endif
- c = createCommand("SVSNICK", do_svsnick, is_services_admin,OPER_HELP_SVSNICK, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("UMODE", do_operumodes, is_services_admin,OPER_HELP_UMODE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("NOOP", do_noop, is_services_admin,OPER_HELP_NOOP, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("JUPE", do_jupe, is_services_admin,OPER_HELP_JUPE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("RAW", do_raw, is_services_admin,OPER_HELP_RAW, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("IGNORE", do_ignoreuser, is_services_admin,OPER_HELP_IGNORE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("OLINE", do_operoline, is_services_admin,OPER_HELP_OLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("UPDATE", do_update, is_services_admin,OPER_HELP_UPDATE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("RELOAD", do_reload, is_services_admin,OPER_HELP_RELOAD, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("QUIT", do_os_quit, is_services_admin,OPER_HELP_QUIT, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SHUTDOWN", do_shutdown, is_services_admin,OPER_HELP_SHUTDOWN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("RESTART", do_restart, is_services_admin,OPER_HELP_RESTART, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SESSION", do_session, is_services_admin,OPER_HELP_SESSION, -1,-1,-1, -1); addCoreCommand(OPERSERV,c);
- c = createCommand("EXCEPTION", do_exception, is_services_admin,OPER_HELP_EXCEPTION, -1,-1,-1, -1); addCoreCommand(OPERSERV,c);
- c = createCommand("CHANLIST", do_chanlist, is_services_admin,OPER_HELP_CHANLIST, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("USERLIST", do_userlist, is_services_admin,OPER_HELP_USERLIST, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("DEFCON", do_defcon, is_services_admin, OPER_HELP_DEFCON,-1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("CHANKILL", do_chankill, is_services_admin, OPER_HELP_CHANKILL,-1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- /* Commands for Services root: */
-#ifdef USE_MODULES
- c = createCommand("MODLOAD", do_modload, is_services_root, -1,-1,-1,-1,OPER_HELP_MODLOAD); addCoreCommand(OPERSERV,c);
- c = createCommand("MODUNLOAD", do_modunload, is_services_root, -1,-1,-1,-1,OPER_HELP_MODUNLOAD); addCoreCommand(OPERSERV,c);
- c = createCommand("MODLIST", do_modlist, is_services_root, -1,-1,-1,-1,OPER_HELP_MODLIST); addCoreCommand(OPERSERV,c);
- c = createCommand("MODINFO", do_modinfo, is_services_root, -1,-1,-1,-1,OPER_HELP_MODINFO); addCoreCommand(OPERSERV,c);
-#endif
+
+ modules_core_init(OperServCoreNumber, OperServCoreModules);
+
#ifdef DEBUG_COMMANDS
c = createCommand("LISTTIMERS", send_timeout_list, is_services_root, -1,-1,-1,-1,-1); addCoreCommand(OPERSERV,c);
c = createCommand("MATCHWILD", do_matchwild, is_services_root, -1,-1,-1,-1,-1); addCoreCommand(OPERSERV,c);
@@ -278,88 +162,6 @@ void operserv(User * u, char *buf)
}
}
-static void get_operserv_stats(long *nrec, long *memuse)
-{
- int i;
- long mem = 0, count = 0, mem2 = 0, count2 = 0;
- Akill *ak;
- SXLine *sx;
-
- if (CheckClones) {
- mem = sizeof(struct clone) * CLONE_DETECT_SIZE * 2;
- for (i = 0; i < CLONE_DETECT_SIZE; i++) {
- if (clonelist[i].host) {
- count++;
- mem += strlen(clonelist[i].host) + 1;
- }
- if (warnings[i].host) {
- count++;
- mem += strlen(warnings[i].host) + 1;
- }
- }
- }
-
- count += akills.count;
- mem += akills.capacity;
- mem += akills.count * sizeof(Akill);
-
- for (i = 0; i < akills.count; i++) {
- ak = akills.list[i];
- mem += strlen(ak->user) + 1;
- mem += strlen(ak->host) + 1;
- mem += strlen(ak->by) + 1;
- mem += strlen(ak->reason) + 1;
- }
-
- if (ircd->sgline) {
- count += sglines.count;
- mem += sglines.capacity;
- mem += sglines.count * sizeof(SXLine);
-
- for (i = 0; i < sglines.count; i++) {
- sx = sglines.list[i];
- mem += strlen(sx->mask) + 1;
- mem += strlen(sx->by) + 1;
- mem += strlen(sx->reason) + 1;
- }
- }
- if (ircd->sqline) {
- count += sqlines.count;
- mem += sqlines.capacity;
- mem += sqlines.count * sizeof(SXLine);
-
- for (i = 0; i < sqlines.count; i++) {
- sx = sqlines.list[i];
- mem += strlen(sx->mask) + 1;
- mem += strlen(sx->by) + 1;
- mem += strlen(sx->reason) + 1;
- }
- }
- if (ircd->szline) {
- count += szlines.count;
- mem += szlines.capacity;
- mem += szlines.count * sizeof(SXLine);
-
- for (i = 0; i < szlines.count; i++) {
- sx = szlines.list[i];
- mem += strlen(sx->mask) + 1;
- mem += strlen(sx->by) + 1;
- mem += strlen(sx->reason) + 1;
- }
- }
-
-
- get_news_stats(&count2, &mem2);
- count += count2;
- mem += mem2;
- get_exception_stats(&count2, &mem2);
- count += count2;
- mem += mem2;
-
- *nrec = count;
- *memuse = mem;
-}
-
/*************************************************************************/
/**************************** Privilege checks ***************************/
/*************************************************************************/
@@ -915,73 +717,8 @@ static int send_clone_lists(User * u)
/*********************** OperServ command functions **********************/
/*************************************************************************/
-/* HELP command. */
-
-static int do_help(User * u)
-{
- const char *cmd = strtok(NULL, "");
-
- if (!cmd) {
- notice_help(s_OperServ, u, OPER_HELP);
- if (is_services_oper(u)) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD);
- if (ircd->sgline || ircd->sqline || ircd->szline) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD_EXTRA);
- }
- if (ircd->sgline) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD_SGLINE);
- }
- if (ircd->sqline) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD_SQLINE);
- }
- if (ircd->szline) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD_SZLINE);
- }
- }
- if (is_services_admin(u)) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD);
- if (ircd->svsnick || ircd->omode || ircd->umode) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD_EXTRA);
- }
- if (ircd->svsnick) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD_SVSNICK);
- }
- if (ircd->omode) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD_OLINE);
- }
- if (ircd->umode) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD_UMODE);
- }
- }
-#ifdef USE_MODULES
- if (is_services_root(u)) {
- notice_help(s_OperServ, u, OPER_HELP_ROOT_CMD);
- }
-#endif
- moduleDisplayHelp(5, u);
- notice_help(s_OperServ, u, OPER_HELP_LOGGED);
- } else {
- mod_help_cmd(s_OperServ, u, OPERSERV, cmd);
- }
- return MOD_CONT;
-}
-
/*************************************************************************/
-static int do_global(User * u)
-{
- char *msg = strtok(NULL, "");
-
- if (!msg) {
- syntax_error(s_OperServ, u, "GLOBAL", OPER_GLOBAL_SYNTAX);
- return MOD_CONT;
- }
- if (WallOSGlobal)
- anope_cmd_global(s_OperServ, "\2%s\2 just used GLOBAL command.",
- u->nick);
- oper_global(u->nick, "%s", msg);
- return MOD_CONT;
-}
Server *server_global(Server * s, char *msg)
{
@@ -1023,934 +760,10 @@ void oper_global(char *nick, char *fmt, ...)
}
-/*************************************************************************/
-
-/* STATS command. */
-
-static int do_stats(User * u)
-{
- time_t uptime = time(NULL) - start_time;
- char *extra = strtok(NULL, "");
- int days = uptime / 86400, hours = (uptime / 3600) % 24,
- mins = (uptime / 60) % 60, secs = uptime % 60;
- struct tm *tm;
- char timebuf[64];
-
- if (extra && stricmp(extra, "ALL") != 0) {
- if (stricmp(extra, "AKILL") == 0) {
- int timeout;
- /* AKILLs */
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_COUNT,
- akills.count);
- timeout = AutokillExpiry + 59;
- if (timeout >= 172800)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAYS,
- timeout / 86400);
- else if (timeout >= 86400)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAY);
- else if (timeout >= 7200)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOURS,
- timeout / 3600);
- else if (timeout >= 3600)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOUR);
- else if (timeout >= 120)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MINS,
- timeout / 60);
- else if (timeout >= 60)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MIN);
- else
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_NONE);
- if (ircd->sgline) {
- /* SGLINEs */
- notice_lang(s_OperServ, u, OPER_STATS_SGLINE_COUNT,
- sglines.count);
- timeout = SGLineExpiry + 59;
- if (timeout >= 172800)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_DAYS,
- timeout / 86400);
- else if (timeout >= 86400)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_DAY);
- else if (timeout >= 7200)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_HOURS,
- timeout / 3600);
- else if (timeout >= 3600)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_HOUR);
- else if (timeout >= 120)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_MINS,
- timeout / 60);
- else if (timeout >= 60)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_MIN);
- else
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_NONE);
- }
- if (ircd->sqline) {
- /* SQLINEs */
- notice_lang(s_OperServ, u, OPER_STATS_SQLINE_COUNT,
- sqlines.count);
- timeout = SQLineExpiry + 59;
- if (timeout >= 172800)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_DAYS,
- timeout / 86400);
- else if (timeout >= 86400)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_DAY);
- else if (timeout >= 7200)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_HOURS,
- timeout / 3600);
- else if (timeout >= 3600)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_HOUR);
- else if (timeout >= 120)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_MINS,
- timeout / 60);
- else if (timeout >= 60)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_MIN);
- else
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_NONE);
- }
- if (ircd->szline) {
- /* SZLINEs */
- notice_lang(s_OperServ, u, OPER_STATS_SZLINE_COUNT,
- szlines.count);
- timeout = SZLineExpiry + 59;
- if (timeout >= 172800)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_DAYS,
- timeout / 86400);
- else if (timeout >= 86400)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_DAY);
- else if (timeout >= 7200)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_HOURS,
- timeout / 3600);
- else if (timeout >= 3600)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_HOUR);
- else if (timeout >= 120)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_MINS,
- timeout / 60);
- else if (timeout >= 60)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_MIN);
- else
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_NONE);
- }
- return MOD_CONT;
- } else if (!stricmp(extra, "RESET")) {
- if (is_services_admin(u)) {
- maxusercnt = usercnt;
- notice_lang(s_OperServ, u, OPER_STATS_RESET);
- } else {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- }
- return MOD_CONT;
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UNKNOWN_OPTION, extra);
- }
- }
-
- notice_lang(s_OperServ, u, OPER_STATS_CURRENT_USERS, usercnt, opcnt);
- tm = localtime(&maxusertime);
- strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT,
- tm);
- notice_lang(s_OperServ, u, OPER_STATS_MAX_USERS, maxusercnt, timebuf);
- if (days > 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_DHMS,
- days, hours, mins, secs);
- } else if (days == 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1DHMS,
- days, hours, mins, secs);
- } else {
- if (hours > 1) {
- if (mins != 1) {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HMS,
- hours, mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HM1S,
- hours, mins, secs);
- }
- } else {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1MS,
- hours, mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1M1S,
- hours, mins, secs);
- }
- }
- } else if (hours == 1) {
- if (mins != 1) {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HMS,
- hours, mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HM1S,
- hours, mins, secs);
- }
- } else {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1MS,
- hours, mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1M1S,
- hours, mins, secs);
- }
- }
- } else {
- if (mins != 1) {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_MS,
- mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_M1S,
- mins, secs);
- }
- } else {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1MS,
- mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1M1S,
- mins, secs);
- }
- }
- }
- }
-
- if (extra && stricmp(extra, "ALL") == 0 && is_services_admin(u)) {
- long count, mem;
-
- notice_lang(s_OperServ, u, OPER_STATS_BYTES_READ,
- total_read / 1024);
- notice_lang(s_OperServ, u, OPER_STATS_BYTES_WRITTEN,
- total_written / 1024);
-
- get_user_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_USER_MEM, count,
- (mem + 512) / 1024);
- get_channel_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_CHANNEL_MEM, count,
- (mem + 512) / 1024);
- get_core_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_GROUPS_MEM, count,
- (mem + 512) / 1024);
- get_aliases_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_ALIASES_MEM, count,
- (mem + 512) / 1024);
- get_chanserv_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_CHANSERV_MEM, count,
- (mem + 512) / 1024);
- get_botserv_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_BOTSERV_MEM, count,
- (mem + 512) / 1024);
- get_operserv_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_OPERSERV_MEM, count,
- (mem + 512) / 1024);
- get_session_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_SESSIONS_MEM, count,
- (mem + 512) / 1024);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* make Services ignore users for a certain time */
-
-static int do_ignoreuser(User * u)
-{
- char *cmd = strtok(NULL, " ");
- int t;
-
- if (!cmd) {
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- return MOD_CONT;
- }
-
- if (!stricmp(cmd, "ADD")) {
-
- char *time = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
- char *rest = strtok(NULL, "");
-
- if (!nick) {
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- return MOD_CONT;
- } else if (!time) {
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- return MOD_CONT;
- } else {
- t = dotime(time);
- rest = NULL;
-
- if (t <= -1) {
- notice_lang(s_OperServ, u, OPER_IGNORE_VALID_TIME);
- return MOD_CONT;
- } else if (t == 0) {
- t = 157248000; /* if 0 is given, we set time to 157248000 seconds == 5 years (let's hope the next restart will be before that time ;-)) */
- add_ignore(nick, t);
- notice_lang(s_OperServ, u, OPER_IGNORE_PERM_DONE, nick);
- } else {
- add_ignore(nick, t);
- notice_lang(s_OperServ, u, OPER_IGNORE_TIME_DONE, nick,
- time);
- }
- }
- } else if (!stricmp(cmd, "LIST")) {
- do_ignorelist(u);
- }
-
- else if (!stricmp(cmd, "DEL")) {
- char *nick = strtok(NULL, " ");
- if (!nick) {
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- } else {
- if (get_ignore(nick) == 0) {
- notice_lang(s_OperServ, u, OPER_IGNORE_LIST_NOMATCH, nick);
- return MOD_CONT;
- } else {
- delete_ignore(nick);
- notice_lang(s_OperServ, u, OPER_IGNORE_DEL_DONE, nick);
- }
- }
- } else if (!stricmp(cmd, "CLEAR")) {
- do_clearignore(u);
-
- } else
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* deletes a nick from the ignore list */
-
-void delete_ignore(const char *nick)
-{
- IgnoreData *ign, *prev;
- IgnoreData **whichlist;
-
- if (!nick || !*nick) {
- return;
- }
-
- whichlist = &ignore[tolower(nick[0])];
-
- for (ign = *whichlist, prev = NULL; ign; prev = ign, ign = ign->next) {
- if (stricmp(ign->who, nick) == 0)
- break;
- }
- if (prev)
- prev->next = ign->next;
- else
- *whichlist = ign->next;
- free(ign);
- ign = NULL;
-}
-
-/*************************************************************************/
-
-/* shows the Services ignore list */
-
-static int do_ignorelist(User * u)
-{
- int sent_header = 0;
- IgnoreData *id;
- int i;
-
- for (i = 0; i < 256; i++) {
- for (id = ignore[i]; id; id = id->next) {
- if (!sent_header) {
- notice_lang(s_OperServ, u, OPER_IGNORE_LIST);
- sent_header = 1;
- }
- notice_user(s_OperServ, u, "%s", id->who);
- }
- }
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_IGNORE_LIST_EMPTY);
- return MOD_CONT;
-}
-
-/**************************************************************************/
-/* Cleares the Services ignore list */
-
-static int do_clearignore(User * u)
-{
- IgnoreData *id = NULL, *next = NULL;
- int i;
- for (i = 0; i < 256; i++) {
- for (id = ignore[i]; id; id = next) {
- next = id->next;
- free(id);
- if (!next) {
- ignore[i] = NULL;
- }
- }
- }
- notice_lang(s_OperServ, u, OPER_IGNORE_LIST_CLEARED);
- return MOD_CONT;
-}
-
-/**************************************************************************/
-
-/* Channel mode changing (MODE command). */
-
-static int do_os_mode(User * u)
-{
- int ac;
- char **av;
- char *chan = strtok(NULL, " "), *modes = strtok(NULL, "");
- Channel *c;
-
- if (!chan || !modes) {
- syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
- return MOD_CONT;
- }
-
- if (!(c = findchan(chan))) {
- notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (c->bouncy_modes) {
- notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
- return MOD_CONT;
- } else if ((ircd->adminmode) && (!is_services_admin(u))
- && (c->mode & ircd->adminmode)) {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- } else {
- anope_cmd_mode(s_OperServ, chan, "%s", modes);
-
- ac = split_buf(modes, &av, 1);
- chan_set_modes(s_OperServ, c, ac, av, 0);
-
- if (WallOSMode)
- anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick,
- modes, chan);
- }
- return MOD_CONT;
-}
-
-/**************************************************************************/
-
-/**
- * Change any user's UMODES
- *
- * modified to be part of the SuperAdmin directive -jester
- * check user flag for SuperAdmin -rob
- */
-static int do_operumodes(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *modes = strtok(NULL, "");
-
- User *u2;
-
- if (!ircd->umode) {
- notice_lang(s_OperServ, u, OPER_UMODE_UNSUPPORTED);
- return MOD_CONT;
- }
-
- /* Only allow this if SuperAdmin is enabled */
- if (!u->isSuperAdmin) {
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
- return MOD_CONT;
- }
-
- if (!nick || !modes) {
- syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX);
- return MOD_CONT;
- }
-
- /**
- * Only accept a +/- mode string
- *-rob
- **/
- if ((modes[0] != '+') && (modes[0] != '-')) {
- syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX);
- return MOD_CONT;
- }
- if (!(u2 = finduser(nick))) {
- notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
- } else {
- anope_cmd_mode(s_OperServ, nick, "%s", modes);
-
- common_svsmode(u2, modes, NULL);
-
- notice_lang(s_OperServ, u, OPER_UMODE_SUCCESS, nick);
- notice_lang(s_OperServ, u2, OPER_UMODE_CHANGED, u->nick);
-
- if (WallOSMode)
- anope_cmd_global(s_OperServ, "\2%s\2 used UMODE on %s",
- u->nick, nick);
- }
- return MOD_CONT;
-}
-
/**************************************************************************/
-/**
- * give Operflags to any user
- *
- * modified to be part of the SuperAdmin directive -jester
- * check u-> for SuperAdmin -rob
- */
-
-static int do_operoline(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *flags = strtok(NULL, "");
- User *u2 = NULL;
-
- if (!ircd->omode) {
- notice_lang(s_OperServ, u, OPER_SVSO_UNSUPPORTED);
- return MOD_CONT;
- }
-
- /* Only allow this if SuperAdmin is enabled */
- if (!u->isSuperAdmin) {
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
- return MOD_CONT;
- }
-
- if (!nick || !flags) {
- syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
- return MOD_CONT;
- } else {
- u2 = finduser(nick);
-
-/* let's check whether the user is online */
-
- if (!finduser(nick)) {
- notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
- } else if (u2 && flags[0] == '+') {
- anope_cmd_svso(s_OperServ, nick, flags);
- anope_cmd_mode(s_OperServ, nick, "+o");
- common_svsmode(u2, "+o", NULL);
- notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP);
- notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
- anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
- u->nick, nick);
- } else if (u2 && flags[0] == '-') {
- anope_cmd_svso(s_OperServ, nick, flags);
- notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
- anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
- u->nick, nick);
- } else
- syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Clear all modes from a channel. */
-
-static int do_clearmodes(User * u)
-{
- char *s;
- int i;
- char *argv[2];
- char *chan = strtok(NULL, " ");
- Channel *c;
- int all = 0;
- int count; /* For saving ban info */
- char **bans; /* For saving ban info */
- int exceptcount; /* For saving except info */
- char **excepts; /* For saving except info */
- int invitecount; /* For saving invite info */
- char **invites; /* For saving invite info */
- struct c_userlist *cu, *next;
-
- if (!chan) {
- syntax_error(s_OperServ, u, "CLEARMODES", OPER_CLEARMODES_SYNTAX);
- return MOD_CONT;
- } else if (!(c = findchan(chan))) {
- notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
- return MOD_CONT;
- } else if (c->bouncy_modes) {
- notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
- return MOD_CONT;
- } else {
- s = strtok(NULL, " ");
- if (s) {
- if (stricmp(s, "ALL") == 0) {
- all = 1;
- } else {
- syntax_error(s_OperServ, u, "CLEARMODES",
- OPER_CLEARMODES_SYNTAX);
- return MOD_CONT;
- }
- }
-
- if (WallOSClearmodes) {
- anope_cmd_global(s_OperServ, "%s used CLEARMODES%s on %s",
- u->nick, all ? " ALL" : "", chan);
- }
- if (all) {
- /* Clear mode +o */
- if (ircd->svsmode_ucmode) {
- anope_cmd_svsmode_chan(c->name, "-o", NULL);
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_OP)) {
- continue;
- }
- argv[0] = sstrdup("-o");
- argv[1] = cu->user->nick;
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- } else {
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_OP))
- continue;
- argv[0] = sstrdup("-o");
- argv[1] = cu->user->nick;
- anope_cmd_mode(s_OperServ, c->name, "-o %s",
- cu->user->nick);
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- }
-
- if (ircd->svsmode_ucmode) {
- anope_cmd_svsmode_chan(c->name, "-v", NULL);
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_VOICE)) {
- continue;
- }
- argv[0] = sstrdup("-v");
- argv[1] = cu->user->nick;
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- } else {
- /* Clear mode +v */
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_VOICE))
- continue;
- argv[0] = sstrdup("-v");
- argv[1] = sstrdup(cu->user->nick);
- anope_cmd_mode(s_OperServ, c->name, "-v %s",
- cu->user->nick);
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- }
-
- /* Clear mode +h */
- if (ircd->svsmode_ucmode && ircd->halfop) {
- anope_cmd_svsmode_chan(c->name, "-h", NULL);
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) {
- continue;
- }
- argv[0] = sstrdup("-h");
- argv[1] = cu->user->nick;
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- } else {
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_HALFOP))
- continue;
- argv[0] = sstrdup("-h");
- argv[1] = sstrdup(cu->user->nick);
- anope_cmd_mode(s_OperServ, c->name, "-h %s",
- cu->user->nick);
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- }
- /* Clear mode Owners */
- if (ircd->svsmode_ucmode && ircd->owner) {
- anope_cmd_svsmode_chan(c->name, ircd->ownerunset, NULL);
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) {
- continue;
- }
- argv[0] = sstrdup(ircd->ownerunset);
- argv[1] = cu->user->nick;
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- } else {
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_OWNER))
- continue;
- argv[0] = sstrdup(ircd->ownerunset);
- argv[1] = sstrdup(cu->user->nick);
- anope_cmd_mode(s_OperServ, c->name, "%s %s",
- ircd->ownerunset, cu->user->nick);
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- }
- /* Clear mode protected or admins */
- if (ircd->svsmode_ucmode && (ircd->protect || ircd->admin)) {
-
- anope_cmd_svsmode_chan(c->name, ircd->adminunset, NULL);
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) {
- continue;
- }
- argv[0] = sstrdup(ircd->adminunset);
- argv[1] = cu->user->nick;
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- } else {
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_PROTECT))
- continue;
- argv[0] = sstrdup(ircd->adminunset);
- argv[1] = sstrdup(cu->user->nick);
- anope_cmd_mode(s_OperServ, c->name, "%s %s",
- ircd->adminunset, cu->user->nick);
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- }
-
-
- }
-
- if (c->mode) {
- /* Clear modes the bulk of the modes */
- anope_cmd_mode(s_OperServ, c->name, "%s", ircd->modestoremove);
- argv[0] = sstrdup(ircd->modestoremove);
- chan_set_modes(s_OperServ, c, 1, argv, 0);
- free(argv[0]);
-
- /* to prevent the internals from complaining send -k, -L, -f by themselves if we need
- to send them - TSL */
- if (c->key) {
- anope_cmd_mode(s_OperServ, c->name, "-k %s", c->key);
- argv[0] = sstrdup("-k");
- argv[1] = c->key;
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- if (ircd->Lmode && c->redirect) {
- anope_cmd_mode(s_OperServ, c->name, "-L %s", c->redirect);
- argv[0] = sstrdup("-L");
- argv[1] = c->redirect;
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- }
- if (ircd->fmode && c->flood) {
- if (flood_mode_char_remove) {
- anope_cmd_mode(s_OperServ, c->name, "%s %s",
- flood_mode_char_remove, c->flood);
- argv[0] = sstrdup(flood_mode_char_remove);
- argv[1] = c->flood;
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[0]);
- } else {
- if (debug) {
- alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes");
- }
- }
- }
- }
-
- /* Clear bans */
- count = c->bancount;
- bans = scalloc(sizeof(char *) * count, 1);
-
- for (i = 0; i < count; i++)
- bans[i] = sstrdup(c->bans[i]);
-
- for (i = 0; i < count; i++) {
- argv[0] = sstrdup("-b");
- argv[1] = bans[i];
- anope_cmd_mode(s_OperServ, c->name, "-b %s", argv[1]);
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[1]);
- free(argv[0]);
- }
-
- free(bans);
-
- excepts = NULL;
-
- if (ircd->except) {
- /* Clear excepts */
- exceptcount = c->exceptcount;
- excepts = scalloc(sizeof(char *) * exceptcount, 1);
-
- for (i = 0; i < exceptcount; i++)
- excepts[i] = sstrdup(c->excepts[i]);
-
- for (i = 0; i < exceptcount; i++) {
- argv[0] = sstrdup("-e");
- argv[1] = excepts[i];
- anope_cmd_mode(s_OperServ, c->name, "-e %s", argv[1]);
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[1]);
- free(argv[0]);
- }
- if (excepts) {
- free(excepts);
- }
- }
-
- if (ircd->invitemode) {
- /* Clear invites */
- invitecount = c->invitecount;
- invites = scalloc(sizeof(char *) * invitecount, 1);
-
- for (i = 0; i < invitecount; i++)
- invites[i] = sstrdup(c->invite[i]);
-
- for (i = 0; i < invitecount; i++) {
- argv[0] = sstrdup("-I");
- argv[1] = excepts[i];
- anope_cmd_mode(s_OperServ, c->name, "-I %s", argv[1]);
- chan_set_modes(s_OperServ, c, 2, argv, 0);
- free(argv[1]);
- free(argv[0]);
- }
-
- free(invites);
- }
-
- }
-
- if (all) {
- notice_lang(s_OperServ, u, OPER_CLEARMODES_ALL_DONE, chan);
- } else {
- notice_lang(s_OperServ, u, OPER_CLEARMODES_DONE, chan);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Kick a user from a channel (KICK command). */
-
-static int do_os_kick(User * u)
-{
- char *argv[3];
- char *chan, *nick, *s;
- Channel *c;
-
- chan = strtok(NULL, " ");
- nick = strtok(NULL, " ");
- s = strtok(NULL, "");
- if (!chan || !nick || !s) {
- syntax_error(s_OperServ, u, "KICK", OPER_KICK_SYNTAX);
- return MOD_CONT;
- }
- if (!(c = findchan(chan))) {
- notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (c->bouncy_modes) {
- notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
- return MOD_CONT;
- }
- anope_cmd_kick(s_OperServ, chan, nick, "%s (%s)", u->nick, s);
- if (WallOSKick)
- anope_cmd_global(s_OperServ, "%s used KICK on %s/%s", u->nick,
- nick, chan);
- argv[0] = sstrdup(chan);
- argv[1] = sstrdup(nick);
- argv[2] = sstrdup(s);
- do_kick(s_OperServ, 3, argv);
- free(argv[2]);
- free(argv[1]);
- free(argv[0]);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Forcefully change a user's nickname */
-
-static int do_svsnick(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *newnick = strtok(NULL, " ");
-
- NickAlias *na;
- char *c;
-
- if (!ircd->svsnick) {
- notice_lang(s_OperServ, u, OPER_SVSNICK_UNSUPPORTED);
- return MOD_CONT;
- }
-
- /* Only allow this if SuperAdmin is enabled */
- if (!u->isSuperAdmin) {
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
- return MOD_CONT;
- }
-
- if (!nick || !newnick) {
- syntax_error(s_OperServ, u, "SVSNICK", OPER_SVSNICK_SYNTAX);
- return MOD_CONT;
- }
-
- /* Truncate long nicknames to NICKMAX-2 characters */
- if (strlen(newnick) > (NICKMAX - 2)) {
- notice_lang(s_NickServ, u, NICK_X_TRUNCATED,
- newnick, NICKMAX - 2, newnick);
- newnick[NICKMAX - 2] = '\0';
- }
-
- /* Check for valid characters */
- if (*newnick == '-' || isdigit(*newnick)) {
- notice_lang(s_OperServ, u, NICK_X_ILLEGAL, newnick);
- return MOD_CONT;
- }
-#define isvalid(c) (((c) >= 'A' && (c) <= '~') || isdigit(c) || (c) == '-')
- for (c = newnick; *c && (c - newnick) < NICKMAX; c++) {
- if (!isvalid(*c) || isspace(*c)) {
- notice_lang(s_OperServ, u, NICK_X_ILLEGAL, nick);
- return MOD_CONT;
- }
- }
-
- /* Check for a nick in use or a forbidden/suspended nick */
- if (!finduser(nick)) {
- notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
- } else if (finduser(newnick)) {
- notice_lang(s_NickServ, u, NICK_X_IN_USE, newnick);
- } else if ((na = findnick(newnick)) && (na->status & NS_VERBOTEN)) {
- notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, newnick);
- } else {
- notice_lang(s_OperServ, u, OPER_SVSNICK_NEWNICK, nick, newnick);
- anope_cmd_global(s_OperServ, "%s used SVSNICK to change %s to %s",
- u->nick, nick, newnick);
- anope_cmd_svsnick(nick, newnick, time(NULL));
- }
- return MOD_CONT;
-}
+/************************************************************************/
/*************************************************************************/
/* Adds an AKILL to the list. Returns >= 0 on success, -1 if it fails, -2
@@ -2176,313 +989,6 @@ static int is_akill_entry_equal(SList * slist, void *item1, void *item2)
return 0;
}
-/* Lists an AKILL entry, prefixing it with the header if needed */
-
-static int akill_list(int number, Akill * ak, User * u, int *sent_header)
-{
- char mask[BUFSIZE];
-
- if (!ak)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_AKILL_LIST_HEADER);
- *sent_header = 1;
- }
-
- snprintf(mask, sizeof(mask), "%s@%s", ak->user, ak->host);
- notice_lang(s_OperServ, u, OPER_AKILL_LIST_FORMAT, number, mask,
- ak->reason);
-
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int akill_list_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return akill_list(number, item, u, sent_header);
-}
-
-/* Lists an AKILL entry, prefixing it with the header if needed */
-
-static int akill_view(int number, Akill * ak, User * u, int *sent_header)
-{
- char mask[BUFSIZE];
- char timebuf[32], expirebuf[256];
- struct tm tm;
-
- if (!ak)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_AKILL_VIEW_HEADER);
- *sent_header = 1;
- }
-
- snprintf(mask, sizeof(mask), "%s@%s", ak->user, ak->host);
- tm = *localtime(&ak->seton);
- strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT,
- &tm);
- expire_left(u->na, expirebuf, sizeof(expirebuf), ak->expires);
- notice_lang(s_OperServ, u, OPER_AKILL_VIEW_FORMAT, number, mask,
- ak->by, timebuf, expirebuf, ak->reason);
-
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int akill_view_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return akill_view(number, item, u, sent_header);
-}
-
-/* Manage the AKILL list. */
-
-static int do_akill(User * u)
-{
- char *cmd = strtok(NULL, " ");
- char breason[BUFSIZE];
-
- if (!cmd)
- cmd = "";
-
- if (!stricmp(cmd, "ADD")) {
- int deleted = 0;
- char *expiry, *mask, *reason;
- time_t expires;
-
- mask = strtok(NULL, " ");
- if (mask && *mask == '+') {
- expiry = mask;
- mask = strtok(NULL, " ");
- } else {
- expiry = NULL;
- }
-
- expires = expiry ? dotime(expiry) : AutokillExpiry;
- /* If the expiry given does not contain a final letter, it's in days,
- * said the doc. Ah well.
- */
- if (expiry && isdigit(expiry[strlen(expiry) - 1]))
- expires *= 86400;
- /* Do not allow less than a minute expiry time */
- if (expires != 0 && expires < 60) {
- notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
- return MOD_CONT;
- } else if (expires > 0) {
- expires += time(NULL);
- }
-
- if (mask && (reason = strtok(NULL, ""))) {
- /* We first do some sanity check on the proposed mask. */
- if (strchr(mask, '!')) {
- notice_lang(s_OperServ, u, OPER_AKILL_NO_NICK);
- return MOD_CONT;
- }
-
- if (!strchr(mask, '@')) {
- notice_lang(s_OperServ, u, BAD_USERHOST_MASK);
- return MOD_CONT;
- }
-
- if (mask && strspn(mask, "~@.*?") == strlen(mask)) {
- notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask);
- return MOD_CONT;
- }
-
- /**
- * Changed sprintf() to snprintf()and increased the size of
- * breason to match bufsize
- * -Rob
- **/
- if (AddAkiller) {
- snprintf(breason, sizeof(breason), "[%s] %s", u->nick,
- reason);
- reason = sstrdup(breason);
- }
-
- deleted = add_akill(u, mask, u->nick, expires, reason);
- if (deleted < 0)
- return MOD_CONT;
- else if (deleted)
- notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL,
- deleted);
- notice_lang(s_OperServ, u, OPER_AKILL_ADDED, mask);
-
- if (WallOSAkill) {
- char buf[128];
-
- if (!expires) {
- strcpy(buf, "does not expire");
- } else {
- int wall_expiry = expires - time(NULL);
- char *s = NULL;
-
- if (wall_expiry >= 86400) {
- wall_expiry /= 86400;
- s = "day";
- } else if (wall_expiry >= 3600) {
- wall_expiry /= 3600;
- s = "hour";
- } else if (wall_expiry >= 60) {
- wall_expiry /= 60;
- s = "minute";
- }
-
- snprintf(buf, sizeof(buf), "expires in %d %s%s",
- wall_expiry, s,
- (wall_expiry == 1) ? "" : "s");
- }
-
- anope_cmd_global(s_OperServ,
- "%s added an AKILL for %s (%s) (%s)",
- u->nick, mask, reason, buf);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
-
- } else {
- syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX);
- }
-
- } else if (!stricmp(cmd, "DEL")) {
-
- char *mask;
- int res = 0;
-
- mask = strtok(NULL, " ");
-
- if (!mask) {
- syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX);
- return MOD_CONT;
- }
-
- if (akills.count == 0) {
- notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY);
- return MOD_CONT;
- }
-
- if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
- /* Deleting a range */
- res = slist_delete_range(&akills, mask, NULL);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
- return MOD_CONT;
- } else if (res == 1) {
- notice_lang(s_OperServ, u, OPER_AKILL_DELETED_ONE);
- } else {
- notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL,
- res);
- }
- } else {
- if ((res = slist_indexof(&akills, mask)) == -1) {
- notice_lang(s_OperServ, u, OPER_AKILL_NOT_FOUND, mask);
- return MOD_CONT;
- }
-
- slist_delete(&akills, res);
- notice_lang(s_OperServ, u, OPER_AKILL_DELETED, mask);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
-
- } else if (!stricmp(cmd, "LIST")) {
- char *mask;
- int res, sent_header = 0;
-
- if (akills.count == 0) {
- notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, " ");
-
- if (!mask || (isdigit(*mask)
- && strspn(mask, "1234567890,-") == strlen(mask))) {
- res =
- slist_enum(&akills, mask, &akill_list_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
- return MOD_CONT;
- } else {
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill");
- }
- } else {
- int i;
- char amask[BUFSIZE];
-
- for (i = 0; i < akills.count; i++) {
- snprintf(amask, sizeof(amask), "%s@%s",
- ((Akill *) akills.list[i])->user,
- ((Akill *) akills.list[i])->host);
- if (!stricmp(mask, amask)
- || match_wild_nocase(mask, amask))
- akill_list(i + 1, akills.list[i], u, &sent_header);
- }
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
- else {
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill");
- }
- }
- } else if (!stricmp(cmd, "VIEW")) {
- char *mask;
- int res, sent_header = 0;
-
- if (akills.count == 0) {
- notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, " ");
-
- if (!mask || (isdigit(*mask)
- && strspn(mask, "1234567890,-") == strlen(mask))) {
- res =
- slist_enum(&akills, mask, &akill_view_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
- return MOD_CONT;
- }
- } else {
- int i;
- char amask[BUFSIZE];
-
- for (i = 0; i < akills.count; i++) {
- snprintf(amask, sizeof(amask), "%s@%s",
- ((Akill *) akills.list[i])->user,
- ((Akill *) akills.list[i])->host);
- if (!stricmp(mask, amask)
- || match_wild_nocase(mask, amask))
- akill_view(i + 1, akills.list[i], u, &sent_header);
- }
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH);
- }
- } else if (!stricmp(cmd, "CLEAR")) {
- slist_clear(&akills, 1);
- notice_lang(s_OperServ, u, OPER_AKILL_CLEAR);
- } else {
- syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX);
- }
- return MOD_CONT;
-}
/*************************************************************************/
@@ -2667,292 +1173,6 @@ static int is_sgline_entry_equal(SList * slist, void *item1, void *item2)
return 0;
}
-/* Lists an SGLINE entry, prefixing it with the header if needed */
-
-static int sgline_list(int number, SXLine * sx, User * u, int *sent_header)
-{
- if (!sx)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_SGLINE_LIST_HEADER);
- *sent_header = 1;
- }
-
- notice_lang(s_OperServ, u, OPER_SGLINE_LIST_FORMAT, number, sx->mask,
- sx->reason);
-
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int sgline_list_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return sgline_list(number, item, u, sent_header);
-}
-
-/* Lists an SGLINE entry, prefixing it with the header if needed */
-
-static int sgline_view(int number, SXLine * sx, User * u, int *sent_header)
-{
- char timebuf[32], expirebuf[256];
- struct tm tm;
-
- if (!sx)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_SGLINE_VIEW_HEADER);
- *sent_header = 1;
- }
-
- tm = *localtime(&sx->seton);
- strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT,
- &tm);
- expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires);
- notice_lang(s_OperServ, u, OPER_SGLINE_VIEW_FORMAT, number, sx->mask,
- sx->by, timebuf, expirebuf, sx->reason);
-
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int sgline_view_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return sgline_view(number, item, u, sent_header);
-}
-
-
-/* Manage the SGLINE list. */
-
-static int do_sgline(User * u)
-{
- char *cmd = strtok(NULL, " ");
-
- if (!ircd->sgline) {
- notice_lang(s_OperServ, u, OPER_SGLINE_UNSUPPORTED);
- return MOD_CONT;
- }
-
- if (!cmd)
- cmd = "";
-
- if (!stricmp(cmd, "ADD")) {
- int deleted = 0;
- char *expiry, *mask, *reason;
- time_t expires;
-
- mask = strtok(NULL, ":");
- if (mask && *mask == '+') {
- expiry = mask;
- mask = strchr(expiry, ' ');
- if (mask) {
- *mask = 0;
- mask++;
- }
- } else {
- expiry = NULL;
- }
-
- expires = expiry ? dotime(expiry) : SGLineExpiry;
- /* If the expiry given does not contain a final letter, it's in days,
- * said the doc. Ah well.
- */
- if (expiry && isdigit(expiry[strlen(expiry) - 1]))
- expires *= 86400;
- /* Do not allow less than a minute expiry time */
- if (expires != 0 && expires < 60) {
- notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
- return MOD_CONT;
- } else if (expires > 0) {
- expires += time(NULL);
- }
-
- if (mask && (reason = strtok(NULL, ""))) {
- /* We first do some sanity check on the proposed mask. */
-
- if (mask && strspn(mask, "*?") == strlen(mask)) {
- notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask);
- return MOD_CONT;
- }
-
- deleted = add_sgline(u, mask, u->nick, expires, reason);
- if (deleted < 0)
- return MOD_CONT;
- else if (deleted)
- notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL,
- deleted);
- notice_lang(s_OperServ, u, OPER_SGLINE_ADDED, mask);
-
- if (WallOSSGLine) {
- char buf[128];
-
- if (!expires) {
- strcpy(buf, "does not expire");
- } else {
- int wall_expiry = expires - time(NULL);
- char *s = NULL;
-
- if (wall_expiry >= 86400) {
- wall_expiry /= 86400;
- s = "day";
- } else if (wall_expiry >= 3600) {
- wall_expiry /= 3600;
- s = "hour";
- } else if (wall_expiry >= 60) {
- wall_expiry /= 60;
- s = "minute";
- }
-
- snprintf(buf, sizeof(buf), "expires in %d %s%s",
- wall_expiry, s,
- (wall_expiry == 1) ? "" : "s");
- }
-
- anope_cmd_global(s_OperServ,
- "%s added an SGLINE for %s (%s)", u->nick,
- mask, buf);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
-
- } else {
- syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX);
- }
-
- } else if (!stricmp(cmd, "DEL")) {
-
- char *mask;
- int res = 0;
-
- mask = strtok(NULL, "");
-
- if (!mask) {
- syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX);
- return MOD_CONT;
- }
-
- if (sglines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
- /* Deleting a range */
- res = slist_delete_range(&sglines, mask, NULL);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
- return MOD_CONT;
- } else if (res == 1) {
- notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_ONE);
- } else {
- notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL,
- res);
- }
- } else {
- if ((res = slist_indexof(&sglines, mask)) == -1) {
- notice_lang(s_OperServ, u, OPER_SGLINE_NOT_FOUND, mask);
- return MOD_CONT;
- }
-
- slist_delete(&sglines, res);
- notice_lang(s_OperServ, u, OPER_SGLINE_DELETED, mask);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
-
- } else if (!stricmp(cmd, "LIST")) {
- char *mask;
- int res, sent_header = 0;
-
- if (sglines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, "");
-
- if (!mask || (isdigit(*mask)
- && strspn(mask, "1234567890,-") == strlen(mask))) {
- res =
- slist_enum(&sglines, mask, &sgline_list_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
- return MOD_CONT;
- }
- } else {
- int i;
- char *amask;
-
- for (i = 0; i < sglines.count; i++) {
- amask = ((SXLine *) sglines.list[i])->mask;
- if (!stricmp(mask, amask)
- || match_wild_nocase(mask, amask))
- sgline_list(i + 1, sglines.list[i], u, &sent_header);
- }
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
- else {
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SGLine");
- }
- }
- } else if (!stricmp(cmd, "VIEW")) {
- char *mask;
- int res, sent_header = 0;
-
- if (sglines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, "");
-
- if (!mask || (isdigit(*mask)
- && strspn(mask, "1234567890,-") == strlen(mask))) {
- res =
- slist_enum(&sglines, mask, &sgline_view_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
- return MOD_CONT;
- }
- } else {
- int i;
- char *amask;
-
- for (i = 0; i < sglines.count; i++) {
- amask = ((SXLine *) sglines.list[i])->mask;
- if (!stricmp(mask, amask)
- || match_wild_nocase(mask, amask))
- sgline_view(i + 1, sglines.list[i], u, &sent_header);
- }
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH);
- }
- } else if (!stricmp(cmd, "CLEAR")) {
- slist_clear(&sglines, 1);
- notice_lang(s_OperServ, u, OPER_SGLINE_CLEAR);
- } else {
- syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX);
- }
- return MOD_CONT;
-}
-
/*************************************************************************/
/* Adds an SQLINE to the list. Returns >= 0 on success, -1 if it failed, -2 if
@@ -3174,294 +1394,6 @@ static int is_sqline_entry_equal(SList * slist, void *item1, void *item2)
return 0;
}
-/* Lists an SQLINE entry, prefixing it with the header if needed */
-
-static int sqline_list(int number, SXLine * sx, User * u, int *sent_header)
-{
- if (!sx)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_SQLINE_LIST_HEADER);
- *sent_header = 1;
- }
-
- notice_lang(s_OperServ, u, OPER_SQLINE_LIST_FORMAT, number, sx->mask,
- sx->reason);
-
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int sqline_list_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return sqline_list(number, item, u, sent_header);
-}
-
-/* Lists an SQLINE entry, prefixing it with the header if needed */
-
-static int sqline_view(int number, SXLine * sx, User * u, int *sent_header)
-{
- char timebuf[32], expirebuf[256];
- struct tm tm;
-
- if (!sx)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_SQLINE_VIEW_HEADER);
- *sent_header = 1;
- }
-
- tm = *localtime(&sx->seton);
- strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT,
- &tm);
- expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires);
- notice_lang(s_OperServ, u, OPER_SQLINE_VIEW_FORMAT, number, sx->mask,
- sx->by, timebuf, expirebuf, sx->reason);
-
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int sqline_view_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return sqline_view(number, item, u, sent_header);
-}
-
-/* Manage the SQLINE list. */
-
-static int do_sqline(User * u)
-{
- char *cmd = strtok(NULL, " ");
-
- if (!ircd->sqline) {
- notice_lang(s_OperServ, u, OPER_SQLINE_UNSUPPORTED);
- return MOD_CONT;
- }
-
- if (!cmd)
- cmd = "";
-
- if (!stricmp(cmd, "ADD")) {
- int deleted = 0;
- char *expiry, *mask, *reason;
- time_t expires;
-
- mask = strtok(NULL, " ");
- if (mask && *mask == '+') {
- expiry = mask;
- mask = strtok(NULL, " ");
- } else {
- expiry = NULL;
- }
-
- expires = expiry ? dotime(expiry) : SQLineExpiry;
- /* If the expiry given does not contain a final letter, it's in days,
- * said the doc. Ah well.
- */
- if (expiry && isdigit(expiry[strlen(expiry) - 1]))
- expires *= 86400;
- /* Do not allow less than a minute expiry time */
- if (expires != 0 && expires < 60) {
- notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
- return MOD_CONT;
- } else if (expires > 0) {
- expires += time(NULL);
- }
-
- if (mask && (reason = strtok(NULL, ""))) {
-
- /* We first do some sanity check on the proposed mask. */
- if (strspn(mask, "*") == strlen(mask)) {
- notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask);
- return MOD_CONT;
- }
-
- /* Channel SQLINEs are only supported on Bahamut servers */
- if (*mask == '#' && !ircd->chansqline) {
- notice_lang(s_OperServ, u,
- OPER_SQLINE_CHANNELS_UNSUPPORTED);
- return MOD_CONT;
- }
-
- deleted = add_sqline(u, mask, u->nick, expires, reason);
- if (deleted < 0)
- return MOD_CONT;
- else if (deleted)
- notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL,
- deleted);
- notice_lang(s_OperServ, u, OPER_SQLINE_ADDED, mask);
-
- if (WallOSSQLine) {
- char buf[128];
-
- if (!expires) {
- strcpy(buf, "does not expire");
- } else {
- int wall_expiry = expires - time(NULL);
- char *s = NULL;
-
- if (wall_expiry >= 86400) {
- wall_expiry /= 86400;
- s = "day";
- } else if (wall_expiry >= 3600) {
- wall_expiry /= 3600;
- s = "hour";
- } else if (wall_expiry >= 60) {
- wall_expiry /= 60;
- s = "minute";
- }
-
- snprintf(buf, sizeof(buf), "expires in %d %s%s",
- wall_expiry, s,
- (wall_expiry == 1) ? "" : "s");
- }
-
- anope_cmd_global(s_OperServ,
- "%s added an SQLINE for %s (%s)", u->nick,
- mask, buf);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
-
- } else {
- syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX);
- }
-
- } else if (!stricmp(cmd, "DEL")) {
-
- char *mask;
- int res = 0;
-
- mask = strtok(NULL, "");
-
- if (!mask) {
- syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX);
- return MOD_CONT;
- }
-
- if (sqlines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
- /* Deleting a range */
- res = slist_delete_range(&sqlines, mask, NULL);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
- return MOD_CONT;
- } else if (res == 1) {
- notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_ONE);
- } else {
- notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL,
- res);
- }
- } else {
- if ((res = slist_indexof(&sqlines, mask)) == -1) {
- notice_lang(s_OperServ, u, OPER_SQLINE_NOT_FOUND, mask);
- return MOD_CONT;
- }
-
- slist_delete(&sqlines, res);
- notice_lang(s_OperServ, u, OPER_SQLINE_DELETED, mask);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
-
- } else if (!stricmp(cmd, "LIST")) {
- char *mask;
- int res, sent_header = 0;
-
- if (sqlines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, "");
-
- if (!mask || (isdigit(*mask)
- && strspn(mask, "1234567890,-") == strlen(mask))) {
- res =
- slist_enum(&sqlines, mask, &sqline_list_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
- return MOD_CONT;
- }
- } else {
- int i;
- char *amask;
-
- for (i = 0; i < sqlines.count; i++) {
- amask = ((SXLine *) sqlines.list[i])->mask;
- if (!stricmp(mask, amask)
- || match_wild_nocase(mask, amask))
- sqline_list(i + 1, sqlines.list[i], u, &sent_header);
- }
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
- else {
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SQLine");
- }
- }
- } else if (!stricmp(cmd, "VIEW")) {
- char *mask;
- int res, sent_header = 0;
-
- if (sqlines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, "");
-
- if (!mask || (isdigit(*mask)
- && strspn(mask, "1234567890,-") == strlen(mask))) {
- res =
- slist_enum(&sqlines, mask, &sqline_view_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
- return MOD_CONT;
- }
- } else {
- int i;
- char *amask;
-
- for (i = 0; i < sqlines.count; i++) {
- amask = ((SXLine *) sqlines.list[i])->mask;
- if (!stricmp(mask, amask)
- || match_wild_nocase(mask, amask))
- sqline_view(i + 1, sqlines.list[i], u, &sent_header);
- }
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH);
- }
- } else if (!stricmp(cmd, "CLEAR")) {
- slist_clear(&sqlines, 1);
- notice_lang(s_OperServ, u, OPER_SQLINE_CLEAR);
- } else {
- syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX);
- }
- return MOD_CONT;
-}
-
/*************************************************************************/
/* Adds an SZLINE to the list. Returns >= 0 on success, -1 on error, -2 if
@@ -3631,390 +1563,6 @@ static int is_szline_entry_equal(SList * slist, void *item1, void *item2)
return 0;
}
-/* Lists an SZLINE entry, prefixing it with the header if needed */
-
-static int szline_list(int number, SXLine * sx, User * u, int *sent_header)
-{
- if (!sx)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_SZLINE_LIST_HEADER);
- *sent_header = 1;
- }
-
- notice_lang(s_OperServ, u, OPER_SZLINE_LIST_FORMAT, number, sx->mask,
- sx->reason);
-
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int szline_list_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return szline_list(number, item, u, sent_header);
-}
-
-/* Lists an SZLINE entry, prefixing it with the header if needed */
-
-static int szline_view(int number, SXLine * sx, User * u, int *sent_header)
-{
- char timebuf[32], expirebuf[256];
- struct tm tm;
-
- if (!sx)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_SZLINE_VIEW_HEADER);
- *sent_header = 1;
- }
-
- tm = *localtime(&sx->seton);
- strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT,
- &tm);
- expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires);
- notice_lang(s_OperServ, u, OPER_SZLINE_VIEW_FORMAT, number, sx->mask,
- sx->by, timebuf, expirebuf, sx->reason);
-
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int szline_view_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return szline_view(number, item, u, sent_header);
-}
-
-/* Manage the SZLINE list. */
-
-static int do_szline(User * u)
-{
- char *cmd = strtok(NULL, " ");
-
- if (!ircd->szline) {
- notice_lang(s_OperServ, u, OPER_SZLINE_UNSUPPORTED);
- return MOD_CONT;
- }
-
- if (!cmd)
- cmd = "";
-
- if (!stricmp(cmd, "ADD")) {
- int deleted = 0;
- char *expiry, *mask, *reason;
- time_t expires;
-
- mask = strtok(NULL, " ");
- if (mask && *mask == '+') {
- expiry = mask;
- mask = strtok(NULL, " ");
- } else {
- expiry = NULL;
- }
-
- expires = expiry ? dotime(expiry) : SZLineExpiry;
- /* If the expiry given does not contain a final letter, it's in days,
- * said the doc. Ah well.
- */
- if (expiry && isdigit(expiry[strlen(expiry) - 1]))
- expires *= 86400;
- /* Do not allow less than a minute expiry time */
- if (expires != 0 && expires < 60) {
- notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
- return MOD_CONT;
- } else if (expires > 0) {
- expires += time(NULL);
- }
-
- if (mask && (reason = strtok(NULL, ""))) {
- /* We first do some sanity check on the proposed mask. */
-
- if (strchr(mask, '!') || strchr(mask, '@')) {
- notice_lang(s_OperServ, u, OPER_SZLINE_ONLY_IPS);
- return MOD_CONT;
- }
-
- if (strspn(mask, "*?") == strlen(mask)) {
- notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask);
- return MOD_CONT;
- }
-
- deleted = add_szline(u, mask, u->nick, expires, reason);
- if (deleted < 0)
- return MOD_CONT;
- else if (deleted)
- notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_SEVERAL,
- deleted);
- notice_lang(s_OperServ, u, OPER_SZLINE_ADDED, mask);
-
- if (WallOSSZLine) {
- char buf[128];
-
- if (!expires) {
- strcpy(buf, "does not expire");
- } else {
- int wall_expiry = expires - time(NULL);
- char *s = NULL;
-
- if (wall_expiry >= 86400) {
- wall_expiry /= 86400;
- s = "day";
- } else if (wall_expiry >= 3600) {
- wall_expiry /= 3600;
- s = "hour";
- } else if (wall_expiry >= 60) {
- wall_expiry /= 60;
- s = "minute";
- }
-
- snprintf(buf, sizeof(buf), "expires in %d %s%s",
- wall_expiry, s,
- (wall_expiry == 1) ? "" : "s");
- }
-
- anope_cmd_global(s_OperServ,
- "%s added an SZLINE for %s (%s)", u->nick,
- mask, buf);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
-
- } else {
- syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX);
- }
-
- } else if (!stricmp(cmd, "DEL")) {
-
- char *mask;
- int res = 0;
-
- mask = strtok(NULL, " ");
-
- if (!mask) {
- syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX);
- return MOD_CONT;
- }
-
- if (szlines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) {
- /* Deleting a range */
- res = slist_delete_range(&szlines, mask, NULL);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
- return MOD_CONT;
- } else if (res == 1) {
- notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_ONE);
- } else {
- notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_SEVERAL,
- res);
- }
- } else {
- if ((res = slist_indexof(&szlines, mask)) == -1) {
- notice_lang(s_OperServ, u, OPER_SZLINE_NOT_FOUND, mask);
- return MOD_CONT;
- }
-
- slist_delete(&szlines, res);
- notice_lang(s_OperServ, u, OPER_SZLINE_DELETED, mask);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
-
- } else if (!stricmp(cmd, "LIST")) {
- char *mask;
- int res, sent_header = 0;
-
- if (szlines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, " ");
-
- if (!mask || (isdigit(*mask)
- && strspn(mask, "1234567890,-") == strlen(mask))) {
- res =
- slist_enum(&szlines, mask, &szline_list_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
- return MOD_CONT;
- }
- } else {
- int i;
- char *amask;
-
- for (i = 0; i < szlines.count; i++) {
- amask = ((SXLine *) szlines.list[i])->mask;
- if (!stricmp(mask, amask)
- || match_wild_nocase(mask, amask))
- szline_list(i + 1, szlines.list[i], u, &sent_header);
- }
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
- }
- } else if (!stricmp(cmd, "VIEW")) {
- char *mask;
- int res, sent_header = 0;
-
- if (szlines.count == 0) {
- notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, " ");
-
- if (!mask || (isdigit(*mask)
- && strspn(mask, "1234567890,-") == strlen(mask))) {
- res =
- slist_enum(&szlines, mask, &szline_view_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
- return MOD_CONT;
- }
- } else {
- int i;
- char *amask;
-
- for (i = 0; i < szlines.count; i++) {
- amask = ((SXLine *) szlines.list[i])->mask;
- if (!stricmp(mask, amask)
- || match_wild_nocase(mask, amask))
- szline_view(i + 1, szlines.list[i], u, &sent_header);
- }
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH);
- }
- } else if (!stricmp(cmd, "CLEAR")) {
- slist_clear(&szlines, 1);
- notice_lang(s_OperServ, u, OPER_SZLINE_CLEAR);
- } else {
- syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_chanlist(User * u)
-{
- char *pattern = strtok(NULL, " ");
- char *opt = strtok(NULL, " ");
-
- int modes = 0;
- User *u2;
-
- if (opt && !stricmp(opt, "SECRET"))
- modes |= (CMODE_s | CMODE_p);
-
- if (pattern && (u2 = finduser(pattern))) {
- struct u_chanlist *uc;
-
- notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick);
-
- for (uc = u2->chans; uc; uc = uc->next) {
- if (modes && !(uc->chan->mode & modes))
- continue;
- notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD,
- uc->chan->name, uc->chan->usercount,
- chan_get_modes(uc->chan, 1, 1),
- (uc->chan->topic ? uc->chan->topic : ""));
- }
- } else {
- int i;
- Channel *c;
-
- notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER);
-
- for (i = 0; i < 1024; i++) {
- for (c = chanlist[i]; c; c = c->next) {
- if (pattern && !match_wild_nocase(pattern, c->name))
- continue;
- if (modes && !(c->mode & modes))
- continue;
- notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, c->name,
- c->usercount, chan_get_modes(c, 1, 1),
- (c->topic ? c->topic : ""));
- }
- }
- }
-
- notice_lang(s_OperServ, u, OPER_CHANLIST_END);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_userlist(User * u)
-{
- char *pattern = strtok(NULL, " ");
- char *opt = strtok(NULL, " ");
-
- Channel *c;
- int modes = 0;
-
- if (opt && !stricmp(opt, "INVISIBLE"))
- modes |= UMODE_i;
-
- if (pattern && (c = findchan(pattern))) {
- struct c_userlist *cu;
-
- notice_lang(s_OperServ, u, OPER_USERLIST_HEADER_CHAN, pattern);
-
- for (cu = c->users; cu; cu = cu->next) {
- if (modes && !(cu->user->mode & modes))
- continue;
- notice_lang(s_OperServ, u, OPER_USERLIST_RECORD,
- cu->user->nick, common_get_vident(cu->user),
- common_get_vhost(cu->user));
- }
- } else {
- char mask[BUFSIZE];
- int i;
- User *u2;
-
- notice_lang(s_OperServ, u, OPER_USERLIST_HEADER);
-
- for (i = 0; i < 1024; i++) {
- for (u2 = userlist[i]; u2; u2 = u2->next) {
- if (pattern) {
- snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick,
- common_get_vident(u2), common_get_vhost(u2));
- if (!match_wild_nocase(pattern, mask))
- continue;
- if (modes && !(u2->mode & modes))
- continue;
- }
- notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, u2->nick,
- common_get_vident(u2), common_get_vhost(u2));
- }
- }
- }
-
- notice_lang(s_OperServ, u, OPER_USERLIST_END);
- return MOD_CONT;
-}
-
/*************************************************************************/
/* Callback function used to sort the admin list */
@@ -4036,192 +1584,6 @@ static void free_adminlist_entry(SList * slist, void *item)
nc->flags &= ~NI_SERVICES_ADMIN;
}
-/* Lists an admin entry, prefixing it with the header if needed */
-
-static int admin_list(int number, NickCore * nc, User * u,
- int *sent_header)
-{
- if (!nc)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_ADMIN_LIST_HEADER);
- *sent_header = 1;
- }
-
- notice_lang(s_OperServ, u, OPER_ADMIN_LIST_FORMAT, number,
- nc->display);
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int admin_list_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return admin_list(number, item, u, sent_header);
-}
-
-/* Services admin list viewing/modification. */
-
-static int do_admin(User * u)
-{
- char *cmd = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
- NickAlias *na;
- int res = 0;
-
- if (skeleton) {
- notice_lang(s_OperServ, u, OPER_ADMIN_SKELETON);
- return MOD_CONT;
- }
-
- if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) {
- syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX);
- } else if (!stricmp(cmd, "ADD")) {
- if (!is_services_root(u)) {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (!(na = findnick(nick))) {
- notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
- return MOD_CONT;
- }
-
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick);
- return MOD_CONT;
- }
-
- if (na->nc->flags & NI_SERVICES_ADMIN
- || slist_indexof(&servadmins, na->nc) != -1) {
- notice_lang(s_OperServ, u, OPER_ADMIN_EXISTS, nick);
- return MOD_CONT;
- }
-
- res = slist_add(&servadmins, na->nc);
- if (res == -2) {
- notice_lang(s_OperServ, u, OPER_ADMIN_REACHED_LIMIT, nick);
- return MOD_CONT;
- } else {
- if (na->nc->flags & NI_SERVICES_OPER
- && (res = slist_indexof(&servopers, na->nc)) != -1) {
- slist_delete(&servopers, res);
- na->nc->flags |= NI_SERVICES_ADMIN;
- notice_lang(s_OperServ, u, OPER_ADMIN_MOVED, nick);
- } else {
- na->nc->flags |= NI_SERVICES_ADMIN;
- notice_lang(s_OperServ, u, OPER_ADMIN_ADDED, nick);
- }
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
- } else if (!stricmp(cmd, "DEL")) {
- if (!is_services_root(u)) {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (servadmins.count == 0) {
- notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY);
- return MOD_CONT;
- }
-
- if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) {
- /* Deleting a range */
- res = slist_delete_range(&servadmins, nick, NULL);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH);
- return MOD_CONT;
- } else if (res == 1) {
- notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_ONE);
- } else {
- notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_SEVERAL,
- res);
- }
- } else {
- if (!(na = findnick(nick))) {
- notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
- return MOD_CONT;
- }
-
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick);
- return MOD_CONT;
- }
-
- if (!(na->nc->flags & NI_SERVICES_ADMIN)
- || (res = slist_indexof(&servadmins, na->nc)) == -1) {
- notice_lang(s_OperServ, u, OPER_ADMIN_NOT_FOUND, nick);
- return MOD_CONT;
- }
-
- slist_delete(&servadmins, res);
- notice_lang(s_OperServ, u, OPER_ADMIN_DELETED, nick);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
- } else if (!stricmp(cmd, "LIST")) {
- int sent_header = 0;
-
- if (servadmins.count == 0) {
- notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY);
- return MOD_CONT;
- }
-
- if (!nick || (isdigit(*nick)
- && strspn(nick, "1234567890,-") == strlen(nick))) {
- res =
- slist_enum(&servadmins, nick, &admin_list_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH);
- return MOD_CONT;
- } else {
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin");
- }
- } else {
- int i;
-
- for (i = 0; i < servadmins.count; i++)
- if (!stricmp
- (nick, ((NickCore *) servadmins.list[i])->display)
- || match_wild_nocase(nick,
- ((NickCore *) servadmins.
- list[i])->display))
- admin_list(i + 1, servadmins.list[i], u, &sent_header);
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH);
- else {
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin");
- }
- }
- } else if (!stricmp(cmd, "CLEAR")) {
- if (!is_services_root(u)) {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (servadmins.count == 0) {
- notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY);
- return MOD_CONT;
- }
-
- slist_clear(&servadmins, 1);
- notice_lang(s_OperServ, u, OPER_ADMIN_CLEAR);
- } else {
- syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX);
- }
- return MOD_CONT;
-}
-
/*************************************************************************/
/* Callback function used to sort the oper list */
@@ -4243,628 +1605,6 @@ static void free_operlist_entry(SList * slist, void *item)
nc->flags &= ~NI_SERVICES_OPER;
}
-/* Lists an oper entry, prefixing it with the header if needed */
-
-static int oper_list(int number, NickCore * nc, User * u, int *sent_header)
-{
- if (!nc)
- return 0;
-
- if (!*sent_header) {
- notice_lang(s_OperServ, u, OPER_OPER_LIST_HEADER);
- *sent_header = 1;
- }
-
- notice_lang(s_OperServ, u, OPER_OPER_LIST_FORMAT, number, nc->display);
- return 1;
-}
-
-/* Callback for enumeration purposes */
-
-static int oper_list_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- int *sent_header = va_arg(args, int *);
-
- return oper_list(number, item, u, sent_header);
-}
-
-/**
- * Display an Opers list Entry
- **/
-static int opers_list(int number, NickCore * nc, User * u, char *level)
-{
- User *au = NULL;
- NickAlias *na;
- int found;
- int i;
-
- if (!nc)
- return 0;
-
- found = 0;
- if ((au = finduser(nc->display))) { /* see if user is online */
- found = 1;
- notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', level,
- nc->display);
- } else {
- for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */
- na = nc->aliases.list[i];
- if ((au = finduser(na->nick))) { /* see if user is online */
- found = 1;
- notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, '*', level,
- nc->display, na->nick);
- }
- }
- }
-
- if (!found)
- notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', level,
- nc->display);
-
- return 1;
-}
-
-/**
- * Function for the enumerator to call
- **/
-static int opers_list_callback(SList * slist, int number, void *item,
- va_list args)
-{
- User *u = va_arg(args, User *);
- char *level = va_arg(args, char *);
-
- return opers_list(number, item, u, level);
-}
-
-/**
- * Display all Services Opers/Admins with Level + Online Status
- * /msg OperServ opers
- **/
-static int do_staff(User * u)
-{
- int idx = 0;
- User *au = NULL;
- NickCore *nc;
- NickAlias *na;
- int found;
- int i;
-
- notice_lang(s_OperServ, u, OPER_STAFF_LIST_HEADER);
- slist_enum(&servopers, NULL, &opers_list_callback, u, "OPER");
- slist_enum(&servadmins, NULL, &opers_list_callback, u, "ADMN");
-
- for (idx = 0; idx < RootNumber; idx++) {
- found = 0;
- if ((au = finduser(ServicesRoots[idx]))) { /* see if user is online */
- found = 1;
- notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', "ROOT",
- ServicesRoots[idx]);
- } else if ((nc = findcore(ServicesRoots[idx]))) {
- for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */
- na = nc->aliases.list[i];
- if ((au = finduser(na->nick))) { /* see if user is online */
- found = 1;
- notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT,
- '*', "ROOT", ServicesRoots[idx], na->nick);
- }
- }
- }
-
- if (!found)
- notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', "ROOT",
- ServicesRoots[idx]);
-
- }
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Staff");
- return MOD_CONT;
-}
-
-/* Services operator list viewing/modification. */
-
-static int do_oper(User * u)
-{
- char *cmd = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
- NickAlias *na;
- int res = 0;
-
- if (skeleton) {
- notice_lang(s_OperServ, u, OPER_OPER_SKELETON);
- return MOD_CONT;
- }
-
- if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) {
- syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX);
- } else if (!stricmp(cmd, "ADD")) {
- if (!is_services_admin(u)) {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (!(na = findnick(nick))) {
- notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
- return MOD_CONT;
- }
-
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick);
- return MOD_CONT;
- }
-
- if (na->nc->flags & NI_SERVICES_OPER
- || slist_indexof(&servopers, na->nc) != -1) {
- notice_lang(s_OperServ, u, OPER_OPER_EXISTS, nick);
- return MOD_CONT;
- }
-
- res = slist_add(&servopers, na->nc);
- if (res == -2) {
- notice_lang(s_OperServ, u, OPER_OPER_REACHED_LIMIT, nick);
- return MOD_CONT;
- } else {
- if (na->nc->flags & NI_SERVICES_ADMIN
- && (res = slist_indexof(&servadmins, na->nc)) != -1) {
- slist_delete(&servadmins, res);
- na->nc->flags |= NI_SERVICES_OPER;
- notice_lang(s_OperServ, u, OPER_OPER_MOVED, nick);
- } else {
- na->nc->flags |= NI_SERVICES_OPER;
- notice_lang(s_OperServ, u, OPER_OPER_ADDED, nick);
- }
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
- } else if (!stricmp(cmd, "DEL")) {
- if (!is_services_admin(u)) {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) {
- /* Deleting a range */
- res = slist_delete_range(&servopers, nick, NULL);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH);
- return MOD_CONT;
- } else if (res == 1) {
- notice_lang(s_OperServ, u, OPER_OPER_DELETED_ONE);
- } else {
- notice_lang(s_OperServ, u, OPER_OPER_DELETED_SEVERAL, res);
- }
- } else {
- if (!(na = findnick(nick))) {
- notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick);
- return MOD_CONT;
- }
-
- if (na->status & NS_VERBOTEN) {
- notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick);
- return MOD_CONT;
- }
-
- if (!(na->nc->flags & NI_SERVICES_OPER)
- || (res = slist_indexof(&servopers, na->nc)) == -1) {
- notice_lang(s_OperServ, u, OPER_OPER_NOT_FOUND, nick);
- return MOD_CONT;
- }
-
- slist_delete(&servopers, res);
- notice_lang(s_OperServ, u, OPER_OPER_DELETED, nick);
- }
-
- if (readonly)
- notice_lang(s_OperServ, u, READ_ONLY_MODE);
- } else if (!stricmp(cmd, "LIST")) {
- int sent_header = 0;
-
- if (servopers.count == 0) {
- notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY);
- return MOD_CONT;
- }
-
- if (!nick || (isdigit(*nick)
- && strspn(nick, "1234567890,-") == strlen(nick))) {
- res =
- slist_enum(&servopers, nick, &oper_list_callback, u,
- &sent_header);
- if (res == 0) {
- notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH);
- return MOD_CONT;
- } else {
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Oper");
- }
- } else {
- int i;
-
- for (i = 0; i < servopers.count; i++)
- if (!stricmp
- (nick, ((NickCore *) servopers.list[i])->display)
- || match_wild_nocase(nick,
- ((NickCore *) servopers.list[i])->
- display))
- oper_list(i + 1, servopers.list[i], u, &sent_header);
-
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH);
- else {
- notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Oper");
- }
- }
- } else if (!stricmp(cmd, "CLEAR")) {
- if (!is_services_admin(u)) {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- }
-
- if (servopers.count == 0) {
- notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY);
- return MOD_CONT;
- }
-
- slist_clear(&servopers, 1);
- notice_lang(s_OperServ, u, OPER_OPER_CLEAR);
- } else {
- syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Set various Services runtime options. */
-
-static int do_set(User * u)
-{
- char *option = strtok(NULL, " ");
- char *setting = strtok(NULL, " ");
- int index;
-
- if (!option) {
- syntax_error(s_OperServ, u, "SET", OPER_SET_SYNTAX);
- } else if (stricmp(option, "LIST") == 0) {
- index =
- (allow_ignore ? OPER_SET_LIST_OPTION_ON :
- OPER_SET_LIST_OPTION_OFF);
- notice_lang(s_OperServ, u, index, "IGNORE");
- index =
- (readonly ? OPER_SET_LIST_OPTION_ON :
- OPER_SET_LIST_OPTION_OFF);
- notice_lang(s_OperServ, u, index, "READONLY");
- index =
- (logchan ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF);
- notice_lang(s_OperServ, u, index, "LOGCHAN");
- index =
- (debug ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF);
- notice_lang(s_OperServ, u, index, "DEBUG");
- index =
- (noexpire ? OPER_SET_LIST_OPTION_ON :
- OPER_SET_LIST_OPTION_OFF);
- notice_lang(s_OperServ, u, index, "NOEXPIRE");
-#ifdef USE_MYSQL
- index =
- (do_mysql ? OPER_SET_LIST_OPTION_ON :
- OPER_SET_LIST_OPTION_OFF);
- notice_lang(s_OperServ, u, index, "SQL");
-#endif
- } else if (!setting) {
- syntax_error(s_OperServ, u, "SET", OPER_SET_SYNTAX);
- } else if (stricmp(option, "IGNORE") == 0) {
- if (stricmp(setting, "on") == 0) {
- allow_ignore = 1;
- notice_lang(s_OperServ, u, OPER_SET_IGNORE_ON);
- } else if (stricmp(setting, "off") == 0) {
- allow_ignore = 0;
- notice_lang(s_OperServ, u, OPER_SET_IGNORE_OFF);
- } else {
- notice_lang(s_OperServ, u, OPER_SET_IGNORE_ERROR);
- }
-#ifdef USE_MYSQL
- } else if (stricmp(option, "SQL") == 0) {
- if (stricmp(setting, "on") == 0) {
- if (!MysqlHost) {
- notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_DISABLED);
- } else {
- if (rdb_init()) {
- notice_lang(s_OperServ, u, OPER_SET_SQL_ON);
- } else {
- notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_INIT);
- }
- }
- } else if (stricmp(setting, "off") == 0) {
- if (!MysqlHost) {
- notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_DISABLED);
- } else {
- /* could call rdb_close() but that does nothing - TSL */
- do_mysql = 0;
- notice_lang(s_OperServ, u, OPER_SET_SQL_OFF);
- }
- } else {
- notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR);
- }
-#endif
- } else if (stricmp(option, "READONLY") == 0) {
- if (stricmp(setting, "on") == 0) {
- readonly = 1;
- alog("Read-only mode activated");
- close_log();
- notice_lang(s_OperServ, u, OPER_SET_READONLY_ON);
- } else if (stricmp(setting, "off") == 0) {
- readonly = 0;
- open_log();
- alog("Read-only mode deactivated");
- notice_lang(s_OperServ, u, OPER_SET_READONLY_OFF);
- } else {
- notice_lang(s_OperServ, u, OPER_SET_READONLY_ERROR);
- }
-
- } else if (stricmp(option, "LOGCHAN") == 0) {
- /* Unlike the other SET commands where only stricmp is necessary,
- * we also have to ensure that LogChannel is defined or we can't
- * send to it.
- *
- * -jester
- */
- if (LogChannel && (stricmp(setting, "on") == 0)) {
- if (ircd->join2msg) {
- anope_cmd_join(s_GlobalNoticer, LogChannel, time(NULL));
- }
- logchan = 1;
- alog("Now sending log messages to %s", LogChannel);
- notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_ON, LogChannel);
- } else if (LogChannel && (stricmp(setting, "off") == 0)) {
- alog("No longer sending log messages to a channel");
- if (ircd->join2msg) {
- anope_cmd_part(s_GlobalNoticer, LogChannel, NULL);
- }
- logchan = 0;
- notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_OFF);
- } else {
- notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_ERROR);
- }
- /**
- * Allow the user to turn super admin on/off
- *
- * Rob
- **/
- } else if (stricmp(option, "SUPERADMIN") == 0) {
- if (!SuperAdmin) {
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_NOT_ENABLED);
- } else if (stricmp(setting, "on") == 0) {
- u->isSuperAdmin = 1;
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ON);
- alog("%s: %s is a SuperAdmin ", s_OperServ, u->nick);
- anope_cmd_global(s_OperServ,
- getstring2(NULL, OPER_SUPER_ADMIN_WALL_ON),
- u->nick);
- } else if (stricmp(setting, "off") == 0) {
- u->isSuperAdmin = 0;
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_OFF);
- alog("%s: %s is no longer a SuperAdmin", s_OperServ, u->nick);
- anope_cmd_global(s_OperServ,
- getstring2(NULL, OPER_SUPER_ADMIN_WALL_OFF),
- u->nick);
- } else {
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_SYNTAX);
- }
- } else if (stricmp(option, "DEBUG") == 0) {
- if (stricmp(setting, "on") == 0) {
- debug = 1;
- alog("Debug mode activated");
- notice_lang(s_OperServ, u, OPER_SET_DEBUG_ON);
- } else if (stricmp(setting, "off") == 0 ||
- (*setting == '0' && atoi(setting) == 0)) {
- alog("Debug mode deactivated");
- debug = 0;
- notice_lang(s_OperServ, u, OPER_SET_DEBUG_OFF);
- } else if (isdigit(*setting) && atoi(setting) > 0) {
- debug = atoi(setting);
- alog("Debug mode activated (level %d)", debug);
- notice_lang(s_OperServ, u, OPER_SET_DEBUG_LEVEL, debug);
- } else {
- notice_lang(s_OperServ, u, OPER_SET_DEBUG_ERROR);
- }
-
- } else if (stricmp(option, "NOEXPIRE") == 0) {
- if (stricmp(setting, "ON") == 0) {
- noexpire = 1;
- alog("No expire mode activated");
- notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_ON);
- } else if (stricmp(setting, "OFF") == 0) {
- noexpire = 0;
- alog("No expire mode deactivated");
- notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_OFF);
- } else {
- notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_ERROR);
- }
- } else {
- notice_lang(s_OperServ, u, OPER_SET_UNKNOWN_OPTION, option);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_noop(User * u)
-{
- char *cmd = strtok(NULL, " ");
- char *server = strtok(NULL, " ");
-
- if (!cmd || !server) {
- syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX);
- } else if (!stricmp(cmd, "SET")) {
- User *u2;
- User *u3 = NULL;
- char reason[NICKMAX + 32];
-
- /* Remove the O:lines */
- anope_cmd_svsnoop(server, 1);
-
- snprintf(reason, sizeof(reason), "NOOP command used by %s",
- u->nick);
- if (WallOSNoOp)
- anope_cmd_global(s_OperServ, "\2%s\2 used NOOP on \2%s\2",
- u->nick, server);
- notice_lang(s_OperServ, u, OPER_NOOP_SET, server);
-
- /* Kill all the IRCops of the server */
- for (u2 = firstuser(); u2; u2 = u3) {
- u3 = nextuser();
- if ((u2) && is_oper(u2) && (u2->server->name)
- && match_wild(server, u2->server->name)) {
- kill_user(s_OperServ, u2->nick, reason);
- }
- }
- } else if (!stricmp(cmd, "REVOKE")) {
- anope_cmd_svsnoop(server, 0);
- notice_lang(s_OperServ, u, OPER_NOOP_REVOKE, server);
- } else {
- syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_jupe(User * u)
-{
- char *jserver = strtok(NULL, " ");
- char *reason = strtok(NULL, "");
-
- if (!jserver) {
- syntax_error(s_OperServ, u, "JUPE", OPER_JUPE_SYNTAX);
- } else {
- if (!isValidHost(jserver, 3)) {
- notice_lang(s_OperServ, u, OPER_JUPE_HOST_ERROR);
- } else {
- anope_cmd_jupe(jserver, u->nick, reason);
-
- if (WallOSJupe)
- anope_cmd_global(s_OperServ, "\2%s\2 used JUPE on \2%s\2",
- u->nick, jserver);
- }
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_raw(User * u)
-{
-
- if (!DisableRaw) {
-
- char *text = strtok(NULL, "");
-
- if (!text)
- syntax_error(s_OperServ, u, "RAW", OPER_RAW_SYNTAX);
- else {
- send_cmd(NULL, "%s", text);
- if (WallOSRaw) {
- char *kw = strtok(text, " ");
- while (kw && *kw == ':')
- kw = strtok(NULL, " ");
- anope_cmd_global(s_OperServ,
- "\2%s\2 used RAW command for \2%s\2",
- u->nick,
- (kw ? kw :
- "\2non RFC compliant message\2"));
- }
- alog("%s used RAW command for %s", u->nick, text);
- }
- } else {
- notice_lang(s_OperServ, u, RAW_DISABLED);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_update(User * u)
-{
- notice_lang(s_OperServ, u, OPER_UPDATING);
- save_data = 1;
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_reload(User * u)
-{
- if (!read_config(1)) {
- quitmsg = calloc(28 + strlen(u->nick), 1);
- if (!quitmsg)
- quitmsg =
- "Error during the reload of the configuration file, but out of memory!";
- else
- sprintf(quitmsg,
- "Error during the reload of the configuration file!");
- quitting = 1;
- }
-
- notice_lang(s_OperServ, u, OPER_RELOAD);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_os_quit(User * u)
-{
- quitmsg = calloc(28 + strlen(u->nick), 1);
- if (!quitmsg)
- quitmsg = "QUIT command received, but out of memory!";
- else
- sprintf(quitmsg, "QUIT command received from %s", u->nick);
-
- if (GlobalOnCycle) {
- oper_global(NULL, "%s", GlobalOnCycleMessage);
- }
- quitting = 1;
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_shutdown(User * u)
-{
- quitmsg = calloc(32 + strlen(u->nick), 1);
- if (!quitmsg)
- quitmsg = "SHUTDOWN command received, but out of memory!";
- else
- sprintf(quitmsg, "SHUTDOWN command received from %s", u->nick);
-
- if (GlobalOnCycle) {
- oper_global(NULL, "%s", GlobalOnCycleMessage);
- }
- save_data = 1;
- delayed_quit = 1;
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-static int do_restart(User * u)
-{
-#ifdef SERVICES_BIN
- quitmsg = calloc(31 + strlen(u->nick), 1);
- if (!quitmsg)
- quitmsg = "RESTART command received, but out of memory!";
- else
- sprintf(quitmsg, "RESTART command received from %s", u->nick);
-
- if (GlobalOnCycle) {
- oper_global(NULL, "%s", GlobalOnCycleMessage);
- }
- /* raise(SIGHUP); */
- do_restart_services();
-#else
- notice_lang(s_OperServ, u, OPER_CANNOT_RESTART);
-#endif
- return MOD_CONT;
-}
-
/*************************************************************************/
#ifdef DEBUG_COMMANDS
@@ -4883,157 +1623,6 @@ static int do_matchwild(User * u)
#endif /* DEBUG_COMMANDS */
/*************************************************************************/
-
-/* Kill all users matching a certain host. The host is obtained from the
- * supplied nick. The raw hostmsk is not supplied with the command in an effort
- * to prevent abuse and mistakes from being made - which might cause *.com to
- * be killed. It also makes it very quick and simple to use - which is usually
- * what you want when someone starts loading numerous clones. In addition to
- * killing the clones, we add a temporary AKILL to prevent them from
- * immediately reconnecting.
- * Syntax: KILLCLONES nick
- * -TheShadow (29 Mar 1999)
- */
-
-static int do_killclones(User * u)
-{
- char *clonenick = strtok(NULL, " ");
- int count = 0;
- User *cloneuser, *user, *tempuser;
- char *clonemask, *akillmask;
- char killreason[NICKMAX + 32];
- char akillreason[] = "Temporary KILLCLONES akill.";
-
- if (!clonenick) {
- notice_lang(s_OperServ, u, OPER_KILLCLONES_SYNTAX);
-
- } else if (!(cloneuser = finduser(clonenick))) {
- notice_lang(s_OperServ, u, OPER_KILLCLONES_UNKNOWN_NICK,
- clonenick);
-
- } else {
- clonemask = smalloc(strlen(cloneuser->host) + 5);
- sprintf(clonemask, "*!*@%s", cloneuser->host);
-
- akillmask = smalloc(strlen(cloneuser->host) + 3);
- sprintf(akillmask, "*@%s", cloneuser->host);
-
- user = firstuser();
- while (user) {
- if (match_usermask(clonemask, user) != 0) {
- tempuser = nextuser();
- count++;
- snprintf(killreason, sizeof(killreason),
- "Cloning [%d]", count);
- kill_user(NULL, user->nick, killreason);
- user = tempuser;
- } else {
- user = nextuser();
- }
- }
-
- add_akill(u, akillmask, u->nick,
- time(NULL) + KillClonesAkillExpire, akillreason);
-
- anope_cmd_global(s_OperServ,
- "\2%s\2 used KILLCLONES for \2%s\2 killing "
- "\2%d\2 clones. A temporary AKILL has been added "
- "for \2%s\2.", u->nick, clonemask, count,
- akillmask);
-
- alog("%s: KILLCLONES: %d clone(s) matching %s killed.",
- s_OperServ, count, clonemask);
-
- free(akillmask);
- free(clonemask);
- }
- return MOD_CONT;
-}
-
-/**
- * Defcon - A method of impelemting various stages of securty, the hope is this will help serives
- * protect a network during an attack, allowing admins to choose the precautions taken at each
- * level.
- *
- * /msg OperServ DefCon [level]
- *
- **/
-
-static int do_defcon(User * u)
-{
- char *lvl = strtok(NULL, " ");
- int newLevel = 0;
- char *langglobal;
- langglobal = getstring(NULL, DEFCON_GLOBAL);
-
- if (!DefConLevel) { /* If we dont have a .conf setting! */
- notice_lang(s_OperServ, u, OPER_DEFCON_NO_CONF);
- return MOD_CONT;
- }
-
- if (!lvl) {
- notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel);
- defcon_sendlvls(u);
- return MOD_CONT;
- }
- newLevel = atoi(lvl);
- if (newLevel < 1 || newLevel > 5) {
- notice_lang(s_OperServ, u, OPER_DEFCON_SYNTAX);
- return MOD_CONT;
- }
- DefConLevel = newLevel;
- send_event(EVENT_DEFCON_LEVEL, "%d", DefConLevel);
- DefContimer = time(NULL);
- notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel);
- defcon_sendlvls(u);
- alog("Defcon level changed to %d by Oper %s", newLevel, u->nick);
- anope_cmd_global(s_OperServ, getstring2(NULL, OPER_DEFCON_WALL),
- u->nick, newLevel);
- /* Global notice the user what is happening. Also any Message that
- the Admin would like to add. Set in config file. */
- if (GlobalOnDefcon) {
- if ((DefConLevel == 5) && (DefConOffMessage)) {
- oper_global(NULL, "%s", DefConOffMessage);
- } else {
- oper_global(NULL, langglobal, DefConLevel);
- }
- }
- if (GlobalOnDefconMore) {
- if ((DefConOffMessage) && DefConLevel == 5) {
- } else {
- oper_global(NULL, "%s", DefconMessage);
- }
- }
- /* Run any defcon functions, e.g. FORCE CHAN MODE */
- runDefCon();
- return MOD_CONT;
-}
-
-/**
- * Reverse the mode string, used for remove DEFCON chan modes.
- **/
-char *defconReverseModes(const char *modes)
-{
- char *newmodes = NULL;
- int i = 0;
- if (!modes) {
- return NULL;
- }
- if (!(newmodes = malloc(sizeof(char) * strlen(modes) + 1))) {
- return NULL;
- }
- for (i = 0; i < strlen(modes); i++) {
- if (modes[i] == '+')
- newmodes[i] = '-';
- else if (modes[i] == '-')
- newmodes[i] = '+';
- else
- newmodes[i] = modes[i];
- }
- newmodes[i] = '\0';
- return newmodes;
-}
-
/**
* Returns 1 if the passed level is part of the CURRENT defcon, else 0 is returned
**/
@@ -5043,42 +1632,17 @@ int checkDefCon(int level)
}
/**
- * Run DefCon level specific Functions.
- **/
-void runDefCon(void)
-{
- char *newmodes;
- if (checkDefCon(DEFCON_FORCE_CHAN_MODES)) {
- if (DefConChanModes && !DefConModesSet) {
- if (DefConChanModes[0] == '+' || DefConChanModes[0] == '-') {
- alog("DEFCON: setting %s on all chan's", DefConChanModes);
- do_mass_mode(DefConChanModes);
- DefConModesSet = 1;
- }
- }
- } else {
- if (DefConChanModes && (DefConModesSet != 0)) {
- if (DefConChanModes[0] == '+' || DefConChanModes[0] == '-') {
- if ((newmodes = defconReverseModes(DefConChanModes))) {
- alog("DEFCON: setting %s on all chan's", newmodes);
- do_mass_mode(newmodes);
- }
- DefConModesSet = 0;
- }
- }
- }
-}
-
-/**
* Automaticaly re-set the DefCon level if the time limit has expired.
**/
void resetDefCon(int level)
{
+ char strLevel[5];
+ snprintf(strLevel, 4, "%d", level);
if (DefConLevel != level) {
if ((DefContimer)
&& (time(NULL) - DefContimer >= dotime(DefConTimeOut))) {
DefConLevel = level;
- send_event(EVENT_DEFCON_LEVEL, "%d", DefConLevel);
+ send_event(EVENT_DEFCON_LEVEL, 1, strLevel);
alog("Defcon level timeout, returning to lvl %d", level);
anope_cmd_global(s_OperServ,
getstring2(NULL, OPER_DEFCON_WALL),
@@ -5100,257 +1664,56 @@ void resetDefCon(int level)
}
/**
- * Send a message to the oper about which precautions are "active" for this level
- **/
-static void defcon_sendlvls(User * u)
-{
- if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_CHANNELS);
- }
- if (checkDefCon(DEFCON_NO_NEW_NICKS)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_NICKS);
- }
- if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_MLOCK_CHANGE);
- }
- if (checkDefCon(DEFCON_FORCE_CHAN_MODES) && (DefConChanModes)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_FORCE_CHAN_MODES,
- DefConChanModes);
- }
- if (checkDefCon(DEFCON_REDUCE_SESSION)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_REDUCE_SESSION,
- DefConSessionLimit);
- }
- if (checkDefCon(DEFCON_NO_NEW_CLIENTS)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_CLIENTS);
- }
- if (checkDefCon(DEFCON_OPER_ONLY)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_OPER_ONLY);
- }
- if (checkDefCon(DEFCON_SILENT_OPER_ONLY)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_SILENT_OPER_ONLY);
- }
- if (checkDefCon(DEFCON_AKILL_NEW_CLIENTS)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_AKILL_NEW_CLIENTS);
- }
- if (checkDefCon(DEFCON_NO_NEW_MEMOS)) {
- notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_MEMOS);
- }
-}
-
-/**
- * ChanKill - Akill an entire channel (got botnet?)
- *
- * /msg OperServ ChanKill +expire #channel reason
- *
+ * Run DefCon level specific Functions.
**/
-
-static int do_chankill(User * u)
+void runDefCon(void)
{
- char *expiry, *channel, *reason;
- time_t expires;
- char breason[BUFSIZE];
- char mask[USERMAX + HOSTMAX + 2];
- struct c_userlist *cu, *next;
- Channel *c;
-
- channel = strtok(NULL, " ");
- if (channel && *channel == '+') {
- expiry = channel;
- channel = strtok(NULL, " ");
- } else {
- expiry = NULL;
- }
-
- expires = expiry ? dotime(expiry) : ChankillExpiry;
- if (expiry && isdigit(expiry[strlen(expiry) - 1]))
- expires *= 86400;
- if (expires != 0 && expires < 60) {
- notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
- return MOD_CONT;
- } else if (expires > 0) {
- expires += time(NULL);
- }
-
- if (channel && (reason = strtok(NULL, ""))) {
-
- if (AddAkiller) {
- snprintf(breason, sizeof(breason), "[%s] %s", u->nick, reason);
- reason = sstrdup(breason);
- }
-
- if ((c = findchan(channel))) {
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (is_oper(cu->user)) {
- continue;
- }
- strncpy(mask, "*@", 3); /* Use *@" for the akill's, */
- strncat(mask, cu->user->host, HOSTMAX);
- add_akill(NULL, mask, s_OperServ, expires, reason);
- check_akill(cu->user->nick, cu->user->username,
- cu->user->host, NULL, NULL);
- }
- if (WallOSAkill) {
- anope_cmd_global(s_OperServ, "%s used CHANKILL on %s (%s)",
- u->nick, channel, reason);
+ char *newmodes;
+ if (checkDefCon(DEFCON_FORCE_CHAN_MODES)) {
+ if (DefConChanModes && !DefConModesSet) {
+ if (DefConChanModes[0] == '+' || DefConChanModes[0] == '-') {
+ alog("DEFCON: setting %s on all chan's", DefConChanModes);
+ do_mass_mode(DefConChanModes);
+ DefConModesSet = 1;
}
- } else {
- notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, channel);
}
} else {
- syntax_error(s_OperServ, u, "CHANKILL", OPER_CHANKILL_SYNTAX);
- }
- return MOD_CONT;
-}
-
-#ifdef USE_MODULES
-
-int do_modload(User * u)
-{
- char *name;
- Module *m;
-
- name = strtok(NULL, "");
- if (!name) {
- syntax_error(s_OperServ, u, "MODLOAD", OPER_MODULE_LOAD_SYNTAX);
- return MOD_CONT;
- }
- m = findModule(name);
- if (!m) {
- m = createModule(name);
- mod_current_module = m;
- mod_current_user = u;
- mod_current_op = 1;
- } else {
- notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, name);
- }
- return MOD_CONT;
-}
-
-int do_modunload(User * u)
-{
- char *name;
- Module *m;
-
- name = strtok(NULL, "");
- if (!name) {
- syntax_error(s_OperServ, u, "MODUNLOAD",
- OPER_MODULE_UNLOAD_SYNTAX);
- return MOD_CONT;
- }
- m = findModule(name);
- if (m) {
- mod_current_user = u;
- mod_current_module = m;
- mod_current_op = 2;
- } else {
- notice_lang(s_OperServ, u, OPER_MODULE_REMOVE_FAIL, name);
- }
- return MOD_CONT;
-}
-
-int do_modlist(User * u)
-{
- int idx;
- int count = 0;
- ModuleHash *current = NULL;
-
- notice_lang(s_OperServ, u, OPER_MODULE_LIST_HEADER);
-
- for (idx = 0; idx != MAX_CMD_HASH; idx++) {
- for (current = MODULE_HASH[idx]; current; current = current->next) {
- notice_lang(s_OperServ, u, OPER_MODULE_LIST, current->name,
- current->m->version);
- count++;
+ if (DefConChanModes && (DefConModesSet != 0)) {
+ if (DefConChanModes[0] == '+' || DefConChanModes[0] == '-') {
+ if ((newmodes = defconReverseModes(DefConChanModes))) {
+ alog("DEFCON: setting %s on all chan's", newmodes);
+ do_mass_mode(newmodes);
+ }
+ DefConModesSet = 0;
+ }
}
}
- if (count == 0) {
- notice_lang(s_OperServ, u, OPER_MODULE_NO_LIST);
- } else {
- notice_lang(s_OperServ, u, OPER_MODULE_LIST_FOOTER, count);
- }
-
- return MOD_CONT;
}
-int do_modinfo(User * u)
+/**
+ * Reverse the mode string, used for remove DEFCON chan modes.
+ **/
+char *defconReverseModes(const char *modes)
{
- char *file;
- struct tm tm;
- char timebuf[64];
- Module *m;
- int idx = 0;
- int display = 0;
-
- file = strtok(NULL, "");
- if (!file) {
- syntax_error(s_OperServ, u, "MODINFO", OPER_MODULE_INFO_SYNTAX);
- return MOD_CONT;
- }
- m = findModule(file);
- if (m) {
- tm = *localtime(&m->time);
- strftime_lang(timebuf, sizeof(timebuf), u,
- STRFTIME_DATE_TIME_FORMAT, &tm);
- notice_lang(s_OperServ, u, OPER_MODULE_INFO_LIST, m->name,
- m->version ? m->version : "?",
- m->author ? m->author : "?", timebuf);
- for (idx = 0; idx < MAX_CMD_HASH; idx++) {
- display += showModuleCmdLoaded(HOSTSERV[idx], m->name, u);
- display += showModuleCmdLoaded(OPERSERV[idx], m->name, u);
- display += showModuleCmdLoaded(NICKSERV[idx], m->name, u);
- display += showModuleCmdLoaded(CHANSERV[idx], m->name, u);
- display += showModuleCmdLoaded(BOTSERV[idx], m->name, u);
- display += showModuleCmdLoaded(MEMOSERV[idx], m->name, u);
- display += showModuleCmdLoaded(HELPSERV[idx], m->name, u);
- display += showModuleMsgLoaded(IRCD[idx], m->name, u);
-
- }
- }
- if (display == 0) {
- notice_lang(s_OperServ, u, OPER_MODULE_NO_INFO, file);
+ char *newmodes = NULL;
+ int i = 0;
+ if (!modes) {
+ return NULL;
}
- return MOD_CONT;
-}
-
-static int showModuleCmdLoaded(CommandHash * cmdList, char *mod_name,
- User * u)
-{
- Command *c;
- CommandHash *current;
- int display = 0;
-
- for (current = cmdList; current; current = current->next) {
- for (c = current->c; c; c = c->next) {
- if ((c->mod_name) && (stricmp(c->mod_name, mod_name) == 0)) {
- notice_lang(s_OperServ, u, OPER_MODULE_CMD_LIST,
- c->service, c->name);
- display++;
- }
- }
+ if (!(newmodes = malloc(sizeof(char) * strlen(modes) + 1))) {
+ return NULL;
}
- return display;
-}
-
-static int showModuleMsgLoaded(MessageHash * msgList, char *mod_name,
- User * u)
-{
- Message *msg;
- MessageHash *mcurrent;
- int display = 0;
- for (mcurrent = msgList; mcurrent; mcurrent = mcurrent->next) {
- for (msg = mcurrent->m; msg; msg = msg->next) {
- if ((msg->mod_name) && (stricmp(msg->mod_name, mod_name) == 0)) {
- notice_lang(s_OperServ, u, OPER_MODULE_MSG_LIST,
- msg->name);
- display++;
- }
- }
+ for (i = 0; i < strlen(modes); i++) {
+ if (modes[i] == '+')
+ newmodes[i] = '-';
+ else if (modes[i] == '-')
+ newmodes[i] = '+';
+ else
+ newmodes[i] = modes[i];
}
- return display;
+ newmodes[i] = '\0';
+ return newmodes;
}
-#endif
/*************************************************************************/
diff --git a/src/protocol/Makefile b/src/protocol/Makefile
new file mode 100644
index 000000000..e73fd7e7c
--- /dev/null
+++ b/src/protocol/Makefile
@@ -0,0 +1,45 @@
+include ./Makefile.inc
+
+MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \
+ 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \
+ 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \
+ 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \
+ 'RUNGROUP=${RUNGROUP}' 'MODULE_PATH=${MODULE_PATH}' \
+ 'PROFILE=${PROFILE}' 'SHARED=${SHARED}'
+
+OBJECTS= $(SRCS:.c=.o)
+SO_FILES=$(OBJECTS:.o=.s)
+CDEFS= -g -rdynamic -Wall
+CFLAGS=$(CFLAGS) $(CDEFS)
+
+all: modules subs
+
+modules: $(OBJECTS) $(SO_FILES)
+
+install:
+ $(CP) ./*.so $(MODULE_PATH)
+
+distclean: clean spotless
+
+.c.o:
+ $(CC) $(CFLAGS) -I../${INCLUDEDIR} -c $<
+
+.o.s:
+ $(CC) ${SHARED} $< -o $*.so ${PROFILE}
+
+subs:
+ @for i in $(SUBS); do \
+ echo "make all in $$i..."; \
+ (cd $$i; $(MAKE) $(MAKEARGS) all); done
+
+subs_clean:
+ @for i in $(SUBS); do \
+ echo "cleaning in $$i..."; \
+ (cd $$i; $(MAKE) $(MAKEARGS) clean); done
+
+clean: subs_clean
+ rm -f *.o *.so *.c~ core
+
+spotless: clean
+ rm -f *.so Makefile.inc
+
diff --git a/src/protocol/Makefile.sub b/src/protocol/Makefile.sub
new file mode 100644
index 000000000..b060ca5b6
--- /dev/null
+++ b/src/protocol/Makefile.sub
@@ -0,0 +1,30 @@
+MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \
+ 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \
+ 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \
+ 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \
+ 'RUNGROUP=${RUNGROUP}' 'MODULE_PATH=${MODULE_PATH}' \
+ 'PROFILE=${PROFILE}' 'SHARED=${SHARED}'
+
+OBJECTS= $(SRCS:.c=.o)
+SO_FILES=$(OBJECTS:.o=.s)
+CDEFS= -g -rdynamic -Wall
+CFLAGS=$(CFLAGS) $(CDEFS)
+
+all: module
+
+module: $(OBJECTS) so
+
+distclean: clean spotless
+
+.c.o:
+ $(CC) $(CFLAGS) -I../ -I../../${INCLUDEDIR} -c $<
+
+so:
+ $(CC) ${SHARED} $(OBJECTS) -o ../$(TARGET).so ${PROFILE}
+
+clean:
+ rm -f *.o *.so *.c~ core
+
+spotless: clean
+ rm -f *~
+
diff --git a/src/protocol/Makefile.win32 b/src/protocol/Makefile.win32
new file mode 100644
index 000000000..1f46f7534
--- /dev/null
+++ b/src/protocol/Makefile.win32
@@ -0,0 +1,26 @@
+include ../../Makefile.inc.win32
+
+SRCS=bahamut.c dreamforge.c hybrid.c inspircd.c plexus.c ptlink.c rageircd.c ratbox.c \
+ shadowircd.c solidircd.c ultimate2.c ultimate3.c unreal31.c unreal32.c viagra.c
+
+OBJECTS= $(SRCS:.c=.dll)
+CFLAGS=/LD /MD /D MODULE_COMPILE $(CFLAGS) /I"../../include"
+LFLAGS=/link ../anope.lib wsock32.lib $(LIBS) $(LFLAGS) $(MYSQL_LIB_PATH) /export:AnopeInit
+
+all: $(OBJECTS)
+
+distclean: clean spotless
+
+.c.dll:
+ $(CC) $(CFLAGS) $< $(LFLAGS)
+
+clean:
+ -@del *.obj
+
+spotless: clean
+ -@del *.dll *.lib *.exp
+
+install:
+ -@mkdir ..\..\$(DATDEST)\modules
+ -@mkdir ..\..\$(DATDEST)\modules\runtime
+ -@copy *.dll ..\..\$(DATDEST)\modules
diff --git a/src/bahamut.c b/src/protocol/bahamut.c
index 1f54406bc..3cc213a7c 100644
--- a/src/bahamut.c
+++ b/src/protocol/bahamut.c
@@ -15,17 +15,9 @@
#include "services.h"
#include "pseudo.h"
+#include "bahamut.h"
-#ifdef IRC_BAHAMUT
-
-const char version_protocol[] = "BahamutIRCd 1.4.*/1.8.*";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = "+j"; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = "-j"; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0; /* does send TSMODE but if it doesn't means it won't so this is disabled */
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"BahamutIRCd 1.4.*/1.8.*", /* ircd name */
"+o", /* nickserv mode */
"+o", /* chanserv mode */
@@ -86,7 +78,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
0, /* VHOST ON NICK */
0, /* Change RealName */
- 0, /* ChanServ extra */
0, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -118,7 +109,7 @@ IRCDVar ircd[] = {
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
CAPAB_TSMODE, /* TSMODE */
@@ -152,7 +143,7 @@ IRCDCAPAB ircdcap[] = {
};
-void anope_set_umode(User * user, int ac, char **av)
+void bahamut_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -271,7 +262,7 @@ unsigned long umodes[128] = {
0, 0 /* ~ ‚ */
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -293,7 +284,7 @@ char csmodes[128] = {
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
@@ -340,7 +331,7 @@ CMMode cmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -406,7 +397,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'j', CMODE_j, 0, get_flood, cs_get_flood},
@@ -424,7 +415,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -472,56 +463,46 @@ CUMode cumodes[128] = {
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void bahamut_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
-
- if (!buf) {
- return;
- }
+ if (!buf) {
+ return;
+ }
- if (ircdcap->tsmode) {
- if (uplink_capab & ircdcap->tsmode) {
- send_cmd(source, "MODE %s 0 %s", dest, buf);
- } else {
- send_cmd(source, "MODE %s %s", dest, buf);
- }
+ if (ircdcap->tsmode) {
+ if (uplink_capab & ircdcap->tsmode) {
+ send_cmd(source, "MODE %s 0 %s", dest, buf);
} else {
send_cmd(source, "MODE %s %s", dest, buf);
}
+ } else {
+ send_cmd(source, "MODE %s %s", dest, buf);
}
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void bahamut_cmd_svshold(char *nick)
{
send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout,
"Being held for registered user");
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void bahamut_cmd_release_svshold(char *nick)
{
send_cmd(ServerName, "SVSHOLD %s 0", nick);
}
/* SVSMODE -b */
-void anope_cmd_unban(char *name, char *nick)
+void bahamut_cmd_unban(char *name, char *nick)
{
- anope_cmd_svsmode_chan(name, "-b", nick);
+ bahamut_cmd_svsmode_chan(name, "-b", nick);
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void bahamut_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
if (nick) {
send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
@@ -530,7 +511,7 @@ void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
}
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void bahamut_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
}
@@ -707,7 +688,7 @@ void moduleAddIRCDMsgs(void) {
/* *INDENT-ON* */
/* SQLINE */
-void anope_cmd_sqline(char *mask, char *reason)
+void bahamut_cmd_sqline(char *mask, char *reason)
{
if (!mask || !reason) {
return;
@@ -717,13 +698,13 @@ void anope_cmd_sqline(char *mask, char *reason)
}
/* UNSGLINE */
-void anope_cmd_unsgline(char *mask)
+void bahamut_cmd_unsgline(char *mask)
{
send_cmd(NULL, "UNSGLINE 0 :%s", mask);
}
/* UNSZLINE */
-void anope_cmd_unszline(char *mask)
+void bahamut_cmd_unszline(char *mask)
{
/* this will likely fail so its only here for legacy */
send_cmd(NULL, "UNSZLINE 0 %s", mask);
@@ -732,7 +713,7 @@ void anope_cmd_unszline(char *mask)
}
/* SZLINE */
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void bahamut_cmd_szline(char *mask, char *reason, char *whom)
{
/* this will likely fail so its only here for legacy */
send_cmd(NULL, "SZLINE %s :%s", mask, reason);
@@ -742,41 +723,31 @@ void anope_cmd_szline(char *mask, char *reason, char *whom)
}
/* SVSNOOP */
-void anope_cmd_svsnoop(char *server, int set)
+void bahamut_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void bahamut_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ bahamut_cmd_svsnoop(server, set);
}
/* SGLINE */
-void anope_cmd_sgline(char *mask, char *reason)
+void bahamut_cmd_sgline(char *mask, char *reason)
{
send_cmd(NULL, "SGLINE %d :%s:%s", strlen(mask), mask, reason);
}
/* RAKILL */
-void anope_cmd_remove_akill(char *user, char *host)
+void bahamut_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "RAKILL %s %s", host, user);
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void bahamut_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!nick || !chan) {
return;
}
@@ -789,25 +760,30 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
/* TOPIC */
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void bahamut_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
/* UNSQLINE */
-void anope_cmd_unsqline(char *user)
+void bahamut_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNSQLINE %s", user);
}
/* JOIN - SJOIN */
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void bahamut_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
}
+void bahamut_cmd_burst()
+{
+ send_cmd(NULL, "BURST");
+}
+
/* AKILL */
/* parv[1]=host
* parv[2]=user
@@ -816,8 +792,8 @@ void anope_cmd_join(char *user, char *channel, time_t chantime)
* parv[5]=time set
* parv[6]=reason
*/
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void bahamut_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
(long int) time(NULL), reason);
@@ -832,21 +808,10 @@ void anope_cmd_akill(char *user, char *host, char *who, time_t when,
/*
Note: if the stamp is null 0, the below usage is correct of Bahamut
*/
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void bahamut_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (!source || !user || !fmt) {
- return;
- }
-
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- if (!buf) {
+ if (!source || !user || !buf) {
return;
}
@@ -860,7 +825,7 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
* parv[3] - mode (or services id if old svs version)
* parv[4] - optional arguement (services id)
*/
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void bahamut_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
(long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
@@ -873,36 +838,17 @@ void anope_cmd_svsmode(User * u, int ac, char **av)
* parv[1] = server name
* parv[2] = comment
*/
-void anope_cmd_squit(char *servname, char *message)
+void bahamut_cmd_squit(char *servname, char *message)
{
send_cmd(NULL, "SQUIT %s :%s", servname, message);
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void bahamut_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
-void anope_cmd_connect(int servernum)
-{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
-
- if (servernum == 1) {
- anope_cmd_pass(RemotePassword);
- } else if (servernum == 2) {
- anope_cmd_pass(RemotePassword2);
- } else if (servernum == 3) {
- anope_cmd_pass(RemotePassword3);
- }
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
- anope_cmd_burst();
-}
-
-
/*
* SVINFO
* parv[0] = sender prefix
@@ -911,30 +857,52 @@ void anope_cmd_connect(int servernum)
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
-void anope_cmd_svinfo()
+void bahamut_cmd_svinfo()
{
send_cmd(NULL, "SVINFO 3 1 0 :%ld", (long int) time(NULL));
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void bahamut_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS %s :TS", pass);
}
/* SERVER */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void bahamut_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, ServerDesc);
}
/* CAPAB */
-void anope_cmd_capab()
+void bahamut_cmd_capab()
{
send_cmd(NULL,
"CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3");
}
+void bahamut_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ if (servernum == 1) {
+ bahamut_cmd_pass(RemotePassword);
+ } else if (servernum == 2) {
+ bahamut_cmd_pass(RemotePassword2);
+ } else if (servernum == 3) {
+ bahamut_cmd_pass(RemotePassword3);
+ }
+ bahamut_cmd_capab();
+ bahamut_cmd_server(ServerName, 1, ServerDesc);
+ bahamut_cmd_svinfo();
+ bahamut_cmd_burst();
+}
+
+
+
+
+
/* EVENT : SERVER */
int anope_event_server(char *source, int ac, char **av)
{
@@ -1062,63 +1030,35 @@ int anope_event_motd(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void bahamut_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
-
- if (!buf) {
- return;
- }
- send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
+ if (!buf) {
+ return;
}
+ send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
}
/* NOTICE */
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void bahamut_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ bahamut_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void bahamut_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void bahamut_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1126,33 +1066,24 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void bahamut_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void bahamut_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void bahamut_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void bahamut_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1161,7 +1092,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void bahamut_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1170,17 +1101,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void bahamut_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1189,17 +1111,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void bahamut_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1208,17 +1121,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void bahamut_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1227,17 +1131,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void bahamut_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1246,17 +1141,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void bahamut_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1265,7 +1151,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void bahamut_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1280,7 +1166,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void bahamut_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1289,7 +1175,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void bahamut_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1299,17 +1185,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void bahamut_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1318,17 +1195,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void bahamut_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1337,17 +1205,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void bahamut_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1355,28 +1214,17 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_nick(char *nick, char *name, char *modes)
+void bahamut_cmd_nick(char *nick, char *name, char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, ServiceUser, ServiceHost,
ServerName, name);
- anope_cmd_sqline(nick, "Reserved for services");
+ bahamut_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void bahamut_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1384,30 +1232,30 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_372(char *source, char *msg)
+void bahamut_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void bahamut_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void bahamut_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void bahamut_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void bahamut_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1417,18 +1265,8 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void bahamut_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -1453,24 +1291,24 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ bahamut_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
-void anope_cmd_351(char *source)
+void bahamut_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
version_build);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void bahamut_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
- anope_cmd_sqline(nick, "Reserved for services");
+ bahamut_cmd_sqline(nick, "Reserved for services");
}
/* SVSNICK */
@@ -1479,7 +1317,7 @@ void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
* parv[2] = new nickname
* parv[3] = timestamp
*/
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void bahamut_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1487,31 +1325,31 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void bahamut_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void bahamut_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void bahamut_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_vhost_off(User * u)
+void bahamut_cmd_vhost_off(User * u)
{
/* Not Supported by this IRCD */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void bahamut_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick,
(unsigned long int) ts);
@@ -1520,19 +1358,19 @@ void anope_cmd_svid_umode(char *nick, time_t ts)
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void bahamut_cmd_nc_change(User * u)
{
common_svsmode(u, "+d", "1");
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void bahamut_cmd_svid_umode2(User * u, char *ts)
{
/* not used by bahamut ircds */
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void bahamut_cmd_svid_umode3(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -1542,7 +1380,7 @@ void anope_cmd_svid_umode3(User * u, char *ts)
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void bahamut_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1582,28 +1420,23 @@ int anope_event_pass(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void bahamut_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Can not find any reference to these in Bahamut */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void bahamut_cmd_svspart(char *source, char *nick, char *chan)
{
/* Can not find any reference to these in Bahamut */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void bahamut_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
-void anope_cmd_burst()
-{
- send_cmd(NULL, "BURST");
-}
-
-void anope_cmd_eob()
+void bahamut_cmd_eob()
{
send_cmd(NULL, "BURST 0");
}
@@ -1646,7 +1479,7 @@ int anope_event_admin(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int bahamut_flood_mode_check(char *value)
{
char *dp, *end;
@@ -1660,20 +1493,20 @@ int anope_flood_mode_check(char *value)
}
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void bahamut_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ bahamut_cmd_squit(jserver, rbuf);
+ bahamut_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void bahamut_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
}
@@ -1682,24 +1515,15 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int bahamut_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void bahamut_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1712,11 +1536,124 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
/* this avoids "undefined symbol" messages of those whom try to load mods that
call on this function */
-void anope_cmd_chghost(char *nick, char *vhost)
+void bahamut_cmd_chghost(char *nick, char *vhost)
{
if (debug) {
alog("debug: This IRCD does not support vhosting");
}
}
-#endif
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(bahamut_cmd_svsnoop);
+ pmodule_cmd_remove_akill(bahamut_cmd_remove_akill);
+ pmodule_cmd_topic(bahamut_cmd_topic);
+ pmodule_cmd_vhost_off(bahamut_cmd_vhost_off);
+ pmodule_cmd_akill(bahamut_cmd_akill);
+ pmodule_cmd_svskill(bahamut_cmd_svskill);
+ pmodule_cmd_svsmode(bahamut_cmd_svsmode);
+ pmodule_cmd_372(bahamut_cmd_372);
+ pmodule_cmd_372_error(bahamut_cmd_372_error);
+ pmodule_cmd_375(bahamut_cmd_375);
+ pmodule_cmd_376(bahamut_cmd_376);
+ pmodule_cmd_nick(bahamut_cmd_nick);
+ pmodule_cmd_guest_nick(bahamut_cmd_guest_nick);
+ pmodule_cmd_mode(bahamut_cmd_mode);
+ pmodule_cmd_bot_nick(bahamut_cmd_bot_nick);
+ pmodule_cmd_kick(bahamut_cmd_kick);
+ pmodule_cmd_notice_ops(bahamut_cmd_notice_ops);
+ pmodule_cmd_notice(bahamut_cmd_notice);
+ pmodule_cmd_notice2(bahamut_cmd_notice2);
+ pmodule_cmd_privmsg(bahamut_cmd_privmsg);
+ pmodule_cmd_privmsg2(bahamut_cmd_privmsg2);
+ pmodule_cmd_serv_notice(bahamut_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(bahamut_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(bahamut_cmd_bot_chan_mode);
+ pmodule_cmd_351(bahamut_cmd_351);
+ pmodule_cmd_quit(bahamut_cmd_quit);
+ pmodule_cmd_pong(bahamut_cmd_pong);
+ pmodule_cmd_join(bahamut_cmd_join);
+ pmodule_cmd_unsqline(bahamut_cmd_unsqline);
+ pmodule_cmd_invite(bahamut_cmd_invite);
+ pmodule_cmd_part(bahamut_cmd_part);
+ pmodule_cmd_391(bahamut_cmd_391);
+ pmodule_cmd_250(bahamut_cmd_250);
+ pmodule_cmd_307(bahamut_cmd_307);
+ pmodule_cmd_311(bahamut_cmd_311);
+ pmodule_cmd_312(bahamut_cmd_312);
+ pmodule_cmd_317(bahamut_cmd_317);
+ pmodule_cmd_219(bahamut_cmd_219);
+ pmodule_cmd_401(bahamut_cmd_401);
+ pmodule_cmd_318(bahamut_cmd_318);
+ pmodule_cmd_242(bahamut_cmd_242);
+ pmodule_cmd_243(bahamut_cmd_243);
+ pmodule_cmd_211(bahamut_cmd_211);
+ pmodule_cmd_global(bahamut_cmd_global);
+ pmodule_cmd_global_legacy(bahamut_cmd_global_legacy);
+ pmodule_cmd_sqline(bahamut_cmd_sqline);
+ pmodule_cmd_squit(bahamut_cmd_squit);
+ pmodule_cmd_svso(bahamut_cmd_svso);
+ pmodule_cmd_chg_nick(bahamut_cmd_chg_nick);
+ pmodule_cmd_svsnick(bahamut_cmd_svsnick);
+ pmodule_cmd_vhost_on(bahamut_cmd_vhost_on);
+ pmodule_cmd_connect(bahamut_cmd_connect);
+ pmodule_cmd_svshold(bahamut_cmd_svshold);
+ pmodule_cmd_release_svshold(bahamut_cmd_release_svshold);
+ pmodule_cmd_unsgline(bahamut_cmd_unsqline);
+ pmodule_cmd_unszline(bahamut_cmd_unszline);
+ pmodule_cmd_szline(bahamut_cmd_szline);
+ pmodule_cmd_sgline(bahamut_cmd_sgline);
+ pmodule_cmd_unban(bahamut_cmd_unban);
+ pmodule_cmd_svsmode_chan(bahamut_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(bahamut_cmd_svid_umode);
+ pmodule_cmd_nc_change(bahamut_cmd_nc_change);
+ pmodule_cmd_svid_umode2(bahamut_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(bahamut_cmd_svid_umode3);
+ pmodule_cmd_eob(bahamut_cmd_eob);
+ pmodule_flood_mode_check(bahamut_flood_mode_check);
+ pmodule_cmd_jupe(bahamut_cmd_jupe);
+ pmodule_valid_nick(bahamut_valid_nick);
+ pmodule_cmd_ctcp(bahamut_cmd_ctcp);
+ pmodule_set_umode(bahamut_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("BahamutIRCd 1.4.*/1.8.*");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("+j");
+ pmodule_ircd_flood_mode_char_remove("-j");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/bahamut.h b/src/protocol/bahamut.h
new file mode 100644
index 000000000..7dd79b732
--- /dev/null
+++ b/src/protocol/bahamut.h
@@ -0,0 +1,131 @@
+/* Bahamut functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+/*************************************************************************/
+
+#define UMODE_a 0x00000001 /* umode +a - Services Admin */
+#define UMODE_h 0x00000002 /* umode +h - Helper */
+#define UMODE_i 0x00000004 /* umode +i - Invisible */
+#define UMODE_o 0x00000008 /* umode +o - Oper */
+#define UMODE_r 0x00000010 /* umode +r - registered nick */
+#define UMODE_w 0x00000020 /* umode +w - Get wallops */
+#define UMODE_A 0x00000040 /* umode +A - Server Admin */
+#define UMODE_x 0x00000080 /* umode +x - Squelch with notice */
+#define UMODE_X 0x00000100 /* umode +X - Squelch without notice */
+#define UMODE_F 0x00000200 /* umode +F - no cptr->since message rate throttle */
+#define UMODE_j 0x00000400 /* umode +j - client rejection notices */
+#define UMODE_K 0x00000800 /* umode +K - U: lined server kill messages */
+#define UMODE_O 0x00001000 /* umode +O - Local Oper */
+#define UMODE_s 0x00002000 /* umode +s - Server notices */
+#define UMODE_c 0x00004000 /* umode +c - Client connections/exits */
+#define UMODE_k 0x00008000 /* umode +k - Server kill messages */
+#define UMODE_f 0x00010000 /* umode +f - Server flood messages */
+#define UMODE_y 0x00020000 /* umode +y - Stats/links */
+#define UMODE_d 0x00040000 /* umode +d - Debug info */
+#define UMODE_g 0x00080000 /* umode +g - Globops */
+#define UMODE_b 0x00100000 /* umode +b - Chatops */
+#define UMODE_n 0x00200000 /* umode +n - Routing Notices */
+#define UMODE_m 0x00400000 /* umode +m - spambot notices */
+#define UMODE_e 0x00800000 /* umode +e - oper notices for the above +D */
+#define UMODE_D 0x01000000 /* umode +D - Hidden dccallow umode */
+#define UMODE_I 0x02000000 /* umode +I - invisible oper (masked) */
+#define UMODE_R 0x80000000 /* unmode +R - No non registered msgs */
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+#define CMODE_c 0x00000400 /* Colors can't be used */
+#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */
+#define CMODE_j 0x00001000 /* join throttle */
+#define CMODE_O 0x00008000 /* Only opers can join */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void bahamut_set_umode(User * user, int ac, char **av);
+void bahamut_cmd_svsnoop(char *server, int set);
+void bahamut_cmd_remove_akill(char *user, char *host);
+void bahamut_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void bahamut_cmd_vhost_off(User * u);
+void bahamut_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void bahamut_cmd_svskill(char *source, char *user, char *buf);
+void bahamut_cmd_svsmode(User * u, int ac, char **av);
+void bahamut_cmd_372(char *source, char *msg);
+void bahamut_cmd_372_error(char *source);
+void bahamut_cmd_375(char *source);
+void bahamut_cmd_376(char *source);
+void bahamut_cmd_nick(char *nick, char *name, char *modes);
+void bahamut_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void bahamut_cmd_mode(char *source, char *dest, char *buf);
+void bahamut_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void bahamut_cmd_kick(char *source, char *chan, char *user, char *buf);
+void bahamut_cmd_notice_ops(char *source, char *dest, char *buf);
+void bahamut_cmd_notice(char *source, char *dest, char *buf);
+void bahamut_cmd_notice2(char *source, char *dest, char *msg);
+void bahamut_cmd_privmsg(char *source, char *dest, char *buf);
+void bahamut_cmd_privmsg2(char *source, char *dest, char *msg);
+void bahamut_cmd_serv_notice(char *source, char *dest, char *msg);
+void bahamut_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void bahamut_cmd_bot_chan_mode(char *nick, char *chan);
+void bahamut_cmd_351(char *source);
+void bahamut_cmd_quit(char *source, char *buf);
+void bahamut_cmd_pong(char *servname, char *who);
+void bahamut_cmd_join(char *user, char *channel, time_t chantime);
+void bahamut_cmd_unsqline(char *user);
+void bahamut_cmd_invite(char *source, char *chan, char *nick);
+void bahamut_cmd_part(char *nick, char *chan, char *buf);
+void bahamut_cmd_391(char *source, char *timestr);
+void bahamut_cmd_250(char *buf);
+void bahamut_cmd_307(char *buf);
+void bahamut_cmd_311(char *buf);
+void bahamut_cmd_312(char *buf);
+void bahamut_cmd_317(char *buf);
+void bahamut_cmd_219(char *source, char *letter);
+void bahamut_cmd_401(char *source, char *who);
+void bahamut_cmd_318(char *source, char *who);
+void bahamut_cmd_242(char *buf);
+void bahamut_cmd_243(char *buf);
+void bahamut_cmd_211(char *buf);
+void bahamut_cmd_global(char *source, char *buf);
+void bahamut_cmd_global_legacy(char *source, char *fmt);
+void bahamut_cmd_sqline(char *mask, char *reason);
+void bahamut_cmd_squit(char *servname, char *message);
+void bahamut_cmd_svso(char *source, char *nick, char *flag);
+void bahamut_cmd_chg_nick(char *oldnick, char *newnick);
+void bahamut_cmd_svsnick(char *source, char *guest, time_t when);
+void bahamut_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void bahamut_cmd_connect(int servernum);
+void bahamut_cmd_svshold(char *nick);
+void bahamut_cmd_release_svshold(char *nick);
+void bahamut_cmd_unsgline(char *mask);
+void bahamut_cmd_unszline(char *mask);
+void bahamut_cmd_szline(char *mask, char *reason, char *whom);
+void bahamut_cmd_sgline(char *mask, char *reason);
+void bahamut_cmd_unban(char *name, char *nick);
+void bahamut_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void bahamut_cmd_svid_umode(char *nick, time_t ts);
+void bahamut_cmd_nc_change(User * u);
+void bahamut_cmd_svid_umode2(User * u, char *ts);
+void bahamut_cmd_svid_umode3(User * u, char *ts);
+void bahamut_cmd_eob();
+int bahamut_flood_mode_check(char *value);
+void bahamut_cmd_jupe(char *jserver, char *who, char *reason);
+int bahamut_valid_nick(char *nick);
+void bahamut_cmd_ctcp(char *source, char *dest, char *buf);
+
diff --git a/src/protocol/configure b/src/protocol/configure
new file mode 100755
index 000000000..119c7c887
--- /dev/null
+++ b/src/protocol/configure
@@ -0,0 +1,35 @@
+#!/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
+
+echo -n "SUBS=" >> ./Makefile.inc
+FIRST=1
+for dir in *
+do
+ if [ -d $dir ] ; then
+ if [ -f $dir/Makefile ] ; then
+ if [ "$FIRST" = 1 ] ; then
+ echo -n " "$dir >> ./Makefile.inc
+ else
+ echo "\\" >> ./Makefile.inc
+ echo -n " " $dir >> ./Makefile.inc
+ fi
+ FIRST=0
+ fi
+ fi
+done
+
+exit 0
+
diff --git a/src/dreamforge.c b/src/protocol/dreamforge.c
index 9174353f7..6c77608f5 100644
--- a/src/dreamforge.c
+++ b/src/protocol/dreamforge.c
@@ -13,17 +13,9 @@
#include "services.h"
#include "pseudo.h"
+#include "dreamforge.h"
-#ifdef IRC_DREAMFORGE
-
-const char version_protocol[] = "DreamForge 4.6.7";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = ""; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = ""; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0;
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"DreamForge 4.6.7", /* ircd name */
"+o", /* nickserv mode */
"+o", /* chanserv mode */
@@ -84,7 +76,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
0, /* VHOST ON NICK */
0, /* Change RealName */
- 0, /* ChanServ extra */
0, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -116,7 +107,7 @@ IRCDVar ircd[] = {
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
0, /* TSMODE */
@@ -149,7 +140,7 @@ IRCDCAPAB ircdcap[] = {
0, 0, 0}
};
-void anope_set_umode(User * user, int ac, char **av)
+void dreamforge_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -259,7 +250,7 @@ unsigned long umodes[128] = {
0, 0 /* ~ ‚ */
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -281,7 +272,7 @@ char csmodes[128] = {
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
@@ -307,7 +298,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -373,7 +364,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
{'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
@@ -387,7 +378,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -517,46 +508,36 @@ int anope_event_capab(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_sqline(char *mask, char *reason)
+void dreamforge_cmd_sqline(char *mask, char *reason)
{
send_cmd(NULL, "SQLINE %s :%s", mask, reason);
}
-void anope_cmd_svsnoop(char *server, int set)
+void dreamforge_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void dreamforge_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ dreamforge_cmd_svsnoop(server, set);
}
-void anope_cmd_remove_akill(char *user, char *host)
+void dreamforge_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "RAKILL %s %s", host, user);
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void dreamforge_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void dreamforge_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!nick || !chan) {
return;
}
@@ -569,34 +550,25 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
-void anope_cmd_unsqline(char *user)
+void dreamforge_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNSQLINE %s", user);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void dreamforge_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(user, "JOIN %s", channel);
}
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void dreamforge_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "AKILL %s %s :%s", host, user, reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void dreamforge_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -608,14 +580,14 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
send_cmd(source, "KILL %s :%s", user, buf);
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void dreamforge_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0],
(ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
}
-void anope_cmd_squit(char *servname, char *message)
+void dreamforge_cmd_squit(char *servname, char *message)
{
send_cmd(NULL, "SQUIT %s :%s", servname, message);
}
@@ -625,55 +597,48 @@ void anope_pong(char *servname)
send_cmd(servname, "PONG %s", servname);
}
-void anope_cmd_connect(int servernum)
-{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
-
- anope_cmd_capab();
- if (servernum == 1)
- anope_cmd_pass(RemotePassword);
- if (servernum == 2)
- anope_cmd_pass(RemotePassword2);
- if (servernum == 3)
- anope_cmd_pass(RemotePassword3);
- anope_cmd_server(ServerName, 1, ServerDesc);
-}
-
/* PASS */
-void anope_cmd_pass(char *pass)
+void dreamforge_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS :%s", pass);
}
-void anope_cmd_capab()
+void dreamforge_cmd_capab()
{
send_cmd(NULL, "PROTOCTL NOQUIT");
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+/* SERVER name hop descript */
+void dreamforge_cmd_server(char *servname, int hop, char *descript)
{
- anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
+ send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
}
-/* SERVER name hop descript */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void dreamforge_cmd_connect(int servernum)
{
- send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ dreamforge_cmd_capab();
+ if (servernum == 1)
+ dreamforge_cmd_pass(RemotePassword);
+ if (servernum == 2)
+ dreamforge_cmd_pass(RemotePassword2);
+ if (servernum == 3)
+ dreamforge_cmd_pass(RemotePassword3);
+ dreamforge_cmd_server(ServerName, 1, ServerDesc);
}
-/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void dreamforge_cmd_bot_chan_mode(char *nick, char *chan)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
+ anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
+}
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
+
+
+/* GLOBOPS */
+void dreamforge_cmd_global(char *source, char *buf)
+{
if (!buf) {
return;
}
@@ -769,17 +734,8 @@ int anope_event_motd(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void dreamforge_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -787,17 +743,8 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "MODE %s %s", dest, buf);
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void dreamforge_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -806,44 +753,26 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
}
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void dreamforge_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ dreamforge_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void dreamforge_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void dreamforge_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -851,22 +780,22 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void dreamforge_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void dreamforge_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void dreamforge_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
-void anope_cmd_351(char *source)
+void dreamforge_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
@@ -874,18 +803,8 @@ void anope_cmd_351(char *source)
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void dreamforge_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -894,7 +813,7 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void dreamforge_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -903,17 +822,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void dreamforge_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -922,17 +832,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void dreamforge_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -941,17 +842,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void dreamforge_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -960,17 +852,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void dreamforge_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -979,17 +862,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void dreamforge_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -998,7 +872,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void dreamforge_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1013,7 +887,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void dreamforge_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1022,7 +896,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void dreamforge_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1032,17 +906,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void dreamforge_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1051,17 +916,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void dreamforge_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1070,17 +926,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void dreamforge_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1088,29 +935,18 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_nick(char *nick, char *name, char *modes)
+void dreamforge_cmd_nick(char *nick, char *name, char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
(long int) time(NULL), ServiceUser, ServiceHost, ServerName,
name);
anope_cmd_mode(nick, nick, "%s", modes);
- anope_cmd_sqline(nick, "Reserved for services");
+ dreamforge_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void dreamforge_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1157,34 +993,34 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ dreamforge_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
-void anope_cmd_372(char *source, char *msg)
+void dreamforge_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void dreamforge_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void dreamforge_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void dreamforge_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void dreamforge_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1194,59 +1030,59 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void dreamforge_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void dreamforge_cmd_bot_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
(long int) time(NULL), user, host, ServerName, real);
anope_cmd_mode(nick, "MODE %s %s", nick, modes);
- anope_cmd_sqline(nick, "Reserved for services");
+ dreamforge_cmd_sqline(nick, "Reserved for services");
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void dreamforge_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void dreamforge_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* UNSGLINE */
-void anope_cmd_unsgline(char *mask)
+void dreamforge_cmd_unsgline(char *mask)
{
/* Not Supported by this IRCD */
}
/* UNSZLINE */
-void anope_cmd_unszline(char *mask)
+void dreamforge_cmd_unszline(char *mask)
{
/* Not Supported by this IRCD */
}
/* SZLINE */
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void dreamforge_cmd_szline(char *mask, char *reason, char *whom)
{
/* Not Supported by this IRCD */
}
/* SGLINE */
-void anope_cmd_sgline(char *mask, char *reason)
+void dreamforge_cmd_sgline(char *mask, char *reason)
{
/* Not Supported by this IRCD */
}
/* SVSNICK */
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void dreamforge_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1254,57 +1090,57 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void dreamforge_cmd_guest_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
{
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
(long int) time(NULL), user, host, ServerName, real);
anope_cmd_mode(nick, "MODE %s %s", nick, modes);
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void dreamforge_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void dreamforge_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_unban(char *name, char *nick)
+void dreamforge_cmd_unban(char *name, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void dreamforge_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_vhost_off(User * u)
+void dreamforge_cmd_vhost_off(User * u)
{
/* Not Supported by this IRCD */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void dreamforge_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s +d 1", nick);
}
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void dreamforge_cmd_nc_change(User * u)
{
common_svsmode(u, "-r+d", "1");
}
/* SVSMODE +r */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void dreamforge_cmd_svid_umode2(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -1313,13 +1149,13 @@ void anope_cmd_svid_umode2(User * u, char *ts)
}
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void dreamforge_cmd_svid_umode3(User * u, char *ts)
{
/* not used */
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void dreamforge_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1328,17 +1164,17 @@ void anope_cmd_chg_nick(char *oldnick, char *newnick)
send_cmd(oldnick, "NICK %s", newnick);
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void dreamforge_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void dreamforge_cmd_svspart(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void dreamforge_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
@@ -1358,30 +1194,30 @@ int anope_event_admin(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int dreamforge_flood_mode_check(char *value)
{
return 0;
}
-void anope_cmd_eob()
+void dreamforge_cmd_eob()
{
/* Not supported */
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void dreamforge_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ dreamforge_cmd_squit(jserver, rbuf);
+ dreamforge_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void dreamforge_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
}
@@ -1390,24 +1226,16 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int dreamforge_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void dreamforge_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
+ char *s;
if (!buf) {
return;
} else {
@@ -1418,4 +1246,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(dreamforge_cmd_svsnoop);
+ pmodule_cmd_remove_akill(dreamforge_cmd_remove_akill);
+ pmodule_cmd_topic(dreamforge_cmd_topic);
+ pmodule_cmd_vhost_off(dreamforge_cmd_vhost_off);
+ pmodule_cmd_akill(dreamforge_cmd_akill);
+ pmodule_cmd_svskill(dreamforge_cmd_svskill);
+ pmodule_cmd_svsmode(dreamforge_cmd_svsmode);
+ pmodule_cmd_372(dreamforge_cmd_372);
+ pmodule_cmd_372_error(dreamforge_cmd_372_error);
+ pmodule_cmd_375(dreamforge_cmd_375);
+ pmodule_cmd_376(dreamforge_cmd_376);
+ pmodule_cmd_nick(dreamforge_cmd_nick);
+ pmodule_cmd_guest_nick(dreamforge_cmd_guest_nick);
+ pmodule_cmd_mode(dreamforge_cmd_mode);
+ pmodule_cmd_bot_nick(dreamforge_cmd_bot_nick);
+ pmodule_cmd_kick(dreamforge_cmd_kick);
+ pmodule_cmd_notice_ops(dreamforge_cmd_notice_ops);
+ pmodule_cmd_notice(dreamforge_cmd_notice);
+ pmodule_cmd_notice2(dreamforge_cmd_notice2);
+ pmodule_cmd_privmsg(dreamforge_cmd_privmsg);
+ pmodule_cmd_privmsg2(dreamforge_cmd_privmsg2);
+ pmodule_cmd_serv_notice(dreamforge_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(dreamforge_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(dreamforge_cmd_bot_chan_mode);
+ pmodule_cmd_351(dreamforge_cmd_351);
+ pmodule_cmd_quit(dreamforge_cmd_quit);
+ pmodule_cmd_pong(dreamforge_cmd_pong);
+ pmodule_cmd_join(dreamforge_cmd_join);
+ pmodule_cmd_unsqline(dreamforge_cmd_unsqline);
+ pmodule_cmd_invite(dreamforge_cmd_invite);
+ pmodule_cmd_part(dreamforge_cmd_part);
+ pmodule_cmd_391(dreamforge_cmd_391);
+ pmodule_cmd_250(dreamforge_cmd_250);
+ pmodule_cmd_307(dreamforge_cmd_307);
+ pmodule_cmd_311(dreamforge_cmd_311);
+ pmodule_cmd_312(dreamforge_cmd_312);
+ pmodule_cmd_317(dreamforge_cmd_317);
+ pmodule_cmd_219(dreamforge_cmd_219);
+ pmodule_cmd_401(dreamforge_cmd_401);
+ pmodule_cmd_318(dreamforge_cmd_318);
+ pmodule_cmd_242(dreamforge_cmd_242);
+ pmodule_cmd_243(dreamforge_cmd_243);
+ pmodule_cmd_211(dreamforge_cmd_211);
+ pmodule_cmd_global(dreamforge_cmd_global);
+ pmodule_cmd_global_legacy(dreamforge_cmd_global_legacy);
+ pmodule_cmd_sqline(dreamforge_cmd_sqline);
+ pmodule_cmd_squit(dreamforge_cmd_squit);
+ pmodule_cmd_svso(dreamforge_cmd_svso);
+ pmodule_cmd_chg_nick(dreamforge_cmd_chg_nick);
+ pmodule_cmd_svsnick(dreamforge_cmd_svsnick);
+ pmodule_cmd_vhost_on(dreamforge_cmd_vhost_on);
+ pmodule_cmd_connect(dreamforge_cmd_connect);
+ pmodule_cmd_svshold(dreamforge_cmd_svshold);
+ pmodule_cmd_release_svshold(dreamforge_cmd_release_svshold);
+ pmodule_cmd_unsgline(dreamforge_cmd_unsqline);
+ pmodule_cmd_unszline(dreamforge_cmd_unszline);
+ pmodule_cmd_szline(dreamforge_cmd_szline);
+ pmodule_cmd_sgline(dreamforge_cmd_sgline);
+ pmodule_cmd_unban(dreamforge_cmd_unban);
+ pmodule_cmd_svsmode_chan(dreamforge_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(dreamforge_cmd_svid_umode);
+ pmodule_cmd_nc_change(dreamforge_cmd_nc_change);
+ pmodule_cmd_svid_umode2(dreamforge_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(dreamforge_cmd_svid_umode3);
+ pmodule_cmd_eob(dreamforge_cmd_eob);
+ pmodule_flood_mode_check(dreamforge_flood_mode_check);
+ pmodule_cmd_jupe(dreamforge_cmd_jupe);
+ pmodule_valid_nick(dreamforge_valid_nick);
+ pmodule_cmd_ctcp(dreamforge_cmd_ctcp);
+ pmodule_set_umode(dreamforge_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("DreamForge 4.6.7");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("");
+ pmodule_ircd_flood_mode_char_remove("");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/dreamforge.h b/src/protocol/dreamforge.h
new file mode 100644
index 000000000..aca591932
--- /dev/null
+++ b/src/protocol/dreamforge.h
@@ -0,0 +1,111 @@
+/* DreamForge IRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#define UMODE_a 0x00000001 /* Services Admin */
+#define UMODE_h 0x00000002 /* Help system operator */
+#define UMODE_i 0x00000004 /* makes user invisible */
+#define UMODE_o 0x00000008 /* Operator */
+#define UMODE_r 0x00000010 /* Nick set by services as registered */
+#define UMODE_w 0x00000020 /* send wallops to them */
+#define UMODE_A 0x00000040 /* Admin */
+#define UMODE_O 0x00000080 /* Local operator */
+#define UMODE_s 0x00000100 /* server notices such as kill */
+#define UMODE_k 0x00000200 /* Show server-kills... */
+#define UMODE_c 0x00000400 /* Show client information */
+#define UMODE_f 0x00000800 /* Receive flood warnings */
+#define UMODE_g 0x80000000 /* Shows some global messages */
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void dreamforge_set_umode(User * user, int ac, char **av);
+void dreamforge_cmd_svsnoop(char *server, int set);
+void dreamforge_cmd_remove_akill(char *user, char *host);
+void dreamforge_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void dreamforge_cmd_vhost_off(User * u);
+void dreamforge_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void dreamforge_cmd_svskill(char *source, char *user, char *buf);
+void dreamforge_cmd_svsmode(User * u, int ac, char **av);
+void dreamforge_cmd_372(char *source, char *msg);
+void dreamforge_cmd_372_error(char *source);
+void dreamforge_cmd_375(char *source);
+void dreamforge_cmd_376(char *source);
+void dreamforge_cmd_nick(char *nick, char *name, char *modes);
+void dreamforge_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void dreamforge_cmd_mode(char *source, char *dest, char *buf);
+void dreamforge_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void dreamforge_cmd_kick(char *source, char *chan, char *user, char *buf);
+void dreamforge_cmd_notice_ops(char *source, char *dest, char *buf);
+void dreamforge_cmd_notice(char *source, char *dest, char *buf);
+void dreamforge_cmd_notice2(char *source, char *dest, char *msg);
+void dreamforge_cmd_privmsg(char *source, char *dest, char *buf);
+void dreamforge_cmd_privmsg2(char *source, char *dest, char *msg);
+void dreamforge_cmd_serv_notice(char *source, char *dest, char *msg);
+void dreamforge_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void dreamforge_cmd_bot_chan_mode(char *nick, char *chan);
+void dreamforge_cmd_351(char *source);
+void dreamforge_cmd_quit(char *source, char *buf);
+void dreamforge_cmd_pong(char *servname, char *who);
+void dreamforge_cmd_join(char *user, char *channel, time_t chantime);
+void dreamforge_cmd_unsqline(char *user);
+void dreamforge_cmd_invite(char *source, char *chan, char *nick);
+void dreamforge_cmd_part(char *nick, char *chan, char *buf);
+void dreamforge_cmd_391(char *source, char *timestr);
+void dreamforge_cmd_250(char *buf);
+void dreamforge_cmd_307(char *buf);
+void dreamforge_cmd_311(char *buf);
+void dreamforge_cmd_312(char *buf);
+void dreamforge_cmd_317(char *buf);
+void dreamforge_cmd_219(char *source, char *letter);
+void dreamforge_cmd_401(char *source, char *who);
+void dreamforge_cmd_318(char *source, char *who);
+void dreamforge_cmd_242(char *buf);
+void dreamforge_cmd_243(char *buf);
+void dreamforge_cmd_211(char *buf);
+void dreamforge_cmd_global(char *source, char *buf);
+void dreamforge_cmd_global_legacy(char *source, char *fmt);
+void dreamforge_cmd_sqline(char *mask, char *reason);
+void dreamforge_cmd_squit(char *servname, char *message);
+void dreamforge_cmd_svso(char *source, char *nick, char *flag);
+void dreamforge_cmd_chg_nick(char *oldnick, char *newnick);
+void dreamforge_cmd_svsnick(char *source, char *guest, time_t when);
+void dreamforge_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void dreamforge_cmd_connect(int servernum);
+void dreamforge_cmd_svshold(char *nick);
+void dreamforge_cmd_release_svshold(char *nick);
+void dreamforge_cmd_unsgline(char *mask);
+void dreamforge_cmd_unszline(char *mask);
+void dreamforge_cmd_szline(char *mask, char *reason, char *whom);
+void dreamforge_cmd_sgline(char *mask, char *reason);
+void dreamforge_cmd_unban(char *name, char *nick);
+void dreamforge_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void dreamforge_cmd_svid_umode(char *nick, time_t ts);
+void dreamforge_cmd_nc_change(User * u);
+void dreamforge_cmd_svid_umode2(User * u, char *ts);
+void dreamforge_cmd_svid_umode3(User * u, char *ts);
+void dreamforge_cmd_eob();
+int dreamforge_flood_mode_check(char *value);
+void dreamforge_cmd_jupe(char *jserver, char *who, char *reason);
+int dreamforge_valid_nick(char *nick);
+void dreamforge_cmd_ctcp(char *source, char *dest, char *buf);
+
diff --git a/src/hybrid.c b/src/protocol/hybrid.c
index b966fa5a7..c1a862f16 100644
--- a/src/hybrid.c
+++ b/src/protocol/hybrid.c
@@ -13,17 +13,9 @@
#include "services.h"
#include "pseudo.h"
+#include "hybrid.h"
-#ifdef IRC_HYBRID
-
-const char version_protocol[] = "Hybrid IRCd 7.0";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = ""; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = ""; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0;
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"HybridIRCd 7.*", /* ircd name */
"+o", /* nickserv mode */
"+o", /* chanserv mode */
@@ -84,7 +76,6 @@ IRCDVar ircd[] = {
0, /* O:LINE */
0, /* VHOST ON NICK */
0, /* Change RealName */
- CHAN_HELP_IRCD_HALFOP, /* ChanServ extra */
CMODE_p, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -116,7 +107,7 @@ IRCDVar ircd[] = {
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
0, /* TSMODE */
@@ -151,7 +142,7 @@ IRCDCAPAB ircdcap[] = {
-void anope_set_umode(User * user, int ac, char **av)
+void hybrid_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -262,7 +253,7 @@ unsigned long umodes[128] = {
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -283,7 +274,7 @@ char csmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
@@ -333,7 +324,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -399,7 +390,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'a', CMODE_a, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
@@ -413,7 +404,7 @@ CBModeInfo cbmodeinfos[] = {
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -462,44 +453,26 @@ CUMode cumodes[128] = {
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void hybrid_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ hybrid_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void hybrid_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void hybrid_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -507,33 +480,24 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void hybrid_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void hybrid_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $$%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void hybrid_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $$%s :%s", dest, msg);
}
-void anope_cmd_global(char *source, const char *fmt, ...)
+void hybrid_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -542,7 +506,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void hybrid_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "OPERWALL :%s", fmt);
}
@@ -676,66 +640,66 @@ void moduleAddIRCDMsgs(void) {
/* *INDENT-ON* */
-void anope_cmd_sqline(char *mask, char *reason)
+void hybrid_cmd_sqline(char *mask, char *reason)
{
}
-void anope_cmd_unsgline(char *mask)
+void hybrid_cmd_unsgline(char *mask)
{
/* Does not support */
}
-void anope_cmd_unszline(char *mask)
+void hybrid_cmd_unszline(char *mask)
{
/* Does not support */
}
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void hybrid_cmd_szline(char *mask, char *reason, char *whom)
{
/* Does not support */
}
-void anope_cmd_svsnoop(char *server, int set)
+void hybrid_cmd_svsnoop(char *server, int set)
{
/* does not support */
}
-void anope_cmd_svsadmin(char *server, int set)
+void hybrid_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ hybrid_cmd_svsnoop(server, set);
}
-void anope_cmd_sgline(char *mask, char *reason)
+void hybrid_cmd_sgline(char *mask, char *reason)
{
/* does not support */
}
-void anope_cmd_remove_akill(char *user, char *host)
+void hybrid_cmd_remove_akill(char *user, char *host)
{
/* does not support */
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void hybrid_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s :%s", chan, topic);
}
-void anope_cmd_vhost_off(User * u)
+void hybrid_cmd_vhost_off(User * u)
{
/* does not support vhosting */
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void hybrid_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
/* does not support vhosting */
}
-void anope_cmd_unsqline(char *user)
+void hybrid_cmd_unsqline(char *user)
{
/* Hybrid does not support SQLINEs */
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void hybrid_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(NULL, "SJOIN %ld %s + :%s", (long int) time(NULL), channel,
user);
@@ -750,24 +714,15 @@ host: the 'host' portion of the kline
reason: the reason for the kline.
*/
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void hybrid_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(s_OperServ, "KLINE * %ld %s %s :%s",
(long int) (expires - (long) time(NULL)), user, host, reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void hybrid_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -780,33 +735,11 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void hybrid_cmd_svsmode(User * u, int ac, char **av)
{
/* Hybrid does not support SVSMODE */
}
-void anope_cmd_connect(int servernum)
-{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
-
- if (servernum == 1)
- anope_cmd_pass(RemotePassword);
- else if (servernum == 2)
- anope_cmd_pass(RemotePassword2);
- else if (servernum == 3)
- anope_cmd_pass(RemotePassword3);
-
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
-}
-
-void anope_cmd_svsinfo()
-{
- /* not used */
-}
-
/*
* SVINFO
* parv[0] = sender prefix
@@ -815,7 +748,7 @@ void anope_cmd_svsinfo()
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
-void anope_cmd_svinfo()
+void hybrid_cmd_svinfo()
{
send_cmd(NULL, "SVINFO 5 5 0 :%ld", (long int) time(NULL));
}
@@ -841,26 +774,49 @@ void anope_cmd_svinfo()
PARA - supports invite broadcasting for +p
ENCAP - ?
*/
-void anope_cmd_capab()
+void hybrid_cmd_capab()
{
send_cmd(NULL,
"CAPAB :QS EX CHW IE EOB KLN GLN HOPS HUB AOPS KNOCK TBURST PARA");
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void hybrid_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS %s :TS", pass);
}
/* SERVER name hop descript */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void hybrid_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
}
+void hybrid_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ if (servernum == 1)
+ hybrid_cmd_pass(RemotePassword);
+ else if (servernum == 2)
+ hybrid_cmd_pass(RemotePassword2);
+ else if (servernum == 3)
+ hybrid_cmd_pass(RemotePassword3);
+
+ hybrid_cmd_capab();
+ hybrid_cmd_server(ServerName, 1, ServerDesc);
+ hybrid_cmd_svinfo();
+}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void hybrid_cmd_svsinfo()
+{
+ /* not used */
+}
+
+
+
+void hybrid_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick,
@@ -868,18 +824,8 @@ void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
}
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void hybrid_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(nick, "PART %s :%s", chan, buf);
} else {
@@ -891,7 +837,7 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ hybrid_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
@@ -940,7 +886,7 @@ int anope_event_eob(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_eob()
+void hybrid_cmd_eob()
{
send_cmd(ServerName, "EOB");
}
@@ -1014,30 +960,30 @@ int anope_event_quit(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_372(char *source, char *msg)
+void hybrid_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void hybrid_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void hybrid_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void hybrid_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void hybrid_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1046,17 +992,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void hybrid_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1065,17 +1002,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void hybrid_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1084,17 +1012,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void hybrid_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1103,17 +1022,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void hybrid_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1122,17 +1032,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void hybrid_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1141,7 +1042,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void hybrid_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1156,7 +1057,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void hybrid_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1165,7 +1066,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void hybrid_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1175,17 +1076,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void hybrid_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1194,17 +1086,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void hybrid_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1213,17 +1096,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void hybrid_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1231,17 +1105,8 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void hybrid_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1249,7 +1114,7 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "MODE %s %s", dest, buf);
}
-void anope_cmd_nick(char *nick, char *name, char *mode)
+void hybrid_cmd_nick(char *nick, char *name, char *mode)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick,
@@ -1257,19 +1122,8 @@ void anope_cmd_nick(char *nick, char *name, char *mode)
ServerName, (name));
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void hybrid_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1277,17 +1131,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void hybrid_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1295,24 +1140,14 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void hybrid_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void hybrid_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -1321,13 +1156,13 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void hybrid_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void hybrid_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1337,7 +1172,7 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* SQUIT */
-void anope_cmd_squit(char *servname, char *message)
+void hybrid_cmd_squit(char *servname, char *message)
{
if (!servname || !message) {
return;
@@ -1359,7 +1194,7 @@ int anope_event_mode(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_351(char *source)
+void hybrid_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
@@ -1374,75 +1209,75 @@ int anope_event_capab(char *source, int ac, char **av)
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void hybrid_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void hybrid_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSNICK */
-void anope_cmd_svsnick(char *nick, char *newnick, time_t when)
+void hybrid_cmd_svsnick(char *nick, char *newnick, time_t when)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void hybrid_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void hybrid_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_unban(char *name, char *nick)
+void hybrid_cmd_unban(char *name, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void hybrid_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void hybrid_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s +d 1", nick);
}
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void hybrid_cmd_nc_change(User * u)
{
/* not used */
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void hybrid_cmd_svid_umode2(User * u, char *ts)
{
/* not used */
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void hybrid_cmd_svid_umode3(User * u, char *ts)
{
/* not used */
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void hybrid_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1471,17 +1306,17 @@ int anope_event_pass(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void hybrid_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void hybrid_cmd_svspart(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void hybrid_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
@@ -1501,7 +1336,7 @@ int anope_event_invite(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int hybrid_flood_mode_check(char *value)
{
return 0;
}
@@ -1516,15 +1351,15 @@ int anope_event_error(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void hybrid_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ hybrid_cmd_squit(jserver, rbuf);
+ hybrid_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
@@ -1532,24 +1367,16 @@ void anope_cmd_jupe(char *jserver, char *who, char *reason)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int hybrid_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void hybrid_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1561,4 +1388,117 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
}
-#endif
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(hybrid_cmd_svsnoop);
+ pmodule_cmd_remove_akill(hybrid_cmd_remove_akill);
+ pmodule_cmd_topic(hybrid_cmd_topic);
+ pmodule_cmd_vhost_off(hybrid_cmd_vhost_off);
+ pmodule_cmd_akill(hybrid_cmd_akill);
+ pmodule_cmd_svskill(hybrid_cmd_svskill);
+ pmodule_cmd_svsmode(hybrid_cmd_svsmode);
+ pmodule_cmd_372(hybrid_cmd_372);
+ pmodule_cmd_372_error(hybrid_cmd_372_error);
+ pmodule_cmd_375(hybrid_cmd_375);
+ pmodule_cmd_376(hybrid_cmd_376);
+ pmodule_cmd_nick(hybrid_cmd_nick);
+ pmodule_cmd_guest_nick(hybrid_cmd_guest_nick);
+ pmodule_cmd_mode(hybrid_cmd_mode);
+ pmodule_cmd_bot_nick(hybrid_cmd_bot_nick);
+ pmodule_cmd_kick(hybrid_cmd_kick);
+ pmodule_cmd_notice_ops(hybrid_cmd_notice_ops);
+ pmodule_cmd_notice(hybrid_cmd_notice);
+ pmodule_cmd_notice2(hybrid_cmd_notice2);
+ pmodule_cmd_privmsg(hybrid_cmd_privmsg);
+ pmodule_cmd_privmsg2(hybrid_cmd_privmsg2);
+ pmodule_cmd_serv_notice(hybrid_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(hybrid_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(hybrid_cmd_bot_chan_mode);
+ pmodule_cmd_351(hybrid_cmd_351);
+ pmodule_cmd_quit(hybrid_cmd_quit);
+ pmodule_cmd_pong(hybrid_cmd_pong);
+ pmodule_cmd_join(hybrid_cmd_join);
+ pmodule_cmd_unsqline(hybrid_cmd_unsqline);
+ pmodule_cmd_invite(hybrid_cmd_invite);
+ pmodule_cmd_part(hybrid_cmd_part);
+ pmodule_cmd_391(hybrid_cmd_391);
+ pmodule_cmd_250(hybrid_cmd_250);
+ pmodule_cmd_307(hybrid_cmd_307);
+ pmodule_cmd_311(hybrid_cmd_311);
+ pmodule_cmd_312(hybrid_cmd_312);
+ pmodule_cmd_317(hybrid_cmd_317);
+ pmodule_cmd_219(hybrid_cmd_219);
+ pmodule_cmd_401(hybrid_cmd_401);
+ pmodule_cmd_318(hybrid_cmd_318);
+ pmodule_cmd_242(hybrid_cmd_242);
+ pmodule_cmd_243(hybrid_cmd_243);
+ pmodule_cmd_211(hybrid_cmd_211);
+ pmodule_cmd_global(hybrid_cmd_global);
+ pmodule_cmd_global_legacy(hybrid_cmd_global_legacy);
+ pmodule_cmd_sqline(hybrid_cmd_sqline);
+ pmodule_cmd_squit(hybrid_cmd_squit);
+ pmodule_cmd_svso(hybrid_cmd_svso);
+ pmodule_cmd_chg_nick(hybrid_cmd_chg_nick);
+ pmodule_cmd_svsnick(hybrid_cmd_svsnick);
+ pmodule_cmd_vhost_on(hybrid_cmd_vhost_on);
+ pmodule_cmd_connect(hybrid_cmd_connect);
+ pmodule_cmd_svshold(hybrid_cmd_svshold);
+ pmodule_cmd_release_svshold(hybrid_cmd_release_svshold);
+ pmodule_cmd_unsgline(hybrid_cmd_unsqline);
+ pmodule_cmd_unszline(hybrid_cmd_unszline);
+ pmodule_cmd_szline(hybrid_cmd_szline);
+ pmodule_cmd_sgline(hybrid_cmd_sgline);
+ pmodule_cmd_unban(hybrid_cmd_unban);
+ pmodule_cmd_svsmode_chan(hybrid_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(hybrid_cmd_svid_umode);
+ pmodule_cmd_nc_change(hybrid_cmd_nc_change);
+ pmodule_cmd_svid_umode2(hybrid_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(hybrid_cmd_svid_umode3);
+ pmodule_cmd_eob(hybrid_cmd_eob);
+ pmodule_flood_mode_check(hybrid_flood_mode_check);
+ pmodule_cmd_jupe(hybrid_cmd_jupe);
+ pmodule_valid_nick(hybrid_valid_nick);
+ pmodule_cmd_ctcp(hybrid_cmd_ctcp);
+ pmodule_set_umode(hybrid_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("Hybrid IRCd 7.0");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("");
+ pmodule_ircd_flood_mode_char_remove("");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/hybrid.h b/src/protocol/hybrid.h
new file mode 100644
index 000000000..153914730
--- /dev/null
+++ b/src/protocol/hybrid.h
@@ -0,0 +1,115 @@
+/* Hybrid IRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#define UMODE_a 0x00000001 /* Admin status */
+#define UMODE_b 0x00000080 /* See bot and drone flooding notices */
+#define UMODE_c 0x00000100 /* Client connection/quit notices */
+#define UMODE_d 0x00000200 /* See debugging notices */
+#define UMODE_f 0x00000400 /* See I: line full notices */
+#define UMODE_g 0x00000800 /* Server Side Ignore */
+#define UMODE_i 0x00000004 /* Not shown in NAMES or WHO unless you share a channel */
+#define UMODE_k 0x00001000 /* See server generated KILL messages */
+#define UMODE_l 0x00002000 /* See LOCOPS messages */
+#define UMODE_n 0x00004000 /* See client nick changes */
+#define UMODE_o 0x00000008 /* Operator status */
+#define UMODE_r 0x00000010 /* See rejected client notices */
+#define UMODE_s 0x00008000 /* See general server notices */
+#define UMODE_u 0x00010000 /* See unauthorized client notices */
+#define UMODE_w 0x00000020 /* See server generated WALLOPS */
+#define UMODE_x 0x00020000 /* See remote server connection and split notices */
+#define UMODE_y 0x00040000 /* See LINKS, STATS (if configured), TRACE notices */
+#define UMODE_z 0x00080000 /* See oper generated WALLOPS */
+
+#define CMODE_i 0x00000001 /* Invite only */
+#define CMODE_m 0x00000002 /* Users without +v/h/o cannot send text to the channel */
+#define CMODE_n 0x00000004 /* Users must be in the channel to send text to it */
+#define CMODE_p 0x00000008 /* Private is obsolete, this now restricts KNOCK */
+#define CMODE_s 0x00000010 /* The channel does not show up on NAMES or LIST */
+#define CMODE_t 0x00000020 /* Only chanops can change the topic */
+#define CMODE_k 0x00000040 /* Key/password for the channel. */
+#define CMODE_l 0x00000080 /* Limit the number of users in a channel */
+#define CMODE_a 0x00000400 /* Anonymous ops, chanops are hidden */
+
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t
+
+void hybrid_set_umode(User * user, int ac, char **av);
+void hybrid_cmd_svsnoop(char *server, int set);
+void hybrid_cmd_remove_akill(char *user, char *host);
+void hybrid_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void hybrid_cmd_vhost_off(User * u);
+void hybrid_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void hybrid_cmd_svskill(char *source, char *user, char *buf);
+void hybrid_cmd_svsmode(User * u, int ac, char **av);
+void hybrid_cmd_372(char *source, char *msg);
+void hybrid_cmd_372_error(char *source);
+void hybrid_cmd_375(char *source);
+void hybrid_cmd_376(char *source);
+void hybrid_cmd_nick(char *nick, char *name, char *modes);
+void hybrid_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void hybrid_cmd_mode(char *source, char *dest, char *buf);
+void hybrid_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void hybrid_cmd_kick(char *source, char *chan, char *user, char *buf);
+void hybrid_cmd_notice_ops(char *source, char *dest, char *buf);
+void hybrid_cmd_notice(char *source, char *dest, char *buf);
+void hybrid_cmd_notice2(char *source, char *dest, char *msg);
+void hybrid_cmd_privmsg(char *source, char *dest, char *buf);
+void hybrid_cmd_privmsg2(char *source, char *dest, char *msg);
+void hybrid_cmd_serv_notice(char *source, char *dest, char *msg);
+void hybrid_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void hybrid_cmd_bot_chan_mode(char *nick, char *chan);
+void hybrid_cmd_351(char *source);
+void hybrid_cmd_quit(char *source, char *buf);
+void hybrid_cmd_pong(char *servname, char *who);
+void hybrid_cmd_join(char *user, char *channel, time_t chantime);
+void hybrid_cmd_unsqline(char *user);
+void hybrid_cmd_invite(char *source, char *chan, char *nick);
+void hybrid_cmd_part(char *nick, char *chan, char *buf);
+void hybrid_cmd_391(char *source, char *timestr);
+void hybrid_cmd_250(char *buf);
+void hybrid_cmd_307(char *buf);
+void hybrid_cmd_311(char *buf);
+void hybrid_cmd_312(char *buf);
+void hybrid_cmd_317(char *buf);
+void hybrid_cmd_219(char *source, char *letter);
+void hybrid_cmd_401(char *source, char *who);
+void hybrid_cmd_318(char *source, char *who);
+void hybrid_cmd_242(char *buf);
+void hybrid_cmd_243(char *buf);
+void hybrid_cmd_211(char *buf);
+void hybrid_cmd_global(char *source, char *buf);
+void hybrid_cmd_global_legacy(char *source, char *fmt);
+void hybrid_cmd_sqline(char *mask, char *reason);
+void hybrid_cmd_squit(char *servname, char *message);
+void hybrid_cmd_svso(char *source, char *nick, char *flag);
+void hybrid_cmd_chg_nick(char *oldnick, char *newnick);
+void hybrid_cmd_svsnick(char *source, char *guest, time_t when);
+void hybrid_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void hybrid_cmd_connect(int servernum);
+void hybrid_cmd_svshold(char *nick);
+void hybrid_cmd_release_svshold(char *nick);
+void hybrid_cmd_unsgline(char *mask);
+void hybrid_cmd_unszline(char *mask);
+void hybrid_cmd_szline(char *mask, char *reason, char *whom);
+void hybrid_cmd_sgline(char *mask, char *reason);
+void hybrid_cmd_unban(char *name, char *nick);
+void hybrid_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void hybrid_cmd_svid_umode(char *nick, time_t ts);
+void hybrid_cmd_nc_change(User * u);
+void hybrid_cmd_svid_umode2(User * u, char *ts);
+void hybrid_cmd_svid_umode3(User * u, char *ts);
+void hybrid_cmd_eob();
+int hybrid_flood_mode_check(char *value);
+void hybrid_cmd_jupe(char *jserver, char *who, char *reason);
+int hybrid_valid_nick(char *nick);
+void hybrid_cmd_ctcp(char *source, char *dest, char *buf);
diff --git a/src/protocol/inspircd.c b/src/protocol/inspircd.c
new file mode 100644
index 000000000..58e5bf50a
--- /dev/null
+++ b/src/protocol/inspircd.c
@@ -0,0 +1,1500 @@
+/* InspIRCd beta 3 functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+/*************************************************************************/
+
+#include "services.h"
+#include "pseudo.h"
+#include "inspircd.h"
+
+#ifdef _WIN32
+#include "winsock.h"
+int inet_aton(const char *name, struct in_addr *addr)
+{
+ uint32 a = inet_addr(name);
+ addr->s_addr = a;
+ return a != (uint32) - 1;
+}
+#endif
+
+IRCDVar myIrcd[] = {
+ {"InspIRCd 1.0 Beta", /* ircd name */
+ "+o", /* nickserv mode */
+ "+o", /* chanserv mode */
+ "+o", /* memoserv mode */
+ "+o", /* hostserv mode */
+ "+io", /* operserv mode */
+ "+o", /* botserv mode */
+ "+o", /* helpserv mode */
+ "+i", /* Dev/Null mode */
+ "+io", /* Global mode */
+ "+o", /* nickserv alias mode */
+ "+o", /* chanserv alias mode */
+ "+o", /* memoserv alias mode */
+ "+io", /* hostserv alias mode */
+ "+io", /* operserv alias mode */
+ "+o", /* botserv alias mode */
+ "+o", /* helpserv alias mode */
+ "+i", /* Dev/Null alias mode */
+ "+io", /* Global alias mode */
+ "+i", /* Used by BotServ Bots */
+ 5, /* Chan Max Symbols */
+ "-cilmnpstuzCGKNOQRSV", /* Modes to Remove */
+ "+ao", /* Channel Umode used by Botserv bots */
+ 1, /* SVSNICK */
+ 1, /* Vhost */
+ 1, /* Has Owner */
+ "+q", /* Mode to set for an owner */
+ "-q", /* Mode to unset for an owner */
+ "+a", /* Mode to set for channel admin */
+ "-a", /* Mode to unset for channel admin */
+ "+r", /* Mode On Reg */
+ "-r", /* Mode on UnReg */
+ "-r", /* Mode on Nick Change */
+ 0, /* Supports SGlines */
+ 1, /* Supports SQlines */
+ 1, /* Supports SZlines */
+ 1, /* Supports Halfop +h */
+ 3, /* Number of server args */
+ 0, /* Join 2 Set */
+ 0, /* Join 2 Message */
+ 0, /* Has exceptions +e */
+ 1, /* TS Topic Forward */
+ 0, /* TS Topci Backward */
+ 0, /* Protected Umode */
+ 0, /* Has Admin */
+ 0, /* Chan SQlines */
+ 0, /* Quit on Kill */
+ 0, /* SVSMODE unban */
+ 1, /* Has Protect */
+ 1, /* Reverse */
+ 1, /* Chan Reg */
+ CMODE_r, /* Channel Mode */
+ 0, /* vidents */
+ 0, /* svshold */
+ 0, /* time stamp on mode */
+ 0, /* NICKIP */
+ 0, /* O:LINE */
+ 1, /* UMODE */
+ 1, /* VHOST ON NICK */
+ 1, /* Change RealName */
+ CMODE_K, /* No Knock */
+ 0, /* Admin Only */
+ DEFAULT_MLOCK, /* Default MLOCK */
+ UMODE_x, /* Vhost Mode */
+ 0, /* +f */
+ 1, /* +L */
+ 0,
+ CMODE_L,
+ 0,
+ 0, /* No Knock requires +i */
+ NULL, /* CAPAB Chan Modes */
+ 1, /* We support inspircd TOKENS */
+ 0, /* TOKENS are CASE Sensitive */
+ 0, /* TIME STAMPS are BASE64 */
+ 0, /* +I support */
+ 0, /* SJOIN ban char */
+ 0, /* SJOIN except char */
+ 0, /* SJOIN invite char */
+ 0, /* Can remove User Channel Modes with SVSMODE */
+ 0, /* Sglines are not enforced until user reconnects */
+ "x", /* vhost char */
+ 0, /* ts6 */
+ 0, /* support helper umode */
+ 0, /* p10 */
+ NULL, /* character set */
+ 1, /* reports sync state */
+ }
+ ,
+ {NULL}
+};
+
+
+IRCDCAPAB myIrcdcap[] = {
+ {
+ CAPAB_NOQUIT, /* NOQUIT */
+ 0, /* TSMODE */
+ 0, /* UNCONNECT */
+ 0, /* NICKIP */
+ 0, /* SJOIN */
+ 0, /* ZIP */
+ 0, /* BURST */
+ 0, /* TS5 */
+ 0, /* TS3 */
+ 0, /* DKEY */
+ 0, /* PT4 */
+ 0, /* SCS */
+ 0, /* QS */
+ 0, /* UID */
+ 0, /* KNOCK */
+ 0, /* CLIENT */
+ 0, /* IPV6 */
+ 0, /* SSJ5 */
+ 0, /* SN2 */
+ CAPAB_TOKEN, /* TOKEN */
+ 0, /* VHOST */
+ 0, /* SSJ3 */
+ 0, /* NICK2 */
+ 0, /* UMODE2 */
+ 0, /* VL */
+ 0, /* TLKEXT */
+ 0, /* DODKEY */
+ 0, /* DOZIP */
+ 0,
+ 0, 0}
+};
+
+unsigned long umodes[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0,
+ 0,
+ 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ UMODE_g,
+ UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o,
+ 0,
+ 0, UMODE_r, 0, 0, 0, 0, UMODE_w,
+ UMODE_x,
+ 0,
+ 0,
+ 0, 0, 0, 0, 0
+};
+
+
+char myCsmodes[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0,
+ 0,
+ 0, 0, 0,
+ 'h', /* (37) % Channel halfops */
+ 0,
+ 0, 0, 0,
+ 'q',
+
+ 'v', 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0
+};
+
+CMMode myCmmodes[128] = {
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL},
+ {NULL},
+ {add_ban, del_ban},
+ {NULL},
+ {NULL},
+ {add_exception, del_exception},
+ {NULL},
+ {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
+ {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
+};
+
+
+
+CBMode myCbmodes[128] = {
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0},
+ {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
+ {0}, /* B */
+ {CMODE_C, 0, NULL, NULL}, /* C */
+ {0}, /* D */
+ {0}, /* E */
+ {0}, /* F */
+ {CMODE_G, 0, NULL, NULL}, /* G */
+ {CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL},
+ {0}, /* I */
+ {0}, /* J */
+ {CMODE_K, 0, NULL, NULL}, /* K */
+ {CMODE_L, 0, set_redirect, cs_set_redirect},
+ {0}, /* M */
+ {CMODE_N, 0, NULL, NULL}, /* N */
+ {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
+ {0}, /* P */
+ {CMODE_Q, 0, NULL, NULL}, /* Q */
+ {CMODE_R, 0, NULL, NULL}, /* R */
+ {CMODE_S, 0, NULL, NULL}, /* S */
+ {0}, /* T */
+ {0}, /* U */
+ {CMODE_V, 0, NULL, NULL}, /* V */
+ {0}, /* W */
+ {0}, /* X */
+ {0}, /* Y */
+ {0}, /* Z */
+ {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, /* a */
+ {0}, /* b */
+ {CMODE_c, 0, NULL, NULL},
+ {0}, /* d */
+ {0}, /* e */
+ {CMODE_f, 0, set_flood, cs_set_flood},
+ {0}, /* g */
+ {0}, /* h */
+ {CMODE_i, 0, NULL, NULL},
+ {0}, /* j */
+ {CMODE_k, 0, set_key, cs_set_key},
+ {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
+ {CMODE_m, 0, NULL, NULL},
+ {CMODE_n, 0, NULL, NULL},
+ {0}, /* o */
+ {CMODE_p, 0, NULL, NULL},
+ {0}, /* q */
+ {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
+ {CMODE_s, 0, NULL, NULL},
+ {CMODE_t, 0, NULL, NULL},
+ {CMODE_u, 0, NULL, NULL},
+ {0}, /* v */
+ {0}, /* w */
+ {0}, /* x */
+ {0}, /* y */
+ {CMODE_z, 0, NULL, NULL},
+ {0}, {0}, {0}, {0}
+};
+
+CBModeInfo myCbmodeinfos[] = {
+ {'c', CMODE_c, 0, NULL, NULL},
+ {'f', CMODE_f, 0, get_flood, cs_get_flood},
+ {'i', CMODE_i, 0, NULL, NULL},
+ {'k', CMODE_k, 0, get_key, cs_get_key},
+ {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
+ {'m', CMODE_m, 0, NULL, NULL},
+ {'n', CMODE_n, 0, NULL, NULL},
+ {'p', CMODE_p, 0, NULL, NULL},
+ {'r', CMODE_r, 0, NULL, NULL},
+ {'s', CMODE_s, 0, NULL, NULL},
+ {'t', CMODE_t, 0, NULL, NULL},
+ {'u', CMODE_u, 0, NULL, NULL},
+ {'z', CMODE_z, 0, NULL, NULL},
+ {'A', CMODE_A, 0, NULL, NULL},
+ {'C', CMODE_C, 0, NULL, NULL},
+ {'G', CMODE_G, 0, NULL, NULL},
+ {'H', CMODE_H, 0, NULL, NULL},
+ {'K', CMODE_K, 0, NULL, NULL},
+ {'L', CMODE_L, 0, get_redirect, cs_get_redirect},
+ {'N', CMODE_N, 0, NULL, NULL},
+ {'O', CMODE_O, 0, NULL, NULL},
+ {'Q', CMODE_Q, 0, NULL, NULL},
+ {'R', CMODE_R, 0, NULL, NULL},
+ {'S', CMODE_S, 0, NULL, NULL},
+ {'V', CMODE_V, 0, NULL, NULL},
+ {0}
+};
+
+CUMode myCumodes[128] = {
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
+
+ {0},
+
+ {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op},
+ {0}, /* b */
+ {0}, /* c */
+ {0}, /* d */
+ {0}, /* e */
+ {0}, /* f */
+ {0}, /* g */
+ {CUS_HALFOP, 0, check_valid_op},
+ {0}, /* i */
+ {0}, /* j */
+ {0}, /* k */
+ {0}, /* l */
+ {0}, /* m */
+ {0}, /* n */
+ {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
+ {0}, /* p */
+ {CUS_OWNER, 0, check_valid_op},
+ {0}, /* r */
+ {0}, /* s */
+ {0}, /* t */
+ {0}, /* u */
+ {CUS_VOICE, 0, NULL},
+ {0}, /* w */
+ {0}, /* x */
+ {0}, /* y */
+ {0}, /* z */
+ {0}, {0}, {0}, {0}, {0}
+};
+
+
+void inspircd_set_umode(User * user, int ac, char **av)
+{
+ int add = 1; /* 1 if adding modes, 0 if deleting */
+ char *modes = av[0];
+
+ ac--;
+
+ if (debug)
+ alog("debug: Changing mode for %s to %s", user->nick, modes);
+
+ while (*modes) {
+
+ add ? (user->mode |= umodes[(int) *modes]) : (user->mode &=
+ ~umodes[(int)
+ *modes]);
+
+ switch (*modes++) {
+ case '+':
+ add = 1;
+ break;
+ case '-':
+ add = 0;
+ break;
+ case 'o':
+ if (add) {
+ opcnt++;
+ if (WallOper) {
+ anope_cmd_global(s_OperServ,
+ "\2%s\2 is now an IRC operator.",
+ user->nick);
+ }
+ display_news(user, NEWS_OPER);
+ } else {
+ opcnt--;
+ }
+ break;
+ case 'r':
+ if (add && !nick_identified(user)) {
+ common_svsmode(user, "-r", NULL);
+ user->mode &= ~UMODE_r;
+ }
+ break;
+ case 'x':
+ update_host(user);
+ break;
+ }
+ }
+}
+
+int anope_event_nickchange(char *source, int ac, char **av);
+int anope_event_servertopic(char *source, int ac, char **av);
+int anope_event_servermode(char *source, int ac, char **av);
+
+/* *INDENT-OFF* */
+void moduleAddIRCDMsgs(void) {
+ Message *m;
+
+ // user has no choice but to use tokens with InspIRCd :)
+ UseTokens = 1;
+
+ updateProtectDetails("PROTECT","PROTECTME","!protect","!deprotect","AUTOPROTECT","+a","-a");
+
+ m = createMessage("$", anope_event_null); addCoreMessage(IRCD,m); // send routing table
+ m = createMessage("X", anope_event_null); addCoreMessage(IRCD,m); // begin netburst NOW
+ m = createMessage("Y", anope_event_null); addCoreMessage(IRCD,m); // end of UPLINK netburst
+ m = createMessage("H", anope_event_null); addCoreMessage(IRCD,m); // local sync start
+ m = createMessage("F", anope_event_null); addCoreMessage(IRCD,m); // local sync end
+ m = createMessage("f", anope_event_null); addCoreMessage(IRCD,m); // local U-lined sync end
+ m = createMessage("*", anope_event_null); addCoreMessage(IRCD,m); // no operation
+ m = createMessage("|", anope_event_null); addCoreMessage(IRCD,m); // oper type
+ m = createMessage("-", anope_event_null); addCoreMessage(IRCD,m); // start mesh operation
+ m = createMessage("s", anope_event_server); addCoreMessage(IRCD,m); // passive server response
+ m = createMessage("U", anope_event_null); addCoreMessage(IRCD,m); // active service connect
+ m = createMessage("J", anope_event_join); addCoreMessage(IRCD,m); // join
+ m = createMessage("k", anope_event_kick); addCoreMessage(IRCD,m); // kick
+ m = createMessage("K", anope_event_kill); addCoreMessage(IRCD,m); // kill
+ m = createMessage("M", anope_event_servermode); addCoreMessage(IRCD,m); // servermode
+ m = createMessage("m", anope_event_mode); addCoreMessage(IRCD,m); // mode
+ m = createMessage("N", anope_event_nick); addCoreMessage(IRCD,m); // nick (introduce)
+ m = createMessage("n", anope_event_nickchange); addCoreMessage(IRCD,m); // nick (change)
+ m = createMessage("V", anope_event_null); addCoreMessage(IRCD,m); // notice
+ m = createMessage("L", anope_event_part); addCoreMessage(IRCD,m); // part
+ m = createMessage("?", anope_event_ping); addCoreMessage(IRCD,m); // ping
+ m = createMessage("P", anope_event_privmsg); addCoreMessage(IRCD,m); // privmsg
+ m = createMessage("Q", anope_event_quit); addCoreMessage(IRCD,m); // quit
+ m = createMessage("&", anope_event_squit); addCoreMessage(IRCD,m); // squit
+ m = createMessage("t", anope_event_topic); addCoreMessage(IRCD,m); // topic (user)
+ m = createMessage("T", anope_event_servertopic); addCoreMessage(IRCD,m); // topic (server)
+ m = createMessage("@", anope_event_null); addCoreMessage(IRCD,m); // wallops
+ m = createMessage("b", anope_event_chghost); addCoreMessage(IRCD,m); // change displayed host
+ m = createMessage("a", anope_event_chgname); addCoreMessage(IRCD,m); // change gecos
+}
+
+/* *INDENT-ON* */
+
+/* Event: PROTOCTL */
+int anope_event_capab(char *source, int ac, char **av)
+{
+ capab_parse(ac, av);
+ return MOD_CONT;
+}
+
+int anope_event_nickchange(char *source, int ac, char **av)
+{
+ do_nick(av[0], av[1], NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
+ return MOD_CONT;
+}
+
+void inspircd_cmd_svsnoop(char *server, int set)
+{
+ send_cmd(NULL, "*");
+}
+
+void inspircd_cmd_svsadmin(char *server, int set)
+{
+ inspircd_cmd_svsnoop(server, set);
+}
+
+void inspircd_cmd_remove_akill(char *user, char *host)
+{
+ send_cmd(NULL, ". %s@%s %s", user, host, s_OperServ);
+}
+
+void inspircd_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
+{
+ send_cmd(NULL, "t %lu %s %s :%s", (unsigned long int) when, whosetit,
+ chan, topic);
+}
+
+void inspircd_cmd_vhost_off(User * u)
+{
+ send_cmd(NULL, "m %s %s -x", s_HostServ, u->nick);
+}
+
+void inspircd_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
+{
+ send_cmd(NULL, "# %s@%s %s %lu %lu :%s", user, host, who,
+ (long int) when, 86400 * 2, reason);
+}
+
+void inspircd_cmd_svskill(char *source, char *user, char *buf)
+{
+ if (!buf || !source || !user) {
+ return;
+ }
+ send_cmd(NULL, "K %s %s :%s", s_OperServ, user, buf);
+}
+
+void inspircd_cmd_svsmode(User * u, int ac, char **av)
+{
+ send_cmd(NULL, "M %s %s", u->nick, av[0]);
+}
+
+
+void inspircd_cmd_372(char *source, char *msg)
+{
+}
+
+void inspircd_cmd_372_error(char *source)
+{
+}
+
+void inspircd_cmd_375(char *source)
+{
+}
+
+void inspircd_cmd_376(char *source)
+{
+}
+
+void inspircd_cmd_nick(char *nick, char *name, char *modes)
+{
+ // N <time> <nick> <host> <displayed-host> <ident> <modes> <ipaddress> <server> :<GECOS>
+ send_cmd(NULL, "N %lu %s %s %s %s %s 0.0.0.0 %s :%s",
+ (long int) time(NULL), nick, ServiceHost, ServiceHost,
+ ServiceUser, modes, ServerName, name);
+}
+
+void inspircd_cmd_guest_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
+{
+ send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick,
+ (long int) time(NULL), user, host, ServerName, modes, real);
+ send_cmd(NULL, "N %lu %s %s %s %s %s 0.0.0.0 %s :%s",
+ (long int) time(NULL), nick, host, host, user, modes,
+ ServerName, real);
+}
+
+void inspircd_cmd_mode(char *source, char *dest, char *buf)
+{
+ if (!buf) {
+ return;
+ }
+ send_cmd(NULL, "m %s %s %s", source, dest, buf);
+}
+
+void inspircd_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
+{
+ send_cmd(NULL, "N %lu %s %s %s %s %s 0.0.0.0 %s :%s",
+ (long int) time(NULL), nick, host, host, user, modes,
+ ServerName, real);
+}
+
+void inspircd_cmd_kick(char *source, char *chan, char *user, char *buf)
+{
+ if (buf) {
+ send_cmd(NULL, "k %s %s :%s", source, user, chan, buf);
+ } else {
+ send_cmd(NULL, "k %s %s :", source, user, chan);
+ }
+}
+
+void inspircd_cmd_notice_ops(char *source, char *dest, char *buf)
+{
+ if (!buf) {
+ return;
+ }
+
+ send_cmd(NULL, "V %s @%s :%s", source, dest, buf);
+}
+
+
+void inspircd_cmd_notice(char *source, char *dest, char *buf)
+{
+ if (!buf) {
+ return;
+ }
+
+ if (UsePrivmsg) {
+ inspircd_cmd_privmsg2(source, dest, buf);
+ } else {
+ send_cmd(NULL, "V %s %s :%s", source, dest, buf);
+ }
+}
+
+void inspircd_cmd_notice2(char *source, char *dest, char *msg)
+{
+ send_cmd(NULL, "V %s %s :%s", source, dest, msg);
+}
+
+void inspircd_cmd_privmsg(char *source, char *dest, char *buf)
+{
+ if (!buf) {
+ return;
+ }
+
+ send_cmd(NULL, "P %s %s :%s", source, dest, buf);
+}
+
+void inspircd_cmd_privmsg2(char *source, char *dest, char *msg)
+{
+ send_cmd(NULL, "P %s %s :%s", source, dest, msg);
+}
+
+void inspircd_cmd_serv_notice(char *source, char *dest, char *msg)
+{
+}
+
+void inspircd_cmd_serv_privmsg(char *source, char *dest, char *msg)
+{
+}
+
+
+void inspircd_cmd_bot_chan_mode(char *nick, char *chan)
+{
+ anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
+}
+
+void inspircd_cmd_351(char *source)
+{
+}
+
+/* QUIT */
+void inspircd_cmd_quit(char *source, char *buf)
+{
+ if (buf) {
+ send_cmd(NULL, "Q %s :%s", source, buf);
+ } else {
+ send_cmd(NULL, "QUIT %s :", source);
+ }
+}
+
+/* PROTOCTL */
+void inspircd_cmd_protoctl()
+{
+}
+
+/* PASS */
+void inspircd_cmd_pass(char *pass)
+{
+// send_cmd(NULL, "PASS :%s", pass);
+}
+
+/* SERVER name hop descript */
+void inspircd_cmd_server(char *servname, int hop, char *descript)
+{
+ Server *newserv;
+ if (hop == 0) {
+ send_cmd(NULL, "H %s", servname);
+ } else {
+ char pw[1024];
+ switch (hop) {
+ case 1:
+ strncpy(pw, RemotePassword, 1023);
+ break;
+ case 2:
+ strncpy(pw, RemotePassword2, 1023);
+ break;
+ case 3:
+ strncpy(pw, RemotePassword3, 1023);
+ break;
+ }
+ send_cmd(NULL, "U %s %s :%s", servname, pw, descript);
+ send_cmd(NULL, "v %s Anope-%s %s :%s - %s -- %s", servname,
+ version_number, ServerName, ircd->name, version_flags,
+ version_build);
+ }
+}
+
+/* PONG */
+void inspircd_cmd_pong(char *servname, char *who)
+{
+ send_cmd(NULL, "!");
+}
+
+/* JOIN */
+void inspircd_cmd_join(char *user, char *channel, time_t chantime)
+{
+ send_cmd(NULL, "J %s %s", user, channel);
+}
+
+/* UNSQLINE */
+void inspircd_cmd_unsqline(char *user)
+{
+ if (!user) {
+ return;
+ }
+ send_cmd(NULL, "[ %s %s", user, s_OperServ);
+}
+
+/* CHGHOST */
+void inspircd_cmd_chghost(char *nick, char *vhost)
+{
+ if (!nick || !vhost) {
+ return;
+ }
+ send_cmd(NULL, "b %s %s", nick, vhost);
+}
+
+/* CHGIDENT */
+void inspircd_cmd_chgident(char *nick, char *vIdent)
+{
+}
+
+/* INVITE */
+void inspircd_cmd_invite(char *source, char *chan, char *nick)
+{
+ if (!source || !chan || !nick) {
+ return;
+ }
+
+ send_cmd(NULL, "i %s %s %s", source, nick, chan);
+}
+
+/* PART */
+void inspircd_cmd_part(char *nick, char *chan, char *buf)
+{
+ if (!nick || !chan) {
+ return;
+ }
+ if (buf) {
+ send_cmd(NULL, "L %s :%s", nick, chan, buf);
+ } else {
+ send_cmd(NULL, "L %s %s :", nick, chan);
+ }
+}
+
+/* 391 */
+void inspircd_cmd_391(char *source, char *timestr)
+{
+}
+
+/* 250 */
+void inspircd_cmd_250(char *buf)
+{
+}
+
+/* 307 */
+void inspircd_cmd_307(char *buf)
+{
+}
+
+/* 311 */
+void inspircd_cmd_311(char *buf)
+{
+}
+
+/* 312 */
+void inspircd_cmd_312(char *buf)
+{
+}
+
+/* 317 */
+void inspircd_cmd_317(char *buf)
+{
+}
+
+/* 219 */
+void inspircd_cmd_219(char *source, char *letter)
+{
+}
+
+/* 401 */
+void inspircd_cmd_401(char *source, char *who)
+{
+}
+
+/* 318 */
+void inspircd_cmd_318(char *source, char *who)
+{
+}
+
+/* 242 */
+void inspircd_cmd_242(char *buf)
+{
+}
+
+/* 243 */
+void inspircd_cmd_243(char *buf)
+{
+}
+
+/* 211 */
+void inspircd_cmd_211(char *buf)
+{
+}
+
+/* GLOBOPS */
+void inspircd_cmd_global(char *source, char *buf)
+{
+ send_cmd(NULL, "V %s * :%s", (source ? source : s_OperServ), buf);
+}
+
+/* SQLINE */
+void inspircd_cmd_sqline(char *mask, char *reason)
+{
+ if (!mask || !reason) {
+ return;
+ }
+ // { <mask> <who-set-it> <time-set> <duration> :<reason>
+ send_cmd(NULL, "{ %s %s %lu 0 :%s", mask, ServerName,
+ (unsigned long) time(NULL), reason);
+}
+
+/* SQUIT */
+void inspircd_cmd_squit(char *servname, char *message)
+{
+ if (!servname) {
+ return;
+ }
+
+ send_cmd(NULL, "& %s", servname);
+}
+
+/* SVSO */
+void inspircd_cmd_svso(char *source, char *nick, char *flag)
+{
+ send_cmd(NULL, "M %s %s", nick, flag);
+}
+
+/* NICK <newnick> */
+void inspircd_cmd_chg_nick(char *oldnick, char *newnick)
+{
+ if (!oldnick || !newnick) {
+ return;
+ }
+
+ send_cmd("n %s %s", oldnick, newnick);
+}
+
+/* SVSNICK */
+void inspircd_cmd_svsnick(char *source, char *guest, time_t when)
+{
+ if (!source || !guest) {
+ return;
+ }
+ send_cmd(NULL, "n %s %s", source, guest);
+}
+
+/* Functions that use serval cmd functions */
+
+void inspircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+{
+ if (!nick) {
+ return;
+ }
+ if (vIdent) {
+ inspircd_cmd_chgident(nick, vIdent);
+ }
+ inspircd_cmd_chghost(nick, vhost);
+}
+
+void inspircd_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ inspircd_cmd_server(ServerName, servernum, ServerDesc);
+}
+
+/* Events */
+
+int anope_event_ping(char *source, int ac, char **av)
+{
+ if (ac < 1)
+ return MOD_CONT;
+ inspircd_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ return MOD_CONT;
+}
+
+int anope_event_436(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+
+int anope_event_away(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+
+int anope_event_servertopic(char *source, int ac, char **av)
+{
+ char *v[32];
+ if (ac != 4)
+ return MOD_CONT;
+ v[0] = av[2]; // channel
+ v[1] = av[3]; // topic
+ do_topic(NULL, 2, v); // no source (server set)
+ return MOD_CONT;
+}
+
+int anope_event_topic(char *source, int ac, char **av)
+{
+ char *v[32];
+ if (ac != 3)
+ return MOD_CONT;
+ v[0] = av[1]; // channel
+ v[1] = av[2]; // topic content
+ do_topic(av[0], 2, v);
+ return MOD_CONT;
+}
+
+int anope_event_squit(char *source, int ac, char **av)
+{
+ char *v[32];
+ if (ac != 1)
+ return MOD_CONT;
+ v[0] = av[1];
+ do_squit(av[1], 1, v);
+ return MOD_CONT;
+}
+
+int anope_event_quit(char *source, int ac, char **av)
+{
+ char *v[32];
+ if (ac != 2)
+ return MOD_CONT;
+ v[0] = av[1];
+ v[1] = av[2];
+ do_quit(av[0], 2, v);
+ return MOD_CONT;
+}
+
+int anope_event_servermode(char *source, int ac, char **av)
+{
+ char *v[32];
+ Channel *c;
+ int i = 0;
+
+ if (*av[0] == '#') {
+ c = findchan(av[0]);
+ for (i = 1; i < ac; i++)
+ v[i - 1] = av[i];
+ if (c) {
+ chan_set_modes(s_OperServ, c, ac - 1, v, 1);
+ }
+ } else {
+ v[0] = av[0];
+ for (i = 0; i < ac; i++)
+ v[i + 1] = av[i];
+ anope_event_mode(av[0], ac + 1, v);
+ }
+ return MOD_CONT;
+}
+
+
+int anope_event_mode(char *source, int ac, char **av)
+{
+ char *v[32];
+ int i;
+ if (ac < 3)
+ return MOD_CONT;
+
+ for (i = 1; i < ac; i++) {
+ v[i - 1] = av[i];
+ }
+ if (*av[1] == '#') {
+ do_cmode(av[1], ac - 1, v);
+ } else {
+ do_umode(av[0], ac - 1, v);
+ }
+ return MOD_CONT;
+}
+
+
+int anope_event_kill(char *source, int ac, char **av)
+{
+ if (ac != 3)
+ return MOD_CONT;
+ m_kill(av[1], av[2]);
+ return MOD_CONT;
+}
+
+int anope_event_kick(char *source, int ac, char **av)
+{
+ // Syntax: k <source> <dest> <channel> :<reason>
+ char *v[32];
+ if (ac != 4)
+ return MOD_CONT;
+ v[0] = av[1];
+ v[1] = av[2];
+ v[2] = av[3];
+ do_kick(av[0], 3, v);
+ return MOD_CONT;
+}
+
+
+int anope_event_join(char *source, int ac, char **av)
+{
+ //if (ac != 2)
+ // return MOD_CONT;
+ //char *v[32];
+ //v[0] = av[1];
+ //do_join(av[0], 1, v);
+ //return MOD_CONT;
+
+ User *u;
+ Channel *c;
+ int i;
+ int32 modes = 0, thismode;
+ char *new_av[32];
+ char *cumodes[3];
+ char thismodes[256];
+ cumodes[0] = thismodes;
+
+ // some sanity checks
+ if (ac < 2) {
+ return MOD_CONT;
+ }
+
+ u = finduser(av[0]); // get the user info
+
+ if (!u) {
+ return MOD_CONT;
+ }
+
+ cumodes[1] = av[0];
+
+ // iterate through each channel the user is joining
+ for (i = 1; i < ac; i++) {
+ // the channel name
+ new_av[0] = av[i];
+
+ // strip off the permissions
+ strcpy(thismodes, "");
+ if (*new_av[0] != '#') {
+ switch (*new_av[0]) {
+ case '@':
+ strcpy(thismodes, "+o");
+ break;
+ case '%':
+ strcpy(thismodes, "+h");
+ break;
+ case '+':
+ strcpy(thismodes, "+v");
+ break;
+ }
+ new_av[0]++;
+ }
+
+ do_join(av[0], 1, new_av);
+ c = findchan(new_av[0]);
+ if ((c) && (strcmp(thismodes, ""))) {
+ chan_set_modes(av[0], c, 2, cumodes, 1);
+ }
+ }
+
+ return MOD_CONT;
+
+}
+
+int anope_event_motd(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+
+int anope_event_setname(char *source, int ac, char **av)
+{
+ User *u;
+
+ if (ac != 2)
+ return MOD_CONT;
+
+ u = finduser(av[0]);
+ if (!u) {
+ if (debug) {
+ alog("user: SETNAME for nonexistent user %s", source);
+ }
+ return MOD_CONT;
+ }
+ change_user_realname(u, av[1]);
+ return MOD_CONT;
+}
+
+int anope_event_chgname(char *source, int ac, char **av)
+{
+ User *u;
+
+ if (ac != 2)
+ return MOD_CONT;
+
+ u = finduser(av[0]);
+ if (!u) {
+ if (debug) {
+ alog("user: CHGNAME for nonexistent user %s", av[0]);
+ }
+ return MOD_CONT;
+ }
+
+ change_user_realname(u, av[1]);
+ return MOD_CONT;
+}
+
+int anope_event_setident(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+int anope_event_chgident(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+
+int anope_event_sethost(char *source, int ac, char **av)
+{
+ User *u;
+
+ if (ac != 2)
+ return MOD_CONT;
+
+ u = finduser(av[0]);
+ if (!u) {
+ if (debug) {
+ alog("user: SETHOST for nonexistent user %s", source);
+ }
+ return MOD_CONT;
+ }
+ change_user_host(u, av[1]);
+ return MOD_CONT;
+}
+
+int anope_event_nick(char *source, int ac, char **av)
+{
+ User *user;
+ struct in_addr addy;
+ uint32 *ad = (uint32 *) & addy;
+
+// someone really should comment this -- Brain
+
+// User *do_nick(const char *source, char *nick, char *username, char *host,
+// char *server, char *realname, time_t ts, uint32 svid,
+// uint32 ip, char *vhost, char *uid)
+
+// Syntax: N <time> <nick> <host> <displayed-host> <ident> <modes> <ipaddress> <server> :<GECOS>
+
+ if (ac == 9) {
+ // fix by brain - 27 apr 2005
+ // During a net merge between two meshed clients there may be some spurious "bouncing"
+ // nick introductions (e.g. introductions for clients we already have). If this happens,
+ // we should ignore any that claim to be from us as these are just confirmations of the
+ // services "complement" - processing them will cause all kinds of session limit oddities.
+ if ((strcmp(av[7], ServerName)) || (finduser(av[1]))) {
+ inet_aton(av[6], &addy);
+ user = do_nick(source, av[1], av[4], av[2], uplink, av[8],
+ strtoul(av[0], NULL, 10), 0, htonl(*ad), av[3],
+ NULL);
+ if (user)
+ anope_set_umode(user, 1, &av[5]);
+ }
+ }
+ return MOD_CONT;
+}
+
+
+int anope_event_chghost(char *source, int ac, char **av)
+{
+ User *u;
+
+ if (ac != 2)
+ return MOD_CONT;
+
+ u = finduser(av[0]);
+ if (!u) {
+ if (debug) {
+ alog("user: CHGHOST for nonexistent user %s", av[0]);
+ }
+ return MOD_CONT;
+ }
+
+ change_user_host(u, av[1]);
+ return MOD_CONT;
+}
+
+/* EVENT: SERVER */
+int anope_event_server(char *source, int ac, char **av)
+{
+ // to shield anope from the intricacies of the mesh,
+ // anope only sees the uplink at all times (and receives
+ // all nick introductions etc as if they'd come from the
+ // uplink directly, 1 hop away.
+ if (!uplink) {
+ uplink = sstrdup(av[0]);
+ do_server(source, av[0], av[1], av[3], NULL);
+ }
+ return MOD_CONT;
+}
+
+
+int anope_event_privmsg(char *source, int ac, char **av)
+{
+ if (ac != 3)
+ return MOD_CONT;
+ m_privmsg(av[0], av[1], av[2]);
+ return MOD_CONT;
+}
+
+int anope_event_part(char *source, int ac, char **av)
+{
+ char *v[32];
+ if (ac != 3)
+ return MOD_CONT;
+ v[0] = av[1]; // channel
+ v[1] = av[2]; // reason
+ do_part(av[0], 2, v);
+ return MOD_CONT;
+}
+
+int anope_event_whois(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+
+/* SVSHOLD - set */
+void inspircd_cmd_svshold(char *nick)
+{
+ /* Not supported by this IRCD */
+}
+
+/* SVSHOLD - release */
+void inspircd_cmd_release_svshold(char *nick)
+{
+ /* Not Supported by this IRCD */
+}
+
+/* UNSGLINE */
+void inspircd_cmd_unsgline(char *mask)
+{
+ /* Not Supported by this IRCD */
+}
+
+/* UNSZLINE */
+void inspircd_cmd_unszline(char *mask)
+{
+ // ] <mask> <who>
+ send_cmd(NULL, "] %s %s", mask, s_OperServ);
+}
+
+/* SZLINE */
+void inspircd_cmd_szline(char *mask, char *reason, char *whom)
+{
+ // } <mask> <who-set-it> <time-set> <duration> :<reason>
+ send_cmd(NULL, "} %s %s %lu %lu :%s", mask, whom,
+ (long int) time(NULL), 86400 * 2, reason);
+}
+
+/* SGLINE */
+void inspircd_cmd_sgline(char *mask, char *reason)
+{
+ /* Not Supported by this IRCD */
+}
+
+void inspircd_cmd_unban(char *name, char *nick)
+{
+ /* Not Supported by this IRCD */
+}
+
+/* SVSMODE channel modes */
+
+void inspircd_cmd_svsmode_chan(char *name, char *mode, char *nick)
+{
+ /* Not Supported by this IRCD */
+}
+
+
+/* SVSMODE +d */
+/* sent if svid is something weird */
+void inspircd_cmd_svid_umode(char *nick, time_t ts)
+{
+ /* Not supported by this IRCD */
+}
+
+/* SVSMODE +d */
+/* nc_change was = 1, and there is no na->status */
+void inspircd_cmd_nc_change(User * u)
+{
+ common_svsmode(u, "-r", "1");
+}
+
+/* SVSMODE +r */
+void inspircd_cmd_svid_umode2(User * u, char *ts)
+{
+ send_cmd(NULL, "m %s %s +r", s_OperServ, u->nick);
+}
+
+void inspircd_cmd_svid_umode3(User * u, char *ts)
+{
+ /* not used */
+}
+
+void inspircd_cmd_svsjoin(char *source, char *nick, char *chan)
+{
+ send_cmd(source, "J %s %s", nick, chan);
+}
+
+void inspircd_cmd_svspart(char *source, char *nick, char *chan)
+{
+ send_cmd(source, "L %s %s :", nick, chan);
+}
+
+void inspircd_cmd_swhois(char *source, char *who, char *mask)
+{
+ /* Not supported at U type server */
+}
+
+void inspircd_cmd_eob()
+{
+ /* Not implemented in this version of inspircd.c */
+}
+
+
+int anope_event_rehash(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+
+int anope_event_credits(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+
+int anope_event_admin(char *source, int ac, char **av)
+{
+ return MOD_CONT;
+}
+
+int inspircd_flood_mode_check(char *value)
+{
+ // no +f mode!
+ return 1;
+}
+
+void inspircd_cmd_jupe(char *jserver, char *who, char *reason)
+{
+ alog("JUPE: Unsupported!");
+}
+
+/* GLOBOPS - to handle old WALLOPS */
+void inspircd_cmd_global_legacy(char *source, char *fmt)
+{
+ send_cmd(NULL, "@ %s :%s", source ? source : ServerName, fmt);
+}
+
+int inspircd_valid_nick(char *nick)
+{
+ // no special nicks
+ return 1;
+}
+
+void inspircd_cmd_ctcp(char *source, char *dest, char *buf)
+{
+ char *s;
+ if (!buf) {
+ return;
+ } else {
+ s = normalizeBuffer(buf);
+ send_cmd(NULL, "V %s %s :\1%s \1", source, dest, s);
+ free(s);
+ }
+}
+
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(inspircd_cmd_svsnoop);
+ pmodule_cmd_remove_akill(inspircd_cmd_remove_akill);
+ pmodule_cmd_topic(inspircd_cmd_topic);
+ pmodule_cmd_vhost_off(inspircd_cmd_vhost_off);
+ pmodule_cmd_akill(inspircd_cmd_akill);
+ pmodule_cmd_svskill(inspircd_cmd_svskill);
+ pmodule_cmd_svsmode(inspircd_cmd_svsmode);
+ pmodule_cmd_372(inspircd_cmd_372);
+ pmodule_cmd_372_error(inspircd_cmd_372_error);
+ pmodule_cmd_375(inspircd_cmd_375);
+ pmodule_cmd_376(inspircd_cmd_376);
+ pmodule_cmd_nick(inspircd_cmd_nick);
+ pmodule_cmd_guest_nick(inspircd_cmd_guest_nick);
+ pmodule_cmd_mode(inspircd_cmd_mode);
+ pmodule_cmd_bot_nick(inspircd_cmd_bot_nick);
+ pmodule_cmd_kick(inspircd_cmd_kick);
+ pmodule_cmd_notice_ops(inspircd_cmd_notice_ops);
+ pmodule_cmd_notice(inspircd_cmd_notice);
+ pmodule_cmd_notice2(inspircd_cmd_notice2);
+ pmodule_cmd_privmsg(inspircd_cmd_privmsg);
+ pmodule_cmd_privmsg2(inspircd_cmd_privmsg2);
+ pmodule_cmd_serv_notice(inspircd_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(inspircd_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(inspircd_cmd_bot_chan_mode);
+ pmodule_cmd_351(inspircd_cmd_351);
+ pmodule_cmd_quit(inspircd_cmd_quit);
+ pmodule_cmd_pong(inspircd_cmd_pong);
+ pmodule_cmd_join(inspircd_cmd_join);
+ pmodule_cmd_unsqline(inspircd_cmd_unsqline);
+ pmodule_cmd_invite(inspircd_cmd_invite);
+ pmodule_cmd_part(inspircd_cmd_part);
+ pmodule_cmd_391(inspircd_cmd_391);
+ pmodule_cmd_250(inspircd_cmd_250);
+ pmodule_cmd_307(inspircd_cmd_307);
+ pmodule_cmd_311(inspircd_cmd_311);
+ pmodule_cmd_312(inspircd_cmd_312);
+ pmodule_cmd_317(inspircd_cmd_317);
+ pmodule_cmd_219(inspircd_cmd_219);
+ pmodule_cmd_401(inspircd_cmd_401);
+ pmodule_cmd_318(inspircd_cmd_318);
+ pmodule_cmd_242(inspircd_cmd_242);
+ pmodule_cmd_243(inspircd_cmd_243);
+ pmodule_cmd_211(inspircd_cmd_211);
+ pmodule_cmd_global(inspircd_cmd_global);
+ pmodule_cmd_global_legacy(inspircd_cmd_global_legacy);
+ pmodule_cmd_sqline(inspircd_cmd_sqline);
+ pmodule_cmd_squit(inspircd_cmd_squit);
+ pmodule_cmd_svso(inspircd_cmd_svso);
+ pmodule_cmd_chg_nick(inspircd_cmd_chg_nick);
+ pmodule_cmd_svsnick(inspircd_cmd_svsnick);
+ pmodule_cmd_vhost_on(inspircd_cmd_vhost_on);
+ pmodule_cmd_connect(inspircd_cmd_connect);
+ pmodule_cmd_svshold(inspircd_cmd_svshold);
+ pmodule_cmd_release_svshold(inspircd_cmd_release_svshold);
+ pmodule_cmd_unsgline(inspircd_cmd_unsqline);
+ pmodule_cmd_unszline(inspircd_cmd_unszline);
+ pmodule_cmd_szline(inspircd_cmd_szline);
+ pmodule_cmd_sgline(inspircd_cmd_sgline);
+ pmodule_cmd_unban(inspircd_cmd_unban);
+ pmodule_cmd_svsmode_chan(inspircd_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(inspircd_cmd_svid_umode);
+ pmodule_cmd_nc_change(inspircd_cmd_nc_change);
+ pmodule_cmd_svid_umode2(inspircd_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(inspircd_cmd_svid_umode3);
+ pmodule_cmd_eob(inspircd_cmd_eob);
+ pmodule_flood_mode_check(inspircd_flood_mode_check);
+ pmodule_cmd_jupe(inspircd_cmd_jupe);
+ pmodule_valid_nick(inspircd_valid_nick);
+ pmodule_cmd_ctcp(inspircd_cmd_ctcp);
+ pmodule_set_umode(inspircd_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Brain");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("InspIRCd 1.0 Beta3");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("+f");
+ pmodule_ircd_flood_mode_char_remove("-f");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/inspircd.h b/src/protocol/inspircd.h
new file mode 100644
index 000000000..a7aa01e4c
--- /dev/null
+++ b/src/protocol/inspircd.h
@@ -0,0 +1,124 @@
+/* InspIRCd 1.0 beta functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+/*************************************************************************/
+
+#define UMODE_a 0x00000001
+#define UMODE_h 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_r 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_A 0x00000040
+#define UMODE_g 0x80000000
+#define UMODE_x 0x40000000
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_c 0x00000400
+#define CMODE_A 0x00000800
+#define CMODE_H 0x00001000
+#define CMODE_K 0x00002000
+#define CMODE_L 0x00004000
+#define CMODE_O 0x00008000
+#define CMODE_Q 0x00010000
+#define CMODE_S 0x00020000
+#define CMODE_V 0x00040000
+#define CMODE_f 0x00080000
+#define CMODE_G 0x00100000
+#define CMODE_C 0x00200000
+#define CMODE_u 0x00400000
+#define CMODE_z 0x00800000
+#define CMODE_N 0x01000000
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void inspircd_set_umode(User * user, int ac, char **av);
+void inspircd_cmd_svsnoop(char *server, int set);
+void inspircd_cmd_remove_akill(char *user, char *host);
+void inspircd_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void inspircd_cmd_vhost_off(User * u);
+void inspircd_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void inspircd_cmd_svskill(char *source, char *user, char *buf);
+void inspircd_cmd_svsmode(User * u, int ac, char **av);
+void inspircd_cmd_372(char *source, char *msg);
+void inspircd_cmd_372_error(char *source);
+void inspircd_cmd_375(char *source);
+void inspircd_cmd_376(char *source);
+void inspircd_cmd_nick(char *nick, char *name, char *modes);
+void inspircd_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void inspircd_cmd_mode(char *source, char *dest, char *buf);
+void inspircd_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void inspircd_cmd_kick(char *source, char *chan, char *user, char *buf);
+void inspircd_cmd_notice_ops(char *source, char *dest, char *buf);
+void inspircd_cmd_notice(char *source, char *dest, char *buf);
+void inspircd_cmd_notice2(char *source, char *dest, char *msg);
+void inspircd_cmd_privmsg(char *source, char *dest, char *buf);
+void inspircd_cmd_privmsg2(char *source, char *dest, char *msg);
+void inspircd_cmd_serv_notice(char *source, char *dest, char *msg);
+void inspircd_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void inspircd_cmd_bot_chan_mode(char *nick, char *chan);
+void inspircd_cmd_351(char *source);
+void inspircd_cmd_quit(char *source, char *buf);
+void inspircd_cmd_pong(char *servname, char *who);
+void inspircd_cmd_join(char *user, char *channel, time_t chantime);
+void inspircd_cmd_unsqline(char *user);
+void inspircd_cmd_invite(char *source, char *chan, char *nick);
+void inspircd_cmd_part(char *nick, char *chan, char *buf);
+void inspircd_cmd_391(char *source, char *timestr);
+void inspircd_cmd_250(char *buf);
+void inspircd_cmd_307(char *buf);
+void inspircd_cmd_311(char *buf);
+void inspircd_cmd_312(char *buf);
+void inspircd_cmd_317(char *buf);
+void inspircd_cmd_219(char *source, char *letter);
+void inspircd_cmd_401(char *source, char *who);
+void inspircd_cmd_318(char *source, char *who);
+void inspircd_cmd_242(char *buf);
+void inspircd_cmd_243(char *buf);
+void inspircd_cmd_211(char *buf);
+void inspircd_cmd_global(char *source, char *buf);
+void inspircd_cmd_global_legacy(char *source, char *fmt);
+void inspircd_cmd_sqline(char *mask, char *reason);
+void inspircd_cmd_squit(char *servname, char *message);
+void inspircd_cmd_svso(char *source, char *nick, char *flag);
+void inspircd_cmd_chg_nick(char *oldnick, char *newnick);
+void inspircd_cmd_svsnick(char *source, char *guest, time_t when);
+void inspircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void inspircd_cmd_connect(int servernum);
+void inspircd_cmd_svshold(char *nick);
+void inspircd_cmd_release_svshold(char *nick);
+void inspircd_cmd_unsgline(char *mask);
+void inspircd_cmd_unszline(char *mask);
+void inspircd_cmd_szline(char *mask, char *reason, char *whom);
+void inspircd_cmd_sgline(char *mask, char *reason);
+void inspircd_cmd_unban(char *name, char *nick);
+void inspircd_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void inspircd_cmd_svid_umode(char *nick, time_t ts);
+void inspircd_cmd_nc_change(User * u);
+void inspircd_cmd_svid_umode2(User * u, char *ts);
+void inspircd_cmd_svid_umode3(User * u, char *ts);
+void inspircd_cmd_eob();
+int inspircd_flood_mode_check(char *value);
+void inspircd_cmd_jupe(char *jserver, char *who, char *reason);
+int inspircd_valid_nick(char *nick);
+void inspircd_cmd_ctcp(char *source, char *dest, char *buf);
+
diff --git a/src/plexus.c b/src/protocol/plexus.c
index 63ef88996..2c14a1c34 100644
--- a/src/plexus.c
+++ b/src/protocol/plexus.c
@@ -13,17 +13,9 @@
#include "services.h"
#include "pseudo.h"
+#include "plexus.h"
-#ifdef IRC_PLEXUS
-
-const char version_protocol[] = "PleXusIRCd 2.0+";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = ""; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = ""; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0;
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"PleXusIRCd 2.0+", /* ircd name */
"+oiSR", /* nickserv mode */
"+oiSR", /* chanserv mode */
@@ -84,7 +76,6 @@ IRCDVar ircd[] = {
0, /* O:LINE */
1, /* VHOST ON NICK */
0, /* Change RealName */
- CHAN_HELP_IRCD_HALFOP, /* ChanServ extra */
CMODE_p, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -116,7 +107,7 @@ IRCDVar ircd[] = {
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
0, /* NOQUIT */
0, /* TSMODE */
@@ -151,7 +142,7 @@ IRCDCAPAB ircdcap[] = {
-void anope_set_umode(User * user, int ac, char **av)
+void plexus_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -317,7 +308,7 @@ unsigned long umodes[128] = {
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -338,7 +329,7 @@ char csmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
@@ -388,7 +379,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -454,7 +445,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'a', CMODE_a, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
@@ -473,7 +464,7 @@ CBModeInfo cbmodeinfos[] = {
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -522,44 +513,26 @@ CUMode cumodes[128] = {
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void plexus_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ plexus_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void plexus_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void plexus_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -567,33 +540,24 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void plexus_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void plexus_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $$%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void plexus_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $$%s :%s", dest, msg);
}
-void anope_cmd_global(char *source, const char *fmt, ...)
+void plexus_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -602,7 +566,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void plexus_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "OPERWALL :%s", fmt);
}
@@ -728,59 +692,59 @@ void moduleAddIRCDMsgs(void) {
/* *INDENT-ON* */
-void anope_cmd_sqline(char *mask, char *reason)
+void plexus_cmd_sqline(char *mask, char *reason)
{
send_cmd(NULL, "RESV * %s :%s", mask, reason);
}
-void anope_cmd_unsgline(char *mask)
+void plexus_cmd_unsgline(char *mask)
{
/* Does not support */
}
-void anope_cmd_unszline(char *mask)
+void plexus_cmd_unszline(char *mask)
{
/* Does not support */
}
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void plexus_cmd_szline(char *mask, char *reason, char *whom)
{
/* Does not support */
}
-void anope_cmd_svsnoop(char *server, int set)
+void plexus_cmd_svsnoop(char *server, int set)
{
/* does not support */
}
-void anope_cmd_svsadmin(char *server, int set)
+void plexus_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ plexus_cmd_svsnoop(server, set);
}
-void anope_cmd_sgline(char *mask, char *reason)
+void plexus_cmd_sgline(char *mask, char *reason)
{
/* does not support */
}
-void anope_cmd_remove_akill(char *user, char *host)
+void plexus_cmd_remove_akill(char *user, char *host)
{
send_cmd(s_OperServ, "UNKLINE * %s %s", user, host);
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void plexus_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "SVSTOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
-void anope_cmd_vhost_off(User * u)
+void plexus_cmd_vhost_off(User * u)
{
send_cmd(NULL, "SVSMODE %s -h", u->nick);
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void plexus_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
if (!nick) {
return;
@@ -789,12 +753,12 @@ void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
send_cmd(NULL, "SVSHOST %s %s", nick, vhost);
}
-void anope_cmd_unsqline(char *user)
+void plexus_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNRESV * %s", user);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void plexus_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(NULL, "SJOIN %ld %s + :%s", (long int) time(NULL), channel,
user);
@@ -809,24 +773,15 @@ host: the 'host' portion of the kline
reason: the reason for the kline.
*/
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void plexus_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(s_OperServ, "KLINE * %ld %s %s :%s",
(long int) (expires - (long) time(NULL)), user, host, reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void plexus_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -838,7 +793,7 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
send_cmd(source, "KILL %s :%s", user, buf);
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void plexus_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %s", u->nick, av[0]);
@@ -846,28 +801,6 @@ void anope_cmd_svsmode(User * u, int ac, char **av)
send_cmd(ServerName, "SVSID %s %s", u->nick, av[1]);
}
-void anope_cmd_connect(int servernum)
-{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
-
- if (servernum == 1)
- anope_cmd_pass(RemotePassword);
- else if (servernum == 2)
- anope_cmd_pass(RemotePassword2);
- else if (servernum == 3)
- anope_cmd_pass(RemotePassword3);
-
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
-}
-
-void anope_cmd_svsinfo()
-{
- /* not used */
-}
-
/*
* SVINFO
* parv[0] = sender prefix
@@ -876,7 +809,7 @@ void anope_cmd_svsinfo()
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
-void anope_cmd_svinfo()
+void plexus_cmd_svinfo()
{
send_cmd(NULL, "SVINFO 5 5 0 :%ld", (long int) time(NULL));
}
@@ -902,47 +835,61 @@ void anope_cmd_svinfo()
PARA - supports invite broadcasting for +p
ENCAP - ?
*/
-void anope_cmd_capab()
+void plexus_cmd_capab()
{
send_cmd(NULL,
"CAPAB :QS EX CHW IE EOB KLN GLN HOPS HUB KNOCK TBURST PARA");
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void plexus_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS %s :TS", pass);
}
/* SERVER name hop descript */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void plexus_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void plexus_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ if (servernum == 1)
+ plexus_cmd_pass(RemotePassword);
+ else if (servernum == 2)
+ plexus_cmd_pass(RemotePassword2);
+ else if (servernum == 3)
+ plexus_cmd_pass(RemotePassword3);
+
+ plexus_cmd_capab();
+ plexus_cmd_server(ServerName, 1, ServerDesc);
+ plexus_cmd_svinfo();
+}
+
+void plexus_cmd_svsinfo()
+{
+ /* not used */
+}
+
+
+
+void plexus_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s %s 0 :%s", nick,
(long int) time(NULL), modes, user, host, "*", ServerName,
real);
- anope_cmd_sqline(nick, "Reserved for services");
+ plexus_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void plexus_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(nick, "PART %s :%s", chan, buf);
} else {
@@ -973,7 +920,7 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ plexus_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
@@ -1022,7 +969,7 @@ int anope_event_eob(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_eob()
+void plexus_cmd_eob()
{
send_cmd(ServerName, "EOB");
}
@@ -1096,30 +1043,30 @@ int anope_event_quit(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_372(char *source, char *msg)
+void plexus_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void plexus_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void plexus_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void plexus_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void plexus_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1128,17 +1075,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void plexus_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1147,17 +1085,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void plexus_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1166,17 +1095,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void plexus_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1185,17 +1105,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void plexus_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1204,17 +1115,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void plexus_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1223,7 +1125,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void plexus_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1238,7 +1140,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void plexus_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1247,7 +1149,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void plexus_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1257,17 +1159,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void plexus_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1276,17 +1169,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void plexus_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1295,17 +1179,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void plexus_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1313,17 +1188,8 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void plexus_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1331,28 +1197,17 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "MODE %s %s", dest, buf);
}
-void anope_cmd_nick(char *nick, char *name, char *mode)
+void plexus_cmd_nick(char *nick, char *name, char *mode)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s %s 0 :%s", nick,
(long int) time(NULL), mode, ServiceUser, ServiceHost,
"*", ServerName, (name));
- anope_cmd_sqline(nick, "Reserved for services");
+ plexus_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void plexus_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1360,17 +1215,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void plexus_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1378,24 +1224,14 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void plexus_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void plexus_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -1404,13 +1240,13 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void plexus_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void plexus_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1420,7 +1256,7 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* SQUIT */
-void anope_cmd_squit(char *servname, char *message)
+void plexus_cmd_squit(char *servname, char *message)
{
if (!servname || !message) {
return;
@@ -1449,7 +1285,7 @@ int anope_event_mode(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_351(char *source)
+void plexus_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
@@ -1464,19 +1300,19 @@ int anope_event_capab(char *source, int ac, char **av)
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void plexus_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void plexus_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSNICK */
-void anope_cmd_svsnick(char *nick, char *newnick, time_t when)
+void plexus_cmd_svsnick(char *nick, char *newnick, time_t when)
{
if (!nick || !newnick) {
return;
@@ -1484,47 +1320,47 @@ void anope_cmd_svsnick(char *nick, char *newnick, time_t when)
send_cmd(NULL, "SVSNICK %s %s", nick, newnick);
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void plexus_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s %s 0 :%s", nick,
(long int) time(NULL), modes, user, host, "*", ServerName,
real);
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void plexus_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_unban(char *name, char *nick)
+void plexus_cmd_unban(char *name, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void plexus_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void plexus_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSID %s 1", nick);
}
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void plexus_cmd_nc_change(User * u)
{
common_svsmode(u, "-R", "1");
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void plexus_cmd_svid_umode2(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+R", ts);
@@ -1533,13 +1369,13 @@ void anope_cmd_svid_umode2(User * u, char *ts)
}
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void plexus_cmd_svid_umode3(User * u, char *ts)
{
/* not used */
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void plexus_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1568,17 +1404,17 @@ int anope_event_pass(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void plexus_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void plexus_cmd_svspart(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void plexus_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
@@ -1598,7 +1434,7 @@ int anope_event_invite(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int plexus_flood_mode_check(char *value)
{
return 0;
}
@@ -1613,15 +1449,15 @@ int anope_event_error(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void plexus_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ plexus_cmd_squit(jserver, rbuf);
+ plexus_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
@@ -1629,24 +1465,16 @@ void anope_cmd_jupe(char *jserver, char *who, char *reason)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int plexus_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void plexus_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1657,4 +1485,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(plexus_cmd_svsnoop);
+ pmodule_cmd_remove_akill(plexus_cmd_remove_akill);
+ pmodule_cmd_topic(plexus_cmd_topic);
+ pmodule_cmd_vhost_off(plexus_cmd_vhost_off);
+ pmodule_cmd_akill(plexus_cmd_akill);
+ pmodule_cmd_svskill(plexus_cmd_svskill);
+ pmodule_cmd_svsmode(plexus_cmd_svsmode);
+ pmodule_cmd_372(plexus_cmd_372);
+ pmodule_cmd_372_error(plexus_cmd_372_error);
+ pmodule_cmd_375(plexus_cmd_375);
+ pmodule_cmd_376(plexus_cmd_376);
+ pmodule_cmd_nick(plexus_cmd_nick);
+ pmodule_cmd_guest_nick(plexus_cmd_guest_nick);
+ pmodule_cmd_mode(plexus_cmd_mode);
+ pmodule_cmd_bot_nick(plexus_cmd_bot_nick);
+ pmodule_cmd_kick(plexus_cmd_kick);
+ pmodule_cmd_notice_ops(plexus_cmd_notice_ops);
+ pmodule_cmd_notice(plexus_cmd_notice);
+ pmodule_cmd_notice2(plexus_cmd_notice2);
+ pmodule_cmd_privmsg(plexus_cmd_privmsg);
+ pmodule_cmd_privmsg2(plexus_cmd_privmsg2);
+ pmodule_cmd_serv_notice(plexus_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(plexus_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(plexus_cmd_bot_chan_mode);
+ pmodule_cmd_351(plexus_cmd_351);
+ pmodule_cmd_quit(plexus_cmd_quit);
+ pmodule_cmd_pong(plexus_cmd_pong);
+ pmodule_cmd_join(plexus_cmd_join);
+ pmodule_cmd_unsqline(plexus_cmd_unsqline);
+ pmodule_cmd_invite(plexus_cmd_invite);
+ pmodule_cmd_part(plexus_cmd_part);
+ pmodule_cmd_391(plexus_cmd_391);
+ pmodule_cmd_250(plexus_cmd_250);
+ pmodule_cmd_307(plexus_cmd_307);
+ pmodule_cmd_311(plexus_cmd_311);
+ pmodule_cmd_312(plexus_cmd_312);
+ pmodule_cmd_317(plexus_cmd_317);
+ pmodule_cmd_219(plexus_cmd_219);
+ pmodule_cmd_401(plexus_cmd_401);
+ pmodule_cmd_318(plexus_cmd_318);
+ pmodule_cmd_242(plexus_cmd_242);
+ pmodule_cmd_243(plexus_cmd_243);
+ pmodule_cmd_211(plexus_cmd_211);
+ pmodule_cmd_global(plexus_cmd_global);
+ pmodule_cmd_global_legacy(plexus_cmd_global_legacy);
+ pmodule_cmd_sqline(plexus_cmd_sqline);
+ pmodule_cmd_squit(plexus_cmd_squit);
+ pmodule_cmd_svso(plexus_cmd_svso);
+ pmodule_cmd_chg_nick(plexus_cmd_chg_nick);
+ pmodule_cmd_svsnick(plexus_cmd_svsnick);
+ pmodule_cmd_vhost_on(plexus_cmd_vhost_on);
+ pmodule_cmd_connect(plexus_cmd_connect);
+ pmodule_cmd_svshold(plexus_cmd_svshold);
+ pmodule_cmd_release_svshold(plexus_cmd_release_svshold);
+ pmodule_cmd_unsgline(plexus_cmd_unsqline);
+ pmodule_cmd_unszline(plexus_cmd_unszline);
+ pmodule_cmd_szline(plexus_cmd_szline);
+ pmodule_cmd_sgline(plexus_cmd_sgline);
+ pmodule_cmd_unban(plexus_cmd_unban);
+ pmodule_cmd_svsmode_chan(plexus_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(plexus_cmd_svid_umode);
+ pmodule_cmd_nc_change(plexus_cmd_nc_change);
+ pmodule_cmd_svid_umode2(plexus_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(plexus_cmd_svid_umode3);
+ pmodule_cmd_eob(plexus_cmd_eob);
+ pmodule_flood_mode_check(plexus_flood_mode_check);
+ pmodule_cmd_jupe(plexus_cmd_jupe);
+ pmodule_valid_nick(plexus_valid_nick);
+ pmodule_cmd_ctcp(plexus_cmd_ctcp);
+ pmodule_set_umode(plexus_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("PleXusIRCd 2.0+");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("");
+ pmodule_ircd_flood_mode_char_remove("");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/plexus.h b/src/protocol/plexus.h
new file mode 100644
index 000000000..54f002ca3
--- /dev/null
+++ b/src/protocol/plexus.h
@@ -0,0 +1,126 @@
+/* PlexusIRCD IRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#define UMODE_a 0x00000001
+#define UMODE_h 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_R 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_s 0x00000040
+#define UMODE_c 0x00000080
+#define UMODE_r 0x00000100
+#define UMODE_k 0x00000200
+#define UMODE_f 0x00000400
+#define UMODE_y 0x00000800
+#define UMODE_d 0x00001000
+#define UMODE_n 0x00002000
+#define UMODE_x 0x00004000
+#define UMODE_u 0x00008000
+#define UMODE_b 0x00010000
+#define UMODE_l 0x00020000
+#define UMODE_g 0x00040000
+#define UMODE_S 0x00080000
+
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_a 0x00000400
+#define CMODE_Z 0x00000800
+#define CMODE_M 0x00001000
+#define CMODE_c 0x00002000
+#define CMODE_O 0x00004000
+#define CMODE_R 0x00008000
+#define CMODE_N 0x00010000
+
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t
+
+void plexus_set_umode(User * user, int ac, char **av);
+void plexus_cmd_svsnoop(char *server, int set);
+void plexus_cmd_remove_akill(char *user, char *host);
+void plexus_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void plexus_cmd_vhost_off(User * u);
+void plexus_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void plexus_cmd_svskill(char *source, char *user, char *buf);
+void plexus_cmd_svsmode(User * u, int ac, char **av);
+void plexus_cmd_372(char *source, char *msg);
+void plexus_cmd_372_error(char *source);
+void plexus_cmd_375(char *source);
+void plexus_cmd_376(char *source);
+void plexus_cmd_nick(char *nick, char *name, char *modes);
+void plexus_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void plexus_cmd_mode(char *source, char *dest, char *buf);
+void plexus_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void plexus_cmd_kick(char *source, char *chan, char *user, char *buf);
+void plexus_cmd_notice_ops(char *source, char *dest, char *buf);
+void plexus_cmd_notice(char *source, char *dest, char *buf);
+void plexus_cmd_notice2(char *source, char *dest, char *msg);
+void plexus_cmd_privmsg(char *source, char *dest, char *buf);
+void plexus_cmd_privmsg2(char *source, char *dest, char *msg);
+void plexus_cmd_serv_notice(char *source, char *dest, char *msg);
+void plexus_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void plexus_cmd_bot_chan_mode(char *nick, char *chan);
+void plexus_cmd_351(char *source);
+void plexus_cmd_quit(char *source, char *buf);
+void plexus_cmd_pong(char *servname, char *who);
+void plexus_cmd_join(char *user, char *channel, time_t chantime);
+void plexus_cmd_unsqline(char *user);
+void plexus_cmd_invite(char *source, char *chan, char *nick);
+void plexus_cmd_part(char *nick, char *chan, char *buf);
+void plexus_cmd_391(char *source, char *timestr);
+void plexus_cmd_250(char *buf);
+void plexus_cmd_307(char *buf);
+void plexus_cmd_311(char *buf);
+void plexus_cmd_312(char *buf);
+void plexus_cmd_317(char *buf);
+void plexus_cmd_219(char *source, char *letter);
+void plexus_cmd_401(char *source, char *who);
+void plexus_cmd_318(char *source, char *who);
+void plexus_cmd_242(char *buf);
+void plexus_cmd_243(char *buf);
+void plexus_cmd_211(char *buf);
+void plexus_cmd_global(char *source, char *buf);
+void plexus_cmd_global_legacy(char *source, char *fmt);
+void plexus_cmd_sqline(char *mask, char *reason);
+void plexus_cmd_squit(char *servname, char *message);
+void plexus_cmd_svso(char *source, char *nick, char *flag);
+void plexus_cmd_chg_nick(char *oldnick, char *newnick);
+void plexus_cmd_svsnick(char *source, char *guest, time_t when);
+void plexus_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void plexus_cmd_connect(int servernum);
+void plexus_cmd_svshold(char *nick);
+void plexus_cmd_release_svshold(char *nick);
+void plexus_cmd_unsgline(char *mask);
+void plexus_cmd_unszline(char *mask);
+void plexus_cmd_szline(char *mask, char *reason, char *whom);
+void plexus_cmd_sgline(char *mask, char *reason);
+void plexus_cmd_unban(char *name, char *nick);
+void plexus_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void plexus_cmd_svid_umode(char *nick, time_t ts);
+void plexus_cmd_nc_change(User * u);
+void plexus_cmd_svid_umode2(User * u, char *ts);
+void plexus_cmd_svid_umode3(User * u, char *ts);
+void plexus_cmd_eob();
+int plexus_flood_mode_check(char *value);
+void plexus_cmd_jupe(char *jserver, char *who, char *reason);
+int plexus_valid_nick(char *nick);
+void plexus_cmd_ctcp(char *source, char *dest, char *buf);
+
+
diff --git a/src/ptlink.c b/src/protocol/ptlink.c
index d7c848953..25c85d739 100644
--- a/src/ptlink.c
+++ b/src/protocol/ptlink.c
@@ -13,17 +13,9 @@
#include "services.h"
#include "pseudo.h"
+#include "ptlink.h"
-#ifdef IRC_PTLINK
-
-const char version_protocol[] = "PTlink 6.15.*+";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = "+f"; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = "-f"; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0;
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"PTlink 6.15.*+", /* ircd name */
"+o", /* nickserv mode */
"+o", /* chanserv mode */
@@ -84,7 +76,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
- CHAN_HELP_IRCD_PROTECT, /* ChanServ extra */
CMODE_K, /* No Knock */
CMODE_A, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -116,7 +107,7 @@ IRCDVar ircd[] = {
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
0, /* NOQUIT */
0, /* TSMODE */
@@ -201,7 +192,7 @@ unsigned long umodes[128] = {
0, 0 /* ~ ‚ */
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -223,7 +214,7 @@ char csmodes[128] = {
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
@@ -250,7 +241,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -316,7 +307,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'d', CMODE_d, 0, NULL, NULL},
{'f', CMODE_f, 0, get_flood, cs_get_flood},
@@ -341,7 +332,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -390,7 +381,7 @@ CUMode cumodes[128] = {
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void ptlink_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(s_ChanServ, chan, "%s %s %s", ircd->botchanumode, nick,
nick);
@@ -606,7 +597,7 @@ int anope_event_capab(char *source, int ac, char **av)
parv[1] = sqlined nick/mask
parv[2] = reason
*/
-void anope_cmd_sqline(char *mask, char *reason)
+void ptlink_cmd_sqline(char *mask, char *reason)
{
send_cmd(ServerName, "SQLINE %s :%s", mask, reason);
}
@@ -619,14 +610,14 @@ void anope_cmd_sqline(char *mask, char *reason)
operations:
noopers - remove existing opers and disable o:lines
*/
-void anope_cmd_svsnoop(char *server, int set)
+void ptlink_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSADMIN %s :%s", server, set ? "noopers" : "rehash");
}
-void anope_cmd_svsadmin(char *server, int set)
+void ptlink_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ ptlink_cmd_svsnoop(server, set);
}
/*
@@ -634,7 +625,7 @@ void anope_cmd_svsadmin(char *server, int set)
parv[0] = sender (server if on network synchronization)
parv[1] = glined usert@host mask or ALL to remove all glines
*/
-void anope_cmd_remove_akill(char *user, char *host)
+void ptlink_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "UNGLINE %s@%s", user, host);
}
@@ -656,12 +647,12 @@ void anope_topic(char *whosets, char *chan, char *whosetit, char *topic,
parv[0] = sender
parv[1] = sqlined nick/mask
*/
-void anope_cmd_unsqline(char *user)
+void ptlink_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNSQLINE %s", user);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void ptlink_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(ServerName, "SJOIN %ld %s + :%s", (long int) time(NULL),
channel, user);
@@ -675,25 +666,16 @@ void anope_cmd_join(char *user, char *channel, time_t chantime)
parv[3] = who added the gline
parv[4] = reason
*/
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void ptlink_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(ServerName, "GLINE %s@%s %i %s :%s", user, host, 86400 * 2,
who, reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void ptlink_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -713,7 +695,7 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
parv[3] = extra parameter ( if news setting mode(+n) )
e.g.: :NickServ SVSMODE Lamego +rn 1991234
*/
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void ptlink_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0],
(ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
@@ -729,35 +711,17 @@ int anope_event_error(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_squit(char *servname, char *message)
+void ptlink_cmd_squit(char *servname, char *message)
{
send_cmd(NULL, "SQUIT %s :%s", servname, message);
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void ptlink_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
-void anope_cmd_connect(int servernum)
-{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
-
- if (servernum == 1)
- anope_cmd_pass(RemotePassword);
- else if (servernum == 2)
- anope_cmd_pass(RemotePassword2);
- else if (servernum == 3)
- anope_cmd_pass(RemotePassword3);
-
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
- anope_cmd_svsinfo();
-}
-
/*
SVINFO %d %d
parv[0] = server name
@@ -767,7 +731,7 @@ void anope_cmd_connect(int servernum)
See the ptlink.h for information on PTLINK_TS_CURRENT, and
PTLINK_TS_MIN
*/
-void anope_cmd_svinfo()
+void ptlink_cmd_svinfo()
{
#if defined(PTLINK_TS_CURRENT) && defined(PTLINK_TS_MIN)
send_cmd(NULL, "SVINFO %d %d %lu", PTLINK_TS_CURRENT, PTLINK_TS_MIN,
@@ -784,7 +748,7 @@ void anope_cmd_svinfo()
parv[1] = local services data TS
parv[1] = max global users
*/
-void anope_cmd_svsinfo()
+void ptlink_cmd_svsinfo()
{
send_cmd(NULL, "SVSINFO %lu %d", (unsigned long int) time(NULL),
maxusercnt);
@@ -796,7 +760,7 @@ void anope_cmd_svsinfo()
(TS indicates this is server uses TS protocol and SVINFO will be sent
for protocol compatibility checking)
*/
-void anope_cmd_pass(char *pass)
+void ptlink_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS %s :TS", pass);
}
@@ -805,17 +769,36 @@ void anope_cmd_pass(char *pass)
CAPAB :%s
parv[1] = capability list
*/
-void anope_cmd_capab()
+void ptlink_cmd_capab()
{
send_cmd(NULL, "CAPAB :QS PTS4");
}
-void anope_cmd_server(char *servname, int hop, char *descript)
+void ptlink_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d Anope.Services%s :%s", servname, hop,
version_number_dotted, descript);
}
+void ptlink_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ if (servernum == 1)
+ ptlink_cmd_pass(RemotePassword);
+ else if (servernum == 2)
+ ptlink_cmd_pass(RemotePassword2);
+ else if (servernum == 3)
+ ptlink_cmd_pass(RemotePassword3);
+
+ ptlink_cmd_capab();
+ ptlink_cmd_server(ServerName, 1, ServerDesc);
+ ptlink_cmd_svinfo();
+ ptlink_cmd_svsinfo();
+}
+
+
int anope_event_privmsg(char *source, int ac, char **av)
{
@@ -929,17 +912,8 @@ int anope_event_motd(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void ptlink_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -948,44 +922,26 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
}
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void ptlink_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ ptlink_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void ptlink_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void ptlink_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -993,33 +949,24 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void ptlink_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void ptlink_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void ptlink_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void ptlink_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1028,7 +975,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void ptlink_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1037,17 +984,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void ptlink_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1056,17 +994,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void ptlink_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1075,17 +1004,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void ptlink_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1094,17 +1014,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void ptlink_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1113,17 +1024,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void ptlink_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1132,7 +1034,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void ptlink_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1147,7 +1049,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void ptlink_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1156,7 +1058,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void ptlink_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1166,17 +1068,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void ptlink_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1185,17 +1078,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void ptlink_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1204,17 +1088,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void ptlink_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1222,17 +1097,8 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void ptlink_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1252,27 +1118,17 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
parv[8] = server
parv[9] = nick info
*/
-void anope_cmd_nick(char *nick, char *name, char *mode)
+void ptlink_cmd_nick(char *nick, char *name, char *mode)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick,
(unsigned long int) time(NULL), mode, ServiceUser,
ServiceHost, ServiceHost, ServerName, name);
- anope_cmd_sqline(nick, "Reserved for services");
+ ptlink_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void ptlink_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1285,18 +1141,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void ptlink_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -1304,18 +1150,8 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
}
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void ptlink_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(nick, "PART %s :%s", chan, buf);
} else {
@@ -1331,18 +1167,18 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
parv[3] = topic time
parv[4] = topic text
*/
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void ptlink_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s :%s", chan, topic);
}
-void anope_cmd_vhost_off(User * u)
+void ptlink_cmd_vhost_off(User * u)
{
/* does not support vhosting */
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void ptlink_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
if (vIdent) {
send_cmd(s_HostServ, "NEWMASK %s@%s %s", vIdent, vhost, nick);
@@ -1352,7 +1188,7 @@ void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void ptlink_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1361,30 +1197,30 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
send_cmd(source, "INVITE %s %s", nick, chan);
}
-void anope_cmd_372(char *source, char *msg)
+void ptlink_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void ptlink_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void ptlink_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void ptlink_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
-void anope_set_umode(User * user, int ac, char **av)
+void ptlink_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -1439,7 +1275,7 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ ptlink_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
@@ -1456,18 +1292,18 @@ int anope_event_away(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void ptlink_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick,
(unsigned long int) time(NULL), modes, user, host, host,
ServerName, real);
- anope_cmd_sqline(nick, "Reserved for services");
+ ptlink_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_351(char *source)
+void ptlink_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
@@ -1475,13 +1311,13 @@ void anope_cmd_351(char *source)
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void ptlink_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void ptlink_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
@@ -1491,7 +1327,7 @@ void anope_cmd_release_svshold(char *nick)
parv[0] = sender
parv[1] = zlined host
*/
-void anope_cmd_unszline(char *mask)
+void ptlink_cmd_unszline(char *mask)
{
send_cmd(s_OperServ, "UNZLINE %s", mask);
}
@@ -1503,7 +1339,7 @@ void anope_cmd_unszline(char *mask)
parv[2] = time
parv[3] = reason
*/
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void ptlink_cmd_szline(char *mask, char *reason, char *whom)
{
send_cmd(s_OperServ, "ZLINE %s %ld :%s", mask,
(long int) time(NULL) + 86400 * 2, reason);
@@ -1514,7 +1350,7 @@ void anope_cmd_szline(char *mask, char *reason, char *whom)
parv[0] = sender
parv[1] = info ban mask
*/
-void anope_cmd_unsgline(char *mask)
+void ptlink_cmd_unsgline(char *mask)
{
send_cmd(ServerName, "UNSXLINE :%s", mask);
}
@@ -1527,7 +1363,7 @@ void anope_cmd_unsgline(char *mask)
* parv[1] = mask length
* parv[2] = real name banned mask:reason
*/
-void anope_cmd_sgline(char *mask, char *reason)
+void ptlink_cmd_sgline(char *mask, char *reason)
{
send_cmd(ServerName, "SXLINE %d :%s:%s", strlen(mask), mask, reason);
}
@@ -1540,7 +1376,7 @@ void anope_cmd_sgline(char *mask, char *reason)
parv[2] = new nick
e.g.: :NickServ SVSNICK Smiler 67455223 _Smiler-
*/
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void ptlink_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1548,8 +1384,8 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void ptlink_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick,
(unsigned long int) time(NULL), modes, user, host, host,
@@ -1557,19 +1393,19 @@ void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
}
-void anope_cmd_unban(char *name, char *nick)
+void ptlink_cmd_unban(char *name, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void ptlink_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void ptlink_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
@@ -1577,26 +1413,26 @@ void anope_cmd_svso(char *source, char *nick, char *flag)
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void ptlink_cmd_svid_umode(char *nick, time_t ts)
{
/* Not Supported by this ircd */
}
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void ptlink_cmd_nc_change(User * u)
{
/* Not Supported by this ircd */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void ptlink_cmd_svid_umode2(User * u, char *ts)
{
common_svsmode(u, "+r", NULL);
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void ptlink_cmd_svid_umode3(User * u, char *ts)
{
/* Bahamuts have this extra one, since they can check on even nick changes */
}
@@ -1608,7 +1444,7 @@ void anope_cmd_svid_umode3(User * u, char *ts)
parv[1] = new nick
parv[2] = TS (timestamp from user's server when nick changed was received)
*/
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void ptlink_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1624,7 +1460,7 @@ void anope_cmd_chg_nick(char *oldnick, char *newnick)
parv[2] = channels list
:OperServ SVSJOIN Trystan #Admin
*/
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void ptlink_cmd_svsjoin(char *source, char *nick, char *chan)
{
send_cmd(source, "SVSJOIN %s %s", nick, chan);
}
@@ -1636,12 +1472,12 @@ void anope_cmd_svsjoin(char *source, char *nick, char *chan)
parv[2] = channels list
e.g.: :ChanServ SVSPART mynick 4163321 #Chan1,#Chan2
*/
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void ptlink_cmd_svspart(char *source, char *nick, char *chan)
{
send_cmd(source, "SVSPART %s :%s", nick, chan);
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void ptlink_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
@@ -1676,7 +1512,7 @@ int anope_event_invite(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int ptlink_flood_mode_check(char *value)
{
char *dp, *end;
@@ -1690,25 +1526,25 @@ int anope_flood_mode_check(char *value)
}
}
-void anope_cmd_eob()
+void ptlink_cmd_eob()
{
/* not supported */
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void ptlink_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 1, rbuf);
+ ptlink_cmd_squit(jserver, rbuf);
+ ptlink_cmd_server(jserver, 1, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void ptlink_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
}
@@ -1717,24 +1553,16 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int ptlink_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void ptlink_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1745,4 +1573,119 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(ptlink_cmd_svsnoop);
+ pmodule_cmd_remove_akill(ptlink_cmd_remove_akill);
+ pmodule_cmd_topic(ptlink_cmd_topic);
+ pmodule_cmd_vhost_off(ptlink_cmd_vhost_off);
+ pmodule_cmd_akill(ptlink_cmd_akill);
+ pmodule_cmd_svskill(ptlink_cmd_svskill);
+ pmodule_cmd_svsmode(ptlink_cmd_svsmode);
+ pmodule_cmd_372(ptlink_cmd_372);
+ pmodule_cmd_372_error(ptlink_cmd_372_error);
+ pmodule_cmd_375(ptlink_cmd_375);
+ pmodule_cmd_376(ptlink_cmd_376);
+ pmodule_cmd_nick(ptlink_cmd_nick);
+ pmodule_cmd_guest_nick(ptlink_cmd_guest_nick);
+ pmodule_cmd_mode(ptlink_cmd_mode);
+ pmodule_cmd_bot_nick(ptlink_cmd_bot_nick);
+ pmodule_cmd_kick(ptlink_cmd_kick);
+ pmodule_cmd_notice_ops(ptlink_cmd_notice_ops);
+ pmodule_cmd_notice(ptlink_cmd_notice);
+ pmodule_cmd_notice2(ptlink_cmd_notice2);
+ pmodule_cmd_privmsg(ptlink_cmd_privmsg);
+ pmodule_cmd_privmsg2(ptlink_cmd_privmsg2);
+ pmodule_cmd_serv_notice(ptlink_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(ptlink_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(ptlink_cmd_bot_chan_mode);
+ pmodule_cmd_351(ptlink_cmd_351);
+ pmodule_cmd_quit(ptlink_cmd_quit);
+ pmodule_cmd_pong(ptlink_cmd_pong);
+ pmodule_cmd_join(ptlink_cmd_join);
+ pmodule_cmd_unsqline(ptlink_cmd_unsqline);
+ pmodule_cmd_invite(ptlink_cmd_invite);
+ pmodule_cmd_part(ptlink_cmd_part);
+ pmodule_cmd_391(ptlink_cmd_391);
+ pmodule_cmd_250(ptlink_cmd_250);
+ pmodule_cmd_307(ptlink_cmd_307);
+ pmodule_cmd_311(ptlink_cmd_311);
+ pmodule_cmd_312(ptlink_cmd_312);
+ pmodule_cmd_317(ptlink_cmd_317);
+ pmodule_cmd_219(ptlink_cmd_219);
+ pmodule_cmd_401(ptlink_cmd_401);
+ pmodule_cmd_318(ptlink_cmd_318);
+ pmodule_cmd_242(ptlink_cmd_242);
+ pmodule_cmd_243(ptlink_cmd_243);
+ pmodule_cmd_211(ptlink_cmd_211);
+ pmodule_cmd_global(ptlink_cmd_global);
+ pmodule_cmd_global_legacy(ptlink_cmd_global_legacy);
+ pmodule_cmd_sqline(ptlink_cmd_sqline);
+ pmodule_cmd_squit(ptlink_cmd_squit);
+ pmodule_cmd_svso(ptlink_cmd_svso);
+ pmodule_cmd_chg_nick(ptlink_cmd_chg_nick);
+ pmodule_cmd_svsnick(ptlink_cmd_svsnick);
+ pmodule_cmd_vhost_on(ptlink_cmd_vhost_on);
+ pmodule_cmd_connect(ptlink_cmd_connect);
+ pmodule_cmd_svshold(ptlink_cmd_svshold);
+ pmodule_cmd_release_svshold(ptlink_cmd_release_svshold);
+ pmodule_cmd_unsgline(ptlink_cmd_unsqline);
+ pmodule_cmd_unszline(ptlink_cmd_unszline);
+ pmodule_cmd_szline(ptlink_cmd_szline);
+ pmodule_cmd_sgline(ptlink_cmd_sgline);
+ pmodule_cmd_unban(ptlink_cmd_unban);
+ pmodule_cmd_svsmode_chan(ptlink_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(ptlink_cmd_svid_umode);
+ pmodule_cmd_nc_change(ptlink_cmd_nc_change);
+ pmodule_cmd_svid_umode2(ptlink_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(ptlink_cmd_svid_umode3);
+ pmodule_cmd_eob(ptlink_cmd_eob);
+ pmodule_flood_mode_check(ptlink_flood_mode_check);
+ pmodule_cmd_jupe(ptlink_cmd_jupe);
+ pmodule_valid_nick(ptlink_valid_nick);
+ pmodule_cmd_ctcp(ptlink_cmd_ctcp);
+ pmodule_set_umode(ptlink_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+
+ pmodule_ircd_version("PTlink 6.15.*+");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("+f");
+ pmodule_ircd_flood_mode_char_remove("-f");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/ptlink.h b/src/protocol/ptlink.h
new file mode 100644
index 000000000..2ec8f1181
--- /dev/null
+++ b/src/protocol/ptlink.h
@@ -0,0 +1,149 @@
+/* PTLink IRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#define UMODE_a 0x00000001
+#define UMODE_h 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_r 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_A 0x00000040
+#define UMODE_B 0x00000080
+#define UMODE_H 0x00000100
+#define UMODE_N 0x00000200
+#define UMODE_O 0x00000400
+#define UMODE_p 0x00000800
+#define UMODE_R 0x00001000
+#define UMODE_s 0x00002000
+#define UMODE_S 0x00004000
+#define UMODE_T 0x00008000
+#define UMODE_v 0x00001000
+#define UMODE_y 0x00002000
+#define UMODE_z 0x00004000
+
+
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_A 0x00000400
+#define CMODE_B 0x00000800
+#define CMODE_c 0x00001000
+#define CMODE_d 0x00002000
+#define CMODE_f 0x00004000
+#define CMODE_K 0x00008000
+#define CMODE_O 0x00010000
+#define CMODE_q 0x00020000
+#define CMODE_S 0x00040000
+#define CMODE_N 0x00080000
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+#define CMODE_C 0x00100000
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+/*
+ The following variables are set to define the TS protocol version
+ that we support.
+
+ PTLink 6.14 to 6.17 TS CURRENT is 6 and MIN is 3
+ PTlink 6.18 TS CURRENT is 9 and MIN is 3
+ PTLink 6.19 TS CURRENT is 10 and MIN is 9
+
+ If you are running 6.18 or 6.19 do not touch these values as they will
+ allow you to connect
+
+ If you are running an older version of PTLink, first think about updating
+ your ircd, or changing the TS_CURRENT to 6 to allow services to connect
+*/
+
+#define PTLINK_TS_CURRENT 9
+#define PTLINK_TS_MIN 3
+
+void ptlink_set_umode(User * user, int ac, char **av);
+void ptlink_cmd_svsnoop(char *server, int set);
+void ptlink_cmd_remove_akill(char *user, char *host);
+void ptlink_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void ptlink_cmd_vhost_off(User * u);
+void ptlink_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void ptlink_cmd_svskill(char *source, char *user, char *buf);
+void ptlink_cmd_svsmode(User * u, int ac, char **av);
+void ptlink_cmd_372(char *source, char *msg);
+void ptlink_cmd_372_error(char *source);
+void ptlink_cmd_375(char *source);
+void ptlink_cmd_376(char *source);
+void ptlink_cmd_nick(char *nick, char *name, char *modes);
+void ptlink_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void ptlink_cmd_mode(char *source, char *dest, char *buf);
+void ptlink_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void ptlink_cmd_kick(char *source, char *chan, char *user, char *buf);
+void ptlink_cmd_notice_ops(char *source, char *dest, char *buf);
+void ptlink_cmd_notice(char *source, char *dest, char *buf);
+void ptlink_cmd_notice2(char *source, char *dest, char *msg);
+void ptlink_cmd_privmsg(char *source, char *dest, char *buf);
+void ptlink_cmd_privmsg2(char *source, char *dest, char *msg);
+void ptlink_cmd_serv_notice(char *source, char *dest, char *msg);
+void ptlink_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void ptlink_cmd_bot_chan_mode(char *nick, char *chan);
+void ptlink_cmd_351(char *source);
+void ptlink_cmd_quit(char *source, char *buf);
+void ptlink_cmd_pong(char *servname, char *who);
+void ptlink_cmd_join(char *user, char *channel, time_t chantime);
+void ptlink_cmd_unsqline(char *user);
+void ptlink_cmd_invite(char *source, char *chan, char *nick);
+void ptlink_cmd_part(char *nick, char *chan, char *buf);
+void ptlink_cmd_391(char *source, char *timestr);
+void ptlink_cmd_250(char *buf);
+void ptlink_cmd_307(char *buf);
+void ptlink_cmd_311(char *buf);
+void ptlink_cmd_312(char *buf);
+void ptlink_cmd_317(char *buf);
+void ptlink_cmd_219(char *source, char *letter);
+void ptlink_cmd_401(char *source, char *who);
+void ptlink_cmd_318(char *source, char *who);
+void ptlink_cmd_242(char *buf);
+void ptlink_cmd_243(char *buf);
+void ptlink_cmd_211(char *buf);
+void ptlink_cmd_global(char *source, char *buf);
+void ptlink_cmd_global_legacy(char *source, char *fmt);
+void ptlink_cmd_sqline(char *mask, char *reason);
+void ptlink_cmd_squit(char *servname, char *message);
+void ptlink_cmd_svso(char *source, char *nick, char *flag);
+void ptlink_cmd_chg_nick(char *oldnick, char *newnick);
+void ptlink_cmd_svsnick(char *source, char *guest, time_t when);
+void ptlink_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void ptlink_cmd_connect(int servernum);
+void ptlink_cmd_svshold(char *nick);
+void ptlink_cmd_release_svshold(char *nick);
+void ptlink_cmd_unsgline(char *mask);
+void ptlink_cmd_unszline(char *mask);
+void ptlink_cmd_szline(char *mask, char *reason, char *whom);
+void ptlink_cmd_sgline(char *mask, char *reason);
+void ptlink_cmd_unban(char *name, char *nick);
+void ptlink_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void ptlink_cmd_svid_umode(char *nick, time_t ts);
+void ptlink_cmd_nc_change(User * u);
+void ptlink_cmd_svid_umode2(User * u, char *ts);
+void ptlink_cmd_svid_umode3(User * u, char *ts);
+void ptlink_cmd_eob();
+int ptlink_flood_mode_check(char *value);
+void ptlink_cmd_jupe(char *jserver, char *who, char *reason);
+int ptlink_valid_nick(char *nick);
+void ptlink_cmd_ctcp(char *source, char *dest, char *buf);
+
+
diff --git a/src/rageircd.c b/src/protocol/rageircd.c
index b357a408c..399d165b7 100644
--- a/src/rageircd.c
+++ b/src/protocol/rageircd.c
@@ -13,18 +13,9 @@
#include "services.h"
#include "pseudo.h"
+#include "rageircd.h"
-#ifdef IRC_RAGE2
-
-const char version_protocol[] = "RageIRCd 2.0.x";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = ""; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = ""; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 1; /* Rage beta 6 does not send TSMODE but uses it so we do this to enable it */
-
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"RageIRCd 2.0.*", /* ircd name */
"+d", /* nickserv mode */
"+d", /* chanserv mode */
@@ -85,7 +76,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
- CHAN_HELP_ULTIMATE3, /* ChanServ extra */
CMODE_p, /* No Knock */
CMODE_A, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -112,11 +102,12 @@ IRCDVar ircd[] = {
0, /* p10 */
NULL, /* character set */
1, /* reports sync state */
- },
+ }
+ ,
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
CAPAB_TSMODE, /* TSMODE */
@@ -201,7 +192,7 @@ unsigned long umodes[128] = {
0, 0 /* ~ ‚ */
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -223,7 +214,7 @@ char csmodes[128] = {
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
@@ -273,7 +264,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -339,7 +330,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
@@ -359,7 +350,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -407,7 +398,7 @@ CUMode cumodes[128] = {
-void anope_cmd_bot_unban(ChannelInfo * ci, char *nick)
+void rageircd_cmd_bot_unban(ChannelInfo * ci, char *nick)
{
send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick);
}
@@ -600,7 +591,7 @@ int anope_event_burst(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_sqline(char *mask, char *reason)
+void rageircd_cmd_sqline(char *mask, char *reason)
{
if (!mask || !reason) {
return;
@@ -609,56 +600,46 @@ void anope_cmd_sqline(char *mask, char *reason)
send_cmd(NULL, "SQLINE %s :%s", mask, reason);
}
-void anope_cmd_unsgline(char *mask)
+void rageircd_cmd_unsgline(char *mask)
{
send_cmd(NULL, "UNSGLINE 0 :%s", mask);
}
-void anope_cmd_unszline(char *mask)
+void rageircd_cmd_unszline(char *mask)
{
send_cmd(NULL, "UNSZLINE 0 %s", mask);
}
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void rageircd_cmd_szline(char *mask, char *reason, char *whom)
{
send_cmd(NULL, "SZLINE %s :%s", mask, reason);
}
-void anope_cmd_svsnoop(char *server, int set)
+void rageircd_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void rageircd_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ rageircd_cmd_svsnoop(server, set);
}
-void anope_cmd_sgline(char *mask, char *reason)
+void rageircd_cmd_sgline(char *mask, char *reason)
{
send_cmd(NULL, "SGLINE %d :%s:%s", strlen(mask), mask, reason);
}
-void anope_cmd_remove_akill(char *user, char *host)
+void rageircd_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "RAKILL %s %s", host, user);
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void rageircd_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!nick || !chan) {
return;
}
@@ -670,26 +651,20 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void rageircd_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
-void anope_cmd_vhost_off(User * u)
+void rageircd_cmd_vhost_off(User * u)
{
send_cmd(s_HostServ, "SVSMODE %s -x", u->nick);
notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
-{
- send_cmd(s_HostServ, "SVSMODE %s +x", nick);
- anope_cmd_chghost(nick, vhost);
-}
-
-void anope_cmd_chghost(char *nick, char *vhost)
+void rageircd_cmd_chghost(char *nick, char *vhost)
{
if (!nick || !vhost) {
return;
@@ -697,34 +672,31 @@ void anope_cmd_chghost(char *nick, char *vhost)
send_cmd(ServerName, "VHOST %s %s", nick, vhost);
}
-void anope_cmd_unsqline(char *user)
+void rageircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+{
+ send_cmd(s_HostServ, "SVSMODE %s +x", nick);
+ rageircd_cmd_chghost(nick, vhost);
+}
+
+void rageircd_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNSQLINE %s", user);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void rageircd_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
}
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void rageircd_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
(long int) time(NULL), reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void rageircd_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -736,25 +708,52 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
send_cmd(source, "SVSKILL %s :%s", user, buf);
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void rageircd_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
(long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
(ac == 2 ? av[1] : ""));
}
-void anope_cmd_squit(char *servname, char *message)
+void rageircd_cmd_squit(char *servname, char *message)
{
send_cmd(NULL, "SQUIT %s :%s", servname, message);
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void rageircd_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
-void anope_cmd_connect(int servernum)
+void rageircd_cmd_svinfo()
+{
+ send_cmd(NULL, "SVINFO 5 3 0 %ld bluemoon 0", (long int) time(NULL));
+}
+
+void rageircd_cmd_capab()
+{
+ /* CAPAB BURST UNCONNECT ZIP SSJ3 SN2 VHOST SUID TOK1 TSMODE */
+ send_cmd(NULL, "CAPAB BURST UNCONNECT SSJ3 SN2 VHOST TSMODE");
+}
+
+void rageircd_cmd_server(char *servname, int hop, char *descript)
+{
+ send_cmd(NULL, "SERVER %s %d :%s", servname, hop, ServerDesc);
+}
+
+/* PASS */
+void rageircd_cmd_pass(char *pass)
+{
+ send_cmd(NULL, "PASS %s :TS", pass);
+}
+
+void rageircd_cmd_burst()
+{
+ send_cmd(NULL, "BURST");
+}
+
+void rageircd_cmd_connect(int servernum)
{
if (Numeric) {
me_server =
@@ -765,37 +764,21 @@ void anope_cmd_connect(int servernum)
}
if (servernum == 1)
- anope_cmd_pass(RemotePassword);
+ rageircd_cmd_pass(RemotePassword);
else if (servernum == 2)
- anope_cmd_pass(RemotePassword2);
+ rageircd_cmd_pass(RemotePassword2);
else if (servernum == 3)
- anope_cmd_pass(RemotePassword3);
- anope_cmd_capab();
+ rageircd_cmd_pass(RemotePassword3);
+ rageircd_cmd_capab();
if (Numeric) {
send_cmd(NULL, "MYID !%s", Numeric);
}
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
- anope_cmd_burst();
-}
-
-void anope_cmd_svinfo()
-{
- send_cmd(NULL, "SVINFO 5 3 0 %ld bluemoon 0", (long int) time(NULL));
-}
-
-void anope_cmd_capab()
-{
- /* CAPAB BURST UNCONNECT ZIP SSJ3 SN2 VHOST SUID TOK1 TSMODE */
- send_cmd(NULL, "CAPAB BURST UNCONNECT SSJ3 SN2 VHOST TSMODE");
-}
-
-void anope_cmd_server(char *servname, int hop, char *descript)
-{
- send_cmd(NULL, "SERVER %s %d :%s", servname, hop, ServerDesc);
+ rageircd_cmd_server(ServerName, 1, ServerDesc);
+ rageircd_cmd_svinfo();
+ rageircd_cmd_burst();
}
-void anope_set_umode(User * user, int ac, char **av)
+void rageircd_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -860,17 +843,8 @@ void anope_set_umode(User * user, int ac, char **av)
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void rageircd_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -878,17 +852,8 @@ void anope_cmd_global(char *source, const char *fmt, ...)
send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf);
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void rageircd_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -897,44 +862,26 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
}
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void rageircd_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ rageircd_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void rageircd_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void rageircd_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -942,17 +889,17 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void rageircd_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void rageircd_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void rageircd_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
@@ -974,28 +921,19 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ rageircd_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
-void anope_cmd_351(char *source)
+void rageircd_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
version_build);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void rageircd_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1012,19 +950,8 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void rageircd_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1032,30 +959,30 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_372(char *source, char *msg)
+void rageircd_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void rageircd_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void rageircd_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void rageircd_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void rageircd_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1065,7 +992,7 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void rageircd_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1074,17 +1001,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void rageircd_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1093,17 +1011,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void rageircd_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1112,17 +1021,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void rageircd_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1131,17 +1031,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void rageircd_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1150,17 +1041,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void rageircd_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1169,7 +1051,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void rageircd_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1184,7 +1066,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void rageircd_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1193,7 +1075,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void rageircd_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1203,17 +1085,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void rageircd_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1222,17 +1095,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void rageircd_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1241,17 +1105,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void rageircd_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1259,13 +1114,13 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_nick(char *nick, char *name, char *modes)
+void rageircd_cmd_nick(char *nick, char *name, char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick,
(long int) time(NULL), ServiceUser, ServiceHost, ServerName,
modes, name);
- anope_cmd_sqline(nick, "Reserved for services");
+ rageircd_cmd_sqline(nick, "Reserved for services");
}
/* EVENT : OS */
@@ -1314,18 +1169,8 @@ int anope_event_cs(char *source, int ac, char **av)
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void rageircd_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -1333,25 +1178,25 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void rageircd_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick,
(long int) time(NULL), user, host, ServerName, modes, real);
- anope_cmd_sqline(nick, "Reserved for services");
+ rageircd_cmd_sqline(nick, "Reserved for services");
}
/* SVSMODE -b */
-void anope_cmd_unban(char *name, char *nick)
+void rageircd_cmd_unban(char *name, char *nick)
{
- anope_cmd_svsmode_chan(name, "-b", nick);
+ rageircd_cmd_svsmode_chan(name, "-b", nick);
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void rageircd_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
if (nick) {
send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
@@ -1360,7 +1205,7 @@ void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
}
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void rageircd_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
}
@@ -1480,26 +1325,20 @@ int anope_event_motd(char *source, int ac, char **av)
return MOD_CONT;
}
-/* PASS */
-void anope_cmd_pass(char *pass)
-{
- send_cmd(NULL, "PASS %s :TS", pass);
-}
-
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void rageircd_cmd_svshold(char *nick)
{
send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout,
"Being held for registered user");
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void rageircd_cmd_release_svshold(char *nick)
{
send_cmd(ServerName, "SVSHOLD %s 0", nick);
}
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void rageircd_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1507,15 +1346,15 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void rageircd_cmd_guest_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
{
send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick,
(long int) time(NULL), user, host, ServerName, modes, real);
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void rageircd_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
@@ -1523,7 +1362,7 @@ void anope_cmd_svso(char *source, char *nick, char *flag)
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void rageircd_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick,
(unsigned long int) ts);
@@ -1531,18 +1370,18 @@ void anope_cmd_svid_umode(char *nick, time_t ts)
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void rageircd_cmd_nc_change(User * u)
{
common_svsmode(u, "+d", "1");
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void rageircd_cmd_svid_umode2(User * u, char *ts)
{
/* not used by bahamut ircds */
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void rageircd_cmd_svid_umode3(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -1552,7 +1391,7 @@ void anope_cmd_svid_umode3(User * u, char *ts)
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void rageircd_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1612,17 +1451,17 @@ int anope_event_sqline(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void rageircd_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Find no reference to it in the code and docs */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void rageircd_cmd_svspart(char *source, char *nick, char *chan)
{
/* Find no reference to it in the code and docs */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void rageircd_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
@@ -1647,35 +1486,30 @@ int anope_event_globops(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int rageircd_flood_mode_check(char *value)
{
return 0;
}
-void anope_cmd_burst()
-{
- send_cmd(NULL, "BURST");
-}
-
-void anope_cmd_eob()
+void rageircd_cmd_eob()
{
send_cmd(NULL, "BURST 0");
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void rageircd_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ rageircd_cmd_squit(jserver, rbuf);
+ rageircd_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void rageircd_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
}
@@ -1684,24 +1518,16 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int rageircd_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void rageircd_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1712,4 +1538,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(rageircd_cmd_svsnoop);
+ pmodule_cmd_remove_akill(rageircd_cmd_remove_akill);
+ pmodule_cmd_topic(rageircd_cmd_topic);
+ pmodule_cmd_vhost_off(rageircd_cmd_vhost_off);
+ pmodule_cmd_akill(rageircd_cmd_akill);
+ pmodule_cmd_svskill(rageircd_cmd_svskill);
+ pmodule_cmd_svsmode(rageircd_cmd_svsmode);
+ pmodule_cmd_372(rageircd_cmd_372);
+ pmodule_cmd_372_error(rageircd_cmd_372_error);
+ pmodule_cmd_375(rageircd_cmd_375);
+ pmodule_cmd_376(rageircd_cmd_376);
+ pmodule_cmd_nick(rageircd_cmd_nick);
+ pmodule_cmd_guest_nick(rageircd_cmd_guest_nick);
+ pmodule_cmd_mode(rageircd_cmd_mode);
+ pmodule_cmd_bot_nick(rageircd_cmd_bot_nick);
+ pmodule_cmd_kick(rageircd_cmd_kick);
+ pmodule_cmd_notice_ops(rageircd_cmd_notice_ops);
+ pmodule_cmd_notice(rageircd_cmd_notice);
+ pmodule_cmd_notice2(rageircd_cmd_notice2);
+ pmodule_cmd_privmsg(rageircd_cmd_privmsg);
+ pmodule_cmd_privmsg2(rageircd_cmd_privmsg2);
+ pmodule_cmd_serv_notice(rageircd_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(rageircd_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(rageircd_cmd_bot_chan_mode);
+ pmodule_cmd_351(rageircd_cmd_351);
+ pmodule_cmd_quit(rageircd_cmd_quit);
+ pmodule_cmd_pong(rageircd_cmd_pong);
+ pmodule_cmd_join(rageircd_cmd_join);
+ pmodule_cmd_unsqline(rageircd_cmd_unsqline);
+ pmodule_cmd_invite(rageircd_cmd_invite);
+ pmodule_cmd_part(rageircd_cmd_part);
+ pmodule_cmd_391(rageircd_cmd_391);
+ pmodule_cmd_250(rageircd_cmd_250);
+ pmodule_cmd_307(rageircd_cmd_307);
+ pmodule_cmd_311(rageircd_cmd_311);
+ pmodule_cmd_312(rageircd_cmd_312);
+ pmodule_cmd_317(rageircd_cmd_317);
+ pmodule_cmd_219(rageircd_cmd_219);
+ pmodule_cmd_401(rageircd_cmd_401);
+ pmodule_cmd_318(rageircd_cmd_318);
+ pmodule_cmd_242(rageircd_cmd_242);
+ pmodule_cmd_243(rageircd_cmd_243);
+ pmodule_cmd_211(rageircd_cmd_211);
+ pmodule_cmd_global(rageircd_cmd_global);
+ pmodule_cmd_global_legacy(rageircd_cmd_global_legacy);
+ pmodule_cmd_sqline(rageircd_cmd_sqline);
+ pmodule_cmd_squit(rageircd_cmd_squit);
+ pmodule_cmd_svso(rageircd_cmd_svso);
+ pmodule_cmd_chg_nick(rageircd_cmd_chg_nick);
+ pmodule_cmd_svsnick(rageircd_cmd_svsnick);
+ pmodule_cmd_vhost_on(rageircd_cmd_vhost_on);
+ pmodule_cmd_connect(rageircd_cmd_connect);
+ pmodule_cmd_svshold(rageircd_cmd_svshold);
+ pmodule_cmd_release_svshold(rageircd_cmd_release_svshold);
+ pmodule_cmd_unsgline(rageircd_cmd_unsqline);
+ pmodule_cmd_unszline(rageircd_cmd_unszline);
+ pmodule_cmd_szline(rageircd_cmd_szline);
+ pmodule_cmd_sgline(rageircd_cmd_sgline);
+ pmodule_cmd_unban(rageircd_cmd_unban);
+ pmodule_cmd_svsmode_chan(rageircd_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(rageircd_cmd_svid_umode);
+ pmodule_cmd_nc_change(rageircd_cmd_nc_change);
+ pmodule_cmd_svid_umode2(rageircd_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(rageircd_cmd_svid_umode3);
+ pmodule_cmd_eob(rageircd_cmd_eob);
+ pmodule_flood_mode_check(rageircd_flood_mode_check);
+ pmodule_cmd_jupe(rageircd_cmd_jupe);
+ pmodule_valid_nick(rageircd_valid_nick);
+ pmodule_cmd_ctcp(rageircd_cmd_ctcp);
+ pmodule_set_umode(rageircd_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("RageIRCd 2.0.x");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("");
+ pmodule_ircd_flood_mode_char_remove("");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(1);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/rageircd.h b/src/protocol/rageircd.h
new file mode 100644
index 000000000..4381950f2
--- /dev/null
+++ b/src/protocol/rageircd.h
@@ -0,0 +1,113 @@
+/* Rage IRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#define UMODE_a 0x00000001
+#define UMODE_h 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_r 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_A 0x00000040
+#define UMODE_R 0x80000000
+#define UMODE_x 0x40000000
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+#define CMODE_c 0x00000400 /* Colors can't be used */
+#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */
+#define CMODE_N 0x00001000
+#define CMODE_S 0x00002000
+#define CMODE_C 0x00004000
+#define CMODE_A 0x00008000
+#define CMODE_O 0x00010000 /* Only opers can join */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void rageircd_set_umode(User * user, int ac, char **av);
+void rageircd_cmd_svsnoop(char *server, int set);
+void rageircd_cmd_remove_akill(char *user, char *host);
+void rageircd_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void rageircd_cmd_vhost_off(User * u);
+void rageircd_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void rageircd_cmd_svskill(char *source, char *user, char *buf);
+void rageircd_cmd_svsmode(User * u, int ac, char **av);
+void rageircd_cmd_372(char *source, char *msg);
+void rageircd_cmd_372_error(char *source);
+void rageircd_cmd_375(char *source);
+void rageircd_cmd_376(char *source);
+void rageircd_cmd_nick(char *nick, char *name, char *modes);
+void rageircd_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void rageircd_cmd_mode(char *source, char *dest, char *buf);
+void rageircd_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void rageircd_cmd_kick(char *source, char *chan, char *user, char *buf);
+void rageircd_cmd_notice_ops(char *source, char *dest, char *buf);
+void rageircd_cmd_notice(char *source, char *dest, char *buf);
+void rageircd_cmd_notice2(char *source, char *dest, char *msg);
+void rageircd_cmd_privmsg(char *source, char *dest, char *buf);
+void rageircd_cmd_privmsg2(char *source, char *dest, char *msg);
+void rageircd_cmd_serv_notice(char *source, char *dest, char *msg);
+void rageircd_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void rageircd_cmd_bot_chan_mode(char *nick, char *chan);
+void rageircd_cmd_351(char *source);
+void rageircd_cmd_quit(char *source, char *buf);
+void rageircd_cmd_pong(char *servname, char *who);
+void rageircd_cmd_join(char *user, char *channel, time_t chantime);
+void rageircd_cmd_unsqline(char *user);
+void rageircd_cmd_invite(char *source, char *chan, char *nick);
+void rageircd_cmd_part(char *nick, char *chan, char *buf);
+void rageircd_cmd_391(char *source, char *timestr);
+void rageircd_cmd_250(char *buf);
+void rageircd_cmd_307(char *buf);
+void rageircd_cmd_311(char *buf);
+void rageircd_cmd_312(char *buf);
+void rageircd_cmd_317(char *buf);
+void rageircd_cmd_219(char *source, char *letter);
+void rageircd_cmd_401(char *source, char *who);
+void rageircd_cmd_318(char *source, char *who);
+void rageircd_cmd_242(char *buf);
+void rageircd_cmd_243(char *buf);
+void rageircd_cmd_211(char *buf);
+void rageircd_cmd_global(char *source, char *buf);
+void rageircd_cmd_global_legacy(char *source, char *fmt);
+void rageircd_cmd_sqline(char *mask, char *reason);
+void rageircd_cmd_squit(char *servname, char *message);
+void rageircd_cmd_svso(char *source, char *nick, char *flag);
+void rageircd_cmd_chg_nick(char *oldnick, char *newnick);
+void rageircd_cmd_svsnick(char *source, char *guest, time_t when);
+void rageircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void rageircd_cmd_connect(int servernum);
+void rageircd_cmd_svshold(char *nick);
+void rageircd_cmd_release_svshold(char *nick);
+void rageircd_cmd_unsgline(char *mask);
+void rageircd_cmd_unszline(char *mask);
+void rageircd_cmd_szline(char *mask, char *reason, char *whom);
+void rageircd_cmd_sgline(char *mask, char *reason);
+void rageircd_cmd_unban(char *name, char *nick);
+void rageircd_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void rageircd_cmd_svid_umode(char *nick, time_t ts);
+void rageircd_cmd_nc_change(User * u);
+void rageircd_cmd_svid_umode2(User * u, char *ts);
+void rageircd_cmd_svid_umode3(User * u, char *ts);
+void rageircd_cmd_eob();
+int rageircd_flood_mode_check(char *value);
+void rageircd_cmd_jupe(char *jserver, char *who, char *reason);
+int rageircd_valid_nick(char *nick);
+void rageircd_cmd_ctcp(char *source, char *dest, char *buf);
diff --git a/src/ratbox.c b/src/protocol/ratbox.c
index f2b329e4a..8059ae1fe 100644
--- a/src/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -13,19 +13,11 @@
#include "services.h"
#include "pseudo.h"
-
-#ifdef IRC_RATBOX
-
-const char version_protocol[] = "Ratbox IRCD 2.0+";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = ""; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = ""; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0;
+#include "ratbox.h"
int ts6nickcount = 0;
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"Ratbox 2.0+", /* ircd name */
"+oi", /* nickserv mode */
"+oi", /* chanserv mode */
@@ -86,7 +78,6 @@ IRCDVar ircd[] = {
0, /* O:LINE */
0, /* VHOST ON NICK */
0, /* Change RealName */
- 0, /* ChanServ extra */
CMODE_p, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -118,7 +109,7 @@ IRCDVar ircd[] = {
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
0, /* NOQUIT */
0, /* TSMODE */
@@ -151,7 +142,7 @@ IRCDCAPAB ircdcap[] = {
0, 0, 0}
};
-void anope_set_umode(User * user, int ac, char **av)
+void ratbox_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -244,7 +235,7 @@ unsigned long umodes[128] = {
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -265,7 +256,7 @@ char csmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
@@ -315,7 +306,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -381,7 +372,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
{'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
@@ -394,7 +385,7 @@ CBModeInfo cbmodeinfos[] = {
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -443,26 +434,17 @@ CUMode cumodes[128] = {
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void ratbox_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
User *u;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ ratbox_cmd_privmsg2(source, dest, buf);
} else {
ud = find_uid(source);
u = finduser(dest);
@@ -472,7 +454,7 @@ void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void ratbox_cmd_notice2(char *source, char *dest, char *msg)
{
Uid *ud;
User *u;
@@ -483,19 +465,10 @@ void anope_cmd_notice2(char *source, char *dest, char *msg)
(UseTS6 ? (u ? u->uid : dest) : dest), msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void ratbox_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud, *ud2;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -506,7 +479,7 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
(UseTS6 ? (ud2 ? ud2->uid : dest) : dest), buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void ratbox_cmd_privmsg2(char *source, char *dest, char *msg)
{
Uid *ud, *ud2;
@@ -517,29 +490,21 @@ void anope_cmd_privmsg2(char *source, char *dest, char *msg)
(UseTS6 ? (ud2 ? ud2->uid : dest) : dest), msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void ratbox_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $$%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void ratbox_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $$%s :%s", dest, msg);
}
-void anope_cmd_global(char *source, const char *fmt, ...)
+void ratbox_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *u;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -557,7 +522,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void ratbox_cmd_global_legacy(char *source, char *fmt)
{
Uid *u;
@@ -782,42 +747,42 @@ void moduleAddIRCDMsgs(void)
/* *INDENT-ON* */
-void anope_cmd_sqline(char *mask, char *reason)
+void ratbox_cmd_sqline(char *mask, char *reason)
{
send_cmd(NULL, "RESV * %s :%s", mask, reason);
}
-void anope_cmd_unsgline(char *mask)
+void ratbox_cmd_unsgline(char *mask)
{
/* Does not support */
}
-void anope_cmd_unszline(char *mask)
+void ratbox_cmd_unszline(char *mask)
{
/* Does not support */
}
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void ratbox_cmd_szline(char *mask, char *reason, char *whom)
{
/* Does not support */
}
-void anope_cmd_svsnoop(char *server, int set)
+void ratbox_cmd_svsnoop(char *server, int set)
{
/* does not support */
}
-void anope_cmd_svsadmin(char *server, int set)
+void ratbox_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ ratbox_cmd_svsnoop(server, set);
}
-void anope_cmd_sgline(char *mask, char *reason)
+void ratbox_cmd_sgline(char *mask, char *reason)
{
/* does not support */
}
-void anope_cmd_remove_akill(char *user, char *host)
+void ratbox_cmd_remove_akill(char *user, char *host)
{
Uid *ud;
@@ -826,8 +791,8 @@ void anope_cmd_remove_akill(char *user, char *host)
"UNKLINE * %s %s", user, host);
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void ratbox_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
Uid *ud;
@@ -836,22 +801,22 @@ void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
chan, topic);
}
-void anope_cmd_vhost_off(User * u)
+void ratbox_cmd_vhost_off(User * u)
{
/* not supported */
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void ratbox_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
/* not supported */
}
-void anope_cmd_unsqline(char *user)
+void ratbox_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNRESV * %s", user);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void ratbox_cmd_join(char *user, char *channel, time_t chantime)
{
Uid *ud;
@@ -869,8 +834,8 @@ host: the 'host' portion of the kline
reason: the reason for the kline.
*/
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void ratbox_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
Uid *ud;
@@ -881,19 +846,10 @@ void anope_cmd_akill(char *user, char *host, char *who, time_t when,
(long int) (expires - (long) time(NULL)), user, host, reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void ratbox_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud, *ud2;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -908,39 +864,12 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
(UseTS6 ? (ud2 ? ud2->uid : user) : user), buf);
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void ratbox_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd((UseTS6 ? TS6SID : ServerName), "SVSMODE %s %s", u->nick,
av[0]);
}
-void anope_cmd_connect(int servernum)
-{
- /* Make myself known to myself in the serverlist */
- if (UseTS6) {
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, TS6SID);
- } else {
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
- }
- if (servernum == 1)
- anope_cmd_pass(RemotePassword);
- else if (servernum == 2)
- anope_cmd_pass(RemotePassword2);
- else if (servernum == 3)
- anope_cmd_pass(RemotePassword3);
-
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
-}
-
-void anope_cmd_svsinfo()
-{
- /* not used */
-}
-
/*
* SVINFO
* parv[0] = sender prefix
@@ -949,11 +878,16 @@ void anope_cmd_svsinfo()
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
-void anope_cmd_svinfo()
+void ratbox_cmd_svinfo()
{
send_cmd(NULL, "SVINFO 6 3 0 :%ld", (long int) time(NULL));
}
+void ratbox_cmd_svsinfo()
+{
+
+}
+
/* CAPAB */
/*
QS - Can handle quit storm removal
@@ -973,14 +907,14 @@ void anope_cmd_svinfo()
PARA - supports invite broadcasting for +p
ENCAP - ?
*/
-void anope_cmd_capab()
+void ratbox_cmd_capab()
{
send_cmd(NULL,
"CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP");
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void ratbox_cmd_pass(char *pass)
{
if (UseTS6) {
send_cmd(NULL, "PASS %s TS 6 :%s", pass, TS6SID);
@@ -990,13 +924,35 @@ void anope_cmd_pass(char *pass)
}
/* SERVER name hop descript */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void ratbox_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void ratbox_cmd_connect(int servernum)
+{
+ /* Make myself known to myself in the serverlist */
+ if (UseTS6) {
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, TS6SID);
+ } else {
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+ }
+ if (servernum == 1)
+ ratbox_cmd_pass(RemotePassword);
+ else if (servernum == 2)
+ ratbox_cmd_pass(RemotePassword2);
+ else if (servernum == 3)
+ ratbox_cmd_pass(RemotePassword3);
+
+ ratbox_cmd_capab();
+ ratbox_cmd_server(ServerName, 1, ServerDesc);
+ ratbox_cmd_svinfo();
+}
+
+void ratbox_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
char nicknumbuf[10];
EnforceQlinedNick(nick, NULL);
@@ -1013,23 +969,13 @@ void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
(long int) time(NULL), modes, user, host, ServerName,
real);
}
- anope_cmd_sqline(nick, "Reserved for services");
+ ratbox_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void ratbox_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
ud = find_uid(nick);
if (buf) {
@@ -1043,7 +989,7 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ ratbox_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
@@ -1080,7 +1026,7 @@ int anope_event_kick(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_eob()
+void ratbox_cmd_eob()
{
/* doesn't support EOB */
}
@@ -1197,32 +1143,32 @@ int anope_event_quit(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_372(char *source, char *msg)
+void ratbox_cmd_372(char *source, char *msg)
{
send_cmd((UseTS6 ? TS6SID : ServerName), "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void ratbox_cmd_372_error(char *source)
{
send_cmd((UseTS6 ? TS6SID : ServerName),
"422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void ratbox_cmd_375(char *source)
{
send_cmd((UseTS6 ? TS6SID : ServerName),
"375 %s :- %s Message of the Day", source, ServerName);
}
-void anope_cmd_376(char *source)
+void ratbox_cmd_376(char *source)
{
send_cmd((UseTS6 ? TS6SID : ServerName),
"376 %s :End of /MOTD command.", source);
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void ratbox_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1231,17 +1177,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void ratbox_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1250,17 +1187,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void ratbox_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1269,17 +1197,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void ratbox_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1288,17 +1207,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void ratbox_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1307,17 +1217,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void ratbox_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1326,7 +1227,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void ratbox_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1341,7 +1242,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void ratbox_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1351,7 +1252,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void ratbox_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1362,17 +1263,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void ratbox_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1381,17 +1273,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void ratbox_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1400,17 +1283,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void ratbox_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1418,18 +1292,9 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void ratbox_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1443,7 +1308,7 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
}
}
-void anope_cmd_tmode(char *source, char *dest, const char *fmt, ...)
+void ratbox_cmd_tmode(char *source, char *dest, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE];
@@ -1461,7 +1326,7 @@ void anope_cmd_tmode(char *source, char *dest, const char *fmt, ...)
send_cmd(NULL, "MODE %s %s", dest, buf);
}
-void anope_cmd_nick(char *nick, char *name, char *mode)
+void ratbox_cmd_nick(char *nick, char *name, char *mode)
{
char nicknumbuf[10];
EnforceQlinedNick(nick, NULL);
@@ -1478,24 +1343,13 @@ void anope_cmd_nick(char *nick, char *name, char *mode)
(long int) time(NULL), mode, ServiceUser, ServiceHost,
ServerName, name);
}
- anope_cmd_sqline(nick, "Reserved for services");
+ ratbox_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void ratbox_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
User *u;
- *buf = '\0';
-
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
ud = find_uid(source);
u = finduser(user);
@@ -1510,17 +1364,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void ratbox_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1528,34 +1373,23 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void ratbox_cmd_bot_chan_mode(char *nick, char *chan)
{
Uid *u;
if (UseTS6) {
u = find_uid(nick);
- anope_cmd_tmode(nick, chan, "%s %s", ircd->botchanumode,
- (u ? u->uid : nick));
+ ratbox_cmd_tmode(nick, chan, "%s %s", ircd->botchanumode,
+ (u ? u->uid : nick));
} else {
anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
}
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void ratbox_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
-
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
ud = find_uid(source);
if (buf) {
@@ -1567,7 +1401,7 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void ratbox_cmd_pong(char *servname, char *who)
{
if (UseTS6) {
send_cmd(TS6SID, "PONG %s", who);
@@ -1577,7 +1411,7 @@ void anope_cmd_pong(char *servname, char *who)
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void ratbox_cmd_invite(char *source, char *chan, char *nick)
{
Uid *ud;
User *u;
@@ -1594,7 +1428,7 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* SQUIT */
-void anope_cmd_squit(char *servname, char *message)
+void ratbox_cmd_squit(char *servname, char *message)
{
if (!servname || !message) {
return;
@@ -1634,7 +1468,7 @@ int anope_event_tmode(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_351(char *source)
+void ratbox_cmd_351(char *source)
{
send_cmd((UseTS6 ? TS6SID : ServerName),
"351 %s Anope-%s %s :%s - %s -- %s", source, version_number,
@@ -1649,73 +1483,73 @@ int anope_event_capab(char *source, int ac, char **av)
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void ratbox_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void ratbox_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSNICK */
-void anope_cmd_svsnick(char *nick, char *newnick, time_t when)
+void ratbox_cmd_svsnick(char *nick, char *newnick, time_t when)
{
/* not supported */
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void ratbox_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
/* not supported */
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void ratbox_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_unban(char *name, char *nick)
+void ratbox_cmd_unban(char *name, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void ratbox_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void ratbox_cmd_svid_umode(char *nick, time_t ts)
{
/* not supported */
}
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void ratbox_cmd_nc_change(User * u)
{
/* not supported */
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void ratbox_cmd_svid_umode2(User * u, char *ts)
{
/* not supported */
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void ratbox_cmd_svid_umode3(User * u, char *ts)
{
/* not used */
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void ratbox_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1746,17 +1580,17 @@ int anope_event_pass(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void ratbox_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void ratbox_cmd_svspart(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void ratbox_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
@@ -1806,7 +1640,7 @@ int anope_event_bmask(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int ratbox_flood_mode_check(char *value)
{
return 0;
}
@@ -1821,15 +1655,15 @@ int anope_event_error(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void ratbox_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ ratbox_cmd_squit(jserver, rbuf);
+ ratbox_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
@@ -1837,24 +1671,16 @@ void anope_cmd_jupe(char *jserver, char *who, char *reason)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int ratbox_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void ratbox_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1865,4 +1691,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(ratbox_cmd_svsnoop);
+ pmodule_cmd_remove_akill(ratbox_cmd_remove_akill);
+ pmodule_cmd_topic(ratbox_cmd_topic);
+ pmodule_cmd_vhost_off(ratbox_cmd_vhost_off);
+ pmodule_cmd_akill(ratbox_cmd_akill);
+ pmodule_cmd_svskill(ratbox_cmd_svskill);
+ pmodule_cmd_svsmode(ratbox_cmd_svsmode);
+ pmodule_cmd_372(ratbox_cmd_372);
+ pmodule_cmd_372_error(ratbox_cmd_372_error);
+ pmodule_cmd_375(ratbox_cmd_375);
+ pmodule_cmd_376(ratbox_cmd_376);
+ pmodule_cmd_nick(ratbox_cmd_nick);
+ pmodule_cmd_guest_nick(ratbox_cmd_guest_nick);
+ pmodule_cmd_mode(ratbox_cmd_mode);
+ pmodule_cmd_bot_nick(ratbox_cmd_bot_nick);
+ pmodule_cmd_kick(ratbox_cmd_kick);
+ pmodule_cmd_notice_ops(ratbox_cmd_notice_ops);
+ pmodule_cmd_notice(ratbox_cmd_notice);
+ pmodule_cmd_notice2(ratbox_cmd_notice2);
+ pmodule_cmd_privmsg(ratbox_cmd_privmsg);
+ pmodule_cmd_privmsg2(ratbox_cmd_privmsg2);
+ pmodule_cmd_serv_notice(ratbox_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(ratbox_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(ratbox_cmd_bot_chan_mode);
+ pmodule_cmd_351(ratbox_cmd_351);
+ pmodule_cmd_quit(ratbox_cmd_quit);
+ pmodule_cmd_pong(ratbox_cmd_pong);
+ pmodule_cmd_join(ratbox_cmd_join);
+ pmodule_cmd_unsqline(ratbox_cmd_unsqline);
+ pmodule_cmd_invite(ratbox_cmd_invite);
+ pmodule_cmd_part(ratbox_cmd_part);
+ pmodule_cmd_391(ratbox_cmd_391);
+ pmodule_cmd_250(ratbox_cmd_250);
+ pmodule_cmd_307(ratbox_cmd_307);
+ pmodule_cmd_311(ratbox_cmd_311);
+ pmodule_cmd_312(ratbox_cmd_312);
+ pmodule_cmd_317(ratbox_cmd_317);
+ pmodule_cmd_219(ratbox_cmd_219);
+ pmodule_cmd_401(ratbox_cmd_401);
+ pmodule_cmd_318(ratbox_cmd_318);
+ pmodule_cmd_242(ratbox_cmd_242);
+ pmodule_cmd_243(ratbox_cmd_243);
+ pmodule_cmd_211(ratbox_cmd_211);
+ pmodule_cmd_global(ratbox_cmd_global);
+ pmodule_cmd_global_legacy(ratbox_cmd_global_legacy);
+ pmodule_cmd_sqline(ratbox_cmd_sqline);
+ pmodule_cmd_squit(ratbox_cmd_squit);
+ pmodule_cmd_svso(ratbox_cmd_svso);
+ pmodule_cmd_chg_nick(ratbox_cmd_chg_nick);
+ pmodule_cmd_svsnick(ratbox_cmd_svsnick);
+ pmodule_cmd_vhost_on(ratbox_cmd_vhost_on);
+ pmodule_cmd_connect(ratbox_cmd_connect);
+ pmodule_cmd_svshold(ratbox_cmd_svshold);
+ pmodule_cmd_release_svshold(ratbox_cmd_release_svshold);
+ pmodule_cmd_unsgline(ratbox_cmd_unsqline);
+ pmodule_cmd_unszline(ratbox_cmd_unszline);
+ pmodule_cmd_szline(ratbox_cmd_szline);
+ pmodule_cmd_sgline(ratbox_cmd_sgline);
+ pmodule_cmd_unban(ratbox_cmd_unban);
+ pmodule_cmd_svsmode_chan(ratbox_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(ratbox_cmd_svid_umode);
+ pmodule_cmd_nc_change(ratbox_cmd_nc_change);
+ pmodule_cmd_svid_umode2(ratbox_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(ratbox_cmd_svid_umode3);
+ pmodule_cmd_eob(ratbox_cmd_eob);
+ pmodule_flood_mode_check(ratbox_flood_mode_check);
+ pmodule_cmd_jupe(ratbox_cmd_jupe);
+ pmodule_valid_nick(ratbox_valid_nick);
+ pmodule_cmd_ctcp(ratbox_cmd_ctcp);
+ pmodule_set_umode(ratbox_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("Ratbox IRCD 2.0+");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("");
+ pmodule_ircd_flood_mode_char_remove("");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/ratbox.h b/src/protocol/ratbox.h
new file mode 100644
index 000000000..b99e4437e
--- /dev/null
+++ b/src/protocol/ratbox.h
@@ -0,0 +1,119 @@
+/* Ratbox IRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#define UMODE_a 0x00000001
+#define UMODE_C 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_z 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_s 0x00000040
+#define UMODE_c 0x00000080
+#define UMODE_r 0x00000100
+#define UMODE_k 0x00000200
+#define UMODE_f 0x00000400
+#define UMODE_y 0x00000800
+#define UMODE_d 0x00001000
+#define UMODE_n 0x00002000
+#define UMODE_x 0x00004000
+#define UMODE_u 0x00008000
+#define UMODE_b 0x00010000
+#define UMODE_l 0x00020000
+#define UMODE_g 0x00040000
+#define UMODE_Z 0x00080000
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040
+#define CMODE_l 0x00000080
+
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t
+
+
+void ratbox_set_umode(User * user, int ac, char **av);
+void ratbox_cmd_svsnoop(char *server, int set);
+void ratbox_cmd_remove_akill(char *user, char *host);
+void ratbox_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void ratbox_cmd_vhost_off(User * u);
+void ratbox_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void ratbox_cmd_svskill(char *source, char *user, char *buf);
+void ratbox_cmd_svsmode(User * u, int ac, char **av);
+void ratbox_cmd_372(char *source, char *msg);
+void ratbox_cmd_372_error(char *source);
+void ratbox_cmd_375(char *source);
+void ratbox_cmd_376(char *source);
+void ratbox_cmd_nick(char *nick, char *name, char *modes);
+void ratbox_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void ratbox_cmd_mode(char *source, char *dest, char *buf);
+void ratbox_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void ratbox_cmd_kick(char *source, char *chan, char *user, char *buf);
+void ratbox_cmd_notice_ops(char *source, char *dest, char *buf);
+void ratbox_cmd_notice(char *source, char *dest, char *buf);
+void ratbox_cmd_notice2(char *source, char *dest, char *msg);
+void ratbox_cmd_privmsg(char *source, char *dest, char *buf);
+void ratbox_cmd_privmsg2(char *source, char *dest, char *msg);
+void ratbox_cmd_serv_notice(char *source, char *dest, char *msg);
+void ratbox_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void ratbox_cmd_bot_chan_mode(char *nick, char *chan);
+void ratbox_cmd_351(char *source);
+void ratbox_cmd_quit(char *source, char *buf);
+void ratbox_cmd_pong(char *servname, char *who);
+void ratbox_cmd_join(char *user, char *channel, time_t chantime);
+void ratbox_cmd_unsqline(char *user);
+void ratbox_cmd_invite(char *source, char *chan, char *nick);
+void ratbox_cmd_part(char *nick, char *chan, char *buf);
+void ratbox_cmd_391(char *source, char *timestr);
+void ratbox_cmd_250(char *buf);
+void ratbox_cmd_307(char *buf);
+void ratbox_cmd_311(char *buf);
+void ratbox_cmd_312(char *buf);
+void ratbox_cmd_317(char *buf);
+void ratbox_cmd_219(char *source, char *letter);
+void ratbox_cmd_401(char *source, char *who);
+void ratbox_cmd_318(char *source, char *who);
+void ratbox_cmd_242(char *buf);
+void ratbox_cmd_243(char *buf);
+void ratbox_cmd_211(char *buf);
+void ratbox_cmd_global(char *source, char *buf);
+void ratbox_cmd_global_legacy(char *source, char *fmt);
+void ratbox_cmd_sqline(char *mask, char *reason);
+void ratbox_cmd_squit(char *servname, char *message);
+void ratbox_cmd_svso(char *source, char *nick, char *flag);
+void ratbox_cmd_chg_nick(char *oldnick, char *newnick);
+void ratbox_cmd_svsnick(char *source, char *guest, time_t when);
+void ratbox_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void ratbox_cmd_connect(int servernum);
+void ratbox_cmd_svshold(char *nick);
+void ratbox_cmd_release_svshold(char *nick);
+void ratbox_cmd_unsgline(char *mask);
+void ratbox_cmd_unszline(char *mask);
+void ratbox_cmd_szline(char *mask, char *reason, char *whom);
+void ratbox_cmd_sgline(char *mask, char *reason);
+void ratbox_cmd_unban(char *name, char *nick);
+void ratbox_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void ratbox_cmd_svid_umode(char *nick, time_t ts);
+void ratbox_cmd_nc_change(User * u);
+void ratbox_cmd_svid_umode2(User * u, char *ts);
+void ratbox_cmd_svid_umode3(User * u, char *ts);
+void ratbox_cmd_eob();
+int ratbox_flood_mode_check(char *value);
+void ratbox_cmd_jupe(char *jserver, char *who, char *reason);
+int ratbox_valid_nick(char *nick);
+void ratbox_cmd_ctcp(char *source, char *dest, char *buf);
+
+
diff --git a/src/shadowircd.c b/src/protocol/shadowircd.c
index c71381782..6471e1dbe 100644
--- a/src/shadowircd.c
+++ b/src/protocol/shadowircd.c
@@ -14,20 +14,12 @@
#include "services.h"
#include "pseudo.h"
-
-#ifdef IRC_SHADOWIRCD
-
-const char version_protocol[] = "ShadowIRCd 4.0+";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = ""; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = ""; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 1;
+#include "shadowircd.h"
/* 6 slot array, 35 possible combinations per slot, exponential. */
int ts6nickcount[6] = { 0, 0, 0, 0, 0, 0 };
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"ShadowIRCd 4.0+", /* ircd name */
"+oiqSK", /* nickserv mode */
"+oiqSK", /* chanserv mode */
@@ -88,7 +80,6 @@ IRCDVar ircd[] = {
0, /* O:LINE */
1, /* VHOST ON NICK */
1, /* Change RealName */
- 0, /* ChanServ extra */
CMODE_K, /* No Knock */
CMODE_A, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -121,7 +112,7 @@ IRCDVar ircd[] = {
};
/* ShadowIRCd does not use CAPAB */
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
0, /* NOQUIT */
0, /* TSMODE */
@@ -154,7 +145,7 @@ IRCDCAPAB ircdcap[] = {
0, 0, 0}
};
-void anope_set_umode(User * user, int ac, char **av)
+void shadowircd_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -247,7 +238,7 @@ unsigned long umodes[128] = {
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -268,7 +259,7 @@ char csmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
@@ -318,7 +309,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -384,7 +375,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
@@ -412,7 +403,7 @@ CBModeInfo cbmodeinfos[] = {
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -461,26 +452,17 @@ CUMode cumodes[128] = {
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void shadowircd_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
User *u;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ shadowircd_cmd_privmsg2(source, dest, buf);
} else {
ud = find_uid(source);
u = finduser(dest);
@@ -489,7 +471,7 @@ void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void shadowircd_cmd_notice2(char *source, char *dest, char *msg)
{
Uid *ud;
User *u;
@@ -500,19 +482,10 @@ void anope_cmd_notice2(char *source, char *dest, char *msg)
msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void shadowircd_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud, *ud2;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -523,7 +496,7 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
(ud2 ? ud2->uid : dest), buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void shadowircd_cmd_privmsg2(char *source, char *dest, char *msg)
{
Uid *ud, *ud2;
@@ -534,29 +507,21 @@ void anope_cmd_privmsg2(char *source, char *dest, char *msg)
(ud2 ? ud2->uid : dest), msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void shadowircd_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $$%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void shadowircd_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $$%s :%s", dest, msg);
}
-void anope_cmd_global(char *source, const char *fmt, ...)
+void shadowircd_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *u;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -574,7 +539,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void shadowircd_cmd_global_legacy(char *source, char *fmt)
{
Uid *u;
@@ -625,7 +590,7 @@ int anope_event_sjoin(char *source, int ac, char **av)
*/
int anope_event_nick(char *source, int ac, char **av)
{
- Server *s;
+ Server *s = NULL;
User *user, *u2;
if (ac == 10) {
@@ -637,6 +602,17 @@ int anope_event_nick(char *source, int ac, char **av)
if (user) {
anope_set_umode(user, 1, &av[3]);
}
+ } else if (ac == 8) {
+ /* Changed use of s->name to av[6], as s will be NULL
+ * if i can believe the above comments, this should be fine
+ * if anyone from shadowircd see's this, and its wrong, let
+ * me know? :)
+ */
+ user = do_nick(source, av[0], av[4], av[5], av[6], av[7],
+ strtoul(av[2], NULL, 10), 0, 0, NULL, NULL);
+ if (user) {
+ anope_set_umode(user, 1, &av[3]);
+ }
} else {
u2 = find_byuid(source);
do_nick((u2 ? u2->nick : source), av[0], NULL, NULL, NULL, NULL,
@@ -813,42 +789,42 @@ void moduleAddIRCDMsgs(void)
/* *INDENT-ON* */
-void anope_cmd_sqline(char *mask, char *reason)
+void shadowircd_cmd_sqline(char *mask, char *reason)
{
send_cmd(NULL, "RESV * %s :%s", mask, reason);
}
-void anope_cmd_unsgline(char *mask)
+void shadowircd_cmd_unsgline(char *mask)
{
/* Does not support */
}
-void anope_cmd_unszline(char *mask)
+void shadowircd_cmd_unszline(char *mask)
{
/* Does not support */
}
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void shadowircd_cmd_szline(char *mask, char *reason, char *whom)
{
/* Does not support */
}
-void anope_cmd_svsnoop(char *server, int set)
+void shadowircd_cmd_svsnoop(char *server, int set)
{
/* does not support */
}
-void anope_cmd_svsadmin(char *server, int set)
+void shadowircd_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ shadowircd_cmd_svsnoop(server, set);
}
-void anope_cmd_sgline(char *mask, char *reason)
+void shadowircd_cmd_sgline(char *mask, char *reason)
{
/* does not support */
}
-void anope_cmd_remove_akill(char *user, char *host)
+void shadowircd_cmd_remove_akill(char *user, char *host)
{
Uid *ud;
@@ -856,8 +832,8 @@ void anope_cmd_remove_akill(char *user, char *host)
send_cmd((ud ? ud->uid : s_OperServ), "UNKLINE * %s %s", user, host);
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void shadowircd_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
Uid *ud;
@@ -866,12 +842,12 @@ void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
whosetit, when, topic);
}
-void anope_cmd_vhost_off(User * u)
+void shadowircd_cmd_vhost_off(User * u)
{
send_cmd(NULL, "MODE %s -v", (u->uid ? u->uid : u->nick));
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void shadowircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
send_cmd(NULL, "SVSCLOAK %s %s", nick, vhost);
@@ -879,12 +855,12 @@ void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
send_cmd(NULL, "SVSIDENT %s %s", nick, vIdent);
}
-void anope_cmd_unsqline(char *user)
+void shadowircd_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNRESV * %s", user);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void shadowircd_cmd_join(char *user, char *channel, time_t chantime)
{
Uid *ud;
@@ -902,8 +878,8 @@ host: the 'host' portion of the kline
reason: the reason for the kline.
*/
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void shadowircd_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
Uid *ud;
@@ -913,19 +889,10 @@ void anope_cmd_akill(char *user, char *host, char *who, time_t when,
(long int) (expires - (long) time(NULL)), user, host, reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void shadowircd_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -938,28 +905,12 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
send_cmd(NULL, "SVSKILL %s :%s", (ud ? ud->uid : user), buf);
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void shadowircd_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(TS6SID, "MODE %s %s", u->uid, av[0]);
}
-void anope_cmd_connect(int servernum)
-{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, TS6SID);
- if (servernum == 1)
- anope_cmd_pass(RemotePassword);
- else if (servernum == 2)
- anope_cmd_pass(RemotePassword2);
- else if (servernum == 3)
- anope_cmd_pass(RemotePassword3);
-
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
-}
-
-void anope_cmd_svsinfo()
+void shadowircd_cmd_svsinfo()
{
/* not used */
}
@@ -972,31 +923,48 @@ void anope_cmd_svsinfo()
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
-void anope_cmd_svinfo()
+void shadowircd_cmd_svinfo()
{
send_cmd(NULL, "SVINFO 6 3 0 :%ld", (long int) time(NULL));
}
-void anope_cmd_capab()
+void shadowircd_cmd_capab()
{
/* ShadowIRCd does not use CAPAB */
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void shadowircd_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS %s TS 6 %s", pass, TS6SID);
}
/* SERVER name protocol hop descript */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void shadowircd_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d %d :%s", servname, hop, PROTOCOL_REVISION,
descript);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+
+void shadowircd_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, TS6SID);
+ if (servernum == 1)
+ shadowircd_cmd_pass(RemotePassword);
+ else if (servernum == 2)
+ shadowircd_cmd_pass(RemotePassword2);
+ else if (servernum == 3)
+ shadowircd_cmd_pass(RemotePassword3);
+
+ shadowircd_cmd_capab();
+ shadowircd_cmd_server(ServerName, 1, ServerDesc);
+ shadowircd_cmd_svinfo();
+}
+
+void shadowircd_cmd_bot_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
{
char nicknumbuf[10];
EnforceQlinedNick(nick, NULL);
@@ -1011,23 +979,13 @@ void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
ts6nickcount[1]++;
ts6nickcount[0] = 0; /* AAAABA */
}
- anope_cmd_sqline(nick, "Reserved for services");
+ shadowircd_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void shadowircd_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
ud = find_uid(nick);
if (buf) {
@@ -1041,7 +999,7 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ shadowircd_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
@@ -1076,7 +1034,7 @@ int anope_event_kick(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_eob()
+void shadowircd_cmd_eob()
{
send_cmd(TS6SID, "EOB");
}
@@ -1146,7 +1104,7 @@ int anope_event_whois(char *source, int ac, char **av)
/* EVENT: SERVER */
int anope_event_server(char *source, int ac, char **av)
{
- if (!stricmp(av[1], "1") && !stricmp(av[2], "1")) {
+ if (!stricmp(av[1], "1")) {
uplink = sstrdup(av[0]);
if (TS6UPLINK) {
do_server(source, av[0], av[1], av[2], TS6UPLINK);
@@ -1166,7 +1124,6 @@ int anope_event_sid(char *source, int ac, char **av)
/* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */
s = findserver_uid(servlist, source);
-
do_server(s->name, av[0], av[1], av[3], av[2]);
return MOD_CONT;
}
@@ -1208,31 +1165,31 @@ int anope_event_quit(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_372(char *source, char *msg)
+void shadowircd_cmd_372(char *source, char *msg)
{
send_cmd(TS6SID, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void shadowircd_cmd_372_error(char *source)
{
send_cmd(TS6SID,
"422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void shadowircd_cmd_375(char *source)
{
send_cmd(TS6SID,
"375 %s :- %s Message of the Day", source, ServerName);
}
-void anope_cmd_376(char *source)
+void shadowircd_cmd_376(char *source)
{
send_cmd(TS6SID, "376 %s :End of /MOTD command.", source);
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void shadowircd_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1241,17 +1198,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void shadowircd_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1260,17 +1208,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void shadowircd_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1279,17 +1218,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void shadowircd_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1298,17 +1228,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void shadowircd_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1317,17 +1238,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void shadowircd_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1336,7 +1248,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void shadowircd_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1351,7 +1263,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void shadowircd_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1360,7 +1272,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void shadowircd_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1370,17 +1282,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void shadowircd_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1389,17 +1292,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void shadowircd_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1408,17 +1302,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void shadowircd_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1426,18 +1311,9 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void shadowircd_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1450,17 +1326,9 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
}
}
-void anope_cmd_tmode(char *source, char *dest, const char *fmt, ...)
+void shadowircd_cmd_tmode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1468,7 +1336,7 @@ void anope_cmd_tmode(char *source, char *dest, const char *fmt, ...)
send_cmd(NULL, "MODE %s %s", dest, buf);
}
-void anope_cmd_nick(char *nick, char *name, char *mode)
+void shadowircd_cmd_nick(char *nick, char *name, char *mode)
{
char nicknumbuf[10];
EnforceQlinedNick(nick, NULL);
@@ -1478,24 +1346,13 @@ void anope_cmd_nick(char *nick, char *name, char *mode)
nicknumbuf, ServiceHost, name);
new_uid(nick, nicknumbuf);
ts6nickcount[0]++;
- anope_cmd_sqline(nick, "Reserved for services");
+ shadowircd_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void shadowircd_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
User *u;
- *buf = '\0';
-
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
ud = find_uid(source);
u = finduser(user);
@@ -1509,17 +1366,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void shadowircd_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1527,30 +1375,20 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void shadowircd_cmd_bot_chan_mode(char *nick, char *chan)
{
Uid *u;
u = find_uid(nick);
- anope_cmd_tmode(nick, chan, "%s %s", ircd->botchanumode,
- (u ? u->uid : nick));
+ anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode,
+ (u ? u->uid : nick));
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void shadowircd_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
Uid *ud;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
ud = find_uid(source);
if (buf) {
@@ -1561,13 +1399,13 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void shadowircd_cmd_pong(char *servname, char *who)
{
send_cmd(TS6SID, "PONG %s", who);
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void shadowircd_cmd_invite(char *source, char *chan, char *nick)
{
Uid *ud;
User *u;
@@ -1584,7 +1422,7 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* SQUIT */
-void anope_cmd_squit(char *servname, char *message)
+void shadowircd_cmd_squit(char *servname, char *message)
{
if (!servname || !message) {
return;
@@ -1620,7 +1458,7 @@ int anope_event_tmode(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_351(char *source)
+void shadowircd_cmd_351(char *source)
{
send_cmd(TS6SID,
"351 %s Anope-%s %s :%s (ShadowProtocol %d) - %s -- %s",
@@ -1636,19 +1474,19 @@ int anope_event_capab(char *source, int ac, char **av)
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void shadowircd_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void shadowircd_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSNICK */
-void anope_cmd_svsnick(char *nick, char *newnick, time_t when)
+void shadowircd_cmd_svsnick(char *nick, char *newnick, time_t when)
{
if (!nick || !newnick) {
return;
@@ -1656,56 +1494,56 @@ void anope_cmd_svsnick(char *nick, char *newnick, time_t when)
send_cmd(NULL, "SVSNICK %s %s %ld", nick, newnick, when);
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void shadowircd_cmd_guest_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
{
/* not supported */
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void shadowircd_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_unban(char *name, char *nick)
+void shadowircd_cmd_unban(char *name, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void shadowircd_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void shadowircd_cmd_svid_umode(char *nick, time_t ts)
{
/* not supported */
}
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void shadowircd_cmd_nc_change(User * u)
{
/* not supported */
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void shadowircd_cmd_svid_umode2(User * u, char *ts)
{
/* not supported */
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void shadowircd_cmd_svid_umode3(User * u, char *ts)
{
/* not used */
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void shadowircd_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1734,17 +1572,17 @@ int anope_event_pass(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void shadowircd_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void shadowircd_cmd_svspart(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void shadowircd_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
@@ -1794,7 +1632,7 @@ int anope_event_bmask(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int shadowircd_flood_mode_check(char *value)
{
return 0;
}
@@ -1809,15 +1647,15 @@ int anope_event_error(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void shadowircd_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ shadowircd_cmd_squit(jserver, rbuf);
+ shadowircd_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
@@ -1825,24 +1663,16 @@ void anope_cmd_jupe(char *jserver, char *who, char *reason)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int shadowircd_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void shadowircd_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1853,4 +1683,117 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(shadowircd_cmd_svsnoop);
+ pmodule_cmd_remove_akill(shadowircd_cmd_remove_akill);
+ pmodule_cmd_topic(shadowircd_cmd_topic);
+ pmodule_cmd_vhost_off(shadowircd_cmd_vhost_off);
+ pmodule_cmd_akill(shadowircd_cmd_akill);
+ pmodule_cmd_svskill(shadowircd_cmd_svskill);
+ pmodule_cmd_svsmode(shadowircd_cmd_svsmode);
+ pmodule_cmd_372(shadowircd_cmd_372);
+ pmodule_cmd_372_error(shadowircd_cmd_372_error);
+ pmodule_cmd_375(shadowircd_cmd_375);
+ pmodule_cmd_376(shadowircd_cmd_376);
+ pmodule_cmd_nick(shadowircd_cmd_nick);
+ pmodule_cmd_guest_nick(shadowircd_cmd_guest_nick);
+ pmodule_cmd_mode(shadowircd_cmd_mode);
+ pmodule_cmd_bot_nick(shadowircd_cmd_bot_nick);
+ pmodule_cmd_kick(shadowircd_cmd_kick);
+ pmodule_cmd_notice_ops(shadowircd_cmd_notice_ops);
+ pmodule_cmd_notice(shadowircd_cmd_notice);
+ pmodule_cmd_notice2(shadowircd_cmd_notice2);
+ pmodule_cmd_privmsg(shadowircd_cmd_privmsg);
+ pmodule_cmd_privmsg2(shadowircd_cmd_privmsg2);
+ pmodule_cmd_serv_notice(shadowircd_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(shadowircd_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(shadowircd_cmd_bot_chan_mode);
+ pmodule_cmd_351(shadowircd_cmd_351);
+ pmodule_cmd_quit(shadowircd_cmd_quit);
+ pmodule_cmd_pong(shadowircd_cmd_pong);
+ pmodule_cmd_join(shadowircd_cmd_join);
+ pmodule_cmd_unsqline(shadowircd_cmd_unsqline);
+ pmodule_cmd_invite(shadowircd_cmd_invite);
+ pmodule_cmd_part(shadowircd_cmd_part);
+ pmodule_cmd_391(shadowircd_cmd_391);
+ pmodule_cmd_250(shadowircd_cmd_250);
+ pmodule_cmd_307(shadowircd_cmd_307);
+ pmodule_cmd_311(shadowircd_cmd_311);
+ pmodule_cmd_312(shadowircd_cmd_312);
+ pmodule_cmd_317(shadowircd_cmd_317);
+ pmodule_cmd_219(shadowircd_cmd_219);
+ pmodule_cmd_401(shadowircd_cmd_401);
+ pmodule_cmd_318(shadowircd_cmd_318);
+ pmodule_cmd_242(shadowircd_cmd_242);
+ pmodule_cmd_243(shadowircd_cmd_243);
+ pmodule_cmd_211(shadowircd_cmd_211);
+ pmodule_cmd_global(shadowircd_cmd_global);
+ pmodule_cmd_global_legacy(shadowircd_cmd_global_legacy);
+ pmodule_cmd_sqline(shadowircd_cmd_sqline);
+ pmodule_cmd_squit(shadowircd_cmd_squit);
+ pmodule_cmd_svso(shadowircd_cmd_svso);
+ pmodule_cmd_chg_nick(shadowircd_cmd_chg_nick);
+ pmodule_cmd_svsnick(shadowircd_cmd_svsnick);
+ pmodule_cmd_vhost_on(shadowircd_cmd_vhost_on);
+ pmodule_cmd_connect(shadowircd_cmd_connect);
+ pmodule_cmd_svshold(shadowircd_cmd_svshold);
+ pmodule_cmd_release_svshold(shadowircd_cmd_release_svshold);
+ pmodule_cmd_unsgline(shadowircd_cmd_unsqline);
+ pmodule_cmd_unszline(shadowircd_cmd_unszline);
+ pmodule_cmd_szline(shadowircd_cmd_szline);
+ pmodule_cmd_sgline(shadowircd_cmd_sgline);
+ pmodule_cmd_unban(shadowircd_cmd_unban);
+ pmodule_cmd_svsmode_chan(shadowircd_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(shadowircd_cmd_svid_umode);
+ pmodule_cmd_nc_change(shadowircd_cmd_nc_change);
+ pmodule_cmd_svid_umode2(shadowircd_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(shadowircd_cmd_svid_umode3);
+ pmodule_cmd_eob(shadowircd_cmd_eob);
+ pmodule_flood_mode_check(shadowircd_flood_mode_check);
+ pmodule_cmd_jupe(shadowircd_cmd_jupe);
+ pmodule_valid_nick(shadowircd_valid_nick);
+ pmodule_cmd_ctcp(shadowircd_cmd_ctcp);
+ pmodule_set_umode(shadowircd_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("ShadowIRCd 4.0+");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("");
+ pmodule_ircd_flood_mode_char_remove("");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(1);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/shadowircd.h b/src/protocol/shadowircd.h
new file mode 100644
index 000000000..4c6669ce2
--- /dev/null
+++ b/src/protocol/shadowircd.h
@@ -0,0 +1,142 @@
+/* ShadowIRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+/* The protocol revision. */
+#define PROTOCOL_REVISION 3402
+
+
+#define UMODE_a 0x00000001
+#define UMODE_C 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_z 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_s 0x00000040
+#define UMODE_c 0x00000080
+#define UMODE_r 0x00000100
+#define UMODE_k 0x00000200
+#define UMODE_f 0x00000400
+#define UMODE_y 0x00000800
+#define UMODE_d 0x00001000
+#define UMODE_n 0x00002000
+#define UMODE_x 0x00004000
+#define UMODE_u 0x00008000
+#define UMODE_b 0x00010000
+#define UMODE_l 0x00020000
+#define UMODE_g 0x00040000
+#define UMODE_v 0x00080000
+#define UMODE_A 0x00100000
+#define UMODE_E 0x00200000
+#define UMODE_G 0x00400000
+#define UMODE_R 0x00800000
+#define UMODE_e 0x01000000
+#define UMODE_O 0x02000000
+#define UMODE_H 0x04000000
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040
+#define CMODE_l 0x00000080
+#define CMODE_K 0x00000100
+#define CMODE_A 0x00000200
+#define CMODE_r 0x00000400
+#define CMODE_z 0x00000800
+#define CMODE_S 0x00001000
+#define CMODE_c 0x00002000
+#define CMODE_E 0x00004000
+#define CMODE_F 0x00008000
+#define CMODE_G 0x00010000
+#define CMODE_L 0x00020000
+#define CMODE_N 0x00040000
+#define CMODE_O 0x00080000
+#define CMODE_P 0x00100000
+#define CMODE_R 0x00200000
+#define CMODE_T 0x00400000
+#define CMODE_V 0x00800000
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void shadowircd_set_umode(User * user, int ac, char **av);
+void shadowircd_cmd_svsnoop(char *server, int set);
+void shadowircd_cmd_remove_akill(char *user, char *host);
+void shadowircd_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void shadowircd_cmd_vhost_off(User * u);
+void shadowircd_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void shadowircd_cmd_svskill(char *source, char *user, char *buf);
+void shadowircd_cmd_svsmode(User * u, int ac, char **av);
+void shadowircd_cmd_372(char *source, char *msg);
+void shadowircd_cmd_372_error(char *source);
+void shadowircd_cmd_375(char *source);
+void shadowircd_cmd_376(char *source);
+void shadowircd_cmd_nick(char *nick, char *name, char *modes);
+void shadowircd_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void shadowircd_cmd_mode(char *source, char *dest, char *buf);
+void shadowircd_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void shadowircd_cmd_kick(char *source, char *chan, char *user, char *buf);
+void shadowircd_cmd_notice_ops(char *source, char *dest, char *buf);
+void shadowircd_cmd_notice(char *source, char *dest, char *buf);
+void shadowircd_cmd_notice2(char *source, char *dest, char *msg);
+void shadowircd_cmd_privmsg(char *source, char *dest, char *buf);
+void shadowircd_cmd_privmsg2(char *source, char *dest, char *msg);
+void shadowircd_cmd_serv_notice(char *source, char *dest, char *msg);
+void shadowircd_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void shadowircd_cmd_bot_chan_mode(char *nick, char *chan);
+void shadowircd_cmd_351(char *source);
+void shadowircd_cmd_quit(char *source, char *buf);
+void shadowircd_cmd_pong(char *servname, char *who);
+void shadowircd_cmd_join(char *user, char *channel, time_t chantime);
+void shadowircd_cmd_unsqline(char *user);
+void shadowircd_cmd_invite(char *source, char *chan, char *nick);
+void shadowircd_cmd_part(char *nick, char *chan, char *buf);
+void shadowircd_cmd_391(char *source, char *timestr);
+void shadowircd_cmd_250(char *buf);
+void shadowircd_cmd_307(char *buf);
+void shadowircd_cmd_311(char *buf);
+void shadowircd_cmd_312(char *buf);
+void shadowircd_cmd_317(char *buf);
+void shadowircd_cmd_219(char *source, char *letter);
+void shadowircd_cmd_401(char *source, char *who);
+void shadowircd_cmd_318(char *source, char *who);
+void shadowircd_cmd_242(char *buf);
+void shadowircd_cmd_243(char *buf);
+void shadowircd_cmd_211(char *buf);
+void shadowircd_cmd_global(char *source, char *buf);
+void shadowircd_cmd_global_legacy(char *source, char *fmt);
+void shadowircd_cmd_sqline(char *mask, char *reason);
+void shadowircd_cmd_squit(char *servname, char *message);
+void shadowircd_cmd_svso(char *source, char *nick, char *flag);
+void shadowircd_cmd_chg_nick(char *oldnick, char *newnick);
+void shadowircd_cmd_svsnick(char *source, char *guest, time_t when);
+void shadowircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void shadowircd_cmd_connect(int servernum);
+void shadowircd_cmd_svshold(char *nick);
+void shadowircd_cmd_release_svshold(char *nick);
+void shadowircd_cmd_unsgline(char *mask);
+void shadowircd_cmd_unszline(char *mask);
+void shadowircd_cmd_szline(char *mask, char *reason, char *whom);
+void shadowircd_cmd_sgline(char *mask, char *reason);
+void shadowircd_cmd_unban(char *name, char *nick);
+void shadowircd_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void shadowircd_cmd_svid_umode(char *nick, time_t ts);
+void shadowircd_cmd_nc_change(User * u);
+void shadowircd_cmd_svid_umode2(User * u, char *ts);
+void shadowircd_cmd_svid_umode3(User * u, char *ts);
+void shadowircd_cmd_eob();
+int shadowircd_flood_mode_check(char *value);
+void shadowircd_cmd_jupe(char *jserver, char *who, char *reason);
+int shadowircd_valid_nick(char *nick);
+void shadowircd_cmd_ctcp(char *source, char *dest, char *buf);
diff --git a/src/solidircd.c b/src/protocol/solidircd.c
index 1e13f388b..753793895 100644
--- a/src/solidircd.c
+++ b/src/protocol/solidircd.c
@@ -15,17 +15,9 @@
#include "services.h"
#include "pseudo.h"
+#include "solidircd.h"
-#ifdef IRC_SOLID
-
-const char version_protocol[] = "Solid-IRCd 3.4.*";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = "+j"; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = "-j"; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0; /* does send TSMODE but if it doesn't means it won't so this is disabled */
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"Solid-IRCd 3.4.*", /* ircd name */
"+o", /* nickserv mode */
"+o", /* chanserv mode */
@@ -86,7 +78,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
0, /* VHOST ON NICK */
0, /* Change RealName */
- CHAN_HELP_IRCD_HALFOP, /* ChanServ extra */
0, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -118,7 +109,7 @@ IRCDVar ircd[] = {
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
CAPAB_TSMODE, /* TSMODE */
@@ -152,7 +143,7 @@ IRCDCAPAB ircdcap[] = {
};
-void anope_set_umode(User * user, int ac, char **av)
+void solidircd_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -274,7 +265,7 @@ unsigned long umodes[128] = {
0, 0 /* ~ ‚ */
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -296,7 +287,7 @@ char csmodes[128] = {
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
@@ -347,7 +338,7 @@ CMMode cmmodes[128] = {
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -413,7 +404,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'j', CMODE_j, 0, get_flood, cs_get_flood},
@@ -434,7 +425,7 @@ CBModeInfo cbmodeinfos[] = {
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -481,56 +472,46 @@ CUMode cumodes[128] = {
{0}, {0}, {0}, {0}, {0}
};
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void solidircd_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
-
- if (!buf) {
- return;
- }
+ if (!buf) {
+ return;
+ }
- if (ircdcap->tsmode) {
- if (uplink_capab & ircdcap->tsmode) {
- send_cmd(source, "MODE %s 0 %s", dest, buf);
- } else {
- send_cmd(source, "MODE %s %s", dest, buf);
- }
+ if (ircdcap->tsmode) {
+ if (uplink_capab & ircdcap->tsmode) {
+ send_cmd(source, "MODE %s 0 %s", dest, buf);
} else {
send_cmd(source, "MODE %s %s", dest, buf);
}
+ } else {
+ send_cmd(source, "MODE %s %s", dest, buf);
}
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void solidircd_cmd_svshold(char *nick)
{
send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout,
"Being held for registered user");
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void solidircd_cmd_release_svshold(char *nick)
{
send_cmd(ServerName, "SVSHOLD %s 0", nick);
}
/* SVSMODE -b */
-void anope_cmd_unban(char *name, char *nick)
+void solidircd_cmd_unban(char *name, char *nick)
{
- anope_cmd_svsmode_chan(name, "-b", nick);
+ solidircd_cmd_svsmode_chan(name, "-b", nick);
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void solidircd_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
if (nick) {
send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
@@ -539,7 +520,7 @@ void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
}
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void solidircd_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
}
@@ -738,7 +719,7 @@ int anope_event_vs(char *source, int ac, char **av)
}
/* SQLINE */
-void anope_cmd_sqline(char *mask, char *reason)
+void solidircd_cmd_sqline(char *mask, char *reason)
{
if (!mask || !reason) {
return;
@@ -748,59 +729,49 @@ void anope_cmd_sqline(char *mask, char *reason)
}
/* UNSGLINE */
-void anope_cmd_unsgline(char *mask)
+void solidircd_cmd_unsgline(char *mask)
{
send_cmd(NULL, "UNSGLINE 0 :%s", mask);
}
/* UNSZLINE */
-void anope_cmd_unszline(char *mask)
+void solidircd_cmd_unszline(char *mask)
{
send_cmd(NULL, "UNSZLINE 0 %s", mask);
}
/* SZLINE */
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void solidircd_cmd_szline(char *mask, char *reason, char *whom)
{
send_cmd(NULL, "SZLINE %s :%s", mask, reason);
}
/* SVSNOOP */
-void anope_cmd_svsnoop(char *server, int set)
+void solidircd_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void solidircd_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ solidircd_cmd_svsnoop(server, set);
}
/* SGLINE */
-void anope_cmd_sgline(char *mask, char *reason)
+void solidircd_cmd_sgline(char *mask, char *reason)
{
send_cmd(NULL, "SGLINE %d :%s:%s", strlen(mask), mask, reason);
}
/* RAKILL */
-void anope_cmd_remove_akill(char *user, char *host)
+void solidircd_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "RAKILL %s %s", host, user);
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void solidircd_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!nick || !chan) {
return;
}
@@ -813,21 +784,21 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
/* TOPIC */
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void solidircd_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
/* UNSQLINE */
-void anope_cmd_unsqline(char *user)
+void solidircd_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNSQLINE %s", user);
}
/* JOIN - SJOIN */
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void solidircd_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
}
@@ -840,8 +811,8 @@ void anope_cmd_join(char *user, char *channel, time_t chantime)
* parv[5]=time set
* parv[6]=reason
*/
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void solidircd_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
(long int) time(NULL), reason);
@@ -856,21 +827,10 @@ void anope_cmd_akill(char *user, char *host, char *who, time_t when,
/*
Note: if the stamp is null 0, the below usage is correct of Bahamut
*/
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void solidircd_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (!source || !user || !fmt) {
- return;
- }
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
-
- if (!buf) {
+ if (!source || !user || !buf) {
return;
}
@@ -884,7 +844,7 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
* parv[3] - mode (or services id if old svs version)
* parv[4] - optional arguement (services id)
*/
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void solidircd_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
(long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
@@ -897,33 +857,20 @@ void anope_cmd_svsmode(User * u, int ac, char **av)
* parv[1] = server name
* parv[2] = comment
*/
-void anope_cmd_squit(char *servname, char *message)
+void solidircd_cmd_squit(char *servname, char *message)
{
send_cmd(NULL, "SQUIT %s :%s", servname, message);
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void solidircd_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
-void anope_cmd_connect(int servernum)
+void solidircd_cmd_burst()
{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
-
- if (servernum == 1) {
- anope_cmd_pass(RemotePassword);
- } else if (servernum == 2) {
- anope_cmd_pass(RemotePassword2);
- } else if (servernum == 3) {
- anope_cmd_pass(RemotePassword3);
- }
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
- anope_cmd_burst();
+ send_cmd(NULL, "BURST");
}
@@ -935,30 +882,48 @@ void anope_cmd_connect(int servernum)
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
-void anope_cmd_svinfo()
+void solidircd_cmd_svinfo()
{
send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL));
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void solidircd_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS %s :TS", pass);
}
/* SERVER */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void solidircd_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, ServerDesc);
}
/* CAPAB */
-void anope_cmd_capab()
+void solidircd_cmd_capab()
{
/* CAPAB SSJOIN NOQUIT BURST UNCONNECT ZIP NICKIP TSMODE */
send_cmd(NULL, "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE");
}
+void solidircd_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ if (servernum == 1) {
+ solidircd_cmd_pass(RemotePassword);
+ } else if (servernum == 2) {
+ solidircd_cmd_pass(RemotePassword2);
+ } else if (servernum == 3) {
+ solidircd_cmd_pass(RemotePassword3);
+ }
+ solidircd_cmd_capab();
+ solidircd_cmd_server(ServerName, 1, ServerDesc);
+ solidircd_cmd_svinfo();
+ solidircd_cmd_burst();
+}
+
/* EVENT : SERVER */
int anope_event_server(char *source, int ac, char **av)
{
@@ -1088,63 +1053,36 @@ int anope_event_motd(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void solidircd_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- if (!buf) {
- return;
- }
- send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
+ if (!buf) {
+ return;
}
+ send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
}
/* NOTICE */
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void solidircd_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ solidircd_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void solidircd_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void solidircd_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1152,33 +1090,24 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void solidircd_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void solidircd_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void solidircd_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void solidircd_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1187,7 +1116,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void solidircd_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1196,17 +1125,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void solidircd_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1215,17 +1135,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void solidircd_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1234,17 +1145,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void solidircd_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1253,17 +1155,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void solidircd_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1272,17 +1165,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void solidircd_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1291,7 +1175,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void solidircd_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1306,7 +1190,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void solidircd_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1315,7 +1199,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void solidircd_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1325,17 +1209,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void solidircd_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1344,17 +1219,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void solidircd_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1363,17 +1229,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void solidircd_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1381,28 +1238,17 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_nick(char *nick, char *name, char *modes)
+void solidircd_cmd_nick(char *nick, char *name, char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, ServiceUser, ServiceHost,
ServerName, name);
- anope_cmd_sqline(nick, "Reserved for services");
+ solidircd_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void solidircd_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1410,30 +1256,30 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_372(char *source, char *msg)
+void solidircd_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void solidircd_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void solidircd_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void solidircd_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void solidircd_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1443,17 +1289,8 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void solidircd_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (buf) {
send_cmd(source, "QUIT :%s", buf);
@@ -1479,24 +1316,24 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ solidircd_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
-void anope_cmd_351(char *source)
+void solidircd_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
version_build);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void solidircd_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
- anope_cmd_sqline(nick, "Reserved for services");
+ solidircd_cmd_sqline(nick, "Reserved for services");
}
/* SVSNICK */
@@ -1505,7 +1342,7 @@ void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
* parv[2] = new nickname
* parv[3] = timestamp
*/
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void solidircd_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1513,41 +1350,42 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void solidircd_cmd_guest_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
{
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void solidircd_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void solidircd_cmd_chghost(char *nick, char *vhost)
{
- send_cmd(s_HostServ, "SVSMODE %s +v", nick);
- anope_cmd_chghost(nick, vhost);
+ if (!nick || !vhost) {
+ return;
+ }
+ send_cmd(ServerName, "SVHOST %s %s", nick, vhost);
}
-void anope_cmd_vhost_off(User * u)
+
+void solidircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
- send_cmd(s_HostServ, "SVSMODE %s -v", u->nick);
- notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
+ send_cmd(s_HostServ, "SVSMODE %s +v", nick);
+ solidircd_cmd_chghost(nick, vhost);
}
-void anope_cmd_chghost(char *nick, char *vhost)
+void solidircd_cmd_vhost_off(User * u)
{
- if (!nick || !vhost) {
- return;
- }
- send_cmd(ServerName, "SVHOST %s %s", nick, vhost);
+ send_cmd(s_HostServ, "SVSMODE %s -v", u->nick);
+ notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void solidircd_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick,
(unsigned long int) ts);
@@ -1556,19 +1394,19 @@ void anope_cmd_svid_umode(char *nick, time_t ts)
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void solidircd_cmd_nc_change(User * u)
{
common_svsmode(u, "+d", "1");
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void solidircd_cmd_svid_umode2(User * u, char *ts)
{
/* not used by bahamut ircds */
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void solidircd_cmd_svid_umode3(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -1578,7 +1416,7 @@ void anope_cmd_svid_umode3(User * u, char *ts)
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void solidircd_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1618,28 +1456,22 @@ int anope_event_pass(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void solidircd_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Can not find any reference to these in Bahamut */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void solidircd_cmd_svspart(char *source, char *nick, char *chan)
{
/* Can not find any reference to these in Bahamut */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void solidircd_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
-
-void anope_cmd_burst()
-{
- send_cmd(NULL, "BURST");
-}
-
-void anope_cmd_eob()
+void solidircd_cmd_eob()
{
send_cmd(NULL, "BURST 0");
}
@@ -1682,7 +1514,7 @@ int anope_event_admin(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int solidircd_flood_mode_check(char *value)
{
char *dp, *end;
@@ -1696,20 +1528,20 @@ int anope_flood_mode_check(char *value)
}
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void solidircd_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ solidircd_cmd_squit(jserver, rbuf);
+ solidircd_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void solidircd_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
}
@@ -1718,24 +1550,16 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int solidircd_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void solidircd_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1746,4 +1570,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(solidircd_cmd_svsnoop);
+ pmodule_cmd_remove_akill(solidircd_cmd_remove_akill);
+ pmodule_cmd_topic(solidircd_cmd_topic);
+ pmodule_cmd_vhost_off(solidircd_cmd_vhost_off);
+ pmodule_cmd_akill(solidircd_cmd_akill);
+ pmodule_cmd_svskill(solidircd_cmd_svskill);
+ pmodule_cmd_svsmode(solidircd_cmd_svsmode);
+ pmodule_cmd_372(solidircd_cmd_372);
+ pmodule_cmd_372_error(solidircd_cmd_372_error);
+ pmodule_cmd_375(solidircd_cmd_375);
+ pmodule_cmd_376(solidircd_cmd_376);
+ pmodule_cmd_nick(solidircd_cmd_nick);
+ pmodule_cmd_guest_nick(solidircd_cmd_guest_nick);
+ pmodule_cmd_mode(solidircd_cmd_mode);
+ pmodule_cmd_bot_nick(solidircd_cmd_bot_nick);
+ pmodule_cmd_kick(solidircd_cmd_kick);
+ pmodule_cmd_notice_ops(solidircd_cmd_notice_ops);
+ pmodule_cmd_notice(solidircd_cmd_notice);
+ pmodule_cmd_notice2(solidircd_cmd_notice2);
+ pmodule_cmd_privmsg(solidircd_cmd_privmsg);
+ pmodule_cmd_privmsg2(solidircd_cmd_privmsg2);
+ pmodule_cmd_serv_notice(solidircd_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(solidircd_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(solidircd_cmd_bot_chan_mode);
+ pmodule_cmd_351(solidircd_cmd_351);
+ pmodule_cmd_quit(solidircd_cmd_quit);
+ pmodule_cmd_pong(solidircd_cmd_pong);
+ pmodule_cmd_join(solidircd_cmd_join);
+ pmodule_cmd_unsqline(solidircd_cmd_unsqline);
+ pmodule_cmd_invite(solidircd_cmd_invite);
+ pmodule_cmd_part(solidircd_cmd_part);
+ pmodule_cmd_391(solidircd_cmd_391);
+ pmodule_cmd_250(solidircd_cmd_250);
+ pmodule_cmd_307(solidircd_cmd_307);
+ pmodule_cmd_311(solidircd_cmd_311);
+ pmodule_cmd_312(solidircd_cmd_312);
+ pmodule_cmd_317(solidircd_cmd_317);
+ pmodule_cmd_219(solidircd_cmd_219);
+ pmodule_cmd_401(solidircd_cmd_401);
+ pmodule_cmd_318(solidircd_cmd_318);
+ pmodule_cmd_242(solidircd_cmd_242);
+ pmodule_cmd_243(solidircd_cmd_243);
+ pmodule_cmd_211(solidircd_cmd_211);
+ pmodule_cmd_global(solidircd_cmd_global);
+ pmodule_cmd_global_legacy(solidircd_cmd_global_legacy);
+ pmodule_cmd_sqline(solidircd_cmd_sqline);
+ pmodule_cmd_squit(solidircd_cmd_squit);
+ pmodule_cmd_svso(solidircd_cmd_svso);
+ pmodule_cmd_chg_nick(solidircd_cmd_chg_nick);
+ pmodule_cmd_svsnick(solidircd_cmd_svsnick);
+ pmodule_cmd_vhost_on(solidircd_cmd_vhost_on);
+ pmodule_cmd_connect(solidircd_cmd_connect);
+ pmodule_cmd_svshold(solidircd_cmd_svshold);
+ pmodule_cmd_release_svshold(solidircd_cmd_release_svshold);
+ pmodule_cmd_unsgline(solidircd_cmd_unsqline);
+ pmodule_cmd_unszline(solidircd_cmd_unszline);
+ pmodule_cmd_szline(solidircd_cmd_szline);
+ pmodule_cmd_sgline(solidircd_cmd_sgline);
+ pmodule_cmd_unban(solidircd_cmd_unban);
+ pmodule_cmd_svsmode_chan(solidircd_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(solidircd_cmd_svid_umode);
+ pmodule_cmd_nc_change(solidircd_cmd_nc_change);
+ pmodule_cmd_svid_umode2(solidircd_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(solidircd_cmd_svid_umode3);
+ pmodule_cmd_eob(solidircd_cmd_eob);
+ pmodule_flood_mode_check(solidircd_flood_mode_check);
+ pmodule_cmd_jupe(solidircd_cmd_jupe);
+ pmodule_valid_nick(solidircd_valid_nick);
+ pmodule_cmd_ctcp(solidircd_cmd_ctcp);
+ pmodule_set_umode(solidircd_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("Solid-IRCd 3.4.*");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("+j");
+ pmodule_ircd_flood_mode_char_remove("-j");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/solidircd.h b/src/protocol/solidircd.h
new file mode 100644
index 000000000..e75f9add6
--- /dev/null
+++ b/src/protocol/solidircd.h
@@ -0,0 +1,137 @@
+/* SolidIRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+/*************************************************************************/
+
+#define UMODE_a 0x00000001 /* umode +a - Services Admin */
+#define UMODE_h 0x00000002 /* umode +h - Helper */
+#define UMODE_i 0x00000004 /* umode +i - Invisible */
+#define UMODE_o 0x00000008 /* umode +o - Oper */
+#define UMODE_r 0x00000010 /* umode +r - registered nick */
+#define UMODE_w 0x00000020 /* umode +w - Get wallops */
+#define UMODE_A 0x00000040 /* umode +A - Server Admin */
+#define UMODE_x 0x00000080 /* umode +x - Squelch with notice */
+#define UMODE_X 0x00000100 /* umode +X - Squelch without notice */
+#define UMODE_F 0x00000200 /* umode +F - no cptr->since message rate throttle */
+#define UMODE_j 0x00000400 /* umode +j - client rejection notices */
+#define UMODE_K 0x00000800 /* umode +K - U: lined server kill messages */
+#define UMODE_O 0x00001000 /* umode +O - Local Oper */
+#define UMODE_s 0x00002000 /* umode +s - Server notices */
+#define UMODE_c 0x00004000 /* umode +c - Client connections/exits */
+#define UMODE_k 0x00008000 /* umode +k - Server kill messages */
+#define UMODE_f 0x00010000 /* umode +f - Server flood messages */
+#define UMODE_y 0x00020000 /* umode +y - Stats/links */
+#define UMODE_d 0x00040000 /* umode +d - Debug info */
+#define UMODE_g 0x00080000 /* umode +g - Globops */
+#define UMODE_b 0x00100000 /* umode +b - Chatops */
+#define UMODE_n 0x00200000 /* umode +n - Routing Notices */
+#define UMODE_m 0x00400000 /* umode +m - spambot notices */
+#define UMODE_e 0x00800000 /* umode +e - oper notices for the above +D */
+#define UMODE_D 0x01000000 /* umode +D - Hidden dccallow umode */
+#define UMODE_I 0x02000000 /* umode +I - invisible oper (masked) */
+#define UMODE_C 0x04000000 /* umode +C - conops */
+#define UMODE_v 0x10000000 /* umode +v - hostmasking */
+#define UMODE_H 0x20000000 /* umode +H - Oper Hiding */
+#define UMODE_z 0x40000000 /* umode +z - SSL */
+#define UMODE_R 0x80000000 /* umode +R - No non registered msgs */
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+#define CMODE_c 0x00000400 /* Colors can't be used */
+#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */
+#define CMODE_j 0x00001000 /* join throttle */
+#define CMODE_S 0x00002000 /* SSL only */
+#define CMODE_N 0x00004000 /* No Nickname change */
+#define CMODE_O 0x00008000 /* Only opers can join */
+
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void solidircd_set_umode(User * user, int ac, char **av);
+void solidircd_cmd_svsnoop(char *server, int set);
+void solidircd_cmd_remove_akill(char *user, char *host);
+void solidircd_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void solidircd_cmd_vhost_off(User * u);
+void solidircd_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void solidircd_cmd_svskill(char *source, char *user, char *buf);
+void solidircd_cmd_svsmode(User * u, int ac, char **av);
+void solidircd_cmd_372(char *source, char *msg);
+void solidircd_cmd_372_error(char *source);
+void solidircd_cmd_375(char *source);
+void solidircd_cmd_376(char *source);
+void solidircd_cmd_nick(char *nick, char *name, char *modes);
+void solidircd_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void solidircd_cmd_mode(char *source, char *dest, char *buf);
+void solidircd_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void solidircd_cmd_kick(char *source, char *chan, char *user, char *buf);
+void solidircd_cmd_notice_ops(char *source, char *dest, char *buf);
+void solidircd_cmd_notice(char *source, char *dest, char *buf);
+void solidircd_cmd_notice2(char *source, char *dest, char *msg);
+void solidircd_cmd_privmsg(char *source, char *dest, char *buf);
+void solidircd_cmd_privmsg2(char *source, char *dest, char *msg);
+void solidircd_cmd_serv_notice(char *source, char *dest, char *msg);
+void solidircd_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void solidircd_cmd_bot_chan_mode(char *nick, char *chan);
+void solidircd_cmd_351(char *source);
+void solidircd_cmd_quit(char *source, char *buf);
+void solidircd_cmd_pong(char *servname, char *who);
+void solidircd_cmd_join(char *user, char *channel, time_t chantime);
+void solidircd_cmd_unsqline(char *user);
+void solidircd_cmd_invite(char *source, char *chan, char *nick);
+void solidircd_cmd_part(char *nick, char *chan, char *buf);
+void solidircd_cmd_391(char *source, char *timestr);
+void solidircd_cmd_250(char *buf);
+void solidircd_cmd_307(char *buf);
+void solidircd_cmd_311(char *buf);
+void solidircd_cmd_312(char *buf);
+void solidircd_cmd_317(char *buf);
+void solidircd_cmd_219(char *source, char *letter);
+void solidircd_cmd_401(char *source, char *who);
+void solidircd_cmd_318(char *source, char *who);
+void solidircd_cmd_242(char *buf);
+void solidircd_cmd_243(char *buf);
+void solidircd_cmd_211(char *buf);
+void solidircd_cmd_global(char *source, char *buf);
+void solidircd_cmd_global_legacy(char *source, char *fmt);
+void solidircd_cmd_sqline(char *mask, char *reason);
+void solidircd_cmd_squit(char *servname, char *message);
+void solidircd_cmd_svso(char *source, char *nick, char *flag);
+void solidircd_cmd_chg_nick(char *oldnick, char *newnick);
+void solidircd_cmd_svsnick(char *source, char *guest, time_t when);
+void solidircd_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void solidircd_cmd_connect(int servernum);
+void solidircd_cmd_svshold(char *nick);
+void solidircd_cmd_release_svshold(char *nick);
+void solidircd_cmd_unsgline(char *mask);
+void solidircd_cmd_unszline(char *mask);
+void solidircd_cmd_szline(char *mask, char *reason, char *whom);
+void solidircd_cmd_sgline(char *mask, char *reason);
+void solidircd_cmd_unban(char *name, char *nick);
+void solidircd_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void solidircd_cmd_svid_umode(char *nick, time_t ts);
+void solidircd_cmd_nc_change(User * u);
+void solidircd_cmd_svid_umode2(User * u, char *ts);
+void solidircd_cmd_svid_umode3(User * u, char *ts);
+void solidircd_cmd_eob();
+int solidircd_flood_mode_check(char *value);
+void solidircd_cmd_jupe(char *jserver, char *who, char *reason);
+int solidircd_valid_nick(char *nick);
+void solidircd_cmd_ctcp(char *source, char *dest, char *buf);
diff --git a/src/ultimate2.c b/src/protocol/ultimate2.c
index efc9171e9..eb8d29462 100644
--- a/src/ultimate2.c
+++ b/src/protocol/ultimate2.c
@@ -13,17 +13,9 @@
#include "services.h"
#include "pseudo.h"
+#include "ultimate2.h"
-#ifdef IRC_ULTIMATE2
-
-const char version_protocol[] = "UltimateIRCd 2.8.2+";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = "+f"; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = "-f"; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0;
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"UltimateIRCd 2.8.*", /* ircd name */
"+S", /* nickserv mode */
"+S", /* chanserv mode */
@@ -84,7 +76,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
0, /* VHOST ON NICK */
1, /* Change RealName */
- CHAN_HELP_IRCD_HALFOP, /* ChanServ extra */
CMODE_K, /* No Knock */
CMODE_A, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -117,7 +108,7 @@ IRCDVar ircd[] = {
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
0, /* TSMODE */
@@ -151,7 +142,7 @@ IRCDCAPAB ircdcap[] = {
0, 0}
};
-void anope_set_umode(User * user, int ac, char **av)
+void ultiamte2_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -262,7 +253,7 @@ unsigned long umodes[128] = {
0, 0, 0, 0, 0
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -283,7 +274,7 @@ char csmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
@@ -310,7 +301,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -376,7 +367,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'f', CMODE_f, 0, get_flood, cs_get_flood},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
@@ -398,7 +389,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -778,40 +769,40 @@ int anope_event_capab(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_sqline(char *mask, char *reason)
+void ultimate2_cmd_sqline(char *mask, char *reason)
{
send_cmd(NULL, "SQLINE %s :%s", mask, reason);
}
-void anope_cmd_svsnoop(char *server, int set)
+void ultimate2_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void ultimate2_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ ultimate2_cmd_svsnoop(server, set);
}
-void anope_cmd_remove_akill(char *user, char *host)
+void ultimate2_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "RAKILL %s %s", host, user);
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void ultimate2_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
-void anope_cmd_vhost_off(User * u)
+void ultimate2_cmd_vhost_off(User * u)
{
/* does not support removing vhosting */
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void ultimate2_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
if (vIdent) {
send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent);
@@ -820,33 +811,24 @@ void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
send_cmd(ServerName, "CHGHOST %s %s", nick, vhost);
}
-void anope_cmd_unsqline(char *user)
+void ultimate2_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNSQLINE %s", user);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void ultimate2_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(user, "JOIN %s", channel);
}
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void ultimate2_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "AKILL %s %s :%s", host, user, reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void ultimate2_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -854,28 +836,13 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
send_cmd(source, "KILL %s :%s", user, buf);
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void ultimate2_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0],
(ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
}
-void anope_cmd_connect(int servernum)
-{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
-
- anope_cmd_capab();
- if (servernum == 1)
- anope_cmd_pass(RemotePassword);
- if (servernum == 2)
- anope_cmd_pass(RemotePassword2);
- if (servernum == 3)
- anope_cmd_pass(RemotePassword3);
- anope_cmd_server(ServerName, 1, ServerDesc);
-}
-
-void anope_cmd_capab()
+void ultimate2_cmd_capab()
{
if (UseTokens) {
send_cmd(NULL, "PROTOCTL NOQUIT TOKEN SILENCE KNOCK");
@@ -886,25 +853,40 @@ void anope_cmd_capab()
/* PASS */
-void anope_cmd_pass(char *pass)
+void ultimate2_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS :%s", pass);
}
/* SERVER name hop descript */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void ultimate2_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void ultimate2_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
+void ultimate2_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ ultimate2_cmd_capab();
+ if (servernum == 1)
+ ultimate2_cmd_pass(RemotePassword);
+ if (servernum == 2)
+ ultimate2_cmd_pass(RemotePassword2);
+ if (servernum == 3)
+ ultimate2_cmd_pass(RemotePassword3);
+ ultimate2_cmd_server(ServerName, 1, ServerDesc);
+}
+
/* CHGHOST */
-void anope_cmd_chghost(char *nick, char *vhost)
+void ultimate2_cmd_chghost(char *nick, char *vhost)
{
if (!nick || !vhost) {
return;
@@ -913,7 +895,7 @@ void anope_cmd_chghost(char *nick, char *vhost)
}
/* CHGIDENT */
-void anope_cmd_chgident(char *nick, char *vIdent)
+void ultimate2_cmd_chgident(char *nick, char *vIdent)
{
if (!nick || !vIdent) {
return;
@@ -922,7 +904,7 @@ void anope_cmd_chgident(char *nick, char *vIdent)
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void ultimate2_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -932,18 +914,8 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void ultimate2_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!nick || !chan) {
return;
}
@@ -956,7 +928,7 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void ultimate2_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -965,17 +937,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void ultimate2_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -984,17 +947,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void ultimate2_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1003,17 +957,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void ultimate2_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1022,17 +967,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void ultimate2_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1041,17 +977,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void ultimate2_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1060,7 +987,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void ultimate2_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1075,7 +1002,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void ultimate2_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1084,7 +1011,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void ultimate2_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1094,17 +1021,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void ultimate2_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1113,17 +1031,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void ultimate2_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1132,17 +1041,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void ultimate2_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1151,17 +1051,8 @@ void anope_cmd_211(const char *fmt, ...)
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void ultimate2_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1170,7 +1061,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* SQUIT */
-void anope_cmd_squit(char *servname, char *message)
+void ultimate2_cmd_squit(char *servname, char *message)
{
if (!servname || !message) {
return;
@@ -1180,7 +1071,7 @@ void anope_cmd_squit(char *servname, char *message)
}
/* SVSO */
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void ultimate2_cmd_svso(char *source, char *nick, char *flag)
{
if (!source || !nick || !flag) {
return;
@@ -1190,7 +1081,7 @@ void anope_cmd_svso(char *source, char *nick, char *flag)
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void ultimate2_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1200,7 +1091,7 @@ void anope_cmd_chg_nick(char *oldnick, char *newnick)
}
/* SVSNICK */
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void ultimate2_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1214,7 +1105,7 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ ultimate2_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
@@ -1341,19 +1232,8 @@ int anope_event_whois(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void ultimate2_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1361,17 +1241,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void ultimate2_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1380,44 +1251,26 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
}
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void ultimate2_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ ultimate2_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void ultimate2_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void ultimate2_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1425,32 +1278,32 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void ultimate2_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void ultimate2_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void ultimate2_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
-void anope_cmd_nick(char *nick, char *name, char *mode)
+void ultimate2_cmd_nick(char *nick, char *name, char *mode)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
(long int) time(NULL), ServiceUser, ServiceHost, ServerName,
name);
anope_cmd_mode(nick, nick, "%s", mode);
- anope_cmd_sqline(nick, "Reserved for services");
+ ultimate2_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_351(char *source)
+void ultimate2_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
@@ -1458,18 +1311,8 @@ void anope_cmd_351(char *source)
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void ultimate2_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -1477,17 +1320,8 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void ultimate2_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1495,81 +1329,81 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "MODE %s %s", dest, buf);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void ultimate2_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
(long int) time(NULL), user, host, ServerName, real);
anope_cmd_mode(nick, nick, "%s", modes);
- anope_cmd_sqline(nick, "Reserved for services");
+ ultimate2_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_372(char *source, char *msg)
+void ultimate2_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void ultimate2_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void ultimate2_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void ultimate2_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void ultimate2_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void ultimate2_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void ultimate2_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* UNSGLINE */
-void anope_cmd_unsgline(char *mask)
+void ultimate2_cmd_unsgline(char *mask)
{
/* Not Supported by this IRCD */
}
/* UNSZLINE */
-void anope_cmd_unszline(char *mask)
+void ultimate2_cmd_unszline(char *mask)
{
/* Not Supported by this IRCD */
}
/* SZLINE */
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void ultimate2_cmd_szline(char *mask, char *reason, char *whom)
{
/* Not Supported by this IRCD */
}
/* SGLINE */
-void anope_cmd_sgline(char *mask, char *reason)
+void ultimate2_cmd_sgline(char *mask, char *reason)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void ultimate2_cmd_guest_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
{
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
(long int) time(NULL), user, host, ServerName, real);
@@ -1577,34 +1411,34 @@ void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
}
-void anope_cmd_unban(char *name, char *nick)
+void ultimate2_cmd_unban(char *name, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void ultimate2_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void ultimate2_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s +d 1", nick);
}
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void ultimate2_cmd_nc_change(User * u)
{
common_svsmode(u, "-r+d", "1");
}
/* SVSMODE +r */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void ultimate2_cmd_svid_umode2(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -1613,7 +1447,7 @@ void anope_cmd_svid_umode2(User * u, char *ts)
}
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void ultimate2_cmd_svid_umode3(User * u, char *ts)
{
/* not used */
}
@@ -1655,7 +1489,7 @@ int anope_event_sqline(char *source, int ac, char **av)
** parv[1] - nick to make join
** parv[2] - channel(s) to join
*/
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void ultimate2_cmd_svsjoin(char *source, char *nick, char *chan)
{
send_cmd(source, "SVSJOIN %s %s", nick, chan);
}
@@ -1667,17 +1501,17 @@ void anope_cmd_svsjoin(char *source, char *nick, char *chan)
** parv[1] - nick to make part
** parv[2] - channel(s) to part
*/
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void ultimate2_cmd_svspart(char *source, char *nick, char *chan)
{
send_cmd(source, "SVSPART %s %s", nick, chan);
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void ultimate2_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
-void anope_cmd_eob()
+void ultimate2_cmd_eob()
{
/* not supported */
}
@@ -1697,7 +1531,7 @@ int anope_event_admin(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int ultiamte2_flood_mode_check(char *value)
{
char *dp, *end;
@@ -1721,20 +1555,20 @@ int anope_event_error(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void ultimate2_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ ultimate2_cmd_squit(jserver, rbuf);
+ ultimate2_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void ultimate2_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
}
@@ -1743,24 +1577,16 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int ultiamte2_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void ultimate2_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1771,4 +1597,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(ultimate2_cmd_svsnoop);
+ pmodule_cmd_remove_akill(ultimate2_cmd_remove_akill);
+ pmodule_cmd_topic(ultimate2_cmd_topic);
+ pmodule_cmd_vhost_off(ultimate2_cmd_vhost_off);
+ pmodule_cmd_akill(ultimate2_cmd_akill);
+ pmodule_cmd_svskill(ultimate2_cmd_svskill);
+ pmodule_cmd_svsmode(ultimate2_cmd_svsmode);
+ pmodule_cmd_372(ultimate2_cmd_372);
+ pmodule_cmd_372_error(ultimate2_cmd_372_error);
+ pmodule_cmd_375(ultimate2_cmd_375);
+ pmodule_cmd_376(ultimate2_cmd_376);
+ pmodule_cmd_nick(ultimate2_cmd_nick);
+ pmodule_cmd_guest_nick(ultimate2_cmd_guest_nick);
+ pmodule_cmd_mode(ultimate2_cmd_mode);
+ pmodule_cmd_bot_nick(ultimate2_cmd_bot_nick);
+ pmodule_cmd_kick(ultimate2_cmd_kick);
+ pmodule_cmd_notice_ops(ultimate2_cmd_notice_ops);
+ pmodule_cmd_notice(ultimate2_cmd_notice);
+ pmodule_cmd_notice2(ultimate2_cmd_notice2);
+ pmodule_cmd_privmsg(ultimate2_cmd_privmsg);
+ pmodule_cmd_privmsg2(ultimate2_cmd_privmsg2);
+ pmodule_cmd_serv_notice(ultimate2_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(ultimate2_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(ultimate2_cmd_bot_chan_mode);
+ pmodule_cmd_351(ultimate2_cmd_351);
+ pmodule_cmd_quit(ultimate2_cmd_quit);
+ pmodule_cmd_pong(ultimate2_cmd_pong);
+ pmodule_cmd_join(ultimate2_cmd_join);
+ pmodule_cmd_unsqline(ultimate2_cmd_unsqline);
+ pmodule_cmd_invite(ultimate2_cmd_invite);
+ pmodule_cmd_part(ultimate2_cmd_part);
+ pmodule_cmd_391(ultimate2_cmd_391);
+ pmodule_cmd_250(ultimate2_cmd_250);
+ pmodule_cmd_307(ultimate2_cmd_307);
+ pmodule_cmd_311(ultimate2_cmd_311);
+ pmodule_cmd_312(ultimate2_cmd_312);
+ pmodule_cmd_317(ultimate2_cmd_317);
+ pmodule_cmd_219(ultimate2_cmd_219);
+ pmodule_cmd_401(ultimate2_cmd_401);
+ pmodule_cmd_318(ultimate2_cmd_318);
+ pmodule_cmd_242(ultimate2_cmd_242);
+ pmodule_cmd_243(ultimate2_cmd_243);
+ pmodule_cmd_211(ultimate2_cmd_211);
+ pmodule_cmd_global(ultimate2_cmd_global);
+ pmodule_cmd_global_legacy(ultimate2_cmd_global_legacy);
+ pmodule_cmd_sqline(ultimate2_cmd_sqline);
+ pmodule_cmd_squit(ultimate2_cmd_squit);
+ pmodule_cmd_svso(ultimate2_cmd_svso);
+ pmodule_cmd_chg_nick(ultimate2_cmd_chg_nick);
+ pmodule_cmd_svsnick(ultimate2_cmd_svsnick);
+ pmodule_cmd_vhost_on(ultimate2_cmd_vhost_on);
+ pmodule_cmd_connect(ultimate2_cmd_connect);
+ pmodule_cmd_svshold(ultimate2_cmd_svshold);
+ pmodule_cmd_release_svshold(ultimate2_cmd_release_svshold);
+ pmodule_cmd_unsgline(ultimate2_cmd_unsqline);
+ pmodule_cmd_unszline(ultimate2_cmd_unszline);
+ pmodule_cmd_szline(ultimate2_cmd_szline);
+ pmodule_cmd_sgline(ultimate2_cmd_sgline);
+ pmodule_cmd_unban(ultimate2_cmd_unban);
+ pmodule_cmd_svsmode_chan(ultimate2_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(ultimate2_cmd_svid_umode);
+ pmodule_cmd_nc_change(ultimate2_cmd_nc_change);
+ pmodule_cmd_svid_umode2(ultimate2_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(ultimate2_cmd_svid_umode3);
+ pmodule_cmd_eob(ultimate2_cmd_eob);
+ pmodule_flood_mode_check(ultiamte2_flood_mode_check);
+ pmodule_cmd_jupe(ultimate2_cmd_jupe);
+ pmodule_valid_nick(ultiamte2_valid_nick);
+ pmodule_cmd_ctcp(ultimate2_cmd_ctcp);
+ pmodule_set_umode(ultiamte2_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("UltimateIRCd 2.8.2+");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("+f");
+ pmodule_ircd_flood_mode_char_remove("-f");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/ultimate2.h b/src/protocol/ultimate2.h
new file mode 100644
index 000000000..dcbee95ec
--- /dev/null
+++ b/src/protocol/ultimate2.h
@@ -0,0 +1,120 @@
+/* Ultimate IRCD 2 functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#define UMODE_a 0x00000001
+#define UMODE_h 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_r 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_A 0x00000040
+#define UMODE_p 0x04000000
+#define UMODE_R 0x08000000
+#define UMODE_P 0x20000000
+#define UMODE_g 0x80000000
+#define UMODE_x 0x40000000
+
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_f 0x00000400
+#define CMODE_x 0x00000800
+#define CMODE_A 0x00001000
+#define CMODE_I 0x00002000
+#define CMODE_K 0x00004000
+#define CMODE_L 0x00008000
+#define CMODE_O 0x00010000
+#define CMODE_S 0x00020000
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void ultimate2_set_umode(User * user, int ac, char **av);
+void ultimate2_cmd_svsnoop(char *server, int set);
+void ultimate2_cmd_remove_akill(char *user, char *host);
+void ultimate2_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void ultimate2_cmd_vhost_off(User * u);
+void ultimate2_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void ultimate2_cmd_svskill(char *source, char *user, char *buf);
+void ultimate2_cmd_svsmode(User * u, int ac, char **av);
+void ultimate2_cmd_372(char *source, char *msg);
+void ultimate2_cmd_372_error(char *source);
+void ultimate2_cmd_375(char *source);
+void ultimate2_cmd_376(char *source);
+void ultimate2_cmd_nick(char *nick, char *name, char *modes);
+void ultimate2_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void ultimate2_cmd_mode(char *source, char *dest, char *buf);
+void ultimate2_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void ultimate2_cmd_kick(char *source, char *chan, char *user, char *buf);
+void ultimate2_cmd_notice_ops(char *source, char *dest, char *buf);
+void ultimate2_cmd_notice(char *source, char *dest, char *buf);
+void ultimate2_cmd_notice2(char *source, char *dest, char *msg);
+void ultimate2_cmd_privmsg(char *source, char *dest, char *buf);
+void ultimate2_cmd_privmsg2(char *source, char *dest, char *msg);
+void ultimate2_cmd_serv_notice(char *source, char *dest, char *msg);
+void ultimate2_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void ultimate2_cmd_bot_chan_mode(char *nick, char *chan);
+void ultimate2_cmd_351(char *source);
+void ultimate2_cmd_quit(char *source, char *buf);
+void ultimate2_cmd_pong(char *servname, char *who);
+void ultimate2_cmd_join(char *user, char *channel, time_t chantime);
+void ultimate2_cmd_unsqline(char *user);
+void ultimate2_cmd_invite(char *source, char *chan, char *nick);
+void ultimate2_cmd_part(char *nick, char *chan, char *buf);
+void ultimate2_cmd_391(char *source, char *timestr);
+void ultimate2_cmd_250(char *buf);
+void ultimate2_cmd_307(char *buf);
+void ultimate2_cmd_311(char *buf);
+void ultimate2_cmd_312(char *buf);
+void ultimate2_cmd_317(char *buf);
+void ultimate2_cmd_219(char *source, char *letter);
+void ultimate2_cmd_401(char *source, char *who);
+void ultimate2_cmd_318(char *source, char *who);
+void ultimate2_cmd_242(char *buf);
+void ultimate2_cmd_243(char *buf);
+void ultimate2_cmd_211(char *buf);
+void ultimate2_cmd_global(char *source, char *buf);
+void ultimate2_cmd_global_legacy(char *source, char *fmt);
+void ultimate2_cmd_sqline(char *mask, char *reason);
+void ultimate2_cmd_squit(char *servname, char *message);
+void ultimate2_cmd_svso(char *source, char *nick, char *flag);
+void ultimate2_cmd_chg_nick(char *oldnick, char *newnick);
+void ultimate2_cmd_svsnick(char *source, char *guest, time_t when);
+void ultimate2_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void ultimate2_cmd_connect(int servernum);
+void ultimate2_cmd_svshold(char *nick);
+void ultimate2_cmd_release_svshold(char *nick);
+void ultimate2_cmd_unsgline(char *mask);
+void ultimate2_cmd_unszline(char *mask);
+void ultimate2_cmd_szline(char *mask, char *reason, char *whom);
+void ultimate2_cmd_sgline(char *mask, char *reason);
+void ultimate2_cmd_unban(char *name, char *nick);
+void ultimate2_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void ultimate2_cmd_svid_umode(char *nick, time_t ts);
+void ultimate2_cmd_nc_change(User * u);
+void ultimate2_cmd_svid_umode2(User * u, char *ts);
+void ultimate2_cmd_svid_umode3(User * u, char *ts);
+void ultimate2_cmd_eob();
+int ultimate2_flood_mode_check(char *value);
+void ultimate2_cmd_jupe(char *jserver, char *who, char *reason);
+int ultimate2_valid_nick(char *nick);
+void ultimate2_cmd_ctcp(char *source, char *dest, char *buf);
+
+
diff --git a/src/ultimate3.c b/src/protocol/ultimate3.c
index 0489ef952..dedfb9077 100644
--- a/src/ultimate3.c
+++ b/src/protocol/ultimate3.c
@@ -13,19 +13,9 @@
#include "services.h"
#include "pseudo.h"
+#include "ultimate3.h"
-#ifdef IRC_ULTIMATE3
-
-const char version_protocol[] = "UltimateIRCd 3.0.0.a26+";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = ""; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = ""; /* mode char for FLOOD mode on remove */
-
-int UseTSMODE = 0;
-
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"UltimateIRCd 3.0.*", /* ircd name */
"+S", /* nickserv mode */
"+S", /* chanserv mode */
@@ -86,7 +76,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
0, /* Change RealName */
- CHAN_HELP_ULTIMATE3, /* ChanServ extra */
CMODE_K, /* No Knock */
CMODE_A, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -113,11 +102,12 @@ IRCDVar ircd[] = {
0, /* p10 */
NULL, /* character set */
1, /* reports sync state */
- },
+ }
+ ,
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
CAPAB_TSMODE, /* TSMODE */
@@ -150,7 +140,7 @@ IRCDCAPAB ircdcap[] = {
0, 0, 0}
};
-void anope_set_umode(User * user, int ac, char **av)
+void ultimate3_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -292,7 +282,7 @@ unsigned long umodes[128] = {
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -314,7 +304,7 @@ char csmodes[128] = {
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
@@ -341,7 +331,7 @@ CMMode cmmodes[128] = {
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -407,7 +397,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
@@ -429,7 +419,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -477,15 +467,15 @@ CUMode cumodes[128] = {
};
/* SVSMODE -b */
-void anope_cmd_unban(char *name, char *nick)
+void ultimate3_cmd_unban(char *name, char *nick)
{
- anope_cmd_svsmode_chan(name, "-b", nick);
+ ultimate3_cmd_svsmode_chan(name, "-b", nick);
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void ultimate3_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
if (nick) {
send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
@@ -665,7 +655,7 @@ void moduleAddIRCDMsgs(void) {
/* *INDENT-ON* */
-void anope_cmd_sqline(char *mask, char *reason)
+void ultimate3_cmd_sqline(char *mask, char *reason)
{
if (!mask || !reason) {
return;
@@ -674,12 +664,12 @@ void anope_cmd_sqline(char *mask, char *reason)
send_cmd(NULL, "SQLINE %s :%s", mask, reason);
}
-void anope_cmd_unsgline(char *mask)
+void ultimate3_cmd_unsgline(char *mask)
{
send_cmd(NULL, "UNSGLINE 0 :%s", mask);
}
-void anope_cmd_unszline(char *mask)
+void ultimate3_cmd_unszline(char *mask)
{
send_cmd(NULL, "UNSZLINE 0 %s", mask);
}
@@ -689,7 +679,7 @@ void anope_cmd_unszline(char *mask)
Complete rewrite of the kline/akill/zline system. (s)zlines no longer exist.
K: lines set on IP addresses without username portions (or *) are treated as Z: lines used to be.
*/
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void ultimate3_cmd_szline(char *mask, char *reason, char *whom)
{
send_cmd(NULL, "AKILL %s * %d %s %ld :%s", mask, 86400 * 2, whom,
(long int) time(NULL), reason);
@@ -697,61 +687,52 @@ void anope_cmd_szline(char *mask, char *reason, char *whom)
/* send_cmd(NULL, "SZLINE %s :%s", mask, reason); */
}
-void anope_cmd_svsnoop(char *server, int set)
+void ultimate3_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void ultimate3_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ ultimate3_cmd_svsnoop(server, set);
}
-void anope_cmd_sgline(char *mask, char *reason)
+void ultimate3_cmd_sgline(char *mask, char *reason)
{
send_cmd(NULL, "SGLINE %d :%s:%s", strlen(mask), mask, reason);
}
-void anope_cmd_remove_akill(char *user, char *host)
+void ultimate3_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "RAKILL %s %s", host, user);
}
-void anope_cmd_vhost_off(User * u)
+void ultimate3_cmd_vhost_off(User * u)
{
send_cmd(s_HostServ, "SVSMODE %s -x", u->nick);
notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void ultimate3_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
send_cmd(s_HostServ, "SVSMODE %s +x", nick);
send_cmd(ServerName, "SETHOST %s %s", nick, vhost);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void ultimate3_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
}
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void ultimate3_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
(long int) time(NULL), reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void ultimate3_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -760,7 +741,7 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void ultimate3_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
(long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
@@ -783,7 +764,7 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ ultimate3_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
@@ -1039,62 +1020,53 @@ int anope_event_whois(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void ultimate3_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
-void anope_cmd_372(char *source, char *msg)
+void ultimate3_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void ultimate3_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void ultimate3_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void ultimate3_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
-void anope_cmd_nick(char *nick, char *name, char *modes)
+void ultimate3_cmd_nick(char *nick, char *name, char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick,
(long int) time(NULL), modes, ServiceUser, ServiceHost,
ServerName, name);
- anope_cmd_sqline(nick, "Reserved for services");
+ ultimate3_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void ultimate3_cmd_guest_nick(char *nick, char *user, char *host,
+ char *real, char *modes)
{
send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void ultimate3_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1102,28 +1074,17 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "MODE %s %s", dest, buf);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void ultimate3_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
- anope_cmd_sqline(nick, "Reserved for services");
+ ultimate3_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void ultimate3_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1131,17 +1092,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void ultimate3_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1150,44 +1102,26 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
}
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void ultimate3_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ ultimate3_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void ultimate3_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void ultimate3_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1195,27 +1129,27 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void ultimate3_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void ultimate3_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void ultimate3_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void ultimate3_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
}
-void anope_cmd_351(char *source)
+void ultimate3_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
@@ -1223,17 +1157,8 @@ void anope_cmd_351(char *source)
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void ultimate3_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1246,33 +1171,33 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
/* PROTOCTL */
-void anope_cmd_capab()
+void ultimate3_cmd_capab()
{
send_cmd(NULL,
"CAPAB TS5 NOQUIT SSJ5 BURST UNCONNECT TSMODE NICKIP CLIENT");
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void ultimate3_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS %s :TS", pass);
}
/* SERVER name hop descript */
/* Unreal 3.2 actually sends some info about itself in the descript area */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void ultimate3_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void ultimate3_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
/* UNSQLINE */
-void anope_cmd_unsqline(char *user)
+void ultimate3_cmd_unsqline(char *user)
{
if (!user) {
return;
@@ -1281,7 +1206,7 @@ void anope_cmd_unsqline(char *user)
}
/* CHGHOST */
-void anope_cmd_chghost(char *nick, char *vhost)
+void ultimate3_cmd_chghost(char *nick, char *vhost)
{
if (!nick || !vhost) {
return;
@@ -1290,7 +1215,7 @@ void anope_cmd_chghost(char *nick, char *vhost)
}
/* CHGIDENT */
-void anope_cmd_chgident(char *nick, char *vIdent)
+void ultimate3_cmd_chgident(char *nick, char *vIdent)
{
if (!nick || !vIdent) {
return;
@@ -1299,7 +1224,7 @@ void anope_cmd_chgident(char *nick, char *vIdent)
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void ultimate3_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1309,17 +1234,8 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void ultimate3_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!nick || !chan) {
return;
@@ -1333,7 +1249,7 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void ultimate3_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1342,17 +1258,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void ultimate3_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1361,17 +1268,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void ultimate3_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1380,17 +1278,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void ultimate3_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1399,17 +1288,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void ultimate3_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1418,17 +1298,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void ultimate3_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1437,7 +1308,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void ultimate3_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1452,7 +1323,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void ultimate3_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1461,7 +1332,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void ultimate3_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1471,17 +1342,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void ultimate3_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1490,17 +1352,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void ultimate3_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1509,17 +1362,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void ultimate3_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1528,17 +1372,8 @@ void anope_cmd_211(const char *fmt, ...)
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void ultimate3_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1547,7 +1382,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* SQUIT */
-void anope_cmd_squit(char *servname, char *message)
+void ultimate3_cmd_squit(char *servname, char *message)
{
if (!servname || !message) {
return;
@@ -1557,7 +1392,7 @@ void anope_cmd_squit(char *servname, char *message)
}
/* SVSO */
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void ultimate3_cmd_svso(char *source, char *nick, char *flag)
{
if (!source || !nick || !flag) {
return;
@@ -1567,7 +1402,7 @@ void anope_cmd_svso(char *source, char *nick, char *flag)
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void ultimate3_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1577,7 +1412,7 @@ void anope_cmd_chg_nick(char *oldnick, char *newnick)
}
/* SVSNICK */
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void ultimate3_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1586,42 +1421,60 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
}
/* Functions that use serval cmd functions */
+/*
+ * SVINFO
+ * parv[0] = sender prefix
+ * parv[1] = TS_CURRENT for the server
+ * parv[2] = TS_MIN for the server
+ * parv[3] = server is standalone or connected to non-TS only
+ * parv[4] = server's idea of UTC time
+ */
+void ultimate3_cmd_svinfo()
+{
+ send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL));
+}
-void anope_cmd_connect(int servernum)
+void ultimate3_cmd_burst()
+{
+ send_cmd(NULL, "BURST");
+}
+
+
+void ultimate3_cmd_connect(int servernum)
{
me_server =
new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
if (servernum == 1) {
- anope_cmd_pass(RemotePassword);
+ ultimate3_cmd_pass(RemotePassword);
}
if (servernum == 2) {
- anope_cmd_pass(RemotePassword2);
+ ultimate3_cmd_pass(RemotePassword2);
}
if (servernum == 3) {
- anope_cmd_pass(RemotePassword3);
+ ultimate3_cmd_pass(RemotePassword3);
}
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
- anope_cmd_burst();
+ ultimate3_cmd_capab();
+ ultimate3_cmd_server(ServerName, 1, ServerDesc);
+ ultimate3_cmd_svinfo();
+ ultimate3_cmd_burst();
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void ultimate3_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void ultimate3_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void ultimate3_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick,
(unsigned long int) ts);
@@ -1629,18 +1482,18 @@ void anope_cmd_svid_umode(char *nick, time_t ts)
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void ultimate3_cmd_nc_change(User * u)
{
common_svsmode(u, "+d", "1");
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void ultimate3_cmd_svid_umode2(User * u, char *ts)
{
/* not used by bahamut ircds */
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void ultimate3_cmd_svid_umode3(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -1656,19 +1509,6 @@ int anope_event_svinfo(char *source, int ac, char **av)
return MOD_CONT;
}
-/*
- * SVINFO
- * parv[0] = sender prefix
- * parv[1] = TS_CURRENT for the server
- * parv[2] = TS_MIN for the server
- * parv[3] = server is standalone or connected to non-TS only
- * parv[4] = server's idea of UTC time
- */
-void anope_cmd_svinfo()
-{
- send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL));
-}
-
int anope_event_pass(char *source, int ac, char **av)
{
/* currently not used but removes the message : unknown message from server */
@@ -1699,32 +1539,27 @@ int anope_event_sqline(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void ultimate3_cmd_svsjoin(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void ultimate3_cmd_svspart(char *source, char *nick, char *chan)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void ultimate3_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
-void anope_cmd_eob()
+void ultimate3_cmd_eob()
{
send_cmd(NULL, "BURST 0");
}
-void anope_cmd_burst()
-{
- send_cmd(NULL, "BURST");
-}
-
int anope_event_error(char *source, int ac, char **av)
{
if (ac >= 1) {
@@ -1798,25 +1633,25 @@ int anope_event_invite(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int ultiamte3_flood_mode_check(char *value)
{
return 0;
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void ultimate3_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ ultimate3_cmd_squit(jserver, rbuf);
+ ultimate3_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void ultimate3_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
}
@@ -1825,24 +1660,16 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int ultiamte3_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void ultimate3_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1853,4 +1680,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(ultimate3_cmd_svsnoop);
+ pmodule_cmd_remove_akill(ultimate3_cmd_remove_akill);
+ pmodule_cmd_topic(ultimate3_cmd_topic);
+ pmodule_cmd_vhost_off(ultimate3_cmd_vhost_off);
+ pmodule_cmd_akill(ultimate3_cmd_akill);
+ pmodule_cmd_svskill(ultimate3_cmd_svskill);
+ pmodule_cmd_svsmode(ultimate3_cmd_svsmode);
+ pmodule_cmd_372(ultimate3_cmd_372);
+ pmodule_cmd_372_error(ultimate3_cmd_372_error);
+ pmodule_cmd_375(ultimate3_cmd_375);
+ pmodule_cmd_376(ultimate3_cmd_376);
+ pmodule_cmd_nick(ultimate3_cmd_nick);
+ pmodule_cmd_guest_nick(ultimate3_cmd_guest_nick);
+ pmodule_cmd_mode(ultimate3_cmd_mode);
+ pmodule_cmd_bot_nick(ultimate3_cmd_bot_nick);
+ pmodule_cmd_kick(ultimate3_cmd_kick);
+ pmodule_cmd_notice_ops(ultimate3_cmd_notice_ops);
+ pmodule_cmd_notice(ultimate3_cmd_notice);
+ pmodule_cmd_notice2(ultimate3_cmd_notice2);
+ pmodule_cmd_privmsg(ultimate3_cmd_privmsg);
+ pmodule_cmd_privmsg2(ultimate3_cmd_privmsg2);
+ pmodule_cmd_serv_notice(ultimate3_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(ultimate3_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(ultimate3_cmd_bot_chan_mode);
+ pmodule_cmd_351(ultimate3_cmd_351);
+ pmodule_cmd_quit(ultimate3_cmd_quit);
+ pmodule_cmd_pong(ultimate3_cmd_pong);
+ pmodule_cmd_join(ultimate3_cmd_join);
+ pmodule_cmd_unsqline(ultimate3_cmd_unsqline);
+ pmodule_cmd_invite(ultimate3_cmd_invite);
+ pmodule_cmd_part(ultimate3_cmd_part);
+ pmodule_cmd_391(ultimate3_cmd_391);
+ pmodule_cmd_250(ultimate3_cmd_250);
+ pmodule_cmd_307(ultimate3_cmd_307);
+ pmodule_cmd_311(ultimate3_cmd_311);
+ pmodule_cmd_312(ultimate3_cmd_312);
+ pmodule_cmd_317(ultimate3_cmd_317);
+ pmodule_cmd_219(ultimate3_cmd_219);
+ pmodule_cmd_401(ultimate3_cmd_401);
+ pmodule_cmd_318(ultimate3_cmd_318);
+ pmodule_cmd_242(ultimate3_cmd_242);
+ pmodule_cmd_243(ultimate3_cmd_243);
+ pmodule_cmd_211(ultimate3_cmd_211);
+ pmodule_cmd_global(ultimate3_cmd_global);
+ pmodule_cmd_global_legacy(ultimate3_cmd_global_legacy);
+ pmodule_cmd_sqline(ultimate3_cmd_sqline);
+ pmodule_cmd_squit(ultimate3_cmd_squit);
+ pmodule_cmd_svso(ultimate3_cmd_svso);
+ pmodule_cmd_chg_nick(ultimate3_cmd_chg_nick);
+ pmodule_cmd_svsnick(ultimate3_cmd_svsnick);
+ pmodule_cmd_vhost_on(ultimate3_cmd_vhost_on);
+ pmodule_cmd_connect(ultimate3_cmd_connect);
+ pmodule_cmd_svshold(ultimate3_cmd_svshold);
+ pmodule_cmd_release_svshold(ultimate3_cmd_release_svshold);
+ pmodule_cmd_unsgline(ultimate3_cmd_unsqline);
+ pmodule_cmd_unszline(ultimate3_cmd_unszline);
+ pmodule_cmd_szline(ultimate3_cmd_szline);
+ pmodule_cmd_sgline(ultimate3_cmd_sgline);
+ pmodule_cmd_unban(ultimate3_cmd_unban);
+ pmodule_cmd_svsmode_chan(ultimate3_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(ultimate3_cmd_svid_umode);
+ pmodule_cmd_nc_change(ultimate3_cmd_nc_change);
+ pmodule_cmd_svid_umode2(ultimate3_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(ultimate3_cmd_svid_umode3);
+ pmodule_cmd_eob(ultimate3_cmd_eob);
+ pmodule_flood_mode_check(ultiamte3_flood_mode_check);
+ pmodule_cmd_jupe(ultimate3_cmd_jupe);
+ pmodule_valid_nick(ultiamte3_valid_nick);
+ pmodule_cmd_ctcp(ultimate3_cmd_ctcp);
+ pmodule_set_umode(ultimate3_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("UltimateIRCd 3.0.0.a26+");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("");
+ pmodule_ircd_flood_mode_char_remove("");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/ultimate3.h b/src/protocol/ultimate3.h
new file mode 100644
index 000000000..6acced7f2
--- /dev/null
+++ b/src/protocol/ultimate3.h
@@ -0,0 +1,125 @@
+/* Ultimate IRCD 3.0 functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+#define UMODE_a 0x00000001
+#define UMODE_h 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_r 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_A 0x00000040
+#define UMODE_0 0x00000080
+#define UMODE_Z 0x00000100 /* umode +Z - Services Root Admin */
+#define UMODE_S 0x00000200 /* umode +S - Services Client */
+#define UMODE_D 0x00000400 /* umode +D - has seen dcc warning message */
+#define UMODE_d 0x00000800 /* umode +d - user is deaf to channel messages */
+#define UMODE_W 0x00001000 /* umode +d - user is deaf to channel messages */
+#define UMODE_p 0x04000000
+#define UMODE_P 0x20000000 /* umode +P - Services Admin */
+#define UMODE_x 0x40000000
+#define UMODE_R 0x80000000
+
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+#define CMODE_c 0x00000400 /* Colors can't be used */
+#define CMODE_A 0x00000800
+#define CMODE_N 0x00001000
+#define CMODE_S 0x00002000
+#define CMODE_K 0x00004000
+#define CMODE_O 0x00008000 /* Only opers can join */
+#define CMODE_q 0x00010000 /* No Quit Reason */
+#define CMODE_M 0x00020000 /* Non-regged nicks can't send messages */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void ultimate3_set_umode(User * user, int ac, char **av);
+void ultimate3_cmd_svsnoop(char *server, int set);
+void ultimate3_cmd_remove_akill(char *user, char *host);
+void ultimate3_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void ultimate3_cmd_vhost_off(User * u);
+void ultimate3_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void ultimate3_cmd_svskill(char *source, char *user, char *buf);
+void ultimate3_cmd_svsmode(User * u, int ac, char **av);
+void ultimate3_cmd_372(char *source, char *msg);
+void ultimate3_cmd_372_error(char *source);
+void ultimate3_cmd_375(char *source);
+void ultimate3_cmd_376(char *source);
+void ultimate3_cmd_nick(char *nick, char *name, char *modes);
+void ultimate3_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void ultimate3_cmd_mode(char *source, char *dest, char *buf);
+void ultimate3_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void ultimate3_cmd_kick(char *source, char *chan, char *user, char *buf);
+void ultimate3_cmd_notice_ops(char *source, char *dest, char *buf);
+void ultimate3_cmd_notice(char *source, char *dest, char *buf);
+void ultimate3_cmd_notice2(char *source, char *dest, char *msg);
+void ultimate3_cmd_privmsg(char *source, char *dest, char *buf);
+void ultimate3_cmd_privmsg2(char *source, char *dest, char *msg);
+void ultimate3_cmd_serv_notice(char *source, char *dest, char *msg);
+void ultimate3_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void ultimate3_cmd_bot_chan_mode(char *nick, char *chan);
+void ultimate3_cmd_351(char *source);
+void ultimate3_cmd_quit(char *source, char *buf);
+void ultimate3_cmd_pong(char *servname, char *who);
+void ultimate3_cmd_join(char *user, char *channel, time_t chantime);
+void ultimate3_cmd_unsqline(char *user);
+void ultimate3_cmd_invite(char *source, char *chan, char *nick);
+void ultimate3_cmd_part(char *nick, char *chan, char *buf);
+void ultimate3_cmd_391(char *source, char *timestr);
+void ultimate3_cmd_250(char *buf);
+void ultimate3_cmd_307(char *buf);
+void ultimate3_cmd_311(char *buf);
+void ultimate3_cmd_312(char *buf);
+void ultimate3_cmd_317(char *buf);
+void ultimate3_cmd_219(char *source, char *letter);
+void ultimate3_cmd_401(char *source, char *who);
+void ultimate3_cmd_318(char *source, char *who);
+void ultimate3_cmd_242(char *buf);
+void ultimate3_cmd_243(char *buf);
+void ultimate3_cmd_211(char *buf);
+void ultimate3_cmd_global(char *source, char *buf);
+void ultimate3_cmd_global_legacy(char *source, char *fmt);
+void ultimate3_cmd_sqline(char *mask, char *reason);
+void ultimate3_cmd_squit(char *servname, char *message);
+void ultimate3_cmd_svso(char *source, char *nick, char *flag);
+void ultimate3_cmd_chg_nick(char *oldnick, char *newnick);
+void ultimate3_cmd_svsnick(char *source, char *guest, time_t when);
+void ultimate3_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void ultimate3_cmd_connect(int servernum);
+void ultimate3_cmd_svshold(char *nick);
+void ultimate3_cmd_release_svshold(char *nick);
+void ultimate3_cmd_unsgline(char *mask);
+void ultimate3_cmd_unszline(char *mask);
+void ultimate3_cmd_szline(char *mask, char *reason, char *whom);
+void ultimate3_cmd_sgline(char *mask, char *reason);
+void ultimate3_cmd_unban(char *name, char *nick);
+void ultimate3_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void ultimate3_cmd_svid_umode(char *nick, time_t ts);
+void ultimate3_cmd_nc_change(User * u);
+void ultimate3_cmd_svid_umode2(User * u, char *ts);
+void ultimate3_cmd_svid_umode3(User * u, char *ts);
+void ultimate3_cmd_eob();
+int ultimate3_flood_mode_check(char *value);
+void ultimate3_cmd_jupe(char *jserver, char *who, char *reason);
+int ultimate3_valid_nick(char *nick);
+void ultimate3_cmd_ctcp(char *source, char *dest, char *buf);
+
+
diff --git a/src/unreal31.c b/src/protocol/unreal31.c
index d8db1d259..4af96c5a3 100644
--- a/src/unreal31.c
+++ b/src/protocol/unreal31.c
@@ -15,18 +15,9 @@
#include "services.h"
#include "pseudo.h"
+#include "unreal31.h"
-#ifdef IRC_UNREAL31
-
-const char version_protocol[] = "UnrealIRCd 3.1.1+";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = "+f"; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = "-f"; /* mode char for FLOOD mode on remove */
-
-int UseTSMODE = 0;
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"UnrealIRCd 3.1.x", /* ircd name */
"+oS", /* nickserv mode */
"+oS", /* chanserv mode */
@@ -87,7 +78,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
1, /* Change RealName */
- CHAN_HELP_UNREAL, /* ChanServ extra */
CMODE_K, /* No Knock */
CMODE_A, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -114,12 +104,13 @@ IRCDVar ircd[] = {
0, /* p10 */
NULL, /* character set */
0, /* reports sync state */
- },
+ }
+ ,
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
0, /* TSMODE */
@@ -177,7 +168,7 @@ unsigned long umodes[128] = {
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -199,7 +190,7 @@ char csmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
@@ -227,7 +218,7 @@ CMMode cmmodes[128] = {
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -293,7 +284,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'f', CMODE_f, 0, get_flood, cs_get_flood},
{'i', CMODE_i, 0, NULL, NULL},
@@ -322,7 +313,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -370,7 +361,7 @@ CUMode cumodes[128] = {
};
-void anope_set_umode(User * user, int ac, char **av)
+void unreal_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -492,52 +483,43 @@ int anope_event_capab(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_svsnoop(char *server, int set)
+void unreal_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void unreal_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ unreal_cmd_svsnoop(server, set);
}
-void anope_cmd_remove_akill(char *user, char *host)
+void unreal_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "TKL - G %s %s %s", user, host, s_OperServ);
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void unreal_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
-void anope_cmd_vhost_off(User * u)
+void unreal_cmd_vhost_off(User * u)
{
send_cmd(s_HostServ, "SVSMODE %s -xt", u->nick);
notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
}
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void unreal_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "TKL + G %s %s %s %ld %ld :%s", user, host, who,
(long int) time(NULL) + 86400 * 2, (long int) when, reason);
}
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void unreal_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -546,69 +528,56 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
return;
}
- va_start(args, fmt);
- vsnprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
-
send_cmd(source, "SVSKILL %s :%s", user, buf);
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void unreal_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0],
(ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
}
-void anope_cmd_372(char *source, char *msg)
+void unreal_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void unreal_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void unreal_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void unreal_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
-void anope_cmd_nick(char *nick, char *name, char *modes)
+void unreal_cmd_nick(char *nick, char *name, char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick,
(long int) time(NULL), ServiceUser, ServiceHost, ServerName,
modes, name);
- anope_cmd_sqline(nick, "Reserved for services");
+ unreal_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void unreal_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick,
(long int) time(NULL), user, host, ServerName, modes, real);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -616,28 +585,17 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "MODE %s %s", dest, buf);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void unreal_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick,
(long int) time(NULL), user, host, ServerName, modes, real);
- anope_cmd_sqline(nick, "Reserved for services");
+ unreal_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void unreal_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -645,17 +603,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -664,44 +613,26 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
}
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ unreal_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void unreal_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -709,28 +640,28 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void unreal_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void unreal_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void unreal_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void unreal_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
}
-void anope_cmd_351(char *source)
+void unreal_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
@@ -738,18 +669,8 @@ void anope_cmd_351(char *source)
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void unreal_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -758,7 +679,7 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
}
/* PROTOCTL */
-void anope_cmd_protoctl()
+void unreal_cmd_protoctl()
{
/*
See Unreal's protoctl.txt for reference
@@ -768,20 +689,20 @@ void anope_cmd_protoctl()
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void unreal_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS :%s", pass);
}
/* SERVER name hop descript */
/* Unreal 3.2 actually sends some info about itself in the descript area */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void unreal_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void unreal_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
@@ -789,13 +710,13 @@ void anope_cmd_pong(char *servname, char *who)
/* JOIN */
/* Althought Unreal 3.2 does not need the timestamp others do so
we get it in the common function call */
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void unreal_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(user, "JOIN %s", channel);
}
/* UNSQLINE */
-void anope_cmd_unsqline(char *user)
+void unreal_cmd_unsqline(char *user)
{
if (!user) {
return;
@@ -804,7 +725,7 @@ void anope_cmd_unsqline(char *user)
}
/* CHGHOST */
-void anope_cmd_chghost(char *nick, char *vhost)
+void unreal_cmd_chghost(char *nick, char *vhost)
{
if (!nick || !vhost) {
return;
@@ -813,7 +734,7 @@ void anope_cmd_chghost(char *nick, char *vhost)
}
/* CHGIDENT */
-void anope_cmd_chgident(char *nick, char *vIdent)
+void unreal_cmd_chgident(char *nick, char *vIdent)
{
if (!nick || !vIdent) {
return;
@@ -822,7 +743,7 @@ void anope_cmd_chgident(char *nick, char *vIdent)
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void unreal_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -832,18 +753,8 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void unreal_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!nick || !chan) {
return;
}
@@ -856,7 +767,7 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void unreal_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -865,17 +776,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void unreal_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -884,17 +786,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void unreal_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -903,17 +796,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void unreal_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -922,17 +806,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void unreal_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -941,17 +816,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void unreal_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -960,7 +826,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void unreal_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -975,7 +841,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void unreal_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -984,7 +850,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void unreal_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -994,17 +860,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void unreal_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1013,17 +870,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void unreal_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1032,17 +880,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void unreal_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1051,17 +890,8 @@ void anope_cmd_211(const char *fmt, ...)
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void unreal_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1070,7 +900,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* SQLINE */
-void anope_cmd_sqline(char *mask, char *reason)
+void unreal_cmd_sqline(char *mask, char *reason)
{
if (!mask || !reason) {
return;
@@ -1080,7 +910,7 @@ void anope_cmd_sqline(char *mask, char *reason)
}
/* SQUIT */
-void anope_cmd_squit(char *servname, char *message)
+void unreal_cmd_squit(char *servname, char *message)
{
if (!servname || !message) {
return;
@@ -1090,7 +920,7 @@ void anope_cmd_squit(char *servname, char *message)
}
/* SVSO */
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void unreal_cmd_svso(char *source, char *nick, char *flag)
{
if (!source || !nick || !flag) {
return;
@@ -1100,7 +930,7 @@ void anope_cmd_svso(char *source, char *nick, char *flag)
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void unreal_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1110,7 +940,7 @@ void anope_cmd_chg_nick(char *oldnick, char *newnick)
}
/* SVSNICK */
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void unreal_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1120,33 +950,33 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
/* Functions that use serval cmd functions */
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void unreal_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
if (!nick) {
return;
}
if (vIdent) {
- anope_cmd_chgident(nick, vIdent);
+ unreal_cmd_chgident(nick, vIdent);
}
- anope_cmd_chghost(nick, vhost);
+ unreal_cmd_chghost(nick, vhost);
}
-void anope_cmd_connect(int servernum)
+void unreal_cmd_connect(int servernum)
{
me_server =
new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
- anope_cmd_protoctl();
+ unreal_cmd_protoctl();
if (servernum == 1) {
- anope_cmd_pass(RemotePassword);
+ unreal_cmd_pass(RemotePassword);
}
if (servernum == 2) {
- anope_cmd_pass(RemotePassword2);
+ unreal_cmd_pass(RemotePassword2);
}
if (servernum == 3) {
- anope_cmd_pass(RemotePassword3);
+ unreal_cmd_pass(RemotePassword3);
}
- anope_cmd_server(ServerName, 1, ServerDesc);
+ unreal_cmd_server(ServerName, 1, ServerDesc);
}
/* Events */
@@ -1155,7 +985,7 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ unreal_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
@@ -1436,32 +1266,32 @@ int anope_event_whois(char *source, int ac, char **av)
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void unreal_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void unreal_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* UNSGLINE */
-void anope_cmd_unsgline(char *mask)
+void unreal_cmd_unsgline(char *mask)
{
/* Not Supported by this IRCD */
}
/* UNSZLINE */
-void anope_cmd_unszline(char *mask)
+void unreal_cmd_unszline(char *mask)
{
send_cmd(NULL, "%s - Z * %s %s", send_token("TKL", "BD"), mask,
s_OperServ);
}
/* SZLINE */
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void unreal_cmd_szline(char *mask, char *reason, char *whom)
{
send_cmd(NULL, "%s + Z * %s %s %ld %ld :%s", send_token("TKL", "BD"),
mask, whom, (long int) time(NULL) + 86400 * 2,
@@ -1469,19 +1299,19 @@ void anope_cmd_szline(char *mask, char *reason, char *whom)
}
/* SGLINE */
-void anope_cmd_sgline(char *mask, char *reason)
+void unreal_cmd_sgline(char *mask, char *reason)
{
/* Not Supported by this IRCD */
}
-void anope_cmd_unban(char *name, char *nick)
+void unreal_cmd_unban(char *name, char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void unreal_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
/* Not Supported by this IRCD */
}
@@ -1489,20 +1319,20 @@ void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void unreal_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s +d 1", nick);
}
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void unreal_cmd_nc_change(User * u)
{
common_svsmode(u, "-r+d", "1");
}
/* SVSMODE +r */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void unreal_cmd_svid_umode2(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -1511,7 +1341,7 @@ void anope_cmd_svid_umode2(User * u, char *ts)
}
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void unreal_cmd_svid_umode3(User * u, char *ts)
{
/* not used */
}
@@ -1521,7 +1351,7 @@ void anope_cmd_svid_umode3(User * u, char *ts)
parv[1] - nick to make join
parv[2] - channel(s) to join
*/
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void unreal_cmd_svsjoin(char *source, char *nick, char *chan)
{
send_cmd(source, "SVSJOIN %s :%s", nick, chan);
}
@@ -1531,17 +1361,17 @@ void anope_cmd_svsjoin(char *source, char *nick, char *chan)
parv[1] - nick to make part
parv[2] - channel(s) to part
*/
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void unreal_cmd_svspart(char *source, char *nick, char *chan)
{
send_cmd(source, "SVSPART %s :%s", nick, chan);
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void unreal_cmd_swhois(char *source, char *who, char *mask)
{
/* Can anyone tell me if 3.1 has this? */
}
-void anope_cmd_eob()
+void unreal_cmd_eob()
{
/* Can anyone tell me if 3.1 has this? */
}
@@ -1562,7 +1392,7 @@ int anope_event_admin(char *source, int ac, char **av)
return MOD_CONT;
}
-int anope_flood_mode_check(char *value)
+int unreal_flood_mode_check(char *value)
{
char *dp, *end;
@@ -1576,20 +1406,20 @@ int anope_flood_mode_check(char *value)
}
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void unreal_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ unreal_cmd_squit(jserver, rbuf);
+ unreal_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void unreal_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "%s :%s",
send_token("GLOBOPS", "]"), fmt);
@@ -1599,7 +1429,7 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int unreal_valid_nick(char *nick)
{
if (!stricmp("ircd", nick)) {
return 0;
@@ -1610,18 +1440,10 @@ int anope_valid_nick(char *nick)
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1632,4 +1454,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(unreal_cmd_svsnoop);
+ pmodule_cmd_remove_akill(unreal_cmd_remove_akill);
+ pmodule_cmd_topic(unreal_cmd_topic);
+ pmodule_cmd_vhost_off(unreal_cmd_vhost_off);
+ pmodule_cmd_akill(unreal_cmd_akill);
+ pmodule_cmd_svskill(unreal_cmd_svskill);
+ pmodule_cmd_svsmode(unreal_cmd_svsmode);
+ pmodule_cmd_372(unreal_cmd_372);
+ pmodule_cmd_372_error(unreal_cmd_372_error);
+ pmodule_cmd_375(unreal_cmd_375);
+ pmodule_cmd_376(unreal_cmd_376);
+ pmodule_cmd_nick(unreal_cmd_nick);
+ pmodule_cmd_guest_nick(unreal_cmd_guest_nick);
+ pmodule_cmd_mode(unreal_cmd_mode);
+ pmodule_cmd_bot_nick(unreal_cmd_bot_nick);
+ pmodule_cmd_kick(unreal_cmd_kick);
+ pmodule_cmd_notice_ops(unreal_cmd_notice_ops);
+ pmodule_cmd_notice(unreal_cmd_notice);
+ pmodule_cmd_notice2(unreal_cmd_notice2);
+ pmodule_cmd_privmsg(unreal_cmd_privmsg);
+ pmodule_cmd_privmsg2(unreal_cmd_privmsg2);
+ pmodule_cmd_serv_notice(unreal_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(unreal_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(unreal_cmd_bot_chan_mode);
+ pmodule_cmd_351(unreal_cmd_351);
+ pmodule_cmd_quit(unreal_cmd_quit);
+ pmodule_cmd_pong(unreal_cmd_pong);
+ pmodule_cmd_join(unreal_cmd_join);
+ pmodule_cmd_unsqline(unreal_cmd_unsqline);
+ pmodule_cmd_invite(unreal_cmd_invite);
+ pmodule_cmd_part(unreal_cmd_part);
+ pmodule_cmd_391(unreal_cmd_391);
+ pmodule_cmd_250(unreal_cmd_250);
+ pmodule_cmd_307(unreal_cmd_307);
+ pmodule_cmd_311(unreal_cmd_311);
+ pmodule_cmd_312(unreal_cmd_312);
+ pmodule_cmd_317(unreal_cmd_317);
+ pmodule_cmd_219(unreal_cmd_219);
+ pmodule_cmd_401(unreal_cmd_401);
+ pmodule_cmd_318(unreal_cmd_318);
+ pmodule_cmd_242(unreal_cmd_242);
+ pmodule_cmd_243(unreal_cmd_243);
+ pmodule_cmd_211(unreal_cmd_211);
+ pmodule_cmd_global(unreal_cmd_global);
+ pmodule_cmd_global_legacy(unreal_cmd_global_legacy);
+ pmodule_cmd_sqline(unreal_cmd_sqline);
+ pmodule_cmd_squit(unreal_cmd_squit);
+ pmodule_cmd_svso(unreal_cmd_svso);
+ pmodule_cmd_chg_nick(unreal_cmd_chg_nick);
+ pmodule_cmd_svsnick(unreal_cmd_svsnick);
+ pmodule_cmd_vhost_on(unreal_cmd_vhost_on);
+ pmodule_cmd_connect(unreal_cmd_connect);
+ pmodule_cmd_svshold(unreal_cmd_svshold);
+ pmodule_cmd_release_svshold(unreal_cmd_release_svshold);
+ pmodule_cmd_unsgline(unreal_cmd_unsqline);
+ pmodule_cmd_unszline(unreal_cmd_unszline);
+ pmodule_cmd_szline(unreal_cmd_szline);
+ pmodule_cmd_sgline(unreal_cmd_sgline);
+ pmodule_cmd_unban(unreal_cmd_unban);
+ pmodule_cmd_svsmode_chan(unreal_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(unreal_cmd_svid_umode);
+ pmodule_cmd_nc_change(unreal_cmd_nc_change);
+ pmodule_cmd_svid_umode2(unreal_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(unreal_cmd_svid_umode3);
+ pmodule_cmd_eob(unreal_cmd_eob);
+ pmodule_flood_mode_check(unreal_flood_mode_check);
+ pmodule_cmd_jupe(unreal_cmd_jupe);
+ pmodule_valid_nick(unreal_valid_nick);
+ pmodule_cmd_ctcp(unreal_cmd_ctcp);
+ pmodule_set_umode(unreal_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("UnrealIRCd 3.1.1+");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("+f");
+ pmodule_ircd_flood_mode_char_remove("-f");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/unreal31.h b/src/protocol/unreal31.h
new file mode 100644
index 000000000..f2ed19503
--- /dev/null
+++ b/src/protocol/unreal31.h
@@ -0,0 +1,124 @@
+/* Unreal IRCD 3.1.x functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+/*************************************************************************/
+
+#define UMODE_a 0x00000001
+#define UMODE_h 0x00000002
+#define UMODE_i 0x00000004
+#define UMODE_o 0x00000008
+#define UMODE_r 0x00000010
+#define UMODE_w 0x00000020
+#define UMODE_A 0x00000040
+#define UMODE_g 0x80000000
+#define UMODE_x 0x40000000
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_c 0x00000400
+#define CMODE_A 0x00000800
+#define CMODE_H 0x00001000
+#define CMODE_K 0x00002000
+#define CMODE_L 0x00004000
+#define CMODE_O 0x00008000
+#define CMODE_Q 0x00010000
+#define CMODE_S 0x00020000
+#define CMODE_V 0x00040000
+#define CMODE_f 0x00080000
+#define CMODE_G 0x00100000
+#define CMODE_C 0x00200000
+#define CMODE_u 0x00400000
+#define CMODE_z 0x00800000
+#define CMODE_N 0x01000000
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void unreal_set_umode(User * user, int ac, char **av);
+void unreal_cmd_svsnoop(char *server, int set);
+void unreal_cmd_remove_akill(char *user, char *host);
+void unreal_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void unreal_cmd_vhost_off(User * u);
+void unreal_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void unreal_cmd_svskill(char *source, char *user, char *buf);
+void unreal_cmd_svsmode(User * u, int ac, char **av);
+void unreal_cmd_372(char *source, char *msg);
+void unreal_cmd_372_error(char *source);
+void unreal_cmd_375(char *source);
+void unreal_cmd_376(char *source);
+void unreal_cmd_nick(char *nick, char *name, char *modes);
+void unreal_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void unreal_cmd_mode(char *source, char *dest, char *buf);
+void unreal_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void unreal_cmd_kick(char *source, char *chan, char *user, char *buf);
+void unreal_cmd_notice_ops(char *source, char *dest, char *buf);
+void unreal_cmd_notice(char *source, char *dest, char *buf);
+void unreal_cmd_notice2(char *source, char *dest, char *msg);
+void unreal_cmd_privmsg(char *source, char *dest, char *buf);
+void unreal_cmd_privmsg2(char *source, char *dest, char *msg);
+void unreal_cmd_serv_notice(char *source, char *dest, char *msg);
+void unreal_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void unreal_cmd_bot_chan_mode(char *nick, char *chan);
+void unreal_cmd_351(char *source);
+void unreal_cmd_quit(char *source, char *buf);
+void unreal_cmd_pong(char *servname, char *who);
+void unreal_cmd_join(char *user, char *channel, time_t chantime);
+void unreal_cmd_unsqline(char *user);
+void unreal_cmd_invite(char *source, char *chan, char *nick);
+void unreal_cmd_part(char *nick, char *chan, char *buf);
+void unreal_cmd_391(char *source, char *timestr);
+void unreal_cmd_250(char *buf);
+void unreal_cmd_307(char *buf);
+void unreal_cmd_311(char *buf);
+void unreal_cmd_312(char *buf);
+void unreal_cmd_317(char *buf);
+void unreal_cmd_219(char *source, char *letter);
+void unreal_cmd_401(char *source, char *who);
+void unreal_cmd_318(char *source, char *who);
+void unreal_cmd_242(char *buf);
+void unreal_cmd_243(char *buf);
+void unreal_cmd_211(char *buf);
+void unreal_cmd_global(char *source, char *buf);
+void unreal_cmd_global_legacy(char *source, char *fmt);
+void unreal_cmd_sqline(char *mask, char *reason);
+void unreal_cmd_squit(char *servname, char *message);
+void unreal_cmd_svso(char *source, char *nick, char *flag);
+void unreal_cmd_chg_nick(char *oldnick, char *newnick);
+void unreal_cmd_svsnick(char *source, char *guest, time_t when);
+void unreal_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void unreal_cmd_connect(int servernum);
+void unreal_cmd_svshold(char *nick);
+void unreal_cmd_release_svshold(char *nick);
+void unreal_cmd_unsgline(char *mask);
+void unreal_cmd_unszline(char *mask);
+void unreal_cmd_szline(char *mask, char *reason, char *whom);
+void unreal_cmd_sgline(char *mask, char *reason);
+void unreal_cmd_unban(char *name, char *nick);
+void unreal_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void unreal_cmd_svid_umode(char *nick, time_t ts);
+void unreal_cmd_nc_change(User * u);
+void unreal_cmd_svid_umode2(User * u, char *ts);
+void unreal_cmd_svid_umode3(User * u, char *ts);
+void unreal_cmd_eob();
+int unreal_flood_mode_check(char *value);
+void unreal_cmd_jupe(char *jserver, char *who, char *reason);
+int unreal_valid_nick(char *nick);
+void unreal_cmd_ctcp(char *source, char *dest, char *buf);
+
diff --git a/src/unreal32.c b/src/protocol/unreal32.c
index 13b868f37..5790cb5f6 100644
--- a/src/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -15,17 +15,9 @@
#include "services.h"
#include "pseudo.h"
+#include "unreal32.h"
-#ifdef IRC_UNREAL32
-
-const char version_protocol[] = "UnrealIRCd 3.2+";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = "+f"; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = "-f"; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0;
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"UnrealIRCd 3.2.x", /* ircd name */
"+oS", /* nickserv mode */
"+oS", /* chanserv mode */
@@ -86,7 +78,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
1, /* Change RealName */
- CHAN_HELP_UNREAL, /* ChanServ extra */
CMODE_K, /* No Knock */
CMODE_A, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -113,11 +104,12 @@ IRCDVar ircd[] = {
0, /* p10 */
NULL, /* character set */
1, /* reports sync state */
- },
+ }
+ ,
{NULL}
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
0, /* TSMODE */
@@ -205,7 +197,7 @@ unsigned long umodes[128] = {
0, 0 /* ~ ‚ */
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -227,7 +219,7 @@ char csmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL},
@@ -274,7 +266,7 @@ CMMode cmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
};
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -340,7 +332,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'f', CMODE_f, 0, get_flood, cs_get_flood},
{'i', CMODE_i, 0, NULL, NULL},
@@ -370,7 +362,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -418,7 +410,7 @@ CUMode cumodes[128] = {
};
-void anope_set_umode(User * user, int ac, char **av)
+void unreal_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -482,264 +474,7 @@ void anope_set_umode(User * user, int ac, char **av)
}
}
-/* *INDENT-OFF* */
-void moduleAddIRCDMsgs(void) {
- Message *m;
- updateProtectDetails("PROTECT","PROTECTME","!protect","!deprotect","AUTOPROTECT","+a","-a");
-
- m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m);
- m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m);
- m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
- m = createMessage("451", anope_event_null); addCoreMessage(IRCD,m);
- m = createMessage("461", anope_event_null); addCoreMessage(IRCD,m);
- m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("6", anope_event_away); addCoreMessage(IRCD,m);
- }
- m = createMessage("INVITE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("*", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("C", anope_event_join); addCoreMessage(IRCD,m);
- }
- m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("H", anope_event_kick); addCoreMessage(IRCD,m);
- }
- m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage(".", anope_event_kill); addCoreMessage(IRCD,m);
- }
- m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("G", anope_event_mode); addCoreMessage(IRCD,m);
- }
- m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("F", anope_event_motd); addCoreMessage(IRCD,m);
- }
- m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("&", anope_event_nick); addCoreMessage(IRCD,m);
- }
- m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("B", anope_event_notice); addCoreMessage(IRCD,m);
- }
- m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("D", anope_event_part); addCoreMessage(IRCD,m);
- }
- m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("8", anope_event_ping); addCoreMessage(IRCD,m);
- }
- m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("!", anope_event_privmsg); addCoreMessage(IRCD,m);
- }
- m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage(",", anope_event_quit); addCoreMessage(IRCD,m);
- }
- m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("'", anope_event_server); addCoreMessage(IRCD,m);
- }
- m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("-", anope_event_squit); addCoreMessage(IRCD,m);
- }
- m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage(")", anope_event_topic); addCoreMessage(IRCD,m);
- }
- m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("%", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("=", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("#", anope_event_whois); addCoreMessage(IRCD,m);
- }
- m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("V", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("GLOBOPS", anope_event_globops); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("]", anope_event_globops); addCoreMessage(IRCD,m);
- }
- m = createMessage("GNOTICE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("Z", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("[", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("Y", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("U", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("h", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SVSMODE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("n", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SVS2MODE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("v", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("e", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("f", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SQLINE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("c", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("d", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("_", anope_event_capab); addCoreMessage(IRCD,m);
- }
- m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AL", anope_event_chghost); addCoreMessage(IRCD,m);
- }
- m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AZ", anope_event_chgident); addCoreMessage(IRCD,m);
- }
- m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("BK", anope_event_chgname); addCoreMessage(IRCD,m);
- }
- m = createMessage("NETINFO", anope_event_netinfo); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AO", anope_event_netinfo); addCoreMessage(IRCD,m);
- }
- m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AA", anope_event_sethost); addCoreMessage(IRCD,m);
- }
- m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AD", anope_event_setident); addCoreMessage(IRCD,m);
- }
- m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AE", anope_event_setname); addCoreMessage(IRCD,m);
- }
- m = createMessage("TKL", anope_event_tkl); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("BD", anope_event_tkl); addCoreMessage(IRCD,m);
- }
- m = createMessage("EOS", anope_event_eos); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("ES", anope_event_eos); addCoreMessage(IRCD,m);
- }
- m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("<", anope_event_pass); addCoreMessage(IRCD,m);
- }
- m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("5", anope_event_error); addCoreMessage(IRCD,m);
- }
- m = createMessage("SMO", anope_event_smo); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AU", anope_event_smo); addCoreMessage(IRCD,m);
- }
- m = createMessage("UMODE2", anope_event_umode2); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("|", anope_event_umode2); addCoreMessage(IRCD,m);
- }
- m = createMessage("SWHOIS", anope_event_swhois); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("BA", anope_event_swhois); addCoreMessage(IRCD,m);
- }
- m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("~", anope_event_sjoin); addCoreMessage(IRCD,m);
- }
- m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("O", anope_event_rehash); addCoreMessage(IRCD,m);
- }
- m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("@", anope_event_admin); addCoreMessage(IRCD,m);
- }
- m = createMessage("CREDITS", anope_event_credits); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AJ", anope_event_credits); addCoreMessage(IRCD,m);
- }
- m = createMessage("SDESC", anope_event_sdesc); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AG", anope_event_sdesc); addCoreMessage(IRCD,m);
- }
- m = createMessage("HTM", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("BH", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("HELP", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("4", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("TRACE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("b", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("LAG", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AF", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("RPING", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AM", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SENDSNO", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("Ss", anope_event_null); addCoreMessage(IRCD,m);
- }
- m = createMessage("SENDUMODE", anope_event_null); addCoreMessage(IRCD,m);
- if (UseTokens) {
- m = createMessage("AP", anope_event_null); addCoreMessage(IRCD,m);
- }
-
-
- /* The none token version of these is in messages.c */
- if (UseTokens) {
- m = createMessage("2", m_stats); addCoreMessage(IRCD,m);
- m = createMessage(">", m_time); addCoreMessage(IRCD,m);
- m = createMessage("+", m_version); addCoreMessage(IRCD,m);
- }
-}
-
-/* *INDENT-ON* */
/* Event: PROTOCTL */
@@ -750,31 +485,31 @@ int anope_event_capab(char *source, int ac, char **av)
}
/* SVSNOOP */
-void anope_cmd_svsnoop(char *server, int set)
+void unreal_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "%s %s %s", send_token("SVSNOOP", "f"), server,
(set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void unreal_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ unreal_cmd_svsnoop(server, set);
}
-void anope_cmd_remove_akill(char *user, char *host)
+void unreal_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "%s - G %s %s %s", send_token("TKL", "BD"), user, host,
s_OperServ);
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void unreal_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "%s %s %s %lu :%s", send_token("TOPIC", ")"), chan,
whosetit, (unsigned long int) when, topic);
}
-void anope_cmd_vhost_off(User * u)
+void unreal_cmd_vhost_off(User * u)
{
if (UseSVS2MODE) {
send_cmd(s_HostServ, "%s %s -xt", send_token("SVS2MODE", "v"),
@@ -783,11 +518,12 @@ void anope_cmd_vhost_off(User * u)
send_cmd(s_HostServ, "%s %s -xt", send_token("SVSMODE", "n"),
u->nick);
}
- notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
+ notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick,
+ myIrcd->vhostchar);
}
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void unreal_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "%s + G %s %s %s %ld %ld :%s", send_token("TKL", "BD"),
user, host, who, (long int) time(NULL) + 86400 * 2,
@@ -800,24 +536,11 @@ void anope_cmd_akill(char *user, char *host, char *who, time_t when,
** parv[1] = client
** parv[2] = kill message
*/
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void unreal_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (!source || !user || !fmt) {
+ if (!source || !user || !buf) {
return;
}
-
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
-
- if (!buf) {
- return;
- }
-
send_cmd(source, "%s %s :%s", send_token("SVSKILL", "h"), user, buf);
}
@@ -828,7 +551,7 @@ void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
* parv[2] - modes to change
* parv[3] - Service Stamp (if mode == d)
*/
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void unreal_cmd_svsmode(User * u, int ac, char **av)
{
if (ac >= 1) {
if (!u || !av[0]) {
@@ -847,58 +570,49 @@ void anope_cmd_svsmode(User * u, int ac, char **av)
}
/* 372 */
-void anope_cmd_372(char *source, char *msg)
+void unreal_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void unreal_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void unreal_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void unreal_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
-void anope_cmd_nick(char *nick, char *name, char *modes)
+void unreal_cmd_nick(char *nick, char *name, char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "%s %s 1 %ld %s %s %s 0 %s %s%s :%s",
send_token("NICK", "&"), nick, (long int) time(NULL),
ServiceUser, ServiceHost, ServerName, modes, ServiceHost,
- (ircd->nickip ? " *" : " "), name);
- anope_cmd_sqline(nick, "Reserved for services");
+ (myIrcd->nickip ? " *" : " "), name);
+ unreal_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void unreal_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
send_cmd(NULL, "%s %s 1 %ld %s %s %s 0 %s %s%s :%s",
send_token("NICK", "&"), nick, (long int) time(NULL), user,
- host, ServerName, modes, host, (ircd->nickip ? " *" : " "),
+ host, ServerName, modes, host, (myIrcd->nickip ? " *" : " "),
real);
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -906,30 +620,19 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "%s %s %s", send_token("MODE", "G"), dest, buf);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void unreal_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "%s %s 1 %ld %s %s %s 0 %s %s%s :%s",
send_token("NICK", "&"), nick, (long int) time(NULL), user,
- host, ServerName, modes, host, (ircd->nickip ? " *" : " "),
+ host, ServerName, modes, host, (myIrcd->nickip ? " *" : " "),
real);
- anope_cmd_sqline(nick, "Reserved for services");
+ unreal_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void unreal_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "%s %s %s :%s", send_token("KICK", "H"), chan,
user, buf);
@@ -938,17 +641,8 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -957,45 +651,27 @@ void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
}
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ unreal_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "%s %s :%s", send_token("NOTICE", "B"), dest,
buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void unreal_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "%s %s :%s", send_token("NOTICE", "B"), dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1003,46 +679,37 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "%s %s :%s", send_token("PRIVMSG", "!"), dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void unreal_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "%s %s :%s", send_token("PRIVMSG", "!"), dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void unreal_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "%s $%s :%s", send_token("NOTICE", "B"), dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void unreal_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "%s $%s :%s", send_token("PRIVMSG", "!"), dest, msg);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void unreal_cmd_bot_chan_mode(char *nick, char *chan)
{
- anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
+ anope_cmd_mode(nick, chan, "%s %s %s", myIrcd->botchanumode, nick,
+ nick);
}
-void anope_cmd_351(char *source)
+void unreal_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
- source, version_number, ServerName, ircd->name, version_flags,
- version_build);
+ source, version_number, ServerName, myIrcd->name,
+ version_flags, version_build);
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void unreal_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "%s :%s", send_token("QUIT", ","), buf);
} else {
@@ -1065,7 +732,7 @@ void anope_cmd_quit(char *source, const char *fmt, ...)
NS = Numeric Server
*/
-void anope_cmd_capab()
+void unreal_cmd_capab()
{
if (UseTokens) {
if (Numeric) {
@@ -1087,14 +754,14 @@ void anope_cmd_capab()
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void unreal_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS :%s", pass);
}
/* SERVER name hop descript */
/* Unreal 3.2 actually sends some info about itself in the descript area */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void unreal_cmd_server(char *servname, int hop, char *descript)
{
if (Numeric) {
send_cmd(NULL, "SERVER %s %d :U0-*-%s %s", servname, hop, Numeric,
@@ -1105,13 +772,13 @@ void anope_cmd_server(char *servname, int hop, char *descript)
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void unreal_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "%s %s", send_token("PONG", "9"), who);
}
/* JOIN */
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void unreal_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(ServerName, "%s !%s %s :%s",
send_token("SJOIN", "~"), base64enc((long int) chantime),
@@ -1123,7 +790,7 @@ void anope_cmd_join(char *user, char *channel, time_t chantime)
** parv[0] = sender
** parv[1] = nickmask
*/
-void anope_cmd_unsqline(char *user)
+void unreal_cmd_unsqline(char *user)
{
if (!user) {
return;
@@ -1132,7 +799,7 @@ void anope_cmd_unsqline(char *user)
}
/* CHGHOST */
-void anope_cmd_chghost(char *nick, char *vhost)
+void unreal_cmd_chghost(char *nick, char *vhost)
{
if (!nick || !vhost) {
return;
@@ -1142,7 +809,7 @@ void anope_cmd_chghost(char *nick, char *vhost)
}
/* CHGIDENT */
-void anope_cmd_chgident(char *nick, char *vIdent)
+void unreal_cmd_chgident(char *nick, char *vIdent)
{
if (!nick || !vIdent) {
return;
@@ -1152,7 +819,7 @@ void anope_cmd_chgident(char *nick, char *vIdent)
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void unreal_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1162,18 +829,8 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void unreal_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!nick || !chan) {
return;
}
@@ -1186,7 +843,7 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
/* 391 RPL_TIME ":%s 391 %s %s :%s" */
-void anope_cmd_391(char *source, char *timestr)
+void unreal_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1195,17 +852,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void unreal_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1214,17 +862,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void unreal_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1233,17 +872,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void unreal_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1252,17 +882,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void unreal_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1271,17 +892,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void unreal_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1290,7 +902,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void unreal_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1305,7 +917,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void unreal_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1314,7 +926,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void unreal_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1324,17 +936,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void unreal_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1343,17 +946,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void unreal_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1362,17 +956,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void unreal_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1381,17 +966,8 @@ void anope_cmd_211(const char *fmt, ...)
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void unreal_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
}
@@ -1401,7 +977,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void unreal_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "%s :%s",
send_token("GLOBOPS", "]"), fmt);
@@ -1416,7 +992,7 @@ void anope_cmd_global_legacy(char *source, char *fmt)
** - Unreal will translate this to TKL for us
**
*/
-void anope_cmd_sqline(char *mask, char *reason)
+void unreal_cmd_sqline(char *mask, char *reason)
{
if (!mask || !reason) {
return;
@@ -1426,7 +1002,7 @@ void anope_cmd_sqline(char *mask, char *reason)
}
/* SQUIT */
-void anope_cmd_squit(char *servname, char *message)
+void unreal_cmd_squit(char *servname, char *message)
{
if (!servname || !message) {
return;
@@ -1442,7 +1018,7 @@ void anope_cmd_squit(char *servname, char *message)
** parv[1] = nick
** parv[2] = options
*/
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void unreal_cmd_svso(char *source, char *nick, char *flag)
{
if (!source || !nick || !flag) {
return;
@@ -1452,7 +1028,7 @@ void anope_cmd_svso(char *source, char *nick, char *flag)
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void unreal_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1469,7 +1045,7 @@ void anope_cmd_chg_nick(char *oldnick, char *newnick)
** parv[2] = new nickname
** parv[3] = timestamp
*/
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void unreal_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1480,18 +1056,18 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
/* Functions that use serval cmd functions */
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void unreal_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
if (!nick) {
return;
}
if (vIdent) {
- anope_cmd_chgident(nick, vIdent);
+ unreal_cmd_chgident(nick, vIdent);
}
- anope_cmd_chghost(nick, vhost);
+ unreal_cmd_chghost(nick, vhost);
}
-void anope_cmd_connect(int servernum)
+void unreal_cmd_connect(int servernum)
{
if (Numeric) {
me_server =
@@ -1501,17 +1077,17 @@ void anope_cmd_connect(int servernum)
new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
}
- anope_cmd_capab();
+ unreal_cmd_capab();
if (servernum == 1) {
- anope_cmd_pass(RemotePassword);
+ unreal_cmd_pass(RemotePassword);
}
if (servernum == 2) {
- anope_cmd_pass(RemotePassword2);
+ unreal_cmd_pass(RemotePassword2);
}
if (servernum == 3) {
- anope_cmd_pass(RemotePassword3);
+ unreal_cmd_pass(RemotePassword3);
}
- anope_cmd_server(ServerName, 1, ServerDesc);
+ unreal_cmd_server(ServerName, 1, ServerDesc);
}
/* Events */
@@ -1520,10 +1096,17 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ unreal_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
+void unreal_cmd_netinfo(int ac, char **av)
+{
+ send_cmd(NULL, "%s %ld %ld %d %s 0 0 0 :%s",
+ send_token("NETINFO", "AO"), (long int) maxusercnt,
+ (long int) time(NULL), atoi(av[2]), av[3], av[7]);
+}
+
/* netinfo
* argv[0] = max global count
* argv[1] = time of end sync
@@ -1536,16 +1119,10 @@ int anope_event_ping(char *source, int ac, char **av)
*/
int anope_event_netinfo(char *source, int ac, char **av)
{
- anope_cmd_netinfo(ac, av);
+ unreal_cmd_netinfo(ac, av);
return MOD_CONT;
}
-void anope_cmd_netinfo(int ac, char **av)
-{
- send_cmd(NULL, "%s %ld %ld %d %s 0 0 0 :%s",
- send_token("NETINFO", "AO"), (long int) maxusercnt,
- (long int) time(NULL), atoi(av[2]), av[3], av[7]);
-}
/* TKL
* add: remove: spamfilter: spamfilter+TKLEXT sqline:
@@ -1945,7 +1522,7 @@ int anope_event_whois(char *source, int ac, char **av)
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void unreal_cmd_svshold(char *nick)
{
send_cmd(NULL, "%s + Q H %s %s %ld %ld :%s", send_token("TKL", "BD"),
nick, ServerName, (long int) time(NULL) + NSReleaseTimeout,
@@ -1953,7 +1530,7 @@ void anope_cmd_svshold(char *nick)
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void unreal_cmd_release_svshold(char *nick)
{
send_cmd(NULL, "%s - Q * %s %s", send_token("TKL", "BD"), nick,
ServerName);
@@ -1963,20 +1540,20 @@ void anope_cmd_release_svshold(char *nick)
/*
* SVSNLINE - :realname mask
*/
-void anope_cmd_unsgline(char *mask)
+void unreal_cmd_unsgline(char *mask)
{
send_cmd(NULL, "%s - :%s", send_token("SVSNLINE", "BR"), mask);
}
/* UNSZLINE */
-void anope_cmd_unszline(char *mask)
+void unreal_cmd_unszline(char *mask)
{
send_cmd(NULL, "%s - Z * %s %s", send_token("TKL", "BD"), mask,
s_OperServ);
}
/* SZLINE */
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void unreal_cmd_szline(char *mask, char *reason, char *whom)
{
send_cmd(NULL, "%s + Z * %s %s %ld %ld :%s", send_token("TKL", "BD"),
mask, whom, (long int) time(NULL) + 86400 * 2,
@@ -1987,7 +1564,7 @@ void anope_cmd_szline(char *mask, char *reason, char *whom)
/*
* SVSNLINE + reason_where_is_space :realname mask with spaces
*/
-void anope_cmd_sgline(char *mask, char *reason)
+void unreal_cmd_sgline(char *mask, char *reason)
{
strnrepl(reason, BUFSIZE, " ", "_");
send_cmd(NULL, "%s + %s :%s", send_token("SVSNLINE", "BR"), reason,
@@ -1995,15 +1572,15 @@ void anope_cmd_sgline(char *mask, char *reason)
}
/* SVSMODE -b */
-void anope_cmd_unban(char *name, char *nick)
+void unreal_cmd_unban(char *name, char *nick)
{
- anope_cmd_svsmode_chan(name, "-b", nick);
+ unreal_cmd_svsmode_chan(name, "-b", nick);
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void unreal_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
if (nick) {
send_cmd(ServerName, "%s %s %s %s", send_token("SVSMODE", "n"),
@@ -2017,7 +1594,7 @@ void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void unreal_cmd_svid_umode(char *nick, time_t ts)
{
if (UseSVS2MODE) {
send_cmd(ServerName, "%s %s +d 1", send_token("SVS2MODE", "v"),
@@ -2030,13 +1607,13 @@ void anope_cmd_svid_umode(char *nick, time_t ts)
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void unreal_cmd_nc_change(User * u)
{
common_svsmode(u, "-r+d", "1");
}
/* SVSMODE +r */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void unreal_cmd_svid_umode2(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -2045,7 +1622,7 @@ void anope_cmd_svid_umode2(User * u, char *ts)
}
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void unreal_cmd_svid_umode3(User * u, char *ts)
{
/* not used */
}
@@ -2080,7 +1657,7 @@ int anope_event_smo(char *source, int ac, char **av)
/* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken
when coming from a none TOKEN'd server
*/
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void unreal_cmd_svsjoin(char *source, char *nick, char *chan)
{
send_cmd(source, "%s %s :%s", send_token("SVSJOIN", "BX"), nick, chan);
}
@@ -2090,7 +1667,7 @@ void anope_cmd_svsjoin(char *source, char *nick, char *chan)
parv[1] - nick to make part
parv[2] - channel(s) to part
*/
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void unreal_cmd_svspart(char *source, char *nick, char *chan)
{
send_cmd(source, "%s %s :%s", send_token("SVSPART", "BT"), nick, chan);
}
@@ -2138,12 +1715,12 @@ int anope_event_sjoin(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void unreal_cmd_swhois(char *source, char *who, char *mask)
{
send_cmd(source, "%s %s :%s", send_token("SWHOIS", "BA"), who, mask);
}
-void anope_cmd_eob()
+void unreal_cmd_eob()
{
send_cmd(ServerName, "%s", send_token("EOS", "ES"));
}
@@ -2153,7 +1730,7 @@ void anope_cmd_eob()
* parv[1] - target nick
* parv[2] - parameters
*/
-void anope_cmd_svswatch(char *sender, char *nick, char *parm)
+void unreal_cmd_svswatch(char *sender, char *nick, char *parm)
{
send_cmd(sender, "%s %s :%s", send_token("SVSWATCH", "Bw"), nick,
parm);
@@ -2161,7 +1738,7 @@ void anope_cmd_svswatch(char *sender, char *nick, char *parm)
/* check if +f mode is valid for the ircd */
/* borrowed part of the new check from channels.c in Unreal */
-int anope_flood_mode_check(char *value)
+int unreal_flood_mode_check(char *value)
{
char *dp, *end;
/* NEW +F */
@@ -2210,15 +1787,15 @@ int anope_flood_mode_check(char *value)
}
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void unreal_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ unreal_cmd_squit(jserver, rbuf);
+ unreal_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
@@ -2226,7 +1803,7 @@ void anope_cmd_jupe(char *jserver, char *who, char *reason)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int unreal_valid_nick(char *nick)
{
if (!stricmp("ircd", nick)) {
return 0;
@@ -2237,18 +1814,9 @@ int anope_valid_nick(char *nick)
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void unreal_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -2259,4 +1827,376 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+/* *INDENT-OFF* */
+void moduleAddIRCDMsgs(void) {
+ Message *m;
+
+ updateProtectDetails("PROTECT","PROTECTME","!protect","!deprotect","AUTOPROTECT","+a","-a");
+
+ m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m);
+ m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m);
+ m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
+ m = createMessage("451", anope_event_null); addCoreMessage(IRCD,m);
+ m = createMessage("461", anope_event_null); addCoreMessage(IRCD,m);
+ m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("6", anope_event_away); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("INVITE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("*", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("C", anope_event_join); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("H", anope_event_kick); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage(".", anope_event_kill); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("G", anope_event_mode); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("F", anope_event_motd); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("&", anope_event_nick); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("B", anope_event_notice); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("D", anope_event_part); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("8", anope_event_ping); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("!", anope_event_privmsg); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage(",", anope_event_quit); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("'", anope_event_server); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("-", anope_event_squit); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage(")", anope_event_topic); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("%", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("=", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("#", anope_event_whois); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("V", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("GLOBOPS", anope_event_globops); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("]", anope_event_globops); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("GNOTICE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("Z", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("[", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("Y", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("U", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("h", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SVSMODE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("n", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SVS2MODE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("v", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("e", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("f", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SQLINE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("c", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("d", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("_", anope_event_capab); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AL", anope_event_chghost); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AZ", anope_event_chgident); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("BK", anope_event_chgname); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("NETINFO", anope_event_netinfo); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AO", anope_event_netinfo); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AA", anope_event_sethost); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AD", anope_event_setident); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AE", anope_event_setname); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("TKL", anope_event_tkl); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("BD", anope_event_tkl); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("EOS", anope_event_eos); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("ES", anope_event_eos); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("<", anope_event_pass); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("5", anope_event_error); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SMO", anope_event_smo); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AU", anope_event_smo); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("UMODE2", anope_event_umode2); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("|", anope_event_umode2); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SWHOIS", anope_event_swhois); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("BA", anope_event_swhois); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("~", anope_event_sjoin); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("O", anope_event_rehash); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("@", anope_event_admin); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("CREDITS", anope_event_credits); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AJ", anope_event_credits); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SDESC", anope_event_sdesc); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AG", anope_event_sdesc); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("HTM", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("BH", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("HELP", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("4", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("TRACE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("b", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("LAG", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AF", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("RPING", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AM", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SENDSNO", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("Ss", anope_event_null); addCoreMessage(IRCD,m);
+ }
+ m = createMessage("SENDUMODE", anope_event_null); addCoreMessage(IRCD,m);
+ if (UseTokens) {
+ m = createMessage("AP", anope_event_null); addCoreMessage(IRCD,m);
+ }
+
+
+ /* The none token version of these is in messages.c */
+ if (UseTokens) {
+ m = createMessage("2", m_stats); addCoreMessage(IRCD,m);
+ m = createMessage(">", m_time); addCoreMessage(IRCD,m);
+ m = createMessage("+", m_version); addCoreMessage(IRCD,m);
+ }
+}
+
+/* *INDENT-ON* */
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(unreal_cmd_svsnoop);
+ pmodule_cmd_remove_akill(unreal_cmd_remove_akill);
+ pmodule_cmd_topic(unreal_cmd_topic);
+ pmodule_cmd_vhost_off(unreal_cmd_vhost_off);
+ pmodule_cmd_akill(unreal_cmd_akill);
+ pmodule_cmd_svskill(unreal_cmd_svskill);
+ pmodule_cmd_svsmode(unreal_cmd_svsmode);
+ pmodule_cmd_372(unreal_cmd_372);
+ pmodule_cmd_372_error(unreal_cmd_372_error);
+ pmodule_cmd_375(unreal_cmd_375);
+ pmodule_cmd_376(unreal_cmd_376);
+ pmodule_cmd_nick(unreal_cmd_nick);
+ pmodule_cmd_guest_nick(unreal_cmd_guest_nick);
+ pmodule_cmd_mode(unreal_cmd_mode);
+ pmodule_cmd_bot_nick(unreal_cmd_bot_nick);
+ pmodule_cmd_kick(unreal_cmd_kick);
+ pmodule_cmd_notice_ops(unreal_cmd_notice_ops);
+ pmodule_cmd_notice(unreal_cmd_notice);
+ pmodule_cmd_notice2(unreal_cmd_notice2);
+ pmodule_cmd_privmsg(unreal_cmd_privmsg);
+ pmodule_cmd_privmsg2(unreal_cmd_privmsg2);
+ pmodule_cmd_serv_notice(unreal_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(unreal_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(unreal_cmd_bot_chan_mode);
+ pmodule_cmd_351(unreal_cmd_351);
+ pmodule_cmd_quit(unreal_cmd_quit);
+ pmodule_cmd_pong(unreal_cmd_pong);
+ pmodule_cmd_join(unreal_cmd_join);
+ pmodule_cmd_unsqline(unreal_cmd_unsqline);
+ pmodule_cmd_invite(unreal_cmd_invite);
+ pmodule_cmd_part(unreal_cmd_part);
+ pmodule_cmd_391(unreal_cmd_391);
+ pmodule_cmd_250(unreal_cmd_250);
+ pmodule_cmd_307(unreal_cmd_307);
+ pmodule_cmd_311(unreal_cmd_311);
+ pmodule_cmd_312(unreal_cmd_312);
+ pmodule_cmd_317(unreal_cmd_317);
+ pmodule_cmd_219(unreal_cmd_219);
+ pmodule_cmd_401(unreal_cmd_401);
+ pmodule_cmd_318(unreal_cmd_318);
+ pmodule_cmd_242(unreal_cmd_242);
+ pmodule_cmd_243(unreal_cmd_243);
+ pmodule_cmd_211(unreal_cmd_211);
+ pmodule_cmd_global(unreal_cmd_global);
+ pmodule_cmd_global_legacy(unreal_cmd_global_legacy);
+ pmodule_cmd_sqline(unreal_cmd_sqline);
+ pmodule_cmd_squit(unreal_cmd_squit);
+ pmodule_cmd_svso(unreal_cmd_svso);
+ pmodule_cmd_chg_nick(unreal_cmd_chg_nick);
+ pmodule_cmd_svsnick(unreal_cmd_svsnick);
+ pmodule_cmd_vhost_on(unreal_cmd_vhost_on);
+ pmodule_cmd_connect(unreal_cmd_connect);
+ pmodule_cmd_svshold(unreal_cmd_svshold);
+ pmodule_cmd_release_svshold(unreal_cmd_release_svshold);
+ pmodule_cmd_unsgline(unreal_cmd_unsqline);
+ pmodule_cmd_unszline(unreal_cmd_unszline);
+ pmodule_cmd_szline(unreal_cmd_szline);
+ pmodule_cmd_sgline(unreal_cmd_sgline);
+ pmodule_cmd_unban(unreal_cmd_unban);
+ pmodule_cmd_svsmode_chan(unreal_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(unreal_cmd_svid_umode);
+ pmodule_cmd_nc_change(unreal_cmd_nc_change);
+ pmodule_cmd_svid_umode2(unreal_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(unreal_cmd_svid_umode3);
+ pmodule_cmd_eob(unreal_cmd_eob);
+ pmodule_flood_mode_check(unreal_flood_mode_check);
+ pmodule_cmd_jupe(unreal_cmd_jupe);
+ pmodule_valid_nick(unreal_valid_nick);
+ pmodule_cmd_ctcp(unreal_cmd_ctcp);
+ pmodule_set_umode(unreal_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("UnrealIRCd 3.2+");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("+f");
+ pmodule_ircd_flood_mode_char_remove("-f");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/unreal32.h b/src/protocol/unreal32.h
new file mode 100644
index 000000000..7bb3863cf
--- /dev/null
+++ b/src/protocol/unreal32.h
@@ -0,0 +1,153 @@
+/* Unreal IRCD 3.2.x functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@unreal.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+/*************************************************************************/
+
+/* User Modes */
+#define UMODE_a 0x00000001 /* a Services Admin */
+#define UMODE_h 0x00000002 /* h Available for help (HelpOp) */
+#define UMODE_i 0x00000004 /* i Invisible (not shown in /who) */
+#define UMODE_o 0x00000008 /* o Global IRC Operator */
+#define UMODE_r 0x00000010 /* r Identifies the nick as being registered */
+#define UMODE_w 0x00000020 /* w Can listen to wallop messages */
+#define UMODE_A 0x00000040 /* A Server Admin */
+#define UMODE_N 0x00000080 /* N Network Administrator */
+#define UMODE_O 0x00000100 /* O Local IRC Operator */
+#define UMODE_C 0x00000200 /* C Co-Admin */
+#define UMODE_d 0x00000400 /* d Makes it so you can not receive channel PRIVMSGs */
+#define UMODE_p 0x00000800 /* Hides the channels you are in in a /whois reply */
+#define UMODE_q 0x00001000 /* q Only U:Lines can kick you (Services Admins Only) */
+#define UMODE_s 0x00002000 /* s Can listen to server notices */
+#define UMODE_t 0x00004000 /* t Says you are using a /vhost */
+#define UMODE_v 0x00008000 /* v Receives infected DCC Send Rejection notices */
+#define UMODE_z 0x00010000 /* z Indicates that you are an SSL client */
+#define UMODE_B 0x00020000 /* B Marks you as being a Bot */
+#define UMODE_G 0x00040000 /* G Filters out all the bad words per configuration */
+#define UMODE_H 0x00080000 /* H Hide IRCop Status (IRCop Only) */
+#define UMODE_S 0x00100000 /* S services client */
+#define UMODE_V 0x00200000 /* V Marks you as a WebTV user */
+#define UMODE_W 0x00400000 /* W Lets you see when people do a /whois on you */
+#define UMODE_T 0x00800000 /* T Prevents you from receiving CTCPs */
+#define UMODE_g 0x20000000 /* g Can send & read globops and locops */
+#define UMODE_x 0x40000000 /* x Gives user a hidden hostname */
+#define UMODE_R 0x80000000 /* Allows you to only receive PRIVMSGs/NOTICEs from registered (+r) users */
+
+
+/*************************************************************************/
+
+/* Channel Modes */
+
+#define CMODE_i 0x00000001
+#define CMODE_m 0x00000002
+#define CMODE_n 0x00000004
+#define CMODE_p 0x00000008
+#define CMODE_s 0x00000010
+#define CMODE_t 0x00000020
+#define CMODE_k 0x00000040 /* These two used only by ChanServ */
+#define CMODE_l 0x00000080
+#define CMODE_R 0x00000100 /* Only identified users can join */
+#define CMODE_r 0x00000200 /* Set for all registered channels */
+#define CMODE_c 0x00000400
+#define CMODE_A 0x00000800
+/* #define CMODE_H 0x00001000 Was now +I may not join, but Unreal Removed it and it will not set in 3.2 */
+#define CMODE_K 0x00002000
+#define CMODE_L 0x00004000
+#define CMODE_O 0x00008000
+#define CMODE_Q 0x00010000
+#define CMODE_S 0x00020000
+#define CMODE_V 0x00040000
+#define CMODE_f 0x00080000
+#define CMODE_G 0x00100000
+#define CMODE_C 0x00200000
+#define CMODE_u 0x00400000
+#define CMODE_z 0x00800000
+#define CMODE_N 0x01000000
+#define CMODE_T 0x02000000
+#define CMODE_M 0x04000000
+
+
+/* Default Modes with MLOCK */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void unreal_set_umode(User * user, int ac, char **av);
+void unreal_cmd_svsnoop(char *server, int set);
+void unreal_cmd_remove_akill(char *user, char *host);
+void unreal_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void unreal_cmd_vhost_off(User * u);
+void unreal_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void unreal_cmd_svskill(char *source, char *user, char *buf);
+void unreal_cmd_svsmode(User * u, int ac, char **av);
+void unreal_cmd_372(char *source, char *msg);
+void unreal_cmd_372_error(char *source);
+void unreal_cmd_375(char *source);
+void unreal_cmd_376(char *source);
+void unreal_cmd_nick(char *nick, char *name, char *modes);
+void unreal_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void unreal_cmd_mode(char *source, char *dest, char *buf);
+void unreal_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void unreal_cmd_kick(char *source, char *chan, char *user, char *buf);
+void unreal_cmd_notice_ops(char *source, char *dest, char *buf);
+void unreal_cmd_notice(char *source, char *dest, char *buf);
+void unreal_cmd_notice2(char *source, char *dest, char *msg);
+void unreal_cmd_privmsg(char *source, char *dest, char *buf);
+void unreal_cmd_privmsg2(char *source, char *dest, char *msg);
+void unreal_cmd_serv_notice(char *source, char *dest, char *msg);
+void unreal_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void unreal_cmd_bot_chan_mode(char *nick, char *chan);
+void unreal_cmd_351(char *source);
+void unreal_cmd_quit(char *source, char *buf);
+void unreal_cmd_pong(char *servname, char *who);
+void unreal_cmd_join(char *user, char *channel, time_t chantime);
+void unreal_cmd_unsqline(char *user);
+void unreal_cmd_invite(char *source, char *chan, char *nick);
+void unreal_cmd_part(char *nick, char *chan, char *buf);
+void unreal_cmd_391(char *source, char *timestr);
+void unreal_cmd_250(char *buf);
+void unreal_cmd_307(char *buf);
+void unreal_cmd_311(char *buf);
+void unreal_cmd_312(char *buf);
+void unreal_cmd_317(char *buf);
+void unreal_cmd_219(char *source, char *letter);
+void unreal_cmd_401(char *source, char *who);
+void unreal_cmd_318(char *source, char *who);
+void unreal_cmd_242(char *buf);
+void unreal_cmd_243(char *buf);
+void unreal_cmd_211(char *buf);
+void unreal_cmd_global(char *source, char *buf);
+void unreal_cmd_global_legacy(char *source, char *fmt);
+void unreal_cmd_sqline(char *mask, char *reason);
+void unreal_cmd_squit(char *servname, char *message);
+void unreal_cmd_svso(char *source, char *nick, char *flag);
+void unreal_cmd_chg_nick(char *oldnick, char *newnick);
+void unreal_cmd_svsnick(char *source, char *guest, time_t when);
+void unreal_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void unreal_cmd_connect(int servernum);
+void unreal_cmd_svshold(char *nick);
+void unreal_cmd_release_svshold(char *nick);
+void unreal_cmd_unsgline(char *mask);
+void unreal_cmd_unszline(char *mask);
+void unreal_cmd_szline(char *mask, char *reason, char *whom);
+void unreal_cmd_sgline(char *mask, char *reason);
+void unreal_cmd_unban(char *name, char *nick);
+void unreal_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void unreal_cmd_svid_umode(char *nick, time_t ts);
+void unreal_cmd_nc_change(User * u);
+void unreal_cmd_svid_umode2(User * u, char *ts);
+void unreal_cmd_svid_umode3(User * u, char *ts);
+void unreal_cmd_eob();
+int unreal_flood_mode_check(char *value);
+void unreal_cmd_jupe(char *jserver, char *who, char *reason);
+int unreal_valid_nick(char *nick);
+void unreal_cmd_ctcp(char *source, char *dest, char *buf);
+
diff --git a/src/viagra.c b/src/protocol/viagra.c
index 565508091..cd9fbe991 100644
--- a/src/viagra.c
+++ b/src/protocol/viagra.c
@@ -14,17 +14,9 @@
#include "services.h"
#include "pseudo.h"
+#include "viagra.h"
-#ifdef IRC_VIAGRA
-
-const char version_protocol[] = "ViagraIRCd 1.3.x";
-
-/* Not all ircds use +f for their flood/join throttle system */
-const char flood_mode_char_set[] = ""; /* mode char for FLOOD mode on set */
-const char flood_mode_char_remove[] = ""; /* mode char for FLOOD mode on remove */
-int UseTSMODE = 0;
-
-IRCDVar ircd[] = {
+IRCDVar myIrcd[] = {
{"ViagraIRCd 1.3.*", /* ircd name */
"+oS", /* nickserv mode */
"+oS", /* chanserv mode */
@@ -85,7 +77,6 @@ IRCDVar ircd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
1, /* Change RealName */
- CHAN_HELP_UNREAL, /* ChanServ extra */
0, /* No Knock */
0, /* Admin Only */
DEFAULT_MLOCK, /* Default MLOCK */
@@ -118,7 +109,7 @@ IRCDVar ircd[] = {
};
-IRCDCAPAB ircdcap[] = {
+IRCDCAPAB myIrcdcap[] = {
{
CAPAB_NOQUIT, /* NOQUIT */
CAPAB_TSMODE, /* TSMODE */
@@ -154,7 +145,7 @@ IRCDCAPAB ircdcap[] = {
-void anope_set_umode(User * user, int ac, char **av)
+void viagra_set_umode(User * user, int ac, char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
char *modes = av[0];
@@ -239,7 +230,7 @@ unsigned long umodes[128] = {
};
-char csmodes[128] = {
+char myCsmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -261,7 +252,7 @@ char csmodes[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0
};
-CMMode cmmodes[128] = {
+CMMode myCmmodes[128] = {
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
{NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
@@ -289,7 +280,7 @@ CMMode cmmodes[128] = {
-CBMode cbmodes[128] = {
+CBMode myCbmodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -355,7 +346,7 @@ CBMode cbmodes[128] = {
{0}, {0}, {0}, {0}
};
-CBModeInfo cbmodeinfos[] = {
+CBModeInfo myCbmodeinfos[] = {
{'c', CMODE_c, 0, NULL, NULL},
{'i', CMODE_i, 0, NULL, NULL},
{'k', CMODE_k, 0, get_key, cs_get_key},
@@ -377,7 +368,7 @@ CBModeInfo cbmodeinfos[] = {
{0}
};
-CUMode cumodes[128] = {
+CUMode myCumodes[128] = {
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
@@ -425,7 +416,7 @@ CUMode cumodes[128] = {
};
-void anope_cmd_bot_unban(ChannelInfo * ci, char *nick)
+void viagra_cmd_bot_unban(ChannelInfo * ci, char *nick)
{
send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick);
}
@@ -743,7 +734,7 @@ void moduleAddIRCDMsgs(void) {
/* SQLINE */
-void anope_cmd_sqline(char *mask, char *reason)
+void viagra_cmd_sqline(char *mask, char *reason)
{
if (!mask || !reason) {
return;
@@ -752,54 +743,44 @@ void anope_cmd_sqline(char *mask, char *reason)
send_cmd(NULL, "SQLINE %s :%s", mask, reason);
}
-void anope_cmd_unsgline(char *mask)
+void viagra_cmd_unsgline(char *mask)
{
send_cmd(NULL, "UNSGLINE 0 :%s", mask);
}
-void anope_cmd_unszline(char *mask)
+void viagra_cmd_unszline(char *mask)
{
send_cmd(NULL, "UNSZLINE 0 %s", mask);
}
-void anope_cmd_szline(char *mask, char *reason, char *whom)
+void viagra_cmd_szline(char *mask, char *reason, char *whom)
{
send_cmd(NULL, "SZLINE %s :%s", mask, reason);
}
-void anope_cmd_svsnoop(char *server, int set)
+void viagra_cmd_svsnoop(char *server, int set)
{
send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
}
-void anope_cmd_svsadmin(char *server, int set)
+void viagra_cmd_svsadmin(char *server, int set)
{
- anope_cmd_svsnoop(server, set);
+ viagra_cmd_svsnoop(server, set);
}
-void anope_cmd_sgline(char *mask, char *reason)
+void viagra_cmd_sgline(char *mask, char *reason)
{
send_cmd(NULL, "SGLINE %d :%s:%s", strlen(mask), mask, reason);
}
-void anope_cmd_remove_akill(char *user, char *host)
+void viagra_cmd_remove_akill(char *user, char *host)
{
send_cmd(NULL, "RAKILL %s %s", host, user);
}
/* PART */
-void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
+void viagra_cmd_part(char *nick, char *chan, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!nick || !chan) {
return;
}
@@ -811,20 +792,20 @@ void anope_cmd_part(char *nick, char *chan, const char *fmt, ...)
}
}
-void anope_cmd_topic(char *whosets, char *chan, char *whosetit,
- char *topic, time_t when)
+void viagra_cmd_topic(char *whosets, char *chan, char *whosetit,
+ char *topic, time_t when)
{
send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
(unsigned long int) when, topic);
}
-void anope_cmd_vhost_off(User * u)
+void viagra_cmd_vhost_off(User * u)
{
send_cmd(NULL, "SVSMODE %s -x", u->nick);
notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
}
-void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
+void viagra_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
{
if (vIdent) {
send_cmd(NULL, "CHGIDENT %s %s", nick, vIdent);
@@ -833,12 +814,12 @@ void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
send_cmd(NULL, "SVSCHGHOST %s %s", nick, vhost);
}
-void anope_cmd_unsqline(char *user)
+void viagra_cmd_unsqline(char *user)
{
send_cmd(NULL, "UNSQLINE %s", user);
}
-void anope_cmd_join(char *user, char *channel, time_t chantime)
+void viagra_cmd_join(char *user, char *channel, time_t chantime)
{
send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
}
@@ -853,8 +834,8 @@ void anope_cmd_join(char *user, char *channel, time_t chantime)
* parv[5]=time set
* parv[6]=reason
*/
-void anope_cmd_akill(char *user, char *host, char *who, time_t when,
- time_t expires, char *reason)
+void viagra_cmd_akill(char *user, char *host, char *who, time_t when,
+ time_t expires, char *reason)
{
send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
(long int) time(NULL), reason);
@@ -868,37 +849,16 @@ void anope_cmd_akill(char *user, char *host, char *who, time_t when,
* parv[2] = nick stamp
* parv[3] = kill message
*/
-void anope_cmd_svskill(char *source, char *user, const char *fmt, ...)
+void viagra_cmd_svskill(char *source, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (!source || !user) {
- return;
- }
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
+ if (buf) {
send_cmd(source, "SVSKILL %s :%s", user, buf);
}
return;
}
-void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
+void viagra_cmd_mode(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -915,18 +875,8 @@ void anope_cmd_mode(char *source, char *dest, const char *fmt, ...)
}
/* QUIT */
-void anope_cmd_quit(char *source, const char *fmt, ...)
+void viagra_cmd_quit(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "QUIT :%s", buf);
} else {
@@ -951,46 +901,28 @@ int anope_event_ping(char *source, int ac, char **av)
{
if (ac < 1)
return MOD_CONT;
- anope_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
+ viagra_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
return MOD_CONT;
}
-void anope_cmd_svsmode(User * u, int ac, char **av)
+void viagra_cmd_svsmode(User * u, int ac, char **av)
{
send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
(long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
(ac == 2 ? av[1] : ""));
}
-void anope_cmd_squit(char *servname, char *message)
+void viagra_cmd_squit(char *servname, char *message)
{
send_cmd(NULL, "SQUIT %s :%s", servname, message);
}
/* PONG */
-void anope_cmd_pong(char *servname, char *who)
+void viagra_cmd_pong(char *servname, char *who)
{
send_cmd(servname, "PONG %s", who);
}
-void anope_cmd_connect(int servernum)
-{
- me_server =
- new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
-
- if (servernum == 1) {
- anope_cmd_pass(RemotePassword);
- } else if (servernum == 2) {
- anope_cmd_pass(RemotePassword2);
- } else if (servernum == 3) {
- anope_cmd_pass(RemotePassword3);
- }
- anope_cmd_capab();
- anope_cmd_server(ServerName, 1, ServerDesc);
- anope_cmd_svinfo();
- anope_cmd_burst();
-}
-
/*
* svinfo
* parv[0] = sender prefix
@@ -999,29 +931,52 @@ void anope_cmd_connect(int servernum)
* parv[3] = server is standalone or connected to non-TS only
* parv[4] = server's idea of UTC time
*/
-void anope_cmd_svinfo()
+void viagra_cmd_svinfo()
{
send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL));
}
/* CAPAB */
-void anope_cmd_capab()
+void viagra_cmd_capab()
{
send_cmd(NULL, "CAPAB TS5 NOQUIT SSJOIN BURST UNCONNECT NICKIP");
}
/* PASS */
-void anope_cmd_pass(char *pass)
+void viagra_cmd_pass(char *pass)
{
send_cmd(NULL, "PASS %s :TS", pass);
}
/* SERVER */
-void anope_cmd_server(char *servname, int hop, char *descript)
+void viagra_cmd_server(char *servname, int hop, char *descript)
{
send_cmd(NULL, "SERVER %s %d :%s", servname, hop, ServerDesc);
}
+void viagra_cmd_burst()
+{
+ send_cmd(NULL, "BURST");
+}
+
+void viagra_cmd_connect(int servernum)
+{
+ me_server =
+ new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
+
+ if (servernum == 1) {
+ viagra_cmd_pass(RemotePassword);
+ } else if (servernum == 2) {
+ viagra_cmd_pass(RemotePassword2);
+ } else if (servernum == 3) {
+ viagra_cmd_pass(RemotePassword3);
+ }
+ viagra_cmd_capab();
+ viagra_cmd_server(ServerName, 1, ServerDesc);
+ viagra_cmd_svinfo();
+ viagra_cmd_burst();
+}
+
/* EVENT : OS */
int anope_event_os(char *source, int ac, char **av)
{
@@ -1174,61 +1129,34 @@ int anope_event_motd(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...)
+void viagra_cmd_notice_ops(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
+ if (!buf) {
send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
}
return;
}
-void anope_cmd_notice(char *source, char *dest, const char *fmt, ...)
+void viagra_cmd_notice(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
if (UsePrivmsg) {
- anope_cmd_privmsg2(source, dest, buf);
+ viagra_cmd_privmsg2(source, dest, buf);
} else {
send_cmd(source, "NOTICE %s :%s", dest, buf);
}
}
-void anope_cmd_notice2(char *source, char *dest, char *msg)
+void viagra_cmd_notice2(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE %s :%s", dest, msg);
}
-void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
+void viagra_cmd_privmsg(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1236,34 +1164,24 @@ void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...)
send_cmd(source, "PRIVMSG %s :%s", dest, buf);
}
-void anope_cmd_privmsg2(char *source, char *dest, char *msg)
+void viagra_cmd_privmsg2(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG %s :%s", dest, msg);
}
-void anope_cmd_serv_notice(char *source, char *dest, char *msg)
+void viagra_cmd_serv_notice(char *source, char *dest, char *msg)
{
send_cmd(source, "NOTICE $%s :%s", dest, msg);
}
-void anope_cmd_serv_privmsg(char *source, char *dest, char *msg)
+void viagra_cmd_serv_privmsg(char *source, char *dest, char *msg)
{
send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
}
/* GLOBOPS */
-void anope_cmd_global(char *source, const char *fmt, ...)
+void viagra_cmd_global(char *source, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1272,7 +1190,7 @@ void anope_cmd_global(char *source, const char *fmt, ...)
}
/* 391 */
-void anope_cmd_391(char *source, char *timestr)
+void viagra_cmd_391(char *source, char *timestr)
{
if (!timestr) {
return;
@@ -1281,18 +1199,8 @@ void anope_cmd_391(char *source, char *timestr)
}
/* 250 */
-void anope_cmd_250(const char *fmt, ...)
+void viagra_cmd_250(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1301,18 +1209,8 @@ void anope_cmd_250(const char *fmt, ...)
}
/* 307 */
-void anope_cmd_307(const char *fmt, ...)
+void viagra_cmd_307(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1321,18 +1219,8 @@ void anope_cmd_307(const char *fmt, ...)
}
/* 311 */
-void anope_cmd_311(const char *fmt, ...)
+void viagra_cmd_311(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1341,18 +1229,8 @@ void anope_cmd_311(const char *fmt, ...)
}
/* 312 */
-void anope_cmd_312(const char *fmt, ...)
+void viagra_cmd_312(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1361,18 +1239,8 @@ void anope_cmd_312(const char *fmt, ...)
}
/* 317 */
-void anope_cmd_317(const char *fmt, ...)
+void viagra_cmd_317(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1381,7 +1249,7 @@ void anope_cmd_317(const char *fmt, ...)
}
/* 219 */
-void anope_cmd_219(char *source, char *letter)
+void viagra_cmd_219(char *source, char *letter)
{
if (!source) {
return;
@@ -1396,7 +1264,7 @@ void anope_cmd_219(char *source, char *letter)
}
/* 401 */
-void anope_cmd_401(char *source, char *who)
+void viagra_cmd_401(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1405,7 +1273,7 @@ void anope_cmd_401(char *source, char *who)
}
/* 318 */
-void anope_cmd_318(char *source, char *who)
+void viagra_cmd_318(char *source, char *who)
{
if (!source || !who) {
return;
@@ -1415,18 +1283,8 @@ void anope_cmd_318(char *source, char *who)
}
/* 242 */
-void anope_cmd_242(const char *fmt, ...)
+void viagra_cmd_242(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1435,18 +1293,8 @@ void anope_cmd_242(const char *fmt, ...)
}
/* 243 */
-void anope_cmd_243(const char *fmt, ...)
+void viagra_cmd_243(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1455,18 +1303,8 @@ void anope_cmd_243(const char *fmt, ...)
}
/* 211 */
-void anope_cmd_211(const char *fmt, ...)
+void viagra_cmd_211(char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (!buf) {
return;
}
@@ -1474,35 +1312,24 @@ void anope_cmd_211(const char *fmt, ...)
send_cmd(NULL, "211 %s ", buf);
}
-void anope_cmd_351(char *source)
+void viagra_cmd_351(char *source)
{
send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s -- %s",
source, version_number, ServerName, ircd->name, version_flags,
version_build);
}
-void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void viagra_cmd_bot_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
EnforceQlinedNick(nick, s_BotServ);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
- anope_cmd_sqline(nick, "Reserved for services");
+ viagra_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
- ...)
+void viagra_cmd_kick(char *source, char *chan, char *user, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
- *buf = '\0';
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
-
if (buf) {
send_cmd(source, "KICK %s %s :%s", chan, user, buf);
} else {
@@ -1510,39 +1337,39 @@ void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,
}
}
-void anope_cmd_nick(char *nick, char *name, char *modes)
+void viagra_cmd_nick(char *nick, char *name, char *modes)
{
EnforceQlinedNick(nick, NULL);
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, ServiceUser, ServiceHost,
ServerName, name);
- anope_cmd_sqline(nick, "Reserved for services");
+ viagra_cmd_sqline(nick, "Reserved for services");
}
-void anope_cmd_372(char *source, char *msg)
+void viagra_cmd_372(char *source, char *msg)
{
send_cmd(ServerName, "372 %s :- %s", source, msg);
}
-void anope_cmd_372_error(char *source)
+void viagra_cmd_372_error(char *source)
{
send_cmd(ServerName, "422 %s :- MOTD file not found! Please "
"contact your IRC administrator.", source);
}
-void anope_cmd_375(char *source)
+void viagra_cmd_375(char *source)
{
send_cmd(ServerName, "375 %s :- %s Message of the Day",
source, ServerName);
}
-void anope_cmd_376(char *source)
+void viagra_cmd_376(char *source)
{
send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
}
/* INVITE */
-void anope_cmd_invite(char *source, char *chan, char *nick)
+void viagra_cmd_invite(char *source, char *chan, char *nick)
{
if (!source || !chan || !nick) {
return;
@@ -1551,7 +1378,7 @@ void anope_cmd_invite(char *source, char *chan, char *nick)
send_cmd(source, "INVITE %s %s", nick, chan);
}
-void anope_cmd_bot_chan_mode(char *nick, char *chan)
+void viagra_cmd_bot_chan_mode(char *nick, char *chan)
{
anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
}
@@ -1563,19 +1390,19 @@ int anope_event_capab(char *source, int ac, char **av)
}
/* SVSHOLD - set */
-void anope_cmd_svshold(char *nick)
+void viagra_cmd_svshold(char *nick)
{
/* Not supported by this IRCD */
}
/* SVSHOLD - release */
-void anope_cmd_release_svshold(char *nick)
+void viagra_cmd_release_svshold(char *nick)
{
/* Not Supported by this IRCD */
}
/* SVSNICK */
-void anope_cmd_svsnick(char *source, char *guest, time_t when)
+void viagra_cmd_svsnick(char *source, char *guest, time_t when)
{
if (!source || !guest) {
return;
@@ -1583,28 +1410,28 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when)
send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
}
-void anope_cmd_guest_nick(char *nick, char *user, char *host, char *real,
- char *modes)
+void viagra_cmd_guest_nick(char *nick, char *user, char *host, char *real,
+ char *modes)
{
send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
(long int) time(NULL), modes, user, host, ServerName, real);
}
-void anope_cmd_svso(char *source, char *nick, char *flag)
+void viagra_cmd_svso(char *source, char *nick, char *flag)
{
/* Not Supported by this IRCD */
}
/* SVSMODE -b */
-void anope_cmd_unban(char *name, char *nick)
+void viagra_cmd_unban(char *name, char *nick)
{
- anope_cmd_svsmode_chan(name, "-b", nick);
+ viagra_cmd_svsmode_chan(name, "-b", nick);
}
/* SVSMODE channel modes */
-void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
+void viagra_cmd_svsmode_chan(char *name, char *mode, char *nick)
{
if (nick) {
send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
@@ -1615,7 +1442,7 @@ void anope_cmd_svsmode_chan(char *name, char *mode, char *nick)
/* SVSMODE +d */
/* sent if svid is something weird */
-void anope_cmd_svid_umode(char *nick, time_t ts)
+void viagra_cmd_svid_umode(char *nick, time_t ts)
{
send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick,
(unsigned long int) ts);
@@ -1623,18 +1450,18 @@ void anope_cmd_svid_umode(char *nick, time_t ts)
/* SVSMODE +d */
/* nc_change was = 1, and there is no na->status */
-void anope_cmd_nc_change(User * u)
+void viagra_cmd_nc_change(User * u)
{
common_svsmode(u, "+d", "1");
}
/* SVSMODE +d */
-void anope_cmd_svid_umode2(User * u, char *ts)
+void viagra_cmd_svid_umode2(User * u, char *ts)
{
/* not used by bahamut ircds */
}
-void anope_cmd_svid_umode3(User * u, char *ts)
+void viagra_cmd_svid_umode3(User * u, char *ts)
{
if (u->svid != u->timestamp) {
common_svsmode(u, "+rd", ts);
@@ -1644,7 +1471,7 @@ void anope_cmd_svid_umode3(User * u, char *ts)
}
/* NICK <newnick> */
-void anope_cmd_chg_nick(char *oldnick, char *newnick)
+void viagra_cmd_chg_nick(char *oldnick, char *newnick)
{
if (!oldnick || !newnick) {
return;
@@ -1659,7 +1486,7 @@ void anope_cmd_chg_nick(char *oldnick, char *newnick)
* parv[1] = nick to make join
* parv[2] = channel(s) to join
*/
-void anope_cmd_svsjoin(char *source, char *nick, char *chan)
+void viagra_cmd_svsjoin(char *source, char *nick, char *chan)
{
send_cmd(source, "SVSJOIN %s :%s", nick, chan);
}
@@ -1670,17 +1497,17 @@ void anope_cmd_svsjoin(char *source, char *nick, char *chan)
* parv[1] = nick to make part
* parv[2] = channel(s) to part
*/
-void anope_cmd_svspart(char *source, char *nick, char *chan)
+void viagra_cmd_svspart(char *source, char *nick, char *chan)
{
send_cmd(source, "SVSPART %s :%s", nick, chan);
}
-void anope_cmd_swhois(char *source, char *who, char *mask)
+void viagra_cmd_swhois(char *source, char *who, char *mask)
{
/* not supported */
}
-int anope_flood_mode_check(char *value)
+int viagra_flood_mode_check(char *value)
{
return 0;
}
@@ -1705,30 +1532,25 @@ int anope_event_invite(char *source, int ac, char **av)
return MOD_CONT;
}
-void anope_cmd_burst()
-{
- send_cmd(NULL, "BURST");
-}
-
-void anope_cmd_eob()
+void viagra_cmd_eob()
{
send_cmd(NULL, "BURST 0");
}
-void anope_cmd_jupe(char *jserver, char *who, char *reason)
+void viagra_cmd_jupe(char *jserver, char *who, char *reason)
{
char rbuf[256];
snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
reason ? ": " : "", reason ? reason : "");
- anope_cmd_squit(jserver, rbuf);
- anope_cmd_server(jserver, 2, rbuf);
+ viagra_cmd_squit(jserver, rbuf);
+ viagra_cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
/* GLOBOPS - to handle old WALLOPS */
-void anope_cmd_global_legacy(char *source, char *fmt)
+void viagra_cmd_global_legacy(char *source, char *fmt)
{
send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
}
@@ -1737,24 +1559,16 @@ void anope_cmd_global_legacy(char *source, char *fmt)
1 = valid nick
0 = nick is in valid
*/
-int anope_valid_nick(char *nick)
+int viagra_valid_nick(char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
-void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
+void viagra_cmd_ctcp(char *source, char *dest, char *buf)
{
- va_list args;
- char buf[BUFSIZE];
char *s;
- *buf = '\0';
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, fmt, args);
- va_end(args);
- }
if (!buf) {
return;
} else {
@@ -1765,4 +1579,118 @@ void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...)
free(s);
}
-#endif
+
+/**
+ * Tell anope which function we want to perform each task inside of anope.
+ * These prototypes must match what anope expects.
+ **/
+void moduleAddAnopeCmds()
+{
+ pmodule_cmd_svsnoop(viagra_cmd_svsnoop);
+ pmodule_cmd_remove_akill(viagra_cmd_remove_akill);
+ pmodule_cmd_topic(viagra_cmd_topic);
+ pmodule_cmd_vhost_off(viagra_cmd_vhost_off);
+ pmodule_cmd_akill(viagra_cmd_akill);
+ pmodule_cmd_svskill(viagra_cmd_svskill);
+ pmodule_cmd_svsmode(viagra_cmd_svsmode);
+ pmodule_cmd_372(viagra_cmd_372);
+ pmodule_cmd_372_error(viagra_cmd_372_error);
+ pmodule_cmd_375(viagra_cmd_375);
+ pmodule_cmd_376(viagra_cmd_376);
+ pmodule_cmd_nick(viagra_cmd_nick);
+ pmodule_cmd_guest_nick(viagra_cmd_guest_nick);
+ pmodule_cmd_mode(viagra_cmd_mode);
+ pmodule_cmd_bot_nick(viagra_cmd_bot_nick);
+ pmodule_cmd_kick(viagra_cmd_kick);
+ pmodule_cmd_notice_ops(viagra_cmd_notice_ops);
+ pmodule_cmd_notice(viagra_cmd_notice);
+ pmodule_cmd_notice2(viagra_cmd_notice2);
+ pmodule_cmd_privmsg(viagra_cmd_privmsg);
+ pmodule_cmd_privmsg2(viagra_cmd_privmsg2);
+ pmodule_cmd_serv_notice(viagra_cmd_serv_notice);
+ pmodule_cmd_serv_privmsg(viagra_cmd_serv_privmsg);
+ pmodule_cmd_bot_chan_mode(viagra_cmd_bot_chan_mode);
+ pmodule_cmd_351(viagra_cmd_351);
+ pmodule_cmd_quit(viagra_cmd_quit);
+ pmodule_cmd_pong(viagra_cmd_pong);
+ pmodule_cmd_join(viagra_cmd_join);
+ pmodule_cmd_unsqline(viagra_cmd_unsqline);
+ pmodule_cmd_invite(viagra_cmd_invite);
+ pmodule_cmd_part(viagra_cmd_part);
+ pmodule_cmd_391(viagra_cmd_391);
+ pmodule_cmd_250(viagra_cmd_250);
+ pmodule_cmd_307(viagra_cmd_307);
+ pmodule_cmd_311(viagra_cmd_311);
+ pmodule_cmd_312(viagra_cmd_312);
+ pmodule_cmd_317(viagra_cmd_317);
+ pmodule_cmd_219(viagra_cmd_219);
+ pmodule_cmd_401(viagra_cmd_401);
+ pmodule_cmd_318(viagra_cmd_318);
+ pmodule_cmd_242(viagra_cmd_242);
+ pmodule_cmd_243(viagra_cmd_243);
+ pmodule_cmd_211(viagra_cmd_211);
+ pmodule_cmd_global(viagra_cmd_global);
+ pmodule_cmd_global_legacy(viagra_cmd_global_legacy);
+ pmodule_cmd_sqline(viagra_cmd_sqline);
+ pmodule_cmd_squit(viagra_cmd_squit);
+ pmodule_cmd_svso(viagra_cmd_svso);
+ pmodule_cmd_chg_nick(viagra_cmd_chg_nick);
+ pmodule_cmd_svsnick(viagra_cmd_svsnick);
+ pmodule_cmd_vhost_on(viagra_cmd_vhost_on);
+ pmodule_cmd_connect(viagra_cmd_connect);
+ pmodule_cmd_svshold(viagra_cmd_svshold);
+ pmodule_cmd_release_svshold(viagra_cmd_release_svshold);
+ pmodule_cmd_unsgline(viagra_cmd_unsqline);
+ pmodule_cmd_unszline(viagra_cmd_unszline);
+ pmodule_cmd_szline(viagra_cmd_szline);
+ pmodule_cmd_sgline(viagra_cmd_sgline);
+ pmodule_cmd_unban(viagra_cmd_unban);
+ pmodule_cmd_svsmode_chan(viagra_cmd_svsmode_chan);
+ pmodule_cmd_svid_umode(viagra_cmd_svid_umode);
+ pmodule_cmd_nc_change(viagra_cmd_nc_change);
+ pmodule_cmd_svid_umode2(viagra_cmd_svid_umode2);
+ pmodule_cmd_svid_umode3(viagra_cmd_svid_umode3);
+ pmodule_cmd_eob(viagra_cmd_eob);
+ pmodule_flood_mode_check(viagra_flood_mode_check);
+ pmodule_cmd_jupe(viagra_cmd_jupe);
+ pmodule_valid_nick(viagra_valid_nick);
+ pmodule_cmd_ctcp(viagra_cmd_ctcp);
+ pmodule_set_umode(viagra_set_umode);
+}
+
+/**
+ * Now tell anope how to use us.
+ **/
+int AnopeInit(int argc, char **argv)
+{
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion("$Id$");
+ moduleSetType(PROTOCOL);
+
+ pmodule_ircd_version("ViagraIRCd 1.3.x");
+ pmodule_ircd_cap(myIrcdcap);
+ pmodule_ircd_var(myIrcd);
+ pmodule_ircd_cbmodeinfos(myCbmodeinfos);
+ pmodule_ircd_cumodes(myCumodes);
+ pmodule_ircd_flood_mode_char_set("");
+ pmodule_ircd_flood_mode_char_remove("");
+ pmodule_ircd_cbmodes(myCbmodes);
+ pmodule_ircd_cmmodes(myCmmodes);
+ pmodule_ircd_csmodes(myCsmodes);
+ pmodule_ircd_useTSMode(0);
+
+ /** Deal with modes anope _needs_ to know **/
+ pmodule_invis_umode(UMODE_i);
+ pmodule_oper_umode(UMODE_o);
+ pmodule_invite_cmode(CMODE_i);
+ pmodule_secret_cmode(CMODE_s);
+ pmodule_private_cmode(CMODE_p);
+ pmodule_key_mode(CMODE_k);
+ pmodule_limit_mode(CMODE_l);
+
+ moduleAddAnopeCmds();
+ moduleAddIRCDMsgs();
+
+ return MOD_CONT;
+}
diff --git a/src/protocol/viagra.h b/src/protocol/viagra.h
new file mode 100644
index 000000000..4e145e92e
--- /dev/null
+++ b/src/protocol/viagra.h
@@ -0,0 +1,132 @@
+/* Viagra IRCD functions
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ *
+ */
+
+/* User Modes */
+#define UMODE_A 0x00000040 /* Is a Server Administrator. */
+#define UMODE_C 0x00002000 /* Is a Server Co Administrator. */
+#define UMODE_I 0x00008000 /* Stealth mode, makes you beeing hidden at channel. invisible joins/parts. */
+#define UMODE_N 0x00000400 /* Is a Network Administrator. */
+#define UMODE_O 0x00004000 /* Local IRC Operator. */
+#define UMODE_Q 0x00001000 /* Is an Abuse Administrator. */
+#define UMODE_R 0x08000000 /* Cant receive messages from non registered user. */
+#define UMODE_S 0x00000080 /* Is a Network Service. For Services only. */
+#define UMODE_T 0x00000800 /* Is a Technical Administrator. */
+#define UMODE_a 0x00000001 /* Is a Services Administrator. */
+#define UMODE_b 0x00040000 /* Can listen to generic bot warnings. */
+#define UMODE_c 0x00010000 /* See's all connects/disconnects on local server. */
+#define UMODE_d 0x00000100 /* Can listen to debug and channel cration notices. */
+#define UMODE_e 0x00080000 /* Can see client connections/exits on remote servers. */
+#define UMODE_f 0x00100000 /* Listen to flood/spam alerts from server. */
+#define UMODE_g 0x00000200 /* Can read & send to globops, and locops. */
+#define UMODE_h 0x00000002 /* Is a Help Operator. */
+#define UMODE_i 0x00000004 /* Invisible (Not shown in /who and /names searches). */
+#define UMODE_n 0x00020000 /* Can see client nick change notices. */
+#define UMODE_o 0x00000008 /* Global IRC Operator. */
+#define UMODE_r 0x00000010 /* Identifies the nick as being registered. */
+#define UMODE_s 0x00200000 /* Can listen to generic server messages. */
+#define UMODE_w 0x00000020 /* Can listen to wallop messages. */
+#define UMODE_x 0x40000000 /* Gives the user hidden hostname. */
+
+
+/* Channel Modes */
+#define CMODE_i 0x00000001 /* Invite-only allowed. */
+#define CMODE_m 0x00000002 /* Moderated channel, noone can speak and changing nick except users with mode +vho */
+#define CMODE_n 0x00000004 /* No messages from outside channel */
+#define CMODE_p 0x00000008 /* Private channel. */
+#define CMODE_s 0x00000010 /* Secret channel. */
+#define CMODE_t 0x00000020 /* Only channel operators may set the topic */
+#define CMODE_k 0x00000040 /* Needs the channel key to join the channel */
+#define CMODE_l 0x00000080 /* Channel may hold at most <number> of users */
+#define CMODE_R 0x00000100 /* Requires a registered nickname to join the channel. */
+#define CMODE_r 0x00000200 /* Channel is registered. */
+#define CMODE_c 0x00000400 /* No ANSI color can be sent to the channel */
+#define CMODE_M 0x00000800 /* Requires a registered nickname to speak at the channel. */
+#define CMODE_H 0x00001000 /* HelpOps only channel. */
+#define CMODE_O 0x00008000 /* IRCOps only channel. */
+#define CMODE_S 0x00020000 /* Strips all mesages out of colors. */
+#define CMODE_N 0x01000000 /* No nickchanges allowed. */
+#define CMODE_P 0x02000000 /* "Peace mode" No kicks allowed unless by u:lines */
+#define CMODE_x 0x04000000 /* No bold/underlined or reversed text can be sent to the channel */
+
+#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
+
+void viagra_set_umode(User * user, int ac, char **av);
+void viagra_cmd_svsnoop(char *server, int set);
+void viagra_cmd_remove_akill(char *user, char *host);
+void viagra_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+void viagra_cmd_vhost_off(User * u);
+void viagra_cmd_akill(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+void viagra_cmd_svskill(char *source, char *user, char *buf);
+void viagra_cmd_svsmode(User * u, int ac, char **av);
+void viagra_cmd_372(char *source, char *msg);
+void viagra_cmd_372_error(char *source);
+void viagra_cmd_375(char *source);
+void viagra_cmd_376(char *source);
+void viagra_cmd_nick(char *nick, char *name, char *modes);
+void viagra_cmd_guest_nick(char *nick, char *user, char *host, char *real, char *modes);
+void viagra_cmd_mode(char *source, char *dest, char *buf);
+void viagra_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes);
+void viagra_cmd_kick(char *source, char *chan, char *user, char *buf);
+void viagra_cmd_notice_ops(char *source, char *dest, char *buf);
+void viagra_cmd_notice(char *source, char *dest, char *buf);
+void viagra_cmd_notice2(char *source, char *dest, char *msg);
+void viagra_cmd_privmsg(char *source, char *dest, char *buf);
+void viagra_cmd_privmsg2(char *source, char *dest, char *msg);
+void viagra_cmd_serv_notice(char *source, char *dest, char *msg);
+void viagra_cmd_serv_privmsg(char *source, char *dest, char *msg);
+void viagra_cmd_bot_chan_mode(char *nick, char *chan);
+void viagra_cmd_351(char *source);
+void viagra_cmd_quit(char *source, char *buf);
+void viagra_cmd_pong(char *servname, char *who);
+void viagra_cmd_join(char *user, char *channel, time_t chantime);
+void viagra_cmd_unsqline(char *user);
+void viagra_cmd_invite(char *source, char *chan, char *nick);
+void viagra_cmd_part(char *nick, char *chan, char *buf);
+void viagra_cmd_391(char *source, char *timestr);
+void viagra_cmd_250(char *buf);
+void viagra_cmd_307(char *buf);
+void viagra_cmd_311(char *buf);
+void viagra_cmd_312(char *buf);
+void viagra_cmd_317(char *buf);
+void viagra_cmd_219(char *source, char *letter);
+void viagra_cmd_401(char *source, char *who);
+void viagra_cmd_318(char *source, char *who);
+void viagra_cmd_242(char *buf);
+void viagra_cmd_243(char *buf);
+void viagra_cmd_211(char *buf);
+void viagra_cmd_global(char *source, char *buf);
+void viagra_cmd_global_legacy(char *source, char *fmt);
+void viagra_cmd_sqline(char *mask, char *reason);
+void viagra_cmd_squit(char *servname, char *message);
+void viagra_cmd_svso(char *source, char *nick, char *flag);
+void viagra_cmd_chg_nick(char *oldnick, char *newnick);
+void viagra_cmd_svsnick(char *source, char *guest, time_t when);
+void viagra_cmd_vhost_on(char *nick, char *vIdent, char *vhost);
+void viagra_cmd_connect(int servernum);
+void viagra_cmd_svshold(char *nick);
+void viagra_cmd_release_svshold(char *nick);
+void viagra_cmd_unsgline(char *mask);
+void viagra_cmd_unszline(char *mask);
+void viagra_cmd_szline(char *mask, char *reason, char *whom);
+void viagra_cmd_sgline(char *mask, char *reason);
+void viagra_cmd_unban(char *name, char *nick);
+void viagra_cmd_svsmode_chan(char *name, char *mode, char *nick);
+void viagra_cmd_svid_umode(char *nick, time_t ts);
+void viagra_cmd_nc_change(User * u);
+void viagra_cmd_svid_umode2(User * u, char *ts);
+void viagra_cmd_svid_umode3(User * u, char *ts);
+void viagra_cmd_eob();
+int viagra_flood_mode_check(char *value);
+void viagra_cmd_jupe(char *jserver, char *who, char *reason);
+int viagra_valid_nick(char *nick);
+void viagra_cmd_ctcp(char *source, char *dest, char *buf);
diff --git a/src/servers.c b/src/servers.c
index 872e1d5a0..2fe928318 100644
--- a/src/servers.c
+++ b/src/servers.c
@@ -343,7 +343,7 @@ void do_server(const char *source, char *servername, char *hops,
s = findserver(servlist, source);
new_server(s, servername, descript, 0, numeric);
- send_event(EVENT_SERVER_CONNECT, servername);
+ send_event(EVENT_SERVER_CONNECT, 1, servername);
}
/*************************************************************************/
@@ -372,7 +372,7 @@ void do_squit(const char *source, int ac, char **av)
alog("SQUIT for nonexistent server (%s)!!", av[0]);
return;
}
- send_event(EVENT_SERVER_SQUIT, s->name);
+ send_event(EVENT_SERVER_SQUIT, 1, s->name);
snprintf(buf, sizeof(buf), "%s %s", s->name,
(s->uplink ? s->uplink->name : ""));
diff --git a/src/tools/Makefile.win32 b/src/tools/Makefile.win32
index 2a60490bf..d48eb5c6b 100644
--- a/src/tools/Makefile.win32
+++ b/src/tools/Makefile.win32
@@ -19,7 +19,6 @@ spotless: clean
-@del *.exe *.lib *.exp
install: FRC
- -@mkdir ..\..\$(DATDEST)\tools
- -@copy *.exe ..\..\$(DATDEST)\tools
+ -@copy *.exe ..\..\$(DATDEST)\
FRC:
diff --git a/src/tools/db-merger.c b/src/tools/db-merger.c
index 1c8a2d7bc..89ee72ea5 100644
--- a/src/tools/db-merger.c
+++ b/src/tools/db-merger.c
@@ -30,9 +30,9 @@
#include <time.h>
#ifndef _WIN32
- #include <unistd.h>
+#include <unistd.h>
#else
- #include "sysconf.h"
+#include "sysconf.h"
#endif
/* CONFIGURATION BLOCK */
diff --git a/src/tools/epona2anope.c b/src/tools/epona2anope.c
index 5ac3cfe8f..e88cae106 100644
--- a/src/tools/epona2anope.c
+++ b/src/tools/epona2anope.c
@@ -30,9 +30,9 @@
#include <time.h>
#ifndef _WIN32
- #include <unistd.h>
+#include <unistd.h>
#else
- #include "sysconf.h"
+#include "sysconf.h"
#endif
/* CONFIGURATION BLOCK */
diff --git a/src/users.c b/src/users.c
index af95c067c..3f9fb9235 100644
--- a/src/users.c
+++ b/src/users.c
@@ -212,7 +212,7 @@ void delete_user(User * user)
}
free(realname);
}
- send_event(EVENT_USER_LOGOFF, user->nick);
+ send_event(EVENT_USER_LOGOFF, 1, user->nick);
if (debug >= 2)
alog("debug: delete_user() called");
@@ -642,7 +642,7 @@ User *do_nick(const char *source, char *nick, char *username, char *host,
} else {
user->svid = 1;
}
- send_event(EVENT_NEWNICK, nick);
+ send_event(EVENT_NEWNICK, 1, nick);
} else {
/* An old user changing nicks. */
@@ -687,7 +687,7 @@ User *do_nick(const char *source, char *nick, char *username, char *host,
}
change_user_nick(user, nick);
- send_event(EVENT_CHANGE_NICK, nick);
+ send_event(EVENT_CHANGE_NICK, 1, nick);
if ((old_na ? old_na->nc : NULL) ==
(user->na ? user->na->nc : NULL))
@@ -892,7 +892,7 @@ int is_protected(User * user)
int is_oper(User * user)
{
if (user) {
- return (user->mode & UMODE_o);
+ return (user->mode & anope_get_oper_mode());
} else {
return 0;
}