diff options
-rw-r--r-- | Changes | 7 | ||||
-rw-r--r-- | Changes.conf | 6 | ||||
-rw-r--r-- | Changes.lang | 8 | ||||
-rwxr-xr-x | Config | 12 | ||||
-rwxr-xr-x | configure | 50 | ||||
-rw-r--r-- | include/bahamut.h | 55 | ||||
-rw-r--r-- | include/commands.h | 18 | ||||
-rw-r--r-- | include/dreamforge.h | 51 | ||||
-rw-r--r-- | include/extern.h | 318 | ||||
-rw-r--r-- | include/hybrid.h | 48 | ||||
-rw-r--r-- | include/ptlink.h | 60 | ||||
-rw-r--r-- | include/rageircd.h | 58 | ||||
-rw-r--r-- | include/services.h | 1173 | ||||
-rw-r--r-- | include/sysconf.h.in | 7 | ||||
-rw-r--r-- | include/ultimate2.h | 63 | ||||
-rw-r--r-- | include/ultimate3.h | 60 | ||||
-rw-r--r-- | include/unreal31.h | 66 | ||||
-rw-r--r-- | include/unreal32.h | 80 | ||||
-rw-r--r-- | include/version.sh | 37 | ||||
-rw-r--r-- | include/viagra.h | 76 | ||||
-rw-r--r-- | lang/cat.l | 13 | ||||
-rw-r--r-- | lang/de.l | 12 | ||||
-rw-r--r-- | lang/en_us.l | 13 | ||||
-rw-r--r-- | lang/es.l | 13 | ||||
-rw-r--r-- | lang/fr.l | 13 | ||||
-rw-r--r-- | lang/gr.l | 13 | ||||
-rw-r--r-- | lang/hun.l | 12 | ||||
-rw-r--r-- | lang/it.l | 13 | ||||
-rw-r--r-- | lang/nl.l | 13 | ||||
-rw-r--r-- | lang/pl.l | 12 | ||||
-rw-r--r-- | lang/pt.l | 13 | ||||
-rw-r--r-- | lang/ru.l | 13 | ||||
-rw-r--r-- | lang/tr.l | 13 | ||||
-rw-r--r-- | src/Makefile | 15 | ||||
-rw-r--r-- | src/actions.c | 163 | ||||
-rw-r--r-- | src/bahamut.c | 1299 | ||||
-rw-r--r-- | src/botserv.c | 237 | ||||
-rw-r--r-- | src/channels.c | 648 | ||||
-rw-r--r-- | src/chanserv.c | 939 | ||||
-rw-r--r-- | src/commands.c | 18 | ||||
-rw-r--r-- | src/datafiles.c | 11 | ||||
-rw-r--r-- | src/dreamforge.c | 1123 | ||||
-rw-r--r-- | src/hostserv.c | 157 | ||||
-rw-r--r-- | src/hybrid.c | 1154 | ||||
-rw-r--r-- | src/init.c | 207 | ||||
-rw-r--r-- | src/language.c | 3 | ||||
-rw-r--r-- | src/log.c | 5 | ||||
-rw-r--r-- | src/main.c | 41 | ||||
-rw-r--r-- | src/messages.c | 1203 | ||||
-rw-r--r-- | src/misc.c | 2 | ||||
-rw-r--r-- | src/modules.c | 6 | ||||
-rw-r--r-- | src/modules/ircd_catserv.c | 2 | ||||
-rw-r--r-- | src/mysql.c | 31 | ||||
-rw-r--r-- | src/news.c | 4 | ||||
-rw-r--r-- | src/nickserv.c | 350 | ||||
-rw-r--r-- | src/operserv.c | 680 | ||||
-rw-r--r-- | src/proxy.c | 36 | ||||
-rw-r--r-- | src/ptlink.c | 1217 | ||||
-rw-r--r-- | src/rageircd.c | 1273 | ||||
-rw-r--r-- | src/send.c | 118 | ||||
-rw-r--r-- | src/servers.c | 167 | ||||
-rw-r--r-- | src/sessions.c | 30 | ||||
-rw-r--r-- | src/ultimate2.c | 1318 | ||||
-rw-r--r-- | src/ultimate3.c | 1427 | ||||
-rw-r--r-- | src/unreal31.c | 1340 | ||||
-rw-r--r-- | src/unreal32.c | 1434 | ||||
-rw-r--r-- | src/users.c | 519 | ||||
-rw-r--r-- | src/viagra.c | 1349 | ||||
-rw-r--r-- | version.log | 6 |
69 files changed, 16206 insertions, 4745 deletions
@@ -1,3 +1,10 @@ +Anope Version S V N +------------------- +Provided by Anope Dev. <dev@anope.org> - 2004 + +Provided by Trystan <trystan@nomadirc.net> - 2004 +08/23 A New protocol independent design (aka anope-capab). [ #00] + Anope Version 1.7.5 ------------------- Provided by Anope Dev. <dev@anope.org> - 2004 diff --git a/Changes.conf b/Changes.conf index 4f7441251..3255ef221 100644 --- a/Changes.conf +++ b/Changes.conf @@ -1,3 +1,9 @@ +Anope Version S V N +------------------- +** ADDED CONFIGURATION DIRECTIVES ** +** MODIFIED CONFIGURATION DIRECTIVES ** +** DELETED CONFIGURATION DIRECTIVES ** + Anope Version 1.7.5 ------------------- ** ADDED CONFIGURATION DIRECTIVES ** diff --git a/Changes.lang b/Changes.lang index ef74b4a0d..19bc817f0 100644 --- a/Changes.lang +++ b/Changes.lang @@ -1,3 +1,11 @@ +Anope Version S V N +------------------- +*** New Strings: + +*** Mod Strings: + +*** Del Strings: + Anope Version 1.7.5 ------------------- *** New Strings: @@ -214,13 +214,15 @@ ok=0 echo "Select the closest to the type of server on your IRC network:" echo " 1) DreamForge 4.6.7 [dated IRCd, upgrade to a current one]" echo " 2) Bahamut 1.4.27 [or later]" -echo " 3) UnrealIRCd 3.1.1 [or later]" +echo " 3) UnrealIRCd 3.1.1 [or later (not 3.2)]" echo " 4) UltimateIRCd 2.8.2 [or later]" echo " 5) UltimateIRCd 3.0.0 [alpha26 or later]" echo " 6) Hybrid IRCd 7.0 [experimental]" echo " 7) ViagraIRCd 1.3.x [or later]" echo " 8) PTlink 6.15.0 [experimental]" echo " 9) RageIRCd 2.0 [beta-3 or later]" +echo " 10) Unreal 3.2 [Unreal 3.2 beta19 or later]" + while [ $ok -eq 0 ] ; do echo2 "[$IRCTYPE] " @@ -242,7 +244,7 @@ while [ $ok -eq 0 ] ; do ok=1; ;; 3) - IRCTYPE_DEF="IRC_UNREAL" + IRCTYPE_DEF="IRC_UNREAL31" ok=1; ;; 4) @@ -270,6 +272,12 @@ while [ $ok -eq 0 ] ; do ok=1; ;; + 10) + IRCTYPE_DEF="IRC_UNREAL32" + ok=1; + ;; + + *) echo "Please enter a valid option number." ;; @@ -1289,23 +1289,6 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - - - - - - - - - - - - if test $# = 0; then echo "You might want to run ./Config or provide some parameters to this script." echo "./configure --help for information about this script" @@ -2888,8 +2871,6 @@ _ACEOF MYSQL=" mysql.c " RDB=" rdb.c " - - x="1"; @@ -8365,36 +8346,21 @@ cat >>confdefs.h <<\_ACEOF #define IRC_BAHAMUT 1 _ACEOF - elif test "$withval" = "IRC_UNREAL"; then - -cat >>confdefs.h <<\_ACEOF -#define IRC_DREAMFORGE 1 -_ACEOF - + elif test "$withval" = "IRC_UNREAL31"; then cat >>confdefs.h <<\_ACEOF -#define IRC_UNREAL 1 +#define IRC_UNREAL31 1 _ACEOF elif test "$withval" = "IRC_ULTIMATE"; then cat >>confdefs.h <<\_ACEOF -#define IRC_DREAMFORGE 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define IRC_ULTIMATE 1 +#define IRC_ULTIMATE2 1 _ACEOF elif test "$withval" = "IRC_ULTIMATE3"; then cat >>confdefs.h <<\_ACEOF -#define IRC_BAHAMUT 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF #define IRC_ULTIMATE3 1 _ACEOF @@ -8407,11 +8373,6 @@ _ACEOF elif test "$withval" = "IRC_VIAGRA"; then cat >>confdefs.h <<\_ACEOF -#define IRC_BAHAMUT 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF #define IRC_VIAGRA 1 _ACEOF @@ -8424,12 +8385,13 @@ _ACEOF elif test "$withval" = "IRC_RAGE2"; then cat >>confdefs.h <<\_ACEOF -#define IRC_BAHAMUT 1 +#define IRC_RAGE2 1 _ACEOF + elif test "$withval" = "IRC_UNREAL32"; then cat >>confdefs.h <<\_ACEOF -#define IRC_RAGE2 1 +#define IRC_UNREAL32 1 _ACEOF fi diff --git a/include/bahamut.h b/include/bahamut.h new file mode 100644 index 000000000..e04729463 --- /dev/null +++ b/include/bahamut.h @@ -0,0 +1,55 @@ +/* Bahamut functions + * + * (C) 2003 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. + * + * + */ + +/*************************************************************************/ + +#ifdef IRC_BAHAMUT + +#define PROTECT_SET_MODE "+" +#define PROTECT_UNSET_MODE "+" +#define CS_CMD_PROTECT "PROTECT" +#define CS_CMD_DEPROTECT "DEPROTECT" +#define FANT_PROTECT_ADD "!protect" +#define FANT_PROTECT_DEL "!deprotect" +#define LEVEL_PROTECT_WORD "AUTOPROTECT" +#define LEVELINFO_PROTECT_WORD "PROTECT" +#define LEVELINFO_PROTECTME_WORD "PROTECTME" + + +#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 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 /* Colors can't be used */ +#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ +#define CMODE_O 0x00008000 /* Only opers can join */ +#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 + +#endif + diff --git a/include/commands.h b/include/commands.h index 00a866219..28226b14f 100644 --- a/include/commands.h +++ b/include/commands.h @@ -20,15 +20,15 @@ * terminated with a NULL name. */ -extern Command *lookup_cmd(Command *list, const char *name); -extern void run_cmd(const char *service, User *u, Command *list, - const char *name); -extern void help_cmd(const char *service, User *u, Command *list, - const char *name); -extern void do_run_cmd(const char *service, User * u, Command *c,const char *cmd); -extern void do_help_cmd(const char *service, User * u, Command *c,const char *cmd); -extern void mod_help_cmd(const char *service, User *u, CommandHash *cmdTable[],const char *cmd); -extern void mod_run_cmd(const char *service, User *u, CommandHash *cmdTable[],const char *cmd); +extern Command *lookup_cmd(Command *list, char *name); +extern void run_cmd(char *service, User *u, Command *list, + char *name); +extern void help_cmd(char *service, User *u, Command *list, + char *name); +extern void do_run_cmd(char *service, User * u, Command *c,const char *cmd); +extern void do_help_cmd(char *service, User * u, Command *c,const char *cmd); +extern void mod_help_cmd(char *service, User *u, CommandHash *cmdTable[],const char *cmd); +extern void mod_run_cmd(char *service, User *u, CommandHash *cmdTable[],const char *cmd); extern char *mod_current_module_name; /*************************************************************************/ diff --git a/include/dreamforge.h b/include/dreamforge.h new file mode 100644 index 000000000..f5f3c755f --- /dev/null +++ b/include/dreamforge.h @@ -0,0 +1,51 @@ +/* DreamForge IRCD functions + * + * (C) 2003 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. + * + * + */ + +#ifdef IRC_DREAMFORGE + +#define OWNER_SET_MODE "+" +#define OWNER_UNSET_MODE "+" +#define PROTECT_SET_MODE "+" +#define PROTECT_UNSET_MODE "+" +#define CS_CMD_PROTECT "PROTECT" +#define CS_CMD_DEPROTECT "DEPROTECT" +#define FANT_PROTECT_ADD "!protect" +#define FANT_PROTECT_DEL "!deprotect" +#define LEVEL_PROTECT_WORD "AUTOPROTECT" +#define LEVELINFO_PROTECT_WORD "PROTECT" +#define LEVELINFO_PROTECTME_WORD "PROTECTME" + +#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 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 + +#endif + diff --git a/include/extern.h b/include/extern.h index fe02b446b..d7d9b71a4 100644 --- a/include/extern.h +++ b/include/extern.h @@ -19,23 +19,24 @@ #define E extern +E char *uplink; -/**** modules.c ****/ -E void moduleCallBackRun(void); -E void moduleCleanStruct(ModuleData * moduleData[]); +/* IRC Variables */ +E IRCDVar ircd[]; +E IRCDCAPAB ircdcap[]; /**** actions.c ****/ -E void change_user_mode(User * u, char *modes, char *arg); -E void kill_user(const char *source, const char *user, const char *reason); +E void kill_user(char *source, char *user, char *reason); E void bad_password(User * u); +E void sqline(char *mask, char *reason); +E void common_unban(ChannelInfo * ci, char *nick); +E void common_svsmode(User * u, char *modes, char *arg); /**** botserv.c ****/ E BotInfo *botlists[256]; - E void get_botserv_stats(long *nrec, long *memuse); - E void bs_init(void); E void botserv(User *u, char *buf); E void botmsgs(User *u, BotInfo *bi, char *buf); @@ -43,7 +44,6 @@ E void botchanmsgs(User *u, ChannelInfo *ci, char *buf); E void load_bs_dbase(void); E void save_bs_dbase(void); E void save_bs_rdb_dbase(void); - E BotInfo *makebot(char *nick); E BotInfo *findbot(char *nick); E void bot_join(ChannelInfo *ci); @@ -54,6 +54,30 @@ E void bot_rejoin_all(BotInfo *bi); E Channel *chanlist[1024]; E CBMode cbmodes[128]; E CBModeInfo cbmodeinfos[]; +E CUMode cumodes[128]; +E CMMode cmmodes[128]; +E unsigned long umodes[128]; +E char csmodes[128]; + +extern void do_mass_mode(char *modes); +extern void add_ban(Channel * chan, char *mask); +extern void chan_adduser2(User * user, Channel * c); +extern void chan_delete(Channel * c); +extern void del_ban(Channel * chan, char *mask); +extern void set_key(Channel * chan, char *value); +extern void set_limit(Channel * chan, char *value); +extern char *get_key(Channel * chan); +extern char *get_limit(Channel * chan); +extern Channel *chan_create(char *chan); +extern Channel *join_user_update(User * user, Channel * chan, char *name); + +extern void add_exception(Channel * chan, char *mask); +extern void del_exception(Channel * chan, char *mask); +extern char *get_flood(Channel * chan); +extern void set_flood(Channel * chan, char *value); +extern char *get_redirect(Channel * chan); +extern void set_redirect(Channel * chan, char *value); + E void get_channel_stats(long *nrec, long *memuse); E Channel *findchan(const char *chan); @@ -84,6 +108,7 @@ E void do_part(const char *source, int ac, char **av); E void do_sjoin(const char *source, int ac, char **av); E void do_topic(const char *source, int ac, char **av); E void do_mass_mode(char *modes); + #define whosends(ci) ((!(ci) || !((ci)->botflags & BS_SYMBIOSIS) || !(ci)->bi || !(ci)->c || (ci)->c->usercount < BSMinUsers) ? s_ChanServ : (ci)->bi->nick) /**** chanserv.c ****/ @@ -107,25 +132,16 @@ E void cs_remove_nick(const NickCore * nc); E void cs_remove_bot(const BotInfo * bi); E void check_modes(Channel * c); -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) E int check_valid_admin(User * user, Channel * chan, int servermode); -#endif E int check_valid_op(User * user, Channel * chan, int servermode); -E int check_should_op(User * user, const char *chan); -E int check_should_voice(User * user, const char *chan); -#ifdef HAS_HALFOP -E int check_should_halfop(User * user, const char *chan); -#endif -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) -E int check_should_owner(User * user, const char *chan); -E int check_should_protect(User * user, const char *chan); -#endif -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) || defined(IRC_PTLINK) -E int check_should_protect(User * user, const char *chan); -#endif +E int check_should_op(User * user, char *chan); +E int check_should_voice(User * user, char *chan); +E int check_should_halfop(User * user, char *chan); +E int check_should_owner(User * user, char *chan); +E int check_should_protect(User * user, char *chan); E int check_kick(User * user, char *chan); E void record_topic(const char *chan); -E void restore_topic(const char *chan); +E void restore_topic(char *chan); E int check_topiclock(Channel * c, time_t topic_time); E ChannelInfo *cs_findchan(const char *chan); @@ -138,19 +154,14 @@ E int get_idealban(ChannelInfo * ci, User * u, char *ret, int retlen); E AutoKick *is_stuck(ChannelInfo * ci, char *mask); E void stick_mask(ChannelInfo * ci, AutoKick * akick); E void stick_all(ChannelInfo * ci); - -#ifdef HAS_FMODE E char *cs_get_flood(ChannelInfo * ci); E void cs_set_flood(ChannelInfo * ci, char *value); -#endif E char *cs_get_key(ChannelInfo * ci); E void cs_set_key(ChannelInfo * ci, char *value); E char *cs_get_limit(ChannelInfo * ci); E void cs_set_limit(ChannelInfo * ci, char *value); -#ifdef HAS_LMODE E char *cs_get_redirect(ChannelInfo * ci); E void cs_set_redirect(ChannelInfo * ci, char *value); -#endif /**** compat.c ****/ @@ -482,10 +493,20 @@ E char *DefconMessage; E char *DefConAkillReason; E char *DefConOffMessage; +E int Numeric; + /**** converter.c ****/ E int convert_ircservices_44(void); +/**** helpserv.c ****/ +E void helpserv(User * u, char *buf); +E void helpserv_init(void); + +/**** hostserv.c ****/ +E void hostserv_init(void); +E void addHostCore(char *nick, char *vIdent, char *vhost, char *creator, int32 tmp_time); + /**** init.c ****/ E void introduce_user(const char *user); @@ -505,7 +526,7 @@ E void lang_init(void); (langtexts[((nc)?((NickCore*)nc)->language:NSDefLanguage)][(index)]) E int strftime_lang(char *buf, int size, User * u, int format, struct tm *tm); -E void syntax_error(const char *service, User * u, const char *command, +E void syntax_error(char *service, User * u, char *command, int msgnum); @@ -555,7 +576,6 @@ E int do_mysql; #endif E int is44; - E int quitting; E int delayed_quit; E char *quitmsg; @@ -581,18 +601,28 @@ E void ms_init(void); E void memoserv(User * u, char *buf); E void check_memos(User * u); +/**** messages.c ****/ + +E int m_nickcoll(char *user); +E int m_away(char *source, char *msg); +E int m_kill(char *nick, char *msg); +E int m_motd(char *source); +E int m_privmsg(char *source, char *receiver, char *msg); +E int m_stats(char *source, int ac, char **av); +E int m_whois(char *source, char *who); +E int m_time(char *source, int ac, char **av); +E int m_version(char *source, int ac, char **av); + /**** misc.c ****/ + E char *strscpy(char *d, const char *s, size_t len); E char *stristr(char *s1, char *s2); E char *strnrepl(char *s, int32 size, const char *old, const char *new); - E char *merge_args(int argc, char **argv); - E int match_wild(const char *pattern, const char *str); E int match_wild_nocase(const char *pattern, const char *str); - E int dotime(const char *s); E char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds); E char *expire_left(NickAlias * na, char *buf, int len, time_t expires); @@ -615,11 +645,18 @@ E void EnforceQlinedNick(char *nick, char *killer); E int nickIsServices(char *nick); +E const char* inttobase64(char* buf, unsigned int v, unsigned int count); +E unsigned int base64toIP(const char* s); +E unsigned int base64toint(const char* s); + +/**** modules.c ****/ +E void moduleCallBackRun(void); +E void moduleCleanStruct(ModuleData * moduleData[]); + /**** news.c ****/ E int32 nnews, news_size; E NewsItem *news; - E void get_news_stats(long *nrec, long *memuse); E void load_news(void); E void save_news(void); @@ -629,15 +666,12 @@ E int do_logonnews(User * u); E int do_opernews(User * u); E int do_randomnews(User * u); - /**** nickserv.c ****/ E NickAlias *nalists[1024]; E NickCore *nclists[1024]; E NickRequest *nrlists[1024]; - E unsigned int guestnum; - E void insert_requestnick(NickRequest * nr); E void alpha_insert_alias(NickAlias * na); E void insert_core(NickCore * nc); @@ -660,23 +694,14 @@ E int nick_recognized(User * u); E void expire_nicks(void); E void expire_requests(void); E int ns_do_register(User * u); - E int delnick(NickAlias * na); E NickAlias *findnick(const char *nick); E NickCore *findcore(const char *nick); E void clean_ns_timeouts(NickAlias * na); - E void nsStartNickTracking(User * u); E void nsStopNickTracking(User * u); E int nsCheckNickTracking(User *u); -/**** helpserv.c ****/ -E void helpserv(User * u, char *buf); -E void helpserv_init(void); - -/**** hostserv.c ****/ -E void hostserv_init(void); -E void addHostCore(char *nick, char *vIdent, char *vhost, char *creator, int32 tmp_time); /**** operserv.c ****/ @@ -699,32 +724,28 @@ E int nick_is_services_admin(NickCore *nc); E int nick_is_services_oper(NickCore *nc); E int add_akill(User *u, char *mask, const char *by, const time_t expires, const char *reason); -E int check_akill(const char *nick, const char *username, const char *host, const char *vhost, const char *ip); +E int check_akill(char *nick, const char *username, const char *host, const char *vhost, const char *ip); E void expire_akills(void); E void oper_global(char *nick, char *fmt, ...); -#ifdef IRC_BAHAMUT + E int add_sgline(User *u, char *mask, const char *by, const time_t expires, const char *reason); -E int check_sgline(const char *nick, const char *realname); +E int check_sgline(char *nick, const char *realname); E void expire_sglines(void); -#endif E int add_sqline(User *u, char *mask, const char *by, const time_t expires, const char *reason); -E int check_sqline(const char *nick, int nick_change); -#ifdef IRC_BAHAMUT -E int check_chan_sqline(const char *chan); -#endif +E int check_sqline(char *nick, int nick_change); E void expire_sqlines(void); +E int check_chan_sqline(const char *chan); -#ifdef IRC_BAHAMUT E int add_szline(User * u, char *mask, const char *by, const time_t expires, const char *reason); E void expire_szlines(void); -#endif E void check_clones(User * user); - E void delete_ignore(const char *nick); +E Server *server_global(Server * s, char *msg); + /**** process.c ****/ E int allow_ignore; @@ -736,19 +757,6 @@ E IgnoreData *get_ignore(const char *nick); E int split_buf(char *buf, char ***argv, int colon_special); E void process(void); -/**** protocol.c ****/ - -E void s_akill(char *user, char *host, char *who, time_t when, - time_t expires, char *reason); -E void s_rakill(char *user, char *host); -E void s_sgline(char *mask, char *reason); -E void s_sqline(char *mask, char *reason); -E void s_svsnoop(char *server, int set); -E void s_szline(char *mask, char *reason); -E void s_unsgline(char *mask); -E void s_unsqline(char *mask); -E void s_unszline(char *mask); - /**** proxy.c ****/ E HostCache *hcache[1024]; @@ -769,44 +777,33 @@ E void send_cmd(const char *source, const char *fmt, ...) E void vsend_cmd(const char *source, const char *fmt, va_list args) FORMAT(printf,2,0); -E void wallops(const char *source, const char *fmt, ...) - FORMAT(printf,2,3); - -E void notice(const char *source, const char *dest, const char *fmt, ...) +E void notice_server(char *source, Server * s, char *fmt, ...) FORMAT(printf,3,4); -E void notice_server(const char *source, Server *s, const char *fmt, ...) +E void notice_user(char *source, User *u, const char *fmt, ...) FORMAT(printf,3,4); -E void notice_user(const char *source, User *u, const char *fmt, ...) - FORMAT(printf,3,4); - -E void notice_list(const char *source, const char *dest, const char **text); -E void notice_lang(const char *source, User *dest, int message, ...); -E void notice_help(const char *source, User *dest, int message, ...); -E void privmsg(const char *source, const char *dest, const char *fmt, ...) - FORMAT(printf,3,4); +E void notice_list(char *source, char *dest, char **text); +E void notice_lang(char *source, User *dest, int message, ...); +E void notice_help(char *source, User *dest, int message, ...); -E void send_mode(const char *source, const char *on, const char *fmt, ...) - FORMAT(printf,3,4); /**** servers.c ****/ E Server *servlist; E Server *me_server; -#ifdef IRC_BAHAMUT -E uint16 uplink_capab; -#endif +E uint32 uplink_capab; E Server *first_server(int flags); E Server *next_server(int flags); -E Server *new_server(Server *uplink, const char *name, const char *desc, - uint16 flags); +E Server *new_server(Server * uplink, const char *name, const char *desc, + uint16 flags); E Server *findserver(Server *s, const char *name); E void do_server(const char *source, int ac, char **av); E void do_squit(const char *source, int ac, char **av); +E void capab_parse(int ac, char **av); /**** sessions.c ****/ @@ -817,7 +814,7 @@ E void get_session_stats(long *nrec, long *memuse); E void get_exception_stats(long *nrec, long *memuse); E int do_session(User *u); -E int add_session(const char *nick, const char *host); +E int add_session(char *nick, char *host); E void del_session(const char *host); E void load_exceptions(void); @@ -848,36 +845,31 @@ E User *userlist[1024]; E int32 usercnt, opcnt, maxusercnt; E time_t maxusertime; -E void set_umode(User * user, int ac, char **av); - E void delete_user(User *user); E void get_user_stats(long *nusers, long *memuse); E User *finduser(const char *nick); E User *firstuser(void); E User *nextuser(void); +E User *finduser_uid(const char *uid); -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_PTLINK) || defined(IRC_RAGE2) +E void update_host(User * user); E void change_user_host(User * user, const char *host); -#endif -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_PTLINK) E void change_user_username(User * user, const char *username); E void change_user_realname(User * user, const char *realname); -#endif E User *do_nick(const char *source, char *nick, char *username, char *host, - char *server, char *realname, time_t ts, uint32 svid, ...); + char *server, char *realname, time_t ts, uint32 svid, uint32 ip, char *vhost, char *uid); + E void do_umode(const char *source, int ac, char **av); E void do_quit(const char *source, int ac, char **av); -E void do_kill(const char *source, int ac, char **av); +E void do_kill(char *source, char *reason); E int is_oper(User * user); E int is_protected(User * user); -#ifdef HAS_EXCEPT E int is_excepted(ChannelInfo * ci, User * user); E int is_excepted_mask(ChannelInfo * ci, char *mask); -#endif E int match_usermask(const char *mask, User * user); E void split_usermask(const char *mask, char **nick, char **user, @@ -922,4 +914,128 @@ extern int encrypt_in_place(char *buf, int size); #endif +E void privmsg(char *source, char *dest, const char *fmt, ...); +E void notice(char *source, char *dest, const char *fmt, ...); + +/******************************************************************************/ + +extern void anope_cmd_211(const char *fmt, ...); /* 211 */ +extern void anope_cmd_219(char *source, char *who); /* 219 */ +extern void anope_cmd_242(const char *fmt, ...); /* 242 */ +extern void anope_cmd_243(const char *fmt, ...); /* 243 */ +extern void anope_cmd_250(const char *fmt, ...); /* 250 */ +extern void anope_cmd_307(const char *fmt, ...); /* 307 */ +extern void anope_cmd_311(const char *fmt, ...); /* 311 */ +extern void anope_cmd_312(const char *fmt, ...); /* 312 */ +extern void anope_cmd_317(const char *fmt, ...); /* 317 */ +extern void anope_cmd_318(char *source, char *who); /* 318 */ +extern void anope_cmd_351(char *source); /* 351 */ +extern void anope_cmd_372(char *source, char *msg); /* 372 */ +extern void anope_cmd_372_error(char *source); /* 372 */ +extern void anope_cmd_375(char *source); /* 375 */ +extern void anope_cmd_376(char *source); /* 376 */ +extern void anope_cmd_391(char *source, char *timestr); /* 391 */ +extern void anope_cmd_401(char *source, char *who); /* 401 */ +extern void anope_cmd_akill(char *user, char *host, char *who, time_t when, time_t expires, char *reason); /* AKILL */ +extern void anope_cmd_capab(); /* CAPAB */ +extern void anope_cmd_chghost(char *nick, char *vhost); /* CHGHOST */ +extern void anope_cmd_chgident(char *nick, char *vIdent); /* CHGIDENT */ +extern void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost); /* CHGHOST + CHGIDENT */ +extern void anope_cmd_vhost_off(char *nick); +extern void anope_cmd_connect(int servernum); /* Connect */ +extern void anope_cmd_ea(); /* EA */ +extern void anope_cmd_global(char *source, const char *fmt, ...); /* GLOBOPS */ +extern void anope_cmd_invite(char *source, char *chan, char *nick); /* INVITE */ +extern void anope_cmd_join(char *user, char *channel, time_t chantime); /* JOIN */ +extern void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, ...); /* KICK */ +extern void anope_cmd_mode(char *source, char *dest, const char *fmt, ...); /* MODE */ +extern void anope_cmd_unban(char *name, char *nick); /* MODE -b */ +extern void anope_cmd_bot_chan_mode(char *nick, char *chan); /* MODE BotServ */ +extern void anope_cmd_netinfo(int ac, char **av); /* NETINFO */ +extern void anope_cmd_nick(char *nick, char *name, char *mode); /* NICK */ +extern void anope_cmd_chg_nick(char *oldnick, char *newnick); /* NICK */ +extern void anope_cmd_bot_nick(char *nick, char *user,char *host,char *real,char *modes); /* NICK */ +extern void anope_cmd_guest_nick(char *nick, char *user,char *host,char *real,char *modes); /* NICK */ +extern void anope_cmd_notice(char *source, char *dest, const char *fmt, ...); /* NOTICE */ +extern void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...); /* NOTICE */ +extern void anope_cmd_notice2(char *source, char *dest, char *msg); /* NOTICE */ +extern void anope_cmd_serv_notice(char *source, char *dest, char *msg); /* NOTICE */ +extern void anope_cmd_part(char *nick, char *chan, const char *fmt, ...); /* PART */ +extern void anope_cmd_pass(char *pass); /* PASS */ +extern void anope_cmd_pong(char *servname, char *who); /* PONG */ +extern void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...); /* PRIVMSG */ +extern void anope_cmd_privmsg2(char *source, char *dest, char *msg); /* PRIVMSG */ +extern void anope_cmd_serv_privmsg(char *source, char *dest, char *msg); /* PRIVMSG */ +extern void anope_cmd_protoctl(); /* PROTOCTL */ +extern void anope_cmd_quit(char *source, const char *fmt, ...); /* QUIT */ +extern void anope_cmd_remove_akill(char *user, char *host); /* RAKILL */ +extern void anope_cmd_server(char *servname, int hop, char *descript); /* SERVER */ +extern void anope_cmd_sgline(char *mask, char *reason); /* SGLINE */ +extern void anope_cmd_sqline(char *mask, char *reason); /* SQLINE */ +extern void anope_cmd_szline(char *mask, char *reason); /* SZLINE */ +extern void anope_cmd_squit(char *servname, char *message); /* SQUIT */ +extern void anope_cmd_svinfo(); /* SVINFO */ +extern void anope_cmd_svshold(char *nick); /* SVSHOLD */ +extern void anope_cmd_relase_svshold(char *nick); /* SVSHOLD */ +extern void anope_cmd_svsinfo(); /* SVSINFO */ +extern void anope_cmd_svskill(char *source,char *user, const char *fmt, ...); /* SVSKILL */ +extern void anope_cmd_svsmode(User * u, int ac, char **av); /* SVSMODE */ +extern void anope_cmd_svsnick(char *nick,char *newnick, time_t when); /* SVSNICK */ +extern void anope_cmd_svsnoop(char *server, int set); /* SVSNOOP */ +extern void anope_cmd_svso(char *source,char *nick, char *flag); /* SVSO */ +extern void anope_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when); /* TOPIC */ +extern void anope_cmd_unsgline(char *mask); /* UNSGLINE */ +extern void anope_cmd_unsqline(char *user); /* UNSQLINE */ +extern void anope_cmd_unszline(char *mask); /* UNSZLINE */ + +extern int anope_event_436(char *source, int ac, char **av); +extern int anope_event_away(char *source, int ac, char **av); +extern int anope_event_ping(char *source, int ac, char **av); +extern int anope_event_motd(char *source, int ac, char **av); +extern int anope_event_join(char *source, int ac, char **av); +extern int anope_event_kick(char *source, int ac, char **av); +extern int anope_event_kill(char *source, int ac, char **av); +extern int anope_event_mode(char *source, int ac, char **av); +extern int anope_event_quit(char *source, int ac, char **av); +extern int anope_event_squit(char *source, int ac, char **av); +extern int anope_event_topic(char *source, int ac, char **av); +extern int anope_event_whois(char *source, int ac, char **av); +extern int anope_event_part(char *source, int ac, char **av); +extern int anope_event_server(char *source, int ac, char **av); +extern int anope_event_nick(char *source, int ac, char **av); +extern int anope_event_privmsg(char *source, int ac, char **av); +extern int anope_event_capab(char *source, int ac, char **av); +extern int anope_event_sjoin(char *source, int ac, char **av); +extern int anope_event_cs(char *source, int ac, char **av); +extern int anope_event_hs(char *source, int ac, char **av); +extern int anope_event_ms(char *source, int ac, char **av); +extern int anope_event_ns(char *source, int ac, char **av); +extern int anope_event_os(char *source, int ac, char **av); +extern int anope_event_vs(char *source, int ac, char **av); +extern int anope_event_svinfo(char *source, int ac, char **av); +extern int anope_event_chghost(char *source, int ac, char **av); +extern int anope_event_sethost(char *source, int ac, char **av); +extern int anope_event_chgident(char *source, int ac, char **av); +extern int anope_event_setident(char *source, int ac, char **av); +extern int anope_event_chgname(char *source, int ac, char **av); +extern int anope_event_setname(char *source, int ac, char **av); +extern int anope_event_svsinfo(char *source, int ac, char **av); +extern int anope_event_snick(char *source, int ac, char **av); +extern int anope_event_vhost(char *source, int ac, char **av); /* Rage IRCD Only */ +extern int anope_event_tkl(char *source, int ac, char **av); +extern int anope_event_eos(char *source, int ac, char **av); +extern int anope_event_pass(char *source, int ac, char **av); +extern int anope_event_netinfo(char *source, int ac, char **av); +extern int anope_event_error(char *source, int ac, char **av); +extern int anope_event_eb(char *source, int ac, char **av); + +extern void anope_set_umode(User * user, int ac, char **av); +extern void anope_cmd_svid_umode(char *nick, time_t ts); +extern void anope_cmd_svid_umode2(User *u, char *ts); +extern void anope_cmd_svid_umode3(User *u, char *ts); +extern void anope_cmd_nc_change(User *u); + +extern char *common_get_vident(User *u); +extern char *common_get_vhost(User *u); + #endif /* EXTERN_H */ diff --git a/include/hybrid.h b/include/hybrid.h new file mode 100644 index 000000000..58664e01a --- /dev/null +++ b/include/hybrid.h @@ -0,0 +1,48 @@ +/* Hybrid IRCD functions + * + * (C) 2003 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. + * + * + */ + +#ifdef IRC_HYBRID + +#define PROTECT_SET_MODE "+" +#define PROTECT_UNSET_MODE "+" +#define CS_CMD_PROTECT "PROTECT" +#define CS_CMD_DEPROTECT "DEPROTECT" +#define FANT_PROTECT_ADD "!protect" +#define FANT_PROTECT_DEL "!deprotect" +#define LEVEL_PROTECT_WORD "AUTOPROTECT" +#define LEVELINFO_PROTECT_WORD "PROTECT" +#define LEVELINFO_PROTECTME_WORD "PROTECTME" + +#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 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 DEFAULT_MLOCK CMODE_n | CMODE_t + +#endif + + diff --git a/include/ptlink.h b/include/ptlink.h new file mode 100644 index 000000000..ca031b720 --- /dev/null +++ b/include/ptlink.h @@ -0,0 +1,60 @@ +/* PTLink IRCD functions + * + * (C) 2003 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. + * + * + */ + +#ifdef IRC_PTLINK + +#define PROTECT_SET_MODE "+a" +#define PROTECT_UNSET_MODE "+a" +#define CS_CMD_PROTECT "PROTECT" +#define CS_CMD_DEPROTECT "DEPROTECT" +#define FANT_PROTECT_ADD "!protect" +#define FANT_PROTECT_DEL "!deprotect" +#define LEVEL_PROTECT_WORD "AUTOPROTECT" +#define LEVELINFO_PROTECT_WORD "PROTECT" +#define LEVELINFO_PROTECTME_WORD "PROTECTME" + +#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 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 DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r + +#endif + + diff --git a/include/rageircd.h b/include/rageircd.h new file mode 100644 index 000000000..e130e6756 --- /dev/null +++ b/include/rageircd.h @@ -0,0 +1,58 @@ +/* Rage IRCD functions + * + * (C) 2003 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. + * + * + */ + +#ifdef IRC_RAGE2 + +#define PROTECT_SET_MODE "+a" +#define PROTECT_UNSET_MODE "+a" +#define FANT_PROTECT_ADD "!admin" +#define FANT_PROTECT_DEL "!deadmin" +#define LEVEL_PROTECT_WORD "AUTOADMIN" +#define LEVELINFO_PROTECT_WORD "ADMIN" +#define LEVELINFO_PROTECTME_WORD "ADMINME" +#define CS_CMD_PROTECT "ADMIN" +#define CS_CMD_DEPROTECT "DEADMIN" + +#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_A 0x00000800 +#define CMODE_N 0x00001000 +#define CMODE_S 0x00002000 +#define CMODE_C 0x00004000 +#define CMODE_c 0x00000400 /* Colors can't be used */ +#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ +#define CMODE_O 0x00008000 /* Only opers can join */ +#define CMODE_R 0x00000100 /* Only identified users can join */ +#define CMODE_r 0x00000200 /* Set for all registered channels */ +#define CMODE_I 0x08000000 + +#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r + +#endif + diff --git a/include/services.h b/include/services.h index 8fcdba9d4..52cd43a1c 100644 --- a/include/services.h +++ b/include/services.h @@ -57,9 +57,13 @@ #ifdef USE_MYSQL # define MYSQL_WARNING 2 # define MYSQL_ERROR 4 - -#include "mysql.h" -#include "errmsg.h" +#ifdef HAVE_MYSQL_MYSQL_H +# include <mysql.h> +# include <errmsg.h> +#else +# include <mysql/mysql.h> +# include <mysql/errmsg.h> +#endif #endif #if HAVE_STRINGS_H @@ -124,280 +128,155 @@ extern int toupper(char), tolower(char); typedef struct server_ Server; typedef struct user_ User; typedef struct channel_ Channel; +typedef struct ModuleData_ ModuleData; /* ModuleData struct */ +typedef struct ModuleDataItem_ ModuleDataItem; /* A Module Data Item struct */ +typedef struct memo_ Memo; +typedef struct nickrequest_ NickRequest; +typedef struct nickalias_ NickAlias; +typedef struct nickcore_ NickCore; +typedef struct botinfo_ BotInfo; +typedef struct chaninfo_ ChannelInfo; +typedef struct badword_ BadWord; +typedef struct bandata_ BanData; +typedef struct userdata_ UserData; +typedef struct mailinfo_ MailInfo; +typedef struct akill_ Akill; +typedef struct sxline_ SXLine; +typedef struct hostcore_ HostCore; +typedef struct newsitem_ NewsItem; +typedef struct hostcache_ HostCache; +typedef struct exception_ Exception; +typedef struct cbmode_ CBMode; +typedef struct cbmodeinfo_ CBModeInfo; +typedef struct cmmode_ CMMode; +typedef struct csmode_ CSMode; +typedef struct cumode_ CUMode; +typedef struct csmodeutil_ CSModeUtil; /*************************************************************************/ -/*************************************************************************/ -/* Protocol tweaks */ - - - -#ifdef IRC_HYBRID -# define HAS_HALFOP -# define HAS_EXCEPT /* Has +e (chan excepts) */ -# define NICKSERV_MODE "+o" -# define CHANSERV_MODE "+o" -# define MEMOSERV_MODE "+o" -# define BOTSERV_MODE "+o" -# define HELPSERV_MODE "+h" -# define OPERSERV_MODE "+io" -# define DEVNULL_MODE "+i" -# define GLOBAL_MODE "+io" -# define NICKSERV_ALIAS_MODE "+o" -# define CHANSERV_ALIAS_MODE "+o" -# define MEMOSERV_ALIAS_MODE "+o" -# define BOTSERV_ALIAS_MODE "+o" -# define HELPSERV_ALIAS_MODE "+h" -# define OPERSERV_ALIAS_MODE "+io" -# define DEVNULL_ALIAS_MODE "+i" -# define GLOBAL_ALIAS_MODE "+io" -# define BOTSERV_BOTS_MODE "+" -#endif - -#ifdef IRC_VIAGRA -# define HAS_HALFOP -# define HAS_VHOST -# define HAS_VIDENT -# define HAS_EXCEPT -# define NICKSERV_MODE "+oS" -# define CHANSERV_MODE "+oS" -# define HOSTSERV_MODE "+oS" -# define MEMOSERV_MODE "+oS" -# define BOTSERV_MODE "+oS" -# define HELPSERV_MODE "+oS" -# define OPERSERV_MODE "+ioS" -# define DEVNULL_MODE "+i" -# define GLOBAL_MODE "+ioS" -# define NICKSERV_ALIAS_MODE "+oS" -# define CHANSERV_ALIAS_MODE "+oS" -# define MEMOSERV_ALIAS_MODE "+oS" -# define BOTSERV_ALIAS_MODE "+oS" -# define HELPSERV_ALIAS_MODE "+oS" -# define OPERSERV_ALIAS_MODE "+ioS" -# define DEVNULL_ALIAS_MODE "+iS" -# define GLOBAL_ALIAS_MODE "+ioS" -# define HOSTSERV_ALIAS_MODE "+ioS" -# define BOTSERV_BOTS_MODE "+qS" -#endif +typedef enum { false, true } boolean; -#if defined(IRC_BAHAMUT) -# define HAS_NICKIP - #if !defined(IRC_ULTIMATE3) && !defined(IRC_VIAGRA) && !defined(IRC_RAGE2) -# define HAS_EXCEPT -# define HAS_SVSHOLD -# define NICKSERV_MODE "+o" -# define CHANSERV_MODE "+o" -# define MEMOSERV_MODE "+o" -# define BOTSERV_MODE "+o" -# define HELPSERV_MODE "+h" -# define OPERSERV_MODE "+io" -# define DEVNULL_MODE "+i" -# define GLOBAL_MODE "+io" -# define NICKSERV_ALIAS_MODE "+o" -# define CHANSERV_ALIAS_MODE "+o" -# define MEMOSERV_ALIAS_MODE "+o" -# define BOTSERV_ALIAS_MODE "+o" -# define HELPSERV_ALIAS_MODE "+h" -# define OPERSERV_ALIAS_MODE "+io" -# define DEVNULL_ALIAS_MODE "+i" -# define GLOBAL_ALIAS_MODE "+io" -# define BOTSERV_BOTS_MODE "+" - #endif -#endif +/*************************************************************************/ -#ifdef IRC_RAGE2 -# define HAS_HALFOP -# define HAS_EXCEPT -# define HAS_VHOST -# define HAS_NICKVHOST -# define NICKSERV_MODE "+dS" -# define CHANSERV_MODE "+dS" -# define HOSTSERV_MODE "+dS" -# define MEMOSERV_MODE "+dS" -# define BOTSERV_MODE "+dS" -# define HELPSERV_MODE "+dSh" -# define OPERSERV_MODE "+diS" -# define DEVNULL_MODE "+diS" -# define GLOBAL_MODE "+diS" -# define NICKSERV_ALIAS_MODE "+o" -# define CHANSERV_ALIAS_MODE "+o" -# define MEMOSERV_ALIAS_MODE "+o" -# define BOTSERV_ALIAS_MODE "+o" -# define HELPSERV_ALIAS_MODE "+h" -# define OPERSERV_ALIAS_MODE "+io" -# define DEVNULL_ALIAS_MODE "+i" -# define GLOBAL_ALIAS_MODE "+io" -# define HOSTSERV_ALIAS_MODE "+io" -# define BOTSERV_BOTS_MODE "+S" -#endif +/* Protocol tweaks */ -#ifdef IRC_PTLINK -# define HAS_NICKVHOST -# define HAS_VHOST -# define HAS_FMODE -# define HAS_EXCEPT -# define NICKSERV_MODE "+o" -# define CHANSERV_MODE "+o" -# define HOSTSERV_MODE "+o" -# define MEMOSERV_MODE "+o" -# define BOTSERV_MODE "+o" -# define HELPSERV_MODE "+h" -# define OPERSERV_MODE "+io" -# define DEVNULL_MODE "+i" -# define GLOBAL_MODE "+io" -# define NICKSERV_ALIAS_MODE "+o" -# define CHANSERV_ALIAS_MODE "+o" -# define MEMOSERV_ALIAS_MODE "+o" -# define BOTSERV_ALIAS_MODE "+o" -# define HELPSERV_ALIAS_MODE "+h" -# define OPERSERV_ALIAS_MODE "+io" -# define DEVNULL_ALIAS_MODE "+i" -# define GLOBAL_ALIAS_MODE "+io" -# define HOSTSERV_ALIAS_MODE "+io" -# define BOTSERV_BOTS_MODE "+" -#endif -#ifdef IRC_ULTIMATE -# define HAS_FMODE /* Has +f chan mode */ -# define HAS_HALFOP -# define HAS_LMODE /* Has +L chan mode */ -# define HAS_VHOST -# define HAS_VIDENT /* Can the IRCD Change Idents on the fly */ -# define HAS_EXCEPT -# define NICKSERV_MODE "+S" -# define CHANSERV_MODE "+S" -# define HOSTSERV_MODE "+oS" -# define MEMOSERV_MODE "+S" -# define BOTSERV_MODE "+S" -# define HELPSERV_MODE "+Sh" -# define OPERSERV_MODE "+iS" -# define DEVNULL_MODE "+iS" -# define GLOBAL_MODE "+iS" -# define NICKSERV_ALIAS_MODE "+oS" -# define CHANSERV_ALIAS_MODE "+oS" -# define MEMOSERV_ALIAS_MODE "+oS" -# define BOTSERV_ALIAS_MODE "+oS" -# define HELPSERV_ALIAS_MODE "+oS" -# define OPERSERV_ALIAS_MODE "+ioS" -# define DEVNULL_ALIAS_MODE "+iS" -# define GLOBAL_ALIAS_MODE "+ioS" -# define HOSTSERV_ALIAS_MODE "+ioS" -# define BOTSERV_BOTS_MODE "+pS" -#endif +#include "hybrid.h" +#include "viagra.h" +#include "bahamut.h" +#include "rageircd.h" +#include "ptlink.h" +#include "ultimate2.h" +#include "unreal31.h" +#include "ultimate3.h" +#include "dreamforge.h" +#include "unreal32.h" -#ifdef IRC_UNREAL -# define HAS_FMODE /* Has +f chan mode */ -# define HAS_HALFOP -# define HAS_LMODE /* Has +L chan mode */ -# define HAS_NICKVHOST -# define HAS_VHOST -# define HAS_VIDENT /* Can the IRCD Change Idents on the fly */ -# define HAS_EXCEPT -# define NICKSERV_MODE "+oS" -# define CHANSERV_MODE "+oS" -# define HOSTSERV_MODE "+oS" -# define MEMOSERV_MODE "+oS" -# define BOTSERV_MODE "+oS" -# define HELPSERV_MODE "+oS" -# define OPERSERV_MODE "+ioS" -# define DEVNULL_MODE "+iS" -# define GLOBAL_MODE "+ioS" -# define NICKSERV_ALIAS_MODE "+oS" -# define CHANSERV_ALIAS_MODE "+oS" -# define MEMOSERV_ALIAS_MODE "+oS" -# define BOTSERV_ALIAS_MODE "+oS" -# define HELPSERV_ALIAS_MODE "+oS" -# define OPERSERV_ALIAS_MODE "+ioS" -# define DEVNULL_ALIAS_MODE "+iS" -# define GLOBAL_ALIAS_MODE "+ioS" -# define HOSTSERV_ALIAS_MODE "+ioS" -# define BOTSERV_BOTS_MODE "+qS" -#endif +typedef struct ircdvars_ IRCDVar; +typedef struct ircdcapab_ IRCDCAPAB; -#ifdef IRC_ULTIMATE3 -# define HAS_HALFOP -# define HAS_VHOST -# define HAS_NICKVHOST -# define HAS_VIDENT /* Can the IRCD Change Idents on the fly */ -# define HAS_EXCEPT -# define NICKSERV_MODE "+S" -# define CHANSERV_MODE "+S" -# define HOSTSERV_MODE "+o" -# define MEMOSERV_MODE "+S" -# define BOTSERV_MODE "+S" -# define HELPSERV_MODE "+Sh" -# define OPERSERV_MODE "+iS" -# define DEVNULL_MODE "+iS" -# define GLOBAL_MODE "+iS" -# define NICKSERV_ALIAS_MODE "+o" -# define CHANSERV_ALIAS_MODE "+o" -# define MEMOSERV_ALIAS_MODE "+o" -# define BOTSERV_ALIAS_MODE "+o" -# define HELPSERV_ALIAS_MODE "+h" -# define OPERSERV_ALIAS_MODE "+io" -# define DEVNULL_ALIAS_MODE "+i" -# define GLOBAL_ALIAS_MODE "+io" -# define HOSTSERV_ALIAS_MODE "+io" -# define BOTSERV_BOTS_MODE "+S" -#endif +struct ircdvars_ { + char *name; /* Name of the ChanServ command */ + char *nickservmode; /* Mode used by NickServ */ + char *chanservmode; /* Mode used by ChanServ */ + char *memoservmode; /* Mode used by MemoServ */ + char *hostservmode; /* Mode used by HostServ */ + char *operservmode; /* Mode used by OperServ */ + char *botservmode; /* Mode used by BotServ */ + char *helpservmode; /* Mode used by HelpServ */ + char *devnullmode; /* Mode used by Dev/Null */ + char *globalmode; /* Mode used by Global */ + char *nickservaliasmode; /* Mode used by NickServ Alias */ + char *chanservaliasmode; /* Mode used by ChanServ Alias */ + char *memoservaliasmode; /* Mode used by MemoServ Alias */ + char *hostservaliasmode; /* Mode used by HostServ Alias */ + char *operservaliasmode; /* Mode used by OperServ Alias */ + char *botservaliasmode; /* Mode used by BotServ Alias */ + char *helpservaliasmode; /* Mode used by HelpServ Alias */ + char *devnullvaliasmode; /* Mode used by Dev/Null Alias */ + char *globalaliasmode; /* Mode used by Global Alias */ + char *botserv_bot_mode; /* Mode used by BotServ Bots */ + int max_symbols; /* Chan Max Symbols */ + char *modestoremove; /* Channel Modes to remove */ + char *botchanumode; /* Modes set when botserv joins a channel */ + int svsnick; /* Supports SVSNICK */ + int vhost; /* Supports vhost */ + int owner; /* Supports Owner */ + char *ownerset; /* Mode to set for owner */ + char *ownerunset; /* Mode to unset for a owner */ + char *modeonreg; /* Mode on Register */ + char *modeonunreg; /* Mode on Unregister */ + char *modeonnick; /* Mode on nick change */ + int sgline; /* Supports SGline */ + int sqline; /* Supports SQline */ + int szline; /* Supports SZline */ + int halfop; /* Supports HalfOp */ + int numservargs; /* Number of Server Args */ + int join2set; /* Join 2 Set Modes */ + int join2msg; /* Join 2 Message */ + int except; /* exception +e */ + int topictsforward; /* TS on Topics Forward */ + int topictsbackward; /* TS on Topics Backward */ + uint32 protectedumode; /* What is the Protected Umode */ + int admin; /* Has Admin */ + int chansqline; /* Supports Channel Sqlines */ + int quitonkill; /* IRCD sends QUIT when kill */ + int svsmode_unban; /* svsmode can be used to unban */ + int protect; /* Has protect modes */ + int reversekickcheck; /* Can reverse ban check */ + int chanreg; /* channel mode +r for register */ + uint32 regmode; /* Mode to use for +r */ + int vident; /* Supports vidents */ + int svshold; /* Supports svshold */ + int tsonmode; /* Timestamp on mode changes */ + int nickip; /* Sends IP on NICK */ + int omode; /* On the fly o:lines */ + int umode; /* change user modes */ + int nickvhost; /* Users vhost sent during NICK */ + int chgreal; /* Change RealName */ + int extrahelp; /* Lang file entry for extra */ + uint32 noknock; /* Channel Mode for no knock */ + uint32 adminmode; /* Admin Only Channel Mode */ + uint32 defmlock; /* Default mlock modes */ + uint32 vhostmode; /* Vhost mode */ + int fmode; /* +f */ + int Lmode; /* +L */ + uint32 chan_fmode; /* Mode */ + uint32 chan_lmode; /* Mode */ + int check_nick_id; /* On nick change check if they could be identified */ +}; -/* - This gets ugly since serval ircds use both DREAMFORCE and their own define -*/ - -#ifdef IRC_DREAMFORGE - #ifndef NICKSERV_MODE - # define NICKSERV_MODE "+o" - #endif - #ifndef CHANSERV_MODE - # define CHANSERV_MODE "+o" - #endif - #ifndef MEMOSERV_MODE - # define MEMOSERV_MODE "+o" - #endif - #ifndef BOTSERV_MODE - # define BOTSERV_MODE "+o" - #endif - #ifndef HELPSERV_MODE - # define HELPSERV_MODE "+h" - #endif - #ifndef OPERSERV_MODE - # define OPERSERV_MODE "+io" - #endif - #ifndef DEVNULL_MODE - # define DEVNULL_MODE "+i" - #endif - #ifndef GLOBAL_MODE - # define GLOBAL_MODE "+io" - #endif - #ifndef BOTSERV_BOTS_MODE - # define BOTSERV_BOTS_MODE "+" - #endif - #ifndef NICKSERV_ALIAS_MODE - # define NICKSERV_ALIAS_MODE "+o" - #endif - #ifndef CHANSERV_ALIAS_MODE - # define CHANSERV_ALIAS_MODE "+o" - #endif - #ifndef MEMOSERV_ALIAS_MODE - # define MEMOSERV_ALIAS_MODE "+o" - #endif - #ifndef BOTSERV_ALIAS_MODE - # define BOTSERV_ALIAS_MODE "+o" - #endif - #ifndef HELPSERV_ALIAS_MODE - # define HELPSERV_ALIAS_MODE "+h" - #endif - #ifndef OPERSERV_ALIAS_MODE - # define OPERSERV_ALIAS_MODE "+io" - #endif - #ifndef DEVNULL_ALIAS_MODE - # define DEVNULL_ALIAS_MODE "+i" - #endif - #ifndef GLOBAL_ALIAS_MODE - # define GLOBAL_ALIAS_MODE "+io" - #endif -#endif +struct ircdcapab_ { + uint32 noquit; + uint32 tsmode; + uint32 unconnect; + uint32 nickip; + uint32 nsjoin; + uint32 zip; + uint32 burst; + uint32 ts5; + uint32 ts3; + uint32 dkey; + uint32 pt4; + uint32 scs; + uint32 qs; + uint32 uid; + uint32 knock; + uint32 client; + uint32 ipv6; + uint32 ssj5; + uint32 sn2; + uint32 token; + uint32 vhost; + uint32 ssj3; + uint32 nick2; + uint32 umode2; + uint32 vl; + uint32 tlkext; + uint32 dodkey; + uint32 dozip; +}; /*************************************************************************/ @@ -412,14 +291,15 @@ typedef struct channel_ Channel; #define PRE_NICK_VERSION 1 #define OPER_VERSION 13 +/*************************************************************************/ + + /** * ModuleData strucs used to allow modules to add / delete module Data from existing structs */ -typedef struct ModuleData_ ModuleData; /* ModuleData struct */ -typedef struct ModuleDataItem_ ModuleDataItem; /* A Module Data Item struct */ struct ModuleDataItem_ { - char *key; /* The key */ + char *key; /* The key */ char *value; /* The Value */ ModuleDataItem *next; /* The next ModuleDataItem in this list */ }; @@ -430,16 +310,11 @@ struct ModuleData_ { ModuleData *next; /* The next ModuleData record */ }; - - -typedef enum { false, true } boolean; - /*************************************************************************/ /* Memo info structures. Since both nicknames and channels can have memos, * we encapsulate memo data in a MemoList to make it easier to handle. */ -typedef struct memo_ Memo; struct memo_ { uint32 number; /* Index number -- not necessarily array position! */ int16 flags; @@ -449,9 +324,6 @@ struct memo_ { ModuleData *moduleData[1024]; /* Module saved data attached to the Memo */ }; -#define MF_UNREAD 0x0001 /* Memo has not yet been read */ -#define MF_RECEIPT 0x0002 /* Sender requested receipt */ - typedef struct { int16 memocount, memomax; Memo *memos; @@ -460,9 +332,7 @@ typedef struct { /*************************************************************************/ /* NickServ nickname structures. */ -typedef struct nickrequest_ NickRequest; -typedef struct nickalias_ NickAlias; -typedef struct nickcore_ NickCore; + struct nickrequest_ { NickRequest *next, *prev; @@ -470,124 +340,48 @@ struct nickrequest_ { char *passcode; char *password; char *email; - time_t requested; - time_t lastmail; /* Unsaved */ }; struct nickalias_ { NickAlias *next, *prev; - - char *nick; /* Nickname */ - - char *last_quit; /* Last quit message */ + char *nick; /* Nickname */ + char *last_quit; /* Last quit message */ char *last_realname; /* Last realname */ char *last_usermask; /* Last usermask */ - - time_t time_registered; /* When the nick was registered */ - time_t last_seen; /* When it was seen online for the last time */ - - int16 status; /* See NS_* below */ - - NickCore *nc; /* I'm an alias of this */ - - /* Not saved */ - ModuleData *moduleData[1024]; /* Module saved data attached to the nick alias */ - User *u; /* Current online user that has me */ + time_t time_registered; /* When the nick was registered */ + time_t last_seen; /* When it was seen online for the last time */ + int16 status; /* See NS_* below */ + NickCore *nc; /* I'm an alias of this */ + /* Not saved */ + ModuleData *moduleData[1024]; /* Module saved data attached to the nick alias */ + User *u; /* Current online user that has me */ }; struct nickcore_ { NickCore *next, *prev; - char *display; /* How the nick is displayed */ - char *pass; /* Password of the nicks */ - - char *email; /* E-mail associated to the nick */ - char *greet; /* Greet associated to the nick */ - uint32 icq; /* ICQ # associated to the nick */ - char *url; /* URL associated to the nick */ - - int32 flags; /* See NI_* below */ - uint16 language; /* Language selected by nickname owner (LANG_*) */ - - int16 accesscount; /* # of entries */ - char **access; /* Array of strings */ - - MemoInfo memos; - - uint16 channelcount; /* Number of channels currently registered */ - uint16 channelmax; /* Maximum number of channels allowed */ - - /* Unsaved data */ - ModuleData *moduleData[1024]; /* Module saved data attached to the NickCore */ - time_t lastmail; /* Last time this nick record got a mail */ - SList aliases; /* List of aliases */ + char *display; /* How the nick is displayed */ + char *pass; /* Password of the nicks */ + char *email; /* E-mail associated to the nick */ + char *greet; /* Greet associated to the nick */ + uint32 icq; /* ICQ # associated to the nick */ + char *url; /* URL associated to the nick */ + int32 flags; /* See NI_* below */ + uint16 language; /* Language selected by nickname owner (LANG_*) */ + int16 accesscount; /* # of entries */ + char **access; /* Array of strings */ + MemoInfo memos; + uint16 channelcount; /* Number of channels currently registered */ + uint16 channelmax; /* Maximum number of channels allowed */ + + /* Unsaved data */ + ModuleData *moduleData[1024]; /* Module saved data attached to the NickCore */ + time_t lastmail; /* Last time this nick record got a mail */ + SList aliases; /* List of aliases */ }; -/* Nickname status flags: */ -#define NS_VERBOTEN 0x0002 /* Nick may not be registered or used */ -#define NS_NO_EXPIRE 0x0004 /* Nick never expires */ -#define NS_IDENTIFIED 0x8000 /* User has IDENTIFY'd */ -#define NS_RECOGNIZED 0x4000 /* ON_ACCESS true && SECURE flag not set */ -#define NS_ON_ACCESS 0x2000 /* User comes from a known address */ -#define NS_KILL_HELD 0x1000 /* Nick is being held after a kill */ -#define NS_GUESTED 0x0100 /* SVSNICK has been sent but nick has not - * yet changed. An enforcer will be - * introduced when it does change. */ -#define NS_MASTER 0x0200 /* Was a master nick; used to import old databases */ -#define NS_TRANSGROUP 0xC000 /* Status flags that can be passed to a nick of the - same group during nick change */ -#define NS_TEMPORARY 0xFF00 /* All temporary status flags */ -/* These two are not used anymore */ -#define NS_OLD_ENCRYPTEDPW 0x0001 /* Nickname password is encrypted */ - -/* Nickname setting flags: */ -#define NI_KILLPROTECT 0x00000001 /* Kill others who take this nick */ -#define NI_SECURE 0x00000002 /* Don't recognize unless IDENTIFY'd */ -#define NI_MSG 0x00000004 /* Use PRIVMSGs instead of NOTICEs */ -#define NI_MEMO_HARDMAX 0x00000008 /* Don't allow user to change memo limit */ -#define NI_MEMO_SIGNON 0x00000010 /* Notify of memos at signon and un-away */ -#define NI_MEMO_RECEIVE 0x00000020 /* Notify of new memos when sent */ -#define NI_PRIVATE 0x00000040 /* Don't show in LIST to non-servadmins */ -#define NI_HIDE_EMAIL 0x00000080 /* Don't show E-mail in INFO */ -#define NI_HIDE_MASK 0x00000100 /* Don't show last seen address in INFO */ -#define NI_HIDE_QUIT 0x00000200 /* Don't show last quit message in INFO */ -#define NI_KILL_QUICK 0x00000400 /* Kill in 20 seconds instead of 60 */ -#define NI_KILL_IMMED 0x00000800 /* Kill immediately instead of in 60 sec */ -#define NI_SERVICES_OPER 0x00001000 /* User is a Services operator */ -#define NI_SERVICES_ADMIN 0x00002000 /* User is a Services admin */ -#define NI_ENCRYPTEDPW 0x00004000 /* Nickname password is encrypted */ -#define NI_SERVICES_ROOT 0x00008000 /* User is a Services root */ -#define NI_MEMO_MAIL 0x00010000 /* User gets email on memo */ -#define NI_HIDE_STATUS 0x00020000 /* Don't show services access status */ - -/* Languages. Never insert anything in the middle of this list, or - * everybody will start getting the wrong language! If you want to change - * the order the languages are displayed in for NickServ HELP SET LANGUAGE, - * do it in language.c. - */ -#define LANG_EN_US 0 /* United States English */ -#define LANG_JA_JIS 1 /* Japanese (JIS encoding) */ -#define LANG_JA_EUC 2 /* Japanese (EUC encoding) */ -#define LANG_JA_SJIS 3 /* Japanese (SJIS encoding) */ -#define LANG_ES 4 /* Spanish */ -#define LANG_PT 5 /* Portugese */ -#define LANG_FR 6 /* French */ -#define LANG_TR 7 /* Turkish */ -#define LANG_IT 8 /* Italian */ -#define LANG_DE 9 /* German */ -#define LANG_CAT 10 /* Catalan */ -#define LANG_GR 11 /* Greek */ -#define LANG_NL 12 /* Dutch */ -#define LANG_RU 13 /* Russian */ -#define LANG_HUN 14 /* Hungarian */ -#define LANG_PL 15 /* Polish */ - -#define NUM_LANGS 16 /* Number of languages */ -#define USED_LANGS 13 /* Number of languages provided */ - -#define DEF_LANGUAGE LANG_EN_US /*************************************************************************/ @@ -596,27 +390,21 @@ struct nickcore_ { * --lara */ -typedef struct botinfo_ BotInfo; - struct botinfo_ { - BotInfo *next, *prev; char *nick; /* Nickname of the bot */ char *user; /* Its user name */ char *host; /* Its hostname */ char *real; /* Its real name */ - int16 flags; /* Bot flags -- see BI_* below */ - time_t created; /* Birth date ;) */ int16 chancount; /* Number of channels that use the bot. */ - /* Dynamic data */ time_t lastmsg; /* Last time we said something */ }; -#define BI_PRIVATE 0x0001 + /* Channel info structures. Stored similarly to the nicks, except that * the second character of the channel name, not the first, is used to @@ -642,9 +430,7 @@ typedef struct { /* Levels for xOP */ #define ACCESS_VOP 3 -#ifdef HAS_HALFOP -# define ACCESS_HOP 4 -#endif +#define ACCESS_HOP 4 #define ACCESS_AOP 5 #define ACCESS_SOP 10 @@ -667,15 +453,12 @@ typedef struct { #define AK_USED 0x0001 #define AK_ISNICK 0x0002 -#define AK_STUCK 0x0004 +#define AK_STUCK 0x0004 /* Structure used to contain bad words. */ -typedef struct badword_ BadWord; - struct badword_ { int16 in_use; - char *word; int16 type; /* BW_* below */ }; @@ -685,7 +468,7 @@ struct badword_ { #define BW_START 2 #define BW_END 3 -typedef struct chaninfo_ ChannelInfo; + struct chaninfo_ { ChannelInfo *next, *prev; char name[CHANMAX]; @@ -708,7 +491,6 @@ struct chaninfo_ { char *forbidreason; int16 bantype; - int16 *levels; /* Access levels for commands */ int16 accesscount; @@ -716,15 +498,11 @@ struct chaninfo_ { int16 akickcount; AutoKick *akick; /* List of users to kickban */ - uint32 mlock_on, mlock_off; /* See channel modes below */ + uint32 mlock_on, mlock_off; /* See channel modes below */ uint32 mlock_limit; /* 0 if no limit */ char *mlock_key; /* NULL if no key */ -#ifdef HAS_FMODE char *mlock_flood; /* NULL if no +f */ -#endif -#ifdef HAS_LMODE char *mlock_redirect; /* NULL if no +L */ -#endif char *entry_message; /* Notice sent on entering channel */ @@ -793,49 +571,49 @@ struct chaninfo_ { #define CA_UNBAN 3 #define CA_AUTOOP 4 #define CA_AUTODEOP 5 /* Maximum, not minimum */ -#define CA_AUTOVOICE 6 +#define CA_AUTOVOICE 6 #define CA_OPDEOP 7 /* ChanServ commands OP and DEOP */ -#define CA_ACCESS_LIST 8 +#define CA_ACCESS_LIST 8 #define CA_CLEAR 9 #define CA_NOJOIN 10 /* Maximum */ -#define CA_ACCESS_CHANGE 11 +#define CA_ACCESS_CHANGE 11 #define CA_MEMO 12 -#define CA_ASSIGN 13 /* BotServ ASSIGN command */ -#define CA_BADWORDS 14 /* BotServ BADWORDS command */ -#define CA_NOKICK 15 /* Not kicked by the bot */ -#define CA_FANTASIA 16 +#define CA_ASSIGN 13 /* BotServ ASSIGN command */ +#define CA_BADWORDS 14 /* BotServ BADWORDS command */ +#define CA_NOKICK 15 /* Not kicked by the bot */ +#define CA_FANTASIA 16 #define CA_SAY 17 -#define CA_GREET 18 +#define CA_GREET 18 #define CA_VOICEME 19 #define CA_VOICE 20 -#define CA_GETKEY 21 -#define CA_AUTOHALFOP 22 -#define CA_AUTOPROTECT 23 -#define CA_OPDEOPME 24 -#define CA_HALFOPME 25 -#define CA_HALFOP 26 -#define CA_PROTECTME 27 -#define CA_PROTECT 28 -#define CA_KICKME 29 -#define CA_KICK 30 +#define CA_GETKEY 21 +#define CA_AUTOHALFOP 22 +#define CA_AUTOPROTECT 23 +#define CA_OPDEOPME 24 +#define CA_HALFOPME 25 +#define CA_HALFOP 26 +#define CA_PROTECTME 27 +#define CA_PROTECT 28 +#define CA_KICKME 29 +#define CA_KICK 30 #define CA_SIGNKICK 31 -/* #define CA_AUTOADMIN 32 -#define CA_ADMINME 33 -#define CA_ADMIN 34 */ -#define CA_BANME 32 -#define CA_BAN 33 -#define CA_TOPIC 34 -#define CA_INFO 35 +/* #define CA_AUTOADMIN 32 +#define CA_ADMINME 33 +#define CA_ADMIN 34 */ +#define CA_BANME 32 +#define CA_BAN 33 +#define CA_TOPIC 34 +#define CA_INFO 35 #define CA_SIZE 36 /* BotServ SET flags */ -#define BS_DONTKICKOPS 0x00000001 -#define BS_DONTKICKVOICES 0x00000002 -#define BS_FANTASY 0x00000004 -#define BS_SYMBIOSIS 0x00000008 -#define BS_GREET 0x00000010 -#define BS_NOBOT 0x00000020 +#define BS_DONTKICKOPS 0x00000001 +#define BS_DONTKICKVOICES 0x00000002 +#define BS_FANTASY 0x00000004 +#define BS_SYMBIOSIS 0x00000008 +#define BS_GREET 0x00000010 +#define BS_NOBOT 0x00000020 /* BotServ Kickers flags */ #define BS_KICK_BOLDS 0x80000000 @@ -850,80 +628,41 @@ struct chaninfo_ { /* Indices for TTB (Times To Ban) */ #define TTB_BOLDS 0 #define TTB_COLORS 1 -#define TTB_REVERSES 2 -#define TTB_UNDERLINES 3 -#define TTB_BADWORDS 4 +#define TTB_REVERSES 2 +#define TTB_UNDERLINES 3 +#define TTB_BADWORDS 4 #define TTB_CAPS 5 #define TTB_FLOOD 6 #define TTB_REPEAT 7 - #define TTB_SIZE 8 /*************************************************************************/ /* ChanServ mode utilities commands */ -typedef struct csmodeutil_ CSModeUtil; - struct csmodeutil_ { - char *name; /* Name of the ChanServ command */ + char *name; /* Name of the ChanServ command */ char *bsname; /* Name of the BotServ fantasy command */ - - char *mode; /* Mode (ie. +o) */ + char *mode; /* Mode (ie. +o) */ int32 notice; /* Notice flag (for the damn OPNOTICE) */ - - int level; /* Level required to use the command */ + int level; /* Level required to use the command */ int levelself; /* Level required to use the command for himself */ }; -#define MUT_DEOP 0 -#define MUT_OP 1 -#define MUT_DEVOICE 2 -#define MUT_VOICE 3 -#ifdef HAS_HALFOP -#define MUT_DEHALFOP 4 -#define MUT_HALFOP 5 -#endif -#ifdef IRC_UNREAL -#define MUT_DEPROTECT 6 -#define MUT_PROTECT 7 -#endif -#ifdef IRC_ULTIMATE3 -#define MUT_DEPROTECT 6 -#define MUT_PROTECT 7 -#endif -#ifdef IRC_RAGE2 -#define MUT_DEPROTECT 6 -#define MUT_PROTECT 7 -#endif -#ifdef IRC_VIAGRA -#define MUT_DEPROTECT 6 -#define MUT_PROTECT 7 -#endif -#ifdef IRC_PTLINK -#define MUT_DEPROTECT 4 -#define MUT_PROTECT 5 -#endif /*************************************************************************/ -/* Server CAPAB flags */ -#ifdef IRC_BAHAMUT -# define CAPAB_NOQUIT 0x0001 -# define CAPAB_TSMODE 0x0002 -# define CAPAB_UNCONNECT 0x0004 -#endif - /* Server data */ struct server_ { Server *next, *prev; - char *name; /* Server name */ - uint16 hops; /* Hops between services and server */ - char *desc; /* Server description */ - uint16 flags; /* Some info flags, as defined below */ + char *name; /* Server name */ + uint16 hops; /* Hops between services and server */ + char *desc; /* Server description */ + uint16 flags; /* Some info flags, as defined below */ + char *suid; /* Server Univeral ID */ - Server *links; /* Linked list head for linked servers */ + Server *links; /* Linked list head for linked servers */ Server *uplink; /* Server which pretends to be the uplink */ }; @@ -938,23 +677,18 @@ struct user_ { char nick[NICKMAX]; - char *username; - char *host; /* User's real hostname */ -#ifdef HAS_VHOST - char *vhost; /* User's virtual hostname */ -#endif -#ifdef HAS_VIDENT - char *vident; /* User's virtual ident */ -#endif - char *realname; - Server *server; /* Server user is connected to */ - - char *nickTrack; /* Nick Tracking */ - - time_t timestamp; /* Timestamp of the nick */ - time_t my_signon; /* When did _we_ see the user? */ - uint32 svid; /* Services ID */ - uint32 mode; /* See below */ + char *username; /* ident */ + char *host; /* User's real hostname */ + char *vhost; /* User's virtual hostname */ + char *vident; /* User's virtual ident */ + char *realname; /* Realname */ + Server *server; /* Server user is connected to */ + char *nickTrack; /* Nick Tracking */ + time_t timestamp; /* Timestamp of the nick */ + time_t my_signon; /* When did _we_ see the user? */ + uint32 svid; /* Services ID */ + uint32 mode; /* See below */ + char *uid; /* Univeral ID */ NickAlias *na; @@ -981,117 +715,7 @@ struct user_ { time_t lastmail; /* Last time this user sent a mail */ }; -#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 - -#ifdef IRC_ULTIMATE -#define UMODE_p 0x04000000 -#define UMODE_R 0x08000000 -#define UMODE_P 0x20000000 -#endif - -#ifdef IRC_ULTIMATE3 -#define UMODE_p 0x04000000 -#define UMODE_Z 0x08000000 -#define UMODE_P 0x20000000 -#endif - -#ifdef IRC_DREAMFORGE -# define UMODE_g 0x80000000 -#endif - -#ifdef IRC_BAHAMUT -# define UMODE_R 0x80000000 -#endif - -#ifdef IRC_VIAGRA -#define UMODE_p 0x04000000 -#endif - -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_RAGE2) -# define UMODE_x 0x40000000 -#endif -/* Returns *current* user hostname */ -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_RAGE2) -# define GetHost(x) ((x)->mode & UMODE_x ? (x)->vhost : (x)->host) -#elif defined(IRC_PTLINK) -# define GetHost(x) ((x)->mode & UMODE_o ? (x)->vhost ? (x)->vhost : (x)->host : (x)->host) -#else -# define GetHost(x) ((x)->host) -#endif - -/* Returns *current* user ident */ -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_VIAGRA) -# define GetIdent(x) ((x)->mode & UMODE_x ? (x)->vident ? (x)->vident : (x)->username : (x)->username) -#else -# define GetIdent(x) ((x)->username) -#endif - -/* This will introduce a pseudo client with the given nick, username, hostname, - realname and modes. It will also make a Q line for the nick on demand. - --lara */ -#if defined(IRC_HYBRID) -# define NEWNICK(nick,user,host,real,modes,qline) \ - do { \ - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", (nick), time(NULL), (modes), \ - (user), (host), ServerName, (real)); \ - } while (0) -#elif defined(IRC_ULTIMATE3) -# define NEWNICK(nick,user,host,real,modes,qline) \ - do { \ - send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", (nick), time(NULL), (modes), \ - (user), (host), ServerName, (real)); \ - if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_RAGE2) -# define NEWNICK(nick,user,host,real,modes,qline) \ - do { \ - send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", (nick), time(NULL), (user), \ - (host), ServerName, (modes), (real)); \ - if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_BAHAMUT) && !defined(IRC_ULTIMATE3) && !defined(IRC_RAGE2) -# define NEWNICK(nick,user,host,real,modes,qline) \ - do { \ - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", (nick), time(NULL), (modes), \ - (user), (host), ServerName, (real)); \ - if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_UNREAL) -# define NEWNICK(nick,user,host,real,modes,qline) \ - do { \ - send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", (nick), time(NULL), \ - (user), (host), ServerName, (modes), (real)); \ - if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_DREAMFORGE) -# define NEWNICK(nick,user,host,real,modes,qline) \ - do { \ - send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", (nick), time(NULL), \ - (user), (host), ServerName, (real)); \ - if (strcmp(modes, "+")) send_cmd((nick), "MODE %s %s", (nick), (modes)); \ - if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_PTLINK) -# define NEWNICK(nick,user,host,real,modes,qline) \ - do { \ - send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", (nick), time(NULL), \ - (modes), (user), (host), (host), ServerName, (real)); \ - if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#endif - -typedef struct cbmode_ CBMode; -typedef struct cbmodeinfo_ CBModeInfo; -typedef struct cmmode_ CMMode; -typedef struct csmode_ CSMode; -typedef struct cumode_ CUMode; struct cbmode_ { uint32 flag; /* Long value that represents the mode */ @@ -1104,7 +728,7 @@ struct cbmode_ { #define CBM_MINUS_NO_ARG 0x0001 /* No argument for unset */ #define CBM_NO_MLOCK 0x0002 /* Can't be MLOCKed */ -#define CBM_NO_USER_MLOCK 0x0004 /* Can't be MLOCKed by non-opers */ +#define CBM_NO_USER_MLOCK 0x0004 /* Can't be MLOCKed by non-opers */ struct cbmodeinfo_ { char mode; /* The mode */ @@ -1128,80 +752,10 @@ struct cumode_ { int (*is_valid) (User *user, Channel *chan, int servermode); }; -/* User flags on channel */ -#define CUS_OP 0x0001 -#define CUS_VOICE 0x0002 - -#ifdef HAS_HALFOP -#define CUS_HALFOP 0x0004 /* Halfop (+h) */ -#endif - -/* Used by Unreal */ -#ifdef IRC_UNREAL -#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */ -#define CUS_PROTECT 0x0010 /* Protected users (+a) */ -#endif - -/* Used by Viagra */ -#ifdef IRC_VIAGRA -#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */ -#define CUS_PROTECT 0x0010 /* Protected users (+a) */ -#endif - -#ifdef IRC_ULTIMATE3 -#define CUS_PROTECT 0x0010 /* Protected users (+a) */ -#endif - -#ifdef IRC_RAGE2 -#define CUS_PROTECT 0x0010 /* Protected users (+a) */ -#endif - -/* Used by PTlink */ -#ifdef IRC_PTLINK -#define CUS_PROTECT 0x0016 /* Protected users (+a) */ -#endif - /* Channel user mode flags */ #define CUF_PROTECT_BOTSERV 0x0001 -/* Useful value */ - -#if defined(IRC_ULTIMATE) -# define CHAN_MAX_SYMBOLS 3 -#elif defined(IRC_ULTIMATE3) -# define CHAN_MAX_SYMBOLS 5 -#elif defined(IRC_UNREAL) -# define CHAN_MAX_SYMBOLS 5 -#elif defined(IRC_RAGE2) -# define CHAN_MAX_SYMBOLS 3 -#else -# define CHAN_MAX_SYMBOLS 2 -#endif - -/* Binary modes that need to be cleared */ - -#if defined(IRC_RAGE2) -#define MODESTOREMOVE "-iklmnpRstcOASCNM" -#elif defined(IRC_BAHAMUT) -#define MODESTOREMOVE "-ciklmnpstOR" -#elif defined(IRC_ULTIMATE) -#define MODESTOREMOVE "-kiflmnpstxAIKLORS" -#elif defined(IRC_ULTIMATE3) -#define MODESTOREMOVE "-iklmnpstRKAO" -#elif defined(IRC_UNREAL) -#define MODESTOREMOVE "-ckiflmnpstuzACGHKLNOQRSV" -#elif defined(IRC_VIAGRA) -#define MODESTOREMOVE "-ciklmnpstORAH" -#elif defined(IRC_PTLINK) -#define MODESTOREMOVE "-cdfiklmnpqstRS" -#else -#define MODESTOREMOVE "-iklmnpstR" -#endif - -typedef struct bandata_ BanData; -typedef struct userdata_ UserData; - /* This structure stocks ban data since it must not be removed when * user is kicked. */ @@ -1237,29 +791,18 @@ struct channel_ { char name[CHANMAX]; ChannelInfo *ci; /* Corresponding ChannelInfo */ time_t creation_time; /* When channel was created */ - char *topic; char topic_setter[NICKMAX]; /* Who set the topic */ time_t topic_time; /* When topic was set */ - - uint32 mode; /* Binary modes only */ + uint32 mode; /* Binary modes only */ uint32 limit; /* 0 if none */ char *key; /* NULL if none */ -#ifdef HAS_LMODE - char *redirect; /* +L; NULL if none */ -#endif -#ifdef HAS_FMODE - char *flood; /* +f; NULL if none */ -#endif - + char *redirect; /* +L; NULL if none */ + char *flood; /* +f; NULL if none */ int32 bancount, bansize; char **bans; - -#ifdef HAS_EXCEPT int32 exceptcount, exceptsize; char **excepts; -#endif - struct c_userlist { struct c_userlist *next, *prev; User *user; @@ -1276,108 +819,13 @@ struct channel_ { int16 bouncy_modes; /* Did we fail to set modes here? */ }; -#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 - -/* The two modes below are for IRC_DREAMFORGE servers only. */ -#ifndef IRC_HYBRID -#define CMODE_R 0x00000100 /* Only identified users can join */ -#define CMODE_r 0x00000200 /* Set for all registered channels */ -#endif - -/* This mode is for IRC_BAHAMUT servers only. */ -#ifdef IRC_BAHAMUT -#define CMODE_c 0x00000400 /* Colors can't be used */ -#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ -#define CMODE_O 0x00008000 /* Only opers can join */ -#endif - -/* This mode is for IRC_HYBRID servers only. */ -#ifdef IRC_HYBRID -#define CMODE_a 0x00000400 -#endif - -/* These modes are for IRC_ULTIMATE servers only. */ -#ifdef IRC_ULTIMATE -#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 -#endif - -/* These modes are for IRC_UNREAL servers only. */ -#ifdef IRC_UNREAL -#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 -#endif - -#ifdef IRC_VIAGRA -#define CMODE_A 0x00001000 -#define CMODE_H 0x00002000 -#endif - -/* These modes are for IRC_ULTIMATE3 servers only */ -#ifdef IRC_ULTIMATE3 -#define CMODE_A 0x00000800 -#define CMODE_N 0x00001000 -#define CMODE_S 0x00002000 -#define CMODE_K 0x00004000 -#define CMODE_O 0x00008000 -#endif - -/* These modes are for IRC_RAGE2 servers only */ -#ifdef IRC_RAGE2 -#define CMODE_A 0x00000800 -#define CMODE_N 0x00001000 -#define CMODE_S 0x00002000 -#define CMODE_C 0x00004000 -#endif - -/* These modes are for IRC_PTLINK servers only. */ -#ifdef IRC_PTLINK -#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 -#endif - - /*************************************************************************/ /* Constants for news types. */ #define NEWS_LOGON 0 #define NEWS_OPER 1 -#define NEWS_RANDOM 2 +#define NEWS_RANDOM 2 /*************************************************************************/ @@ -1393,8 +841,6 @@ typedef struct ignore_data { /* Mail data */ -typedef struct mailinfo_ MailInfo; - struct mailinfo_ { FILE *pipe; User *sender; @@ -1404,8 +850,6 @@ struct mailinfo_ { /*************************************************************************/ -typedef struct akill_ Akill; - struct akill_ { char *user; /* User part of the AKILL */ char *host; /* Host part of the AKILL */ @@ -1421,8 +865,6 @@ struct akill_ { /* Structure for OperServ SGLINE and SZLINE commands */ -typedef struct sxline_ SXLine; - struct sxline_ { char *mask; char *by; @@ -1435,8 +877,6 @@ struct sxline_ { /* Host serv structures */ -typedef struct hostcore_ HostCore; - struct hostcore_ { HostCore *next; char *nick; /* Owner of the vHost */ @@ -1448,7 +888,7 @@ struct hostcore_ { /*************************************************************************/ -typedef struct newsitem_ NewsItem; + struct newsitem_ { int16 type; @@ -1460,7 +900,7 @@ struct newsitem_ { /*************************************************************************/ -typedef struct exception_ Exception; + struct exception_ { char *mask; /* Hosts to which this exception applies */ int limit; /* Session limit for exception */ @@ -1478,7 +918,7 @@ struct exception_ { /* Proxy stuff */ -typedef struct hostcache_ HostCache; + struct hostcache_ { HostCache *prev, *next; @@ -1515,6 +955,127 @@ struct hostcache_ { #define DEFCON_SILENT_OPER_ONLY 128 /* Silently ignore non-opers */ #define DEFCON_AKILL_NEW_CLIENTS 256 /* AKILL any new clients */ #define DEFCON_NO_NEW_MEMOS 512 /* No New Memos Sent */ + +/*************************************************************************/ + +/* Memo Flags */ +#define MF_UNREAD 0x0001 /* Memo has not yet been read */ +#define MF_RECEIPT 0x0002 /* Sender requested receipt */ + + +/* Nickname status flags: */ +#define NS_VERBOTEN 0x0002 /* Nick may not be registered or used */ +#define NS_NO_EXPIRE 0x0004 /* Nick never expires */ +#define NS_IDENTIFIED 0x8000 /* User has IDENTIFY'd */ +#define NS_RECOGNIZED 0x4000 /* ON_ACCESS true && SECURE flag not set */ +#define NS_ON_ACCESS 0x2000 /* User comes from a known address */ +#define NS_KILL_HELD 0x1000 /* Nick is being held after a kill */ +#define NS_GUESTED 0x0100 /* SVSNICK has been sent but nick has not + * yet changed. An enforcer will be + * introduced when it does change. */ +#define NS_MASTER 0x0200 /* Was a master nick; used to import old databases */ +#define NS_TRANSGROUP 0xC000 /* Status flags that can be passed to a nick of the + same group during nick change */ +#define NS_TEMPORARY 0xFF00 /* All temporary status flags */ +/* These two are not used anymore */ +#define NS_OLD_ENCRYPTEDPW 0x0001 /* Nickname password is encrypted */ + +/* Nickname setting flags: */ +#define NI_KILLPROTECT 0x00000001 /* Kill others who take this nick */ +#define NI_SECURE 0x00000002 /* Don't recognize unless IDENTIFY'd */ +#define NI_MSG 0x00000004 /* Use PRIVMSGs instead of NOTICEs */ +#define NI_MEMO_HARDMAX 0x00000008 /* Don't allow user to change memo limit */ +#define NI_MEMO_SIGNON 0x00000010 /* Notify of memos at signon and un-away */ +#define NI_MEMO_RECEIVE 0x00000020 /* Notify of new memos when sent */ +#define NI_PRIVATE 0x00000040 /* Don't show in LIST to non-servadmins */ +#define NI_HIDE_EMAIL 0x00000080 /* Don't show E-mail in INFO */ +#define NI_HIDE_MASK 0x00000100 /* Don't show last seen address in INFO */ +#define NI_HIDE_QUIT 0x00000200 /* Don't show last quit message in INFO */ +#define NI_KILL_QUICK 0x00000400 /* Kill in 20 seconds instead of 60 */ +#define NI_KILL_IMMED 0x00000800 /* Kill immediately instead of in 60 sec */ +#define NI_SERVICES_OPER 0x00001000 /* User is a Services operator */ +#define NI_SERVICES_ADMIN 0x00002000 /* User is a Services admin */ +#define NI_ENCRYPTEDPW 0x00004000 /* Nickname password is encrypted */ +#define NI_SERVICES_ROOT 0x00008000 /* User is a Services root */ +#define NI_MEMO_MAIL 0x00010000 /* User gets email on memo */ +#define NI_HIDE_STATUS 0x00020000 /* Don't show services access status */ + +/* Languages. Never insert anything in the middle of this list, or + * everybody will start getting the wrong language! If you want to change + * the order the languages are displayed in for NickServ HELP SET LANGUAGE, + * do it in language.c. + */ +#define LANG_EN_US 0 /* United States English */ +#define LANG_JA_JIS 1 /* Japanese (JIS encoding) */ +#define LANG_JA_EUC 2 /* Japanese (EUC encoding) */ +#define LANG_JA_SJIS 3 /* Japanese (SJIS encoding) */ +#define LANG_ES 4 /* Spanish */ +#define LANG_PT 5 /* Portugese */ +#define LANG_FR 6 /* French */ +#define LANG_TR 7 /* Turkish */ +#define LANG_IT 8 /* Italian */ +#define LANG_DE 9 /* German */ +#define LANG_CAT 10 /* Catalan */ +#define LANG_GR 11 /* Greek */ +#define LANG_NL 12 /* Dutch */ +#define LANG_RU 13 /* Russian */ +#define LANG_HUN 14 /* Hungarian */ +#define LANG_PL 15 /* Polish */ + +#define NUM_LANGS 16 /* Number of languages */ +#define USED_LANGS 13 /* Number of languages provided */ + + +#define DEF_LANGUAGE LANG_EN_US + +#define BI_PRIVATE 0x0001 + +#define CUS_OP 0x0001 +#define CUS_VOICE 0x0002 +#define CUS_HALFOP 0x0004 /* Halfop (+h) */ +#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */ +#define CUS_PROTECT 0x0010 /* Protected users (+a) */ + +#define MUT_DEOP 0 +#define MUT_OP 1 +#define MUT_DEVOICE 2 +#define MUT_VOICE 3 +#define MUT_DEHALFOP 4 +#define MUT_HALFOP 5 +#define MUT_DEPROTECT 6 +#define MUT_PROTECT 7 + + +#define CAPAB_NOQUIT 0x00000001 +#define CAPAB_TSMODE 0x00000002 +#define CAPAB_UNCONNECT 0x00000004 +#define CAPAB_NICKIP 0x00000008 +#define CAPAB_NSJOIN 0x00000010 +#define CAPAB_ZIP 0x00000020 +#define CAPAB_BURST 0x00000040 +#define CAPAB_TS3 0x00000080 +#define CAPAB_TS5 0x00000100 +#define CAPAB_DKEY 0x00000200 +#define CAPAB_DOZIP 0x00000400 +#define CAPAB_DODKEY 0x00000800 +#define CAPAB_QS 0x00001000 +#define CAPAB_SCS 0x00002000 +#define CAPAB_PT4 0x00004000 +#define CAPAB_UID 0x00008000 +#define CAPAB_KNOCK 0x00010000 +#define CAPAB_CLIENT 0x00020000 +#define CAPAB_IPV6 0x00040000 +#define CAPAB_SSJ5 0x00080000 +#define CAPAB_SN2 0x00100000 +#define CAPAB_VHOST 0x00200000 +#define CAPAB_TOKEN 0x00400000 +#define CAPAB_SSJ3 0x00800000 +#define CAPAB_NICK2 0x01000000 +#define CAPAB_UMODE2 0x02000000 +#define CAPAB_VL 0x04000000 +#define CAPAB_TLKEXT 0x08000000 + + /*************************************************************************/ #include "extern.h" diff --git a/include/sysconf.h.in b/include/sysconf.h.in index 2b5108676..326501c5e 100644 --- a/include/sysconf.h.in +++ b/include/sysconf.h.in @@ -109,13 +109,16 @@ #undef IRC_RAGE2 /* "Second IRCD type" */ -#undef IRC_ULTIMATE +#undef IRC_ULTIMATE2 /* "Second IRCD type" */ #undef IRC_ULTIMATE3 /* "Second IRCD type" */ -#undef IRC_UNREAL +#undef IRC_UNREAL31 + +/* "Second IRCD type" */ +#undef IRC_UNREAL32 /* "Second IRCD type" */ #undef IRC_VIAGRA diff --git a/include/ultimate2.h b/include/ultimate2.h new file mode 100644 index 000000000..4cbd2c363 --- /dev/null +++ b/include/ultimate2.h @@ -0,0 +1,63 @@ +/* Ultimate IRCD 2 functions + * + * (C) 2003 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. + * + * + */ + +#ifdef IRC_ULTIMATE2 + +#define PROTECT_SET_MODE "+a" +#define PROTECT_UNSET_MODE "+a" +#define CS_CMD_PROTECT "PROTECT" +#define CS_CMD_DEPROTECT "DEPROTECT" +#define FANT_PROTECT_ADD "!protect" +#define FANT_PROTECT_DEL "!deprotect" +#define LEVEL_PROTECT_WORD "AUTOPROTECT" +#define LEVELINFO_PROTECT_WORD "PROTECT" +#define LEVELINFO_PROTECTME_WORD "PROTECTME" + +#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 + +#endif + + diff --git a/include/ultimate3.h b/include/ultimate3.h new file mode 100644 index 000000000..b654e8f08 --- /dev/null +++ b/include/ultimate3.h @@ -0,0 +1,60 @@ +/* Ultimate IRCD 3.0 functions + * + * (C) 2003 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. + * + * + */ + +#ifdef IRC_ULTIMATE3 + +#define PROTECT_SET_MODE "+a" +#define PROTECT_UNSET_MODE "+a" +#define FANT_PROTECT_ADD "!admin" +#define FANT_PROTECT_DEL "!deadmin" +#define LEVEL_PROTECT_WORD "AUTOADMIN" +#define LEVELINFO_PROTECT_WORD "ADMIN" +#define LEVELINFO_PROTECTME_WORD "ADMINME" +#define CS_CMD_PROTECT "ADMIN" +#define CS_CMD_DEPROTECT "DEADMIN" + +#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_Z 0x08000000 +#define UMODE_P 0x20000000 +#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_A 0x00000800 +#define CMODE_N 0x00001000 +#define CMODE_S 0x00002000 +#define CMODE_K 0x00004000 +#define CMODE_c 0x00000400 /* Colors can't be used */ +#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ +#define CMODE_O 0x00008000 /* Only opers can join */ +#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 + +#endif + diff --git a/include/unreal31.h b/include/unreal31.h new file mode 100644 index 000000000..40766af30 --- /dev/null +++ b/include/unreal31.h @@ -0,0 +1,66 @@ +/* Unreal IRCD 3.1.x functions + * + * (C) 2003 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. + * + * + */ + +/*************************************************************************/ + +#ifdef IRC_UNREAL31 + +#define PROTECT_SET_MODE "+a" +#define PROTECT_UNSET_MODE "+a" +#define CS_CMD_PROTECT "PROTECT" +#define CS_CMD_DEPROTECT "DEPROTECT" +#define FANT_PROTECT_ADD "!protect" +#define FANT_PROTECT_DEL "!deprotect" +#define LEVEL_PROTECT_WORD "AUTOPROTECT" +#define LEVELINFO_PROTECT_WORD "PROTECT" +#define LEVELINFO_PROTECTME_WORD "PROTECTME" + +#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 + +#endif diff --git a/include/unreal32.h b/include/unreal32.h new file mode 100644 index 000000000..02df21643 --- /dev/null +++ b/include/unreal32.h @@ -0,0 +1,80 @@ +/* Unreal IRCD 3.2.x functions + * + * (C) 2003 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. + * + * + */ + +#ifdef IRC_UNREAL32 + +/*************************************************************************/ + +/* User Modes */ +#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 UMODE_R 0x80000000 + +/*************************************************************************/ + +/* 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_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 */ + +/*************************************************************************/ + +/* Since we differ !protect from !admin we need to know what to use */ + +#define FANT_PROTECT_ADD "!protect" +#define FANT_PROTECT_DEL "!deprotect" +#define LEVEL_PROTECT_WORD "AUTOPROTECT" +#define LEVELINFO_PROTECT_WORD "PROTECT" +#define LEVELINFO_PROTECTME_WORD "PROTECTME" +#define PROTECT_SET_MODE "+a" +#define PROTECT_UNSET_MODE "+a" +#define CS_CMD_PROTECT "PROTECT" +#define CS_CMD_DEPROTECT "DEPROTECT" + +/*************************************************************************/ + +/* Default Modes with MLOCK */ + +#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r + +#endif diff --git a/include/version.sh b/include/version.sh index 6f5cad192..2ff3bb5a3 100644 --- a/include/version.sh +++ b/include/version.sh @@ -50,40 +50,6 @@ const char version_number[] = "$VERSION"; const char version_build[] = "build #" BUILD ", compiled " __DATE__ " " __TIME__; -const char version_protocol[] = -#if defined(IRC_ULTIMATE3) - "UltimateIRCd 3.0.0.a26+" -# define VER_IRCD "UltimateIRCd 3.0.* -" -#elif defined(IRC_VIAGRA) - "ViagraIRCd 1.3.x" -# define VER_IRCD "ViagraIRCd 1.3.* -" -#elif defined(IRC_RAGE2) - "RageIRCd 2.0.x" -# define VER_IRCD "RageIRCd 2.0.* -" -#elif defined(IRC_BAHAMUT) - "Bahamut 1.4.27+" -# define VER_IRCD "BahamutIRCd 1.4.*/1.8.* -" -#elif defined(IRC_ULTIMATE) - "UltimateIRCd 2.8.2+" -# define VER_IRCD "UltimateIRCd 2.8.* -" -#elif defined(IRC_UNREAL) - "UnrealIRCd 3.1.1+" -# define VER_IRCD "UnrealIRCd -" -#elif defined(IRC_DREAMFORGE) - "DreamForge 4.6.7" -# define VER_IRCD "DreamForgeIRCd 4.6.7 -" -#elif defined(IRC_HYBRID) - "Hybrid IRCd 7.0" -# define VER_IRCD "HybridIRCd 7.* -" -#elif defined(IRC_PTLINK) - "PTlink 6.14.5+" -# define VER_IRCD "PTlinkIRCd 6.14.* -" -#else - "unknown" -# define VER_IRCD -#endif - ; - #ifdef DEBUG_COMMANDS # define VER_DEBUG "D" #else @@ -140,7 +106,8 @@ const char version_protocol[] = # define VER_MODULE #endif -const char version_flags[] = VER_IRCD VER_DEBUG VER_ENCRYPTION VER_THREAD VER_OS VER_GHBNR VER_MYSQL VER_MODULE; +/* the space is needed cause if you build with nothing it will complain */ +const char version_flags[] = " " VER_DEBUG VER_ENCRYPTION VER_THREAD VER_OS VER_GHBNR VER_MYSQL VER_MODULE; EOF diff --git a/include/viagra.h b/include/viagra.h new file mode 100644 index 000000000..44fd9166b --- /dev/null +++ b/include/viagra.h @@ -0,0 +1,76 @@ +/* Viagra IRCD functions + * + * (C) 2003 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. + * + * + */ + +#ifdef IRC_VIAGRA + +#define PROTECT_SET_MODE "+a" +#define PROTECT_UNSET_MODE "+a" +#define CS_CMD_PROTECT "PROTECT" +#define CS_CMD_DEPROTECT "DEPROTECT" +#define FANT_PROTECT_ADD "!protect" +#define FANT_PROTECT_DEL "!deprotect" +#define LEVEL_PROTECT_WORD "AUTOPROTECT" +#define LEVELINFO_PROTECT_WORD "PROTECT" +#define LEVELINFO_PROTECTME_WORD "PROTECTME" + +/* 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 + +#endif + diff --git a/lang/cat.l b/lang/cat.l index 244e0f8a5..c4a548dc1 100644 --- a/lang/cat.l +++ b/lang/cat.l @@ -6282,3 +6282,16 @@ HOST_HELP_GROUP This command allows users to set the vhost of thier CURRENT nick to be the vhost for all nicks in the same group. + +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + @@ -6482,3 +6482,15 @@ HOST_HELP_GROUP Dieses Command erlaubt es Usern, den vhost ihres aktuellen Nicks, zum vhost der gessamten Group zu setzen. +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + diff --git a/lang/en_us.l b/lang/en_us.l index f53d832c4..674b1d988 100644 --- a/lang/en_us.l +++ b/lang/en_us.l @@ -6023,3 +6023,16 @@ HOST_HELP_GROUP CURRENT nick to be the vhost for all nicks in the same group. +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + + @@ -6292,3 +6292,16 @@ HOST_HELP_GROUP Este comando permite a usuarios a setear el vhost de su nick actual para ser el vhost para todos los nicks en el mismo grupo. + +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + @@ -6314,3 +6314,16 @@ HOST_HELP_GROUP Permet d'enregistrer la vHost du nick actuellement utilisé pour tous les pseudos du groupe. + +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + @@ -6159,3 +6159,16 @@ HOST_HELP_GROUP This command allows users to set the vhost of thier CURRENT nick to be the vhost for all nicks in the same group. + +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + diff --git a/lang/hun.l b/lang/hun.l index 40504e9b7..a849be40b 100644 --- a/lang/hun.l +++ b/lang/hun.l @@ -6044,3 +6044,15 @@ HOST_HELP_GROUP Ez a parancs lehetõvé teszi, hogy a JELENLEGI nick vhostját beállítsuk a csoport minden nickjére. +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + @@ -6317,3 +6317,16 @@ HOST_HELP_GROUP Questo comando permette agli utenti di impostare il vhost del loro nick ATTUALE come vhost di tutti i nick nello stesso gruppo. + +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + @@ -6182,3 +6182,16 @@ HOST_HELP_GROUP HUIDIGE nick de vhost van alle nicks in de zelfde groep te laten zijn. +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + + @@ -6597,3 +6597,15 @@ HOST_HELP_GROUP CURRENT nick to be the vhost for all nicks in the same group. +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + @@ -5916,3 +5916,16 @@ HOST_HELP_GROUP This command allows users to set the vhost of thier CURRENT nick to be the vhost for all nicks in the same group. + +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + @@ -6061,3 +6061,16 @@ HOST_HELP_GROUP Ýòà êîìàíäà ïîçâîëÿåò ïîëüçîâàòåëÿì óñòàíîâèòü âèðòóàëüíûé õîñò ñ èõ ÒÅÊÓÙÅÃÎ íèêà íà âñå íèêè ãðóïïû. + +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + @@ -6092,3 +6092,16 @@ HOST_HELP_GROUP This command allows users to set the vhost of thier CURRENT nick to be the vhost for all nicks in the same group. + +OPER_SVSNICK_UNSUPPORTED + Sorry, SVSNICK is not available on this network. + +OPER_SQLINE_UNSUPPORTED + Sorry, SQLINE is not available on this network. + +OPER_SVSO_UNSUPPORTED + Sorry, OLINE is not available on this network. + +OPER_UMODE_UNSUPPORTED + Sorry, UMODE is not available on this network. + diff --git a/src/Makefile b/src/Makefile index aa2303268..3465c8e47 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,13 +3,16 @@ RDB_OBJ = $(RDB:.c=.o) OBJS = actions.o botserv.o channels.o chanserv.o commands.o compat.o converter.o \ config.o datafiles.o encrypt.o helpserv.o hostserv.o init.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 protocol.o proxy.o send.o servers.o sessions.o slist.o sockutil.o \ - timeout.o users.o \ + process.o proxy.o send.o servers.o sessions.o slist.o sockutil.o \ + timeout.o users.o dreamforge.o bahamut.o unreal31.o ultimate2.o ultimate3.o \ + hybrid.o ptlink.o viagra.o rageircd.o unreal32.o \ $(VSNPRINTF_O) $(RDB_OBJ) $(MYSQL_OBJ) SRCS = actions.c botserv.c channels.c chanserv.c commands.c compat.c converter.c \ config.c datafiles.c encrypt.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 protocol.c proxy.c send.c servers.c sessions.c slist.c sockutil.c \ + process.c proxy.c send.c servers.c sessions.c slist.c sockutil.c \ + dreamforge.c bahamut.c unreal31.c ultimate2.c ultimate3.c \ + hybrid.c ptlink.c viagra.c rageircd.c unreal32.c \ timeout.c users.c \ $(VSNPRINTF_C) $(RDB) $(MYSQL) @@ -17,7 +20,11 @@ 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/version.h + ../include/modules.h ../include/slist.h ../include/version.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 + MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \ diff --git a/src/actions.c b/src/actions.c index cb7fd0851..a863eae76 100644 --- a/src/actions.c +++ b/src/actions.c @@ -38,43 +38,12 @@ void bad_password(User * u) /*************************************************************************/ -void change_user_mode(User * u, char *modes, char *arg) -{ -#ifndef IRC_HYBRID - int ac = 1; - char *av[2]; - - av[0] = modes; - if (arg) { - av[1] = arg; - ac++; - } -#ifdef IRC_BAHAMUT - send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, u->timestamp, - av[0], (ac == 2 ? " " : ""), (ac == 2 ? av[1] : "")); -#else - send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0], - (ac == 2 ? " " : ""), (ac == 2 ? av[1] : "")); -#endif - set_umode(u, ac, av); -#endif -} - -/*************************************************************************/ - /* Remove a user from the IRC network. `source' is the nick which should * generate the kill, or NULL for a server-generated kill. */ -void kill_user(const char *source, const char *user, const char *reason) +void kill_user(char *source, char *user, char *reason) { -#ifdef IRC_BAHAMUT - /* Bahamut uses SVSKILL as a better way to kill users. It sends back - * a QUIT message that Anope uses to clean up after the kill is done. - */ - send_cmd(NULL, "SVSKILL %s :%s", user, reason); -#else - char *av[2]; char buf[BUFSIZE]; if (!user || !*user) @@ -83,13 +52,131 @@ void kill_user(const char *source, const char *user, const char *reason) source = ServerName; if (!reason) reason = ""; + snprintf(buf, sizeof(buf), "%s (%s)", source, reason); - av[0] = sstrdup(user); - av[1] = buf; - send_cmd(source, "KILL %s :%s", user, av[1]); - do_kill(source, 2, av); - free(av[0]); -#endif + + anope_cmd_svskill(source, user, buf); + + if (!ircd->quitonkill) { + do_kill(user, buf); + } +} + +/*************************************************************************/ + +void sqline(char *mask, char *reason) +{ + if (ircd->chansqline) { + if (*mask == '#') { + int i; + Channel *c, *next; + + char *av[3]; + struct c_userlist *cu, *cunext; + + anope_cmd_sqline(mask, reason); + + for (i = 0; i < 1024; i++) { + for (c = chanlist[i]; c; c = next) { + next = c->next; + + if (!match_wild_nocase(mask, c->name)) + continue; + + for (cu = c->users; cu; cu = cunext) { + cunext = cu->next; + + if (is_oper(cu->user)) + continue; + + av[0] = c->name; + av[1] = cu->user->nick; + av[2] = reason; + anope_cmd_kick(s_OperServ, av[0], av[1], + "Q-Lined: %s", av[2]); + do_kick(s_ChanServ, 3, av); + } + } + } + } else { + anope_cmd_sqline(mask, reason); + } + } else { + anope_cmd_sqline(mask, reason); + } +} + +/*************************************************************************/ + +void common_unban(ChannelInfo * ci, char *nick) +{ + int count, i; + char *av[3], **bans; + User *u; + + if (!ci || !ci->c || !ci->bi || !nick) + return; + if (!(u = finduser(nick))) + return; + + if (ircd->svsmode_unban) { + anope_cmd_unban(ci->name, nick); + } else { + av[0] = ci->name; + av[1] = sstrdup("-b"); + count = ci->c->bancount; + bans = scalloc(sizeof(char *) * count, 1); + memcpy(bans, ci->c->bans, sizeof(char *) * count); + for (i = 0; i < count; i++) { + if (match_usermask(bans[i], u)) { + anope_cmd_mode(whosends(ci), ci->name, "-b %s", bans[i]); + av[2] = bans[i]; + do_cmode(ci->bi->nick, 3, av); + } + } + free(bans); + free(av[1]); + } +} + +/*************************************************************************/ + +void common_svsmode(User * u, char *modes, char *arg) +{ + int ac = 1; + char *av[2]; + + av[0] = modes; + if (arg) { + av[1] = arg; + ac++; + } + anope_cmd_svsmode(u, ac, av); + anope_set_umode(u, ac, av); +} + +/*************************************************************************/ + +char *common_get_vhost(User * u) +{ + if (u->mode & ircd->vhostmode) { + return u->vhost; + } else { + return u->host; + } } /*************************************************************************/ + +char *common_get_vident(User * u) +{ + if (u->mode & ircd->vhostmode) { + if (u->vident) { + return u->vident; + } else { + return u->username; + } + } else { + return u->username; + } +} diff --git a/src/bahamut.c b/src/bahamut.c new file mode 100644 index 000000000..b605924d7 --- /dev/null +++ b/src/bahamut.c @@ -0,0 +1,1299 @@ +/* Bahamut functions + * + * (C) 2003 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. + * + * + */ + +/*************************************************************************/ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_BAHAMUT + +const char version_protocol[] = "BahamutIRCd 1.4.*/1.8.*"; + +IRCDVar ircd[] = { + {"BahamutIRCd 1.4.*/1.8.*", /* ircd name */ + "+o", /* nickserv mode */ + "+o", /* chanserv mode */ + "+o", /* memoserv mode */ + "+", /* hostserv mode */ + "+io", /* operserv mode */ + "+o", /* botserv mode */ + "+h", /* helpserv mode */ + "+i", /* Dev/Null mode */ + "+io", /* Global mode */ + "+o", /* nickserv alias mode */ + "+o", /* chanserv alias mode */ + "+o", /* memoserv alias mode */ + "+", /* hostserv alias mode */ + "+io", /* operserv alias mode */ + "+o", /* botserv alias mode */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+", /* Used by BotServ Bots */ + 2, /* Chan Max Symbols */ + "-ciklmnpstOR", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 0, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+rd", /* Mode On Reg */ + "-r+d", /* Mode on UnReg */ + "+d", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 0, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 1, /* Chan SQlines */ + 1, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 0, /* vidents */ + 1, /* svshold */ + 1, /* time stamp on mode */ + 1, /* NICKIP */ + 0, /* UMODE */ + 0, /* O:LINE */ + 0, /* VHOST ON NICK */ + 0, /* Change RealName */ + 0, /* ChanServ extra */ + 0, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + 0, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, /* Mode */ + 0, /* Mode */ + 1, + + } + , + {NULL} +}; + +IRCDCAPAB ircdcap[] = { + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + 0, /* ZIP */ + CAPAB_BURST, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + CAPAB_DOZIP /* DOZIP */ + } +}; + + +void anope_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 'a': + if (add && !is_services_admin(user)) { + send_cmd(ServerName, "SVSMODE %s -a", user->nick); + user->mode &= ~UMODE_a; + } + break; + case 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + } + } +} + + + + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, + 0, + UMODE_R, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0, 0, 0, 0, 0, + 0, UMODE_a, 0, 0, 0, 0, 0, + 0, + UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, + 0, + 0, UMODE_r, 0, 0, 0, 0, UMODE_w, + 0, + 0, + 0, + 0, 0, 0, 0, 0 +}; + +char csmodes[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, + + '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, 0, 0 +}; + + +CMMode cmmodes[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 cbmodes[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}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {CMODE_M}, + {0}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {0}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* 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 */ + {0}, /* f */ + {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}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} +}; + +CBModeInfo cbmodeinfos[] = { + {'c', CMODE_c, 0, NULL, NULL}, + {'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}, + {'M', CMODE_M, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {0} +}; + +CUMode cumodes[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}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {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 anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + 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) +{ + send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout, + "Being held for registered user"); +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + send_cmd(ServerName, "SVSHOLD %s 0", nick); +} + +/* SVSMODE -b */ +void anope_cmd_unban(char *name, char *nick) +{ + send_cmd(ServerName, "SVSMODE %s -b %s", name, nick); +} + +void anope_cmd_bot_chan_mode(char *nick, char *chan) +{ + anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick); +} + +/* EVENT: SJOIN */ +int anope_event_sjoin(char *source, int ac, char **av) +{ + do_sjoin(source, ac, av); + return MOD_CONT; +} + +/* +** NICK - new +** source = NULL +** parv[0] = nickname +** parv[1] = hopcount +** parv[2] = timestamp +** parv[3] = modes +** parv[4] = username +** parv[5] = hostname +** parv[6] = server +** parv[7] = servicestamp +** parv[8] = IP +** parv[9] = info +** NICK - change +** source = oldnick +** parv[0] = new nickname +** parv[1] = hopcount +*/ +int anope_event_nick(char *source, int ac, char **av) +{ + User *user; + + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), + strtoul(av[8], NULL, 0), NULL, NULL); + if (user) { + anope_set_umode(user, 1, &av[3]); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; +} + +/* EVENT : CAPAB */ +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +/* EVENT : OS */ +int anope_event_os(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +/* EVENT : NS */ +int anope_event_ns(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +/* EVENT : MS */ +int anope_event_ms(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +/* EVENT : HS */ +int anope_event_hs(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +/* EVENT : CS */ +int anope_event_cs(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("RS", NULL); addCoreMessage(IRCD,m); + m = createMessage("SGLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SS", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); + m = createMessage("SZLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSGLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSZLINE", NULL); addCoreMessage(IRCD,m); +} + +/* *INDENT-ON* */ + +/* SQLINE */ +void anope_cmd_sqline(char *mask, char *reason) +{ + if (!mask || !reason) { + return; + } + + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +/* UNSGLINE */ +void anope_cmd_unsgline(char *mask) +{ + send_cmd(NULL, "UNSGLINE 0 :%s", mask); +} + +/* UNSZLINE */ +void anope_cmd_unszline(char *mask) +{ + send_cmd(NULL, "UNSZLINE 0 %s", mask); +} + +/* SZLINE */ +void anope_cmd_szline(char *mask, char *reason) +{ + send_cmd(NULL, "SZLINE %s :%s", mask, reason); +} + +/* SVSNOOP */ +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-")); +} + +/* SGLINE */ +void anope_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) +{ + send_cmd(NULL, "RAKILL %s %s", host, user); +} + +/* PART */ +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (!nick || !chan) { + return; + } + + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +/* TOPIC */ +void anope_cmd_topic(char *whosets, char *chan, char *whosetit, + char *topic, time_t when) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +/* UNSQLINE */ +void anope_cmd_unsqline(char *user) +{ + send_cmd(NULL, "UNSQLINE %s", user); +} + +/* JOIN - SJOIN */ +void anope_cmd_join(char *user, char *channel, time_t chantime) +{ + send_cmd(user, "SJOIN %ld %s", chantime, channel); +} + +/* AKILL */ +/* parv[1]=host + * parv[2]=user + * parv[3]=length + * parv[4]=akiller + * 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) +{ + send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, + time(NULL), reason); +} + +/* SVSKILL */ +/* parv[0] = servername + * parv[1] = client + * parv[2] = nick stamp + * parv[3] = kill message + */ +/* + 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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + if (!source || !user) { + return; + } + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "SVSKILL %s :%s", user, buf); +} + +/* SVSMODE */ +/* parv[0] - sender + * parv[1] - nick + * parv[2] - TS (or mode, depending on svs version) + * 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) +{ + send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, u->timestamp, + av[0], (ac == 2 ? " " : ""), (ac == 2 ? av[1] : "")); +} + +/* SQUIT */ +void anope_cmd_squit(char *servname, char *message) +{ + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +/* PONG */ +void anope_cmd_pong(char *servname, char *who) +{ + send_cmd(servname, "PONG %s", who); +} + +void anope_cmd_connect(int servernum) +{ + 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(); +} + +/* SVINFO */ +void anope_cmd_svinfo() +{ + send_cmd(NULL, "SVINFO 3 1 0 :%ld", time(NULL)); +} + +/* PASS */ +void anope_cmd_pass(char *pass) +{ + send_cmd(NULL, "PASS %s :TS", pass); +} + +/* SERVER */ +void anope_cmd_server(char *servname, int hop, char *descript) +{ + send_cmd(NULL, "SERVER %s %d :%s", ServerName, hop, ServerDesc); +} + +/* CAPAB */ +void anope_cmd_capab() +{ + send_cmd(NULL, "CAPAB NICKIP SSJOIN TS3 NOQUIT TSMODE UNCONNECT"); +} + +/* EVENT : SERVER */ +int anope_event_server(char *source, int ac, char **av) +{ + char *uplink; + + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } + + do_server(source, ac, av); + return MOD_CONT; +} + +/* EVENT : PRIVMSG */ +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +/* EVENT : 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 + */ +int anope_event_svinfo(char *source, int ac, char **av) +{ + return MOD_CONT; +} + + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + +/* EVENT: MODE */ +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + +/* EVENT: KILL */ +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +/* EVENT: KICK */ +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + +/* EVENT: JOIN */ +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +/* EVENT: MOTD */ +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + +/* NOTICE */ +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +void anope_cmd_nick(char *nick, char *name, char *modes) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, time(NULL), + modes, ServiceUser, ServiceHost, ServerName, name); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_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) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +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]); + return MOD_CONT; +} + +void anope_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) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, time(NULL), + modes, user, host, ServerName, real); + anope_cmd_sqline(nick, "Reserved for services"); +} + +/* SVSNICK */ +/* parv[0] = sender + * parv[1] = old nickname + * parv[2] = new nickname + * parv[3] = timestamp + */ +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +void anope_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, time(NULL), + modes, user, host, ServerName, real); +} + +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + /* Not Supported by this IRCD */ +} + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + /* Not Supported by this IRCD */ +} + +void anope_cmd_vhost_off(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) +{ + send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, ts); +} + + +/* SVSMODE +d */ +/* nc_change was = 1, and there is no na->status */ +void anope_cmd_nc_change(User * u) +{ + common_svsmode(u, "+d", "1"); +} + +/* SVSMODE +d */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + // not used by bahamut ircds +} + + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } +} + +#endif diff --git a/src/botserv.c b/src/botserv.c index b8710672b..361662a31 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -46,7 +46,6 @@ 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 void bot_raw_unban(ChannelInfo * ci, char *nick); static int do_help(User * u); static int do_bot(User * u); @@ -222,20 +221,9 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) cstatus = chan_get_user_status(ci->c, u); if (buf && !check_access(u, ci, CA_NOKICK) && -#ifdef HAS_HALFOP -#if defined(IRC_UNREAL) || defined (IRC_VIAGRA) (!(ci->botflags & BS_DONTKICKOPS) || !(cstatus & (CUS_HALFOP | CUS_OP | CUS_OWNER | CUS_PROTECT))) -# elif defined (IRC_ULTIMATE3) || defined(IRC_RAGE2) - (!(ci->botflags & BS_DONTKICKOPS) - || !(cstatus & (CUS_HALFOP | CUS_OP | CUS_PROTECT))) -# else - (!(ci->botflags & BS_DONTKICKOPS) - || !(cstatus & (CUS_HALFOP | CUS_OP))) -# endif -#else - (!(ci->botflags & BS_DONTKICKOPS) || !(cstatus & CUS_OP)) -#endif + && (!(ci->botflags & BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) { /* Bolds kicker */ if ((ci->botflags & BS_KICK_BOLDS) && strchr(buf, 2)) { @@ -466,13 +454,10 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) cmd = strtok(buf, " "); if (cmd) { -#if defined(IRC_UNREAL) || defined (IRC_VIAGRA) - if (!stricmp(cmd, "!deowner")) { + if (!stricmp(cmd, "!deowner") && ircd->owner) { if (is_founder(u, ci)) bot_raw_mode(u, ci, "-q", u->nick); - } else -#endif - if (!stricmp(cmd, "!kb")) { + } else if (!stricmp(cmd, "!kb")) { char *target = strtok(NULL, " "); char *reason = strtok(NULL, ""); @@ -502,11 +487,9 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) else bot_raw_kick(u, ci, target, reason); } -#if defined(IRC_UNREAL) || defined (IRC_VIAGRA) - } else if (!stricmp(cmd, "!owner")) { + } else if (!stricmp(cmd, "!owner") && ircd->owner) { if (is_founder(u, ci)) bot_raw_mode(u, ci, "+q", u->nick); -#endif } else if (!stricmp(cmd, "!seen")) { char *target = strtok(NULL, " "); char buf[BUFSIZE]; @@ -520,16 +503,16 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) /* If we look for the bot */ snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_BOT), u->nick); - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - buf); + 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); - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - buf); + 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, @@ -549,8 +532,8 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) getstring(u->na, BOT_SEEN_ON_CHANNEL_AS), target, u2->nick); - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - buf); + 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 @@ -568,15 +551,15 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) getstring(u->na, BOT_SEEN_NEVER), target); } - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - buf); + 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); - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - buf); + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", + buf); } } } else if (!stricmp(cmd, "!unban") @@ -584,9 +567,9 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) char *target = strtok(NULL, " "); if (!target) - bot_raw_unban(ci, u->nick); + common_unban(ci, u->nick); else - bot_raw_unban(ci, target); + common_unban(ci, target); } else { CSModeUtil *util = csmodeutils; @@ -669,7 +652,7 @@ void load_bs_dbase(void) restore_db(f); \ log_perror("Write error on %s", BotDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - wallops(NULL, "Write error on %s: %s", BotDBName, \ + anope_cmd_global(NULL, "Write error on %s: %s", BotDBName, \ strerror(errno)); \ lastwarn = time(NULL); \ } \ @@ -830,8 +813,8 @@ BotInfo *findbot(char *nick) static void unassign(User * u, ChannelInfo * ci) { if (ci->c && ci->c->usercount >= BSMinUsers) { - send_cmd(ci->bi->nick, "PART %s :UNASSIGN from %s", ci->name, - u->nick); + anope_cmd_part(ci->bi->nick, ci->name, "UNASSIGN from %s", + u->nick); } ci->bi->chancount--; ci->bi = NULL; @@ -851,7 +834,8 @@ static BanData *get_ban_data(Channel * c, User * u) if (!c || !u) return NULL; - snprintf(mask, sizeof(mask), "%s@%s", u->username, GetHost(u)); + snprintf(mask, sizeof(mask), "%s@%s", u->username, + common_get_vhost(u)); for (bd = c->bd; bd; bd = next) { if (now - bd->last_use > BSKeepData) { @@ -955,7 +939,7 @@ void bot_join(ChannelInfo * ci) av[1] = sstrdup("-b"); for (i = 0; i < count; i++) { if (match_wild_nocase(ci->c->bans[i], botmask)) { - send_mode(ci->bi->nick, ci->name, "%s", bans[i]); + anope_cmd_mode(ci->bi->nick, ci->name, "%s", bans[i]); av[2] = sstrdup(bans[i]); do_cmode(ci->bi->nick, 3, av); free(av[2]); @@ -968,29 +952,12 @@ void bot_join(ChannelInfo * ci) /* Should we be invited? */ if ((ci->c->mode & CMODE_i) || (ci->c->limit && ci->c->usercount >= ci->c->limit)) - send_cmd(NULL, "NOTICE @%s :%s invited %s into the channel.", - ci->c->name, ci->bi->nick, ci->bi->nick); + anope_cmd_notice_ops(NULL, ci->c->name, + "%s invited %s into the channel.", + ci->bi->nick, ci->bi->nick); } -#ifdef IRC_BAHAMUT - send_cmd(ci->bi->nick, "SJOIN %ld %s", ci->c->creation_time, - ci->c->name); -#elif defined(IRC_HYBRID) - send_cmd(NULL, "SJOIN %ld %s + :%s", time(NULL), ci->c->name, - ci->bi->nick); -#else - send_cmd(ci->bi->nick, "JOIN %s", ci->c->name); -#endif - -#if defined(IRC_UNREAL) || defined (IRC_VIAGRA) - send_mode(ci->bi->nick, ci->c->name, "+ao %s %s", ci->bi->nick, - ci->bi->nick); -#elif defined(IRC_PTLINK) - /* PTLinks requieres an IRCop to u-line changes, so use ChanServ */ - send_mode(s_ChanServ, ci->c->name, "+ao %s %s", ci->bi->nick, - ci->bi->nick); -#else - send_mode(ci->bi->nick, ci->c->name, "+o %s", ci->bi->nick); -#endif + anope_cmd_join(ci->bi->nick, ci->c->name, ci->c->creation_time); + anope_cmd_bot_chan_mode(ci->bi->nick, ci->c->name); } /*************************************************************************/ @@ -1033,7 +1000,7 @@ static void check_ban(ChannelInfo * ci, User * u, int ttbtype) av[1] = sstrdup("+b"); get_idealban(ci, u, mask, sizeof(mask)); av[2] = mask; - send_mode(ci->bi->nick, av[0], "+b %s", av[2]); + anope_cmd_mode(ci->bi->nick, av[0], "+b %s", av[2]); do_cmode(ci->bi->nick, 3, av); free(av[1]); } @@ -1062,7 +1029,7 @@ static void bot_kick(ChannelInfo * ci, User * u, int message, ...) av[0] = ci->name; av[1] = u->nick; av[2] = buf; - send_cmd(ci->bi->nick, "KICK %s %s :%s", av[0], av[1], av[2]); + anope_cmd_kick(ci->bi->nick, av[0], av[1], "%s", av[2]); do_kick(ci->bi->nick, 3, av); } @@ -1080,31 +1047,31 @@ static void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, if (!u) return; -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) - if (is_protected(u) && (requester != u)) { - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - getstring2(NULL, PERMISSION_DENIED)); - return; + if (ircd->protectedumode) { + if (is_protected(u) && (requester != u)) { + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", + getstring2(NULL, PERMISSION_DENIED)); + return; + } } -#endif if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci))) return; -#ifdef HAS_EXCEPT - if (is_excepted(ci, u) == 1) { - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - getstring2(NULL, BOT_EXCEPT)); - return; + if (ircd->except) { + if (is_excepted(ci, u) == 1) { + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", + getstring2(NULL, BOT_EXCEPT)); + return; + } } -#endif av[0] = ci->name; av[1] = sstrdup("+b"); get_idealban(ci, u, mask, sizeof(mask)); av[2] = mask; - send_mode(ci->bi->nick, av[0], "+b %s", av[2]); + anope_cmd_mode(ci->bi->nick, av[0], "+b %s", av[2]); do_cmode(ci->bi->nick, 3, av); free(av[1]); @@ -1119,7 +1086,7 @@ static void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, av[2] = reason; } - send_cmd(ci->bi->nick, "KICK %s %s :%s", av[0], av[1], av[2]); + anope_cmd_kick(ci->bi->nick, av[0], av[1], "%s", av[2]); do_kick(ci->bi->nick, 3, av); } @@ -1136,13 +1103,13 @@ static void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, if (!u || !is_on_chan(ci->c, u)) return; -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) - if (is_protected(u) && (requester != u)) { - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - getstring2(NULL, PERMISSION_DENIED)); - return; + if (ircd->protectedumode) { + if (is_protected(u) && (requester != u)) { + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", + getstring2(NULL, PERMISSION_DENIED)); + return; + } } -#endif if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci))) @@ -1159,7 +1126,7 @@ static void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, av[2] = reason; } - send_cmd(ci->bi->nick, "KICK %s %s :%s", av[0], av[1], av[2]); + anope_cmd_kick(ci->bi->nick, av[0], av[1], "%s", av[2]); do_kick(ci->bi->nick, 3, av); } @@ -1176,13 +1143,13 @@ static void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode, if (!u || !is_on_chan(ci->c, u)) return; -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) - if (is_protected(u) && *mode == '-' && (requester != u)) { - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, - getstring2(NULL, PERMISSION_DENIED)); - return; + if (ircd->protectedumode) { + if (is_protected(u) && *mode == '-' && (requester != u)) { + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", + getstring2(NULL, PERMISSION_DENIED)); + return; + } } -#endif if (*mode == '-' && (ci->flags & CI_PEACE) && stricmp(requester->nick, nick) @@ -1193,57 +1160,12 @@ static void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode, av[1] = mode; av[2] = nick; - send_mode(ci->bi->nick, av[0], "%s %s", av[1], av[2]); + anope_cmd_mode(ci->bi->nick, av[0], "%s %s", av[1], av[2]); do_cmode(ci->bi->nick, 3, av); } /*************************************************************************/ -/* Removes all bans for a nick on a channel */ - -static void bot_raw_unban(ChannelInfo * ci, char *nick) -{ -#ifndef IRC_BAHAMUT - int count, i; - char *av[3], **bans; - User *u; -#endif - - if (!ci || !ci->c || !ci->bi || !nick) - return; -#ifndef IRC_BAHAMUT - if (!(u = finduser(nick))) - return; -#else - if (!finduser(nick)) - return; -#endif - -#ifndef IRC_BAHAMUT - av[0] = ci->name; - av[1] = sstrdup("-b"); - - count = ci->c->bancount; - bans = scalloc(sizeof(char *) * count, 1); - memcpy(bans, ci->c->bans, sizeof(char *) * count); - - for (i = 0; i < count; i++) { - if (match_usermask(bans[i], u)) { - send_mode(ci->bi->nick, ci->name, "-b %s", bans[i]); - av[2] = bans[i]; - do_cmode(ci->bi->nick, 3, av); - } - } - free(bans); - free(av[1]); -#else - send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick); -#endif -} - -/*************************************************************************/ -/*************************************************************************/ - static int do_help(User * u) { char *cmd = strtok(NULL, ""); @@ -1383,8 +1305,8 @@ static int do_bot(User * u) EnforceQlinedNick(nick, s_BotServ); /* We make the bot online, ready to serve */ - NEWNICK(bi->nick, bi->user, bi->host, bi->real, - BOTSERV_BOTS_MODE, 1); + 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); @@ -1493,9 +1415,9 @@ static int do_bot(User * u) if (stricmp(bi->nick, nick)) { /* The new nick is really different, so we remove the Q line for the old nick. */ -#ifndef IRC_HYBRID - send_cmd(NULL, "UNSQLINE %s", bi->nick); -#endif + if (ircd->sqline) { + anope_cmd_unsqline(bi->nick); + } /* We check whether the nick is registered, and drop it if so */ if ((na = findnick(nick))) @@ -1524,12 +1446,12 @@ static int do_bot(User * u) /* If only the nick changes, we just make the bot change his nick, else we must make it quit and rejoin. */ if (!user) - send_cmd(oldnick, "NICK %s", bi->nick); + anope_cmd_chg_nick(oldnick, bi->nick); else { - send_cmd(oldnick, "QUIT :Quit: Be right back"); + anope_cmd_quit(oldnick, "Quit: Be right back"); - NEWNICK(bi->nick, bi->user, bi->host, bi->real, - BOTSERV_BOTS_MODE, 1); + anope_cmd_bot_nick(bi->nick, bi->user, bi->host, bi->real, + ircd->botserv_bot_mode); bot_rejoin_all(bi); } @@ -1546,12 +1468,12 @@ static int do_bot(User * u) else if (!(bi = findbot(nick))) notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick); else { - send_cmd(bi->nick, - "QUIT :Quit: Help! I'm being deleted by %s!", - u->nick); -#ifndef IRC_HYBRID - send_cmd(NULL, "UNSQLINE %s", bi->nick); -#endif + 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); @@ -2494,11 +2416,12 @@ static int do_say(User * u) notice_lang(s_BotServ, u, ACCESS_DENIED); else { if (text[0] != '\001') { - send_cmd(ci->bi->nick, "PRIVMSG %s :%s", ci->name, text); + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", text); ci->bi->lastmsg = time(NULL); if (logchan && LogBot) - send_cmd(ci->bi->nick, "PRIVMSG %s :SAY %s %s %s", - LogChannel, u->nick, ci->name, text); + 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); } @@ -2528,12 +2451,12 @@ static int do_act(User * u) else if (!check_access(u, ci, CA_SAY)) notice_lang(s_BotServ, u, ACCESS_DENIED); else { - send_cmd(ci->bi->nick, "PRIVMSG %s :%cACTION %s%c", ci->name, 1, - text, 1); + anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION %s%c", 1, + text, 1); ci->bi->lastmsg = time(NULL); if (logchan && LogBot) - send_cmd(ci->bi->nick, "PRIVMSG %s :ACT %s %s %s", LogChannel, - u->nick, ci->name, text); + anope_cmd_privmsg(ci->bi->nick, LogChannel, ":ACT %s %s %s", + u->nick, ci->name, text); } return MOD_CONT; } diff --git a/src/channels.c b/src/channels.c index f099eda32..acb0caad8 100644 --- a/src/channels.c +++ b/src/channels.c @@ -19,410 +19,24 @@ Channel *chanlist[1024]; #define HASH(chan) ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0) -static void add_ban(Channel * chan, char *mask); -#ifdef HAS_EXCEPT -static void add_exception(Channel * chan, char *mask); -#endif -static void chan_adduser2(User * user, Channel * c); -static Channel *chan_create(const char *chan); -static void chan_delete(Channel * c); -static void del_ban(Channel * chan, char *mask); -#ifdef HAS_EXCEPT -static void del_exception(Channel * chan, char *mask); -#endif -#ifdef HAS_FMODE -static char *get_flood(Channel * chan); -#endif -static char *get_key(Channel * chan); -static char *get_limit(Channel * chan); -#ifdef HAS_LMODE -static char *get_redirect(Channel * chan); -#endif -static Channel *join_user_update(User * user, Channel * chan, char *name); -#ifdef HAS_FMODE -static void set_flood(Channel * chan, char *value); -#endif -static void set_key(Channel * chan, char *value); -static void set_limit(Channel * chan, char *value); -#ifdef HAS_LMODE -static void set_redirect(Channel * chan, char *value); -#endif +void add_ban(Channel * chan, char *mask); +void add_exception(Channel * chan, char *mask); +void chan_adduser2(User * user, Channel * c); +Channel *chan_create(char *chan); +void chan_delete(Channel * c); +void del_ban(Channel * chan, char *mask); +void del_exception(Channel * chan, char *mask); +char *get_flood(Channel * chan); +char *get_key(Channel * chan); +char *get_limit(Channel * chan); +char *get_redirect(Channel * chan); +Channel *join_user_update(User * user, Channel * chan, char *name); +void set_flood(Channel * chan, char *value); +void set_key(Channel * chan, char *value); +void set_limit(Channel * chan, char *value); +void set_redirect(Channel * chan, char *value); void do_mass_mode(char *modes); -/*************************************************************************/ -/* *INDENT-OFF* */ - -CBMode cbmodes[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 }, -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) || defined(IRC_VIAGRA) - { CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL }, -#else - { 0 }, /* A */ -#endif - { 0 }, /* B */ -#if defined(IRC_UNREAL) || defined(IRC_RAGE2) - { CMODE_C, 0, NULL, NULL }, -#else - { 0 }, /* C */ -#endif - { 0 }, /* D */ - { 0 }, /* E */ - { 0 }, /* F */ -#ifdef IRC_UNREAL - { CMODE_G, 0, NULL, NULL }, -#else - { 0 }, /* G */ -#endif -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) - { CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL }, -#else - { 0 }, /* H */ -#endif -#ifdef IRC_ULTIMATE - { CMODE_I }, -#else - { 0 }, /* I */ -#endif - { 0 }, /* J */ -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) || defined(IRC_UNREAL) - { CMODE_K, 0, NULL, NULL }, -#else - { 0 }, /* K */ -#endif -#ifdef HAS_LMODE - { CMODE_L, 0, set_redirect, cs_set_redirect }, -#else - { 0 }, /* L */ -#endif -#ifdef IRC_BAHAMUT - { CMODE_M }, -#else - { 0 }, /* M */ -#endif -#if defined (IRC_UNREAL) || defined (IRC_ULTIMATE3) || defined (IRC_PTLINK) || defined(IRC_RAGE2) - { CMODE_N, 0, NULL, NULL }, -#else - { 0 }, /* N */ -#endif -#if defined(IRC_BAHAMUT) || defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - { CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL }, -#else - { 0 }, /* O */ -#endif - { 0 }, /* P */ -#ifdef IRC_UNREAL - { CMODE_Q, 0, NULL, NULL }, -#else - { 0 }, /* Q */ -#endif -#ifndef IRC_HYBRID - { CMODE_R, 0, NULL, NULL }, /* R */ -#else - { 0 }, -#endif -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined (IRC_ULTIMATE3) || defined (IRC_PTLINK) || defined(IRC_RAGE2) - { CMODE_S, 0, NULL, NULL }, -#else - { 0 }, /* S */ -#endif - { 0 }, /* T */ - { 0 }, /* U */ -#ifdef IRC_UNREAL - { CMODE_V, 0, NULL, NULL }, -#else - { 0 }, /* V */ -#endif - { 0 }, /* W */ - { 0 }, /* X */ - { 0 }, /* Y */ - { 0 }, /* Z */ - { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, -#ifdef IRC_HYBRID - { CMODE_a, 0, NULL, NULL }, -#else - { 0 }, /* a */ -#endif - { 0 }, /* b */ -#if defined(IRC_BAHAMUT) || defined(IRC_UNREAL) || defined (IRC_PTLINK) - { CMODE_c, 0, NULL, NULL }, -#else - { 0 }, /* c */ -#endif -#ifdef IRC_PTLINK - { CMODE_d, 0, NULL, NULL }, -#else - { 0 }, /* d */ -#endif - { 0 }, /* e */ -#ifdef HAS_FMODE - { CMODE_f, 0, set_flood, cs_set_flood }, -#else - { 0 }, /* f */ -#endif - { 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 }, -#ifdef IRC_PTLINK - { CMODE_q, 0, NULL, NULL }, -#else - { 0 }, /* q */ -#endif -#ifndef IRC_HYBRID - { CMODE_r, CBM_NO_MLOCK, NULL, NULL }, -#else - { 0 }, -#endif - { CMODE_s, 0, NULL, NULL }, - { CMODE_t, 0, NULL, NULL }, -#ifdef IRC_UNREAL - { CMODE_u, 0, NULL, NULL }, -#else - { 0 }, -#endif - { 0 }, /* v */ - { 0 }, /* w */ -#ifdef IRC_ULTIMATE - { CMODE_x }, -#else - { 0 }, /* x */ -#endif - { 0 }, /* y */ -#ifdef IRC_UNREAL - { CMODE_z, 0, NULL, NULL }, -#else - { 0 }, /* z */ -#endif - { 0 }, { 0 }, { 0 }, { 0 } -}; - -CBModeInfo cbmodeinfos[] = { -#if defined(IRC_HYBRID) - { 'a', CMODE_a, 0, NULL, NULL }, -#endif -#if defined(IRC_BAHAMUT) || defined(IRC_UNREAL) || defined(IRC_PTLINK) || defined(IRC_RAGE2) - { 'c', CMODE_c, 0, NULL, NULL }, -#endif -#if defined(IRC_PTLINK) - { 'd', CMODE_d, 0, NULL, NULL }, -#endif -#ifdef HAS_FMODE - { 'f', CMODE_f, 0, get_flood, cs_get_flood }, -#endif - { '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 }, -#ifdef IRC_PTLINK - { 'q', CMODE_q, 0, NULL, NULL }, -#endif -#ifndef IRC_HYBRID - { 'r', CMODE_r, 0, NULL, NULL }, -#endif - { 's', CMODE_s, 0, NULL, NULL }, - { 't', CMODE_t, 0, NULL, NULL }, -#ifdef IRC_UNREAL - { 'u', CMODE_u, 0, NULL, NULL }, -#endif -#ifdef IRC_ULTIMATE - { 'x', CMODE_x, 0, NULL, NULL }, -#endif -#ifdef IRC_UNREAL - { 'z', CMODE_z, 0, NULL, NULL }, -#endif -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_PTLINK) || defined(IRC_RAGE2) || defined(IRC_VIAGRA) - { 'A', CMODE_A, 0, NULL, NULL }, -#endif -#if defined(IRC_UNREAL) || defined(IRC_RAGE2) - { 'C', CMODE_C, 0, NULL, NULL }, -#endif -#ifdef IRC_UNREAL - { 'G', CMODE_G, 0, NULL, NULL }, -#endif -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) - { 'H', CMODE_H, 0, NULL, NULL }, -#endif -#ifdef IRC_ULTIMATE - { 'I', CMODE_I, 0, NULL, NULL }, -#endif -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_PTLINK) || defined(IRC_ULTIMATE3) - { 'K', CMODE_K, 0, NULL, NULL }, -#endif -#ifdef HAS_LMODE - { 'L', CMODE_L, 0, get_redirect, cs_get_redirect }, -#endif -#ifdef IRC_BAHAMUT -#ifndef IRC_ULTIMATE3 - { 'M', CMODE_M, 0, NULL, NULL }, -#endif -#endif -#if defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_PTLINK) || defined(IRC_RAGE2) - { 'N', CMODE_N, 0, NULL, NULL }, -#endif -#if defined(IRC_BAHAMUT) || defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - { 'O', CMODE_O, 0, NULL, NULL }, -#endif -#ifdef IRC_UNREAL - { 'Q', CMODE_Q, 0, NULL, NULL }, -#endif -#ifndef IRC_HYBRID - { 'R', CMODE_R, 0, NULL, NULL }, -#endif -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_PTLINK) || defined(IRC_RAGE2) - { 'S', CMODE_S, 0, NULL, NULL }, -#endif -#ifdef IRC_UNREAL - { 'V', CMODE_V, 0, NULL, NULL }, -#endif - { 0 } -}; - -static CMMode cmmodes[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 }, -#ifdef HAS_EXCEPT - { add_exception, del_exception }, -#endif - { 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 } -}; - -#if defined(IRC_BAHAMUT) || defined(IRC_HYBRID) || defined(IRC_PTLINK) - -static char csmodes[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, - #if defined(IRC_ULTIMATE3) || defined(IRC_HYBRID) - 'a', /* (33) ! Channel Admins */ - #else - 0, - #endif - 0, 0, 0, - #if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - 'h', /* (37) % Channel halfops */ - #else - 0, - #endif - 0, 0, 0, 0, - #if defined(IRC_RAGE2) - 'a', /* * Channel Admins */ - #else - 0, - #endif - - '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, 0, 0 -}; - -#endif - -static CUMode cumodes[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 }, - -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) - { CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op }, -#else -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - { CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_admin }, -#else - { 0 }, /* a */ -#endif -#endif - { 0 }, /* b */ - { 0 }, /* c */ - { 0 }, /* d */ - { 0 }, /* e */ - { 0 }, /* f */ - { 0 }, /* g */ -#ifdef HAS_HALFOP - { CUS_HALFOP, 0, check_valid_op }, -#else - { 0 }, /* h */ -#endif - { 0 }, /* i */ - { 0 }, /* j */ - { 0 }, /* k */ - { 0 }, /* l */ - { 0 }, /* m */ - { 0 }, /* n */ - { CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op }, - { 0 }, /* p */ -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) - { CUS_OWNER, 0, check_valid_op }, -#else - { 0 }, /* q */ -#endif - { 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 } -}; - -/* *INDENT-ON* */ -/*************************************************************************/ /**************************** External Calls *****************************/ /*************************************************************************/ @@ -453,7 +67,7 @@ void chan_deluser(User * user, Channel * c) c->usercount--; if (s_BotServ && c->ci && c->ci->bi && c->usercount == BSMinUsers - 1) { - send_cmd(c->ci->bi->nick, "PART %s", c->name); + anope_cmd_part(c->ci->bi->nick, c->name, NULL); } if (!c->users) @@ -598,8 +212,8 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av, BotInfo *bi; if ((bi = findbot(*av))) { - send_mode(bi->nick, chan->name, "+%c %s", mode, - bi->nick); + anope_cmd_mode(bi->nick, chan->name, "+%c %s", mode, + bi->nick); continue; } } @@ -665,7 +279,7 @@ void chan_set_user_status(Channel * chan, User * user, int16 status) if (HelpChannel && status == CUS_OP && !stricmp(chan->name, HelpChannel)) - change_user_mode(user, "+h", NULL); + common_svsmode(user, "+h", NULL); for (uc = user->chans; uc; uc = uc->next) { if (uc->chan == chan) { @@ -752,26 +366,26 @@ void get_channel_stats(long *nrec, long *memuse) mem += strlen(chan->topic) + 1; if (chan->key) mem += strlen(chan->key) + 1; -#ifdef HAS_FMODE - if (chan->flood) - mem += strlen(chan->flood) + 1; -#endif -#ifdef HAS_LMODE - if (chan->redirect) - mem += strlen(chan->redirect) + 1; -#endif + if (ircd->fmode) { + if (chan->flood) + mem += strlen(chan->flood) + 1; + } + if (ircd->Lmode) { + if (chan->redirect) + mem += strlen(chan->redirect) + 1; + } mem += sizeof(char *) * chan->bansize; for (j = 0; j < chan->bancount; j++) { if (chan->bans[j]) mem += strlen(chan->bans[j]) + 1; } -#ifdef HAS_EXCEPT - mem += sizeof(char *) * chan->exceptsize; - for (j = 0; j < chan->exceptcount; j++) { - if (chan->excepts[j]) - mem += strlen(chan->excepts[j]) + 1; + if (ircd->except) { + mem += sizeof(char *) * chan->exceptsize; + for (j = 0; j < chan->exceptcount; j++) { + if (chan->excepts[j]) + mem += strlen(chan->excepts[j]) + 1; + } } -#endif for (cu = chan->users; cu; cu = cu->next) { mem += sizeof(*cu); if (cu->ud) { @@ -986,8 +600,6 @@ void do_part(const char *source, int ac, char **av) /*************************************************************************/ -#if defined(IRC_BAHAMUT) || defined(IRC_HYBRID) || defined(IRC_PTLINK) - /* Handle a SJOIN command. On channel creation, syntax is: @@ -1013,16 +625,15 @@ void do_sjoin(const char *source, int ac, char **av) /* Double check to avoid unknown modes that need parameters */ if (ac >= 4 && ac <= 6) { - char *s, *end, cubuf[CHAN_MAX_SYMBOLS + 2], *end2, - *cumodes[CHAN_MAX_SYMBOLS + 1]; + char *s, *end, cubuf[ircd->max_symbols + 2], *end2, + *cumodes[ircd->max_symbols + 1]; c = findchan(av[1]); -#ifndef IRC_HYBRID -#ifndef IRC_PTLINK - if (!c) - is_sqlined = check_chan_sqline(av[1]); -#endif -#endif + + if (ircd->chansqline) { + if (!c) + is_sqlined = check_chan_sqline(av[1]); + } cubuf[0] = '+'; cumodes[0] = cubuf; @@ -1048,7 +659,7 @@ void do_sjoin(const char *source, int ac, char **av) } if (is_sqlined && !is_oper(user)) { - send_cmd(s_OperServ, "KICK %s %s :Q-Lined", av[1], s); + anope_cmd_kick(s_OperServ, av[1], s, "Q-Lined"); } else { if (!check_kick(user, av[1])) { /* Make the user join; if the channel does not exist it @@ -1094,14 +705,13 @@ void do_sjoin(const char *source, int ac, char **av) return; c = findchan(av[1]); -#ifndef IRC_HYBRID -#ifndef IRC_PTLINK - if (!c) - is_sqlined = check_chan_sqline(av[1]); -#endif -#endif + if (ircd->chansqline) { + if (!c) + is_sqlined = check_chan_sqline(av[1]); + } + if (is_sqlined && !is_oper(user)) { - send_cmd(s_OperServ, "KICK %s %s :Q-Lined", av[1], user->nick); + anope_cmd_kick(s_OperServ, av[1], user->nick, "Q-Lined"); } else { c = join_user_update(user, c, av[1]); c->creation_time = strtoul(av[0], NULL, 10); @@ -1109,7 +719,6 @@ void do_sjoin(const char *source, int ac, char **av) } } -#endif /*************************************************************************/ @@ -1119,34 +728,29 @@ void do_cmode(const char *source, int ac, char **av) { Channel *chan; ChannelInfo *ci = NULL; -#ifdef IRC_BAHAMUT - -/* Ultimate3 doesn't send TS on Mode - TSL */ -#if !defined(IRC_ULTIMATE3) int i; char *t; - /* TSMODE for bahamut - leave this code out to break MODEs. -GD */ - if (uplink_capab & CAPAB_TSMODE) { - for (i = 0; i < strlen(av[1]); i++) { - if (!isdigit(av[1][i])) - break; - } - if (av[1][i] == '\0') { - /* We have a valid TS field in av[1] now, so we can strip it off */ - /* After we swap av[0] and av[1] ofcourse to not break stuff! :) */ - t = av[0]; - av[0] = av[1]; - av[1] = t; - ac--; - av++; - } else { - alog("TSMODE enabled but MODE has no valid TS"); + if (ircdcap->tsmode) { + /* TSMODE for bahamut - leave this code out to break MODEs. -GD */ + if (uplink_capab & ircdcap->tsmode) { + for (i = 0; i < strlen(av[1]); i++) { + if (!isdigit(av[1][i])) + break; + } + if (av[1][i] == '\0') { + /* We have a valid TS field in av[1] now, so we can strip it off */ + /* After we swap av[0] and av[1] ofcourse to not break stuff! :) */ + t = av[0]; + av[0] = av[1]; + av[1] = t; + ac--; + av++; + } else { + alog("TSMODE enabled but MODE has no valid TS"); + } } } -#endif - -#endif chan = findchan(av[0]); if (!chan) { @@ -1206,7 +810,7 @@ void do_topic(const char *source, int ac, char **av) /**************************** Internal Calls *****************************/ /*************************************************************************/ -static void add_ban(Channel * chan, char *mask) +void add_ban(Channel * chan, char *mask) { if (s_BotServ && BSSmartJoin && chan->ci && chan->ci->bi && chan->usercount >= BSMinUsers) { @@ -1216,7 +820,7 @@ static void add_ban(Channel * chan, char *mask) snprintf(botmask, sizeof(botmask), "%s!%s@%s", bi->nick, bi->user, bi->host); if (match_wild_nocase(mask, botmask)) { - send_mode(bi->nick, chan->name, "-b %s", mask); + anope_cmd_mode(bi->nick, chan->name, "-b %s", mask); return; } } @@ -1233,9 +837,7 @@ static void add_ban(Channel * chan, char *mask) /*************************************************************************/ -#ifdef HAS_EXCEPT - -static void add_exception(Channel * chan, char *mask) +void add_exception(Channel * chan, char *mask) { if (chan->exceptcount >= chan->exceptsize) { chan->exceptsize += 8; @@ -1248,8 +850,6 @@ static void add_exception(Channel * chan, char *mask) alog("debug: Added except %s to channel %s", mask, chan->name); } -#endif - /*************************************************************************/ /* Add/remove a user to/from a channel, creating or deleting the channel as @@ -1258,32 +858,22 @@ static void add_exception(Channel * chan, char *mask) * Modified, so ignored users won't get any status via services -certus */ -static void chan_adduser2(User * user, Channel * c) +void chan_adduser2(User * user, Channel * c) { struct c_userlist *u; char *chan = c->name; if (get_ignore(user->nick) == NULL) { -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) - if (check_should_owner(user, chan)) { + if (ircd->owner && check_should_owner(user, chan)) { chan_set_user_status(c, user, CUS_OWNER | CUS_OP); - } else -#endif -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) || defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) || defined(IRC_PTLINK) - if (check_should_protect(user, chan)) { + } else if (ircd->protect && check_should_protect(user, chan)) { chan_set_user_status(c, user, CUS_PROTECT | CUS_OP); - } else -#endif - if (check_should_op(user, chan)) { + } else if (check_should_op(user, chan)) { chan_set_user_status(c, user, CUS_OP); - } else -#ifdef HAS_HALFOP - if (check_should_halfop(user, chan)) { + } else if (ircd->halfop && check_should_halfop(user, chan)) { chan_set_user_status(c, user, CUS_HALFOP); - } else -#endif - if (check_should_voice(user, chan)) { + } else if (check_should_voice(user, chan)) { chan_set_user_status(c, user, CUS_VOICE); } } @@ -1323,8 +913,8 @@ static void chan_adduser2(User * user, Channel * c) if (c->usercount >= BSMinUsers && (c->ci->botflags & BS_GREET) && user->na && user->na->nc->greet && check_access(user, c->ci, CA_GREET)) { - send_cmd(c->ci->bi->nick, "PRIVMSG %s :[%s] %s", c->name, - user->na->nick, user->na->nc->greet); + anope_cmd_privmsg(c->ci->bi->nick, c->name, "[%s] %s", + user->na->nick, user->na->nc->greet); c->ci->bi->lastmsg = time(NULL); } } @@ -1336,7 +926,7 @@ static void chan_adduser2(User * user, Channel * c) chan_adduser, but splitted to make it more efficient to use for SJOINs). */ -static Channel *chan_create(const char *chan) +Channel *chan_create(char *chan) { Channel *c; Channel **list; @@ -1370,7 +960,7 @@ static Channel *chan_create(const char *chan) /* This destroys the channel structure, freeing everything in it. */ -static void chan_delete(Channel * c) +void chan_delete(Channel * c) { BanData *bd, *next; int i; @@ -1393,14 +983,14 @@ static void chan_delete(Channel * c) if (c->key) free(c->key); -#ifdef HAS_FMODE - if (c->flood) - free(c->flood); -#endif -#ifdef HAS_LMODE - if (c->redirect) - free(c->redirect); -#endif + if (ircd->fmode) { + if (c->flood) + free(c->flood); + } + if (ircd->Lmode) { + if (c->redirect) + free(c->redirect); + } for (i = 0; i < c->bancount; ++i) { if (c->bans[i]) @@ -1411,17 +1001,17 @@ static void chan_delete(Channel * c) if (c->bansize) free(c->bans); -#ifdef HAS_EXCEPT - for (i = 0; i < c->exceptcount; ++i) { - if (c->excepts[i]) - free(c->excepts[i]); - else - alog("channel: BUG freeing %s: exceps[%d] is NULL!", c->name, - i); + if (ircd->except) { + for (i = 0; i < c->exceptcount; ++i) { + if (c->excepts[i]) + free(c->excepts[i]); + else + alog("channel: BUG freeing %s: exceps[%d] is NULL!", + c->name, i); + } + if (c->exceptsize) + free(c->excepts); } - if (c->exceptsize) - free(c->excepts); -#endif if (c->next) c->next->prev = c->prev; @@ -1435,7 +1025,7 @@ static void chan_delete(Channel * c) /*************************************************************************/ -static void del_ban(Channel * chan, char *mask) +void del_ban(Channel * chan, char *mask) { char **s = chan->bans; int i = 0; @@ -1462,9 +1052,7 @@ static void del_ban(Channel * chan, char *mask) /*************************************************************************/ -#ifdef HAS_EXCEPT - -static void del_exception(Channel * chan, char *mask) +void del_exception(Channel * chan, char *mask) { int i; int reset = 0; @@ -1486,29 +1074,23 @@ static void del_exception(Channel * chan, char *mask) alog("debug: Deleted except %s to channel %s", mask, chan->name); } -#endif - /*************************************************************************/ -#ifdef HAS_FMODE - -static char *get_flood(Channel * chan) +char *get_flood(Channel * chan) { return chan->flood; } -#endif - /*************************************************************************/ -static char *get_key(Channel * chan) +char *get_key(Channel * chan) { return chan->key; } /*************************************************************************/ -static char *get_limit(Channel * chan) +char *get_limit(Channel * chan) { static char limit[16]; @@ -1521,18 +1103,14 @@ static char *get_limit(Channel * chan) /*************************************************************************/ -#ifdef HAS_LMODE - -static char *get_redirect(Channel * chan) +char *get_redirect(Channel * chan) { return chan->redirect; } -#endif - /*************************************************************************/ -static Channel *join_user_update(User * user, Channel * chan, char *name) +Channel *join_user_update(User * user, Channel * chan, char *name) { struct u_chanlist *c; @@ -1557,9 +1135,7 @@ static Channel *join_user_update(User * user, Channel * chan, char *name) /*************************************************************************/ -#ifdef HAS_FMODE - -static void set_flood(Channel * chan, char *value) +void set_flood(Channel * chan, char *value) { if (chan->flood) free(chan->flood); @@ -1570,11 +1146,9 @@ static void set_flood(Channel * chan, char *value) chan->flood ? chan->flood : "no flood settings"); } -#endif - /*************************************************************************/ -static void set_key(Channel * chan, char *value) +void set_key(Channel * chan, char *value) { if (chan->key) free(chan->key); @@ -1587,7 +1161,7 @@ static void set_key(Channel * chan, char *value) /*************************************************************************/ -static void set_limit(Channel * chan, char *value) +void set_limit(Channel * chan, char *value) { chan->limit = value ? strtoul(value, NULL, 10) : 0; @@ -1598,9 +1172,7 @@ static void set_limit(Channel * chan, char *value) /*************************************************************************/ -#ifdef HAS_LMODE - -static void set_redirect(Channel * chan, char *value) +void set_redirect(Channel * chan, char *value) { if (chan->redirect) free(chan->redirect); @@ -1611,8 +1183,6 @@ static void set_redirect(Channel * chan, char *value) chan->redirect ? chan->redirect : "no redirect"); } -#endif - void do_mass_mode(char *modes) { int ac, i; @@ -1633,7 +1203,7 @@ void do_mass_mode(char *modes) if (c->bouncy_modes) { return; } else { - send_mode(s_OperServ, c->name, "%s", modes); + anope_cmd_mode(s_OperServ, c->name, "%s", modes); chan_set_modes(s_OperServ, c, ac, av, 1); } } diff --git a/src/chanserv.c b/src/chanserv.c index 06236c547..63f9bfeca 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -67,100 +67,57 @@ typedef struct { char *name; int desc; } LevelInfo; + static LevelInfo levelinfo[] = { - { CA_AUTODEOP, "AUTODEOP", CHAN_LEVEL_AUTODEOP }, -#ifdef HAS_HALFOP + { CA_AUTODEOP, "AUTODEOP", CHAN_LEVEL_AUTODEOP }, { CA_AUTOHALFOP, "AUTOHALFOP", CHAN_LEVEL_AUTOHALFOP }, -#endif - { CA_AUTOOP, "AUTOOP", CHAN_LEVEL_AUTOOP }, -#ifdef IRC_UNREAL - { CA_AUTOPROTECT, "AUTOPROTECT", CHAN_LEVEL_AUTOPROTECT }, -#endif -#ifdef IRC_VIAGRA - { CA_AUTOPROTECT, "AUTOPROTECT", CHAN_LEVEL_AUTOPROTECT }, -#endif -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - { CA_AUTOPROTECT, "AUTOADMIN", CHAN_LEVEL_AUTOPROTECT }, -#endif - { CA_AUTOVOICE, "AUTOVOICE", CHAN_LEVEL_AUTOVOICE }, - { CA_NOJOIN, "NOJOIN", CHAN_LEVEL_NOJOIN }, - { CA_SIGNKICK, "SIGNKICK", CHAN_LEVEL_SIGNKICK }, - - { CA_ACCESS_LIST, "ACC-LIST", CHAN_LEVEL_ACCESS_LIST }, - { CA_ACCESS_CHANGE, "ACC-CHANGE", CHAN_LEVEL_ACCESS_CHANGE }, - { CA_AKICK, "AKICK", CHAN_LEVEL_AKICK }, - { CA_SET, "SET", CHAN_LEVEL_SET }, - - { CA_BAN, "BAN", CHAN_LEVEL_BAN }, + { CA_AUTOOP, "AUTOOP", CHAN_LEVEL_AUTOOP }, + { CA_AUTOPROTECT, LEVEL_PROTECT_WORD, CHAN_LEVEL_AUTOPROTECT }, + { CA_AUTOVOICE, "AUTOVOICE", CHAN_LEVEL_AUTOVOICE }, + { CA_NOJOIN, "NOJOIN", CHAN_LEVEL_NOJOIN }, + { CA_SIGNKICK, "SIGNKICK", CHAN_LEVEL_SIGNKICK }, + { CA_ACCESS_LIST, "ACC-LIST", CHAN_LEVEL_ACCESS_LIST }, + { CA_ACCESS_CHANGE, "ACC-CHANGE", CHAN_LEVEL_ACCESS_CHANGE }, + { CA_AKICK, "AKICK", CHAN_LEVEL_AKICK }, + { CA_SET, "SET", CHAN_LEVEL_SET }, + { CA_BAN, "BAN", CHAN_LEVEL_BAN }, { CA_BANME, "BANME", CHAN_LEVEL_BANME }, - { CA_CLEAR, "CLEAR", CHAN_LEVEL_CLEAR }, - { CA_GETKEY, "GETKEY", CHAN_LEVEL_GETKEY }, -#ifdef HAS_HALFOP + { CA_CLEAR, "CLEAR", CHAN_LEVEL_CLEAR }, + { CA_GETKEY, "GETKEY", CHAN_LEVEL_GETKEY }, { CA_HALFOP, "HALFOP", CHAN_LEVEL_HALFOP }, - { CA_HALFOPME, "HALFOPME", CHAN_LEVEL_HALFOPME }, -#endif - { CA_INFO, "INFO", CHAN_LEVEL_INFO }, + { CA_HALFOPME, "HALFOPME", CHAN_LEVEL_HALFOPME }, + { CA_INFO, "INFO", CHAN_LEVEL_INFO }, { CA_KICK, "KICK", CHAN_LEVEL_KICK }, { CA_KICKME, "KICKME", CHAN_LEVEL_KICKME }, - { CA_INVITE, "INVITE", CHAN_LEVEL_INVITE }, - { CA_OPDEOP, "OPDEOP", CHAN_LEVEL_OPDEOP }, - { CA_OPDEOPME, "OPDEOPME", CHAN_LEVEL_OPDEOPME }, -#ifdef IRC_UNREAL - { CA_PROTECT, "PROTECT", CHAN_LEVEL_PROTECT }, - { CA_PROTECTME, "PROTECTME", CHAN_LEVEL_PROTECTME }, -#endif -#ifdef IRC_VIAGRA - { CA_PROTECT, "PROTECT", CHAN_LEVEL_PROTECT }, - { CA_PROTECTME, "PROTECTME", CHAN_LEVEL_PROTECTME }, -#endif -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - { CA_PROTECT, "ADMIN", CHAN_LEVEL_PROTECT }, - { CA_PROTECTME, "ADMINME", CHAN_LEVEL_PROTECTME }, -#endif - { CA_TOPIC, "TOPIC", CHAN_LEVEL_TOPIC }, - { CA_UNBAN, "UNBAN", CHAN_LEVEL_UNBAN }, - { CA_VOICE, "VOICE", CHAN_LEVEL_VOICE }, - { CA_VOICEME, "VOICEME", CHAN_LEVEL_VOICEME }, - - { CA_MEMO, "MEMO", CHAN_LEVEL_MEMO }, - - { CA_ASSIGN, "ASSIGN", CHAN_LEVEL_ASSIGN }, - { CA_BADWORDS, "BADWORDS", CHAN_LEVEL_BADWORDS }, - { CA_FANTASIA, "FANTASIA", CHAN_LEVEL_FANTASIA }, - { CA_GREET, "GREET", CHAN_LEVEL_GREET }, - { CA_NOKICK, "NOKICK", CHAN_LEVEL_NOKICK }, - { CA_SAY, "SAY", CHAN_LEVEL_SAY }, - - { -1 } + { CA_INVITE, "INVITE", CHAN_LEVEL_INVITE }, + { CA_OPDEOP, "OPDEOP", CHAN_LEVEL_OPDEOP }, + { CA_OPDEOPME, "OPDEOPME", CHAN_LEVEL_OPDEOPME }, + { CA_PROTECT, LEVELINFO_PROTECT_WORD, CHAN_LEVEL_PROTECT }, + { CA_PROTECTME, LEVELINFO_PROTECTME_WORD, CHAN_LEVEL_PROTECTME }, + { CA_TOPIC, "TOPIC", CHAN_LEVEL_TOPIC }, + { CA_UNBAN, "UNBAN", CHAN_LEVEL_UNBAN }, + { CA_VOICE, "VOICE", CHAN_LEVEL_VOICE }, + { CA_VOICEME, "VOICEME", CHAN_LEVEL_VOICEME }, + { CA_MEMO, "MEMO", CHAN_LEVEL_MEMO }, + { CA_ASSIGN, "ASSIGN", CHAN_LEVEL_ASSIGN }, + { CA_BADWORDS, "BADWORDS", CHAN_LEVEL_BADWORDS }, + { CA_FANTASIA, "FANTASIA", CHAN_LEVEL_FANTASIA }, + { CA_GREET, "GREET", CHAN_LEVEL_GREET }, + { CA_NOKICK, "NOKICK", CHAN_LEVEL_NOKICK }, + { CA_SAY, "SAY", CHAN_LEVEL_SAY }, + { -1 } }; static int levelinfo_maxwidth = 0; CSModeUtil csmodeutils[] = { - { "DEOP", "!deop", "-o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, - { "OP", "!op", "+o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, + { "DEOP", "!deop", "-o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, + { "OP", "!op", "+o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, { "DEVOICE", "!devoice", "-v", 0 , CA_VOICE, CA_VOICEME }, - { "VOICE", "!voice", "+v", 0 , CA_VOICE, CA_VOICEME }, -#ifdef HAS_HALFOP - { "DEHALFOP", "!dehalfop", "-h", 0 , CA_HALFOP, CA_HALFOPME }, - { "HALFOP", "!halfop", "+h", 0 , CA_HALFOP, CA_HALFOPME }, -#endif -#ifdef IRC_UNREAL - { "DEPROTECT", "!deprotect", "-a", 0 , CA_PROTECT, CA_PROTECTME }, - { "PROTECT", "!protect", "+a", 0 , CA_PROTECT, CA_PROTECTME }, -#endif -#ifdef IRC_VIAGRA - { "DEPROTECT", "!deprotect", "-a", 0 , CA_PROTECT, CA_PROTECTME }, - { "PROTECT", "!protect", "+a", 0 , CA_PROTECT, CA_PROTECTME }, -#endif -#ifdef IRC_PTLINK - { "DEPROTECT", "!deprotect", "-a", 0 , CA_PROTECT, CA_PROTECTME }, - { "PROTECT", "!protect", "+a", 0 , CA_PROTECT, CA_PROTECTME }, -#endif -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - { "DEPROTECT", "!deadmin", "-a", 0 , CA_PROTECT, CA_PROTECTME }, - { "PROTECT", "!admin", "+a", 0 , CA_PROTECT, CA_PROTECTME }, -#endif - + { "VOICE", "!voice", "+v", 0 , CA_VOICE, CA_VOICEME }, + { "DEHALFOP", "!dehalfop", "-h", 0 , CA_HALFOP, CA_HALFOPME }, + { "HALFOP", "!halfop", "+h", 0 , CA_HALFOP, CA_HALFOPME }, + { "DEPROTECT", FANT_PROTECT_DEL, PROTECT_UNSET_MODE, 0 , CA_PROTECT, CA_PROTECTME }, + { "PROTECT", FANT_PROTECT_ADD, PROTECT_SET_MODE, 0 , CA_PROTECT, CA_PROTECTME }, { NULL } }; @@ -267,9 +224,7 @@ 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); -#ifdef HAS_HALFOP static int do_hop(User * u); -#endif static int do_sop(User * u); static int do_vop(User * u); static int do_access(User * u); @@ -283,26 +238,12 @@ static int do_op(User * u); static int do_deop(User * u); static int do_voice(User * u); static int do_devoice(User * u); -#ifdef HAS_HALFOP static int do_halfop(User * u); static int do_dehalfop(User * u); -#endif -#ifdef IRC_UNREAL -static int do_protect(User * u); -static int do_deprotect(User * u); -static int do_owner(User * u); -static int do_deowner(User * u); -#endif -#ifdef IRC_VIAGRA static int do_protect(User * u); static int do_deprotect(User * u); static int do_owner(User * u); static int do_deowner(User * u); -#endif -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) || defined(IRC_PTLINK) -static int do_protect(User * u); -static int do_deprotect(User * u); -#endif static int do_cs_kick(User * u); static int do_ban(User * u); static int do_cs_topic(User * u); @@ -348,9 +289,7 @@ void moduleAddChanServCmds(void) { 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,CHAN_SERVADMIN_HELP_SET_NOEXPIRE,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); -#ifdef HAS_HALFOP c = createCommand("HOP", do_hop, NULL, CHAN_HELP_HOP, -1,-1,-1,-1); addCoreCommand(CHANSERV,c); -#endif 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); @@ -363,30 +302,14 @@ void moduleAddChanServCmds(void) { 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); -#ifdef HAS_HALFOP 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); -#endif -#ifdef IRC_UNREAL - 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); -#endif -#ifdef IRC_VIAGRA 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); -#endif -#ifdef IRC_PTLINK - 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); -#endif -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) 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); -#endif 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); @@ -606,14 +529,14 @@ void get_chanserv_stats(long *nrec, long *memuse) } if (ci->mlock_key) mem += strlen(ci->mlock_key) + 1; -#ifdef HAS_FMODE - if (ci->mlock_flood) - mem += strlen(ci->mlock_flood) + 1; -#endif -#ifdef HAS_LMODE - if (ci->mlock_redirect) - mem += strlen(ci->mlock_redirect) + 1; -#endif + if (ircd->fmode) { + if (ci->mlock_flood) + mem += strlen(ci->mlock_flood) + 1; + } + if (ircd->Lmode) { + if (ci->mlock_redirect) + mem += strlen(ci->mlock_redirect) + 1; + } if (ci->last_topic) mem += strlen(ci->last_topic) + 1; if (ci->entry_message) @@ -960,20 +883,20 @@ void load_cs_dbase(void) SAFE(read_int32(&ci->mlock_limit, f)); SAFE(read_string(&ci->mlock_key, f)); if (ver >= 10) { -#ifdef HAS_FMODE - SAFE(read_string(&ci->mlock_flood, f)); -#else - SAFE(read_string(&s, f)); - if (s) - free(s); -#endif -#ifdef HAS_LMODE - SAFE(read_string(&ci->mlock_redirect, f)); -#else - SAFE(read_string(&s, f)); - if (s) - free(s); -#endif + if (ircd->fmode) { + SAFE(read_string(&ci->mlock_flood, f)); + } else { + SAFE(read_string(&s, f)); + if (s) + free(s); + } + if (ircd->Lmode) { + SAFE(read_string(&ci->mlock_redirect, f)); + } else { + SAFE(read_string(&s, f)); + if (s) + free(s); + } } SAFE(read_int16(&ci->memos.memocount, f)); @@ -1144,7 +1067,7 @@ void load_cs_dbase(void) restore_db(f); \ log_perror("Write error on %s", ChanDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - wallops(NULL, "Write error on %s: %s", ChanDBName, \ + anope_cmd_global(NULL, "Write error on %s: %s", ChanDBName, \ strerror(errno)); \ lastwarn = time(NULL); \ } \ @@ -1224,17 +1147,16 @@ void save_cs_dbase(void) SAFE(write_int32(ci->mlock_off, f)); SAFE(write_int32(ci->mlock_limit, f)); SAFE(write_string(ci->mlock_key, f)); -#ifdef HAS_FMODE - SAFE(write_string(ci->mlock_flood, f)); -#else - SAFE(write_string(NULL, f)); -#endif -#ifdef HAS_LMODE - SAFE(write_string(ci->mlock_redirect, f)); -#else - SAFE(write_string(NULL, f)); -#endif - + if (ircd->fmode) { + SAFE(write_string(ci->mlock_flood, f)); + } else { + SAFE(write_string(NULL, f)); + } + if (ircd->Lmode) { + SAFE(write_string(ci->mlock_redirect, f)); + } else { + SAFE(write_string(NULL, f)); + } SAFE(write_int16(ci->memos.memocount, f)); SAFE(write_int16(ci->memos.memomax, f)); memos = ci->memos.memos; @@ -1333,9 +1255,10 @@ void check_modes(Channel * c) /* Check for mode bouncing */ if (c->server_modecount >= 3 && c->chanserv_modecount >= 3) { - wallops(NULL, "Warning: unable to set modes on channel %s. " - "Are your servers' U:lines configured correctly?", - c->name); + anope_cmd_global(NULL, + "Warning: unable to set modes on channel %s. " + "Are your servers' U:lines configured correctly?", + c->name); alog("%s: Bouncy modes on channel %s", s_ChanServ, c->name); c->bouncy_modes = 1; return; @@ -1348,12 +1271,12 @@ void check_modes(Channel * c) c->chanserv_modecount++; if (!(ci = c->ci)) { -#ifndef IRC_HYBRID - if (c->mode & CMODE_r) { - c->mode &= ~CMODE_r; - send_mode(whosends(ci), c->name, "-r"); + if (ircd->regmode) { + if (c->mode & ircd->regmode) { + c->mode &= ~ircd->regmode; + anope_cmd_mode(whosends(ci), c->name, "-r"); + } } -#endif return; } @@ -1440,37 +1363,40 @@ void check_modes(Channel * c) *end = 0; *end2 = 0; - send_mode(whosends(ci), c->name, "%s%s", modebuf, - (end2 == argbuf ? "" : argbuf)); + anope_cmd_mode(whosends(ci), c->name, "%s%s", modebuf, + (end2 == argbuf ? "" : argbuf)); } /*************************************************************************/ -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - int check_valid_admin(User * user, Channel * chan, int servermode) { if (!chan->ci) return 1; + if (!ircd->admin) { + return 0; + } + /* They will be kicked; no need to deop, no need to update our internal struct too */ if (chan->ci->flags & CI_VERBOTEN) return 0; if (servermode && !check_access(user, chan->ci, CA_AUTOPROTECT)) { notice_lang(s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ); - send_mode(whosends(chan->ci), chan->name, "-a %s", user->nick); + anope_cmd_mode(whosends(chan->ci), chan->name, "-a %s", + user->nick); return 0; } if (check_access(user, chan->ci, CA_AUTODEOP)) { - send_mode(whosends(chan->ci), chan->name, "-a %s", user->nick); + anope_cmd_mode(whosends(chan->ci), chan->name, "-a %s", + user->nick); return 0; } return 1; } -#endif /*************************************************************************/ @@ -1489,49 +1415,56 @@ int check_valid_op(User * user, Channel * chan, int servermode) if (servermode && !check_access(user, chan->ci, CA_AUTOOP)) { notice_lang(s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ); -#ifdef HAS_HALFOP -# if defined(IRC_UNREAL) - if (check_access(user, chan->ci, CA_AUTOHALFOP)) { - send_mode(whosends(chan->ci), chan->name, "-aoq %s %s %s", - user->nick, user->nick, user->nick); - } else { - send_mode(whosends(chan->ci), chan->name, "-ahoq %s %s %s %s", - user->nick, user->nick, user->nick, user->nick); - } -# elif defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - if (check_access(user, chan->ci, CA_AUTOHALFOP)) { - send_mode(whosends(chan->ci), chan->name, "-ao %s %s", - user->nick, user->nick); - } else { - send_mode(whosends(chan->ci), chan->name, "-aoh %s %s %s", - user->nick, user->nick, user->nick); - } -# else - if (check_access(user, chan->ci, CA_AUTOHALFOP)) { - send_mode(whosends(chan->ci), chan->name, "-o %s", user->nick); + if (ircd->halfop) { + if (ircd->owner && ircd->protect) { + if (check_access(user, chan->ci, CA_AUTOHALFOP)) { + anope_cmd_mode(whosends(chan->ci), chan->name, + "-aoq %s %s %s", user->nick, user->nick, + user->nick); + } else { + anope_cmd_mode(whosends(chan->ci), chan->name, + "-ahoq %s %s %s %s", user->nick, + user->nick, user->nick, user->nick); + } + } else if (!ircd->owner && ircd->protect) { + if (check_access(user, chan->ci, CA_AUTOHALFOP)) { + anope_cmd_mode(whosends(chan->ci), chan->name, + "-ao %s %s", user->nick, user->nick); + } else { + anope_cmd_mode(whosends(chan->ci), chan->name, + "-aoh %s %s %s", user->nick, user->nick, + user->nick); + } + } else { + if (check_access(user, chan->ci, CA_AUTOHALFOP)) { + anope_cmd_mode(whosends(chan->ci), chan->name, "-o %s", + user->nick); + } else { + anope_cmd_mode(whosends(chan->ci), chan->name, + "-ho %s %s", user->nick, user->nick); + } + } } else { - send_mode(whosends(chan->ci), chan->name, "-ho %s %s", - user->nick, user->nick); + anope_cmd_mode(whosends(chan->ci), chan->name, "-o %s", + user->nick); } -# endif -#else - send_mode(whosends(chan->ci), chan->name, "-o %s", user->nick); -#endif return 0; } if (check_access(user, chan->ci, CA_AUTODEOP)) { -#ifdef HAS_HALFOP -# ifdef IRC_UNREAL - send_mode(whosends(chan->ci), chan->name, "-ahoq %s %s %s %s", - user->nick, user->nick, user->nick, user->nick); -# else - send_mode(whosends(chan->ci), chan->name, "-ho %s %s", user->nick, - user->nick); -# endif -#else - send_mode(whosends(chan->ci), chan->name, "-o %s", user->nick); -#endif + if (ircd->halfop) { + if (ircd->owner && ircd->protect) { + anope_cmd_mode(whosends(chan->ci), chan->name, + "-ahoq %s %s %s %s", user->nick, user->nick, + user->nick, user->nick); + } else { + anope_cmd_mode(whosends(chan->ci), chan->name, "-ho %s %s", + user->nick, user->nick); + } + } else { + anope_cmd_mode(whosends(chan->ci), chan->name, "-o %s", + user->nick); + } return 0; } @@ -1544,7 +1477,7 @@ int check_valid_op(User * user, Channel * chan, int servermode) * Return 1 if the user was opped, 0 otherwise. (Updates the channel's * last used time if the user was opped.) */ -int check_should_op(User * user, const char *chan) +int check_should_op(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); @@ -1555,7 +1488,7 @@ int check_should_op(User * user, const char *chan) return 0; if (check_access(user, ci, CA_AUTOOP)) { - send_mode(whosends(ci), chan, "+o %s", user->nick); + anope_cmd_mode(whosends(ci), chan, "+o %s", user->nick); return 1; } @@ -1567,7 +1500,7 @@ int check_should_op(User * user, const char *chan) /* Check whether a user should be voiced on a channel, and if so, do it. * Return 1 if the user was voiced, 0 otherwise. */ -int check_should_voice(User * user, const char *chan) +int check_should_voice(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); @@ -1578,7 +1511,7 @@ int check_should_voice(User * user, const char *chan) return 0; if (check_access(user, ci, CA_AUTOVOICE)) { - send_mode(whosends(ci), chan, "+v %s", user->nick); + anope_cmd_mode(whosends(ci), chan, "+v %s", user->nick); return 1; } @@ -1587,9 +1520,7 @@ int check_should_voice(User * user, const char *chan) /*************************************************************************/ -#ifdef HAS_HALFOP - -int check_should_halfop(User * user, const char *chan) +int check_should_halfop(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); @@ -1597,20 +1528,16 @@ int check_should_halfop(User * user, const char *chan) return 0; if (check_access(user, ci, CA_AUTOHALFOP)) { - send_mode(whosends(ci), chan, "+h %s", user->nick); + anope_cmd_mode(whosends(ci), chan, "+h %s", user->nick); return 1; } return 0; } -#endif - /*************************************************************************/ -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) - -int check_should_owner(User * user, const char *chan) +int check_should_owner(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); @@ -1619,20 +1546,17 @@ int check_should_owner(User * user, const char *chan) if (((ci->flags & CI_SECUREFOUNDER) && is_real_founder(user, ci)) || (!(ci->flags & CI_SECUREFOUNDER) && is_founder(user, ci))) { - send_mode(whosends(ci), chan, "+oq %s %s", user->nick, user->nick); + anope_cmd_mode(whosends(ci), chan, "+oq %s %s", user->nick, + user->nick); return 1; } return 0; } -#endif - /*************************************************************************/ -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) || defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) || defined(IRC_PTLINK) - -int check_should_protect(User * user, const char *chan) +int check_should_protect(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); @@ -1640,15 +1564,14 @@ int check_should_protect(User * user, const char *chan) return 0; if (check_access(user, ci, CA_AUTOPROTECT)) { - send_mode(whosends(ci), chan, "+oa %s %s", user->nick, user->nick); + anope_cmd_mode(whosends(ci), chan, "+oa %s %s", user->nick, + user->nick); return 1; } return 0; } -#endif - /*************************************************************************/ /* Tiny helper routine to get ChanServ out of a channel after it went in. */ @@ -1661,7 +1584,7 @@ static void timeout_leave(Timeout * to) if (ci) /* Check cos the channel may be dropped in the meantime */ ci->flags &= ~CI_INHABIT; - send_cmd(s_ChanServ, "PART %s", chan); + anope_cmd_part(s_ChanServ, chan, NULL); free(to->data); } @@ -1712,7 +1635,6 @@ int check_kick(User * user, char *chan) else nc = NULL; -#ifdef HAS_EXCEPT /* * Before we go through akick lists, see if they're excepted FIRST * We cannot kick excempted users that are akicked or not on the channel access list @@ -1720,10 +1642,9 @@ int check_kick(User * user, char *chan) * * UltimateIRCd 3.x at least informs channel staff when a joining user is matching an exempt. */ - if (is_excepted(ci, user) == 1) { + if (ircd->except && is_excepted(ci, user) == 1) { return 0; } -#endif for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED)) @@ -1755,7 +1676,7 @@ int check_kick(User * user, char *chan) kick: if (debug) alog("debug: channel: AutoKicking %s!%s@%s from %s", user->nick, - user->username, GetHost(user), chan); + user->username, common_get_vhost(user), chan); /* Remember that the user has not been added to our channel user list * yet, so we check whether the channel does not exist OR has no user @@ -1765,15 +1686,8 @@ int check_kick(User * user, char *chan) * c may be NULL even if it exists */ if ((!(c = findchan(chan)) || c->usercount == 0) && !(ci->flags & CI_INHABIT)) { -#if defined(IRC_BAHAMUT) - send_cmd(s_ChanServ, "SJOIN %lu %s", - (c ? c->creation_time : time(NULL)), chan); -#elif defined(IRC_HYBRID) - send_cmd(NULL, "SJOIN %ld %s + :@%s", - time(NULL), chan, s_ChanServ); -#else - send_cmd(s_ChanServ, "JOIN %s", chan); -#endif + anope_cmd_join(s_ChanServ, chan, + (c ? c->creation_time : time(NULL))); t = add_timeout(CSInhabit, timeout_leave, 0); t->data = sstrdup(chan); ci->flags |= CI_INHABIT; @@ -1787,8 +1701,8 @@ int check_kick(User * user, char *chan) free(av[1]); } - send_mode(whosends(ci), chan, "+b %s %lu", mask, time(NULL)); - send_cmd(whosends(ci), "KICK %s %s :%s", chan, user->nick, reason); + anope_cmd_mode(whosends(ci), chan, "+b %s %lu", mask, time(NULL)); + anope_cmd_kick(whosends(ci), chan, user->nick, "%s", reason); return 1; } @@ -1821,7 +1735,7 @@ void record_topic(const char *chan) /* Restore the topic in a channel when it's created, if we should. */ -void restore_topic(const char *chan) +void restore_topic(char *chan) { Channel *c = findchan(chan); ChannelInfo *ci; @@ -1838,19 +1752,19 @@ void restore_topic(const char *chan) c->topic = NULL; strscpy(c->topic_setter, s_ChanServ, NICKMAX); } -#ifdef IRC_HYBRID - if (whosends(ci) == s_ChanServ) { - send_cmd(NULL, "SJOIN %ld %s + :%s", time(NULL), chan, s_ChanServ); - send_mode(NULL, chan, "+o %s", s_ChanServ); + if (ircd->join2set) { + if (whosends(ci) == s_ChanServ) { + anope_cmd_join(s_ChanServ, chan, time(NULL)); + anope_cmd_mode(NULL, chan, "+o %s", s_ChanServ); + } } - send_cmd(whosends(ci), "TOPIC %s :%s", chan, c->topic ? c->topic : ""); - if (whosends(ci) == s_ChanServ) { - send_cmd(s_ChanServ, "PART %s", chan); + anope_cmd_topic(whosends(ci), c->name, c->topic_setter, + c->topic ? c->topic : "", c->topic_time); + if (ircd->join2set) { + if (whosends(ci) == s_ChanServ) { + anope_cmd_part(s_ChanServ, c->name, NULL); + } } -#else - send_cmd(whosends(ci), "TOPIC %s %s %lu :%s", c->name, c->topic_setter, - c->topic_time, c->topic ? c->topic : ""); -#endif } /*************************************************************************/ @@ -1873,28 +1787,28 @@ int check_topiclock(Channel * c, time_t topic_time) c->topic = NULL; strscpy(c->topic_setter, ci->last_topic_setter, NICKMAX); -#ifdef IRC_UNREAL - /* Because older timestamps are rejected */ - c->topic_time = topic_time + 1; -#else - c->topic_time = ci->last_topic_time; -#endif + if (ircd->topictsforward) { + /* Because older timestamps are rejected */ + c->topic_time = topic_time + 1; + } else { + c->topic_time = ci->last_topic_time; + } -#ifdef IRC_HYBRID - if (whosends(ci) == s_ChanServ) { - send_cmd(NULL, "SJOIN %ld %s + :%s", time(NULL), c->name, - s_ChanServ); - send_mode(NULL, c->name, "+o %s", s_ChanServ); + 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); + } } - send_cmd(whosends(ci), "TOPIC %s :%s", c->name, - c->topic ? c->topic : ""); - if (whosends(ci) == s_ChanServ) { - send_cmd(s_ChanServ, "PART %s", c->name); + + anope_cmd_topic(whosends(ci), c->name, c->topic_setter, + c->topic ? c->topic : "", c->topic_time); + + if (ircd->join2set) { + if (whosends(ci) == s_ChanServ) { + anope_cmd_part(s_ChanServ, c->ci->name, NULL); + } } -#else - send_cmd(whosends(ci), "TOPIC %s %s %lu :%s", c->name, c->topic_setter, - c->topic_time, c->topic ? c->topic : ""); -#endif return 1; } @@ -1960,13 +1874,13 @@ void cs_remove_nick(const NickCore * nc) } } else { alog("%s: Deleting channel %s owned by deleted nick %s", s_ChanServ, ci->name, nc->display); -#ifndef IRC_HYBRID - /* Maybe move this to delchan() ? */ - if ((ci->c) && (ci->c->mode & CMODE_r)) { - ci->c->mode &= ~CMODE_r; - send_mode(whosends(ci), ci->name, "-r"); + if (ircd->regmode) { + /* Maybe move this to delchan() ? */ + if ((ci->c) && (ci->c->mode & ircd->regmode)) { + ci->c->mode &= ~ircd->regmode; + anope_cmd_mode(whosends(ci), ci->name, "-r"); + } } -#endif delchan(ci); continue; @@ -2131,7 +2045,7 @@ int delchan(ChannelInfo * ci) } if (ci->c) { if (ci->bi && ci->c->usercount >= BSMinUsers) { - send_cmd(ci->bi->nick, "PART %s", ci->c->name); + anope_cmd_part(ci->bi->nick, ci->c->name, NULL); } ci->c->ci = NULL; } @@ -2151,14 +2065,14 @@ int delchan(ChannelInfo * ci) free(ci->desc); if (ci->mlock_key) free(ci->mlock_key); -#ifdef HAS_FMODE - if (ci->mlock_flood) - free(ci->mlock_flood); -#endif -#ifdef HAS_LMODE - if (ci->mlock_redirect) - free(ci->mlock_redirect); -#endif + if (ircd->fmode) { + if (ci->mlock_flood) + free(ci->mlock_flood); + } + if (ircd->Lmode) { + if (ci->mlock_redirect) + free(ci->mlock_redirect); + } if (ci->last_topic) free(ci->last_topic); if (ci->forbidby) @@ -2343,18 +2257,20 @@ int get_idealban(ChannelInfo * ci, User * u, char *ret, int retlen) switch (ci->bantype) { case 0: - snprintf(ret, retlen, "*!%s@%s", GetIdent(u), GetHost(u)); + snprintf(ret, retlen, "*!%s@%s", common_get_vident(u), + common_get_vhost(u)); return 1; case 1: snprintf(ret, retlen, "*!%s%s@%s", - (strlen(GetIdent(u)) < - (*(GetIdent(u)) == + (strlen(common_get_vident(u)) < + (*(common_get_vident(u)) == '~' ? USERMAX + 1 : USERMAX) ? "*" : ""), - (*(GetIdent(u)) == '~' ? GetIdent(u) + 1 : GetIdent(u)), - GetHost(u)); + (*(common_get_vident(u)) == + '~' ? common_get_vident(u) + 1 : common_get_vident(u)), + common_get_vhost(u)); return 1; case 2: - snprintf(ret, retlen, "*!*@%s", GetHost(u)); + snprintf(ret, retlen, "*!*@%s", common_get_vhost(u)); return 1; case 3: mask = create_mask(u); @@ -2392,15 +2308,11 @@ static void make_unidentified(User * u, ChannelInfo * ci) /*************************************************************************/ -#ifdef HAS_FMODE - char *cs_get_flood(ChannelInfo * ci) { return ci->mlock_flood; } -#endif - /*************************************************************************/ char *cs_get_key(ChannelInfo * ci) @@ -2423,19 +2335,13 @@ char *cs_get_limit(ChannelInfo * ci) /*************************************************************************/ -#ifdef HAS_LMODE - char *cs_get_redirect(ChannelInfo * ci) { return ci->mlock_redirect; } -#endif - /*************************************************************************/ -#ifdef HAS_FMODE - void cs_set_flood(ChannelInfo * ci, char *value) { char *dp, *end; @@ -2450,13 +2356,11 @@ void cs_set_flood(ChannelInfo * ci, char *value) && (*end == 0)) { ci->mlock_flood = sstrdup(value); } else { - ci->mlock_on &= ~CMODE_f; + ci->mlock_on &= ~ircd->chan_fmode; ci->mlock_flood = NULL; } } -#endif - /*************************************************************************/ void cs_set_key(ChannelInfo * ci, char *value) @@ -2485,8 +2389,6 @@ void cs_set_limit(ChannelInfo * ci, char *value) /*************************************************************************/ -#ifdef HAS_LMODE - void cs_set_redirect(ChannelInfo * ci, char *value) { if (ci->mlock_redirect) @@ -2496,13 +2398,11 @@ void cs_set_redirect(ChannelInfo * ci, char *value) if (value && *value == '#') { ci->mlock_redirect = sstrdup(value); } else { - ci->mlock_on &= ~CMODE_L; + ci->mlock_on &= ~ircd->chan_lmode; ci->mlock_redirect = NULL; } } -#endif - int get_access_level(ChannelInfo * ci, NickAlias * na) { ChanAccess *access; @@ -2531,18 +2431,14 @@ int get_access_level(ChannelInfo * ci, NickAlias * na) char *get_xop_level(int level) { - if (level < ACCESS_VOP) { return "Err"; -#ifdef HAS_HALFOP - } else if (level < ACCESS_HOP) { + } else if (ircd->halfop && level < ACCESS_HOP) { return "VOP"; - } else if (level < ACCESS_AOP) { - return "HOP"; -#else - } else if (level < ACCESS_AOP) { + } else if (!ircd->halfop && level < ACCESS_AOP) { return "VOP"; -#endif + } else if (ircd->halfop && level < ACCESS_AOP) { + return "HOP"; } else if (level < ACCESS_SOP) { return "AOP"; } else if (level < ACCESS_FOUNDER) { @@ -2563,18 +2459,9 @@ static int do_help(User * u) if (!cmd) { notice_help(s_ChanServ, u, CHAN_HELP); -#ifdef IRC_UNREAL - notice_help(s_ChanServ, u, CHAN_HELP_UNREAL); -#endif -#ifdef IRC_VIAGRA - notice_help(s_ChanServ, u, CHAN_HELP_UNREAL); -#endif -#ifdef IRC_ULTIMATE - notice_help(s_ChanServ, u, CHAN_HELP_ULTIMATE); -#endif -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - notice_help(s_ChanServ, u, CHAN_HELP_ULTIMATE3); -#endif + if (ircd->extrahelp) { + notice_help(s_ChanServ, u, ircd->extrahelp); + } if (CSExpire >= 86400) notice_help(s_ChanServ, u, CHAN_HELP_EXPIRES, CSExpire / 86400); @@ -2639,7 +2526,7 @@ static int do_register(User * u) s_NickServ); } 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, GetHost(u)); + alog("%s: Attempt to register FORBIDden channel %s by %s!%s@%s", s_ChanServ, ci->name, u->nick, u->username, common_get_vhost(u)); notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); } else { notice_lang(s_ChanServ, u, CHAN_ALREADY_REGISTERED, chan); @@ -2676,11 +2563,7 @@ static int do_register(User * u) ci->c = c; ci->bantype = CSDefBantype; ci->flags = CSDefFlags; -#ifdef IRC_HYBRID - ci->mlock_on = CMODE_n | CMODE_t; -#else - ci->mlock_on = CMODE_n | CMODE_t | CMODE_r; -#endif + ci->mlock_on = ircd->defmlock; ci->memos.memomax = MSMaxMemos; ci->last_used = ci->time_registered; ci->founder = nc; @@ -2705,7 +2588,7 @@ static int do_register(User * u) ci->botflags = BSDefFlags; ci->founder->channelcount++; alog("%s: Channel '%s' registered by %s!%s@%s", s_ChanServ, chan, - u->nick, u->username, GetHost(u)); + u->nick, u->username, common_get_vhost(u)); notice_lang(s_ChanServ, u, CHAN_REGISTERED, chan, u->nick); #ifndef USE_ENCRYPTION notice_lang(s_ChanServ, u, CHAN_PASSWORD_IS, ci->founderpass); @@ -2719,9 +2602,9 @@ static int do_register(User * u) uc->chan = ci; /* Implement new mode lock */ check_modes(c); -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - send_mode(s_ChanServ, chan, "+a %s", u->nick); -#endif + if (ircd->admin) { + anope_cmd_mode(s_ChanServ, chan, "+a %s", u->nick); + } } return MOD_CONT; } @@ -2757,7 +2640,7 @@ static int do_identify(User * u) u->founder_chans = uc; uc->chan = ci; alog("%s: %s!%s@%s identified for %s", s_ChanServ, u->nick, - u->username, GetHost(u), ci->name); + u->username, common_get_vhost(u), ci->name); } notice_lang(s_ChanServ, u, CHAN_IDENTIFY_SUCCEEDED, chan); @@ -2766,7 +2649,8 @@ static int do_identify(User * u) 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, GetHost(u)); + s_ChanServ, ci->name, u->nick, u->username, + common_get_vhost(u)); notice_lang(s_ChanServ, u, PASSWORD_INCORRECT); bad_password(u); } @@ -2844,14 +2728,17 @@ static int do_drop(User * u) if (readonly) /* in this case we know they're a Services admin */ notice_lang(s_ChanServ, u, READ_ONLY_MODE); -#ifndef IRC_HYBRID + if (ci->c) { - ci->c->mode &= ~CMODE_r; - send_mode(whosends(ci), ci->name, "-r"); + if (ircd->regmode) { + ci->c->mode &= ~ircd->regmode; + anope_cmd_mode(whosends(ci), ci->name, "-r"); + } } -#endif + alog("%s: Channel %s dropped by %s!%s@%s (founder: %s)", - s_ChanServ, ci->name, u->nick, u->username, GetHost(u), + s_ChanServ, ci->name, u->nick, u->username, + common_get_vhost(u), (ci->founder ? ci->founder->display : "(none)")); delchan(ci); @@ -2860,8 +2747,9 @@ static int do_drop(User * u) * drop the channel before issuing the wallops. */ if (WallDrop && is_servadmin && level < ACCESS_FOUNDER) - wallops(s_ChanServ, "\2%s\2 used DROP on channel \2%s\2", - u->nick, chan); + 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); } @@ -3018,7 +2906,7 @@ static int do_set_founder(User * u, ChannelInfo * ci, char *param) 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, GetHost(u)); + u->username, common_get_vhost(u)); /* Founder and successor must not be the same group */ if (nc == ci->successor) @@ -3064,7 +2952,8 @@ static int do_set_successor(User * u, ChannelInfo * ci, char *param) 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, GetHost(u)); + (nc ? nc->display : "none"), u->nick, u->username, + common_get_vhost(u)); ci->successor = nc; @@ -3110,14 +2999,15 @@ static int do_set_password(User * u, ChannelInfo * ci, char *param) 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, GetHost(u), ci->name); + s_ChanServ, u->nick, u->username, common_get_vhost(u), + ci->name); if (WallSetpass) - wallops(s_ChanServ, - "\2%s\2 set password as Services admin for channel \2%s\2", - u->nick, ci->name); + 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, GetHost(u), + s_ChanServ, u->nick, u->username, common_get_vhost(u), ci->name, ci->founder->display); } return MOD_CONT; @@ -3197,19 +3087,19 @@ static int do_set_mlock(User * u, ChannelInfo * ci, char *param) } /* Reinitialize everything */ -#ifdef IRC_HYBRID - ci->mlock_on = 0; -#else - ci->mlock_on = CMODE_r; -#endif + if (ircd->chanreg) { + ci->mlock_on = ircd->regmode; + } else { + ci->mlock_on = 0; + } ci->mlock_off = ci->mlock_limit = 0; ci->mlock_key = NULL; -#ifdef HAS_FMODE - ci->mlock_flood = NULL; -#endif -#ifdef HAS_LMODE - ci->mlock_redirect = NULL; -#endif + if (ircd->fmode) { + ci->mlock_flood = NULL; + } + if (ircd->Lmode) { + ci->mlock_redirect = NULL; + } while ((mode = *param++)) { switch (mode) { @@ -3247,33 +3137,30 @@ static int do_set_mlock(User * u, ChannelInfo * ci, char *param) } } /* while (*param) */ -#ifdef HAS_LMODE - /* We can't mlock +L if +l is not mlocked as well. */ - if ((ci->mlock_on & CMODE_L) && !(ci->mlock_on & CMODE_l)) { - ci->mlock_on &= ~CMODE_L; - free(ci->mlock_redirect); - notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED); + 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); + } } -#endif -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) /* We can't mlock +K if +i is not mlocked as well. */ - if ((ci->mlock_on & CMODE_K) && !(ci->mlock_on & CMODE_i)) { - ci->mlock_on &= ~CMODE_K; - notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED); + if (ircd->noknock) { + 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); + } } -#endif /* Since we always enforce mode r there is no way to have no * mode lock at all. */ -#if defined(IRC_HYBRID) - /* James: Hybrid doesn't HAVE mode r, so now you have to check :P */ - if (get_mlock_modes(ci, 0)) -#endif + 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) @@ -3483,11 +3370,11 @@ static int do_set_xop(User * u, ChannelInfo * ci, char *param) } else if (CHECKLEV(CA_AUTOOP) || CHECKLEV(CA_OPDEOP) || CHECKLEV(CA_OPDEOPME)) { access->level = ACCESS_AOP; -#ifdef HAS_HALFOP - } else if (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP) - || CHECKLEV(CA_HALFOPME)) { - access->level = ACCESS_HOP; -#endif + } 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; @@ -3502,13 +3389,13 @@ static int do_set_xop(User * u, ChannelInfo * ci, char *param) } alog("%s: %s!%s@%s enabled XOP for %s", s_ChanServ, u->nick, - u->username, GetHost(u), ci->name); + u->username, common_get_vhost(u), ci->name); notice_lang(s_ChanServ, u, CHAN_SET_XOP_ON); } 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, GetHost(u), ci->name); + u->username, common_get_vhost(u), ci->name); notice_lang(s_ChanServ, u, CHAN_SET_XOP_OFF); } else { syntax_error(s_ChanServ, u, "SET XOP", CHAN_SET_XOP_SYNTAX); @@ -3715,7 +3602,7 @@ static int do_xop(User * u, char *xname, int xlev, int *xmsgs) 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, GetHost(u), ulev, change ? "changed" : "set", access->level, na->nick, nc->display, ci->name); + alog("%s: %s!%s@%s (level %d) %s access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, common_get_vhost(u), ulev, change ? "changed" : "set", access->level, na->nick, nc->display, ci->name); if (!change) { notice_lang(s_ChanServ, u, xmsgs[3], access->nc->display, @@ -3851,15 +3738,11 @@ static int do_aop(User * u) /*************************************************************************/ -#ifdef HAS_HALFOP - static int do_hop(User * u) { return do_xop(u, "HOP", ACCESS_HOP, xop_msgs[3]); } -#endif - /*************************************************************************/ static int do_sop(User * u) @@ -4023,7 +3906,7 @@ static int do_access(User * u) 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, GetHost(u), ulev, access->level, na->nick, nc->display, ci->name); + alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, common_get_vhost(u), 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; @@ -4053,7 +3936,7 @@ static int do_access(User * u) 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, GetHost(u), ulev, access->level, na->nick, nc->display, ci->name); + alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, common_get_vhost(u), 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) { @@ -4112,7 +3995,7 @@ static int do_access(User * u) } 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, GetHost(u), get_access(u, ci), na->nick, access->nc->display, chan); + alog("%s: %s!%s@%s (level %d) deleted access of %s (group %s) on %s", s_ChanServ, u->nick, u->username, common_get_vhost(u), get_access(u, ci), na->nick, access->nc->display, chan); access->nc = NULL; access->in_use = 0; } @@ -4158,9 +4041,8 @@ static int do_access(User * u) notice_lang(s_ChanServ, u, CHAN_ACCESS_CLEAR); alog("%s: %s!%s@%s (level %d) cleared access list on %s", - s_ChanServ, u->nick, u->username, GetHost(u), get_access(u, - ci), - chan); + s_ChanServ, u->nick, u->username, common_get_vhost(u), + get_access(u, ci), chan); } else { syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX); @@ -4181,14 +4063,14 @@ AutoKick *is_stuck(ChannelInfo * ci, char *mask) if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) || !(akick->flags & AK_STUCK)) continue; - /* Example: mask = *!*@*.org and akick->u.mask = *!*@*.epona.org */ + /* Example: mask = *!*@*.org and akick->u.mask = *!*@*.anope.org */ if (match_wild_nocase(mask, akick->u.mask)) return akick; -#ifdef IRC_DREAMFORGE - /* Example: mask = *!*@irc.epona.org and akick->u.mask = *!*@*.epona.org */ - if (match_wild_nocase(akick->u.mask, mask)) - return akick; -#endif + if (ircd->reversekickcheck) { + /* Example: mask = *!*@irc.anope.org and akick->u.mask = *!*@*.anope.org */ + if (match_wild_nocase(akick->u.mask, mask)) + return akick; + } } return NULL; @@ -4207,19 +4089,19 @@ void stick_mask(ChannelInfo * ci, AutoKick * akick) if (match_wild_nocase(ci->c->bans[i], akick->u.mask)) return; -#ifdef IRC_DREAMFORGE - /* If akick is wider than a ban already in place. - Example: c->bans[i] = *!*@irc.epona.org and akick->u.mask = *!*@*.epona.org */ - if (match_wild_nocase(akick->u.mask, ci->c->bans[i])) - return; -#endif + if (ircd->reversekickcheck) { + /* If akick is wider than a ban already in place. + Example: c->bans[i] = *!*@irc.epona.org and akick->u.mask = *!*@*.epona.org */ + if (match_wild_nocase(akick->u.mask, ci->c->bans[i])) + return; + } } /* Falling there means set the ban */ av[0] = sstrdup("+b"); av[1] = akick->u.mask; - send_mode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); + anope_cmd_mode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); chan_set_modes(s_ChanServ, ci->c, 2, av, 1); free(av[0]); } @@ -4239,7 +4121,7 @@ void stick_all(ChannelInfo * ci) av[0] = sstrdup("+b"); av[1] = akick->u.mask; - send_mode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); + anope_cmd_mode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); chan_set_modes(s_ChanServ, ci->c, 2, av, 1); free(av[0]); } @@ -4408,12 +4290,12 @@ static int do_akick(User * u) } /* Check excepts BEFORE we get this far */ -#ifdef HAS_EXCEPT - if (is_excepted_mask(ci, mask) == 1) { - notice_lang(s_ChanServ, u, CHAN_EXCEPTED, mask, chan); - return MOD_CONT; + if (ircd->except) { + if (is_excepted_mask(ci, mask) == 1) { + notice_lang(s_ChanServ, u, CHAN_EXCEPTED, mask, chan); + return MOD_CONT; + } } -#endif for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { if (!(akick->flags & AK_USED)) @@ -4781,7 +4663,7 @@ static int do_levels(User * u) 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, GetHost(u), + s_ChanServ, u->nick, u->username, common_get_vhost(u), levelinfo[i].name, ci->name, level); notice_lang(s_ChanServ, u, CHAN_LEVELS_CHANGED, levelinfo[i].name, chan, level); @@ -4797,7 +4679,7 @@ static int do_levels(User * u) ci->levels[levelinfo[i].what] = ACCESS_INVALID; alog("%s: %s!%s@%s disabled level %s on channel %s", - s_ChanServ, u->nick, u->username, GetHost(u), + s_ChanServ, u->nick, u->username, common_get_vhost(u), levelinfo[i].name, ci->name); notice_lang(s_ChanServ, u, CHAN_LEVELS_DISABLED, levelinfo[i].name, chan); @@ -4846,7 +4728,8 @@ static int do_levels(User * u) reset_levels(ci); alog("%s: %s!%s@%s reset levels definitions on channel %s", - s_ChanServ, u->nick, u->username, GetHost(u), ci->name); + s_ChanServ, u->nick, u->username, common_get_vhost(u), + ci->name); notice_lang(s_ChanServ, u, CHAN_LEVELS_RESET, chan); } else { syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX); @@ -5153,7 +5036,7 @@ static int do_invite(User * u) } else if (!u || !check_access(u, ci, CA_INVITE)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); } else { - send_cmd(whosends(ci), "INVITE %s %s", u->nick, chan); + anope_cmd_invite(whosends(ci), chan, u->nick); } return MOD_CONT; } @@ -5185,8 +5068,8 @@ static int do_util(User * u, CSModeUtil * util) for (uc = u->chans; uc; uc = uc->next) { if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) && check_access(u, ci, util->levelself)) { - send_mode(whosends(ci), uc->chan->name, "%s %s", - util->mode, u->nick); + 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) @@ -5219,12 +5102,11 @@ static int do_util(User * u, CSModeUtil * util) } 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); -#if defined (IRC_ULTIMATE) || defined (IRC_ULTIMATE3) } else if (*util->mode == '-' && is_protected(u2)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); -#endif } else { - send_mode(whosends(ci), c->name, "%s %s", util->mode, u2->nick); + anope_cmd_mode(whosends(ci), c->name, "%s %s", util->mode, + u2->nick); av[0] = util->mode; av[1] = u2->nick; @@ -5267,8 +5149,6 @@ static int do_devoice(User * u) /*************************************************************************/ -#ifdef HAS_HALFOP - static int do_halfop(User * u) { return do_util(u, &csmodeutils[MUT_HALFOP]); @@ -5281,12 +5161,8 @@ static int do_dehalfop(User * u) return do_util(u, &csmodeutils[MUT_DEHALFOP]); } -#endif - /*************************************************************************/ -#if defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_RAGE2) || defined(IRC_PTLINK) - static int do_protect(User * u) { return do_util(u, &csmodeutils[MUT_PROTECT]); @@ -5301,10 +5177,6 @@ static int do_deprotect(User * u) /*************************************************************************/ -#endif - -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) - static int do_owner(User * u) { char *av[2]; @@ -5324,8 +5196,8 @@ static int do_owner(User * u) for (uc = u->chans; uc; uc = uc->next) { if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) && is_founder(u, ci)) { - send_mode(whosends(ci), uc->chan->name, "%s %s", - av[0], u->nick); + anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s", + av[0], u->nick); chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); } } @@ -5345,7 +5217,7 @@ static int do_owner(User * u) } else if (!is_founder(u, ci)) { notice_lang(s_ChanServ, u, ACCESS_DENIED); } else { - send_mode(whosends(ci), c->name, "+q %s", u->nick); + anope_cmd_mode(whosends(ci), c->name, "+q %s", u->nick); av[0] = sstrdup("+q"); av[1] = u->nick; @@ -5376,8 +5248,8 @@ static int do_deowner(User * u) for (uc = u->chans; uc; uc = uc->next) { if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) && is_founder(u, ci)) { - send_mode(whosends(ci), uc->chan->name, "%s %s", - av[0], u->nick); + anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s", + av[0], u->nick); chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); } } @@ -5397,7 +5269,7 @@ static int do_deowner(User * u) } else if (!is_founder(u, ci)) { notice_lang(s_ChanServ, u, ACCESS_DENIED); } else { - send_mode(whosends(ci), c->name, "-q %s", u->nick); + anope_cmd_mode(whosends(ci), c->name, "-q %s", u->nick); av[0] = sstrdup("-q"); av[1] = u->nick; @@ -5407,8 +5279,6 @@ static int do_deowner(User * u) return MOD_CONT; } -#endif - /*************************************************************************/ static int do_cs_kick(User * u) @@ -5444,11 +5314,11 @@ static int do_cs_kick(User * u) if ((ci->flags & CI_SIGNKICK) || ((ci->flags & CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK))) - send_cmd(whosends(ci), "KICK %s %s :%s (%s)", ci->name, - u->nick, reason, u->nick); + anope_cmd_kick(whosends(ci), ci->name, u->nick, + "%s (%s)", reason, u->nick); else - send_cmd(whosends(ci), "KICK %s %s :%s", ci->name, - u->nick, reason); + anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s", + reason); av[0] = ci->name; av[1] = u->nick; av[2] = reason; @@ -5479,21 +5349,18 @@ static int do_cs_kick(User * u) } else if (!is_same && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci))) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); -#if defined (IRC_ULTIMATE) || defined (IRC_ULTIMATE3) } else if (is_protected(u2)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); -#endif } else { char *av[3]; if ((ci->flags & CI_SIGNKICK) || ((ci->flags & CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK))) - send_cmd(whosends(ci), "KICK %s %s :%s (%s)", ci->name, params, - reason, u->nick); + anope_cmd_kick(whosends(ci), ci->name, params, "%s (%s)", + reason, u->nick); else - send_cmd(whosends(ci), "KICK %s %s :%s", ci->name, params, - reason); + anope_cmd_kick(whosends(ci), ci->name, params, "%s", reason); av[0] = ci->name; av[1] = params; av[2] = reason; @@ -5535,31 +5402,32 @@ static int do_ban(User * u) char *av[3]; char mask[BUFSIZE]; -#ifdef HAS_EXCEPT /* * Dont ban/kick the user on channels where he is excepted * to prevent services <-> server wars. */ - if (is_excepted(ci, u)) - notice_lang(s_ChanServ, u, CHAN_EXCEPTED, - u->nick, ci->name); - continue; -#endif + if (ircd->except) { + if (is_excepted(ci, u)) + notice_lang(s_ChanServ, u, CHAN_EXCEPTED, + u->nick, ci->name); + continue; + } av[0] = sstrdup("+b"); get_idealban(ci, u, mask, sizeof(mask)); av[1] = mask; - send_mode(whosends(ci), uc->chan->name, "+b %s", av[1]); + 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))) - send_cmd(whosends(ci), "KICK %s %s :%s (%s)", ci->name, - u->nick, reason, u->nick); + anope_cmd_kick(whosends(ci), ci->name, u->nick, + "%s (%s)", reason, u->nick); else - send_cmd(whosends(ci), "KICK %s %s :%s", ci->name, - u->nick, reason); + anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s", + reason); av[0] = ci->name; av[1] = u->nick; av[2] = reason; @@ -5588,14 +5456,12 @@ static int do_ban(User * u) } else if (!is_same && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci))) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); -#ifdef HAS_EXCEPT /* * Dont ban/kick the user on channels where he is excepted * to prevent services <-> server wars. */ - } else if (is_excepted(ci, u2)) { + } else if (ircd->except && is_excepted(ci, u2)) { notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name); -#endif } else { char *av[3]; char mask[BUFSIZE]; @@ -5603,7 +5469,7 @@ static int do_ban(User * u) av[0] = sstrdup("+b"); get_idealban(ci, u2, mask, sizeof(mask)); av[1] = mask; - send_mode(whosends(ci), c->name, "+b %s", av[1]); + anope_cmd_mode(whosends(ci), c->name, "+b %s", av[1]); chan_set_modes(s_ChanServ, c, 2, av, 1); free(av[0]); @@ -5614,11 +5480,11 @@ static int do_ban(User * u) if ((ci->flags & CI_SIGNKICK) || ((ci->flags & CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK))) - send_cmd(whosends(ci), "KICK %s %s :%s (%s)", ci->name, params, - reason, u->nick); + anope_cmd_kick(whosends(ci), ci->name, params, "%s (%s)", + reason, u->nick); else - send_cmd(whosends(ci), "KICK %s %s :%s", ci->name, params, - reason); + anope_cmd_kick(whosends(ci), ci->name, params, "%s", reason); + av[0] = ci->name; av[1] = params; av[2] = reason; @@ -5658,30 +5524,28 @@ static int do_cs_topic(User * u) free(c->topic); c->topic = topic ? sstrdup(topic) : NULL; strscpy(c->topic_setter, u->nick, NICKMAX); -#if defined(IRC_DREAMFORGE) && !defined(IRC_ULTIMATE) && !defined(IRC_UNREAL) - c->topic_time = c->topic_time - 1; -#else - c->topic_time = ci->last_topic_time; -#endif + if (ircd->topictsbackward) { + c->topic_time = c->topic_time - 1; + } else { + c->topic_time = ci->last_topic_time; + } if (is_services_admin(u)) alog("%s: %s!%s@%s changed topic of %s as services admin.", s_ChanServ, u->nick, u->username, u->host, c->name); -#ifdef IRC_HYBRID - if (whosends(ci) == s_ChanServ) { - send_cmd(NULL, "SJOIN %ld %s + :%s", time(NULL), c->name, - s_ChanServ); - send_mode(NULL, c->name, "+o %s", s_ChanServ); + 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); + } } - send_cmd(whosends(ci), "TOPIC %s :%s", c->name, - c->topic ? c->topic : ""); - if (whosends(ci) == s_ChanServ) { - send_cmd(s_ChanServ, "PART %s", c->name); + 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); + } } -#else - send_cmd(whosends(ci), "TOPIC %s %s %lu :%s", c->name, u->nick, - c->topic_time, topic ? topic : ""); -#endif } return MOD_CONT; } @@ -5705,29 +5569,7 @@ static int do_unban(User * u) } else if (!check_access(u, ci, CA_UNBAN)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); } else { -#ifndef IRC_BAHAMUT - int i; - char *av[3]; - /* Save original ban info */ - int count = c->bancount; - char **bans = scalloc(sizeof(char *) * count, 1); - memcpy(bans, c->bans, sizeof(char *) * count); - - av[0] = chan; - av[1] = sstrdup("-b"); - for (i = 0; i < count; i++) { - if (match_usermask(bans[i], u)) { - send_mode(whosends(ci), chan, "-b %s", bans[i]); - av[2] = sstrdup(bans[i]); - do_cmode(s_ChanServ, 3, av); - free(av[2]); - } - } - free(av[1]); - free(bans); -#else - send_cmd(ServerName, "SVSMODE %s -b %s", chan, u->nick); -#endif + common_unban(ci, u->nick); notice_lang(s_ChanServ, u, CHAN_UNBANNED, chan); } return MOD_CONT; @@ -5766,7 +5608,7 @@ static int do_clear(User * u) av[0] = sstrdup(chan); av[1] = sstrdup("-b"); av[2] = bans[i]; - send_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]); + 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]); @@ -5774,8 +5616,7 @@ static int do_clear(User * u) } notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan); free(bans); -#ifdef HAS_EXCEPT - } else if (stricmp(what, "excepts") == 0) { + } else if (ircd->except && stricmp(what, "excepts") == 0) { char *av[3]; int i; @@ -5789,7 +5630,7 @@ static int do_clear(User * u) av[0] = sstrdup(chan); av[1] = sstrdup("-e"); av[2] = excepts[i]; - send_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]); + 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]); @@ -5797,16 +5638,15 @@ static int do_clear(User * u) } notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); free(excepts); -#endif } else if (stricmp(what, "modes") == 0) { char buf[BUFSIZE], *end = buf; char *argv[2]; if (c->mode) { /* Clear modes */ - send_mode(s_ChanServ, c->name, "%s %s", MODESTOREMOVE, - c->key ? c->key : ""); - argv[0] = sstrdup(MODESTOREMOVE); + anope_cmd_mode(s_ChanServ, c->name, "%s %s", + ircd->modestoremove, c->key ? c->key : ""); + argv[0] = sstrdup(ircd->modestoremove); argv[1] = c->key ? c->key : NULL; chan_set_modes(s_OperServ, c, c->key ? 2 : 1, argv, 0); free(argv[0]); @@ -5845,7 +5685,7 @@ static int do_clear(User * u) *end = 0; - send_mode(whosends(ci), c->name, "-%s", buf); + anope_cmd_mode(whosends(ci), c->name, "-%s", buf); c->mode = 0; check_modes(c); } @@ -5861,15 +5701,14 @@ static int do_clear(User * u) av[0] = sstrdup(chan); av[1] = sstrdup("-o"); av[2] = sstrdup(cu->user->nick); - send_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]); + 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); -#ifdef HAS_HALFOP - } else if (stricmp(what, "hops") == 0) { + } else if (ircd->halfop && stricmp(what, "hops") == 0) { char *av[3]; struct c_userlist *cu, *next; @@ -5880,14 +5719,13 @@ static int do_clear(User * u) av[0] = sstrdup(chan); av[1] = sstrdup("-h"); av[2] = sstrdup(cu->user->nick); - send_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]); + 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); -#endif } else if (stricmp(what, "voices") == 0) { char *av[3]; struct c_userlist *cu, *next; @@ -5899,7 +5737,7 @@ static int do_clear(User * u) av[0] = sstrdup(chan); av[1] = sstrdup("-v"); av[2] = sstrdup(cu->user->nick); - send_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]); + 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]); @@ -5918,7 +5756,7 @@ static int do_clear(User * u) av[0] = sstrdup(chan); av[1] = sstrdup(cu->user->nick); av[2] = sstrdup(buf); - send_cmd(whosends(ci), "KICK %s %s :%s", av[0], av[1], av[2]); + anope_cmd_kick(whosends(ci), av[0], av[1], av[2]); do_kick(s_ChanServ, 3, av); free(av[2]); free(av[1]); @@ -5972,10 +5810,12 @@ static int do_getpass(User * u) notice_lang(s_ChanServ, u, PERMISSION_DENIED); } else { alog("%s: %s!%s@%s used GETPASS on %s", - s_ChanServ, u->nick, u->username, GetHost(u), ci->name); + s_ChanServ, u->nick, u->username, common_get_vhost(u), + ci->name); if (WallGetpass) { - wallops(s_ChanServ, "\2%s\2 used GETPASS on channel \2%s\2", - u->nick, chan); + 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); @@ -6034,7 +5874,7 @@ static int do_sendpass(User * u) MailEnd(mail); alog("%s: %s!%s@%s used SENDPASS on %s", s_ChanServ, u->nick, - u->username, GetHost(u), chan); + u->username, common_get_vhost(u), chan); notice_lang(s_ChanServ, u, CHAN_SENDPASS_OK, chan); } #endif @@ -6082,15 +5922,15 @@ static int do_forbid(User * u) av[0] = c->name; av[1] = cu->user->nick; av[2] = reason ? reason : "CHAN_FORBID_REASON"; - send_cmd(s_ChanServ, "KICK %s %s :%s", av[0], av[1], - av[2]); + anope_cmd_kick(s_ChanServ, av[0], av[1], av[2]); do_kick(s_ChanServ, 3, av); } } if (WallForbid) - wallops(s_ChanServ, "\2%s\2 used FORBID on channel \2%s\2", - u->nick, ci->name); + anope_cmd_global(s_ChanServ, + "\2%s\2 used FORBID on channel \2%s\2", + u->nick, ci->name); alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick, ci->name); @@ -6155,15 +5995,15 @@ static int do_suspend(User * u) av[0] = c->name; av[1] = cu->user->nick; av[2] = reason ? reason : "CHAN_SUSPEND_REASON"; - send_cmd(s_ChanServ, "KICK %s %s :%s", av[0], av[1], - av[2]); + anope_cmd_kick(s_ChanServ, av[0], av[1], av[2]); do_kick(s_ChanServ, 3, av); } } if (WallForbid) - wallops(s_ChanServ, "\2%s\2 used SUSPEND on channel \2%s\2", - u->nick, ci->name); + 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); @@ -6203,8 +6043,9 @@ static int do_unsuspend(User * u) ci->forbidby = NULL; if (WallForbid) - wallops(s_ChanServ, "\2%s\2 used UNSUSPEND on channel \2%s\2", - u->nick, ci->name); + 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); diff --git a/src/commands.c b/src/commands.c index 2863d6ca3..833c987c7 100644 --- a/src/commands.c +++ b/src/commands.c @@ -22,7 +22,7 @@ * command exists. */ -Command *lookup_cmd(Command * list, const char *cmd) +Command *lookup_cmd(Command * list, char *cmd) { Command *c; @@ -39,22 +39,20 @@ Command *lookup_cmd(Command * list, const char *cmd) * privilege to do so; if not, print an appropriate error message. */ -void run_cmd(const char *service, User * u, Command * list, - const char *cmd) +void run_cmd(char *service, User * u, Command * list, char *cmd) { Command *c = lookup_cmd(list, cmd); do_run_cmd(service, u, c, cmd); } -void mod_run_cmd(const char *service, User * u, CommandHash * cmdTable[], +void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *cmd) { Command *c = findCommand(cmdTable, cmd); do_run_cmd(service, u, c, cmd); } -void do_run_cmd(const char *service, User * u, Command * c, - const char *cmd) +void do_run_cmd(char *service, User * u, Command * c, const char *cmd) { int retVal = 0; Command *current; @@ -97,8 +95,7 @@ void do_run_cmd(const char *service, User * u, Command * c, /* Print a help message for the given command. */ -void do_help_cmd(const char *service, User * u, Command * c, - const char *cmd) +void do_help_cmd(char *service, User * u, Command * c, const char *cmd) { Command *current; int has_had_help = 0; @@ -161,14 +158,13 @@ void do_help_cmd(const char *service, User * u, Command * c, } } -void help_cmd(const char *service, User * u, Command * list, - const char *cmd) +void help_cmd(char *service, User * u, Command * list, char *cmd) { Command *c = lookup_cmd(list, cmd); do_help_cmd(service, u, c, cmd); } -void mod_help_cmd(const char *service, User * u, CommandHash * cmdTable[], +void mod_help_cmd(char *service, User * u, CommandHash * cmdTable[], const char *cmd) { Command *c = findCommand(cmdTable, cmd); diff --git a/src/datafiles.c b/src/datafiles.c index 5a5512e80..49fb8b040 100644 --- a/src/datafiles.c +++ b/src/datafiles.c @@ -144,8 +144,8 @@ static dbFILE *open_db_write(const char *service, const char *filename, static int walloped = 0; if (!walloped) { walloped++; - wallops(NULL, "Can't back up %s database %s", service, - filename); + anope_cmd_global(NULL, "Can't back up %s database %s", service, + filename); } errno = errno_save; log_perror("Can't back up %s database %s", service, filename); @@ -171,8 +171,8 @@ static dbFILE *open_db_write(const char *service, const char *filename, static int walloped = 0; if (!walloped) { walloped++; - wallops(NULL, "Can't write to %s database %s", service, - filename); + anope_cmd_global(NULL, "Can't write to %s database %s", + service, filename); } errno = errno_save; log_perror("Can't write to %s database %s", service, filename); @@ -424,7 +424,8 @@ static void rename_database(char *name, char *ext) snprintf(destpath, sizeof(destpath), "backups/%s.%s", name, ext); if (rename(name, destpath) != 0) { alog("Backup of %s failed.", name); - wallops(s_OperServ, "WARNING! Backup of %s failed.", name); + anope_cmd_global(s_OperServ, "WARNING! Backup of %s failed.", + name); } } diff --git a/src/dreamforge.c b/src/dreamforge.c new file mode 100644 index 000000000..e9c90aa5c --- /dev/null +++ b/src/dreamforge.c @@ -0,0 +1,1123 @@ +/* DreamForge IRCD functions + * + * (C) 2003 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. + * + * + */ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_DREAMFORGE + +const char version_protocol[] = "DreamForge 4.6.7"; + +IRCDVar ircd[] = { + {"DreamForge 4.6.7", /* ircd name */ + "+o", /* nickserv mode */ + "+o", /* chanserv mode */ + "+o", /* memoserv mode */ + "+", /* hostserv mode */ + "+io", /* operserv mode */ + "+o", /* botserv mode */ + "+h", /* helpserv mode */ + "+i", /* Dev/Null mode */ + "+io", /* Global mode */ + "+o", /* nickserv alias mode */ + "+o", /* chanserv alias mode */ + "+o", /* memoserv alias mode */ + "+", /* hostserv alias mode */ + "+io", /* operserv alias mode */ + "+o", /* botserv alias mode */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+", /* Used by BotServ Bots */ + 2, /* Chan Max Symbols */ + "-iklmnpstR", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 0, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+rd", /* Mode On Reg */ + "-r+d", /* Mode on UnReg */ + "+d", /* Mode on Nick Change */ + 0, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ + 0, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 0, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 1, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 0, /* Has Protect */ + 1, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 0, /* vidents */ + 0, /* svshold */ + 1, /* time stamp on mode */ + 0, /* NICKIP */ + 0, /* UMODE */ + 0, /* O:LINE */ + 0, /* VHOST ON NICK */ + 0, /* Change RealName */ + 0, /* ChanServ extra */ + 0, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + 0, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, /* Mode */ + 0, /* Mode */ + 0, + + } + , + {NULL} +}; + +IRCDCAPAB ircdcap[] = { + { + 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 */ + } +}; + +void anope_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 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + } + } +} + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 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_a, 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, + 0, + 0, + 0, + 0, 0, 0, 0, 0 +}; + +char csmodes[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, + + '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, 0, 0 +}; + + +CMMode cmmodes[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}, + {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 cbmodes[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}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {0}, /* M */ + {0}, /* N */ + {0}, /* O */ + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {0}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {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}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} +}; + +CBModeInfo cbmodeinfos[] = { + {'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}, + {'R', CMODE_R, 0, NULL, NULL}, + {0} +}; + +CUMode cumodes[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}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {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} +}; + + + +int anope_event_nick(char *source, int ac, char **av) +{ + if (ac != 2) { + do_nick(source, av[0], av[3], av[4], av[5], av[7], + strtoul(av[2], NULL, 10), strtoul(av[6], NULL, 0), 0, NULL, + NULL); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + + m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m); + +} + +/* *INDENT-ON* */ + +/* Event: PROTOCTL */ +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +void anope_cmd_sqline(char *mask, char *reason) +{ + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-")); +} + +void anope_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) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +/* PART */ +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (!nick || !chan) { + return; + } + + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + + +void anope_cmd_unsqline(char *user) +{ + send_cmd(NULL, "UNSQLINE %s", user); +} + +void anope_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) +{ + send_cmd(NULL, "AKILL %s %s :%s", host, user, reason); +} + + +void anope_cmd_svskill(char *source, char *user, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + if (!source || !user) { + return; + } + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "KILL %s :%s", user, buf); +} + +void anope_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) +{ + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +void anope_pong(char *servname) +{ + send_cmd(servname, "PONG %s", servname); +} + +void anope_cmd_connect(int servernum) +{ + 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) +{ + send_cmd(NULL, "PASS :%s", pass); +} + +void anope_cmd_bot_chan_mode(char *nick, char *chan) +{ + anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick); +} + +/* SERVER name hop descript */ +void anope_cmd_server(char *servname, int hop, char *descript) +{ + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); +} + +/* GLOBOPS */ +void anope_cmd_global(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +void anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(source, "MODE %s %s", dest, buf); +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + + +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_cmd_serv_privmsg(char *source, char *dest, char *msg) +{ + send_cmd(source, "PRIVMSG $%s :%s", dest, msg); +} + +void anope_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); +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +void anope_cmd_nick(char *nick, char *name, char *modes) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick, time(NULL), + ServiceUser, ServiceHost, ServerName, name); + anope_cmd_mode(nick, nick, "%s", modes); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +/* EVENT: SERVER */ +int anope_event_server(char *source, int ac, char **av) +{ + char *uplink; + + if (!stricmp(av[1], "1")) + uplink = sstrdup(av[0]); + do_server(source, ac, av); + return MOD_CONT; +} + + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +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]); + return MOD_CONT; +} + +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_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) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +/* PONG */ +void anope_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) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick, time(NULL), + user, host, ServerName, real); + anope_cmd_mode(nick, "MODE %s %s", nick, modes); + anope_cmd_sqline(nick, "Reserved for services"); +} + +/* SVSHOLD - set */ +void anope_cmd_svshold(char *nick) +{ + /* Not supported by this IRCD */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + /* Not Supported by this IRCD */ +} + +/* UNSGLINE */ +void anope_cmd_unsgline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* UNSZLINE */ +void anope_cmd_unszline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* SZLINE */ +void anope_cmd_szline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +/* SGLINE */ +void anope_cmd_sgline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +/* SVSNICK */ +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +void anope_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, 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) +{ + /* Not Supported by this IRCD */ +} + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + /* Not Supported by this IRCD */ +} + +void anope_cmd_unban(char *name, char *nick) +{ + /* Not Supported by this IRCD */ +} + +void anope_cmd_vhost_off(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) +{ + 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) +{ + common_svsmode(u, "-r+d", "1"); +} + +/* SVSMODE +r */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } +} + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + // not used +} + +#endif diff --git a/src/hostserv.c b/src/hostserv.c index 7c2945683..4c862e8b3 100644 --- a/src/hostserv.c +++ b/src/hostserv.c @@ -33,9 +33,6 @@ HostCore *insertHostCore(HostCore * head, HostCore * prev, char *nick, HostCore *deleteHostCore(HostCore * head, HostCore * prev); void delHostCore(char *nick); -static void send_on(char *nick, char *vIdent, char *vhost); -static void send_off(User * u); - char *getvIdent(char *nick); char *getvHost(char *nick); @@ -112,11 +109,11 @@ void hostserv(User * u, char *buf) } else if (skeleton) { notice_lang(s_HostServ, u, SERVICE_OFFLINE, s_HostServ); } else { -#ifdef HAS_VHOST - mod_run_cmd(s_HostServ, u, HOSTSERV, cmd); -#else - notice_lang(s_HostServ, u, SERVICE_OFFLINE, s_HostServ); -#endif + if (ircd->vhost) { + mod_run_cmd(s_HostServ, u, HOSTSERV, cmd); + } else { + notice_lang(s_HostServ, u, SERVICE_OFFLINE, s_HostServ); + } } } @@ -129,8 +126,8 @@ HostCore *createHostCorelist(HostCore * next, char *nick, char *vIdent, next = malloc(sizeof(HostCore)); if (next == NULL) { - wallops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); + anope_cmd_global(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); } else { next->nick = malloc(sizeof(char) * strlen(nick) + 1); next->vHost = malloc(sizeof(char) * strlen(vHost) + 1); @@ -139,8 +136,8 @@ HostCore *createHostCorelist(HostCore * next, char *nick, char *vIdent, next->vIdent = malloc(sizeof(char) * strlen(vIdent) + 1); if ((next->nick == NULL) || (next->vHost == NULL) || (next->creator == NULL)) { - wallops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); + anope_cmd_global(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); return NULL; } strcpy(next->nick, nick); @@ -148,8 +145,8 @@ HostCore *createHostCorelist(HostCore * next, char *nick, char *vIdent, strcpy(next->creator, creator); if (vIdent) { if ((next->vIdent == NULL)) { - wallops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); + anope_cmd_global(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); return NULL; } strcpy(next->vIdent, vIdent); @@ -208,8 +205,8 @@ HostCore *insertHostCore(HostCore * head, HostCore * prev, char *nick, newCore = malloc(sizeof(HostCore)); if (newCore == NULL) { - wallops(s_HostServ, - "Unable to allocate memory to insert into the vHost LL, problems i sense.."); + anope_cmd_global(s_HostServ, + "Unable to allocate memory to insert into the vHost LL, problems i sense.."); return NULL; } else { newCore->nick = malloc(sizeof(char) * strlen(nick) + 1); @@ -219,8 +216,8 @@ HostCore *insertHostCore(HostCore * head, HostCore * prev, char *nick, newCore->vIdent = malloc(sizeof(char) * strlen(vIdent) + 1); if ((newCore->nick == NULL) || (newCore->vHost == NULL) || (newCore->creator == NULL)) { - wallops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); + anope_cmd_global(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); return NULL; } strcpy(newCore->nick, nick); @@ -228,8 +225,8 @@ HostCore *insertHostCore(HostCore * head, HostCore * prev, char *nick, strcpy(newCore->creator, creator); if (vIdent) { if ((newCore->vIdent == NULL)) { - wallops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); + anope_cmd_global(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); return NULL; } strcpy(newCore->vIdent, vIdent); @@ -589,7 +586,7 @@ void load_hs_dbase_v3(dbFILE * f) restore_db(f); \ log_perror("Write error on %s", HostDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - wallops(NULL, "Write error on %s: %s", HostDBName, \ + anope_cmd_global(NULL, "Write error on %s: %s", HostDBName, \ strerror(errno)); \ lastwarn = time(NULL); \ } \ @@ -684,10 +681,10 @@ int do_setall(User * u) } } } -#ifndef HAS_VIDENT - notice_lang(s_HostServ, u, HOST_NO_VIDENT); - return MOD_CONT; -#endif + if (!ircd->vident) { + notice_lang(s_HostServ, u, HOST_NO_VIDENT); + return MOD_CONT; + } } if (strlen(rawhostmask) < HOSTMAX - 1) @@ -863,10 +860,10 @@ int do_set(User * u) } } } -#ifndef HAS_VIDENT - notice_lang(s_HostServ, u, HOST_NO_VIDENT); - return MOD_CONT; -#endif + 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); @@ -918,14 +915,14 @@ int do_on(User * u) } else { notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost); } - send_on(u->nick, vIdent, vHost); -#ifdef HAS_VHOST - u->vhost = sstrdup(vHost); -#endif -#ifdef HAS_VIDENT - if (vIdent) - u->vident = sstrdup(vIdent); -#endif + 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 { @@ -951,14 +948,14 @@ int do_on_id(User * u) } else { notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost); } - send_on(u->nick, vIdent, vHost); -#ifdef HAS_VHOST - u->vhost = sstrdup(vHost); -#endif -#ifdef HAS_VIDENT - if (vIdent) - u->vident = sstrdup(vIdent); -#endif + 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); } return MOD_CONT; @@ -988,7 +985,7 @@ int do_del(User * u) int do_off(User * u) { /* put any generic code here... :) */ - send_off(u); + anope_cmd_vhost_off(u->nick); return MOD_CONT; } @@ -1031,76 +1028,16 @@ void set_lastmask(User * u) free(u->na->last_usermask); u->na->last_usermask = - smalloc(strlen(GetIdent(u)) + strlen(GetHost(u)) + 2); - sprintf(u->na->last_usermask, "%s@%s", GetIdent(u), GetHost(u)); + smalloc(strlen(common_get_vident(u)) + + strlen(common_get_vhost(u)) + 2); + sprintf(u->na->last_usermask, "%s@%s", common_get_vident(u), + common_get_vhost(u)); } /*************************************************************************/ /* End of Generic Functions */ /*************************************************************************/ -/*************************************************************************/ -/* Start of Server Functions */ -/*************************************************************************/ -void send_on(char *nick, char *vIdent, char *vhost) -{ -#ifdef IRC_UNREAL - if (vIdent) { - send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); - } - send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); -#endif -#ifdef IRC_VIAGRA - if (vIdent) { - send_cmd(NULL, "CHGIDENT %s %s", nick, vIdent); - } - send_cmd(NULL, "SVSMODE %s +x", nick); - send_cmd(NULL, "SVSCHGHOST %s %s", nick, vhost); -#endif -#ifdef IRC_ULTIMATE - if (vIdent) { - send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); - } - send_cmd(s_HostServ, "SVSMODE %s +x", nick); - send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); -#endif -#ifdef IRC_ULTIMATE3 - send_cmd(s_HostServ, "SVSMODE %s +x", nick); - send_cmd(ServerName, "SETHOST %s %s", nick, vhost); -#endif -#ifdef IRC_RAGE2 - send_cmd(s_HostServ, "SVSMODE %s +z", nick); - send_cmd(ServerName, "VHOST %s %s", nick, vhost); -#endif -} - -/*************************************************************************/ -void send_off(User * u) -{ -#ifdef IRC_UNREAL - send_cmd(s_HostServ, "SVSMODE %s -xt", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick); - /* - * tell them to type /mode nick +x to get their original - * host cloaking back - */ -#endif -#ifdef IRC_VIAGRA - send_cmd(NULL, "SVSMODE %s -x", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick); -#endif -#ifdef IRC_ULTIMATE - /* UltimateIRCd 2.x does not allow users to control +x */ -#endif -#ifdef IRC_ULTIMATE3 - send_cmd(s_HostServ, "SVSMODE %s -x", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick); -#endif -#ifdef IRC_RAGE2 - send_cmd(s_HostServ, "SVSMODE %s -z", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick); -#endif -} /*************************************************************************/ /* End of Server Functions */ diff --git a/src/hybrid.c b/src/hybrid.c new file mode 100644 index 000000000..1a290f30b --- /dev/null +++ b/src/hybrid.c @@ -0,0 +1,1154 @@ +/* Hybrid IRCD functions + * + * (C) 2003 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. + * + * + */ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_HYBRID + +const char version_protocol[] = "Hybrid IRCd 7.0"; + +IRCDVar ircd[] = { + {"HybridIRCd 7.*", /* ircd name */ + "+o", /* nickserv mode */ + "+o", /* chanserv mode */ + "+o", /* memoserv mode */ + NULL, /* hostserv mode */ + "+io", /* operserv mode */ + "+o", /* botserv mode */ + "+h", /* helpserv mode */ + "+i", /* Dev/Null mode */ + "+io", /* Global mode */ + "+o", /* nickserv alias mode */ + "+o", /* chanserv alias mode */ + "+o", /* memoserv alias mode */ + NULL, /* hostserv alias mode */ + "+io", /* operserv alias mode */ + "+o", /* botserv alias mode */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+", /* Used by BotServ Bots */ + 3, /* Chan Max Symbols */ + "-iklmnpstR", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 0, /* SVSNICK */ + 0, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + NULL, /* Mode On Reg */ + NULL, /* Mode on UnReg */ + NULL, /* Mode on Nick Change */ + 0, /* Supports SGlines */ + 0, /* Supports SQlines */ + 0, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 1, /* Join 2 Set */ + 1, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 0, /* Chan Reg */ + 0, /* Channel Mode */ + 0, /* vidents */ + 0, /* svshold */ + 0, /* time stamp on mode */ + 0, /* NICKIP */ + 0, /* UMODE */ + 0, /* O:LINE */ + 0, /* VHOST ON NICK */ + 0, /* Change RealName */ + 0, /* ChanServ extra */ + 0, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + 0, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, + 0, + 0, + } + , + {NULL} +}; + +IRCDCAPAB ircdcap[] = { + { + 0, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + 0, /* BURST */ + CAPAB_TS5, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + CAPAB_QS, /* QS */ + CAPAB_UID, /* UID */ + CAPAB_KNOCK, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0 /* DOZIP */ + } +}; + + + +void anope_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 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + + } + } +} + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 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_a, 0, 0, 0, 0, 0, + 0, + UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, + 0, + 0, UMODE_r, 0, 0, 0, 0, UMODE_w, + 0, + 0, + 0, + 0, 0, 0, 0, 0 +}; + +char csmodes[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, + 'a', /* (33) ! Channel Admins */ + 0, 0, 0, + 0, + 0, 0, 0, 0, + 0, + + '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, 0, 0 +}; + + +CMMode cmmodes[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 cbmodes[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}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {0}, /* M */ + {0}, /* N */ + {0}, /* O */ + {0}, /* P */ + {0}, /* Q */ + {0}, + {0}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {CMODE_a, 0, NULL, NULL}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {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 */ + {0}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} +}; + +CBModeInfo cbmodeinfos[] = { + {'a', CMODE_a, 0, NULL, NULL}, + {'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}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {0} +}; + + +CUMode cumodes[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}, /* a */ + {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 */ + {0}, /* q */ + {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 anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $$%s :%s", dest, msg); +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "WALLOPS :%s", buf); +} + + +int anope_event_sjoin(char *source, int ac, char **av) +{ + do_sjoin(source, ac, av); + return MOD_CONT; +} + +int anope_event_nick(char *source, int ac, char **av) +{ + if (ac != 2) { + User *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 { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac == 4) { + do_topic(source, ac, av); + } else { + Channel *c = findchan(av[0]); + time_t topic_time = time(NULL); + + if (!c) { + alog("channel: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + return MOD_CONT; + } + + if (check_topiclock(c, topic_time)) + return MOD_CONT; + + if (c->topic) { + free(c->topic); + c->topic = NULL; + } + if (ac > 1 && *av[1]) + c->topic = sstrdup(av[1]); + + strscpy(c->topic_setter, source, sizeof(c->topic_setter)); + c->topic_time = topic_time; + + record_topic(av[0]); + } + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("STATS", m_stats); addCoreMessage(IRCD,m); + m = createMessage("TIME", m_time); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", NULL); addCoreMessage(IRCD,m); + + +} + +/* *INDENT-ON* */ + + +void anope_cmd_sqline(char *mask, char *reason) +{ + +} +void anope_cmd_unsgline(char *mask) +{ +/* Does not support */ +} + +void anope_cmd_unszline(char *mask) +{ + /* Does not support */ +} +void anope_cmd_szline(char *mask, char *reason) +{ + /* Does not support */ +} + +void anope_cmd_svsnoop(char *server, int set) +{ + /* does not support */ +} + +void anope_cmd_sgline(char *mask, char *reason) +{ + /* does not support */ +} + +void anope_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) +{ + send_cmd(whosets, "TOPIC %s :%s", chan, topic); +} + +void anope_cmd_vhost_off(char *nick) +{ + /* does not support vhosting */ +} + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + /* does not support vhosting */ +} + +void anope_cmd_unsqline(char *user) +{ + /* Hybrid does not support SQLINEs */ +} + +void anope_cmd_join(char *user, char *channel, time_t chantime) +{ + send_cmd(NULL, "SJOIN %ld %s + :%s", time(NULL), channel, user); +} + +void anope_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", + (expires - (long) time(NULL)), user, host, reason); +} + +void anope_cmd_svskill(char *source, char *user, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + if (!source || !user) { + return; + } + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "KILL %s :%s", user, buf); +} + + +void anope_cmd_svsmode(User * u, int ac, char **av) +{ + /* Hybrid does not support SVSMODE */ +} + +void anope_cmd_connect(int servernum) +{ + 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_svsinfo(); +} + +/* SVSINFO */ +void anope_cmd_svsinfo() +{ + send_cmd(NULL, "SVSINFO 5 5 0 :%ld", time(NULL)); +} + +/* CAPAB */ +void anope_cmd_capab() +{ + send_cmd(NULL, "CAPAB TS5 EX IE HOPS HUB AOPS"); +} + +/* PASS */ +void anope_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) +{ + 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) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, time(NULL), + modes, user, host, ServerName, real); + +} + +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + + if (fmt) { + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +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]); + return MOD_CONT; +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +/* EVENT: SERVER */ +int anope_event_server(char *source, int ac, char **av) +{ + char *uplink; + + if (!stricmp(av[1], "1")) + uplink = sstrdup(av[0]); + do_server(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_cmd_376(char *source) +{ + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +void anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(source, "MODE %s %s", dest, buf); +} + +void anope_cmd_nick(char *nick, char *name, char *mode) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, time(NULL), mode, + ServiceUser, ServiceHost, ServerName, (name)); +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + +void anope_cmd_bot_chan_mode(char *nick, char *chan) +{ + anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick); +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +/* PONG */ +void anope_cmd_pong(char *servname, char *who) +{ + send_cmd(servname, "PONG %s", who); +} + +/* INVITE */ +void anope_cmd_invite(char *source, char *chan, char *nick) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +/* SQUIT */ +void anope_cmd_squit(char *servname, char *message) +{ + if (!servname || !message) { + return; + } + + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + +void anope_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); +} + +/* Event: PROTOCTL */ +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +/* SVSHOLD - set */ +void anope_cmd_svshold(char *nick) +{ + /* Not supported by this IRCD */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + /* Not Supported by this IRCD */ +} + +/* SVSNICK */ +void anope_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) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, time(NULL), + modes, user, host, ServerName, real); +} + +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + /* Not Supported by this IRCD */ +} + +void anope_cmd_unban(char *name, 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) +{ + 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) +{ + // not used +} + +/* SVSMODE +d */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + // not used +} + + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + // not used +} + + +#endif diff --git a/src/init.c b/src/init.c index c6daf5918..3ceca3c3f 100644 --- a/src/init.c +++ b/src/init.c @@ -17,64 +17,9 @@ int servernum = 0; extern void moduleAddMsgs(void); +extern void moduleAddIRCDMsgs(void); /*************************************************************************/ -/* Send a NICK command for the given pseudo-client. If `user' is NULL, - * send NICK commands for all the pseudo-clients. - * - * Now also sends MODE and SQLINE */ -#if defined(IRC_HYBRID) -# define NICK(nick,name,modes) \ - do { \ - kill_user(NULL, (nick), "Nick used by Services"); \ - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", (nick), time(NULL), (modes), \ - ServiceUser, ServiceHost, ServerName, (name)); \ - } while (0) -#elif defined(IRC_ULTIMATE3) -# define NICK(nick,name,modes) \ - do { \ - send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", (nick), time(NULL), (modes), \ - ServiceUser, ServiceHost, ServerName, (name)); \ - send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_RAGE2) -# define NICK(nick,name,modes) \ - do { \ - send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", (nick), time(NULL), ServiceUser, \ - ServiceHost, ServerName, (modes), (name)); \ - send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_BAHAMUT) -# define NICK(nick,name,modes) \ - do { \ - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", (nick), time(NULL), (modes), \ - ServiceUser, ServiceHost, ServerName, (name)); \ - send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_UNREAL) -# define NICK(nick,name,modes) \ - do { \ - send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", (nick), time(NULL), \ - ServiceUser, ServiceHost, ServerName, (modes), (name)); \ - send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_DREAMFORGE) -# define NICK(nick,name,modes) \ - do { \ - send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", (nick), time(NULL), \ - ServiceUser, ServiceHost, ServerName, (name)); \ - if (strcmp(modes, "+")) send_mode((nick), (nick), "%s", (modes)); \ - send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#elif defined(IRC_PTLINK) -# define NICK(nick,name,modes) \ - do { \ - send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", (nick), time(NULL), \ - (modes), ServiceUser, ServiceHost, ServiceHost, ServerName, (name)); \ - send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ - } while (0) -#endif - void introduce_user(const char *user) { @@ -87,98 +32,107 @@ void introduce_user(const char *user) lasttimes[LTSIZE - 1] = time(NULL); #undef LTSIZE + /* NickServ */ if (!user || stricmp(user, s_NickServ) == 0) { EnforceQlinedNick(s_NickServ, NULL); - NICK(s_NickServ, desc_NickServ, NICKSERV_MODE); + anope_cmd_nick(s_NickServ, desc_NickServ, ircd->nickservmode); } + + /* ChanServ */ if (!user || stricmp(user, s_ChanServ) == 0) { EnforceQlinedNick(s_ChanServ, NULL); - NICK(s_ChanServ, desc_ChanServ, CHANSERV_MODE); + anope_cmd_nick(s_ChanServ, desc_ChanServ, ircd->chanservmode); } -#ifdef HAS_VHOST - if (s_HostServ && (!user || stricmp(user, s_HostServ) == 0)) { + if (s_HostServ && ircd->vhost + && (!user || stricmp(user, s_HostServ) == 0)) { EnforceQlinedNick(s_HostServ, NULL); - NICK(s_HostServ, desc_HostServ, HOSTSERV_MODE); + anope_cmd_nick(s_HostServ, desc_HostServ, ircd->hostservmode); } -#endif if (!user || stricmp(user, s_MemoServ) == 0) { EnforceQlinedNick(s_MemoServ, NULL); - NICK(s_MemoServ, desc_MemoServ, MEMOSERV_MODE); + anope_cmd_nick(s_MemoServ, desc_MemoServ, ircd->memoservmode); } if (s_BotServ && (!user || stricmp(user, s_BotServ) == 0)) { EnforceQlinedNick(s_BotServ, NULL); - NICK(s_BotServ, desc_BotServ, BOTSERV_MODE); + anope_cmd_nick(s_BotServ, desc_BotServ, ircd->botservmode); } if (!user || stricmp(user, s_HelpServ) == 0) { EnforceQlinedNick(s_HelpServ, NULL); - NICK(s_HelpServ, desc_HelpServ, HELPSERV_MODE); + anope_cmd_nick(s_HelpServ, desc_HelpServ, ircd->helpservmode); } if (!user || stricmp(user, s_OperServ) == 0) { EnforceQlinedNick(s_OperServ, NULL); - NICK(s_OperServ, desc_OperServ, OPERSERV_MODE); + anope_cmd_nick(s_OperServ, desc_OperServ, ircd->operservmode); } if (s_DevNull && (!user || stricmp(user, s_DevNull) == 0)) { EnforceQlinedNick(s_DevNull, NULL); - NICK(s_DevNull, desc_DevNull, DEVNULL_MODE); + anope_cmd_nick(s_DevNull, desc_DevNull, ircd->devnullmode); } if (!user || stricmp(user, s_GlobalNoticer) == 0) { EnforceQlinedNick(s_GlobalNoticer, NULL); - NICK(s_GlobalNoticer, desc_GlobalNoticer, GLOBAL_MODE); + anope_cmd_nick(s_GlobalNoticer, desc_GlobalNoticer, + ircd->globalmode); } /* We make aliases go online */ if (s_NickServAlias && (!user || stricmp(user, s_NickServAlias) == 0)) { EnforceQlinedNick(s_NickServAlias, NULL); - NICK(s_NickServAlias, desc_NickServAlias, NICKSERV_ALIAS_MODE); + anope_cmd_nick(s_NickServAlias, desc_NickServAlias, + ircd->nickservaliasmode); } if (s_ChanServAlias && (!user || stricmp(user, s_ChanServAlias) == 0)) { EnforceQlinedNick(s_ChanServAlias, NULL); - NICK(s_ChanServAlias, desc_ChanServAlias, CHANSERV_ALIAS_MODE); + anope_cmd_nick(s_ChanServAlias, desc_ChanServAlias, + ircd->chanservaliasmode); } if (s_MemoServAlias && (!user || stricmp(user, s_MemoServAlias) == 0)) { EnforceQlinedNick(s_MemoServAlias, NULL); - NICK(s_MemoServAlias, desc_MemoServAlias, MEMOSERV_ALIAS_MODE); + anope_cmd_nick(s_MemoServAlias, desc_MemoServAlias, + ircd->memoservaliasmode); } if (s_BotServAlias && (!user || stricmp(user, s_BotServAlias) == 0)) { EnforceQlinedNick(s_BotServAlias, NULL); - NICK(s_BotServAlias, desc_BotServAlias, BOTSERV_ALIAS_MODE); + anope_cmd_nick(s_BotServAlias, desc_BotServAlias, + ircd->botservaliasmode); } if (s_HelpServAlias && (!user || stricmp(user, s_HelpServAlias) == 0)) { EnforceQlinedNick(s_HelpServAlias, NULL); - NICK(s_HelpServAlias, desc_HelpServAlias, HELPSERV_ALIAS_MODE); + anope_cmd_nick(s_HelpServAlias, desc_HelpServAlias, + ircd->helpservaliasmode); } if (s_OperServAlias && (!user || stricmp(user, s_OperServAlias) == 0)) { EnforceQlinedNick(s_OperServAlias, NULL); - NICK(s_OperServAlias, desc_OperServAlias, OPERSERV_ALIAS_MODE); + anope_cmd_nick(s_OperServAlias, desc_OperServAlias, + ircd->operservaliasmode); } if (s_DevNullAlias && (!user || stricmp(user, s_DevNullAlias) == 0)) { EnforceQlinedNick(s_DevNullAlias, NULL); - NICK(s_DevNullAlias, desc_DevNullAlias, DEVNULL_ALIAS_MODE); + anope_cmd_nick(s_DevNullAlias, desc_DevNullAlias, + ircd->devnullvaliasmode); } -#ifdef HAS_VHOST - if (s_HostServAlias && (!user || stricmp(user, s_HostServAlias) == 0)) { + if (s_HostServAlias && ircd->vhost + && (!user || stricmp(user, s_HostServAlias) == 0)) { EnforceQlinedNick(s_HostServAlias, NULL); - NICK(s_HostServAlias, desc_HostServAlias, HOSTSERV_ALIAS_MODE); + anope_cmd_nick(s_HostServAlias, desc_HostServAlias, + ircd->hostservaliasmode); } -#endif - if (s_GlobalNoticerAlias && (!user || stricmp(user, s_GlobalNoticerAlias) == 0)) { EnforceQlinedNick(s_GlobalNoticerAlias, NULL); - NICK(s_GlobalNoticerAlias, desc_GlobalNoticerAlias, - GLOBAL_ALIAS_MODE); + anope_cmd_nick(s_GlobalNoticerAlias, desc_GlobalNoticerAlias, + ircd->globalaliasmode); } /* We make the bots go online */ @@ -192,8 +146,8 @@ void introduce_user(const char *user) EnforceQlinedNick(bi->nick, s_BotServ); if (!user || !stricmp(user, bi->nick)) - NEWNICK(bi->nick, bi->user, bi->host, bi->real, - BOTSERV_BOTS_MODE, 1); + anope_cmd_bot_nick(bi->nick, bi->user, bi->host, + bi->real, ircd->botserv_bot_mode); } } } @@ -513,6 +467,9 @@ int init(int ac, char **av) if (!read_config(0)) return -1; + /* Add IRCD Message handlers */ + moduleAddIRCDMsgs(); + /* Add Core MSG handles */ moduleAddMsgs(); @@ -735,75 +692,8 @@ int init(int ac, char **av) RemotePort); } -#ifdef IRC_UNREAL - send_cmd(NULL, "PROTOCTL NICKv2 VHP"); -#endif -#if defined(IRC_ULTIMATE3) - if (servernum == 1) - send_cmd(NULL, "PASS %s :TS", RemotePassword); - else if (servernum == 2) - send_cmd(NULL, "PASS %s :TS", RemotePassword2); - else if (servernum == 3) - send_cmd(NULL, "PASS %s :TS", RemotePassword3); - send_cmd(NULL, "CAPAB NICKIP SSJ5 TS5 CLIENT"); -#elif defined(IRC_RAGE2) - if (servernum == 1) - send_cmd(NULL, "PASS %s :TS", RemotePassword); - else if (servernum == 2) - send_cmd(NULL, "PASS %s :TS", RemotePassword2); - else if (servernum == 3) - send_cmd(NULL, "PASS %s :TS", RemotePassword3); - send_cmd(NULL, "CAPAB SSJ3 SN2 VHOST"); -#elif defined(IRC_BAHAMUT) - if (servernum == 1) - send_cmd(NULL, "PASS %s :TS", RemotePassword); - else if (servernum == 2) - send_cmd(NULL, "PASS %s :TS", RemotePassword2); - else if (servernum == 3) - send_cmd(NULL, "PASS %s :TS", RemotePassword3); - send_cmd(NULL, "CAPAB NICKIP SSJOIN TS3 NOQUIT TSMODE UNCONNECT"); -#elif defined(IRC_HYBRID) - if (servernum == 1) - send_cmd(NULL, "PASS %s :TS", RemotePassword); - else if (servernum == 2) - send_cmd(NULL, "PASS %s :TS", RemotePassword2); - else if (servernum == 3) - send_cmd(NULL, "PASS %s :TS", RemotePassword3); - send_cmd(NULL, "CAPAB TS5 EX IE HOPS HUB AOPS"); -#elif defined(IRC_PTLINK) - if (servernum == 1) - send_cmd(NULL, "PASS %s :TS", RemotePassword); - else if (servernum == 2) - send_cmd(NULL, "PASS %s :TS", RemotePassword2); - else if (servernum == 3) - send_cmd(NULL, "PASS %s :TS", RemotePassword3); -#else - if (servernum == 1) - send_cmd(NULL, "PASS :%s", RemotePassword); - if (servernum == 2) - send_cmd(NULL, "PASS :%s", RemotePassword2); - if (servernum == 3) - send_cmd(NULL, "PASS :%s", RemotePassword3); -#endif -#ifdef IRC_PTLINK - send_cmd(NULL, "SERVER %s 1 Anope.Services%s :%s", - ServerName, version_number, ServerDesc); -#else - send_cmd(NULL, "SERVER %s 1 :%s", ServerName, ServerDesc); -#endif -#ifdef IRC_RAGE2 - send_cmd(NULL, "SVINFO 5 5 0 %ld bluemoon 0", time(NULL)); -#endif -#if defined(IRC_BAHAMUT) && !defined(IRC_RAGE2) - send_cmd(NULL, "SVINFO 3 1 0 :%ld", time(NULL)); -#endif -#ifdef IRC_HYBRID - send_cmd(NULL, "SVSINFO 5 5 0 :%ld", time(NULL)); -#endif -#ifdef IRC_PTLINK - send_cmd(NULL, "SVINFO 3 6 %lu", time(NULL)); - send_cmd(NULL, "SVSINFO %lu %d", time(NULL), maxusercnt); -#endif + anope_cmd_connect(servernum); + sgets2(inbuf, sizeof(inbuf), servsock); if (strnicmp(inbuf, "ERROR", 5) == 0) { /* Close server socket first to stop wallops, since the other @@ -815,20 +705,17 @@ int init(int ac, char **av) /* Announce a logfile error if there was one */ if (openlog_failed) { - wallops(NULL, "Warning: couldn't open logfile: %s", - strerror(openlog_errno)); + anope_cmd_global(NULL, "Warning: couldn't open logfile: %s", + strerror(openlog_errno)); } /* Bring in our pseudo-clients */ introduce_user(NULL); /* And hybrid needs Global joined in the logchan */ -#ifdef IRC_HYBRID - if (logchan) { - send_cmd(NULL, "SJOIN %ld %s + :%s", time(NULL), LogChannel, - s_GlobalNoticer); + if (logchan && ircd->join2msg) { + anope_cmd_join(s_GlobalNoticer, LogChannel, time(NULL)); } -#endif /** * Load our delayed modeles - modules that are planing on making clients need to wait till now diff --git a/src/language.c b/src/language.c index 23fe39286..c1a8541a5 100644 --- a/src/language.c +++ b/src/language.c @@ -258,8 +258,7 @@ int strftime_lang(char *buf, int size, User * u, int format, struct tm *tm) /* Send a syntax-error message to the user. */ -void syntax_error(const char *service, User * u, const char *command, - int msgnum) +void syntax_error(char *service, User * u, char *command, int msgnum) { const char *str = getstring(u->na, msgnum); notice_lang(service, u, SYNTAX_ERROR, str); @@ -248,7 +248,7 @@ void fatal(const char *fmt, ...) if (nofork) fprintf(stderr, "%sFATAL: %s\n", buf, buf2); if (servsock >= 0) - wallops(NULL, "FATAL ERROR! %s", buf2); + anope_cmd_global(NULL, "FATAL ERROR! %s", buf2); exit(1); } @@ -291,7 +291,8 @@ void fatal_perror(const char *fmt, ...) fprintf(stderr, "%sFATAL: %s: %s\n", buf, buf2, strerror(errno_save)); if (servsock >= 0) - wallops(NULL, "FATAL ERROR! %s: %s", buf2, strerror(errno_save)); + anope_cmd_global(NULL, "FATAL ERROR! %s: %s", buf2, + strerror(errno_save)); exit(1); } diff --git a/src/main.c b/src/main.c index cb9c3a009..bc7bb6672 100644 --- a/src/main.c +++ b/src/main.c @@ -102,16 +102,18 @@ static void expire_all(void) } waiting = -25; expire_akills(); -#ifdef IRC_BAHAMUT - waiting = -26; - expire_sglines(); -#endif - waiting = -28; - expire_sqlines(); -#ifdef IRC_BAHAMUT - waiting = -27; - expire_szlines(); -#endif + if (ircd->sgline) { + waiting = -26; + expire_sglines(); + } + if (ircd->sqline) { + waiting = -28; + expire_sqlines(); + } + if (ircd->szline) { + waiting = -27; + expire_szlines(); + } #ifndef STREAMLINED expire_exceptions(); #endif @@ -170,7 +172,7 @@ void save_databases(void) waiting = -13; } /* Temporary fix to avoid unwanted timeouts... */ - send_cmd(ServerName, "PONG %s", ServerName); + anope_cmd_pong(ServerName, ServerName); if (s_BotServ) { waiting = -14; save_bs_rdb_dbase(); @@ -199,7 +201,7 @@ static void services_restart(void) alog("Restarting"); if (!quitmsg) quitmsg = "Restarting"; - send_cmd(ServerName, "SQUIT %s :%s", ServerName, quitmsg); + anope_cmd_squit(ServerName, quitmsg); disconn(servsock); close_log(); #if defined(LINUX20) || defined(LINUX22) @@ -236,7 +238,7 @@ static void services_shutdown(void) quitmsg = "Terminating, reason unknown"; alog("%s", quitmsg); if (started) - send_cmd(ServerName, "SQUIT %s :%s", ServerName, quitmsg); + anope_cmd_squit(ServerName, quitmsg); disconn(servsock); } @@ -301,7 +303,7 @@ void sighandler(int signum) inbuf[447] = '>'; inbuf[448] = 0; } - wallops(NULL, "PANIC! buffer = %s\r\n", inbuf); + anope_cmd_global(NULL, "PANIC! buffer = %s\r\n", inbuf); } else if (waiting < 0) { /* This is static on the off-chance we run low on stack */ static char buf[BUFSIZE]; @@ -345,21 +347,20 @@ void sighandler(int signum) case -25: snprintf(buf, sizeof(buf), "expiring autokills"); break; -#ifdef IRC_BAHAMUT case -26: snprintf(buf, sizeof(buf), "expiring SGLINEs"); break; case -27: snprintf(buf, sizeof(buf), "expiring SZLINEs"); break; -#endif case -28: snprintf(buf, sizeof(buf), "expiring SQLINEs"); break; default: snprintf(buf, sizeof(buf), "waiting=%d", waiting); } - wallops(NULL, "PANIC! %s (%s)", buf, strsignal(signum)); + anope_cmd_global(NULL, "PANIC! %s (%s)", buf, + strsignal(signum)); alog("PANIC! %s (%s)", buf, strsignal(signum)); } } @@ -456,8 +457,8 @@ int main(int ac, char **av, char **envp) if (!readonly && (save_data || t - last_update >= UpdateTimeout)) { if (delayed_quit) - wallops(NULL, - "Updating databases on shutdown, please wait."); + anope_cmd_global(NULL, + "Updating databases on shutdown, please wait."); save_databases(); @@ -510,7 +511,7 @@ int main(int ac, char **av, char **envp) alog("Restarting"); if (!quitmsg) quitmsg = "Restarting"; - send_cmd(ServerName, "SQUIT %s :%s", ServerName, quitmsg); + anope_cmd_squit(ServerName, quitmsg); disconn(servsock); close_log(); #if defined(LINUX20) || defined(LINUX22) diff --git a/src/messages.c b/src/messages.c index 887a9986f..335fc1093 100644 --- a/src/messages.c +++ b/src/messages.c @@ -16,593 +16,132 @@ #include "messages.h" #include "language.h" -static char *uplink; -int servernum; -/* List of messages is at the bottom of the file. */ - -/*************************************************************************/ -/*************************************************************************/ - -static int m_nickcoll(char *source, int ac, char **av) -{ - if (ac < 1) - return MOD_CONT; - if (!skeleton && !readonly) - introduce_user(av[0]); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_ping(char *source, int ac, char **av) -{ - if (ac < 1) - return MOD_CONT; - send_cmd(ServerName, "PONG %s %s", ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_away(char *source, int ac, char **av) -{ - User *u = finduser(source); - - if (u && (ac == 0 || *av[0] == 0)) /* un-away */ - check_memos(u); - return MOD_CONT; -} - -/*************************************************************************/ +int servernum; -#ifdef IRC_BAHAMUT - -static int m_capab(char *source, int ac, char **av) -{ - int i; - - for (i = 0; i < ac; i++) { - if (!stricmp(av[i], "NOQUIT")) - uplink_capab |= CAPAB_NOQUIT; - else if (!stricmp(av[i], "TSMODE")) - uplink_capab |= CAPAB_TSMODE; - else if (!stricmp(av[i], "UNCONNECT")) - uplink_capab |= CAPAB_UNCONNECT; - } - - return MOD_CONT; -} - -#endif /*************************************************************************/ -#ifdef IRC_BAHAMUT - -static int m_cs(char *source, int ac, char **av) +int m_nickcoll(char *user) { - User *u; - time_t starttime, stoptime; /* When processing started and finished */ - - if (ac < 1 || skeleton) - return MOD_CONT; - - u = finduser(source); - - if (!u) { - alog("%s: user record for %s not found", s_ChanServ, source); - notice(s_ChanServ, source, getstring(NULL, USER_RECORD_NOT_FOUND)); - return MOD_CONT; - } - - /* Check if we should ignore. Operators always get through. */ - if (allow_ignore && !is_oper(u)) { - IgnoreData *ign = get_ignore(source); - if (ign && ign->time > time(NULL)) { - alog("Ignored message from %s: \"%s\"", source, inbuf); - return MOD_CONT; - } - } - - starttime = time(NULL); - if (!is_oper(u) && CSOpersOnly) - notice_lang(s_ChanServ, u, ACCESS_DENIED); - else - chanserv(u, av[0]); - - /* Add to ignore list if the command took a significant amount of time. */ - if (allow_ignore) { - stoptime = time(NULL); - if (stoptime > starttime && *source && !strchr(source, '.')) - add_ignore(source, stoptime - starttime); - } + if (!skeleton && !readonly) + introduce_user(user); return MOD_CONT; } -#endif - /*************************************************************************/ -#ifdef IRC_BAHAMUT - -static int m_hs(char *source, int ac, char **av) +int m_away(char *source, char *msg) { User *u; - time_t starttime, stoptime; /* When processing started and finished */ - - if (ac < 1 || skeleton) - return MOD_CONT; u = finduser(source); - if (!u) { - alog("%s: user record for %s not found", s_HelpServ, source); - notice(s_HelpServ, source, getstring(NULL, USER_RECORD_NOT_FOUND)); - return MOD_CONT; - } - - /* Check if we should ignore. Operators always get through. */ - if (allow_ignore && !is_oper(u)) { - IgnoreData *ign = get_ignore(source); - if (ign && ign->time > time(NULL)) { - alog("Ignored message from %s: \"%s\"", source, inbuf); - return MOD_CONT; - } - } - - starttime = time(NULL); - - 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); - - /* Add to ignore list if the command took a significant amount of time. */ - if (allow_ignore) { - stoptime = time(NULL); - if (stoptime > starttime && *source && !strchr(source, '.')) - add_ignore(source, stoptime - starttime); - } - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -static int m_join(char *source, int ac, char **av) -{ - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_kick(char *source, int ac, char **av) -{ - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); + if (u && msg == 0) /* un-away */ + check_memos(u); return MOD_CONT; } /*************************************************************************/ -static int m_kill(char *source, int ac, char **av) +int m_kill(char *nick, char *msg) { BotInfo *bi; - if (ac != 2) - return MOD_CONT; /* Recover if someone kills us. */ - if (stricmp(av[0], s_OperServ) == 0 || - (s_OperServAlias && stricmp(av[0], s_OperServAlias) == 0) || - stricmp(av[0], s_NickServ) == 0 || - (s_NickServAlias && stricmp(av[0], s_NickServAlias) == 0) || - stricmp(av[0], s_ChanServ) == 0 || - (s_ChanServAlias && stricmp(av[0], s_ChanServAlias) == 0) || - stricmp(av[0], s_MemoServ) == 0 || - (s_MemoServAlias && stricmp(av[0], s_MemoServAlias) == 0) || - (s_HostServ && stricmp(av[0], s_HostServ) == 0) || - (s_HostServAlias && stricmp(av[0], s_HostServAlias) == 0) || - (s_BotServ && stricmp(av[0], s_BotServ) == 0) || - (s_BotServAlias && stricmp(av[0], s_BotServAlias) == 0) || - stricmp(av[0], s_HelpServ) == 0 || - (s_HelpServAlias && stricmp(av[0], s_HelpServAlias) == 0) || - (s_DevNull && stricmp(av[0], s_DevNull) == 0) || - (s_DevNullAlias && stricmp(av[0], s_DevNullAlias) == 0) || - stricmp(av[0], s_GlobalNoticer) == 0 || - (s_GlobalNoticerAlias && stricmp(av[0], s_GlobalNoticerAlias) == 0) + if (stricmp(nick, s_OperServ) == 0 || + (s_OperServAlias && stricmp(nick, s_OperServAlias) == 0) || + stricmp(nick, s_NickServ) == 0 || + (s_NickServAlias && stricmp(nick, s_NickServAlias) == 0) || + stricmp(nick, s_ChanServ) == 0 || + (s_ChanServAlias && stricmp(nick, s_ChanServAlias) == 0) || + stricmp(nick, s_MemoServ) == 0 || + (s_MemoServAlias && stricmp(nick, s_MemoServAlias) == 0) || + (s_HostServ && stricmp(nick, s_HostServ) == 0) || + (s_HostServAlias && stricmp(nick, s_HostServAlias) == 0) || + (s_BotServ && stricmp(nick, s_BotServ) == 0) || + (s_BotServAlias && stricmp(nick, s_BotServAlias) == 0) || + stricmp(nick, s_HelpServ) == 0 || + (s_HelpServAlias && stricmp(nick, s_HelpServAlias) == 0) || + (s_DevNull && stricmp(nick, s_DevNull) == 0) || + (s_DevNullAlias && stricmp(nick, s_DevNullAlias) == 0) || + stricmp(nick, s_GlobalNoticer) == 0 || + (s_GlobalNoticerAlias && stricmp(nick, s_GlobalNoticerAlias) == 0) ) { if (!readonly && !skeleton) - introduce_user(av[0]); - } else if (s_BotServ && (bi = findbot(av[0]))) { + introduce_user(nick); + } else if (s_BotServ && (bi = findbot(nick))) { if (!readonly && !skeleton) { - introduce_user(av[0]); + introduce_user(nick); bot_rejoin_all(bi); } } else { - do_kill(source, ac, av); + do_kill(nick, msg); } return MOD_CONT; } /*************************************************************************/ -static int m_mode(char *source, int ac, char **av) +int m_time(char *source, int ac, char **av) { - if (*av[0] == '#' || *av[0] == '&') { - if (ac < 2) - return MOD_CONT; - do_cmode(source, ac, av); - } else { - if (ac != 2) - return MOD_CONT; - do_umode(source, ac, av); - } + time_t t; + struct tm *tm; + char buf[64]; + + time(&t); + tm = localtime(&t); + strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm); + anope_cmd_391(source, buf); return MOD_CONT; } /*************************************************************************/ -static int m_motd(char *source, int ac, char **av) +int m_motd(char *source) { FILE *f; char buf[BUFSIZE]; f = fopen(MOTDFilename, "r"); - send_cmd(ServerName, "375 %s :- %s Message of the Day", - source, ServerName); + anope_cmd_375(source); if (f) { while (fgets(buf, sizeof(buf), f)) { buf[strlen(buf) - 1] = 0; - send_cmd(ServerName, "372 %s :- %s", source, buf); + anope_cmd_372(source, buf); } fclose(f); } else { - send_cmd(ServerName, "372 %s :- MOTD file not found! Please " - "contact your IRC administrator.", source); - } - send_cmd(ServerName, "376 %s :End of /MOTD command.", source); - return MOD_CONT; -} - -/*************************************************************************/ - -#ifdef IRC_BAHAMUT - -static int m_ms(char *source, int ac, char **av) -{ - User *u; - time_t starttime, stoptime; /* When processing started and finished */ - - if (ac < 1 || skeleton) - return MOD_CONT; - - u = finduser(source); - - if (!u) { - alog("%s: user record for %s not found", s_MemoServ, source); - notice(s_MemoServ, source, getstring(NULL, USER_RECORD_NOT_FOUND)); - return MOD_CONT; - } - - /* Check if we should ignore. Operators always get through. */ - if (allow_ignore && !is_oper(u)) { - IgnoreData *ign = get_ignore(source); - if (ign && ign->time > time(NULL)) { - alog("Ignored message from %s: \"%s\"", source, inbuf); - return MOD_CONT; - } - } - - starttime = time(NULL); - - memoserv(u, av[0]); - - /* Add to ignore list if the command took a significant amount of time. */ - if (allow_ignore) { - stoptime = time(NULL); - if (stoptime > starttime && *source && !strchr(source, '.')) - add_ignore(source, stoptime - starttime); - } - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -static int m_nick(char *source, int ac, char **av) -{ - if (ac != 2) { -#if defined(IRC_HYBRID) - User *user = do_nick(source, av[0], av[4], av[5], av[6], av[7], - strtoul(av[2], NULL, 10), 0); - if (user) - set_umode(user, 1, &av[3]); -#else -#if defined(IRC_BAHAMUT) -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - User *user = do_nick(source, av[0], av[4], av[5], av[6], av[9], - strtoul(av[2], NULL, 10), strtoul(av[7], NULL, - 0), - strtoul(av[8], NULL, 0), "*"); -# else - User *user = do_nick(source, av[0], av[4], av[5], av[6], av[9], - strtoul(av[2], NULL, 10), strtoul(av[7], NULL, - 0), - strtoul(av[8], NULL, 0)); -# endif - if (user) - set_umode(user, 1, &av[3]); -#elif defined(IRC_UNREAL) - if (ac == 7) { - /* For some reasons, Unreal sends this sometimes */ - do_nick(source, av[0], av[3], av[4], av[5], av[6], - strtoul(av[2], NULL, 10), 0, "*"); - } else { - User *user = do_nick(source, av[0], av[3], av[4], av[5], av[9], - strtoul(av[2], NULL, 10), strtoul(av[6], - NULL, - 0), - av[8]); - - if (user) - set_umode(user, 1, &av[7]); - } -#else -# if defined(IRC_ULTIMATE) - if (ac == 7) { - do_nick(source, av[0], av[3], av[4], av[5], av[6], - strtoul(av[2], NULL, 10), 0); - } else { - do_nick(source, av[0], av[3], av[4], av[5], av[7], - strtoul(av[2], NULL, 10), strtoul(av[6], NULL, 0)); - } -/* PTlink IRCd - PTS4 */ -#elif defined(IRC_PTLINK) - User *user = do_nick(source, av[0], av[4], av[6], av[7], av[8], - strtoul(av[2], NULL, 10), 0, av[5]); - if (user) - set_umode(user, 1, &av[3]); -#else - do_nick(source, av[0], av[3], av[4], av[5], av[7], - strtoul(av[2], NULL, 10), strtoul(av[6], NULL, 0)); -# endif -#endif -#endif - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0); - } - return MOD_CONT; -} - -/*************************************************************************/ - -#ifdef IRC_ULTIMATE3 - -static int m_client(char *source, int ac, char **av) -{ - if (ac != 2) { - User *user = do_nick(source, av[0], av[5], av[6], av[8], av[11], - strtoul(av[2], NULL, 10), strtoul(av[9], NULL, - 0), - strtoul(av[10], NULL, 0), av[7]); - if (user) { - set_umode(user, 1, &av[3]); - } - } - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -#ifdef IRC_RAGE2 - -static int m_snick(char *source, int ac, char **av) -{ - if (ac != 2) { - User *user = do_nick(source, av[0], av[3], av[4], av[7], av[10], - strtoul(av[1], NULL, 10), strtoul(av[8], NULL, - 0), - strtoul(av[5], NULL, 0), av[6]); - if (user) { - set_umode(user, 1, &av[9]); - } - } - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -#ifdef IRC_BAHAMUT - -static int m_ns(char *source, int ac, char **av) -{ - User *u; - time_t starttime, stoptime; /* When processing started and finished */ - - if (ac < 1 || skeleton) - return MOD_CONT; - - u = finduser(source); - - if (!u) { - alog("%s: user record for %s not found", s_NickServ, source); - notice(s_NickServ, source, getstring(NULL, USER_RECORD_NOT_FOUND)); - return MOD_CONT; - } - - /* Check if we should ignore. Operators always get through. */ - if (allow_ignore && !is_oper(u)) { - IgnoreData *ign = get_ignore(source); - if (ign && ign->time > time(NULL)) { - alog("Ignored message from %s: \"%s\"", source, inbuf); - return MOD_CONT; - } - } - - starttime = time(NULL); - - nickserv(u, av[0]); - - /* Add to ignore list if the command took a significant amount of time. */ - if (allow_ignore) { - stoptime = time(NULL); - if (stoptime > starttime && *source && !strchr(source, '.')) - add_ignore(source, stoptime - starttime); - } - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -#ifdef IRC_PTLINK -/* - * Note: This function has no validation whatsoever. Also, as of PTlink6.15.1 - * when you /deoper you get to keep your vindent, but you lose your vhost. In - * that case serives will *NOT* modify it's internal record for the vhost. We - * need to address this in the future. - */ -static int m_newmask(char *source, int ac, char **av) -{ - User *u; - char *newhost = NULL, *newuser = NULL; - - if (ac != 1) - return MOD_CONT; - u = finduser(source); - - if (!u) { - alog("user: NEWMASK for nonexistent user %s", av[0]); - return MOD_CONT; - } - - newuser = myStrGetOnlyToken(av[0], '@', 0); - if (newuser) { - newhost = myStrGetTokenRemainder(av[0], '@', 1); - change_user_username(u, newuser); - } else { - newhost = av[0]; - } - - if (*newhost == '@') - newhost++; - - if (newhost) { - change_user_host(u, newhost); - } - - return MOD_CONT; -} -#endif - - -/*************************************************************************/ - -#ifdef IRC_BAHAMUT - -static int m_os(char *source, int ac, char **av) -{ - User *u; - time_t starttime, stoptime; /* When processing started and finished */ - - if (ac < 1) - return MOD_CONT; - - u = finduser(source); - - if (!u) { - alog("%s: user record for %s not found", s_OperServ, source); - notice(s_OperServ, source, getstring(NULL, USER_RECORD_NOT_FOUND)); - return MOD_CONT; - } - - /* Check if we should ignore. Operators always get through. */ - if (allow_ignore && !is_oper(u)) { - IgnoreData *ign = get_ignore(source); - if (ign && ign->time > time(NULL)) { - alog("Ignored message from %s: \"%s\"", source, inbuf); - return MOD_CONT; - } - } - - starttime = time(NULL); - - if (is_oper(u)) { - operserv(u, av[0]); - } else { - notice_lang(s_OperServ, u, ACCESS_DENIED); - - if (WallBadOS) - wallops(s_OperServ, - "Denied access to %s from %s!%s@%s (non-oper)", - s_OperServ, u->nick, u->username, u->host); - } - - /* Add to ignore list if the command took a significant amount of time. */ - if (allow_ignore) { - stoptime = time(NULL); - if (stoptime > starttime && *source && !strchr(source, '.')) - add_ignore(source, stoptime - starttime); + anope_cmd_372_error(source); } + anope_cmd_376(source); return MOD_CONT; } -#endif - /*************************************************************************/ -static int m_part(char *source, int ac, char **av) -{ - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_privmsg(char *source, int ac, char **av) +int m_privmsg(char *source, char *receiver, char *msg) { char *s; - char *buf; time_t starttime, stoptime; /* When processing started and finished */ BotInfo *bi; ChannelInfo *ci; User *u; - if (ac != 2) - return MOD_CONT; - u = finduser(source); if (!u) { - alog("%s: user record for %s not found", av[1], source); - notice(av[1], source, getstring(NULL, USER_RECORD_NOT_FOUND)); + alog("%s: user record for %s not found", msg, source); + anope_cmd_notice(msg, source, + getstring(NULL, USER_RECORD_NOT_FOUND)); return MOD_CONT; } - if (*av[0] == '#') { - if (s_BotServ && (ci = cs_findchan(av[0]))) - if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) - /* Some paranoia checks */ - /* Copy the message to a temp. variable, otherwise botchanmsgs would break the buffer for modules -Keeper */ - buf = sstrdup(av[1]); - botchanmsgs(u, ci, buf); - free(buf); + if (*receiver == '#') { + if (s_BotServ && (ci = cs_findchan(receiver))) + if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) /* Some paranoia checks */ + botchanmsgs(u, ci, msg); } else { /* Check if we should ignore. Operators always get through. */ @@ -616,7 +155,7 @@ static int m_privmsg(char *source, int ac, char **av) /* If a server is specified (nick@server format), make sure it matches * us, and strip it off. */ - s = strchr(av[0], '@'); + s = strchr(receiver, '@'); if (s) { *s++ = 0; if (stricmp(s, ServerName) != 0) @@ -625,59 +164,54 @@ static int m_privmsg(char *source, int ac, char **av) starttime = time(NULL); - if ((stricmp(av[0], s_OperServ) == 0) - || (s_OperServAlias && (stricmp(av[0], s_OperServAlias) == 0))) { + if ((stricmp(receiver, s_OperServ) == 0) + || (s_OperServAlias + && (stricmp(receiver, s_OperServAlias) == 0))) { if (is_oper(u)) { - operserv(u, av[1]); + operserv(u, msg); } else { notice_lang(s_OperServ, u, ACCESS_DENIED); if (WallBadOS) - wallops(s_OperServ, - "Denied access to %s from %s!%s@%s (non-oper)", - s_OperServ, u->nick, u->username, u->host); + anope_cmd_global(s_OperServ, + "Denied access to %s from %s!%s@%s (non-oper)", + s_OperServ, u->nick, u->username, + u->host); } - } else if ((stricmp(av[0], s_NickServ) == 0) + } else if ((stricmp(receiver, s_NickServ) == 0) || (s_NickServAlias - && (stricmp(av[0], s_NickServAlias) == 0))) { - nickserv(u, av[1]); - } else if ((stricmp(av[0], s_ChanServ) == 0) + && (stricmp(receiver, s_NickServAlias) == 0))) { + nickserv(u, msg); + } else if ((stricmp(receiver, s_ChanServ) == 0) || (s_ChanServAlias - && (stricmp(av[0], s_ChanServAlias) == 0))) { + && (stricmp(receiver, s_ChanServAlias) == 0))) { if (!is_oper(u) && CSOpersOnly) notice_lang(s_ChanServ, u, ACCESS_DENIED); else - chanserv(u, av[1]); - } else if ((stricmp(av[0], s_MemoServ) == 0) + chanserv(u, msg); + } else if ((stricmp(receiver, s_MemoServ) == 0) || (s_MemoServAlias - && (stricmp(av[0], s_MemoServAlias) == 0))) { - memoserv(u, av[1]); - } else if (s_HostServ && ((stricmp(av[0], s_HostServ) == 0) + && (stricmp(receiver, s_MemoServAlias) == 0))) { + memoserv(u, msg); + } else if (s_HostServ && ((stricmp(receiver, s_HostServ) == 0) || (s_HostServAlias - && (stricmp(av[0], s_HostServAlias) - == 0)))) { - hostserv(u, av[1]); - } else if (s_HelpServ && ((stricmp(av[0], s_HelpServ) == 0) + && + (stricmp(receiver, s_HostServAlias) + == 0)))) { + hostserv(u, msg); + } else if (s_HelpServ && ((stricmp(receiver, s_HelpServ) == 0) || (s_HelpServAlias - && (stricmp(av[0], s_HelpServAlias) - == 0)))) { - helpserv(u, av[1]); - } else if (s_BotServ && ((stricmp(av[0], s_BotServ) == 0) + && + (stricmp(receiver, s_HelpServAlias) + == 0)))) { + helpserv(u, msg); + } else if (s_BotServ && ((stricmp(receiver, s_BotServ) == 0) || (s_BotServAlias - && (stricmp(av[0], s_BotServAlias) == - 0)))) { - botserv(u, av[1]); -/* This HelpServ code is history since HelpServ is a REAL service */ - -/* } else if ((stricmp(av[0], s_HelpServ) == 0) - || (s_HelpServAlias - && (stricmp(av[0], s_HelpServAlias) == 0))) { - 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); */ - } else if (s_BotServ && (bi = findbot(av[0]))) { - botmsgs(u, bi, av[1]); + && (stricmp(receiver, s_BotServAlias) + == 0)))) { + botserv(u, msg); + } else if (s_BotServ && (bi = findbot(receiver))) { + botmsgs(u, bi, msg); } /* Add to ignore list if the command took a significant amount of time. */ @@ -692,222 +226,7 @@ static int m_privmsg(char *source, int ac, char **av) /*************************************************************************/ -static int m_quit(char *source, int ac, char **av) -{ - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_squit(char *source, int ac, char **av) -{ - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_server(char *source, int ac, char **av) -{ - if (!stricmp(av[1], "1")) - uplink = sstrdup(av[0]); -#ifdef IRC_PTLINK - if (ac != 4) -#else - if (ac != 3) -#endif - return MOD_CONT; - do_server(source, ac, av); - return MOD_CONT; -} - -/*************************************************************************/ - -#if defined(IRC_ULTIMATE3) - -static int m_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", av[0]); - return MOD_CONT; - } - - change_user_host(u, av[1]); - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -#ifdef IRC_RAGE2 - -static int m_vhost(char *source, int ac, char **av) -{ - User *u; - - if (ac != 2) - return MOD_CONT; - - u = finduser(av[0]); - if (!u) { - if (debug) - alog("user: VHOST for nonexistent user %s", av[0]); - return MOD_CONT; - } - - change_user_host(u, av[1]); - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_VIAGRA) - -static int m_chghost(char *source, int ac, char **av) -{ - User *u; - - if (ac != 2) - return MOD_CONT; - - u = finduser(av[0]); - if (!u) { - alog("user: CHGHOST for nonexistent user %s", av[0]); - return MOD_CONT; - } - - change_user_host(u, av[1]); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_sethost(char *source, int ac, char **av) -{ - User *u; - - if (ac != 1) - return MOD_CONT; - - u = finduser(source); - if (!u) { - if (debug) - alog("user: SETHOST for nonexistent user %s", source); - return MOD_CONT; - } - - change_user_host(u, av[0]); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_chgident(char *source, int ac, char **av) -{ - User *u; - - if (ac != 2) - return MOD_CONT; - - u = finduser(av[0]); - if (!u) { - alog("user: CHGIDENT for nonexistent user %s", av[0]); - return MOD_CONT; - } - - change_user_username(u, av[1]); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_setident(char *source, int ac, char **av) -{ - User *u; - - if (ac != 1) - return MOD_CONT; - - u = finduser(source); - if (!u) { - alog("user: SETIDENT for nonexistent user %s", source); - return MOD_CONT; - } - - change_user_username(u, av[0]); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_chgname(char *source, int ac, char **av) -{ - User *u; - - if (ac != 2) - return MOD_CONT; - - u = finduser(av[0]); - if (!u) { - alog("user: CHGNAME for nonexistent user %s", av[0]); - return MOD_CONT; - } - - change_user_realname(u, av[1]); - return MOD_CONT; -} - -/*************************************************************************/ - -static int m_setname(char *source, int ac, char **av) -{ - User *u; - - if (ac != 1) - return MOD_CONT; - - u = finduser(source); - if (!u) { - alog("user: SETNAME for nonexistent user %s", source); - return MOD_CONT; - } - - change_user_realname(u, av[0]); - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -#if defined(IRC_BAHAMUT) || defined(IRC_HYBRID) || defined(IRC_PTLINK) || defined(IRC_RAGE2) - -static int m_sjoin(char *source, int ac, char **av) -{ - do_sjoin(source, ac, av); - return MOD_CONT; -} - -#endif - -/*************************************************************************/ - -static int m_stats(char *source, int ac, char **av) +int m_stats(char *source, int ac, char **av) { int i; User *u; @@ -923,76 +242,71 @@ static int m_stats(char *source, int ac, char **av) if (u && is_oper(u)) { if (servernum == 1) { - send_cmd(NULL, - "211 %s Server SendBuf SentBytes SentMsgs RecvBuf " - "RecvBytes RecvMsgs ConnTime", source); - send_cmd(NULL, "211 %s %s %d %d %d %d %d %d %ld", source, - RemoteServer, write_buffer_len(), total_written, - -1, read_buffer_len(), total_read, -1, - time(NULL) - start_time); + anope_cmd_211 + ("%s Server SendBuf SentBytes SentMsgs RecvBuf " + "RecvBytes RecvMsgs ConnTime", source); + anope_cmd_211("%s %s %d %d %d %d %d %d %ld", source, + RemoteServer, write_buffer_len(), + total_written, -1, read_buffer_len(), + total_read, -1, time(NULL) - start_time); } else if (servernum == 2) { - send_cmd(NULL, - "211 %s Server SendBuf SentBytes SentMsgs RecvBuf " - "RecvBytes RecvMsgs ConnTime", source); - send_cmd(NULL, "211 %s %s %d %d %d %d %d %d %ld", source, - RemoteServer2, write_buffer_len(), total_written, - -1, read_buffer_len(), total_read, -1, - time(NULL) - start_time); + anope_cmd_211 + ("%s Server SendBuf SentBytes SentMsgs RecvBuf " + "RecvBytes RecvMsgs ConnTime", source); + anope_cmd_211("%s %s %d %d %d %d %d %d %ld", source, + RemoteServer2, write_buffer_len(), + total_written, -1, read_buffer_len(), + total_read, -1, time(NULL) - start_time); } else if (servernum == 3) { - send_cmd(NULL, - "211 %s Server SendBuf SentBytes SentMsgs RecvBuf " - "RecvBytes RecvMsgs ConnTime", source); - send_cmd(NULL, "211 %s %s %d %d %d %d %d %d %ld", source, - RemoteServer3, write_buffer_len(), total_written, - -1, read_buffer_len(), total_read, -1, - time(NULL) - start_time); + anope_cmd_211 + ("%s Server SendBuf SentBytes SentMsgs RecvBuf " + "RecvBytes RecvMsgs ConnTime", source); + anope_cmd_211("%s %s %d %d %d %d %d %d %ld", source, + RemoteServer3, write_buffer_len(), + total_written, -1, read_buffer_len(), + total_read, -1, time(NULL) - start_time); } } - send_cmd(NULL, "219 %s l :End of /STATS report.", source); + anope_cmd_219(source, NULL); break; case 'o': case 'O': /* Check whether the user is an operator */ u = finduser(source); if (u && !is_oper(u) && HideStatsO) { - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, - *av[0]); + anope_cmd_219(source, av[0]); } else { for (i = 0; i < RootNumber; i++) - send_cmd(NULL, "243 %s O * * %s Root 0", source, - ServicesRoots[i]); + anope_cmd_243("%s O * * %s Root 0", source, + ServicesRoots[i]); for (i = 0; i < servadmins.count && (nc = servadmins.list[i]); i++) - send_cmd(NULL, "243 %s O * * %s Admin 0", source, - nc->display); + anope_cmd_243("%s O * * %s Admin 0", source, nc->display); for (i = 0; i < servopers.count && (nc = servopers.list[i]); i++) - send_cmd(NULL, "243 %s O * * %s Oper 0", source, - nc->display); + anope_cmd_243("%s O * * %s Oper 0", source, nc->display); - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, - *av[0]); + anope_cmd_219(source, av[0]); } break; case 'u':{ int uptime = time(NULL) - start_time; - send_cmd(NULL, "242 %s :Services up %d day%s, %02d:%02d:%02d", - source, uptime / 86400, - (uptime / 86400 == 1) ? "" : "s", - (uptime / 3600) % 24, (uptime / 60) % 60, - uptime % 60); - send_cmd(NULL, - "250 %s :Current users: %d (%d ops); maximum %d", - source, usercnt, opcnt, maxusercnt); - send_cmd(NULL, "219 %s u :End of /STATS report.", source); + anope_cmd_242("%s :Services up %d day%s, %02d:%02d:%02d", + source, uptime / 86400, + (uptime / 86400 == 1) ? "" : "s", + (uptime / 3600) % 24, (uptime / 60) % 60, + uptime % 60); + anope_cmd_250("%s :Current users: %d (%d ops); maximum %d", + source, usercnt, opcnt, maxusercnt); + anope_cmd_219(source, NULL); break; } /* case 'u' */ default: - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, *av[0]); + anope_cmd_219(source, av[0]); break; } return MOD_CONT; @@ -1000,283 +314,76 @@ static int m_stats(char *source, int ac, char **av) /*************************************************************************/ -static int m_time(char *source, int ac, char **av) -{ - time_t t; - struct tm *tm; - char buf[64]; - - time(&t); - tm = localtime(&t); - strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm); - send_cmd(NULL, "391 %s %s :%s", source, ServerName, buf); - return MOD_CONT; -} - -/*************************************************************************/ -#ifdef IRC_HYBRID -static int m_topic(char *source, int ac, char **av) +int m_version(char *source, int ac, char **av) { - if (ac == 4) { - do_topic(source, ac, av); - } else { - Channel *c = findchan(av[0]); - time_t topic_time = time(NULL); - - if (!c) { - alog("channel: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - return MOD_CONT; - } - - if (check_topiclock(c, topic_time)) - return MOD_CONT; - - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 1 && *av[1]) - c->topic = sstrdup(av[1]); - - strscpy(c->topic_setter, source, sizeof(c->topic_setter)); - c->topic_time = topic_time; - - record_topic(av[0]); + if (source) { + anope_cmd_351(source); } return MOD_CONT; } -#else -/*************************************************************************/ -static int m_topic(char *source, int ac, char **av) -{ - if (ac != 4) - return MOD_CONT; - do_topic(source, ac, av); - return MOD_CONT; -} -#endif -/*************************************************************************/ -int m_version(char *source, int ac, char **av) -{ - if (source) - send_cmd(ServerName, "351 %s Anope-%s %s :%s -- %s", - source, version_number, ServerName, version_flags, - version_build); - return MOD_CONT; -} /*************************************************************************/ -int m_whois(char *source, int ac, char **av) +int m_whois(char *source, char *who) { BotInfo *bi; const char *clientdesc; - if (source && ac >= 1) { - if (stricmp(av[0], s_NickServ) == 0) + if (source && who) { + if (stricmp(who, s_NickServ) == 0) clientdesc = desc_NickServ; - else if (stricmp(av[0], s_ChanServ) == 0) + else if (stricmp(who, s_ChanServ) == 0) clientdesc = desc_ChanServ; - else if (stricmp(av[0], s_MemoServ) == 0) + else if (stricmp(who, s_MemoServ) == 0) clientdesc = desc_MemoServ; - else if (s_BotServ && stricmp(av[0], s_BotServ) == 0) + else if (s_BotServ && stricmp(who, s_BotServ) == 0) clientdesc = desc_BotServ; - else if (s_HostServ && stricmp(av[0], s_HostServ) == 0) + else if (s_HostServ && stricmp(who, s_HostServ) == 0) clientdesc = desc_HostServ; - else if (stricmp(av[0], s_HelpServ) == 0) + else if (stricmp(who, s_HelpServ) == 0) clientdesc = desc_HelpServ; - else if (stricmp(av[0], s_OperServ) == 0) + else if (stricmp(who, s_OperServ) == 0) clientdesc = desc_OperServ; - else if (stricmp(av[0], s_GlobalNoticer) == 0) + else if (stricmp(who, s_GlobalNoticer) == 0) clientdesc = desc_GlobalNoticer; - else if (s_DevNull && stricmp(av[0], s_DevNull) == 0) + else if (s_DevNull && stricmp(who, s_DevNull) == 0) clientdesc = desc_DevNull; - else if (s_BotServ && (bi = findbot(av[0]))) { + else if (s_BotServ && (bi = findbot(who))) { /* Bots are handled separately */ - send_cmd(ServerName, "311 %s %s %s %s * :%s", source, bi->nick, - bi->user, bi->host, bi->real); - send_cmd(ServerName, "307 %s :%s is a registered nick", source, - bi->nick); - send_cmd(ServerName, "312 %s %s %s :%s", source, bi->nick, - ServerName, ServerDesc); - send_cmd(ServerName, - "317 %s %s %ld %ld :seconds idle, signon time", - source, bi->nick, time(NULL) - bi->lastmsg, - start_time); - send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, - bi->nick); + anope_cmd_311("%s %s %s %s * :%s", source, bi->nick, + bi->user, bi->host, bi->real); + anope_cmd_307("%s :%s is a registered nick", source, bi->nick); + anope_cmd_312("%s %s %s :%s", source, bi->nick, ServerName, + ServerDesc); + anope_cmd_317("%s %s %ld %ld :seconds idle, signon time", + source, bi->nick, time(NULL) - bi->lastmsg, + start_time); + anope_cmd_318(source, bi->nick); return MOD_CONT; } else { - send_cmd(ServerName, "401 %s %s :No such service.", source, - av[0]); + anope_cmd_401(source, who); return MOD_CONT; } - send_cmd(ServerName, "311 %s %s %s %s * :%s", source, av[0], - ServiceUser, ServiceHost, clientdesc); - send_cmd(ServerName, "312 %s %s %s :%s", source, av[0], ServerName, - ServerDesc); - send_cmd(ServerName, - "317 %s %s %ld %ld :seconds idle, signon time", source, - av[0], time(NULL) - start_time, start_time); - send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, - av[0]); - } - return MOD_CONT; -} - -/*************************************************************************/ - -#ifdef IRC_VIAGRA -int m_vs(char *source, int ac, char **av) -{ - User *u; - - if (ac != 2) - return MOD_CONT; - - u = finduser(av[0]); - if (!u) { - alog("user: VS for nonexistent user %s", av[0]); - return MOD_CONT; + anope_cmd_311("%s %s %s %s * :%s", source, who, + ServiceUser, ServiceHost, clientdesc); + anope_cmd_219(source, who); + anope_cmd_317("%s %s %ld %ld :seconds idle, signon time", source, + who, time(NULL) - start_time, start_time); + anope_cmd_318(source, who); } - - change_user_host(u, av[1]); return MOD_CONT; - } -#endif -/*************************************************************************/ /* *INDENT-OFF* */ void moduleAddMsgs(void) { Message *m; - m = createMessage("401", NULL); addCoreMessage(IRCD,m); - m = createMessage("436", m_nickcoll); addCoreMessage(IRCD,m); - m = createMessage("AWAY", m_away); addCoreMessage(IRCD,m); - m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); - m = createMessage("JOIN", m_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", m_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", m_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", m_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", m_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", m_nick); addCoreMessage(IRCD,m); - m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); - m = createMessage("PART", m_part); addCoreMessage(IRCD,m); - m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); - m = createMessage("PING", m_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", m_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", m_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", m_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", m_squit); addCoreMessage(IRCD,m); m = createMessage("STATS", m_stats); addCoreMessage(IRCD,m); m = createMessage("TIME", m_time); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", m_topic); addCoreMessage(IRCD,m); - m = createMessage("USER", NULL); addCoreMessage(IRCD,m); m = createMessage("VERSION", m_version); addCoreMessage(IRCD,m); - m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", m_whois); addCoreMessage(IRCD,m); - - /* DALnet specific messages */ - m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); - m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); - m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); - m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); - m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); - m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); - m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); - m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); - m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); - m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); - m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); - - /* DreamForge specific messages */ -#ifdef IRC_DREAMFORGE - m = createMessage("PROTOCTL", NULL); addCoreMessage(IRCD,m); -#endif - - /* Bahamut specific messages */ -#ifdef IRC_BAHAMUT - m = createMessage("CAPAB", m_capab); addCoreMessage(IRCD,m); - m = createMessage("CS", m_cs); addCoreMessage(IRCD,m); - m = createMessage("HS", m_hs); addCoreMessage(IRCD,m); - m = createMessage("MS", m_ms); addCoreMessage(IRCD,m); - m = createMessage("NS", m_ns); addCoreMessage(IRCD,m); - m = createMessage("OS", m_os); addCoreMessage(IRCD,m); - m = createMessage("RS", NULL); addCoreMessage(IRCD,m); - m = createMessage("SGLINE", NULL); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", m_sjoin); addCoreMessage(IRCD,m); - m = createMessage("SS", NULL); addCoreMessage(IRCD,m); - m = createMessage("SVINFO", NULL); addCoreMessage(IRCD,m); - m = createMessage("SZLINE", NULL); addCoreMessage(IRCD,m); - m = createMessage("UNSGLINE", NULL); addCoreMessage(IRCD,m); - m = createMessage("UNSZLINE", NULL); addCoreMessage(IRCD,m); -#endif - /* Hyb Messages */ -#ifdef IRC_HYBRID - m = createMessage("CAPAB", NULL); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", m_sjoin); addCoreMessage(IRCD,m); - m = createMessage("SVINFO", NULL); addCoreMessage(IRCD,m); -#endif - - -#ifdef IRC_ULTIMATE - m = createMessage("CHGHOST", m_chghost); addCoreMessage(IRCD,m); - m = createMessage("CHGIDENT", m_chgident); addCoreMessage(IRCD,m); - m = createMessage("CHGNAME", m_chgname); addCoreMessage(IRCD,m); - m = createMessage("NETINFO", NULL); addCoreMessage(IRCD,m); - m = createMessage("SETHOST", m_sethost); addCoreMessage(IRCD,m); - m = createMessage("SETIDENT", m_setident); addCoreMessage(IRCD,m); - m = createMessage("SETNAME", m_setname); addCoreMessage(IRCD,m); - m = createMessage("VCTRL", NULL); addCoreMessage(IRCD,m); -#endif - -#ifdef IRC_PTLINK - m = createMessage("NEWMASK" , m_newmask); addCoreMessage(IRCD,m); - m = createMessage("CAPAB" , NULL); addCoreMessage(IRCD,m); - m = createMessage("SVINFO" , NULL); addCoreMessage(IRCD,m); - m = createMessage("SVSINFO" , NULL); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", m_sjoin); addCoreMessage(IRCD,m); -#endif - -#ifdef IRC_UNREAL - m = createMessage("CHGHOST", m_chghost); addCoreMessage(IRCD,m); - m = createMessage("CHGIDENT", m_chgident); addCoreMessage(IRCD,m); - m = createMessage("CHGNAME", m_chgname); addCoreMessage(IRCD,m); - m = createMessage("NETINFO", NULL); addCoreMessage(IRCD,m); - m = createMessage("SETHOST", m_sethost); addCoreMessage(IRCD,m); - m = createMessage("SETIDENT", m_setident); addCoreMessage(IRCD,m); - m = createMessage("SETNAME", m_setname); addCoreMessage(IRCD,m); -#endif -#ifdef IRC_VIAGRA - m = createMessage("CHGHOST", m_chghost); addCoreMessage(IRCD,m); - m = createMessage("CHGIDENT", m_chgident); addCoreMessage(IRCD,m); - m = createMessage("CHGNAME", m_chgname); addCoreMessage(IRCD,m); - m = createMessage("SETHOST", m_sethost); addCoreMessage(IRCD,m); - m = createMessage("SETIDENT", m_setident); addCoreMessage(IRCD,m); - m = createMessage("SETNAME", m_setname); addCoreMessage(IRCD,m); - m = createMessage("VS", m_vs); addCoreMessage(IRCD,m); -#endif -#ifdef IRC_ULTIMATE3 - m = createMessage("SETHOST", m_sethost); addCoreMessage(IRCD,m); - m = createMessage("NETINFO", NULL); addCoreMessage(IRCD,m); - m = createMessage("GCONNECT", NULL); addCoreMessage(IRCD,m); - m = createMessage("NETGLOBAL", NULL); addCoreMessage(IRCD,m); - m = createMessage("CHATOPS", NULL); addCoreMessage(IRCD,m); - m = createMessage("NETCTRL", NULL); addCoreMessage(IRCD,m); - m = createMessage("CLIENT", m_client); addCoreMessage(IRCD,m); - m = createMessage("SMODE", NULL); addCoreMessage(IRCD,m); -#endif -#ifdef IRC_RAGE2 - m = createMessage("SNICK", m_snick); addCoreMessage(IRCD,m); - m = createMessage("VHOST", m_vhost); addCoreMessage(IRCD,m); -#endif } -/* *INDENT-ON* */ /*************************************************************************/ Message *find_message(const char *name) diff --git a/src/misc.c b/src/misc.c index 922f0e05d..c72402f14 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1,4 +1,5 @@ /* Miscellaneous routines. +/* Miscellaneous routines. * * (C) 2003 Anope Team * Contact us at info@anope.org @@ -709,3 +710,4 @@ int nickIsServices(char *nick) return found; } + diff --git a/src/modules.c b/src/modules.c index 2a78a7af7..26c4651d7 100644 --- a/src/modules.c +++ b/src/modules.c @@ -1,4 +1,5 @@ /* Modular support +/* Modular support * * (C) 2003 Anope Team * Contact us at info@anope.org @@ -370,7 +371,7 @@ int loadModule(Module * m, User * u) } if (u) { - wallops(s_OperServ, "%s loaded module %s", u->nick, m->name); + anope_cmd_global(s_OperServ, "%s loaded module %s", u->nick, m->name); notice_lang(s_OperServ, u, OPER_MODULE_LOADED, m->name); } addModule(m); @@ -416,7 +417,7 @@ int unloadModule(Module * m, User * u) return MOD_ERR_NOUNLOAD; } else { if (u) { - wallops(s_OperServ, "%s unloaded module %s", u->nick, m->name); + anope_cmd_global(s_OperServ, "%s unloaded module %s", u->nick, m->name); notice_lang(s_OperServ, u, OPER_MODULE_UNLOADED, m->name); } delModule(m); @@ -2023,3 +2024,4 @@ void moduleCleanStruct(ModuleData * moduleData[]) } /* EOF */ + diff --git a/src/modules/ircd_catserv.c b/src/modules/ircd_catserv.c index 436b18dcc..05a3f997d 100644 --- a/src/modules/ircd_catserv.c +++ b/src/modules/ircd_catserv.c @@ -76,7 +76,7 @@ int my_privmsg(char *source, int ac, char **av) void addClient(char *nick, char *realname) { - NEWNICK(nick, "catserv", "meow.meow.land", realname, "+", 1); + anope_cmd_bot_nick(nick, "catserv", "meow.meow.land", realname, "+"); } void delClient(void) diff --git a/src/mysql.c b/src/mysql.c index 1b83502c2..ab3aaa14e 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -1,4 +1,5 @@ /* MySQL functions. +/* MySQL functions. * * (C) 2003 Anope Team * Contact us at info@anope.org @@ -418,16 +419,8 @@ void db_mysql_save_cs_info(ChannelInfo * ci) ciforbidby = db_mysql_quote(ci->forbidby); ciforbidreason = db_mysql_quote(ci->forbidreason); cimlock_key = db_mysql_quote(ci->mlock_key); -#ifdef HAS_FMODE cimlock_flood = db_mysql_quote(ci->mlock_flood); -#else - cimlock_flood = NULL; -#endif -#ifdef HAS_LMODE cimlock_redirect = db_mysql_quote(ci->mlock_redirect); -#else - cimlock_redirect = NULL; -#endif cientrymsg = db_mysql_quote(ci->entry_message); cibotnick = ci->bi ? db_mysql_quote(ci->bi->nick) : ""; @@ -455,16 +448,8 @@ void db_mysql_save_cs_info(ChannelInfo * ci) (int) ci->accesscount, (int) ci->akickcount, (int) ci->mlock_on, (int) ci->mlock_off, (int) ci->mlock_limit, cimlock_key, -#ifdef HAS_FMODE cimlock_flood, -#else - "", -#endif -#ifdef HAS_LMODE cimlock_redirect, -#else - "", -#endif cientrymsg, (int) ci->memos.memomax, cibotnick, @@ -502,16 +487,8 @@ void db_mysql_save_cs_info(ChannelInfo * ci) (int) ci->accesscount, (int) ci->akickcount, (int) ci->mlock_on, (int) ci->mlock_off, (int) ci->mlock_limit, cimlock_key, -#ifdef HAS_FMODE cimlock_flood, -#else - "", -#endif -#ifdef HAS_LMODE cimlock_redirect, -#else - "", -#endif cientrymsg, cibotnick, (int) ci->botflags, @@ -1330,13 +1307,8 @@ void db_mysql_load_cs_dbase(void) ci->mlock_off = atoi(mysql_row[19]); ci->mlock_limit = atoi(mysql_row[20]); ci->mlock_key = sstrdup(mysql_row[21]); -#ifdef HAS_FMODE ci->mlock_flood = sstrdup(mysql_row[22]); -#endif - -#ifdef HAS_LMODE ci->mlock_redirect = sstrdup(mysql_row[23]); -#endif ci->memos.memomax = atoi(mysql_row[25]); snprintf(sqlcmd, MAX_SQL_BUF, "SELECT `number`,`flags`,`time`,`sender`,`text` FROM `anope_ms_info` WHERE `receiver` = '%s'", @@ -1636,3 +1608,4 @@ void db_mysql_load_ns_dbase(void) } } } + diff --git a/src/news.c b/src/news.c index 530a4ae35..cce868ec2 100644 --- a/src/news.c +++ b/src/news.c @@ -1,4 +1,5 @@ /* News functions. +/* News functions. * * (C) 2003 Anope Team * Contact us at info@anope.org @@ -96,7 +97,6 @@ struct newsmsgs msgarray[] = { }; /* *INDENT-ON* */ - static int *findmsgs(int16 type, char **typename) { int i; @@ -209,7 +209,7 @@ void load_news() restore_db(f); \ log_perror("Write error on %s", NewsDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - wallops(NULL, "Write error on %s: %s", NewsDBName, \ + anope_cmd_global(NULL, "Write error on %s: %s", NewsDBName, \ strerror(errno)); \ lastwarn = time(NULL); \ } \ diff --git a/src/nickserv.c b/src/nickserv.c index ec10e4fe0..3342f635b 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -857,7 +857,7 @@ void load_ns_dbase(void) restore_db(f); \ log_perror("Write error on %s", NickDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - wallops(NULL, "Write error on %s: %s", NickDBName, \ + anope_cmd_global(NULL, "Write error on %s: %s", NickDBName, \ strerror(errno)); \ lastwarn = time(NULL); \ } \ @@ -1070,8 +1070,10 @@ int validate_user(User * u) if (na->last_usermask) free(na->last_usermask); na->last_usermask = - scalloc(strlen(GetIdent(u)) + strlen(GetHost(u)) + 2, 1); - sprintf(na->last_usermask, "%s@%s", GetIdent(u), GetHost(u)); + 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); @@ -1112,25 +1114,36 @@ void cancel_user(User * u) if (na) { if (na->status & NS_GUESTED) { -#ifdef HAS_SVSHOLD - if (UseSVSHOLD) { - send_cmd(ServerName, "SVSHOLD %s %d :%s", na->nick, - NSReleaseTimeout, - "Being held for registered user"); + if (ircd->svshold) { + if (UseSVSHOLD) { + anope_cmd_svshold(na->nick); + } else { + if (ircd->svsnick) { + anope_cmd_guest_nick(u->nick, NSEnforcerUser, + NSEnforcerHost, + "Services Enforcer", "+"); + add_ns_timeout(na, TO_RELEASE, NSReleaseTimeout); + } else { + anope_cmd_svskill(s_NickServ, u->nick, + "Killing to enforce nick"); + } + } } else { -#endif - NEWNICK(u->nick, NSEnforcerUser, NSEnforcerHost, - "Services Enforcer", "+", 0); - add_ns_timeout(na, TO_RELEASE, NSReleaseTimeout); -#ifdef HAS_SVSHOLD + if (ircd->svsnick) { + anope_cmd_guest_nick(u->nick, NSEnforcerUser, + NSEnforcerHost, + "Services Enforcer", "+"); + add_ns_timeout(na, TO_RELEASE, NSReleaseTimeout); + } else { + anope_cmd_svskill(s_NickServ, u->nick, + "Killing to enforce nick"); + } } -#endif na->status &= ~NS_TEMPORARY; na->status |= NS_KILL_HELD; } else { na->status &= ~NS_TEMPORARY; } - del_ns_timeout(na, TO_COLLIDE); } } @@ -1275,39 +1288,34 @@ static int is_on_access(User * u, NickCore * nc) { int i; char *buf; -#ifdef HAS_VHOST char *buf2 = NULL; -#endif if (nc->accesscount == 0) return 0; buf = scalloc(strlen(u->username) + strlen(u->host) + 2, 1); sprintf(buf, "%s@%s", u->username, u->host); -#ifdef HAS_VHOST - if (u->vhost) { - buf2 = scalloc(strlen(u->username) + strlen(u->vhost) + 2, 1); - sprintf(buf2, "%s@%s", u->username, u->vhost); + if (ircd->vhost) { + if (u->vhost) { + buf2 = scalloc(strlen(u->username) + strlen(u->vhost) + 2, 1); + sprintf(buf2, "%s@%s", u->username, u->vhost); + } } -#endif for (i = 0; i < nc->accesscount; i++) { if (match_wild_nocase(nc->access[i], buf) -#ifdef HAS_VHOST - || (u->vhost ? match_wild_nocase(nc->access[i], buf2) : 0) -#endif - ) { + || (u->vhost ? match_wild_nocase(nc->access[i], buf2) : 0)) { free(buf); -#ifdef HAS_VHOST - free(buf2); -#endif + if (ircd->vhost) { + free(buf2); + } return 1; } } free(buf); -#ifdef HAS_VHOST - free(buf2); -#endif + if (ircd->vhost) { + free(buf2); + } return 0; } @@ -1587,12 +1595,7 @@ int delnick(NickAlias * na) if (na->u) { na->u->na = NULL; -#ifndef IRC_PTLINK - change_user_mode(na->u, "-r+d", "1"); -#else - change_user_mode(na->u, "-r", NULL); -#endif - + common_svsmode(na->u, ircd->modeonunreg, "1"); } @@ -1661,9 +1664,7 @@ int delnick(NickAlias * na) static void collide(NickAlias * na, int from_timeout) { -#ifndef IRC_HYBRID char guestnick[NICKMAX]; -#endif if (!from_timeout) del_ns_timeout(na, TO_COLLIDE); @@ -1676,15 +1677,16 @@ static void collide(NickAlias * na, int from_timeout) * --Certus */ -#ifdef IRC_HYBRID - kill_user(s_NickServ, na->nick, "Services nickname-enforcer kill"); -#else - snprintf(guestnick, sizeof(guestnick), "%s%d", NSGuestNickPrefix, - guestnum++); - notice_lang(s_NickServ, na->u, FORCENICKCHANGE_CHANGING, guestnick); - send_cmd(NULL, "SVSNICK %s %s :%ld", na->nick, guestnick, time(NULL)); - na->status |= NS_GUESTED; -#endif + if (ircd->svsnick) { + snprintf(guestnick, sizeof(guestnick), "%s%d", NSGuestNickPrefix, + guestnum++); + notice_lang(s_NickServ, na->u, FORCENICKCHANGE_CHANGING, + guestnick); + anope_cmd_svsnick(na->nick, guestnick, time(NULL)); + na->status |= NS_GUESTED; + } else { + kill_user(s_NickServ, na->nick, "Services nickname-enforcer kill"); + } } /*************************************************************************/ @@ -1695,12 +1697,15 @@ static void release(NickAlias * na, int from_timeout) { if (!from_timeout) del_ns_timeout(na, TO_RELEASE); -#ifdef HAS_SVSHOLD - if (UseSVSHOLD) - send_cmd(ServerName, "SVSHOLD %s 0", na->nick); - else -#endif - send_cmd(na->nick, "QUIT"); + if (ircd->svshold) { + if (UseSVSHOLD) { + anope_cmd_relase_svshold(na->nick); + } else { + anope_cmd_quit(na->nick, NULL); + } + } else { + anope_cmd_quit(na->nick, NULL); + } na->status &= ~NS_KILL_HELD; } @@ -1959,7 +1964,7 @@ static int do_register(User * u) } 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, GetHost(u), u->nick); + s_NickServ, u->username, common_get_vhost(u), u->nick); notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); } else { notice_lang(s_NickServ, u, NICK_ALREADY_REGISTERED, u->nick); @@ -2138,9 +2143,7 @@ static int do_confirm(User * u) if (na) { int i; -#if !defined(IRC_PTLINK) char tsbuf[16]; -#endif #ifdef USE_ENCRYPTION len = strlen(pass); @@ -2173,8 +2176,10 @@ static int do_confirm(User * u) na->last_realname = sstrdup("unknown"); } else { na->last_usermask = - scalloc(strlen(GetIdent(u)) + strlen(GetHost(u)) + 2, 1); - sprintf(na->last_usermask, "%s@%s", GetIdent(u), GetHost(u)); + 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); @@ -2188,7 +2193,7 @@ static int do_confirm(User * u) u->na = na; na->u = u; alog("%s: '%s' registered by %s@%s (e-mail: %s)", s_NickServ, - u->nick, u->username, GetHost(u), + u->nick, u->username, common_get_vhost(u), (email ? email : "none")); notice_lang(s_NickServ, u, NICK_REGISTERED, u->nick, na->nc->access[0]); @@ -2196,12 +2201,13 @@ static int do_confirm(User * u) notice_lang(s_NickServ, u, NICK_PASSWORD_IS, na->nc->pass); #endif u->lastnickreg = time(NULL); -#if !defined(IRC_PTLINK) - snprintf(tsbuf, sizeof(tsbuf), "%lu", u->timestamp); - change_user_mode(u, "+rd", tsbuf); -#else - change_user_mode(u, "+r", NULL); -#endif + if (ircd->modeonreg) { + if (ircd->tsonmode) { + common_svsmode(u, ircd->modeonreg, tsbuf); + } else { + common_svsmode(u, ircd->modeonreg, NULL); + } + } } else { notice_lang(s_NickServ, u, NICK_FORCE_REG, nr->nick); @@ -2229,9 +2235,7 @@ static int do_group(User * u) char *nick = strtok(NULL, " "); char *pass = strtok(NULL, " "); int i; -#if !defined(IRC_PTLINK) char tsbuf[16]; -#endif if (NSEmailReg && (findrequestnick(u->nick))) { notice_lang(s_NickServ, u, NICK_REQUESTED); @@ -2253,7 +2257,7 @@ static int do_group(User * u) 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, GetHost(u), u->nick); + s_NickServ, u->username, common_get_vhost(u), u->nick); notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u->nick); } else if (u->na && NSNoGroupChange) { notice_lang(s_NickServ, u, NICK_GROUP_CHANGE_DISABLED, s_NickServ); @@ -2271,7 +2275,7 @@ static int do_group(User * u) 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, GetHost(u)); + s_NickServ, u->nick, u->username, common_get_vhost(u)); notice_lang(s_NickServ, u, PASSWORD_INCORRECT); bad_password(u); } else { @@ -2297,8 +2301,10 @@ static int do_group(User * u) if (na) { na->last_usermask = - scalloc(strlen(GetIdent(u)) + strlen(GetHost(u)) + 2, 1); - sprintf(na->last_usermask, "%s@%s", GetIdent(u), GetHost(u)); + 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 = NS_IDENTIFIED | NS_RECOGNIZED; @@ -2325,16 +2331,18 @@ static int do_group(User * u) rdb_close(); } #endif - alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", s_NickServ, u->nick, u->username, GetHost(u), u->nick, target->nick, target->nc->display, (target->nc->email ? target->nc->email : "none")); + alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", s_NickServ, u->nick, u->username, common_get_vhost(u), 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); -#if !defined(IRC_PTLINK) snprintf(tsbuf, sizeof(tsbuf), "%lu", u->timestamp); - change_user_mode(u, "+rd", tsbuf); -#else - change_user_mode(u, "+r", NULL); -#endif + if (ircd->modeonreg) { + if (ircd->tsonmode) { + common_svsmode(u, ircd->modeonreg, tsbuf); + } else { + common_svsmode(u, ircd->modeonreg, NULL); + } + } check_memos(u); } else { @@ -2363,9 +2371,9 @@ static int do_nickupdate(User * u) na->last_realname = sstrdup(u->realname); na->status |= NS_IDENTIFIED; na->last_seen = time(NULL); -#ifdef HAS_VHOST - do_on_id(u); -#endif + if (ircd->vhost) { + do_on_id(u); + } notice_lang(s_NickServ, u, NICK_UPDATE_SUCCESS, s_NickServ); } return MOD_CONT; @@ -2379,9 +2387,7 @@ static int do_identify(User * u) NickAlias *na; NickRequest *nr; int res; -#if !defined(IRC_PTLINK) char tsbuf[16]; -#endif if (!pass) { syntax_error(s_NickServ, u, "IDENTIFY", NICK_IDENTIFY_SYNTAX); @@ -2395,7 +2401,7 @@ static int do_identify(User * u) notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); } else if (!(res = check_password(pass, na->nc->pass))) { alog("%s: Failed IDENTIFY for %s!%s@%s", s_NickServ, u->nick, - u->username, GetHost(u)); + u->username, common_get_vhost(u)); notice_lang(s_NickServ, u, PASSWORD_INCORRECT); bad_password(u); } else if (res == -1) { @@ -2407,8 +2413,10 @@ static int do_identify(User * u) if (na->last_usermask) free(na->last_usermask); na->last_usermask = - scalloc(strlen(GetIdent(u)) + strlen(GetHost(u)) + 2, 1); - sprintf(na->last_usermask, "%s@%s", GetIdent(u), GetHost(u)); + 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); @@ -2416,21 +2424,22 @@ static int do_identify(User * u) na->status |= NS_IDENTIFIED; na->last_seen = time(NULL); - -#ifndef IRC_PTLINK snprintf(tsbuf, sizeof(tsbuf), "%lu", u->timestamp); - change_user_mode(u, "+rd", tsbuf); -#else - change_user_mode(u, "+r", ""); -#endif /* IRC_PTLINK */ + if (ircd->modeonreg) { + if (ircd->tsonmode) { + common_svsmode(u, ircd->modeonreg, tsbuf); + } else { + common_svsmode(u, ircd->modeonreg, ""); + } + } alog("%s: %s!%s@%s identified for nick %s", s_NickServ, u->nick, - u->username, GetHost(u), u->nick); + u->username, common_get_vhost(u), u->nick); notice_lang(s_NickServ, u, NICK_IDENTIFY_SUCCEEDED); -#ifdef HAS_VHOST - do_on_id(u); -#endif + if (ircd->vhost) { + do_on_id(u); + } if (NSModeOnID) { do_setmodes(u); } @@ -2462,19 +2471,14 @@ int should_mode_change(int16 status, int16 mode) if (status & CUS_OP) { return 0; } -#ifdef HAS_HALFOP if (status & CUS_HALFOP) { return 0; } -#endif if (status & CUS_VOICE) { return 0; } return 1; break; -#ifdef HAS_HALFOP - - case CUS_HALFOP: if (status & CUS_OP) { return 0; @@ -2484,44 +2488,20 @@ int should_mode_change(int16 status, int16 mode) } return 1; break; -#endif -#ifdef IRC_UNREAL case CUS_OWNER: - if (status & CUS_OWNER) { - return 0; - } - break; - case CUS_PROTECT: - if (status & CUS_OWNER) { - return 0; - } - if (status & CUS_PROTECT) { - return 0; - } - break; -#endif -#ifdef IRC_VIAGRA - case CUS_OWNER: - if (status & CUS_OWNER) { - return 0; - } - break; - case CUS_PROTECT: - if (status & CUS_OWNER) { - return 0; - } - if (status & CUS_PROTECT) { - return 0; + if (ircd->owner) { + if (status & CUS_OWNER) { + return 0; + } } break; -#endif -#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) case CUS_PROTECT: - if (status & CUS_PROTECT) { - return 0; + if (ircd->protect) { + if (status & CUS_PROTECT) { + return 0; + } } break; -#endif } return 1; } @@ -2536,30 +2516,22 @@ static int do_setmodes(User * u) for (uc = u->chans; uc; uc = uc->next) { if ((c = uc->chan)) { chan = c->name; -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) - if (should_mode_change(uc->status, CUS_OWNER) + if (ircd->owner && should_mode_change(uc->status, CUS_OWNER) && check_should_owner(u, chan)) { chan_set_user_status(c, u, CUS_OWNER); - } else -#endif -#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) || defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) || defined(IRC_PTLINK) - if (should_mode_change(uc->status, CUS_PROTECT) - && check_should_protect(u, chan)) { + } else if (ircd->protect + && should_mode_change(uc->status, CUS_PROTECT) + && check_should_protect(u, chan)) { chan_set_user_status(c, u, CUS_PROTECT); - } else -#endif - if (should_mode_change(uc->status, CUS_OP) - && check_should_op(u, chan)) { + } else if (should_mode_change(uc->status, CUS_OP) + && check_should_op(u, chan)) { chan_set_user_status(c, u, CUS_OP); - } else -#ifdef HAS_HALFOP - if (should_mode_change(uc->status, CUS_HALFOP) - && check_should_halfop(u, chan)) { + } else if (ircd->halfop + && should_mode_change(uc->status, CUS_HALFOP) + && check_should_halfop(u, chan)) { chan_set_user_status(c, u, CUS_HALFOP); - } else -#endif - if (should_mode_change(uc->status, CUS_VOICE) - && check_should_voice(u, chan)) { + } else if (should_mode_change(uc->status, CUS_VOICE) + && check_should_voice(u, chan)) { chan_set_user_status(c, u, CUS_VOICE); } } @@ -2567,7 +2539,6 @@ static int do_setmodes(User * u) return MOD_CONT; } - /*************************************************************************/ static int do_logout(User * u) @@ -2599,11 +2570,11 @@ static int do_logout(User * u) u2->na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED); } - change_user_mode(u2, "-r+d", "1"); + common_svsmode(u2, "-r+d", "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, GetHost(u), u2->nick); + u->username, common_get_vhost(u), u2->nick); if (nick) notice_lang(s_NickServ, u, NICK_LOGOUT_X_SUCCEEDED, nick); @@ -2638,10 +2609,11 @@ static int do_drop(User * u) if (readonly) notice_lang(s_NickServ, u, READ_ONLY_MODE); if (WallDrop) - wallops(s_NickServ, "\2%s\2 used DROP on \2%s\2", - u->nick, nick); + 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, GetHost(u), + s_NickServ, u->nick, u->username, common_get_vhost(u), nr->nick, nr->email); delnickrequest(nr); notice_lang(s_NickServ, u, NICK_X_DROPPED, nick); @@ -2667,14 +2639,15 @@ static int do_drop(User * u) notice_lang(s_NickServ, u, READ_ONLY_MODE); alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", - s_NickServ, u->nick, u->username, GetHost(u), na->nick, - na->nc->display, (na->nc->email ? na->nc->email : "none")); + s_NickServ, u->nick, u->username, common_get_vhost(u), + na->nick, na->nc->display, + (na->nc->email ? na->nc->email : "none")); delnick(na); if (!is_mine) { if (WallDrop) - wallops(s_NickServ, "\2%s\2 used DROP on \2%s\2", u->nick, - nick); + 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) @@ -2831,14 +2804,14 @@ static int do_set_password(User * u, NickCore * nc, char *param) #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, GetHost(u), nc->display, (nc->email ? nc->email : "none")); + alog("%s: %s!%s@%s used SET PASSWORD as Services admin on %s (e-mail: %s)", s_NickServ, u->nick, u->username, common_get_vhost(u), nc->display, (nc->email ? nc->email : "none")); if (WallSetpass) - wallops(s_NickServ, - "\2%s\2 used SET PASSWORD as Services admin on \2%s\2", - u->nick, nc->display); + 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, GetHost(u), + u->nick, u->username, common_get_vhost(u), (nc->email ? nc->email : "none")); } return MOD_CONT; @@ -2896,7 +2869,7 @@ static int do_set_email(User * u, NickCore * nc, char *param) } alog("%s: %s!%s@%s (e-mail: %s) changed its e-mail to %s.", s_NickServ, - u->nick, u->username, GetHost(u), + u->nick, u->username, common_get_vhost(u), (nc->email ? nc->email : "none"), (param ? param : "none")); if (nc->email) @@ -3254,10 +3227,7 @@ static int do_info(User * u) NickAlias *na; NickRequest *nr = NULL; int is_servadmin = is_services_admin(u); - -#ifdef HAS_VHOST char *vHost; -#endif if (!nick) { syntax_error(s_NickServ, u, "INFO", NICK_INFO_SYNTAX); @@ -3374,8 +3344,7 @@ static int do_info(User * u) notice_lang(s_NickServ, u, NICK_INFO_ICQ, na->nc->icq); if (show_hidden) { -#ifdef HAS_VHOST - if (s_HostServ) { + if (s_HostServ && ircd->vhost) { if (getvHost(na->nick) != NULL) { vHost = smalloc(strlen(getvHost(na->nick)) + 2); bzero(vHost, sizeof(vHost)); @@ -3385,7 +3354,6 @@ static int do_info(User * u) free(vHost); } } -#endif if (na->nc->greet) notice_lang(s_NickServ, u, NICK_INFO_GREET, na->nc->greet); @@ -3673,10 +3641,8 @@ static int do_alist(User * u) min_level = ACCESS_SOP; } else if (stricmp(lev, "AOP") == 0) { min_level = ACCESS_AOP; -#ifdef HAS_HALFOP } else if (stricmp(lev, "HOP") == 0) { min_level = ACCESS_HOP; -#endif } else if (stricmp(lev, "VOP") == 0) { min_level = ACCESS_VOP; } else { @@ -3771,7 +3737,8 @@ static int do_recover(User * u) 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, GetHost(u)); + s_NickServ, nick, u->nick, u->username, + common_get_vhost(u)); bad_password(u); } } @@ -3813,7 +3780,8 @@ static int do_release(User * u) 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, GetHost(u)); + s_NickServ, nick, u->nick, u->username, + common_get_vhost(u)); bad_password(u); } } @@ -3860,7 +3828,8 @@ static int do_ghost(User * u) 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, GetHost(u)); + s_NickServ, nick, u->nick, u->username, + common_get_vhost(u)); bad_password(u); } } @@ -3916,7 +3885,7 @@ static int do_getemail(User * u) return MOD_CONT; } alog("%s: %s!%s@%s used GETEMAIL on %s", s_NickServ, u->nick, - u->username, GetHost(u), email); + u->username, common_get_vhost(u), email); for (i = 0; i < 1024; i++) { for (nc = nclists[i]; nc; nc = nc->next) { if (nc->email) { @@ -3954,10 +3923,11 @@ static int do_getpass(User * u) } else if (!(na = findnick(nick))) { if ((nr = findrequestnick(nick))) { alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick, - u->username, GetHost(u), nick); + u->username, common_get_vhost(u), nick); if (WallGetpass) - wallops(s_NickServ, "\2%s\2 used GETPASS on \2%s\2", - u->nick, nick); + 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 { @@ -3972,10 +3942,10 @@ static int do_getpass(User * u) notice_lang(s_NickServ, u, PERMISSION_DENIED); } else { alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick, - u->username, GetHost(u), nick); + u->username, common_get_vhost(u), nick); if (WallGetpass) - wallops(s_NickServ, "\2%s\2 used GETPASS on \2%s\2", u->nick, - nick); + 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); } @@ -4031,7 +4001,7 @@ static int do_sendpass(User * u) MailEnd(mail); alog("%s: %s!%s@%s used SENDPASS on %s", s_NickServ, u->nick, - u->username, GetHost(u), nick); + u->username, common_get_vhost(u), nick); notice_lang(s_NickServ, u, NICK_SENDPASS_OK, nick); } #endif @@ -4081,8 +4051,8 @@ static int do_forbid(User * u) } if (WallForbid) - wallops(s_NickServ, "\2%s\2 used FORBID on \2%s\2", u->nick, - nick); + 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); diff --git a/src/operserv.c b/src/operserv.c index 6aeed2f65..1836f943e 100644 --- a/src/operserv.c +++ b/src/operserv.c @@ -53,16 +53,12 @@ static void free_operlist_entry(SList * slist, void *item); static int is_akill_entry_equal(SList * slist, void *item1, void *item2); static void free_akill_entry(SList * slist, void *item); -#ifdef IRC_BAHAMUT static int is_sgline_entry_equal(SList * slist, void *item1, void *item2); static void free_sgline_entry(SList * slist, void *item); -#endif static int is_sqline_entry_equal(SList * slist, void *item1, void *item2); static void free_sqline_entry(SList * slist, void *item); -#ifdef IRC_BAHAMUT static int is_szline_entry_equal(SList * slist, void *item1, void *item2); static void free_szline_entry(SList * slist, void *item); -#endif static int do_help(User * u); static int do_global(User * u); @@ -113,17 +109,9 @@ static int showModuleMsgLoaded(MessageHash * msgList, char *mod_name, User * u); #endif - -#ifdef USE_OSSVS -#ifndef IRC_HYBRID static int do_operumodes(User * u); -#endif static int do_svsnick(User * u); -#endif - -#if defined(IRC_UNREAL) && defined(USE_OSSVS) static int do_operoline(User * u); -#endif #ifdef DEBUG_COMMANDS static void send_clone_lists(User * u); @@ -141,16 +129,12 @@ SListOpts saopts = { SLISTF_SORT, &compare_adminlist_entries, NULL, &free_adminlist_entry }; -#ifdef IRC_BAHAMUT SListOpts sgopts = { 0, NULL, &is_sgline_entry_equal, &free_sgline_entry }; -#endif SListOpts soopts = { SLISTF_SORT, &compare_operlist_entries, NULL, &free_operlist_entry }; SListOpts sqopts = { SLISTF_SORT, NULL, &is_sqline_entry_equal, &free_sqline_entry }; -#ifdef IRC_BAHAMUT SListOpts szopts = { 0, NULL, &is_szline_entry_equal, &free_szline_entry }; -#endif /*************************************************************************/ /* *INDENT-OFF* */ @@ -190,19 +174,13 @@ void moduleAddOperServCmds(void) { 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 SUPERADMIN",NULL, NULL,OPER_HELP_SET_SUPERADMIN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c); -#ifdef USE_OSSVS c = createCommand("SVSNICK", do_svsnick, is_services_admin,OPER_HELP_SVSNICK, -1,-1,-1,-1); addCoreCommand(OPERSERV,c); -#ifndef IRC_HYBRID c = createCommand("UMODE", do_operumodes, is_services_admin,OPER_HELP_UMODE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c); -#endif -#endif 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); -#if defined(IRC_UNREAL) && defined(USE_OSSVS) c = createCommand("OLINE", do_operoline, is_services_admin,OPER_HELP_OLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c); -#endif 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); @@ -259,16 +237,19 @@ void os_init(void) slist_init(&akills); akills.opts = &akopts; - slist_init(&sglines); -#ifdef IRC_BAHAMUT - sglines.opts = &sgopts; -#endif - slist_init(&sqlines); - sqlines.opts = &sqopts; - slist_init(&szlines); -#ifdef IRC_BAHAMUT - szlines.opts = &szopts; -#endif + + if (ircd->sgline) { + slist_init(&sglines); + sglines.opts = &sgopts; + } + if (ircd->sqline) { + slist_init(&sqlines); + sqlines.opts = &sqopts; + } + if (ircd->szline) { + slist_init(&szlines); + szlines.opts = &szopts; + } } /*************************************************************************/ @@ -327,46 +308,43 @@ static void get_operserv_stats(long *nrec, long *memuse) mem += strlen(ak->reason) + 1; } -#ifdef IRC_BAHAMUT - - count += sglines.count; - mem += sglines.capacity; - mem += sglines.count * sizeof(SXLine); + 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; + 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); -#endif - - 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; + 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); -#ifdef IRC_BAHAMUT - - 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; + 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; + } } -#endif get_news_stats(&count2, &mem2); count += count2; @@ -437,7 +415,7 @@ static void load_old_akill(void) /* No nicknames allowed! */ if (strchr(ak->user, '!')) { - s_rakill(ak->user, ak->host); + anope_cmd_remove_akill(ak->user, ak->host); free(ak); continue; } @@ -473,7 +451,7 @@ static void load_old_akill(void) if (match_wild_nocase(amask, mask2) && (entry->expires >= ak->expires || entry->expires == 0)) { - s_rakill(ak->user, ak->host); + anope_cmd_remove_akill(ak->user, ak->host); free(ak); ak = NULL; break; @@ -683,7 +661,7 @@ void load_os_dbase(void) restore_db(f); \ log_perror("Write error on %s", OperDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - wallops(NULL, "Write error on %s: %s", OperDBName, \ + anope_cmd_global(NULL, "Write error on %s: %s", OperDBName, \ strerror(errno)); \ lastwarn = time(NULL); \ } \ @@ -900,13 +878,13 @@ void check_clones(User * user) free(clonelist[0].host); i = CLONE_DETECT_SIZE - 1; memmove(clonelist, clonelist + 1, sizeof(struct clone) * i); - clonelist[i].host = sstrdup(GetHost(user)); + clonelist[i].host = sstrdup(common_get_vhost(user)); last_time = clonelist[i].time = time(NULL); clone_count = 1; while (--i >= 0 && clonelist[i].host) { if (clonelist[i].time < last_time - CloneMaxDelay) break; - if (stricmp(clonelist[i].host, GetHost(user)) == 0) { + if (stricmp(clonelist[i].host, common_get_vhost(user)) == 0) { ++clone_count; last_time = clonelist[i].time; if (clone_count >= CloneMinUsers) @@ -917,22 +895,22 @@ void check_clones(User * user) /* Okay, we have clones. Check first to see if we already know * about them. */ for (i = CLONE_DETECT_SIZE - 1; i >= 0 && warnings[i].host; --i) { - if (stricmp(warnings[i].host, GetHost(user)) == 0) + if (stricmp(warnings[i].host, common_get_vhost(user)) == 0) break; } if (i < 0 || warnings[i].time < user->my_signon - CloneWarningDelay) { /* Send out the warning, and note it. */ - wallops(s_OperServ, - "\2WARNING\2 - possible clones detected from %s", - GetHost(user)); + anope_cmd_global(s_OperServ, + "\2WARNING\2 - possible clones detected from %s", + common_get_vhost(user)); alog("%s: possible clones detected from %s", s_OperServ, - GetHost(user)); + common_get_vhost(user)); i = CLONE_DETECT_SIZE - 1; if (warnings[0].host) free(warnings[0].host); memmove(warnings, warnings + 1, sizeof(struct clone) * i); - warnings[i].host = sstrdup(GetHost(user)); + warnings[i].host = sstrdup(common_get_vhost(user)); warnings[i].time = clonelist[i].time; if (KillClones) kill_user(s_OperServ, user->nick, "Clone kill"); @@ -1011,7 +989,8 @@ static int do_global(User * u) return MOD_CONT; } if (WallOSGlobal) - wallops(s_OperServ, "\2%s\2 just used GLOBAL command.", u->nick); + anope_cmd_global(s_OperServ, "\2%s\2 just used GLOBAL command.", + u->nick); oper_global(u->nick, "%s", msg); return MOD_CONT; } @@ -1093,73 +1072,96 @@ static int do_stats(User * u) notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MIN); else notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_NONE); -#ifdef IRC_BAHAMUT - /* 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); -#endif - /* 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); -#ifdef IRC_BAHAMUT - /* 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); -#endif + 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)) { @@ -1440,20 +1442,20 @@ static int do_os_mode(User * u) } else if (c->bouncy_modes) { notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); return MOD_CONT; -#ifdef CMODE_A - } else if ((!is_services_admin(u)) && (c->mode & CMODE_A)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; -#endif + } else if (ircd->adminmode) { + if ((!is_services_admin(u)) && (c->mode & ircd->adminmode)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } } else { - send_mode(s_OperServ, chan, "%s", modes); + 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) - wallops(s_OperServ, "%s used MODE %s on %s", u->nick, modes, - chan); + anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick, + modes, chan); } return MOD_CONT; } @@ -1466,8 +1468,6 @@ static int do_os_mode(User * u) * modified to be part of the SuperAdmin directive -jester * check user flag for SuperAdmin -rob */ -#ifdef USE_OSSVS -#ifndef IRC_HYBRID static int do_operumodes(User * u) { char *nick = strtok(NULL, " "); @@ -1475,6 +1475,11 @@ static int do_operumodes(User * u) 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); @@ -1497,20 +1502,20 @@ static int do_operumodes(User * u) if (!(u2 = finduser(nick))) { notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); } else { - send_mode(s_OperServ, nick, "%s", modes); + anope_cmd_mode(s_OperServ, nick, "%s", modes); - change_user_mode(u2, modes, NULL); + 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) - wallops(s_OperServ, "\2%s\2 used UMODE on %s", u->nick, nick); + anope_cmd_global(s_OperServ, "\2%s\2 used UMODE on %s", + u->nick, nick); } return MOD_CONT; } -#endif -#endif + /**************************************************************************/ /** @@ -1519,7 +1524,6 @@ static int do_operumodes(User * u) * modified to be part of the SuperAdmin directive -jester * check u-> for SuperAdmin -rob */ -#if defined (IRC_UNREAL) && defined (USE_OSSVS) static int do_operoline(User * u) { @@ -1527,6 +1531,11 @@ static int do_operoline(User * u) 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); @@ -1544,22 +1553,24 @@ static int do_operoline(User * u) if (!finduser(nick)) { notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); } else if (u2 && flags[0] == '+') { - send_cmd(s_OperServ, "SVSO %s %s", nick, flags); - send_mode(s_OperServ, nick, "+o"); - change_user_mode(u2, "+o", NULL); + 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); - wallops(s_OperServ, "\2%s\2 used OLINE for %s", u->nick, nick); + anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s", + u->nick, nick); } else if (u2 && flags[0] == '-') { - send_cmd(s_OperServ, "SVSO %s %s", nick, flags); + anope_cmd_svso(s_OperServ, nick, flags); notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); - wallops(s_OperServ, "\2%s\2 used OLINE for %s", u->nick, 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; } -#endif + /*************************************************************************/ /* Clear all modes from a channel. */ @@ -1574,10 +1585,8 @@ static int do_clearmodes(User * u) int all = 0; int count; /* For saving ban info */ char **bans; /* For saving ban info */ -#ifdef HAS_EXCEPT int exceptcount; /* For saving except info */ char **excepts; /* For saving except info */ -#endif struct c_userlist *cu, *next; if (!chan) { @@ -1600,8 +1609,8 @@ static int do_clearmodes(User * u) } if (WallOSClearmodes) - wallops(s_OperServ, "%s used CLEARMODES%s on %s", u->nick, - all ? " ALL" : "", chan); + anope_cmd_global(s_OperServ, "%s used CLEARMODES%s on %s", + u->nick, all ? " ALL" : "", chan); if (all) { /* Clear mode +o */ @@ -1614,7 +1623,8 @@ static int do_clearmodes(User * u) argv[0] = sstrdup("-o"); argv[1] = cu->user->nick; - send_mode(s_OperServ, c->name, "-o %s", 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]); @@ -1630,34 +1640,36 @@ static int do_clearmodes(User * u) argv[0] = sstrdup("-v"); argv[1] = sstrdup(cu->user->nick); - send_mode(s_OperServ, c->name, "-v %s", 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]); } -#ifdef HAS_HALFOP /* Clear mode +h */ - for (cu = c->users; cu; cu = next) { - next = cu->next; + if (ircd->halfop) { + for (cu = c->users; cu; cu = next) { + next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) - continue; + if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) + continue; - argv[0] = sstrdup("-h"); - argv[1] = sstrdup(cu->user->nick); + argv[0] = sstrdup("-h"); + argv[1] = sstrdup(cu->user->nick); - send_mode(s_OperServ, c->name, "-h %s", cu->user->nick); - chan_set_modes(s_OperServ, c, 2, argv, 0); + anope_cmd_mode(s_OperServ, c->name, "-h %s", + cu->user->nick); + chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); + free(argv[0]); + } } -#endif } /* Clear modes */ - send_mode(s_OperServ, c->name, "%s %s", MODESTOREMOVE, - c->key ? c->key : ""); - argv[0] = sstrdup(MODESTOREMOVE); + anope_cmd_mode(s_OperServ, c->name, "%s %s", ircd->modestoremove, + c->key ? c->key : ""); + argv[0] = sstrdup(ircd->modestoremove); argv[1] = c->key ? c->key : NULL; chan_set_modes(s_OperServ, c, c->key ? 2 : 1, argv, 0); free(argv[0]); @@ -1672,7 +1684,7 @@ static int do_clearmodes(User * u) for (i = 0; i < count; i++) { argv[0] = sstrdup("-b"); argv[1] = bans[i]; - send_mode(s_OperServ, c->name, "-b %s", argv[1]); + 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]); @@ -1680,25 +1692,25 @@ static int do_clearmodes(User * u) free(bans); -#ifdef HAS_EXCEPT - /* Clear excepts */ - exceptcount = c->exceptcount; - excepts = scalloc(sizeof(char *) * exceptcount, 1); + 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++) + excepts[i] = sstrdup(c->excepts[i]); - for (i = 0; i < exceptcount; i++) { - argv[0] = sstrdup("-e"); - argv[1] = excepts[i]; - send_mode(s_OperServ, c->name, "-e %s", argv[1]); - chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[1]); - free(argv[0]); - } + 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]); + } - free(excepts); -#endif + free(excepts); + } } notice_lang(s_OperServ, u, OPER_CLEARMODES_ALL_DONE, chan); @@ -1728,9 +1740,10 @@ static int do_os_kick(User * u) notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); return MOD_CONT; } - send_cmd(s_OperServ, "KICK %s %s :%s (%s)", chan, nick, u->nick, s); + anope_cmd_kick(s_OperServ, chan, nick, "%s (%s)", u->nick, s); if (WallOSKick) - wallops(s_OperServ, "%s used KICK on %s/%s", u->nick, nick, chan); + 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); @@ -1744,7 +1757,6 @@ static int do_os_kick(User * u) /*************************************************************************/ /* Forcefully change a user's nickname */ -#ifdef USE_OSSVS static int do_svsnick(User * u) { @@ -1754,6 +1766,11 @@ static int do_svsnick(User * u) 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); @@ -1794,13 +1811,13 @@ static int do_svsnick(User * u) notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, newnick); } else { notice_lang(s_OperServ, u, OPER_SVSNICK_NEWNICK, nick, newnick); - wallops(s_OperServ, "%s used SVSNICK to change %s to %s", - u->nick, nick, newnick); - send_cmd(NULL, "SVSNICK %s %s :%ld", nick, newnick, time(NULL)); + 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; } -#endif + /*************************************************************************/ /* Adds an AKILL to the list. Returns >= 0 on success, -1 if it fails, -2 @@ -1904,8 +1921,8 @@ int add_akill(User * u, char *mask, const char *by, const time_t expires, slist_add(&akills, entry); if (AkillOnAdd) - s_akill(entry->user, entry->host, entry->by, entry->seton, - entry->expires, entry->reason); + anope_cmd_akill(entry->user, entry->host, entry->by, entry->seton, + entry->expires, entry->reason); free(mask2); @@ -1914,7 +1931,7 @@ int add_akill(User * u, char *mask, const char *by, const time_t expires, /* Does the user match any AKILLs? */ -int check_akill(const char *nick, const char *username, const char *host, +int check_akill(char *nick, const char *username, const char *host, const char *vhost, const char *ip) { int i; @@ -1938,19 +1955,19 @@ int check_akill(const char *nick, const char *username, const char *host, if (match_wild_nocase(ak->user, username) && (match_wild_nocase(ak->host, host) || (vhost && match_wild_nocase(ak->host, vhost)))) { - s_akill(ak->user, ak->host, ak->by, ak->seton, ak->expires, - ak->reason); + anope_cmd_akill(ak->user, ak->host, ak->by, ak->seton, + ak->expires, ak->reason); return 1; } -#ifdef HAS_NICKIP - if (ip) - if (match_wild_nocase(ak->user, username) - && match_wild_nocase(ak->host, ip)) { - s_akill(ak->user, ak->host, ak->by, ak->seton, ak->expires, - ak->reason); - return 1; - } -#endif + if (ircd->nickip) { + if (ip) + if (match_wild_nocase(ak->user, username) + && match_wild_nocase(ak->host, ip)) { + anope_cmd_akill(ak->user, ak->host, ak->by, ak->seton, + ak->expires, ak->reason); + return 1; + } + } } @@ -1972,8 +1989,8 @@ void expire_akills(void) continue; if (WallAkillExpire) - wallops(s_OperServ, "AKILL on %s@%s has expired", ak->user, - ak->host); + anope_cmd_global(s_OperServ, "AKILL on %s@%s has expired", + ak->user, ak->host); slist_delete(&akills, i); } } @@ -1983,7 +2000,7 @@ static void free_akill_entry(SList * slist, void *item) Akill *ak = item; /* Remove the AKILLs from all the servers */ - s_rakill(ak->user, ak->host); + anope_cmd_remove_akill(ak->user, ak->host); /* Free the structure */ free(ak->user); @@ -2180,8 +2197,9 @@ static int do_akill(User * u) (wall_expiry == 1) ? "" : "s"); } - wallops(s_OperServ, "%s added an AKILL for %s (%s) (%s)", - u->nick, mask, reason, buf); + anope_cmd_global(s_OperServ, + "%s added an AKILL for %s (%s) (%s)", + u->nick, mask, reason, buf); } if (readonly) @@ -2321,8 +2339,6 @@ static int do_akill(User * u) /*************************************************************************/ -#ifdef IRC_BAHAMUT - /* Adds an SGLINE to the list. Returns >= 0 on success, -1 if it failed, -2 if * only the expiry time changed. * The success result is the number of SGLINEs that were deleted to successfully add one. @@ -2402,14 +2418,14 @@ int add_sgline(User * u, char *mask, const char *by, const time_t expires, slist_add(&sglines, entry); - s_sgline(entry->mask, entry->reason); + anope_cmd_sgline(entry->mask, entry->reason); return deleted; } /* Does the user match any SGLINEs? */ -int check_sgline(const char *nick, const char *realname) +int check_sgline(char *nick, const char *realname) { int i; SXLine *sx; @@ -2423,10 +2439,9 @@ int check_sgline(const char *nick, const char *realname) continue; if (match_wild_nocase(sx->mask, realname)) { - s_sgline(sx->mask, sx->reason); + anope_cmd_sgline(sx->mask, sx->reason); /* We kill nick since s_sgline can't */ - send_cmd(ServerName, "SVSKILL %s :G-Lined: %s", nick, - sx->reason); + anope_cmd_svskill(ServerName, nick, "G-Lined: %s", sx->reason); return 1; } } @@ -2449,7 +2464,8 @@ void expire_sglines(void) continue; if (WallSGLineExpire) - wallops(s_OperServ, "SGLINE on \2%s\2 has expired", sx->mask); + anope_cmd_global(s_OperServ, "SGLINE on \2%s\2 has expired", + sx->mask); slist_delete(&sglines, i); } } @@ -2459,7 +2475,7 @@ static void free_sgline_entry(SList * slist, void *item) SXLine *sx = item; /* Remove the SGLINE from all the servers */ - s_unsgline(sx->mask); + anope_cmd_unsgline(sx->mask); /* Free the structure */ free(sx->mask); @@ -2549,15 +2565,18 @@ static int sgline_view_callback(SList * slist, int number, void *item, return sgline_view(number, item, u, sent_header); } -#endif /* Manage the SGLINE list. */ static int do_sgline(User * u) { -#ifdef IRC_BAHAMUT char *cmd = strtok(NULL, " "); + if (!ircd->sgline) { + notice_lang(s_OperServ, u, OPER_SGLINE_UNSUPPORTED); + return MOD_CONT; + } + if (!cmd) cmd = ""; @@ -2633,8 +2652,9 @@ static int do_sgline(User * u) (wall_expiry == 1) ? "" : "s"); } - wallops(s_OperServ, "%s added an SGLINE for %s (%s)", - u->nick, mask, buf); + anope_cmd_global(s_OperServ, + "%s added an SGLINE for %s (%s)", u->nick, + mask, buf); } if (readonly) @@ -2763,9 +2783,6 @@ static int do_sgline(User * u) } else { syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); } -#else - notice_lang(s_OperServ, u, OPER_SGLINE_UNSUPPORTED); -#endif return MOD_CONT; } @@ -2854,17 +2871,18 @@ int add_sqline(User * u, char *mask, const char *by, const time_t expires, slist_add(&sqlines, entry); - s_sqline(entry->mask, entry->reason); + sqline(entry->mask, entry->reason); return deleted; } /* Does the user match any SQLINEs? */ -int check_sqline(const char *nick, int nick_change) +int check_sqline(char *nick, int nick_change) { int i; SXLine *sx; + char *reason; if (sqlines.count == 0) return 0; @@ -2874,28 +2892,17 @@ int check_sqline(const char *nick, int nick_change) if (!sx) continue; -#ifdef IRC_BAHAMUT - if (*sx->mask == '#') - continue; -#endif + if (ircd->chansqline) { + if (*sx->mask == '#') + continue; + } if (match_wild_nocase(sx->mask, nick)) { - s_sqline(sx->mask, sx->reason); + sqline(sx->mask, sx->reason); /* We kill nick since s_sqline can't */ -#ifdef IRC_BAHAMUT - send_cmd(ServerName, "SVSKILL %s :Q-Lined: %s", nick, - sx->reason); -#else - if (!nick_change) { - send_cmd(s_OperServ, "KILL %s :Q-Lined: %s", nick, - sx->reason); - } else { - char reason[300]; - snprintf(reason, sizeof(reason), "Q-Lined: %s", - sx->reason); - kill_user(s_OperServ, nick, reason); - } -#endif + snprintf(reason, sizeof(reason), "Q-Lined: %s", sx->reason); + kill_user(s_OperServ, nick, reason); + return 1; } } @@ -2903,7 +2910,6 @@ int check_sqline(const char *nick, int nick_change) return 0; } -#ifdef IRC_BAHAMUT int check_chan_sqline(const char *chan) { int i; @@ -2921,14 +2927,13 @@ int check_chan_sqline(const char *chan) continue; if (match_wild_nocase(sx->mask, chan)) { - s_sqline(sx->mask, sx->reason); + sqline(sx->mask, sx->reason); return 1; } } return 0; } -#endif /* Delete any expired SQLINEs. */ @@ -2945,7 +2950,8 @@ void expire_sqlines(void) continue; if (WallSQLineExpire) - wallops(s_OperServ, "SQLINE on \2%s\2 has expired", sx->mask); + anope_cmd_global(s_OperServ, "SQLINE on \2%s\2 has expired", + sx->mask); slist_delete(&sqlines, i); } @@ -2956,7 +2962,7 @@ static void free_sqline_entry(SList * slist, void *item) SXLine *sx = item; /* Remove the SQLINE from all the servers */ - s_unsqline(sx->mask); + anope_cmd_unsqline(sx->mask); /* Free the structure */ free(sx->mask); @@ -3052,6 +3058,11 @@ 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 = ""; @@ -3089,14 +3100,14 @@ static int do_sqline(User * u) notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); return MOD_CONT; } -#ifndef IRC_BAHAMUT - /* Channel SQLINEs are only supported on Bahamut servers */ - if (*mask == '#') { - notice_lang(s_OperServ, u, - OPER_SQLINE_CHANNELS_UNSUPPORTED); - return MOD_CONT; + if (ircd->chansqline) { + /* Channel SQLINEs are only supported on Bahamut servers */ + if (*mask == '#') { + notice_lang(s_OperServ, u, + OPER_SQLINE_CHANNELS_UNSUPPORTED); + return MOD_CONT; + } } -#endif deleted = add_sqline(u, mask, u->nick, expires, reason); if (deleted < 0) @@ -3131,8 +3142,9 @@ static int do_sqline(User * u) (wall_expiry == 1) ? "" : "s"); } - wallops(s_OperServ, "%s added an SQLINE for %s (%s)", - u->nick, mask, buf); + anope_cmd_global(s_OperServ, + "%s added an SQLINE for %s (%s)", u->nick, + mask, buf); } if (readonly) @@ -3266,8 +3278,6 @@ static int do_sqline(User * u) /*************************************************************************/ -#ifdef IRC_BAHAMUT - /* Adds an SZLINE to the list. Returns >= 0 on success, -1 on error, -2 if * only the expiry time changed. * The success result is the number of SZLINEs that were deleted to successfully add one. @@ -3344,7 +3354,7 @@ int add_szline(User * u, char *mask, const char *by, const time_t expires, entry->expires = expires; slist_add(&szlines, entry); - s_szline(entry->mask, entry->reason); + anope_cmd_szline(entry->mask, entry->reason); return deleted; } @@ -3364,7 +3374,8 @@ void expire_szlines(void) continue; if (WallSZLineExpire) - wallops(s_OperServ, "SZLINE on \2%s\2 has expired", sx->mask); + anope_cmd_global(s_OperServ, "SZLINE on \2%s\2 has expired", + sx->mask); slist_delete(&szlines, i); } } @@ -3374,7 +3385,7 @@ static void free_szline_entry(SList * slist, void *item) SXLine *sx = item; /* Remove the SZLINE from all the servers */ - s_unszline(sx->mask); + anope_cmd_unszline(sx->mask); /* Free the structure */ free(sx->mask); @@ -3465,15 +3476,17 @@ static int szline_view_callback(SList * slist, int number, void *item, return szline_view(number, item, u, sent_header); } -#endif - /* Manage the SZLINE list. */ static int do_szline(User * u) { -#ifdef IRC_BAHAMUT char *cmd = strtok(NULL, " "); + if (!ircd->szline) { + notice_lang(s_OperServ, u, OPER_SZLINE_UNSUPPORTED); + return MOD_CONT; + } + if (!cmd) cmd = ""; @@ -3550,8 +3563,9 @@ static int do_szline(User * u) (wall_expiry == 1) ? "" : "s"); } - wallops(s_OperServ, "%s added an SZLINE for %s (%s)", - u->nick, mask, buf); + anope_cmd_global(s_OperServ, + "%s added an SZLINE for %s (%s)", u->nick, + mask, buf); } if (readonly) @@ -3677,9 +3691,6 @@ static int do_szline(User * u) } else { syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX); } -#else - notice_lang(s_OperServ, u, OPER_SZLINE_UNSUPPORTED); -#endif return MOD_CONT; } @@ -3754,8 +3765,8 @@ static int do_userlist(User * u) if (modes && !(cu->user->mode & modes)) continue; notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, - cu->user->nick, GetIdent(cu->user), - GetHost(cu->user)); + cu->user->nick, common_get_vident(cu->user), + common_get_vhost(cu->user)); } } else { char mask[BUFSIZE]; @@ -3768,14 +3779,14 @@ static int do_userlist(User * u) for (u2 = userlist[i]; u2; u2 = u2->next) { if (pattern) { snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick, - GetIdent(u2), GetHost(u2)); + 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, - GetIdent(u2), GetHost(u2)); + common_get_vident(u2), common_get_vhost(u2)); } } } @@ -4313,17 +4324,16 @@ static int do_set(User * u) * -jester */ if (LogChannel && (stricmp(setting, "on") == 0)) { -#ifdef IRC_HYBRID - send_cmd(NULL, "SJOIN %ld %s + :%s", time(NULL), LogChannel, - s_GlobalNoticer); -#endif + 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)) { -#ifdef IRC_HYBRID - send_cmd(s_GlobalNoticer, "PART %s :Parting", LogChannel); -#endif + if (ircd->join2msg) { + anope_cmd_part(s_GlobalNoticer, LogChannel, NULL); + } logchan = 0; alog("No longer sending log messages to a channel"); notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_OFF); @@ -4340,14 +4350,16 @@ static int do_set(User * u) u->isSuperAdmin = 1; notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ON); alog("%s: %s is a SuperAdmin ", s_OperServ, u->nick); - wallops(s_OperServ, getstring2(NULL, OPER_SUPER_ADMIN_WALL_ON), - u->nick); + anope_cmd_global(s_OperServ, + getstring2(NULL, OPER_SUPER_ADMIN_WALL_ON), + u->nick); } else if (SuperAdmin && (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); - wallops(s_OperServ, - getstring2(NULL, OPER_SUPER_ADMIN_WALL_OFF), 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); } @@ -4403,13 +4415,13 @@ static int do_noop(User * u) char reason[NICKMAX + 32]; /* Remove the O:lines */ - s_svsnoop(server, 1); + anope_cmd_svsnoop(server, 1); snprintf(reason, sizeof(reason), "NOOP command used by %s", u->nick); if (WallOSNoOp) - wallops(s_OperServ, "\2%s\2 used NOOP on \2%s\2", u->nick, - server); + 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 */ @@ -4421,7 +4433,7 @@ static int do_noop(User * u) } } } else if (!stricmp(cmd, "REVOKE")) { - s_svsnoop(server, 0); + anope_cmd_svsnoop(server, 0); notice_lang(s_OperServ, u, OPER_NOOP_REVOKE, server); } else { syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX); @@ -4446,18 +4458,13 @@ static int do_jupe(User * u) snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", u->nick, reason ? ": " : "", reason ? reason : ""); - send_cmd(NULL, "SQUIT %s :%s", jserver, rbuf); -#ifdef IRC_PTLINK - send_cmd(NULL, "SERVER %s 1 Anope.Services%s :%s", - jserver, version_number, rbuf); -#else - send_cmd(NULL, "SERVER %s 2 :%s", jserver, rbuf); -#endif + anope_cmd_squit(jserver, rbuf); + anope_cmd_server(jserver, 1, rbuf); new_server(me_server, jserver, rbuf, SERVER_JUPED); if (WallOSJupe) - wallops(s_OperServ, "\2%s\2 used JUPE on \2%s\2", u->nick, - jserver); + anope_cmd_global(s_OperServ, "\2%s\2 used JUPE on \2%s\2", + u->nick, jserver); } } return MOD_CONT; @@ -4480,9 +4487,11 @@ static int do_raw(User * u) char *kw = strtok(text, " "); while (kw && *kw == ':') kw = strtok(NULL, " "); - wallops(s_OperServ, "\2%s\2 used RAW command for \2%s\2", - u->nick, - (kw ? kw : "\2non RFC compliant message\2")); + 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); } @@ -4647,9 +4656,11 @@ static int do_killclones(User * u) add_akill(u, akillmask, u->nick, time(NULL) + KillClonesAkillExpire, akillreason); - wallops(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); + 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); @@ -4697,8 +4708,8 @@ static int do_defcon(User * u) notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel); defcon_sendlvls(u); alog("Defcon level changed to %d by Oper %s", newLevel, u->nick); - wallops(s_OperServ, getstring2(NULL, OPER_DEFCON_WALL), u->nick, - newLevel); + 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) { @@ -4789,8 +4800,9 @@ void resetDefCon(int level) && (time(NULL) - DefContimer >= dotime(DefConTimeOut))) { DefConLevel = level; alog("Defcon level timeout, returning to lvl %d", level); - wallops(s_OperServ, getstring2(NULL, OPER_DEFCON_WALL), - s_OperServ, level); + anope_cmd_global(s_OperServ, + getstring2(NULL, OPER_DEFCON_WALL), + s_OperServ, level); if (GlobalOnDefcon) { if (DefConOffMessage) { oper_global(NULL, "%s", DefConOffMessage); @@ -4900,8 +4912,8 @@ static int do_chankill(User * u) cu->user->host, NULL, NULL); } if (WallOSAkill) { - wallops(s_OperServ, "%s used CHANKILL on %s (%s)", u->nick, - channel, reason); + 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); diff --git a/src/proxy.c b/src/proxy.c index 4938c128c..2287031ff 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -48,7 +48,7 @@ SList pxqueue; pthread_mutex_t queuemut = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t queuecond = PTHREAD_COND_INITIALIZER; -#if !defined(HAS_NICKIP) && !defined(HAVE_GETHOSTBYNAME_R6) && !defined(HAVE_GETHOSTBYNAME_R5) && !defined(HAVE_GETHOSTBYNAME_R3) +#if !defined(HAVE_GETHOSTBYNAME_R6) && !defined(HAVE_GETHOSTBYNAME_R5) && !defined(HAVE_GETHOSTBYNAME_R3) pthread_mutex_t resmut = PTHREAD_MUTEX_INITIALIZER; #endif @@ -64,9 +64,7 @@ static void proxy_queue_signal(void); static void proxy_queue_unlock(void); static void proxy_queue_wait(void); static int proxy_read(int s, char *buf, size_t buflen); -#ifndef HAS_NICKIP static uint32 proxy_resolve(char *host); -#endif static int proxy_scan(uint32 ip); static void *proxy_thread_main(void *arg); @@ -126,12 +124,12 @@ void get_proxy_stats(long *nrec, long *memuse) static void proxy_akill(char *host) { - s_akill("*", host, s_OperServ, time(NULL), - time(NULL) + (ProxyExpire ? ProxyExpire : 86400 * 2), - ProxyAkillReason); + anope_cmd_akill("*", host, s_OperServ, time(NULL), + time(NULL) + (ProxyExpire ? ProxyExpire : 86400 * 2), + ProxyAkillReason); if (WallProxy) - wallops(s_OperServ, "Insecure proxy \2%s\2 has been AKILLed.", - host); + anope_cmd_global(s_OperServ, + "Insecure proxy \2%s\2 has been AKILLed.", host); } /*************************************************************************/ @@ -173,7 +171,7 @@ static void proxy_cache_del(HostCache * hc) alog("debug: Deleting %s from host cache", hc->host); if (hc->status > HC_NORMAL) - s_rakill("*", hc->host); + anope_cmd_remove_akill("*", hc->host); if (hc->next) hc->next->prev = hc->prev; @@ -239,9 +237,9 @@ int proxy_check(char *nick, char *host, uint32 ip) notice(s_GlobalNoticer, nick, *message); hc = proxy_cache_add(host); -#ifdef HAS_NICKIP - hc->ip = htonl(ip); -#endif + if (ircd->nickip) { + hc->ip = htonl(ip); + } hc->status = HC_QUEUED; proxy_queue_lock(); @@ -439,8 +437,6 @@ static int proxy_read(int s, char *buf, size_t buflen) /* Resolves hostnames in a thread safe manner */ -#ifndef HAS_NICKIP - static uint32 proxy_resolve(char *host) { struct hostent *hentp = NULL; @@ -485,8 +481,6 @@ static uint32 proxy_resolve(char *host) return ip; } -#endif - /*************************************************************************/ /* Scans the given host for proxy */ @@ -685,11 +679,11 @@ static void *proxy_thread_main(void *arg) alog("debug: Scanning host %s for proxy", hc->host); } } -#ifndef HAS_NICKIP - /* Test if it's an IP, and if not try to resolve the hostname */ - if ((hc->ip = aton(hc->host)) == INADDR_NONE) - hc->ip = proxy_resolve(hc->host); -#endif + if (!ircd->nickip) { + /* Test if it's an IP, and if not try to resolve the hostname */ + if ((hc->ip = aton(hc->host)) == INADDR_NONE) + hc->ip = proxy_resolve(hc->host); + } status = proxy_scan(hc->ip); if (debug) { diff --git a/src/ptlink.c b/src/ptlink.c new file mode 100644 index 000000000..a57ebbf6b --- /dev/null +++ b/src/ptlink.c @@ -0,0 +1,1217 @@ +/* PTLink IRCD functions + * + * (C) 2003 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. + * + * + */ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_PTLINK + +const char version_protocol[] = "PTlink 6.14.5+"; + +IRCDVar ircd[] = { + {"PTlinkIRCd 6.14.*", /* ircd name */ + "+o", /* nickserv mode */ + "+o", /* chanserv mode */ + "+o", /* memoserv mode */ + "+o", /* hostserv mode */ + "+io", /* operserv mode */ + "+o", /* botserv mode */ + "+h", /* 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 */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+", /* Used by BotServ Bots */ + 2, /* Chan Max Symbols */ + "-cdfiklmnpqstRS", /* Modes to Remove */ + "+ao", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+r", /* Mode On Reg */ + "-r", /* Mode on UnReg */ + "+d", /* Mode on Nick Change */ + 0, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ + 0, /* Supports Halfop +h */ + 4, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* 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 */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 0, /* svshold */ + 0, /* time stamp on mode */ + 0, /* NICKIP */ + 1, /* UMODE */ + 0, /* O:LINE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + 0, /* ChanServ extra */ + CMODE_K, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_o, /* Vhost Mode */ + 1, /* +f */ + 0, /* +L */ + CMODE_f, + 0, + 1, + + } + , + {NULL} +}; + +IRCDCAPAB ircdcap[] = { + { + 0, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + 0, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + CAPAB_PT4, /* PT4 */ + CAPAB_SCS, /* SCS */ + CAPAB_QS, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0 /* DOZIP */ + } +}; + + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 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_a, 0, 0, 0, 0, 0, + 0, + UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, + 0, + 0, UMODE_r, 0, 0, 0, 0, UMODE_w, + 0, + 0, + 0, + 0, 0, 0, 0, 0 +}; + +char csmodes[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, + + '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, 0, 0 +}; + + +CMMode cmmodes[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 cbmodes[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}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {0}, /* M */ + {CMODE_N, 0, NULL, NULL}, + {0}, /* O */ + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {CMODE_d, 0, NULL, NULL}, + {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}, + {CMODE_q, 0, NULL, NULL}, + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} +}; + +CBModeInfo cbmodeinfos[] = { + {'c', CMODE_c, 0, NULL, NULL}, + {'d', CMODE_d, 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}, + {'q', CMODE_q, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'A', CMODE_A, 0, NULL, NULL}, + {'K', CMODE_K, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {0} +}; + +CUMode cumodes[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}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {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 anope_cmd_bot_chan_mode(char *nick, char *chan) +{ + anope_cmd_mode(s_ChanServ, chan, "%s %s %s", ircd->botchanumode, nick, + nick); +} + +int anope_event_sjoin(char *source, int ac, char **av) +{ + do_sjoin(source, ac, av); + return MOD_CONT; +} + +/* + * Note: This function has no validation whatsoever. Also, as of PTlink6.15.1 + * when you /deoper you get to keep your vindent, but you lose your vhost. In + * that case serives will *NOT* modify it's internal record for the vhost. We + * need to address this in the future. + */ +int anope_event_newmask(char *source, int ac, char **av) +{ + User *u; + char *newhost = NULL, *newuser = NULL; + + if (ac != 1) + return MOD_CONT; + u = finduser(source); + + if (!u) { + alog("user: NEWMASK for nonexistent user %s", av[0]); + return MOD_CONT; + } + + newuser = myStrGetOnlyToken(av[0], '@', 0); + if (newuser) { + newhost = myStrGetTokenRemainder(av[0], '@', 1); + change_user_username(u, newuser); + } else { + newhost = av[0]; + } + + if (*newhost == '@') + newhost++; + + if (newhost) { + change_user_host(u, newhost); + } + + return MOD_CONT; +} + + +int anope_event_nick(char *source, int ac, char **av) +{ + User *user; + + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[6], av[7], av[8], + strtoul(av[2], NULL, 10), 0, 0, av[5], NULL); + if (user) + anope_set_umode(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; +} + +int anope_event_server(char *source, int ac, char **av) +{ + char *uplink; + + if (!stricmp(av[1], "1")) + uplink = sstrdup(av[0]); + do_server(source, ac, av); + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("STATS", m_stats); addCoreMessage(IRCD,m); + m = createMessage("TIME", m_time); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + + /* DALnet specific messages */ + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + + m = createMessage("NEWMASK", anope_event_newmask); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); + m = createMessage("SVSINFO", anope_event_svsinfo); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); +} + +/* *INDENT-ON* */ + + +int anope_event_svsinfo(char *source, int ac, char **av) +{ + return MOD_CONT; +} + +int anope_event_svinfo(char *source, int ac, char **av) +{ + return MOD_CONT; +} + +/* Event: PROTOCTL */ +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +void anope_cmd_sqline(char *mask, char *reason) +{ + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSADMIN %s :%s", server, set ? "noopers" : "rehash"); +} + +void anope_cmd_remove_akill(char *user, char *host) +{ + send_cmd(NULL, "UNGLINE %s@%s", user, host); +} + + +void anope_part(char *nick, char *chan) +{ + send_cmd(nick, "PART %s", chan); +} +void anope_topic(char *whosets, char *chan, char *whosetit, char *topic, + time_t when) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +void anope_cmd_unsqline(char *user) +{ + send_cmd(NULL, "UNSQLINE %s", user); +} + +void anope_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) +{ + 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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + if (!source || !user) { + return; + } + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "KILL %s :%s", user, buf); +} + + +void anope_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) +{ + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +/* PONG */ +void anope_cmd_pong(char *servname, char *who) +{ + send_cmd(servname, "PONG %s", who); +} + +void anope_cmd_connect(int servernum) +{ + 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_server(ServerName, 1, ServerDesc); + anope_cmd_svinfo(); + anope_cmd_svsinfo(); +} + +void anope_cmd_svinfo() +{ + send_cmd(NULL, "SVINFO 3 6 %lu", time(NULL)); +} + +void anope_cmd_svsinfo() +{ + send_cmd(NULL, "SVSINFO %lu %d", time(NULL), maxusercnt); +} + +/* PASS */ +void anope_cmd_pass(char *pass) +{ + send_cmd(NULL, "PASS %s :TS", pass); +} + +void anope_cmd_server(char *servname, int hop, char *descript) +{ + send_cmd(NULL, "SERVER %s %d Anope.Services%s :%s", servname, hop, + version_number, descript); +} + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + + +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +void anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(source, "MODE %s %s", dest, buf); +} + +void anope_cmd_nick(char *nick, char *name, char *mode) +{ + send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick, time(NULL), + mode, ServiceUser, ServiceHost, ServiceHost, ServerName, + name); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + + if (fmt) { + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +void anope_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(char *nick) +{ + /* does not support vhosting */ +} + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + /* does not support vhosting */ +} + +/* INVITE */ +void anope_cmd_invite(char *source, char *chan, char *nick) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_cmd_376(char *source) +{ + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); +} + + +void anope_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 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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); + if (is_services_admin(user)) { + send_cmd(ServerName, "SVSMODE %s +a", user->nick); + user->mode |= UMODE_a; + } + + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + } + } +} + +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]); + return MOD_CONT; +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +void anope_cmd_bot_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, time(NULL), + modes, user, host, host, ServerName, real); + anope_cmd_sqline(nick, "Reserved for services"); + +} + +void anope_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); +} + +/* SVSHOLD - set */ +void anope_cmd_svshold(char *nick) +{ + /* Not supported by this IRCD */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + /* Not Supported by this IRCD */ +} + +/* UNSGLINE */ +void anope_cmd_unsgline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* UNSZLINE */ +void anope_cmd_unszline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* SZLINE */ +void anope_cmd_szline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +/* SGLINE */ +void anope_cmd_sgline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +/* SVSNICK */ +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +void anope_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, time(NULL), + modes, user, host, host, ServerName, real); +} + + +void anope_cmd_unban(char *name, char *nick) +{ + /* Not Supported by this IRCD */ +} + +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + /* Not Supported by this IRCD */ +} + + +/* SVSMODE +d */ +/* sent if svid is something weird */ +void anope_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) +{ + common_svsmode(u, "+d", "1"); +} + +/* SVSMODE +d */ +/* sent if svid is something weird */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + common_svsmode(u, "+r", NULL); +} + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + /* Bahamuts have this extra one, since they can check on even nick changes */ +} + + +#endif diff --git a/src/rageircd.c b/src/rageircd.c new file mode 100644 index 000000000..617b75696 --- /dev/null +++ b/src/rageircd.c @@ -0,0 +1,1273 @@ +/* Rage IRCD functions + * + * (C) 2003 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. + * + * + */ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_RAGE2 + +const char version_protocol[] = "RageIRCd 2.0.x"; + +IRCDVar ircd[] = { + {"RageIRCd 2.0.*", /* ircd name */ + "+dS", /* nickserv mode */ + "+dS", /* chanserv mode */ + "+dS", /* memoserv mode */ + "+dS", /* hostserv mode */ + "+diS", /* operserv mode */ + "+dS", /* botserv mode */ + "+dSh", /* helpserv mode */ + "+diS", /* Dev/Null mode */ + "+diS", /* 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 */ + "+S", /* Used by BotServ Bots */ + 3, /* Chan Max Symbols */ + "-iklmnpRstcOASCNM", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+rd", /* Mode On Reg */ + "-rd", /* Mode on UnReg */ + "-r+d", /* Mode on Nick Change */ + 1, /* 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 */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 1, /* Has Admin */ + 1, /* Chan SQlines */ + 1, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 0, /* vidents */ + 0, /* svshold */ + 1, /* time stamp on mode */ + 0, /* NICKIP */ + 0, /* UMODE */ + 0, /* O:LINE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CHAN_HELP_ULTIMATE3, /* ChanServ extra */ + 0, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, + 0, + 1, + + }, + {NULL} +}; + +IRCDCAPAB ircdcap[] = { + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + CAPAB_BURST, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + CAPAB_UID, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + CAPAB_SN2, /* SN2 */ + CAPAB_TOKEN, /* TOKEN */ + CAPAB_VHOST, /* VHOST */ + CAPAB_SSJ3, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0 /* DOZIP */ + } +}; + + + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, + 0, + UMODE_R, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0, 0, 0, 0, 0, + 0, UMODE_a, 0, 0, 0, 0, 0, + 0, + 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 csmodes[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, + 'a', /* * Channel Admins */ + + '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, 0, 0 +}; + + +CMMode cmmodes[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 cbmodes[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}, + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {CMODE_M}, + {CMODE_N, 0, NULL, NULL}, + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, + {0}, /* T */ + {0}, /* U */ + {0}, /* 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 */ + {0}, /* f */ + {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}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} +}; + +CBModeInfo cbmodeinfos[] = { + {'c', CMODE_c, 0, NULL, NULL}, + {'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}, + {'A', CMODE_A, 0, NULL, NULL}, + {'C', CMODE_C, 0, NULL, NULL}, + {'M', CMODE_M, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {0} +}; + +CUMode cumodes[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_admin}, + {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 */ + {0}, /* q */ + {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 anope_cmd_bot_unban(ChannelInfo * ci, char *nick) +{ + send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick); +} + +int anope_event_sjoin(char *source, int ac, char **av) +{ + do_sjoin(source, ac, av); + return MOD_CONT; +} + +int anope_event_nick(char *source, int ac, char **av) +{ + User *user; + + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), + strtoul(av[8], NULL, 0), "*", NULL); + if (user) + anope_set_umode(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; +} + +/* Event: PROTOCTL */ +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +int anope_event_vhost(char *source, int ac, char **av) +{ + User *u; + + if (ac != 2) + return MOD_CONT; + + u = finduser(av[0]); + if (!u) { + if (debug) + alog("user: VHOST for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_host(u, av[1]); + return MOD_CONT; +} + +/* +** SNICK +** source = NULL +** parv[0] = nickname Trystan +** parv[1] = timestamp 1090113640 +** parv[2] = hops 1 +** parv[3] = username Trystan +** parv[4] = host c-24-2-101-227.client.comcast.net +** parv[5] = IP 402810339 +** parv[6] = vhost mynet-27CCA80D.client.comcast.net +** parv[7] = server rage2.nomadirc.net +** parv[8] = servicestamp 0 +** parv[9] = modes +ix +** parv[10] = info Dreams are answers to questions not yet asked +*/ + +int anope_event_snick(char *source, int ac, char **av) +{ + User *user; + + if (ac != 2) { + user = do_nick(source, av[0], av[3], av[4], av[7], av[10], + strtoul(av[1], NULL, 10), strtoul(av[8], NULL, 0), + strtoul(av[5], NULL, 0), av[6], NULL); + if (user) { + anope_set_umode(user, 1, &av[9]); + } + } + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + + /* DALnet specific messages */ + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("RS", NULL); addCoreMessage(IRCD,m); + m = createMessage("SGLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SS", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", NULL); addCoreMessage(IRCD,m); + m = createMessage("SZLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSGLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSZLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SNICK", anope_event_snick); addCoreMessage(IRCD,m); + m = createMessage("VHOST", anope_event_vhost); addCoreMessage(IRCD,m); +} + +/* *INDENT-ON* */ + +void anope_cmd_sqline(char *mask, char *reason) +{ + if (!mask || !reason) { + return; + } + + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +void anope_cmd_unsgline(char *mask) +{ + send_cmd(NULL, "UNSGLINE 0 :%s", mask); +} + +void anope_cmd_unszline(char *mask) +{ + send_cmd(NULL, "UNSZLINE 0 %s", mask); +} +void anope_cmd_szline(char *mask, char *reason) +{ + send_cmd(NULL, "SZLINE %s :%s", mask, reason); +} + +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-")); +} + +void anope_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) +{ + send_cmd(NULL, "RAKILL %s %s", host, user); +} + + +/* PART */ +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (!nick || !chan) { + return; + } + + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +void anope_cmd_topic(char *whosets, char *chan, char *whosetit, + char *topic, time_t when) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +void anope_cmd_vhost_off(char *nick) +{ + send_cmd(s_HostServ, "SVSMODE %s -z", nick); +} + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + send_cmd(s_HostServ, "SVSMODE %s +z", nick); + send_cmd(ServerName, "VHOST %s %s", nick, vhost); +} + +void anope_cmd_unsqline(char *user) +{ + send_cmd(NULL, "UNSQLINE %s", user); +} + +void anope_cmd_join(char *user, char *channel, time_t chantime) +{ + send_cmd(user, "SJOIN %ld %s", chantime, channel); +} + +void anope_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, + time(NULL), reason); +} + +void anope_cmd_svskill(char *source, char *user, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + if (!source || !user) { + return; + } + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "SVSKILL %s :%s", user, buf); +} + +void anope_cmd_svsmode(User * u, int ac, char **av) +{ + send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, u->timestamp, + av[0], (ac == 2 ? " " : ""), (ac == 2 ? av[1] : "")); +} + +void anope_cmd_squit(char *servname, char *message) +{ + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +/* PONG */ +void anope_cmd_pong(char *servname, char *who) +{ + send_cmd(servname, "PONG %s", who); +} + +void anope_cmd_connect(int servernum) +{ + 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_svinfo() +{ + send_cmd(NULL, "SVINFO 5 5 0 %ld bluemoon 0", time(NULL)); +} + +void anope_cmd_capab() +{ + send_cmd(NULL, "CAPAB SSJ3 SN2 VHOST"); +} + +void anope_cmd_server(char *servname, int hop, char *descript) +{ + send_cmd(NULL, "SERVER %s %d :%s", ServerName, hop, ServerDesc); +} + +void anope_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 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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); + if (is_services_oper(user)) { + send_cmd(ServerName, "SVSMODE %s +a", user->nick); + user->mode |= UMODE_a; + } + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } +} + +/* GLOBOPS */ +void anope_cmd_global(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + + +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_cmd_serv_privmsg(char *source, char *dest, char *msg) +{ + send_cmd(source, "PRIVMSG $%s :%s", dest, msg); +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +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]); + return MOD_CONT; +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + 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); + } +} + + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_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) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +void anope_cmd_nick(char *nick, char *name, char *modes) +{ + send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick, + time(NULL), ServiceUser, ServiceHost, ServerName, modes, + name); + anope_cmd_sqline(nick, "Reserved for services"); +} + +int anope_event_os(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_ns(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_ms(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_hs(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_cs(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +void anope_cmd_bot_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, + time(NULL), user, host, ServerName, modes, real); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_unban(char *name, char *nick) +{ + send_cmd(ServerName, "SVSMODE %s -b %s", name, nick); +} + +void anope_cmd_bot_chan_mode(char *nick, char *chan) +{ + anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick); +} + +int anope_event_server(char *source, int ac, char **av) +{ + char *uplink; + + if (!stricmp(av[1], "1")) + uplink = sstrdup(av[0]); + do_server(source, ac, av); + return MOD_CONT; +} + + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + 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) +{ + /* Not supported */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + /* Not supported */ +} + +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +void anope_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, time(NULL), + user, host, ServerName, modes, real); +} + + +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + /* Not Supported by this IRCD */ +} + + +/* SVSMODE +d */ +/* sent if svid is something weird */ +void anope_cmd_svid_umode(char *nick, time_t ts) +{ + send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, ts); +} + +/* SVSMODE +d */ +/* nc_change was = 1, and there is no na->status */ +void anope_cmd_nc_change(User * u) +{ + common_svsmode(u, "+d", "1"); +} + +/* SVSMODE +d */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + // not used by bahamut ircds +} + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } +} + + + +#endif diff --git a/src/send.c b/src/send.c index a0284323a..ec7bc66ee 100644 --- a/src/send.c +++ b/src/send.c @@ -46,27 +46,7 @@ void vsend_cmd(const char *source, const char *fmt, va_list args) /*************************************************************************/ -/* Send out a WALLOPS (a GLOBOPS on ircd.dal). */ - -void wallops(const char *source, const char *fmt, ...) -{ - va_list args; - char buf[BUFSIZE]; - - va_start(args, fmt); - - vsnprintf(buf, sizeof(buf), fmt, args); -#ifdef IRC_HYBRID - send_cmd(source ? source : ServerName, "WALLOPS :%s", buf); -#else - send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); -#endif -} - -/*************************************************************************/ - -/* Send a NOTICE from the given source to the given nick. */ -void notice(const char *source, const char *dest, const char *fmt, ...) +void notice_server(char *source, Server * s, char *fmt, ...) { va_list args; char buf[BUFSIZE]; @@ -74,32 +54,16 @@ void notice(const char *source, const char *dest, const char *fmt, ...) va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); - send_cmd(source, "%s %s :%s", (UsePrivmsg ? "PRIVMSG" : "NOTICE"), - dest, buf); -} - -/*************************************************************************/ - -void notice_server(const char *source, Server * s, const char *fmt, ...) -{ - va_list args; - char buf[BUFSIZE]; - - va_start(args, fmt); - - vsnprintf(buf, sizeof(buf), fmt, args); -#ifdef IRC_HYBRID - send_cmd(source, "%s $$%s :%s", (UsePrivmsg ? "PRIVMSG" : "NOTICE"), - s->name, buf); -#else - send_cmd(source, "%s $%s :%s", (UsePrivmsg ? "PRIVMSG" : "NOTICE"), - s->name, buf); -#endif + if (UsePrivmsg) { + anope_cmd_serv_privmsg(source, s->name, buf); + } else { + anope_cmd_serv_notice(source, s->name, buf); + } } /*************************************************************************/ -void notice_user(const char *source, User * u, const char *fmt, ...) +void notice_user(char *source, User * u, const char *fmt, ...) { va_list args; char buf[BUFSIZE]; @@ -107,15 +71,17 @@ void notice_user(const char *source, User * u, const char *fmt, ...) va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); - send_cmd(source, "%s %s :%s", - (UsePrivmsg && (!u->na || (u->na->nc->flags & NI_MSG)) ? - "PRIVMSG" : "NOTICE"), u->nick, buf); + if (UsePrivmsg && (!u->na || (u->na->nc->flags & NI_MSG))) { + anope_cmd_privmsg2(source, u->nick, buf); + } else { + anope_cmd_notice2(source, u->nick, buf); + } } /*************************************************************************/ /* Send a NULL-terminated array of text as NOTICEs. */ -void notice_list(const char *source, const char *dest, const char **text) +void notice_list(char *source, char *dest, char **text) { while (*text) { /* Have to kludge around an ircII bug here: if a notice includes @@ -123,9 +89,9 @@ void notice_list(const char *source, const char *dest, const char **text) * with a single space. */ if (**text) - notice(source, dest, *text); + anope_cmd_notice2(source, dest, *text); else - notice(source, dest, " "); + anope_cmd_notice2(source, dest, " "); text++; } } @@ -133,7 +99,7 @@ void notice_list(const char *source, const char *dest, const char **text) /*************************************************************************/ /* Send a message in the user's selected language to the user using NOTICE. */ -void notice_lang(const char *source, User * dest, int message, ...) +void notice_lang(char *source, User * dest, int message, ...) { va_list args; char buf[4096]; /* because messages can be really big */ @@ -153,12 +119,11 @@ void notice_lang(const char *source, User * dest, int message, ...) s += strcspn(s, "\n"); if (*s) *s++ = 0; - send_cmd(source, "%s %s :%s", (UsePrivmsg - && (!dest->na || (dest->na->nc-> - flags & - NI_MSG)) ? - "PRIVMSG" : "NOTICE"), - dest->nick, *t ? t : " "); + if (UsePrivmsg && (!dest->na || (dest->na->nc->flags & NI_MSG))) { + anope_cmd_privmsg2(source, dest->nick, *t ? t : " "); + } else { + anope_cmd_notice2(source, dest->nick, *t ? t : " "); + } } } @@ -168,7 +133,7 @@ void notice_lang(const char *source, User * dest, int message, ...) * to simplify letting help messages display the name of the pseudoclient * that's sending them. */ -void notice_help(const char *source, User * dest, int message, ...) +void notice_help(char *source, User * dest, int message, ...) { va_list args; char buf[4096], buf2[4096], outbuf[BUFSIZE]; @@ -195,19 +160,18 @@ void notice_help(const char *source, User * dest, int message, ...) *s++ = 0; strscpy(outbuf, t, sizeof(outbuf)); strnrepl(outbuf, sizeof(outbuf), "\1\1", source); - send_cmd(source, "%s %s :%s", - (UsePrivmsg - && (!dest->na - || (dest->na->nc-> - flags & NI_MSG)) ? "PRIVMSG" : "NOTICE"), - dest->nick, *outbuf ? outbuf : " "); + if (UsePrivmsg && (!dest->na || (dest->na->nc->flags & NI_MSG))) { + anope_cmd_privmsg2(source, dest->nick, *outbuf ? outbuf : " "); + } else { + anope_cmd_notice2(source, dest->nick, *outbuf ? outbuf : " "); + } } } /*************************************************************************/ -/* Send a PRIVMSG from the given source to the given nick. */ -void privmsg(const char *source, const char *dest, const char *fmt, ...) +/* Send a NOTICE from the given source to the given nick. */ +void notice(char *source, char *dest, const char *fmt, ...) { va_list args; char buf[BUFSIZE]; @@ -215,13 +179,17 @@ void privmsg(const char *source, const char *dest, const char *fmt, ...) va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); - send_cmd(source, "PRIVMSG %s :%s", dest, buf); + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + anope_cmd_notice2(source, dest, buf); + } } /*************************************************************************/ -/* Sends a MODE from the given source on the given nick */ -void send_mode(const char *source, const char *on, const char *fmt, ...) +/* Send a PRIVMSG from the given source to the given nick. */ +void privmsg(char *source, char *dest, const char *fmt, ...) { va_list args; char buf[BUFSIZE]; @@ -229,17 +197,5 @@ void send_mode(const char *source, const char *on, const char *fmt, ...) va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); -#ifdef IRC_BAHAMUT - -/* Ultimate3 doesn't send TS Mode - doing so will cause modes not to send */ -/* btw - this is used by channel setting was well - TSL */ -#if !defined(IRC_ULTIMATE3) - if (uplink_capab & CAPAB_TSMODE) - send_cmd(source, "MODE %s 0 %s", on, buf); - else -#endif -#endif - send_cmd(source, "MODE %s %s", on, buf); + anope_cmd_privmsg2(source, dest, buf); } - -/*************************************************************************/ diff --git a/src/servers.c b/src/servers.c index 71e6ce92a..8a672f248 100644 --- a/src/servers.c +++ b/src/servers.c @@ -16,9 +16,7 @@ Server *servlist = NULL; Server *me_server = NULL; -#ifdef IRC_BAHAMUT -uint16 uplink_capab; -#endif +uint32 uplink_capab; /* For first_server / next_server */ static Server *server_cur; @@ -112,10 +110,8 @@ Server *new_server(Server * uplink, const char *name, const char *desc, static void delete_server(Server * serv, const char *quitreason) { Server *s, *snext; -#ifdef IRC_BAHAMUT User *u, *unext; NickAlias *na; -#endif if (!serv) { alog("delete_server() called with NULL arg!"); @@ -125,32 +121,32 @@ static void delete_server(Server * serv, const char *quitreason) if (debug) alog("delete_server() called for %s", serv->name); -#ifdef IRC_BAHAMUT - if (uplink_capab & CAPAB_NOQUIT) { - u = firstuser(); - while (u) { - unext = nextuser(); - if (u->server == serv) { - if ((na = u->na) && !(na->status & NS_VERBOTEN) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { - na->last_seen = time(NULL); - if (na->last_quit) - free(na->last_quit); - na->last_quit = - (quitreason ? sstrdup(quitreason) : NULL); - } + if (ircdcap->noquit) { + if (uplink_capab & ircdcap->noquit) { + u = firstuser(); + while (u) { + unext = nextuser(); + if (u->server == serv) { + if ((na = u->na) && !(na->status & NS_VERBOTEN) + && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + na->last_seen = time(NULL); + if (na->last_quit) + free(na->last_quit); + na->last_quit = + (quitreason ? sstrdup(quitreason) : NULL); + } #ifndef STREAMLINED - if (LimitSessions) - del_session(u->host); + if (LimitSessions) + del_session(u->host); #endif - delete_user(u); + delete_user(u); + } + u = unext; } - u = unext; + if (debug >= 2) + alog("delete_server() cleared all users"); } - if (debug >= 2) - alog("delete_server() cleared all users"); } -#endif s = serv->links; while (s) { @@ -215,17 +211,23 @@ void do_server(const char *source, int ac, char **av) s = me_server; else s = findserver(servlist, source); -#ifdef IRC_PTLINK - if (ac < 4) - alog("Malformed SERVER received (less than 4 params)"); - else - new_server(s, av[0], av[3], 0); -#else - if (ac < 3) - alog("Malformed SERVER received (less than 3 params)"); - else - new_server(s, av[0], av[2], 0); -#endif + if (ircd->numservargs == 4) { + if (ac < 4) + alog("Malformed SERVER received (less than 4 params)"); + else + new_server(s, av[0], av[3], 0); + } + if (ircd->numservargs == 7) { + if (ac < 7) + alog("Malformed SERVER received (less than 7 params)"); + else + new_server(s, av[0], av[6], 0); + } else { + if (ac < 3) + alog("Malformed SERVER received (less than 3 params)"); + else + new_server(s, av[0], av[2], 0); + } } /*************************************************************************/ @@ -245,15 +247,94 @@ void do_squit(const char *source, int ac, char **av) snprintf(buf, sizeof(buf), "%s %s", s->name, (s->uplink ? s->uplink->name : "")); -#ifdef IRC_BAHAMUT - if ((s->uplink == me_server) && (uplink_capab & CAPAB_UNCONNECT)) { - if (debug) - alog("debuf: Sending UNCONNECT SQUIT for %s", s->name); - send_cmd(ServerName, "SQUIT %s :%s", s->name, buf); + if (ircdcap->unconnect) { + if ((s->uplink == me_server) + && (uplink_capab & ircdcap->unconnect)) { + if (debug) + alog("debuf: Sending UNCONNECT SQUIT for %s", s->name); + /* need to fix */ + anope_cmd_squit(s->name, buf); + } } -#endif delete_server(s, buf); } +void capab_parse(int ac, char **av) +{ + int i; + + for (i = 0; i < ac; i++) { + if (!stricmp(av[i], "NOQUIT")) { + uplink_capab |= CAPAB_NOQUIT; + } + if (!stricmp(av[i], "TSMODE")) { + uplink_capab |= CAPAB_TSMODE; + } + if (!stricmp(av[i], "UNCONNECT")) { + uplink_capab |= CAPAB_UNCONNECT; + } + if (!stricmp(av[i], "NICKIP")) { + uplink_capab |= CAPAB_NICKIP; + } + if (!stricmp(av[i], "SSJOIN")) { + uplink_capab |= CAPAB_NSJOIN; + } + if (!stricmp(av[i], "ZIP")) { + uplink_capab |= CAPAB_ZIP; + } + if (!stricmp(av[i], "BURST")) { + uplink_capab |= CAPAB_BURST; + } + if (!stricmp(av[i], "TS5")) { + uplink_capab |= CAPAB_TS5; + } + if (!stricmp(av[i], "TS3")) { + uplink_capab |= CAPAB_TS3; + } + if (!stricmp(av[i], "DKEY")) { + uplink_capab |= CAPAB_DKEY; + } + if (!stricmp(av[i], "PT4")) { + uplink_capab |= CAPAB_PT4; + } + if (!stricmp(av[i], "SCS")) { + uplink_capab |= CAPAB_SCS; + } + if (!stricmp(av[i], "QS")) { + uplink_capab |= CAPAB_QS; + } + if (!stricmp(av[i], "UID")) { + uplink_capab |= CAPAB_UID; + } + if (!stricmp(av[i], "KNOCK")) { + uplink_capab |= CAPAB_KNOCK; + } + if (!stricmp(av[i], "CLIENT")) { + uplink_capab |= CAPAB_CLIENT; + } + if (!stricmp(av[i], "IPV6")) { + uplink_capab |= CAPAB_IPV6; + } + if (!stricmp(av[i], "SSJ5")) { + uplink_capab |= CAPAB_SSJ5; + } + if (!stricmp(av[i], "SN2")) { + uplink_capab |= CAPAB_SN2; + } + if (!stricmp(av[i], "TOK1")) { + uplink_capab |= CAPAB_TOKEN; + } + if (!stricmp(av[i], "TOKEN")) { + uplink_capab |= CAPAB_TOKEN; + } + if (!stricmp(av[i], "VHOST")) { + uplink_capab |= CAPAB_VHOST; + } + if (!stricmp(av[i], "SSJ3")) { + uplink_capab |= CAPAB_SSJ3; + } + } +} + /* EOF */ diff --git a/src/sessions.c b/src/sessions.c index 1620a2e15..948d28807 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -219,7 +219,7 @@ static Session *findsession(const char *host) * Returns 1 if the host was added or 0 if the user was killed. */ -int add_session(const char *nick, const char *host) +int add_session(char *nick, char *host) { Session *session, **list; Exception *exception; @@ -245,12 +245,8 @@ int add_session(const char *nick, const char *host) /* We don't use kill_user() because a user stucture has not yet * been created. Simply kill the user. -TheShadow */ -#ifdef IRC_BAHAMUT - send_cmd(NULL, "SVSKILL %s :Session limit exceeded", nick); -#else - send_cmd(s_OperServ, "KILL %s :%s (Session limit exceeded)", - nick, s_OperServ); -#endif + kill_user(s_OperServ, nick, "Session limit exceeded"); + session->hits++; if (MaxSessionKill && session->hits >= MaxSessionKill) { char akillmask[BUFSIZE]; @@ -258,9 +254,9 @@ int add_session(const char *nick, const char *host) add_akill(NULL, akillmask, s_OperServ, time(NULL) + SessionAutoKillExpiry, "Session limit exceeded"); - wallops(s_OperServ, - "Added a temporary AKILL for \2%s\2 due to excessive connections", - akillmask); + anope_cmd_global(s_OperServ, + "Added a temporary AKILL for \2%s\2 due to excessive connections", + akillmask); } return 0; } else { @@ -292,9 +288,9 @@ void del_session(const char *host) session = findsession(host); if (!session) { - wallops(s_OperServ, - "WARNING: Tried to delete non-existant session: \2%s", - host); + anope_cmd_global(s_OperServ, + "WARNING: Tried to delete non-existant session: \2%s", + host); alog("session: Tried to delete non-existant session: %s", host); return; } @@ -337,9 +333,9 @@ void expire_exceptions(void) if (exceptions[i].expires == 0 || exceptions[i].expires > now) continue; if (WallExceptionExpire) - wallops(s_OperServ, - "Session limit exception for %s has expired.", - exceptions[i].mask); + anope_cmd_global(s_OperServ, + "Session limit exception for %s has expired.", + exceptions[i].mask); free(exceptions[i].mask); free(exceptions[i].reason); nexceptions--; @@ -429,7 +425,7 @@ void load_exceptions() restore_db(f); \ log_perror("Write error on %s", ExceptionDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - wallops(NULL, "Write error on %s: %s", ExceptionDBName, \ + anope_cmd_global(NULL, "Write error on %s: %s", ExceptionDBName, \ strerror(errno)); \ lastwarn = time(NULL); \ } \ diff --git a/src/ultimate2.c b/src/ultimate2.c new file mode 100644 index 000000000..c58d876fc --- /dev/null +++ b/src/ultimate2.c @@ -0,0 +1,1318 @@ +/* Ultimate IRCD 2 functions + * + * (C) 2003 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. + * + * + */ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_ULTIMATE2 + +const char version_protocol[] = "UltimateIRCd 2.8.2+"; + +IRCDVar ircd[] = { + {"UltimateIRCd 2.8.*", /* ircd name */ + "+S", /* nickserv mode */ + "+S", /* chanserv mode */ + "+S", /* memoserv mode */ + "+oS", /* hostserv mode */ + "+iS", /* operserv mode */ + "+S", /* botserv mode */ + "+Sh", /* helpserv mode */ + "+iS", /* Dev/Null mode */ + "+iS", /* Global mode */ + "+oS", /* nickserv alias mode */ + "+oS", /* chanserv alias mode */ + "+oS", /* memoserv alias mode */ + "+ioS", /* hostserv alias mode */ + "+ioS", /* operserv alias mode */ + "+oS", /* botserv alias mode */ + "+oS", /* helpserv alias mode */ + "+iS", /* Dev/Null alias mode */ + "+ioS", /* Global alias mode */ + "+pS", /* Used by BotServ Bots */ + 3, /* Chan Max Symbols */ + "-kiflmnpstxAIKLORS", /* Modes to Remove */ + "+ao", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+rd", /* Mode On Reg */ + "-r+d", /* Mode on UnReg */ + "-r+d", /* Mode on Nick Change */ + 0, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + UMODE_p, /* Protected Umode */ + 0, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 0, /* Has Protect */ + 1, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 0, /* svshold */ + 1, /* time stamp on mode */ + 0, /* NICKIP */ + 1, /* UMODE */ + 0, /* O:LINE */ + 0, /* VHOST ON NICK */ + 1, /* Change RealName */ + CHAN_HELP_ULTIMATE, /* ChanServ extra */ + CMODE_K, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 1, /* +f */ + 1, /* +L */ + CMODE_f, + CMODE_L, + 0, + + } + , + {NULL} +}; + + +IRCDCAPAB ircdcap[] = { + { + 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 */ + } +}; + +void anope_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 'a': + if (add && !is_services_oper(user)) { + send_cmd(ServerName, "SVSMODE %s -a", user->nick); + user->mode &= ~UMODE_a; + } + break; + case 'P': + if (add && !is_services_admin(user)) { + send_cmd(ServerName, "SVSMODE %s -P", user->nick); + user->mode &= ~UMODE_P; + } + break; + case 'R': + if (add && !is_services_root(user)) { + send_cmd(ServerName, "SVSMODE %s -R", user->nick); + user->mode &= ~UMODE_R; + } + break; + case 'd': + if (ac == 0) { + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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); + if (is_services_oper(user)) { + send_cmd(ServerName, "SVSMODE %s +a", user->nick); + user->mode |= UMODE_a; + } + + if (is_services_admin(user)) { + send_cmd(ServerName, "SVSMODE %s +P", user->nick); + user->mode |= UMODE_P; + } + + if (is_services_root(user)) { + send_cmd(ServerName, "SVSMODE %s +R", user->nick); + user->mode |= UMODE_R; + } + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } +} + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + UMODE_P, + 0, + UMODE_R, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0, 0, 0, 0, 0, + 0, UMODE_a, 0, 0, 0, 0, 0, + UMODE_g, + UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, + UMODE_p, + 0, UMODE_r, 0, 0, 0, 0, UMODE_w, + UMODE_x, + 0, + 0, + 0, 0, 0, 0, 0 +}; + +char csmodes[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, + + '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, 0, 0 +}; + +CMMode cmmodes[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 cbmodes[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 */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {CMODE_I}, + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, + {CMODE_L, 0, set_redirect, cs_set_redirect}, + {0}, /* M */ + {0}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {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}, + {0}, + {0}, /* v */ + {0}, /* w */ + {CMODE_x}, + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} +}; + +CBModeInfo cbmodeinfos[] = { + {'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}, + {'x', CMODE_x, 0, NULL, NULL}, + {'A', CMODE_A, 0, NULL, NULL}, + {'I', CMODE_I, 0, NULL, NULL}, + {'K', CMODE_K, 0, NULL, NULL}, + {'L', CMODE_L, 0, get_redirect, cs_get_redirect}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {0} +}; + +CUMode cumodes[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}, /* a */ + {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 */ + {0}, /* q */ + {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} +}; + + +int anope_event_setname(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETNAME for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_realname(u, av[0]); + 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) { + 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) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETIDENT for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_username(u, av[0]); + return MOD_CONT; +} + +int anope_event_chgident(char *source, int ac, char **av) +{ + User *u; + + if (ac != 2) + return MOD_CONT; + + u = finduser(av[0]); + if (!u) { + alog("user: CHGIDENT for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_username(u, av[1]); + return MOD_CONT; +} + +int anope_event_sethost(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + if (debug) + alog("user: SETHOST for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_host(u, av[0]); + return MOD_CONT; +} + +int anope_event_nick(char *source, int ac, char **av) +{ + if (ac != 2) { + if (ac == 7) { + do_nick(source, av[0], av[3], av[4], av[5], av[6], + strtoul(av[2], NULL, 10), 0, 0, NULL, NULL); + } else { + do_nick(source, av[0], av[3], av[4], av[5], av[7], + strtoul(av[2], NULL, 10), strtoul(av[6], NULL, 0), 0, + NULL, NULL); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + 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) { + alog("user: CHGHOST for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_host(u, av[1]); + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + + /* DALnet specific messages */ + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + + m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("NETINFO", NULL); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); + m = createMessage("VCTRL", NULL); addCoreMessage(IRCD,m); +} + +/* *INDENT-ON* */ + +/* Event: PROTOCTL */ +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +void anope_cmd_sqline(char *mask, char *reason) +{ + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-")); +} + +void anope_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) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +void anope_cmd_vhost_off(char *nick) +{ + /* does not support vhosting */ +} + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + if (vIdent) { + send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); + } + send_cmd(s_HostServ, "SVSMODE %s +x", nick); + send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); +} + +void anope_cmd_unsqline(char *user) +{ + send_cmd(NULL, "UNSQLINE %s", user); +} + +void anope_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) +{ + send_cmd(NULL, "AKILL %s %s :%s", host, user, reason); +} + +void anope_cmd_svskill(char *source, char *user, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "KILL %s :%s", user, buf); +} + +void anope_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) +{ + 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) +{ + send_cmd(NULL, "PASS :%s", pass); +} + +/* SERVER name hop descript */ +void anope_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) +{ + send_cmd(servname, "PONG %s", who); +} + +/* CHGHOST */ +void anope_cmd_chghost(char *nick, char *vhost) +{ + if (!nick || !vhost) { + return; + } + send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); +} + +/* CHGIDENT */ +void anope_cmd_chgident(char *nick, char *vIdent) +{ + if (!nick || !vIdent) { + return; + } + send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); +} + +/* INVITE */ +void anope_cmd_invite(char *source, char *chan, char *nick) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +/* PART */ +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (!nick || !chan) { + return; + } + + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +/* GLOBOPS */ +void anope_cmd_global(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +/* SQUIT */ +void anope_cmd_squit(char *servname, char *message) +{ + if (!servname || !message) { + return; + } + + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +/* SVSO */ +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + if (!source || !nick || !flag) { + return; + } + + send_cmd(source, "SVSO %s %s", nick, flag); +} + +/* NICK <newnick> */ +void anope_cmd_chg_nick(char *oldnick, char *newnick) +{ + if (!oldnick || !newnick) { + return; + } + + send_cmd(oldnick, "NICK %s", newnick); +} + +/* SVSNICK */ +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +/* Events */ + +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]); + return MOD_CONT; +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +/* EVENT: SERVER */ +int anope_event_server(char *source, int ac, char **av) +{ + char *uplink; + + if (!stricmp(av[1], "1")) + uplink = sstrdup(av[0]); + do_server(source, ac, av); + return MOD_CONT; +} + + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + + +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_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) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick, time(NULL), + ServiceUser, ServiceHost, ServerName, name); + anope_cmd_mode(nick, nick, "%s", mode); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_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); +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +void anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(source, "MODE %s %s", dest, buf); +} + +void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real, + char *modes) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick, time(NULL), + user, host, ServerName, real); + anope_cmd_mode(nick, "MODE %s %s", nick, modes); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_cmd_376(char *source) +{ + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); +} + +void anope_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) +{ + /* Not supported by this IRCD */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + /* Not Supported by this IRCD */ +} + +/* UNSGLINE */ +void anope_cmd_unsgline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* UNSZLINE */ +void anope_cmd_unszline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* SZLINE */ +void anope_cmd_szline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +/* SGLINE */ +void anope_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) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick, time(NULL), + user, host, ServerName, real); + anope_cmd_mode(nick, "MODE %s %s", nick, modes); +} + + +void anope_cmd_unban(char *name, 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) +{ + 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) +{ + common_svsmode(u, "-r+d", "1"); +} + +/* SVSMODE +r */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } +} + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + // not used +} + + + +#endif diff --git a/src/ultimate3.c b/src/ultimate3.c new file mode 100644 index 000000000..fb866d447 --- /dev/null +++ b/src/ultimate3.c @@ -0,0 +1,1427 @@ +/* Ultimate IRCD 3 functions + * + * (C) 2003 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. + * + * + */ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_ULTIMATE3 + +const char version_protocol[] = "UltimateIRCd 3.0.0.a26+"; + +IRCDVar ircd[] = { + {"UltimateIRCd 3.0.*", /* ircd name */ + "+S", /* nickserv mode */ + "+S", /* chanserv mode */ + "+S", /* memoserv mode */ + "+o", /* hostserv mode */ + "+iS", /* operserv mode */ + "+S", /* botserv mode */ + "+Sh", /* helpserv mode */ + "+iS", /* Dev/Null mode */ + "+iS", /* 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 */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+S", /* Used by BotServ Bots */ + 5, /* Chan Max Symbols */ + "-iklmnpstRKAO", /* Modes to Remove */ + "+ao", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+rd", /* Mode On Reg */ + "-r+d", /* Mode on UnReg */ + "+d", /* Mode on Nick Change */ + 1, /* 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 */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + UMODE_p, /* Protected Umode */ + 1, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 0, /* vidents */ + 0, /* svshold */ + 1, /* time stamp on mode */ + 0, /* NICKIP */ + 1, /* UMODE */ + 0, /* O:LINE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CHAN_HELP_ULTIMATE3, /* ChanServ extra */ + CMODE_K, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, + 0, + 1, + }, + {NULL} +}; + +IRCDCAPAB ircdcap[] = { + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + 0, /* NICKIP */ + CAPAB_NSJOIN, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + CAPAB_BURST, /* BURST */ + CAPAB_TS5, /* TS5 */ + 0, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + CAPAB_CLIENT, /* CLIENT */ + CAPAB_IPV6, /* IPV6 */ + CAPAB_SSJ5, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + CAPAB_DODKEY, /* DODKEY */ + CAPAB_DOZIP /* DOZIP */ + } +}; + +void anope_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 'a': + if (add && !is_services_oper(user)) { + send_cmd(ServerName, "SVSMODE %s -a", user->nick); + user->mode &= ~UMODE_a; + } + break; + case 'P': + if (add && !is_services_admin(user)) { + send_cmd(ServerName, "SVSMODE %s -P", user->nick); + user->mode &= ~UMODE_P; + } + break; + case 'Z': + if (add && !is_services_root(user)) { + send_cmd(ServerName, "SVSMODE %s -Z", user->nick); + user->mode &= ~UMODE_Z; + } + break; + case 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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); + if (is_services_oper(user)) { + send_cmd(ServerName, "SVSMODE %s +a", user->nick); + user->mode |= UMODE_a; + } + + if (is_services_admin(user)) { + send_cmd(ServerName, "SVSMODE %s +P", user->nick); + user->mode |= UMODE_P; + } + + if (is_services_root(user)) { + send_cmd(ServerName, "SVSMODE %s +Z", user->nick); + user->mode |= UMODE_Z; + } + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } +} + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + UMODE_P, + 0, + 0, + 0, 0, 0, 0, 0, 0, 0, + UMODE_Z, + 0, 0, 0, 0, 0, + 0, UMODE_a, 0, 0, 0, 0, 0, + 0, + UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, + UMODE_p, + 0, UMODE_r, 0, 0, 0, 0, UMODE_w, + UMODE_x, + 0, + 0, + 0, 0, 0, 0, 0 +}; + + +char csmodes[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, + 'a', /* (33) ! Channel Admins */ + 0, 0, 0, + 'h', /* (37) % Channel halfops */ + 0, 0, 0, 0, + 0, + + '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, 0, 0 +}; + + +CMMode cmmodes[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 cbmodes[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 */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, + {0}, /* L */ + {CMODE_M}, + {CMODE_N, 0, NULL, NULL}, + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {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}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} +}; + +CBModeInfo cbmodeinfos[] = { + {'c', CMODE_c, 0, NULL, NULL}, + {'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}, + {'A', CMODE_A, 0, NULL, NULL}, + {'K', CMODE_K, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {0} +}; + +CUMode cumodes[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_admin}, + {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 */ + {0}, /* q */ + {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} +}; + + +/* SVSMODE -b */ +void anope_cmd_unban(char *name, char *nick) +{ + send_cmd(ServerName, "SVSMODE %s -b %s", name, nick); +} + +int anope_event_sjoin(char *source, int ac, char **av) +{ + do_sjoin(source, ac, av); + return MOD_CONT; +} + + +/* +** NICK - new +** source = NULL +** parv[0] = nickname +** parv[1] = hopcount +** parv[2] = timestamp +** parv[3] = modes +** parv[4] = username +** parv[5] = hostname +** parv[6] = server +** parv[7] = servicestamp +** parv[8] = IP +** parv[9] = info +** NICK - change +** source = oldnick +** parv[0] = new nickname +** parv[1] = hopcount +*/ +int anope_event_nick(char *source, int ac, char **av) +{ + if (ac != 2) { + User *user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, + 0), + strtoul(av[8], NULL, 0), "*", NULL); + if (user) + anope_set_umode(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + 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", av[0]); + return MOD_CONT; + } + + change_user_host(u, av[1]); + return MOD_CONT; +} + +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +/* +** CLIENT +** source = NULL +** parv[0] = nickname Trystan +** parv[1] = hopcount 1 +** parv[2] = timestamp 1090083810 +** parv[3] = modes +ix +** parv[4] = modes ? + +** parv[5] = username Trystan +** parv[6] = hostname c-24-2-101-227.client.comcast.net +** parv[7] = vhost 3223f75b.2b32ee69.client.comcast.net +** parv[8] = server WhiteRose.No.Eu.Shadow-Realm.org +** parv[9] = svid 0 +** parv[10] = ip 402810339 +** parv[11] = info Dreams are answers to questions not yet asked +*/ +int anope_event_client(char *source, int ac, char **av) +{ + if (ac != 2) { + User *user = do_nick(source, av[0], av[5], av[6], av[8], av[11], + strtoul(av[2], NULL, 10), strtoul(av[9], NULL, + 0), + strtoul(av[10], NULL, 0), av[7], NULL); + if (user) { + anope_set_umode(user, 1, &av[3]); + } + } + return MOD_CONT; +} + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("RS", NULL); addCoreMessage(IRCD,m); + m = createMessage("SGLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SS", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", NULL); addCoreMessage(IRCD,m); + m = createMessage("SZLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSGLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSZLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("NETINFO", NULL); addCoreMessage(IRCD,m); + m = createMessage("GCONNECT", NULL); addCoreMessage(IRCD,m); + m = createMessage("NETGLOBAL", NULL); addCoreMessage(IRCD,m); + m = createMessage("CHATOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("NETCTRL", NULL); addCoreMessage(IRCD,m); + m = createMessage("CLIENT", anope_event_client); addCoreMessage(IRCD,m); + m = createMessage("SMODE", NULL); addCoreMessage(IRCD,m); +} + +/* *INDENT-ON* */ + + +void anope_cmd_sqline(char *mask, char *reason) +{ + if (!mask || !reason) { + return; + } + + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +void anope_cmd_unsgline(char *mask) +{ + send_cmd(NULL, "UNSGLINE 0 :%s", mask); +} + +void anope_cmd_unszline(char *mask) +{ + send_cmd(NULL, "UNSZLINE 0 %s", mask); +} +void anope_cmd_szline(char *mask, char *reason) +{ + send_cmd(NULL, "SZLINE %s :%s", mask, reason); +} + +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-")); +} + +void anope_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) +{ + send_cmd(NULL, "RAKILL %s %s", host, user); +} + +void anope_cmd_vhost_off(char *nick) +{ + send_cmd(s_HostServ, "SVSMODE %s -x", nick); +} + +void anope_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) +{ + send_cmd(user, "SJOIN %ld %s", chantime, channel); +} + +void anope_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, + time(NULL), reason); +} + +void anope_cmd_svskill(char *source, char *user, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "SVSKILL %s :%s", user, buf); +} + + +void anope_cmd_svsmode(User * u, int ac, char **av) +{ + send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, u->timestamp, + av[0], (ac == 2 ? " " : ""), (ac == 2 ? av[1] : "")); +} + +void anope_squit(char *servname, char *message) +{ + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +void anope_pong(char *servname) +{ + send_cmd(servname, "PONG %s", servname); +} + +/* Events */ + +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]); + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + +int anope_event_os(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_ns(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_ms(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_hs(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_cs(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +int anope_event_setname(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETNAME for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_realname(u, av[0]); + 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) { + 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) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETIDENT for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_username(u, av[0]); + return MOD_CONT; +} +int anope_event_chgident(char *source, int ac, char **av) +{ + User *u; + + if (ac != 2) + return MOD_CONT; + + u = finduser(av[0]); + if (!u) { + alog("user: CHGIDENT for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_username(u, av[1]); + return MOD_CONT; +} + +/* EVENT: SERVER */ +int anope_event_server(char *source, int ac, char **av) +{ + char *uplink; + + if (!stricmp(av[1], "1")) + uplink = sstrdup(av[0]); + do_server(source, ac, av); + return MOD_CONT; +} + + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +void anope_cmd_topic(char *whosets, char *chan, char *whosetit, + char *topic, time_t when) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_cmd_376(char *source) +{ + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); +} + +void anope_cmd_nick(char *nick, char *name, char *modes) +{ + send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick, + time(NULL), modes, ServiceUser, ServiceHost, ServerName, + name); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_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, + time(NULL), modes, user, host, ServerName, real); +} + +void anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(source, "MODE %s %s", dest, buf); +} + +void anope_cmd_bot_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, + time(NULL), modes, user, host, ServerName, real); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + + +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_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) +{ + anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick); +} + +void anope_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); +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +/* PROTOCTL */ +void anope_cmd_capab() +{ + send_cmd(NULL, "CAPAB NICKIP SSJ5 TS5 CLIENT"); +} + +/* PASS */ +void anope_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) +{ + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); +} + +/* PONG */ +void anope_cmd_pong(char *servname, char *who) +{ + send_cmd(servname, "PONG %s", who); +} + +/* UNSQLINE */ +void anope_cmd_unsqline(char *user) +{ + if (!user) { + return; + } + send_cmd(NULL, "UNSQLINE %s", user); +} + +/* CHGHOST */ +void anope_cmd_chghost(char *nick, char *vhost) +{ + if (!nick || !vhost) { + return; + } + send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); +} + +/* CHGIDENT */ +void anope_cmd_chgident(char *nick, char *vIdent) +{ + if (!nick || !vIdent) { + return; + } + send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); +} + +/* INVITE */ +void anope_cmd_invite(char *source, char *chan, char *nick) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +/* PART */ +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (!nick || !chan) { + return; + } + + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +/* GLOBOPS */ +void anope_cmd_global(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +/* SQUIT */ +void anope_cmd_squit(char *servname, char *message) +{ + if (!servname || !message) { + return; + } + + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +/* SVSO */ +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + if (!source || !nick || !flag) { + return; + } + + send_cmd(source, "SVSO %s %s", nick, flag); +} + +/* NICK <newnick> */ +void anope_cmd_chg_nick(char *oldnick, char *newnick) +{ + if (!oldnick || !newnick) { + return; + } + + send_cmd(oldnick, "NICK %s", newnick); +} + +/* SVSNICK */ +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +/* Functions that use serval cmd functions */ + +void anope_cmd_connect(int servernum) +{ + if (!servernum) { + servernum = 1; + } + + if (servernum == 1) { + anope_cmd_pass(RemotePassword); + } + if (servernum == 2) { + anope_cmd_pass(RemotePassword2); + } + if (servernum == 3) { + anope_cmd_pass(RemotePassword3); + } + anope_cmd_capab(); + anope_cmd_server(ServerName, 1, ServerDesc); +} + +/* SVSHOLD - set */ +void anope_cmd_svshold(char *nick) +{ + /* Not supported by this IRCD */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_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) +{ + send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, ts); +} + +/* SVSMODE +d */ +/* nc_change was = 1, and there is no na->status */ +void anope_cmd_nc_change(User * u) +{ + common_svsmode(u, "+d", "1"); +} + +/* SVSMODE +d */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + // not used by bahamut ircds +} + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } + +} + + + +#endif diff --git a/src/unreal31.c b/src/unreal31.c new file mode 100644 index 000000000..72e30ff1f --- /dev/null +++ b/src/unreal31.c @@ -0,0 +1,1340 @@ +/* Unreal IRCD 3.1.x functions + * + * (C) 2003 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. + * + * + */ + +/*************************************************************************/ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_UNREAL31 + +const char version_protocol[] = "UnrealIRCd 3.1.1+"; + +IRCDVar ircd[] = { + {"UnrealIRCd 3.1.x", /* ircd name */ + "+oS", /* nickserv mode */ + "+oS", /* chanserv mode */ + "+oS", /* memoserv mode */ + "+oS", /* hostserv mode */ + "+ioS", /* operserv mode */ + "+oS", /* botserv mode */ + "+oS", /* helpserv mode */ + "+iS", /* Dev/Null mode */ + "+ioS", /* Global mode */ + "+oS", /* nickserv alias mode */ + "+oS", /* chanserv alias mode */ + "+oS", /* memoserv alias mode */ + "+ioS", /* hostserv alias mode */ + "+ioS", /* operserv alias mode */ + "+oS", /* botserv alias mode */ + "+oS", /* helpserv alias mode */ + "+iS", /* Dev/Null alias mode */ + "+ioS", /* Global alias mode */ + "+qS", /* Used by BotServ Bots */ + 5, /* Chan Max Symbols */ + "-ckiflmnpstuzACGHKLNOQRSV", /* 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 */ + "+rd", /* Mode On Reg */ + "-r+d", /* Mode on UnReg */ + "-r+d", /* Mode on Nick Change */ + 0, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 1, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 1, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 1, /* Has Protect */ + 1, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 1, /* svshold */ + 1, /* time stamp on mode */ + 0, /* NICKIP */ + 1, /* UMODE */ + 1, /* O:LINE */ + 1, /* VHOST ON NICK */ + 1, /* Change RealName */ + CHAN_HELP_UNREAL, /* ChanServ extra */ + CMODE_K, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 1, /* +f */ + 1, /* +L */ + CMODE_f, + CMODE_L, + 0, + + }, + {NULL} +}; + + +IRCDCAPAB ircdcap[] = { + { + CAPAB_NOQUIT, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* 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 */ + CAPAB_SSJ3, /* SSJ3 */ + CAPAB_NICK2, /* NICK2 */ + CAPAB_UMODE2, /* UMODE2 */ + CAPAB_VL, /* VL */ + CAPAB_TLKEXT, /* TLKEXT */ + 0, /* DODKEY */ + 0 /* DOZIP */ + } +}; + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 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_a, 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 csmodes[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, + + '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, 0, 0 +}; + +CMMode cmmodes[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 cbmodes[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}, + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {CMODE_G, 0, NULL, NULL}, + {CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* I */ + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, + {CMODE_L, 0, set_redirect, cs_set_redirect}, + {0}, /* M */ + {CMODE_N, 0, NULL, NULL}, + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {CMODE_Q, 0, NULL, NULL}, + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, + {0}, /* T */ + {0}, /* U */ + {CMODE_V, 0, NULL, NULL}, + {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 cbmodeinfos[] = { + {'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 cumodes[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 anope_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 'd': + if (ac == 0) { + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } +} + + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("STATS", m_stats); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("NETINFO", NULL); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); +} + +/* *INDENT-ON* */ + +/* Event: PROTOCTL */ +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-")); +} + +void anope_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) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +void anope_cmd_vhost_off(char *nick) +{ + send_cmd(s_HostServ, "SVSMODE %s -xt", nick); +} + +void anope_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, + time(NULL) + 86400 * 2, when, reason); +} + +void anope_cmd_svskill(char *source, char *user, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + if (!source || !user) { + return; + } + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "KILL %s :%s", user, buf); +} + +void anope_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) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_cmd_376(char *source) +{ + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); +} + +void anope_cmd_nick(char *nick, char *name, char *modes) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick, time(NULL), + ServiceUser, ServiceHost, ServerName, modes, name); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_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, time(NULL), + user, host, ServerName, modes, real); +} + +void anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(source, "MODE %s %s", dest, buf); +} + +void anope_cmd_bot_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, time(NULL), + user, host, ServerName, modes, real); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + + +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_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) +{ + anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick); +} + +void anope_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); +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +/* PROTOCTL */ +void anope_cmd_protoctl() +{ + /* + See Unreal's protoctl.txt for reference + VHP - Send hostnames in NICKv2 even if not sethosted + */ + send_cmd(NULL, "PROTOCTL NICKv2 VHP"); +} + +/* PASS */ +void anope_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) +{ + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); +} + +/* PONG */ +void anope_cmd_pong(char *servname, char *who) +{ + send_cmd(servname, "PONG %s", 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) +{ + send_cmd(user, "JOIN %s", channel); +} + +/* UNSQLINE */ +void anope_cmd_unsqline(char *user) +{ + if (!user) { + return; + } + send_cmd(NULL, "UNSQLINE %s", user); +} + +/* CHGHOST */ +void anope_cmd_chghost(char *nick, char *vhost) +{ + if (!nick || !vhost) { + return; + } + send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); +} + +/* CHGIDENT */ +void anope_cmd_chgident(char *nick, char *vIdent) +{ + if (!nick || !vIdent) { + return; + } + send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); +} + +/* INVITE */ +void anope_cmd_invite(char *source, char *chan, char *nick) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +/* PART */ +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (!nick || !chan) { + return; + } + + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +/* GLOBOPS */ +void anope_cmd_global(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +/* SQLINE */ +void anope_cmd_sqline(char *mask, char *reason) +{ + if (!mask || !reason) { + return; + } + + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +/* SQUIT */ +void anope_cmd_squit(char *servname, char *message) +{ + if (!servname || !message) { + return; + } + + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +/* SVSO */ +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + if (!source || !nick || !flag) { + return; + } + + send_cmd(source, "SVSO %s %s", nick, flag); +} + +/* NICK <newnick> */ +void anope_cmd_chg_nick(char *oldnick, char *newnick) +{ + if (!oldnick || !newnick) { + return; + } + + send_cmd(oldnick, "NICK %s", newnick); +} + +/* SVSNICK */ +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +/* Functions that use serval cmd functions */ + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + if (!nick) { + return; + } + if (vIdent) { + anope_cmd_chgident(nick, vIdent); + } + anope_cmd_chghost(nick, vhost); +} + +void anope_cmd_connect(int servernum) +{ + if (!servernum) { + servernum = 1; + } + + anope_cmd_protoctl(); + 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); +} + +/* Events */ + +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]); + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +int anope_event_setname(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETNAME for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_realname(u, av[0]); + 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) { + 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) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETIDENT for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_username(u, av[0]); + return MOD_CONT; +} +int anope_event_chgident(char *source, int ac, char **av) +{ + User *u; + + if (ac != 2) + return MOD_CONT; + + u = finduser(av[0]); + if (!u) { + alog("user: CHGIDENT for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_username(u, av[1]); + return MOD_CONT; +} + +int anope_event_sethost(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + if (debug) + alog("user: SETHOST for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_host(u, av[0]); + return MOD_CONT; +} + + +int anope_event_nick(char *source, int ac, char **av) +{ + User *user; + + if (ac != 2) { + if (ac == 7) { + /* + <codemastr> that was a bug that is now fixed in 3.2.1 + <codemastr> in some instances it would use the non-nickv2 format + <codemastr> it's sent when a nick collision occurs + - so we have to leave it around for now -TSL + */ + do_nick(source, av[0], av[3], av[4], av[5], av[6], + strtoul(av[2], NULL, 10), 0, 0, "*", NULL); + } else { + user = do_nick(source, av[0], av[3], av[4], av[5], av[9], + strtoul(av[2], NULL, 10), strtoul(av[6], NULL, + 0), 0, av[8], + NULL); + if (user) + anope_set_umode(user, 1, &av[7]); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + 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) { + 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) +{ + char *uplink; + + if (!stricmp(av[1], "1")) + uplink = sstrdup(av[0]); + do_server(source, ac, av); + return MOD_CONT; +} + + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +/* SVSHOLD - set */ +void anope_cmd_svshold(char *nick) +{ + /* Not supported by this IRCD */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + /* Not Supported by this IRCD */ +} + +/* UNSGLINE */ +void anope_cmd_unsgline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* UNSZLINE */ +void anope_cmd_unszline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* SZLINE */ +void anope_cmd_szline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +/* SGLINE */ +void anope_cmd_sgline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +void anope_cmd_unban(char *name, 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) +{ + 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) +{ + common_svsmode(u, "-r+d", "1"); +} + +/* SVSMODE +r */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } +} + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + // not used +} + +#endif diff --git a/src/unreal32.c b/src/unreal32.c new file mode 100644 index 000000000..a48fa0b94 --- /dev/null +++ b/src/unreal32.c @@ -0,0 +1,1434 @@ +/* Unreal IRCD 3.2.x functions + * + * (C) 2003 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. + * + * + */ + +/*************************************************************************/ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_UNREAL32 + +const char version_protocol[] = "UnrealIRCd 3.2+"; + +IRCDVar ircd[] = { + {"UnrealIRCd 3.2.x", /* ircd name */ + "+oS", /* nickserv mode */ + "+oS", /* chanserv mode */ + "+oS", /* memoserv mode */ + "+oS", /* hostserv mode */ + "+ioS", /* operserv mode */ + "+oS", /* botserv mode */ + "+oS", /* helpserv mode */ + "+iS", /* Dev/Null mode */ + "+ioS", /* Global mode */ + "+oS", /* nickserv alias mode */ + "+oS", /* chanserv alias mode */ + "+oS", /* memoserv alias mode */ + "+ioS", /* hostserv alias mode */ + "+ioS", /* operserv alias mode */ + "+oS", /* botserv alias mode */ + "+oS", /* helpserv alias mode */ + "+iS", /* Dev/Null alias mode */ + "+ioS", /* Global alias mode */ + "+qS", /* Used by BotServ Bots */ + 5, /* Chan Max Symbols */ + "-ckiflmnpstuzACGHKLNOQRSV", /* 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 */ + "+rd", /* Mode On Reg */ + "-r+d", /* Mode on UnReg */ + "-r+d", /* Mode on Nick Change */ + 0, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 1, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 1, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 1, /* Has Protect */ + 1, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 1, /* svshold */ + 1, /* time stamp on mode */ + 0, /* NICKIP */ + 1, /* UMODE */ + 1, /* O:LINE */ + 1, /* VHOST ON NICK */ + 1, /* Change RealName */ + CHAN_HELP_UNREAL, /* ChanServ extra */ + CMODE_K, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 1, /* +f */ + 1, /* +L */ + CMODE_f, + CMODE_L, + 0, + + }, + {NULL} +}; + +IRCDCAPAB ircdcap[] = { + { + CAPAB_NOQUIT, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* 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 */ + CAPAB_SSJ3, /* SSJ3 */ + CAPAB_NICK2, /* NICK2 */ + CAPAB_UMODE2, /* UMODE2 */ + CAPAB_VL, /* VL */ + CAPAB_TLKEXT, /* TLKEXT */ + 0, /* DODKEY */ + 0 /* DOZIP */ + } +}; + +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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 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_a, 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 csmodes[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, + + '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, 0, 0 +}; + +CMMode cmmodes[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 cbmodes[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}, + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {CMODE_G, 0, NULL, NULL}, + {CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* I */ + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, + {CMODE_L, 0, set_redirect, cs_set_redirect}, + {0}, /* M */ + {CMODE_N, 0, NULL, NULL}, + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {CMODE_Q, 0, NULL, NULL}, + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, + {0}, /* T */ + {0}, /* U */ + {CMODE_V, 0, NULL, NULL}, + {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 cbmodeinfos[] = { + {'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 cumodes[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 anope_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 'd': + if (ac == 0) { + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } +} + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", NULL); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("NETINFO", anope_event_netinfo); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); + m = createMessage("TKL", anope_event_tkl); addCoreMessage(IRCD,m); + m = createMessage("EOS", anope_event_eos); addCoreMessage(IRCD,m); + m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); +} + +/* *INDENT-ON* */ + + +/* Event: PROTOCTL */ +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +/* SVSNOOP */ +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-")); +} + +void anope_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) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +void anope_cmd_vhost_off(char *nick) +{ + send_cmd(s_HostServ, "SVSMODE %s -xt", nick); +} + +void anope_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, + time(NULL) + 86400 * 2, when, reason); +} + +void anope_cmd_svskill(char *source, char *user, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + if (!source || !user) { + return; + } + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "KILL %s :%s", user, buf); +} + +void anope_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] : "")); +} + +/* 372 */ +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_cmd_376(char *source) +{ + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); +} + +void anope_cmd_nick(char *nick, char *name, char *modes) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick, time(NULL), + ServiceUser, ServiceHost, ServerName, modes, name); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_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, time(NULL), + user, host, ServerName, modes, real); +} + +void anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(source, "MODE %s %s", dest, buf); +} + +void anope_cmd_bot_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, time(NULL), + user, host, ServerName, modes, real); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + + +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_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) +{ + anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick); +} + +void anope_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); +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +/* PROTOCTL */ +void anope_cmd_protoctl() +{ + /* + See Unreal's protoctl.txt for reference + VHP - Send hostnames in NICKv2 even if not sethosted + */ + send_cmd(NULL, "PROTOCTL NICKv2 VHP"); +} + +/* PASS */ +void anope_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) +{ + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); +} + +/* PONG */ +void anope_cmd_pong(char *servname, char *who) +{ + send_cmd(servname, "PONG %s", 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) +{ + send_cmd(user, "JOIN %s", channel); +} + +/* UNSQLINE */ +void anope_cmd_unsqline(char *user) +{ + if (!user) { + return; + } + send_cmd(NULL, "UNSQLINE %s", user); +} + +/* CHGHOST */ +void anope_cmd_chghost(char *nick, char *vhost) +{ + if (!nick || !vhost) { + return; + } + send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); +} + +/* CHGIDENT */ +void anope_cmd_chgident(char *nick, char *vIdent) +{ + if (!nick || !vIdent) { + return; + } + send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); +} + +/* INVITE */ +void anope_cmd_invite(char *source, char *chan, char *nick) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +/* PART */ +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (!nick || !chan) { + return; + } + + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +/* GLOBOPS */ +void anope_cmd_global(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +/* SQLINE */ +void anope_cmd_sqline(char *mask, char *reason) +{ + if (!mask || !reason) { + return; + } + + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +/* SQUIT */ +void anope_cmd_squit(char *servname, char *message) +{ + if (!servname || !message) { + return; + } + + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +/* SVSO */ +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + if (!source || !nick || !flag) { + return; + } + + send_cmd(source, "SVSO %s %s", nick, flag); +} + +/* NICK <newnick> */ +void anope_cmd_chg_nick(char *oldnick, char *newnick) +{ + if (!oldnick || !newnick) { + return; + } + + send_cmd(oldnick, "NICK %s", newnick); +} + +/* SVSNICK */ +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +/* Functions that use serval cmd functions */ + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + if (!nick) { + return; + } + if (vIdent) { + anope_cmd_chgident(nick, vIdent); + } + anope_cmd_chghost(nick, vhost); +} + +void anope_cmd_connect(int servernum) +{ + if (!servernum) { + servernum = 1; + } + + anope_cmd_protoctl(); + 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); +} + +/* Events */ + +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]); + return MOD_CONT; +} + +/* netinfo + * argv[0] = max global count + * argv[1] = time of end sync + * argv[2] = unreal protocol using (numeric) + * argv[3] = cloak-crc (> u2302) + * argv[4] = free(**) + * argv[5] = free(**) + * argv[6] = free(**) + * argv[7] = ircnet + */ +int anope_event_netinfo(char *source, int ac, char **av) +{ + anope_cmd_netinfo(ac, av); + return MOD_CONT; +} + +void anope_cmd_netinfo(int ac, char **av) +{ + send_cmd(NULL, "NETINFO 0 %d %d %s 0 0 0 :%s", atoi(av[1]), + atoi(av[2]), av[3], av[7]); +} + +/* TKL + * add: remove: spamfilter: spamfilter+TKLEXT sqline: + * parv[ 1]: + - +/- + +/- + * parv[ 2]: type type type type type + * parv[ 3]: user user target target hold + * parv[ 4]: host host action action host + * parv[ 5]: setby removedby (un)setby setby setby + * parv[ 6]: expire_at expire_at (0) expire_at (0) expire_at + * parv[ 7]: set_at set_at set_at set_at + * parv[ 8]: reason regex tkl duration reason + * parv[ 9]: tkl reason [A] + * parv[10]: regex + * +*/ +int anope_event_tkl(char *source, int ac, char **av) +{ + return MOD_CONT; +} + +int anope_event_eos(char *source, int ac, char **av) +{ + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + +/* +** away +** parv[0] = sender prefix +** parv[1] = away message +*/ +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +/* +** m_topic +** parv[0] = sender prefix +** parv[1] = topic text +** +** For servers using TS: +** parv[0] = sender prefix +** parv[1] = channel name +** parv[2] = topic nickname +** parv[3] = topic time +** parv[4] = topic text +*/ +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + +int anope_event_pass(char *source, int ac, char **av) +{ + return MOD_CONT; +} + + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +int anope_event_setname(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETNAME for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_realname(u, av[0]); + 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) { + 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) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETIDENT for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_username(u, av[0]); + return MOD_CONT; +} +int anope_event_chgident(char *source, int ac, char **av) +{ + User *u; + + if (ac != 2) + return MOD_CONT; + + u = finduser(av[0]); + if (!u) { + alog("user: CHGIDENT for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_username(u, av[1]); + return MOD_CONT; +} + +int anope_event_sethost(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + if (debug) + alog("user: SETHOST for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_host(u, av[0]); + return MOD_CONT; +} + + +/* +** NICK - new +** source = NULL +** parv[0] = nickname +** parv[1] = hopcount +** parv[2] = timestamp +** parv[3] = username +** parv[4] = hostname +** parv[5] = servername +** if NICK version 1: +** parv[6] = servicestamp +** parv[7] = info +** if NICK version 2: +** parv[6] = servicestamp +** parv[7] = umodes +** parv[8] = virthost, * if none +** parv[9] = info +** if NICKIP: +** parv[9] = ip +** parv[10] = info +** +** NICK - change +** source = oldnick +** parv[0] = new nickname +** parv[1] = hopcount +*/ +int anope_event_nick(char *source, int ac, char **av) +{ + User *user; + + if (ac != 2) { + if (ac == 7) { + /* + <codemastr> that was a bug that is now fixed in 3.2.1 + <codemastr> in some instances it would use the non-nickv2 format + <codemastr> it's sent when a nick collision occurs + - so we have to leave it around for now -TSL + */ + do_nick(source, av[0], av[3], av[4], av[5], av[6], + strtoul(av[2], NULL, 10), 0, 0, "*", NULL); + } else { + user = do_nick(source, av[0], av[3], av[4], av[5], av[9], + strtoul(av[2], NULL, 10), strtoul(av[6], NULL, + 0), 0, av[8], + NULL); + if (user) + anope_set_umode(user, 1, &av[7]); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + 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) { + 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) +{ + char *uplink; + + if (!stricmp(av[1], "1")) + uplink = sstrdup(av[0]); + do_server(source, ac, av); + return MOD_CONT; +} + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +/* SVSHOLD - set */ +void anope_cmd_svshold(char *nick) +{ + /* Not supported by this IRCD */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + /* Not Supported by this IRCD */ +} + +/* UNSGLINE */ +void anope_cmd_unsgline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* UNSZLINE */ +void anope_cmd_unszline(char *mask) +{ + /* Not Supported by this IRCD */ +} + +/* SZLINE */ +void anope_cmd_szline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +/* SGLINE */ +void anope_cmd_sgline(char *mask, char *reason) +{ + /* Not Supported by this IRCD */ +} + +/* SVSMODE -b */ +void anope_cmd_unban(char *name, 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) +{ + 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) +{ + common_svsmode(u, "-r+d", "1"); +} + +/* SVSMODE +r */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } +} + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + // not used +} + +#endif diff --git a/src/users.c b/src/users.c index bd86d8e93..34946be08 100644 --- a/src/users.c +++ b/src/users.c @@ -20,53 +20,6 @@ User *userlist[1024]; int32 usercnt = 0, opcnt = 0, maxusercnt = 0; time_t maxusertime; -static 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, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) - UMODE_P, -#else - 0, -#endif - 0, -#if defined(IRC_BAHAMUT) || defined(IRC_ULTIMATE) - UMODE_R, -#else - 0, -#endif - 0, 0, 0, 0, 0, 0, 0, -#ifdef IRC_ULTIMATE3 - UMODE_Z, -#else - 0, -#endif - 0, 0, 0, 0, 0, - 0, UMODE_a, 0, 0, 0, 0, 0, -#ifdef IRC_DREAMFORGE - UMODE_g, -#else - 0, -#endif - UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) - UMODE_p, -#else - 0, -#endif - 0, UMODE_r, 0, 0, 0, 0, UMODE_w, -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_RAGE2) - UMODE_x, -#else - 0, -#endif - 0, - 0, - 0, 0, 0, 0, 0 -}; - /*************************************************************************/ /*************************************************************************/ @@ -138,9 +91,7 @@ static void change_user_nick(User * user, const char *nick) /*************************************************************************/ -#ifdef HAS_VHOST - -static void update_host(User * user) +void update_host(User * user) { if (user->na && (nick_identified(user) || (!(user->na->nc->flags & NI_SECURE) @@ -149,22 +100,20 @@ static void update_host(User * user) free(user->na->last_usermask); user->na->last_usermask = - smalloc(strlen(GetIdent(user)) + strlen(GetHost(user)) + 2); - sprintf(user->na->last_usermask, "%s@%s", GetIdent(user), - GetHost(user)); + smalloc(strlen(common_get_vident(user)) + + strlen(common_get_vhost(user)) + 2); + sprintf(user->na->last_usermask, "%s@%s", common_get_vident(user), + common_get_vhost(user)); } if (debug) alog("debug: %s changes its host to %s", user->nick, - GetHost(user)); + common_get_vhost(user)); } -#endif /*************************************************************************/ -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_PTLINK) || defined(IRC_RAGE2) - /* Change the (virtual) hostname of a user. */ void change_user_host(User * user, const char *host) @@ -181,10 +130,8 @@ void change_user_host(User * user, const char *host) update_host(user); } -#endif /*************************************************************************/ -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_VIAGRA) || defined(IRC_PTLINK) /* Change the realname of a user. */ void change_user_realname(User * user, const char *realname) @@ -222,150 +169,17 @@ void change_user_username(User * user, const char *username) free(user->na->last_usermask); user->na->last_usermask = - smalloc(strlen(GetIdent(user)) + strlen(GetHost(user)) + 2); - sprintf(user->na->last_usermask, "%s@%s", GetIdent(user), - GetHost(user)); + smalloc(strlen(common_get_vident(user)) + + strlen(common_get_vhost(user)) + 2); + sprintf(user->na->last_usermask, "%s@%s", common_get_vident(user), + common_get_vhost(user)); } if (debug) alog("debug: %s changes its username to %s", user->nick, username); } -#endif - /*************************************************************************/ -void 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; -#if defined(IRC_BAHAMUT) && !defined(IRC_ULTIMATE3) && !defined(IRC_VIAGRA) && !defined(IRC_RAGE2) - case 'a': - if (add && !is_services_admin(user)) { - send_cmd(ServerName, "SVSMODE %s -a", user->nick); - user->mode &= ~UMODE_a; - } - break; -#endif -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) - case 'a': - if (add && !is_services_oper(user)) { - send_cmd(ServerName, "SVSMODE %s -a", user->nick); - user->mode &= ~UMODE_a; - } - break; - case 'P': - if (add && !is_services_admin(user)) { - send_cmd(ServerName, "SVSMODE %s -P", user->nick); - user->mode &= ~UMODE_P; - } - break; -#endif -#if defined(IRC_ULTIMATE) - case 'R': - if (add && !is_services_root(user)) { - send_cmd(ServerName, "SVSMODE %s -R", user->nick); - user->mode &= ~UMODE_R; - } - break; -#endif -#if defined(IRC_ULTIMATE3) - case 'Z': - if (add && !is_services_root(user)) { - send_cmd(ServerName, "SVSMODE %s -Z", user->nick); - user->mode &= ~UMODE_Z; - } - break; -#endif - case 'd': - if (ac == 0) { -#if !defined(IRC_ULTIMATE) && !defined(IRC_UNREAL) - alog("user: umode +d with no parameter (?) for user %s", - user->nick); -#endif - break; - } - - ac--; - av++; - user->svid = strtoul(*av, NULL, 0); - break; - case 'o': - if (add) { - opcnt++; - - if (WallOper) - wallops(s_OperServ, "\2%s\2 is now an IRC operator.", - user->nick); - display_news(user, NEWS_OPER); -#if defined(IRC_PTLINK) - if (is_services_admin(user)) { - send_cmd(ServerName, "SVSMODE %s +a", user->nick); - user->mode |= UMODE_a; - } -#endif -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) - if (is_services_oper(user)) { - send_cmd(ServerName, "SVSMODE %s +a", user->nick); - user->mode |= UMODE_a; - } -#endif - -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) - if (is_services_admin(user)) { - send_cmd(ServerName, "SVSMODE %s +P", user->nick); - user->mode |= UMODE_P; - } -#endif - -#ifdef IRC_ULTIMATE - if (is_services_root(user)) { - send_cmd(ServerName, "SVSMODE %s +R", user->nick); - user->mode |= UMODE_R; - } -#endif -#ifdef IRC_ULTIMATE3 - if (is_services_root(user)) { - send_cmd(ServerName, "SVSMODE %s +Z", user->nick); - user->mode |= UMODE_Z; - } -#endif - } else { - opcnt--; - } - break; - case 'r': - if (add && !nick_identified(user)) { - send_cmd(ServerName, "SVSMODE %s -r", user->nick); - user->mode &= ~UMODE_r; - } - break; -#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_RAGE2) - case 'x': - update_host(user); - break; -#endif - } - } -} /*************************************************************************/ @@ -377,16 +191,16 @@ void delete_user(User * user) struct u_chaninfolist *ci, *ci2; if (LogUsers) { -#ifdef HAS_VHOST - alog("LOGUSERS: %s (%s@%s => %s) (%s) left the network (%s).", - user->nick, user->username, user->host, - (user->vhost ? user->vhost : "(none)"), user->realname, - user->server->name); -#else - alog("LOGUSERS: %s (%s@%s) (%s) left the network (%s).", - user->nick, user->username, user->host, - user->realname, user->server->name); -#endif + if (ircd->vhost) { + alog("LOGUSERS: %s (%s@%s => %s) (%s) left the network (%s).", + user->nick, user->username, user->host, + (user->vhost ? user->vhost : "(none)"), user->realname, + user->server->name); + } else { + alog("LOGUSERS: %s (%s@%s) (%s) left the network (%s).", + user->nick, user->username, user->host, + user->realname, user->server->name); + } } if (debug >= 2) @@ -398,10 +212,10 @@ void delete_user(User * user) alog("debug: delete_user(): free user data"); free(user->username); free(user->host); -#ifdef HAS_VHOST - if (user->vhost) - free(user->vhost); -#endif + if (ircd->vhost) { + if (user->vhost) + free(user->vhost); + } free(user->realname); if (debug >= 2) alog("debug: delete_user(): remove from channels"); @@ -466,10 +280,10 @@ void get_user_stats(long *nusers, long *memuse) mem += strlen(user->username) + 1; if (user->host) mem += strlen(user->host) + 1; -#ifdef HAS_VHOST - if (user->vhost) - mem += strlen(user->vhost) + 1; -#endif + if (ircd->vhost) { + if (user->vhost) + mem += strlen(user->vhost) + 1; + } if (user->realname) mem += strlen(user->realname) + 1; if (user->server->name) @@ -540,7 +354,8 @@ User *nextuser(void) /* Handle a server NICK command. */ User *do_nick(const char *source, char *nick, char *username, char *host, - char *server, char *realname, time_t ts, uint32 svid, ...) + char *server, char *realname, time_t ts, uint32 svid, + uint32 ip, char *vhost, char *uid) { User *user; @@ -551,32 +366,18 @@ User *do_nick(const char *source, char *nick, char *username, char *host, char mask[USERMAX + HOSTMAX + 2]; if (!*source) { -#ifdef HAS_NICKIP char ipbuf[16]; struct in_addr addr; - uint32 ip; -#endif -#ifdef HAS_VHOST - char *vhost = NULL; -#endif -#if defined(HAS_NICKIP) || defined(HAS_NICKVHOST) - va_list args; - va_start(args, svid); -#endif - -#ifdef HAS_NICKIP - ip = va_arg(args, uint32); -#endif -#ifdef HAS_NICKVHOST - vhost = va_arg(args, char *); - if (!strcmp(vhost, "*")) { - vhost = NULL; - if (debug) - alog("debug: new user with no vhost in NICK command: %s", - nick); + if (ircd->nickvhost) { + if (vhost) { + if (!strcmp(vhost, "*")) { + vhost = NULL; + if (debug) + alog("debug: new user with no vhost in NICK command: %s", nick); + } + } } -#endif /* This is a new user; create a User structure for it. */ if (debug) @@ -586,33 +387,35 @@ User *do_nick(const char *source, char *nick, char *username, char *host, /** * Ugly swap routine for Flop's bug :) **/ - tmp = strchr(realname, '%'); - while (tmp) { - *tmp = '-'; + if (realname) { tmp = strchr(realname, '%'); + while (tmp) { + *tmp = '-'; + tmp = strchr(realname, '%'); + } } /** * End of ugly swap **/ -#ifdef HAS_NICKIP - addr.s_addr = htonl(ip); - ntoa(addr, ipbuf, sizeof(ipbuf)); -#endif + if (ircd->nickip) { + addr.s_addr = htonl(ip); + ntoa(addr, ipbuf, sizeof(ipbuf)); + } -#ifdef HAS_NICKVHOST -# ifdef HAS_NICKIP - alog("LOGUSERS: %s (%s@%s => %s) (%s) [%s] connected to the network (%s).", nick, username, host, vhost, realname, ipbuf, server); -# else - alog("LOGUSERS: %s (%s@%s => %s) (%s) connected to the network (%s).", nick, username, host, vhost, realname, server); -# endif -#else -# ifdef HAS_NICKIP - alog("LOGUSERS: %s (%s@%s) (%s) [%s] connected to the network (%s).", nick, username, host, realname, ipbuf, server); -# else - alog("LOGUSERS: %s (%s@%s) (%s) connected to the network (%s).", nick, username, host, realname, server); -# endif -#endif + if (ircd->nickvhost) { + if (ircd->nickip) { + alog("LOGUSERS: %s (%s@%s => %s) (%s) [%s] connected to the network (%s).", nick, username, host, vhost, realname, ipbuf, server); + } else { + alog("LOGUSERS: %s (%s@%s => %s) (%s) connected to the network (%s).", nick, username, host, vhost, realname, server); + } + } else { + if (ircd->nickip) { + alog("LOGUSERS: %s (%s@%s) (%s) [%s] connected to the network (%s).", nick, username, host, realname, ipbuf, server); + } else { + alog("LOGUSERS: %s (%s@%s) (%s) connected to the network (%s).", nick, username, host, realname, server); + } + } } /* We used to ignore the ~ which a lot of ircd's use to indicate no @@ -628,17 +431,7 @@ User *do_nick(const char *source, char *nick, char *username, char *host, * as such, create a user_struct, and if the client is removed, we'll delete it again when the QUIT notice * comes in from the ircd. **/ - if (check_akill(nick, username, host, -#ifdef HAS_NICKVHOST - vhost, -#else - NULL, -#endif -#ifdef HAS_NICKIP - ipbuf)) { -#else - NULL)) { -#endif + if (check_akill(nick, username, host, vhost, ipbuf)) { /* return NULL; */ } @@ -654,30 +447,20 @@ User *do_nick(const char *source, char *nick, char *username, char *host, time(NULL) + dotime(DefConAKILL), DefConAkillReason ? DefConAkillReason : "DEFCON AKILL"); - if (check_akill(nick, username, host, -#ifdef HAS_NICKVHOST - vhost, -#else - NULL, -#endif -#ifdef HAS_NICKIP - ipbuf)) { -#else - NULL)) { -#endif + if (check_akill(nick, username, host, vhost, ipbuf)) { /* return NULL; */ } } -#ifdef IRC_BAHAMUT - /* Next for SGLINEs */ - if (check_sgline(nick, realname)) - return NULL; -#endif - - /* And for SQLINEs */ - if (check_sqline(nick, 0)) - return NULL; - + if (ircd->sgline) { + /* Next for SGLINEs */ + if (check_sgline(nick, realname)) + return NULL; + } + if (ircd->sqline) { + /* And for SQLINEs */ + if (check_sqline(nick, 0)) + return NULL; + } #ifndef STREAMLINED /* Now check for session limits */ if (LimitSessions && !add_session(nick, host)) @@ -686,12 +469,9 @@ User *do_nick(const char *source, char *nick, char *username, char *host, /* And finally, for proxy ;) */ #ifdef USE_THREADS -# ifdef HAS_NICKIP - if (ProxyDetect && proxy_check(nick, host, ip)) -# else - if (ProxyDetect && proxy_check(nick, host, 0)) -# endif + if (ProxyDetect && proxy_check(nick, host, ip)) { return NULL; + } #endif /* Allocate User structure and fill it in. */ @@ -702,10 +482,8 @@ User *do_nick(const char *source, char *nick, char *username, char *host, user->realname = sstrdup(realname); user->timestamp = ts; user->my_signon = time(NULL); - -#ifdef HAS_VHOST user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); -#endif + user->uid = uid; /* p10 stuff */ if (CheckClones) { /* Check to see if it looks like clones. */ @@ -731,14 +509,9 @@ User *do_nick(const char *source, char *nick, char *username, char *host, } else if (svid != 1) { /* Resets the svid because it doesn't match */ user->svid = 1; -#ifdef IRC_BAHAMUT - send_cmd(ServerName, "SVSMODE %s %lu +d 1", user->nick, - user->timestamp); -#else -#ifndef IRC_PTLINK - send_cmd(ServerName, "SVSMODE %s +d 1", user->nick); -#endif -#endif + + anope_cmd_svid_umode(user->nick, user->timestamp); + } else { user->svid = 1; } @@ -746,6 +519,7 @@ User *do_nick(const char *source, char *nick, char *username, char *host, } else { /* An old user changing nicks. */ user = finduser(source); + if (!user) { alog("user: NICK from nonexistent nick %s", source); return NULL; @@ -755,13 +529,11 @@ User *do_nick(const char *source, char *nick, char *username, char *host, alog("debug: %s changes nick to %s", source, nick); if (LogUsers) { -#ifdef HAS_VHOST - alog("LOGUSERS: %s (%s@%s => %s) (%s) changed his nick to %s (%s).", user->nick, user->username, user->host, (user->vhost ? user->vhost : "(none)"), user->realname, nick, user->server->name); -#else - alog("LOGUSERS: %s (%s@%s) (%s) changed his nick to %s (%s).", - user->nick, user->username, user->host, - user->realname, nick, user->server->name); -#endif + if (ircd->vhost) { + alog("LOGUSERS: %s (%s@%s => %s) (%s) changed his nick to %s (%s).", user->nick, user->username, user->host, (user->vhost ? user->vhost : "(none)"), user->realname, nick, user->server->name); + } else { + alog("LOGUSERS: %s (%s@%s) (%s) changed his nick to %s (%s).", user->nick, user->username, user->host, user->realname, nick, user->server->name); + } } user->timestamp = ts; @@ -791,17 +563,14 @@ User *do_nick(const char *source, char *nick, char *username, char *host, if (!nc_changed && (user->na)) user->na->status |= status; else { -#if !defined(IRC_BAHAMUT) && !defined(IRC_PTLINK) - /* Because on Bahamut it would be already -r */ - change_user_mode(user, "-r+d", "1"); -#else - change_user_mode(user, "+d", "1"); -#endif + anope_cmd_nc_change(user); } } - if (!is_oper(user) && check_sqline(user->nick, 1)) - return NULL; + if (ircd->sqline) { + if (!is_oper(user) && check_sqline(user->nick, 1)) + return NULL; + } } /* if (!*source) */ @@ -814,6 +583,7 @@ User *do_nick(const char *source, char *nick, char *username, char *host, if (nc_changed || !nick_recognized(user)) { if (validate_user(user)) check_memos(user); + } else { if (nick_identified(user)) { user->na->last_seen = time(NULL); @@ -821,44 +591,29 @@ User *do_nick(const char *source, char *nick, char *username, char *host, if (user->na->last_usermask) free(user->na->last_usermask); user->na->last_usermask = - smalloc(strlen(GetIdent(user)) + strlen(GetHost(user)) + - 2); - sprintf(user->na->last_usermask, "%s@%s", GetIdent(user), - GetHost(user)); - -#ifdef IRC_PTLINK - change_user_mode(user, "+r", NULL); -#endif - -#if !defined(IRC_BAHAMUT) && !defined(IRC_PTLINK) - if (user->svid != user->timestamp) { - char tsbuf[16]; - snprintf(tsbuf, sizeof(tsbuf), "%lu", user->timestamp); - change_user_mode(user, "+rd", tsbuf); - } else { - change_user_mode(user, "+r", NULL); - } -#endif + smalloc(strlen(common_get_vident(user)) + + strlen(common_get_vhost(user)) + 2); + sprintf(user->na->last_usermask, "%s@%s", + common_get_vident(user), common_get_vhost(user)); + char tsbuf[16]; + snprintf(tsbuf, sizeof(tsbuf), "%lu", user->timestamp); + anope_cmd_svid_umode2(user, tsbuf); alog("%s: %s!%s@%s automatically identified for nick %s", - s_NickServ, user->nick, user->username, GetHost(user), - user->nick); + s_NickServ, user->nick, user->username, + common_get_vhost(user), user->nick); } } -/* Bahamut sets -r on every nick changes, so we must test it even if nc_changed == 0 */ -#ifdef IRC_BAHAMUT - if (nick_identified(user)) { - if (user->svid != user->timestamp) { + /* Bahamut sets -r on every nick changes, so we must test it even if nc_changed == 0 */ + if (ircd->check_nick_id) { + if (nick_identified(user)) { char tsbuf[16]; snprintf(tsbuf, sizeof(tsbuf), "%lu", user->timestamp); - change_user_mode(user, "+rd", tsbuf); - } else { - change_user_mode(user, "+r", NULL); + anope_cmd_svid_umode3(user, tsbuf); } } -#endif return user; } @@ -877,8 +632,8 @@ void do_umode(const char *source, int ac, char **av) if (stricmp(source, av[0]) != 0) { alog("user: MODE %s %s from different nick %s!", av[0], av[1], source); - wallops(NULL, "%s attempted to change mode %s for %s", source, - av[1], av[0]); + anope_cmd_global(NULL, "%s attempted to change mode %s for %s", + source, av[1], av[0]); return; } @@ -889,7 +644,7 @@ void do_umode(const char *source, int ac, char **av) return; } - set_umode(user, ac - 1, &av[1]); + anope_set_umode(user, ac - 1, &av[1]); } /*************************************************************************/ @@ -932,22 +687,22 @@ void do_quit(const char *source, int ac, char **av) * av[1] = reason */ -void do_kill(const char *source, int ac, char **av) +void do_kill(char *nick, char *msg) { User *user; NickAlias *na; - user = finduser(av[0]); + user = finduser(nick); if (!user) return; if (debug) - alog("debug: %s killed", av[0]); + alog("debug: %s killed", nick); if ((na = user->na) && (!(na->status & NS_VERBOTEN)) && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { na->last_seen = time(NULL); if (na->last_quit) free(na->last_quit); - na->last_quit = *av[1] ? sstrdup(av[1]) : NULL; + na->last_quit = *msg ? sstrdup(msg) : NULL; } #ifndef STREAMLINED @@ -960,15 +715,16 @@ void do_kill(const char *source, int ac, char **av) /*************************************************************************/ /*************************************************************************/ -#if defined(IRC_ULTIMATE) || defined(IRC_ULTIMATE3) - /* Is the given user protected from kicks and negative mode changes? */ int is_protected(User * user) { - return (user->mode & UMODE_p); + if (ircd->protectedumode) { + return (user->mode & ircd->protectedumode); + } else { + return 0; + } } -#endif /*************************************************************************/ @@ -982,7 +738,6 @@ int is_oper(User * user) /*************************************************************************/ /*************************************************************************/ -#ifdef HAS_EXCEPT /* Is the given user ban-excepted? */ int is_excepted(ChannelInfo * ci, User * user) { @@ -993,6 +748,10 @@ int is_excepted(ChannelInfo * ci, User * user) if (!ci->c) return 0; + if (!ircd->except) { + return 0; + } + count = ci->c->exceptcount; excepts = scalloc(sizeof(char *) * count, 1); memcpy(excepts, ci->c->excepts, sizeof(char *) * count); @@ -1018,6 +777,10 @@ int is_excepted_mask(ChannelInfo * ci, char *mask) if (!ci->c) return 0; + if (!ircd->except) { + return 0; + } + count = ci->c->exceptcount; excepts = scalloc(sizeof(char *) * count, 1); memcpy(excepts, ci->c->excepts, sizeof(char *) * count); @@ -1031,7 +794,7 @@ int is_excepted_mask(ChannelInfo * ci, char *mask) return isexcepted; } -#endif + /*************************************************************************/ /* Does the user's usermask match the given mask (either nick!user@host or @@ -1061,17 +824,11 @@ int match_usermask(const char *mask, User * user) result = match_wild_nocase(nick, user->nick) && match_wild_nocase(username, user->username) && (match_wild_nocase(host, user->host) -#ifdef HAS_VHOST - || match_wild_nocase(host, user->vhost) -#endif - ); + || match_wild_nocase(host, user->vhost)); } else { result = match_wild_nocase(username, user->username) && (match_wild_nocase(host, user->host) -#ifdef HAS_VHOST - || match_wild_nocase(host, user->vhost) -#endif - ); + || match_wild_nocase(host, user->vhost)); } free(mask2); @@ -1125,38 +882,40 @@ void split_usermask(const char *mask, char **nick, char **user, char *create_mask(User * u) { char *mask, *s, *end; - int ulen = strlen(GetIdent(u)); + int ulen = strlen(common_get_vident(u)); /* Get us a buffer the size of the username plus hostname. The result * will never be longer than this (and will often be shorter), thus we * can use strcpy() and sprintf() safely. */ - end = mask = smalloc(ulen + strlen(GetHost(u)) + 3); + end = mask = smalloc(ulen + strlen(common_get_vhost(u)) + 3); end += sprintf(end, "%s%s@", (ulen < - (*(GetIdent(u)) == + (*(common_get_vident(u)) == '~' ? USERMAX + 1 : USERMAX) ? "*" : ""), - (*(GetIdent(u)) == - '~' ? GetIdent(u) + 1 : GetIdent(u))); + (*(common_get_vident(u)) == + '~' ? common_get_vident(u) + + 1 : common_get_vident(u))); - if (strspn(GetHost(u), "0123456789.") == strlen(GetHost(u)) - && (s = strchr(GetHost(u), '.')) + if (strspn(common_get_vhost(u), "0123456789.") == + strlen(common_get_vhost(u)) + && (s = strchr(common_get_vhost(u), '.')) && (s = strchr(s + 1, '.')) && (s = strchr(s + 1, '.')) && (!strchr(s + 1, '.'))) { /* IP addr */ - s = sstrdup(GetHost(u)); + s = sstrdup(common_get_vhost(u)); *strrchr(s, '.') = 0; sprintf(end, "%s.*", s); free(s); } else { - if ((s = strchr(GetHost(u), '.')) && strchr(s + 1, '.')) { - s = sstrdup(strchr(GetHost(u), '.') - 1); + if ((s = strchr(common_get_vhost(u), '.')) && strchr(s + 1, '.')) { + s = sstrdup(strchr(common_get_vhost(u), '.') - 1); *s = '*'; strcpy(end, s); free(s); } else { - strcpy(end, GetHost(u)); + strcpy(end, common_get_vhost(u)); } } return mask; diff --git a/src/viagra.c b/src/viagra.c new file mode 100644 index 000000000..c47278057 --- /dev/null +++ b/src/viagra.c @@ -0,0 +1,1349 @@ +/* Viagra IRCD functions + * + * (C) 2003 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. + * + * + */ + +#include "services.h" +#include "pseudo.h" + +#ifdef IRC_VIAGRA + +const char version_protocol[] = "ViagraIRCd 1.3.x"; + +IRCDVar ircd[] = { + {"ViagraIRCd 1.3.*", /* ircd name */ + "+oS", /* nickserv mode */ + "+oS", /* chanserv mode */ + "+oS", /* memoserv mode */ + "+oS", /* hostserv mode */ + "+ioS", /* operserv mode */ + "+oS", /* botserv mode */ + "+oS", /* helpserv mode */ + "+i", /* Dev/Null mode */ + "+ioS", /* Global mode */ + "+oS", /* nickserv alias mode */ + "+oS", /* chanserv alias mode */ + "+oS", /* memoserv alias mode */ + "+ioS", /* hostserv alias mode */ + "+ioS", /* operserv alias mode */ + "+oS", /* botserv alias mode */ + "+oS", /* helpserv alias mode */ + "+iS", /* Dev/Null alias mode */ + "+ioS", /* Global alias mode */ + "+qS", /* Used by BotServ Bots */ + 5, /* Chan Max Symbols */ + "-ciklmnpstOR", /* 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 */ + "+rd", /* Mode On Reg */ + "-r+d", /* Mode on UnReg */ + "-r+d", /* Mode on Nick Change */ + 1, /* 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 */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 1, /* Has Admin */ + 0, /* Chan SQlines */ + 1, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 1, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 0, /* svshold */ + 1, /* time stamp on mode */ + 1, /* NICKIP */ + 1, /* UMODE */ + 0, /* O:LINE */ + 1, /* VHOST ON NICK */ + 1, /* Change RealName */ + CHAN_HELP_UNREAL, /* ChanServ extra */ + 0, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, + 0, + 1, + + } + , + {NULL} +}; + + +IRCDCAPAB ircdcap[] = { + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + CAPAB_NICKIP, /* NICKIP */ + CAPAB_NSJOIN, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + CAPAB_BURST, /* BURST */ + CAPAB_TS5, /* TS5 */ + CAPAB_TS3, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + CAPAB_DODKEY, /* DODKEY */ + CAPAB_DOZIP /* DOZIP */ + } +}; + + + + +void anope_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 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 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)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } +} + +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, UMODE_A, 0, UMODE_C, 0, 0, 0, 0, 0, UMODE_I, 0, 0, 0, 0, UMODE_N, + UMODE_O, + 0, + UMODE_Q, + UMODE_R, + UMODE_S, UMODE_T, 0, 0, 0, 0, 0, + 0, + 0, 0, 0, 0, 0, + 0, UMODE_a, UMODE_b, UMODE_c, UMODE_d, UMODE_e, UMODE_f, + UMODE_g, + UMODE_h, UMODE_i, 0, 0, 0, 0, UMODE_n, UMODE_o, + 0, + 0, UMODE_r, UMODE_s, 0, 0, 0, UMODE_w, + UMODE_x, + 0, + 0, + 0, 0, 0, 0, 0 +}; + +char csmodes[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, + '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, 0, 0 +}; + + +CMMode cmmodes[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 cbmodes[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}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {CMODE_M}, + {0}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {0}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* 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 */ + {0}, /* f */ + {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}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} +}; + +CBModeInfo cbmodeinfos[] = { + {'c', CMODE_c, 0, NULL, NULL}, + {'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}, + {'M', CMODE_M, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {0} +}; + +CUMode cumodes[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 anope_cmd_bot_unban(ChannelInfo * ci, char *nick) +{ + send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick); +} + +int anope_event_setname(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETNAME for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_realname(u, av[0]); + return MOD_CONT; +} + +int anope_event_sjoin(char *source, int ac, char **av) +{ + do_sjoin(source, ac, av); + 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) { + 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) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + alog("user: SETIDENT for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_username(u, av[0]); + return MOD_CONT; +} + +int anope_event_chgident(char *source, int ac, char **av) +{ + User *u; + + if (ac != 2) + return MOD_CONT; + + u = finduser(av[0]); + if (!u) { + alog("user: CHGIDENT for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_username(u, av[1]); + return MOD_CONT; +} + + +int anope_event_sethost(char *source, int ac, char **av) +{ + User *u; + + if (ac != 1) + return MOD_CONT; + + u = finduser(source); + if (!u) { + if (debug) + alog("user: SETHOST for nonexistent user %s", source); + return MOD_CONT; + } + + change_user_host(u, av[0]); + return MOD_CONT; +} + +int anope_event_nick(char *source, int ac, char **av) +{ + User *user; + + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), + strtoul(av[8], NULL, 0), "*", NULL); + if (user) { + anope_set_umode(user, 1, &av[3]); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; +} + +int anope_event_vs(char *source, int ac, char **av) +{ + User *u; + + if (ac != 2) + return MOD_CONT; + + u = finduser(av[0]); + if (!u) { + alog("user: VS for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_host(u, av[1]); + 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) { + alog("user: CHGHOST for nonexistent user %s", av[0]); + return MOD_CONT; + } + + change_user_host(u, av[1]); + return MOD_CONT; +} + +int anope_event_436(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + m_nickcoll(av[0]); + return MOD_CONT; +} + + +/* *INDENT-OFF* */ +void moduleAddIRCDMsgs(void) { + Message *m; + + m = createMessage("401", NULL); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", NULL); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", NULL); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", NULL); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", NULL); addCoreMessage(IRCD,m); + m = createMessage("GOPER", NULL); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", NULL); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", NULL); addCoreMessage(IRCD,m); + + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("RS", NULL); addCoreMessage(IRCD,m); + m = createMessage("SGLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SS", NULL); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", NULL); addCoreMessage(IRCD,m); + m = createMessage("SZLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSGLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("UNSZLINE", NULL); addCoreMessage(IRCD,m); + m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); + m = createMessage("VS", anope_event_vs); addCoreMessage(IRCD,m); +} + +/* *INDENT-ON* */ + + +/* SQLINE */ +void anope_cmd_sqline(char *mask, char *reason) +{ + if (!mask || !reason) { + return; + } + + send_cmd(NULL, "SQLINE %s :%s", mask, reason); +} + +void anope_cmd_unsgline(char *mask) +{ + send_cmd(NULL, "UNSGLINE 0 :%s", mask); +} + +void anope_cmd_unszline(char *mask) +{ + send_cmd(NULL, "UNSZLINE 0 %s", mask); +} + +void anope_cmd_szline(char *mask, char *reason) +{ + send_cmd(NULL, "SZLINE %s :%s", mask, reason); +} + +void anope_cmd_svsnoop(char *server, int set) +{ + send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-")); +} + +void anope_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) +{ + send_cmd(NULL, "RAKILL %s %s", host, user); +} + +/* PART */ +void anope_cmd_part(char *nick, char *chan, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (!nick || !chan) { + return; + } + + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } +} + +void anope_cmd_topic(char *whosets, char *chan, char *whosetit, + char *topic, time_t when) +{ + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, when, topic); +} + +void anope_cmd_vhost_off(char *nick) +{ + send_cmd(NULL, "SVSMODE %s -x", nick); +} + +void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) +{ + if (vIdent) { + send_cmd(NULL, "CHGIDENT %s %s", nick, vIdent); + } + send_cmd(NULL, "SVSMODE %s +x", nick); + send_cmd(NULL, "SVSCHGHOST %s %s", nick, vhost); +} + +void anope_cmd_unsqline(char *user) +{ + send_cmd(NULL, "UNSQLINE %s", user); +} + +void anope_cmd_join(char *user, char *channel, time_t chantime) +{ + send_cmd(user, "SJOIN %ld %s", chantime, channel); +} + +void anope_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, + time(NULL), reason); +} + +void anope_cmd_svskill(char *source, char *user, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + if (!source || !user) { + return; + } + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "SVSKILL %s :%s", user, buf); +} + +void anope_cmd_mode(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + 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); + } +} + +/* QUIT */ +void anope_cmd_quit(char *source, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } +} + +int anope_event_away(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + + if (!source) { + return MOD_CONT; + } + m_away(source, av[0]); + return MOD_CONT; +} + +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]); + return MOD_CONT; +} + +void anope_cmd_svsmode(User * u, int ac, char **av) +{ + send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, u->timestamp, + av[0], (ac == 2 ? " " : ""), (ac == 2 ? av[1] : "")); +} + +void anope_cmd_squit(char *servname, char *message) +{ + send_cmd(servname, "SQUIT %s :%s", servname, message); +} + +/* PONG */ +void anope_cmd_pong(char *servname, char *who) +{ + send_cmd(servname, "PONG %s", who); +} + +void anope_cmd_connect(int servernum) +{ + 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(); +} + +/* SVINFO */ +void anope_cmd_svinfo() +{ + send_cmd(NULL, "SVINFO 3 1 0 :%ld", time(NULL)); +} + +/* CAPAB */ +void anope_cmd_capab() +{ + send_cmd(NULL, "CAPAB NICKIP SSJOIN TS3 NOQUIT TSMODE UNCONNECT"); +} + +/* PASS */ +void anope_cmd_pass(char *pass) +{ + send_cmd(NULL, "PASS %s :TS", pass); +} + +/* SERVER */ +void anope_cmd_server(char *servname, int hop, char *descript) +{ + send_cmd(NULL, "SERVER %s %d :%s", ServerName, hop, ServerDesc); +} + +int anope_event_os(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_ns(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_ms(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_hs(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_cs(char *source, int ac, char **av) +{ + if (ac < 1) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_server(char *source, int ac, char **av) +{ + char *uplink; + + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } + do_server(source, ac, av); + return MOD_CONT; +} + + +int anope_event_privmsg(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; +} + +int anope_event_part(char *source, int ac, char **av) +{ + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; +} + +int anope_event_whois(char *source, int ac, char **av) +{ + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; +} + +int anope_event_topic(char *source, int ac, char **av) +{ + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; +} + +int anope_event_squit(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; +} + +int anope_event_quit(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; +} + + +int anope_event_mode(char *source, int ac, char **av) +{ + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; +} + +int anope_event_kill(char *source, int ac, char **av) +{ + if (ac != 2) + return MOD_CONT; + + m_kill(av[0], av[1]); + return MOD_CONT; +} + +int anope_event_kick(char *source, int ac, char **av) +{ + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; +} + +int anope_event_join(char *source, int ac, char **av) +{ + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; +} + +int anope_event_motd(char *source, int ac, char **av) +{ + if (!source) { + return MOD_CONT; + } + + m_motd(source); + return MOD_CONT; +} + +void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); +} + +void anope_cmd_notice(char *source, char *dest, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (UsePrivmsg) { + anope_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source, "PRIVMSG %s :%s", dest, buf); +} + +void anope_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) +{ + send_cmd(source, "NOTICE $%s :%s", dest, msg); +} + +void anope_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, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); +} + +/* 391 */ +void anope_cmd_391(char *source, char *timestr) +{ + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); +} + +/* 250 */ +void anope_cmd_250(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "250 %s ", buf); +} + +/* 307 */ +void anope_cmd_307(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "307 %s ", buf); +} + +/* 311 */ +void anope_cmd_311(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "311 %s ", buf); +} + +/* 312 */ +void anope_cmd_312(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "312 %s ", buf); +} + +/* 317 */ +void anope_cmd_317(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(ServerName, "317 %s ", buf); +} + +/* 219 */ +void anope_cmd_219(char *source, char *letter) +{ + if (!source) { + return; + } + + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } +} + +/* 401 */ +void anope_cmd_401(char *source, char *who) +{ + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); +} + +/* 318 */ +void anope_cmd_318(char *source, char *who) +{ + if (!source || !who) { + return; + } + + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); +} + +/* 242 */ +void anope_cmd_242(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "242 %s ", buf); +} + +/* 243 */ +void anope_cmd_243(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + send_cmd(NULL, "243 %s ", buf); +} + +/* 211 */ +void anope_cmd_211(const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + send_cmd(NULL, "211 %s ", buf); +} + +void anope_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) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, time(NULL), + modes, user, host, ServerName, real); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, + ...) +{ + va_list args; + char buf[BUFSIZE]; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } +} + +void anope_cmd_nick(char *nick, char *name, char *modes) +{ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, time(NULL), + modes, ServiceUser, ServiceHost, ServerName, name); + anope_cmd_sqline(nick, "Reserved for services"); +} + +void anope_cmd_372(char *source, char *msg) +{ + send_cmd(ServerName, "372 %s :- %s", source, msg); +} + +void anope_cmd_372_error(char *source) +{ + send_cmd(ServerName, "372 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); +} + +void anope_cmd_375(char *source) +{ + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); +} + +void anope_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) +{ + if (!source || !chan || !nick) { + return; + } + + send_cmd(source, "INVITE %s %s", nick, chan); +} + +void anope_cmd_bot_chan_mode(char *nick, char *chan) +{ + anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick); +} + +int anope_event_capab(char *source, int ac, char **av) +{ + capab_parse(ac, av); + return MOD_CONT; +} + +/* SVSHOLD - set */ +void anope_cmd_svshold(char *nick) +{ + /* Not supported by this IRCD */ +} + +/* SVSHOLD - release */ +void anope_cmd_relase_svshold(char *nick) +{ + /* Not Supported by this IRCD */ +} + +/* SVSNICK */ +void anope_cmd_svsnick(char *source, char *guest, time_t when) +{ + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, when); +} + +void anope_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, time(NULL), + modes, user, host, ServerName, real); +} + +void anope_cmd_svso(char *source, char *nick, char *flag) +{ + /* Not Supported by this IRCD */ +} + + +void anope_cmd_unban(char *name, 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) +{ + send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, ts); +} + +/* SVSMODE +d */ +/* nc_change was = 1, and there is no na->status */ +void anope_cmd_nc_change(User * u) +{ + common_svsmode(u, "+d", "1"); +} + +/* SVSMODE +d */ +void anope_cmd_svid_umode2(User * u, char *ts) +{ + // not used by bahamut ircds +} + +void anope_cmd_svid_umode3(User * u, char *ts) +{ + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } +} + + + +#endif diff --git a/version.log b/version.log index 2ec75b9d6..2df9d221f 100644 --- a/version.log +++ b/version.log @@ -8,10 +8,14 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="5" -VERSION_BUILD="325" +VERSION_BUILD="327" # $Log$ # +# BUILD : 1.7.5 (327) +# BUGS : none +# NOTES : Merged anope-capab into main trunk... +# # BUILD : 1.7.5 (325) # BUGS : 128 139 146 147 148 # NOTES : Applied patch supplied by Trystan to fix bugs listed above. |