From 1c7c2df89be3a51d03cdb409d6099ab701e521cb Mon Sep 17 00:00:00 2001 From: fishwaldo <> Date: Mon, 30 Jun 2003 15:18:24 +0000 Subject: [PATCH] new IRCd framework ready for the IRCd porter's to play with --- .gitattributes | 6 + Bahamut.c | 1283 ++++++++++++++++++++++++++++++++++++++++++++++++ Bahamut.h | 526 ++++++++++++++++++++ ChangeLog | 1 + Ircu.c | 946 +++++++++++++++++++++++++++++++++++ Ircu.h | 330 +++++++++++++ QuantumIRCd.c | 1283 ++++++++++++++++++++++++++++++++++++++++++++++++ QuantumIRCd.h | 526 ++++++++++++++++++++ config.h.in | 9 + configure | 170 +++++-- configure.in | 81 ++- main.c | 10 +- stats.h | 8 +- 13 files changed, 5131 insertions(+), 48 deletions(-) create mode 100644 Bahamut.c create mode 100644 Bahamut.h create mode 100644 Ircu.c create mode 100644 Ircu.h create mode 100644 QuantumIRCd.c create mode 100644 QuantumIRCd.h diff --git a/.gitattributes b/.gitattributes index 7f46a97c..eb1fdd7e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,12 +2,18 @@ /.indent.pro -text /AUTHORS -text /BUGS -text +/Bahamut.c -text +/Bahamut.h -text /COPYING -text /CREDITS -text /ChangeLog -text /Config -text +/Ircu.c -text +/Ircu.h -text /Makefile.in -text /Makefile.inc.in -text +/QuantumIRCd.c -text +/QuantumIRCd.h -text /README -text /RELNOTES -text /TODO -text diff --git a/Bahamut.c b/Bahamut.c new file mode 100644 index 00000000..58b98571 --- /dev/null +++ b/Bahamut.c @@ -0,0 +1,1283 @@ +/* NeoStats - IRC Statistical Services +** Copyright (c) 1999-2003 Adam Rutter, Justin Hammond +** http://www.neostats.net/ +** +** Portions Copyright (c) 2000-2001 ^Enigma^ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +** USA +** +** NeoStats CVS Identification +** $Id: Bahamut.c,v 1.1 2003/06/30 15:18:23 fishwaldo Exp $ +*/ + +#include "stats.h" +#include "ircd.h" +#include "sock.h" +#include "Ultimate.h" +#include "dl.h" +#include "log.h" + + +IntCommands cmd_list[] = { + /* Command Function srvmsg */ + {MSG_STATS, Usr_Stats, 1, 0} + , + {TOK_STATS, Usr_Stats, 1, 0} + , + {MSG_SETHOST, Usr_Vhost, 1, 0} + , + {TOK_SETHOST, Usr_Vhost, 1, 0} + , + {MSG_VERSION, Usr_Version, 1, 0} + , + {TOK_VERSION, Usr_Version, 1, 0} + , + {MSG_MOTD, Usr_ShowMOTD, 1, 0} + , + {TOK_MOTD, Usr_ShowMOTD, 1, 0} + , + {MSG_CREDITS, Usr_Showcredits, 1, 0} + , + {TOK_CREDITS, Usr_Showcredits, 1, 0} + , + {MSG_SERVER, Usr_AddServer, 1, 0} + , + {TOK_SERVER, Usr_AddServer, 1, 0} + , + {MSG_SQUIT, Usr_DelServer, 1, 0} + , + {TOK_SQUIT, Usr_DelServer, 1, 0} + , + {MSG_QUIT, Usr_DelUser, 1, 0} + , + {TOK_QUIT, Usr_DelUser, 1, 0} + , + {MSG_MODE, Usr_Mode, 1, 0} + , + {TOK_MODE, Usr_Mode, 1, 0} + , + {MSG_SVSMODE, Usr_Smode, 1, 0} + , + {TOK_SVSMODE, Usr_Smode, 1, 0} + , + {MSG_KILL, Usr_Kill, 1, 0} + , + {TOK_KILL, Usr_Kill, 1, 0} + , + {MSG_PONG, Usr_Pong, 1, 0} + , + {TOK_PONG, Usr_Pong, 1, 0} + , + {MSG_AWAY, Usr_Away, 1, 0} + , + {TOK_AWAY, Usr_Away, 1, 0} + , + {MSG_NICK, Usr_Nick, 1, 0} + , + {TOK_NICK, Usr_Nick, 1, 0} + , + {MSG_TOPIC, Usr_Topic, 1, 0} + , + {TOK_TOPIC, Usr_Topic, 1, 0} + , + {MSG_KICK, Usr_Kick, 1, 0} + , + {TOK_KICK, Usr_Kick, 1, 0} + , + {MSG_JOIN, Usr_Join, 1, 0} + , + {TOK_JOIN, Usr_Join, 1, 0} + , + {MSG_PART, Usr_Part, 1, 0} + , + {TOK_PART, Usr_Part, 1, 0} + , + {MSG_PING, Srv_Ping, 0, 0} + , + {TOK_PING, Srv_Ping, 0, 0} + , +#ifndef ULTIMATE3 + {MSG_SNETINFO, Srv_Netinfo, 0, 0} + , + {TOK_SNETINFO, Srv_Netinfo, 0, 0} + , + +#endif +#ifdef ULTIMATE3 + {MSG_SVINFO, Srv_Svinfo, 0, 0} + , + {MSG_CAPAB, Srv_Connect, 0, 0} + , + {MSG_BURST, Srv_Burst, 0, 0} + , + {MSG_SJOIN, Srv_Sjoin, 1, 0} + , + {MSG_CLIENT, Srv_Client, 0, 0} + , + {MSG_SMODE, Srv_Smode, 1, 0} + , +#endif + {MSG_VCTRL, Srv_Vctrl, 0, 0} + , + {TOK_VCTRL, Srv_Vctrl, 0, 0} + , + {MSG_PASS, Srv_Pass, 0, 0} + , + {TOK_PASS, Srv_Pass, 0, 0} + , + {MSG_SERVER, Srv_Server, 0, 0} + , + {TOK_SERVER, Srv_Server, 0, 0} + , + {MSG_SQUIT, Srv_Squit, 0, 0} + , + {TOK_SQUIT, Srv_Squit, 0, 0} + , + {MSG_NICK, Srv_Nick, 0, 0} + , + {TOK_NICK, Srv_Nick, 0, 0} + , + {MSG_SVSNICK, Srv_Svsnick, 0, 0} + , + {TOK_SVSNICK, Srv_Svsnick, 0, 0} + , + {MSG_KILL, Srv_Kill, 0, 0} + , + {TOK_KILL, Srv_Kill, 0, 0} + , + {MSG_PROTOCTL, Srv_Connect, 0, 0} + , + {TOK_PROTOCTL, Srv_Connect, 0, 0} + , + {NULL, NULL, 0, 0} +}; + + + + +aCtab cFlagTab[] = { + {MODE_CHANOP, 'o', 1, 0, '@'} + , + {MODE_HALFOP, 'h', 1, 0, '%'} + , + {MODE_CHANADMIN, 'a', 1, 0, '!'} + , + {MODE_VOICE, 'v', 1, 0, '+'} + , + {MODE_BAN, 'b', 0, 1, 0} + , + {MODE_EXCEPT, 'e', 0, 1, 0} + , + {MODE_FLOODLIMIT, 'f', 0, 1, 0} + , /* Flood limiter */ + {MODE_INVITEONLY, 'i', 0, 0, 0} + , + {MODE_KEY, 'k', 0, 1, 0} + , + {MODE_LIMIT, 'l', 0, 1, 0} + , + {MODE_MODERATED, 'm', 0, 0, 0} + , + {MODE_NOPRIVMSGS, 'n', 0, 0, 0} + , + {MODE_PRIVATE, 'p', 0, 0, 0} + , + {MODE_RGSTR, 'r', 0, 0, 0} + , + {MODE_SECRET, 's', 0, 0, 0} + , + {MODE_TOPICLIMIT, 't', 0, 0, 0} + , + {MODE_NOCOLOR, 'x', 0, 0, 0} + , + {MODE_ADMONLY, 'A', 0, 0, 0} + , + {MODE_NOINVITE, 'I', 0, 0, 0} + , /* no invites */ + {MODE_NOKNOCK, 'K', 0, 0, 0} + , /* knock knock (no way!) */ + {MODE_LINK, 'L', 0, 1, 0} + , + {MODE_OPERONLY, 'O', 0, 0, 0} + , + {MODE_RGSTRONLY, 'R', 0, 0, 0} + , + {MODE_STRIP, 'S', 0, 0, 0} + , /* works? */ + {0x0, 0x0, 0x0, 0x0, 0x0} +}; + + +#ifdef ULTIMATE3 +Oper_Modes usr_mds[] = { + {UMODE_OPER, 'o', 50} + , + {UMODE_LOCOP, 'O', 40} + , + {UMODE_INVISIBLE, 'i', 0} + , + {UMODE_WALLOP, 'w', 0} + , + {UMODE_SERVNOTICE, 's', 0} + , + {UMODE_CLIENT, 'c', 0} + , + {UMODE_REGNICK, 'r', 10} + , + {UMODE_KILLS, 'k', 0} + , + {UMODE_FAILOP, 'g', 0} + , + {UMODE_HELPOP, 'h', 30} + , + {UMODE_FLOOD, 'f', 0} + , + {UMODE_SPY, 'y', 0} + , + {UMODE_DCC, 'D', 0} + , + {UMODE_GLOBOPS, 'g', 0} + , + {UMODE_CHATOP, 'c', 0} + , + {UMODE_SERVICESOPER, 'a', 100} + , + {UMODE_REJ, 'j', 0} + , + {UMODE_ROUTE, 'n', 0} + , + {UMODE_SPAM, 'm', 0} + , + {UMODE_HIDE, 'x', 0} + , + {UMODE_IRCADMIN, 'Z', 200} + , + {UMODE_SERVICESADMIN, 'P', 185} + , + {UMODE_SERVICES, 'S', 200} + , + {UMODE_PROT, 'p', 0} + , + {UMODE_GLOBCON, 'F', 0} + , + {UMODE_DEBUG, 'd', 0} + , + {UMODE_DCCWARN, 'd', 0} + , + {UMODE_WHOIS, 'W', 0} + , + {0, 0, 0} +}; + +Oper_Modes susr_mds[] = { + {SMODE_SSL, 's', 0} + , + {SMODE_COADMIN, 'a', 75} + , + {SMODE_SERVADMIN, 'A', 100} + , + {SMODE_COTECH, 't', 125} + , + {SMODE_TECHADMIN, 'T', 150} + , + {SMODE_CONET, 'n', 175} + , + {SMODE_NETADMIN, 'N', 190} + , + {SMODE_GUEST, 'G', 100} + , + {0, 0, 0} +}; + +#elif ULTIMATE +Oper_Modes usr_mds[] = { + {UMODE_OPER, 'o', 50} + , + {UMODE_LOCOP, 'O', 40} + , + {UMODE_INVISIBLE, 'i', 0} + , + {UMODE_WALLOP, 'w', 0} + , + {UMODE_FAILOP, 'g', 0} + , + {UMODE_HELPOP, 'h', 30} + , + {UMODE_SERVNOTICE, 's', 0} + , + {UMODE_KILLS, 'k', 0} + , + {UMODE_SERVICES, 'S', 200} + , + {UMODE_SERVICESADMIN, 'P', 200} + , + {UMODE_RBOT, 'B', 0} + , + {UMODE_SBOT, 'b', 0} + , + {UMODE_ADMIN, 'z', 70} + , + {UMODE_NETADMIN, 'N', 185} + , + {UMODE_TECHADMIN, 'T', 190} + , + {UMODE_CLIENT, 'c', 0} + , + {UMODE_FLOOD, 'f', 0} + , + {UMODE_REGNICK, 'r', 0} + , + {UMODE_HIDE, 'x', 0} + , + {UMODE_WATCHER, 'W', 0} + , + {UMODE_SERVICESOPER, 'a', 100} + , + {UMODE_SUPER, 'p', 40} + , + {UMODE_IRCADMIN, 'Z', 100} + , + {0, 0, 0} +}; +#endif + +void init_ircd() +{ + /* count the number of commands */ + ircd_srv.cmdcount = ((sizeof(cmd_list) / sizeof(cmd_list[0])) - 1); +}; + +int sserver_cmd(const char *name, const int numeric, const char *infoline) +{ + sts(":%s %s %s %d :%s", me.name, + (me.token ? TOK_SERVER : MSG_SERVER), name, numeric, infoline); + return 1; +} + +int slogin_cmd(const char *name, const int numeric, const char *infoline, + const char *pass) +{ +#ifndef ULTIMATE3 + sts("%s %s", (me.token ? TOK_PASS : MSG_PASS), pass); +#else + sts("%s %s :TS", (me.token ? TOK_PASS : MSG_PASS), pass); + sts("CAPAB TS5 BURST SSJ5 NICKIP CLIENT"); +#endif + sts("%s %s %d :%s", (me.token ? TOK_SERVER : MSG_SERVER), name, + numeric, infoline); + return 1; +} + +int ssquit_cmd(const char *server) +{ + sts("%s %s", (me.token ? TOK_SQUIT : MSG_SQUIT), server); + return 1; +} + +int sprotocol_cmd(const char *option) +{ +#ifndef ULTIMATE3 + sts("%s %s", (me.token ? TOK_PROTOCTL : MSG_PROTOCTL), option); +#endif + return 1; +} + +int squit_cmd(const char *who, const char *quitmsg) +{ + sts(":%s %s :%s", who, (me.token ? TOK_QUIT : MSG_QUIT), quitmsg); + DelUser(who); + return 1; +} + +int spart_cmd(const char *who, const char *chan) +{ + sts(":%s %s %s", who, (me.token ? TOK_PART : MSG_PART), chan); + part_chan(finduser(who), (char *) chan); + return 1; +} + +#ifdef ULTIMATE3 +int sjoin_cmd(const char *who, const char *chan, unsigned long chflag) +{ + char flag; + char mode[2]; + char **av; + int ac; + char tmp[512]; + switch (chflag) { + case MODE_CHANOP: + flag = '@'; + strcpy(mode, "0"); + break; + case MODE_HALFOP: + flag = '%'; + strcpy(mode, "h"); + break; + case MODE_VOICE: + flag = '+'; + strcpy(mode, "v"); + break; + case MODE_CHANADMIN: + flag = '!'; + strcpy(mode, "a"); + break; + default: + flag = ' '; + strcpy(mode, ""); + } + sts(":%s %s 0 %s + :%c%s", me.name, MSG_SJOIN, chan, flag, who); + join_chan(finduser(who), (char *) chan); + snprintf(tmp, 512, "%s +%s %s", chan, mode, who); + ac = split_buf(tmp, &av, 0); + ChanMode(me.name, av, ac); + free(av); + +#else +int sjoin_cmd(const char *who, const char *chan) +{ + sts(":%s %s %s", who, (me.token ? TOK_JOIN : MSG_JOIN), chan); + join_chan(finduser(who), (char *) chan); +#endif + return 1; +} + +int schmode_cmd(const char *who, const char *chan, const char *mode, + const char *args) +{ + char **av; + int ac; + char tmp[512]; + + sts(":%s %s %s %s %s %lu", me.name, + (me.token ? TOK_MODE : MSG_MODE), chan, mode, args, + time(NULL)); + snprintf(tmp, 512, "%s %s %s", chan, mode, args); + ac = split_buf(tmp, &av, 0); + ChanMode("", av, ac); + free(av); + return 1; +} + +#ifndef ULTIMATE3 +int snewnick_cmd(const char *nick, const char *ident, const char *host, + const char *realname) +{ + sts("%s %s 1 %lu %s %s %s 0 :%s", (me.token ? TOK_NICK : MSG_NICK), + nick, time(NULL), ident, host, me.name, realname); + AddUser(nick, ident, host, me.name, 0, time(NULL)); +#else +int snewnick_cmd(const char *nick, const char *ident, const char *host, + const char *realname, long mode) +{ + int i, j; + char newmode[20]; + newmode[0] = '+'; + j = 1; + for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) { + if (mode & usr_mds[i].umodes) { + newmode[j] = usr_mds[i].mode; + j++; + } + + } + newmode[j] = '\0'; + sts("%s %s 1 %lu %s %s %s %s 0 %lu :%s", + (me.token ? TOK_NICK : MSG_NICK), nick, time(NULL), newmode, + ident, host, me.name, time(NULL), realname); + AddUser(nick, ident, host, me.name, 0, time(NULL)); + UserMode(nick, newmode, 0); +#endif + return 1; +} + +int sping_cmd(const char *from, const char *reply, const char *to) +{ + sts(":%s %s %s :%s", from, (me.token ? TOK_PING : MSG_PING), reply, + to); + return 1; +} + +int sumode_cmd(const char *who, const char *target, long mode) +{ + int i, j; + char newmode[20]; + newmode[0] = '+'; + j = 1; + for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) { + if (mode & usr_mds[i].umodes) { + newmode[j] = usr_mds[i].mode; + j++; + } + + } + newmode[j] = '\0'; + sts(":%s %s %s :%s", who, (me.token ? TOK_MODE : MSG_MODE), target, + newmode); + UserMode(target, newmode, 0); + return 1; +} + +int snumeric_cmd(const int numeric, const char *target, const char *data, + ...) +{ + va_list ap; + char buf[512]; + va_start(ap, data); + vsnprintf(buf, 512, data, ap); + sts(":%s %d %s :%s", me.name, numeric, target, buf); + va_end(ap); + return 1; +} + +int spong_cmd(const char *reply) +{ + sts("%s %s", (me.token ? TOK_PONG : MSG_PONG), reply); + return 1; +} + +int snetinfo_cmd() +{ + sts(":%s %s 0 %d %d %s 0 0 0 :%s", me.name, MSG_SNETINFO, + time(NULL), ircd_srv.uprot, ircd_srv.cloak, me.netname); + return 1; +} + +int vctrl_cmd() +{ + sts("%s %d %d %d %d 0 0 0 0 0 0 0 0 0 0 :%s", MSG_VCTRL, + ircd_srv.uprot, ircd_srv.nicklg, ircd_srv.modex, ircd_srv.gc, + me.netname); + return 1; +} +int skill_cmd(const char *from, const char *target, const char *reason, + ...) +{ + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + sts(":%s %s %s :%s", from, (me.token ? TOK_KILL : MSG_KILL), + target, buf); + va_end(ap); + DelUser(target); + return 1; +} + +int ssvskill_cmd(const char *who, const char *reason, ...) +{ + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + sts(":%s %s %s :%s", me.name, MSG_SVSKILL, + who, buf); + va_end(ap); + return 1; +} + +int ssmo_cmd(const char *from, const char *umodetarget, const char *msg) +{ + chanalert(s_Services, + "Warning, Module %s tried to SMO, which is not supported in Ultimate", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning, Module %s tried to SMO, which is not supported in Ultimate", + segvinmodule); + return 1; +} + +int snick_cmd(const char *oldnick, const char *newnick) +{ + Change_User(finduser(oldnick), newnick); + sts(":%s %s %s %d", oldnick, (me.token ? TOK_NICK : MSG_NICK), + newnick, time(NULL)); + return 1; +} +int sswhois_cmd(const char *target, const char *swhois) +{ + chanalert(s_Services, + "Warning Module %s tried to SWHOIS, which is not supported in Ultimate", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning. Module %s tried to SWHOIS, which is not supported in Ultimate", + segvinmodule); + return 1; +} +int ssvsnick_cmd(const char *target, const char *newnick) +{ + sts("%s %s %s :%d", (me.token ? TOK_SVSNICK : MSG_SVSNICK), target, + newnick, time(NULL)); + return 1; +} + +int ssvsjoin_cmd(const char *target, const char *chan) +{ + sts("%s %s %s", (me.token ? TOK_SVSJOIN : MSG_SVSJOIN), target, + chan); + return 1; +} + +int ssvspart_cmd(const char *target, const char *chan) +{ + sts("%s %s %s", (me.token ? TOK_SVSPART : MSG_SVSPART), target, + chan); + return 1; +} + +int skick_cmd(const char *who, const char *target, const char *chan, + const char *reason) +{ + sts(":%s %s %s %s :%s", who, (me.token ? TOK_KICK : MSG_KICK), + chan, target, (reason ? reason : "No Reason Given")); + part_chan(finduser(target), (char *) chan); + return 1; +} +int swallops_cmd(const char *who, const char *msg, ...) +{ + va_list ap; + char buf[512]; + va_start(ap, msg); + vsnprintf(buf, 512, msg, ap); + sts(":%s %s :%s", who, (me.token ? TOK_WALLOPS : MSG_WALLOPS), + buf); + va_end(ap); + return 1; +} + +int ssvshost_cmd(const char *who, const char *vhost) +{ + User *u; + u = finduser(who); + if (!u) { + nlog(LOG_WARNING, LOG_CORE, + "Can't Find user %s for ssvshost_cmd", who); + return 0; + } else { + strncpy(u->vhost, vhost, MAXHOST); +#ifdef ULTIMATE3 + sts(":%s %s %s %s", me.name, + (me.token ? TOK_SETHOST : MSG_SETHOST), who, vhost); +#elif ULTIMATE + sts(":%s CHGHOST %s %s", me.name, who, vhost); +#endif + return 1; + } +} +int sakill_cmd(const char *host, const char *ident, const char *setby, + const int length, const char *reason, ...) +{ + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + sts(":%s %s %s %s %d %s %d :%s", me.name, + (me.token ? TOK_AKILL : MSG_AKILL), host, ident, length, setby, + time(NULL), buf); + va_end(ap); + return 1; +} + +int srakill_cmd(const char *host, const char *ident) +{ + sts(":%s %s %s %s", me.name, (me.token ? TOK_RAKILL : MSG_RAKILL), + host, ident); + return 1; +} + + +int ssvinfo_cmd() +{ + sts("SVINFO 5 3 0 :%d", time(NULL)); + return 1; +} +int sburst_cmd(int b) +{ + if (b == 0) { + sts("BURST 0"); + } else { + sts("BURST"); + } + return 1; +} + + + +void chanalert(char *who, char *buf, ...) +{ + va_list ap; + char tmp[512]; + char out[512]; + va_start(ap, buf); + vsnprintf(tmp, 512, buf, ap); + + if (me.onchan) { + snprintf(out, 512, ":%s PRIVMSG %s :%s", who, me.chan, + tmp); + nlog(LOG_DEBUG3, LOG_CORE, "SENT: %s", out); + sts("%s", out); + } + va_end(ap); +} +void prefmsg(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + if (me.want_privmsg) { + snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2); + } else { + snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2); + } + sts("%s", buf); + va_end(ap); +} +void privmsg(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2); + sts("%s", buf); + va_end(ap); +} + +void notice(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2); + sts("%s", buf); + va_end(ap); +} + + +void privmsg_list(char *to, char *from, const char **text) +{ + while (*text) { + if (**text) + prefmsg(to, from, "%s", *text); + else + prefmsg(to, from, " "); + text++; + } +} + + +void globops(char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + +/* Shmad - have to get rid of nasty term echos :-) */ + +/* Fish - now that was crackhead coding! */ + if (me.onchan) { + snprintf(buf, 512, ":%s GLOBOPS :%s", from, buf2); + sts("%s", buf); + } else { + nlog(LOG_NORMAL, LOG_CORE, "%s", buf2); + } + va_end(ap); +} + + +void Srv_Sjoin(char *origin, char **argv, int argc) +{ + char nick[MAXNICK]; + long mode = 0; + long mode1 = 0; + char *modes; + int ok = 1, i, j = 3; + ModesParm *m; + Chans *c; + lnode_t *mn = NULL; + list_t *tl; + if (argc <= 2) { + modes = argv[1]; + } else { + modes = argv[2]; + } + + if (*modes == '#') { + join_chan(finduser(origin), modes); + return; + } + tl = list_create(10); + + if (*modes != '+') { + goto nomodes; + } + while (*modes) { + for (i = 0; + i < ((sizeof(cFlagTab) / sizeof(cFlagTab[0])) - 1); + i++) { + if (*modes == cFlagTab[i].flag) { + if (cFlagTab[i].parameters) { + m = smalloc(sizeof(ModesParm)); + m->mode = cFlagTab[i].mode; + strncpy(m->param, argv[j], + PARAMSIZE); + mn = lnode_create(m); + if (!list_isfull(tl)) { + list_append(tl, mn); + } else { + nlog(LOG_CRITICAL, + LOG_CORE, + "Eeeek, tl list is full in Svr_Sjoin(ircd.c)"); + do_exit(0); + } + j++; + } else { + mode1 |= cFlagTab[i].mode; + } + } + } + modes++; + } + nomodes: + while (argc > j) { + modes = argv[j]; + mode = 0; + while (ok == 1) { + for (i = 0; + i < + ((sizeof(cFlagTab) / sizeof(cFlagTab[0])) - + 1); i++) { + if (cFlagTab[i].sjoin != 0) { + if (*modes == cFlagTab[i].sjoin) { + mode |= cFlagTab[i].mode; + modes++; + i = -1; + } + } else { + /* sjoin's should be at the top of the list */ + ok = 0; + strncpy(nick, modes, MAXNICK); + break; + } + } + } + join_chan(finduser(nick), argv[1]); + ChangeChanUserMode(findchan(argv[1]), finduser(nick), 1, + mode); + j++; + ok = 1; + } + c = findchan(argv[1]); + c->modes |= mode1; + if (!list_isempty(tl)) { + if (!list_isfull(c->modeparms)) { + list_transfer(c->modeparms, tl, list_first(tl)); + } else { + /* eeeeeeek, list is full! */ + nlog(LOG_CRITICAL, LOG_CORE, + "Eeeek, c->modeparms list is full in Svr_Sjoin(ircd.c)"); + do_exit(0); + } + } + list_destroy(tl); +} + +void Srv_Burst(char *origin, char **argv, int argc) +{ + if (argc > 0) { + if (ircd_srv.burst == 1) { + sburst_cmd(0); + ircd_srv.burst = 0; + me.synced = 1; + init_ServBot(); + } + } else { + ircd_srv.burst = 1; + } +} + +void Srv_Connect(char *origin, char **argv, int argc) +{ + int i; + + for (i = 0; i < argc; i++) { + if (!strcasecmp("TOKEN", argv[i])) { + me.token = 1; + } +#ifdef ULTIMATE3 + if (!strcasecmp("CLIENT", argv[i])) { + me.client = 1; + } +#endif + } +} + + +void Usr_Stats(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(origin); + if (!u) { + nlog(LOG_WARNING, LOG_CORE, + "Recieved a Message from a Unknown User! (%s)", + origin); + return; + } + ShowStats(argv[0], u); +} + +void Usr_Version(char *origin, char **argv, int argc) +{ + snumeric_cmd(351, origin, "%d.%d.%d%s :%s -> %s %s", MAJOR, MINOR, + REV, version, me.name, version_date, version_time); +} +void Usr_ShowMOTD(char *origin, char **argv, int argc) +{ + ShowMOTD(origin); +} +void Usr_ShowADMIN(char *origin, char **argv, int argc) +{ + ShowADMIN(origin); +} +void Usr_Showcredits(char *origin, char **argv, int argc) +{ + Showcredits(origin); +} +void Usr_AddServer(char *origin, char **argv, int argc) +{ + AddServer(argv[0], origin, atoi(argv[1])); +} +void Usr_DelServer(char *origin, char **argv, int argc) +{ + DelServer(argv[0]); +} +void Usr_DelUser(char *origin, char **argv, int argc) +{ + DelUser(origin); +} +void Usr_Smode(char *origin, char **argv, int argc) +{ + if (!strchr(argv[0], '#')) { + /* its user svsmode change */ + UserMode(argv[0], argv[2], 0); + } else { + /* its a channel svsmode change */ + ChanMode(origin, argv, argc); + } +} +void Usr_Mode(char *origin, char **argv, int argc) +{ + if (!strchr(argv[0], '#')) { + nlog(LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[0]); + UserMode(argv[0], argv[1], 0); + } else { + ChanMode(origin, argv, argc); + } +} +void Usr_Kill(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(argv[0]); + if (u) { + KillUser(argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, "Can't find user %s for Kill", + argv[0]); + } +} +void Usr_Vhost(char *origin, char **argv, int argc) +{ + User *u; +#ifndef ULTIMATE3 + u = finduser(origin); +#else + u = finduser(argv[0]); +#endif + if (u) { +#ifndef ULTIMATE3 + strncpy(u->vhost, argv[0], MAXHOST); +#else + strncpy(u->vhost, argv[1], MAXHOST); +#endif + } +} +void Usr_Pong(char *origin, char **argv, int argc) +{ + Server *s; + s = findserver(argv[0]); + if (s) { + dopong(s); + } else { + nlog(LOG_NOTICE, LOG_CORE, + "Received PONG from unknown server: %s", argv[0]); + } +} +void Usr_Away(char *origin, char **argv, int argc) +{ + char *Buf; + User *u = finduser(origin); + if (u) { + if (argc > 0) { + Buf = joinbuf(argv, argc, 0); + } else { + Buf = NULL; + } + Do_Away(u, Buf); + if (argc > 0) { + free(Buf); + } + } else { + nlog(LOG_NOTICE, LOG_CORE, + "Warning, Unable to find User %s for Away", origin); + } +} +void Usr_Nick(char *origin, char **argv, int argc) +{ + User *u = finduser(origin); + if (u) { + Change_User(u, argv[0]); + } +} +void Usr_Topic(char *origin, char **argv, int argc) +{ + char *buf; + Chans *c; + c = findchan(argv[0]); + if (c) { + buf = joinbuf(argv, argc, 3); + Change_Topic(argv[1], c, atoi(argv[2]), buf); + free(buf); + } else { + nlog(LOG_WARNING, LOG_CORE, "Ehhh, Can't find Channel %s", + argv[0]); + } + +} + +void Usr_Kick(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(argv[1]); + if (u) { + kick_chan(u, argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Warning, Can't find user %s for kick %s", argv[1], + argv[0]); + } +} +void Usr_Join(char *origin, char **argv, int argc) +{ + char *s, *t; + t = argv[0]; + while (*(s = t)) { + t = s + strcspn(s, ","); + if (*t) + *t++ = 0; + join_chan(finduser(origin), s); + } +} +void Usr_Part(char *origin, char **argv, int argc) +{ + part_chan(finduser(origin), argv[0]); +} +void Srv_Ping(char *origin, char **argv, int argc) +{ + spong_cmd(argv[0]); +#ifdef ULTIMATE3 + if (ircd_srv.burst) { + sping_cmd(me.name, argv[0], argv[0]); + } +#endif +} + +void Srv_Vctrl(char *origin, char **argv, int argc) +{ + ircd_srv.uprot = atoi(argv[0]); + ircd_srv.nicklg = atoi(argv[1]); + ircd_srv.modex = atoi(argv[2]); + ircd_srv.gc = atoi(argv[3]); + strncpy(me.netname, argv[14], MAXPASS); + vctrl_cmd(); +} + +void Srv_Svinfo(char *origin, char **argv, int argc) +{ + ssvinfo_cmd(); +} + +#ifndef ULTIMATE3 +void Srv_Netinfo(char *origin, char **argv, int argc) +{ + me.onchan = 1; + ircd_srv.uprot = atoi(argv[2]); + strncpy(ircd_srv.cloak, argv[3], 10); + strncpy(me.netname, argv[7], MAXPASS); + + snetinfo_cmd(); + init_ServBot(); + globops(me.name, "Link with Network \2Complete!\2"); +#ifdef DEBUG + ns_debug_to_coders(me.chan); +#endif + if (ircd_srv.uprot == 2109) { + me.usesmo = 1; + } + Module_Event("NETINFO", NULL, 0); + me.synced = 1; +} +#endif + +void Srv_Pass(char *origin, char **argv, int argc) +{ +} +void Srv_Server(char *origin, char **argv, int argc) +{ + Server *s; + if (*origin == 0) { + AddServer(argv[0], me.name, atoi(argv[1])); + } else { + AddServer(argv[0], origin, atoi(argv[1])); + } + s = findserver(argv[0]); + me.s = s; +} +void Srv_Squit(char *origin, char **argv, int argc) +{ + Server *s; + s = findserver(argv[0]); + if (s) { + DelServer(argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Waring, Squit from Unknown Server %s", argv[0]); + } + +} + +/* BE REALLY CAREFULL ABOUT THE ORDER OF THESE ifdef's */ + +void Srv_Nick(char *origin, char **argv, int argc) +{ + char *realname; +#if ULTIMATE3 + AddUser(argv[0], argv[4], argv[5], argv[6], + strtoul(argv[8], NULL, 10), strtoul(argv[2], NULL, 10)); + realname = joinbuf(argv, argc, 9); + AddRealName(argv[0], realname); + free(realname); + nlog(LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[3]); + UserMode(argv[0], argv[3], 0); +#elif ULTIMATE + AddUser(argv[0], argv[3], argv[4], argv[5], 0, + strtoul(argv[2], NULL, 10)); + realname = joinbuf(argv, argc, 7); + AddRealName(argv[0], realname); + free(realname); +#endif +} + +/* Ultimate3 Client Support */ +#ifdef ULTIMATE3 +void Srv_Client(char *origin, char **argv, int argc) +{ + char *realname; + + AddUser(argv[0], argv[5], argv[6], argv[8], + strtoul(argv[10], NULL, 10), strtoul(argv[2], NULL, 10)); + realname = joinbuf(argv, argc, 11); + AddRealName(argv[0], realname); + free(realname); + nlog(LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[3]); + UserMode(argv[0], argv[3], 0); + nlog(LOG_DEBUG1, LOG_CORE, "Smode: SMode: %s", argv[4]); + UserMode(argv[0], argv[4], 1); + +} + +void Srv_Smode(char *origin, char **argv, int argc) +{ + UserMode(argv[0], argv[1], 1); +}; + +/* ultimate 3 */ +#endif + +void Srv_Svsnick(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(argv[0]); + if (u) { + Change_User(u, argv[1]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Warning, Can't find user %s for SVSNICK", argv[0]); + } + +} +void Srv_Kill(char *origin, char **argv, int argc) +{ +} + + + +int SignOn_NewBot(const char *nick, const char *user, + const char *host, const char *rname, long Umode) +{ + +#ifdef ULTIMATE3 + snewnick_cmd(nick, user, host, rname, Umode); +#else + snewnick_cmd(nick, user, host, rname); + sumode_cmd(nick, nick, Umode); +#endif + if ((me.allbots > 0) || (Umode & UMODE_SERVICES)) { +#ifdef ULTIMATE3 + sjoin_cmd(nick, me.chan, MODE_CHANADMIN); +#else /* ulitmate3 */ + sjoin_cmd(nick, me.chan); +#endif + schmode_cmd(nick, me.chan, "+a", nick); + /* all bots join */ + } + return 1; +} diff --git a/Bahamut.h b/Bahamut.h new file mode 100644 index 00000000..2d442106 --- /dev/null +++ b/Bahamut.h @@ -0,0 +1,526 @@ +/* NeoStats - IRC Statistical Services +** Copyright (c) 1999-2003 Adam Rutter, Justin Hammond +** http://www.neostats.net/ +** +** Portions Copyright (c) 2000-2001 ^Enigma^ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +** USA +** +** NeoStats CVS Identification +** $Id: Bahamut.h,v 1.1 2003/06/30 15:18:23 fishwaldo Exp $ +*/ +#ifndef ULTIMATE_H +#define ULTIMATE_H + +/* we support tokens */ +#define HAVE_TOKEN_SUP + + +#define MSG_PRIVATE "PRIVMSG" /* PRIV */ +#define TOK_PRIVATE "!" /* 33 */ +#define MSG_WHO "WHO" /* WHO -> WHOC */ +#define TOK_WHO "\"" /* 34 */ +#define MSG_WHOIS "WHOIS" /* WHOI */ +#define TOK_WHOIS "#" /* 35 */ +#define MSG_WHOWAS "WHOWAS" /* WHOW */ +#define TOK_WHOWAS "$" /* 36 */ +#define MSG_USER "USER" /* USER */ +#define TOK_USER "%" /* 37 */ +#define MSG_NICK "NICK" /* NICK */ +#define TOK_NICK "&" /* 38 */ +#define MSG_SERVER "SERVER" /* SERV */ +#define TOK_SERVER "'" /* 39 */ +#define MSG_LIST "LIST" /* LIST */ +#define TOK_LIST "(" /* 40 */ +#define MSG_TOPIC "TOPIC" /* TOPI */ +#define TOK_TOPIC ")" /* 41 */ +#define MSG_INVITE "INVITE" /* INVI */ +#define TOK_INVITE "*" /* 42 */ +#define MSG_VERSION "VERSION" /* VERS */ +#define TOK_VERSION "+" /* 43 */ +#define MSG_QUIT "QUIT" /* QUIT */ +#define TOK_QUIT "," /* 44 */ +#define MSG_SQUIT "SQUIT" /* SQUI */ +#define TOK_SQUIT "-" /* 45 */ +#define MSG_KILL "KILL" /* KILL */ +#define TOK_KILL "." /* 46 */ +#define MSG_INFO "INFO" /* INFO */ +#define TOK_INFO "/" /* 47 */ +#define MSG_LINKS "LINKS" /* LINK */ +#define TOK_LINKS "0" /* 48 */ +#define MSG_WATCH "WATCH" /* WATCH */ +#define TOK_WATCH "1" /* 49 */ +#define MSG_STATS "STATS" /* STAT */ +#define TOK_STATS "2" /* 50 */ +#define MSG_HELP "HELP" /* HELP */ +#define MSG_HELPOP "HELPOP" /* HELP */ +#define TOK_HELP "4" /* 52 */ +#define MSG_ERROR "ERROR" /* ERRO */ +#define TOK_ERROR "5" /* 53 */ +#define MSG_AWAY "AWAY" /* AWAY */ +#define TOK_AWAY "6" /* 54 */ +#define MSG_CONNECT "CONNECT" /* CONN */ +#define TOK_CONNECT "7" /* 55 */ +#define MSG_PING "PING" /* PING */ +#define TOK_PING "8" /* 56 */ +#define MSG_PONG "PONG" /* PONG */ +#define TOK_PONG "9" /* 57 */ +#define MSG_OPER "OPER" /* OPER */ +#define TOK_OPER ";" /* 59 */ +#define MSG_PASS "PASS" /* PASS */ +#define TOK_PASS "<" /* 60 */ +#define MSG_WALLOPS "WALLOPS" /* WALL */ +#define TOK_WALLOPS "=" /* 61 */ +#define MSG_TIME "TIME" /* TIME */ +#define TOK_TIME ">" /* 62 */ +#define MSG_NAMES "NAMES" /* NAME */ +#define TOK_NAMES "?" /* 63 */ +#define MSG_ADMIN "ADMIN" /* ADMI */ +#define TOK_ADMIN "@" /* 64 */ +#define MSG_NOTICE "NOTICE" /* NOTI */ +#define TOK_NOTICE "B" /* 66 */ +#define MSG_JOIN "JOIN" /* JOIN */ +#define TOK_JOIN "C" /* 67 */ +#define MSG_PART "PART" /* PART */ +#define TOK_PART "D" /* 68 */ +#define MSG_LUSERS "LUSERS" /* LUSE */ +#define TOK_LUSERS "E" /* 69 */ +#define MSG_MOTD "MOTD" /* MOTD */ +#define TOK_MOTD "F" /* 70 */ +#define MSG_MODE "MODE" /* MODE */ +#define TOK_MODE "G" /* 71 */ +#define MSG_KICK "KICK" /* KICK */ +#define TOK_KICK "H" /* 72 */ +#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ +#define TOK_SERVICE "I" /* 73 */ +#define MSG_USERHOST "USERHOST" /* USER -> USRH */ +#define TOK_USERHOST "J" /* 74 */ +#define MSG_ISON "ISON" /* ISON */ +#define TOK_ISON "K" /* 75 */ +#define MSG_SQUERY "SQUERY" /* SQUE */ +#define TOK_SQUERY "L" /* 76 */ +#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ +#define TOK_SERVLIST "M" /* 77 */ +#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ +#define TOK_SERVSET "N" /* 78 */ +#define MSG_REHASH "REHASH" /* REHA */ +#define TOK_REHASH "O" /* 79 */ +#define MSG_RESTART "RESTART" /* REST */ +#define TOK_RESTART "P" /* 80 */ +#define MSG_CLOSE "CLOSE" /* CLOS */ +#define TOK_CLOSE "Q" /* 81 */ +#define MSG_DIE "DIE" /* DIE */ +#define TOK_DIE "R" /* 82 */ +#define MSG_HASH "HASH" /* HASH */ +#define TOK_HASH "S" /* 83 */ +#define MSG_DNS "DNS" /* DNS -> DNSS */ +#define TOK_DNS "T" /* 84 */ +#define MSG_SILENCE "SILENCE" /* SILE */ +#define TOK_SILENCE "U" /* 85 */ +#define MSG_AKILL "AKILL" /* AKILL */ +#define TOK_AKILL "V" /* 86 */ +#define MSG_KLINE "KLINE" /* KLINE */ +#define TOK_KLINE "W" /* 87 */ +#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ +#define TOK_UNKLINE "X" /* 88 */ +#define MSG_RAKILL "RAKILL" /* RAKILL */ +#define TOK_RAKILL "Y" /* 89 */ +#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ +#define TOK_GNOTICE "Z" /* 90 */ +#define MSG_GOPER "GOPER" /* GOPER */ +#define TOK_GOPER "[" /* 91 */ +#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ +#define TOK_GLOBOPS "]" /* 93 */ +#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ +#define TOK_LOCOPS "^" /* 94 */ +#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ +#define TOK_PROTOCTL "_" /* 95 */ +#define MSG_TRACE "TRACE" /* TRAC */ +#define TOK_TRACE "b" /* 98 */ +#define MSG_SQLINE "SQLINE" /* SQLINE */ +#define TOK_SQLINE "c" /* 99 */ +#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ +#define TOK_UNSQLINE "d" /* 100 */ +#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ +#define TOK_SVSNICK "e" /* 101 */ +#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */ +#define TOK_SVSNOOP "f" /* 101 */ +#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */ +#define TOK_IDENTIFY "g" /* 103 */ +#define MSG_SVSKILL "SVSKILL" /* SVSKILL */ +#define TOK_SVSKILL "h" /* 104 */ +#define MSG_NICKSERV "NICKSERV" /* NICKSERV */ +#define MSG_NS "NS" +#define TOK_NICKSERV "i" /* 105 */ +#define MSG_CHANSERV "CHANSERV" /* CHANSERV */ +#define MSG_CS "CS" +#define TOK_CHANSERV "j" /* 106 */ +#define MSG_OPERSERV "OPERSERV" /* OPERSERV */ +#define MSG_OS "OS" +#define TOK_OPERSERV "k" /* 107 */ +#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */ +#define MSG_MS "MS" +#define TOK_MEMOSERV "l" /* 108 */ +#define MSG_SERVICES "SERVICES" /* SERVICES */ +#define TOK_SERVICES "m" /* 109 */ +#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ +#define TOK_SVSMODE "n" /* 110 */ +#define MSG_SAMODE "SAMODE" /* SAMODE */ +#define TOK_SAMODE "o" /* 111 */ +#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ +#define TOK_CHATOPS "p" /* 112 */ +#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ +#define TOK_HELPSERV "r" /* 114 */ +#define MSG_ZLINE "ZLINE" /* ZLINE */ +#define TOK_ZLINE "s" /* 115 */ +#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ +#define TOK_UNZLINE "t" /* 116 */ +#define MSG_NETINFO "NETINFO" /* NETINFO */ +#define TOK_NETINFO "u" /* 117 */ +#define MSG_RULES "RULES" /* RULES */ +#define TOK_RULES "v" /* 118 */ +#define MSG_MAP "MAP" /* MAP */ +#define TOK_MAP "w" /* 119 */ +#define MSG_NETG "NETG" /* NETG */ +#define TOK_NETG "x" /* 120 */ +#define MSG_ADCHAT "ADCHAT" /* Adchat */ +#define TOK_ADCHAT "y" /* 121 */ +#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ +#define TOK_MAKEPASS "z" /* 122 */ +#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ +#define TOK_ADDHUB "{" /* 123 */ +#define MSG_DELHUB "DELHUB" /* DELHUB */ +#define TOK_DELHUB "|" /* 124 */ +#define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */ +#define TOK_ADDCNLINE "}" /* 125 */ +#define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */ +#define TOK_DELCNLINE "~" /* 126 */ +#define MSG_ADDOPER "ADDOPER" /* ADDOPER */ +#define TOK_ADDOPER "" /* 127 */ +#define MSG_DELOPER "DELOPER" /* DELOPER */ +#define TOK_DELOPER "!!" /* 33 + 33 */ +#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ +#define TOK_ADDQLINE "!\"" /* 33 + 34 */ +#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ +#define TOK_DELQLINE "!#" /* 33 + 35 */ +#define MSG_GSOP "GSOP" /* GSOP */ +#define TOK_GSOP "!$" /* 33 + 36 */ +#define MSG_ISOPER "ISOPER" /* ISOPER */ +#define TOK_ISOPER "!%" /* 33 + 37 */ +#define MSG_ADG "ADG" /* ADG */ +#define TOK_ADG "!&" /* 33 + 38 */ +#define MSG_NMON "NMON" /* NMON */ +#define TOK_NMON "!'" /* 33 + 39 */ +#define MSG_DALINFO "DALINFO" /* DALnet Credits */ +#define TOK_DALINFO "!(" /* 33 + 40 */ +#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ +#define TOK_CREDITS "!)" /* 33 + 41 */ +#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ +#define TOK_OPERMOTD "!*" /* 33 + 42 */ +#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ +#define TOK_REMREHASH "!+" /* 33 + 43 */ +#define MSG_MONITOR "MONITOR" /* MONITOR */ +#define TOK_MONITOR "!," /* 33 + 44 */ +#define MSG_GLINE "GLINE" /* The awesome g-line */ +#define TOK_GLINE "!-" /* 33 + 45 */ +#define MSG_REMGLINE "REMGLINE" /* remove g-line */ +#define TOK_REMGLINE "!." /* 33 + 46 */ +#define MSG_STATSERV "STATSERV" /* StatServ */ +#define TOK_STATSERV "!/" /* 33 + 47 */ +#define MSG_RULESERV "RULESERV" /* RuleServ */ +#define TOK_RULESERV "!0" /* 33 + 48 */ +#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ +#define TOK_SNETINFO "!1" /* 33 + 49 */ +#define MSG_TSCTL "TSCTL" /* TSCTL */ +#define TOK_TSCTL "!3" /* 33 + 51 */ +#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ +#define TOK_SVSJOIN "!4" /* 33 + 52 */ +#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ +#define TOK_SAJOIN "!5" /* 33 + 53 */ +#define MSG_SDESC "SDESC" /* SDESC */ +#define TOK_SDESC "!6" /* 33 + 54 */ +#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ +#define TOK_UNREALINFO "!7" /* 33 + 55 */ +#define MSG_SETHOST "SETHOST" /* sethost */ +#define TOK_SETHOST "!8" /* 33 + 56 */ +#define MSG_SETIDENT "SETIDENT" /* set ident */ +#define TOK_SETIDENT "!9" /* 33 + 57 */ +#define MSG_SETNAME "SETNAME" /* set Realname */ +#define TOK_SETNAME "!;" /* 33 + 59 */ +#define MSG_CHGHOST "CHGHOST" /* Changehost */ +#define TOK_CHGHOST "!<" /* 33 + 60 */ +#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ +#define TOK_CHGIDENT "!=" /* 33 + 61 */ +#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ +#define TOK_RANDQUOTE "!>" /* 33 + 62 */ +#define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */ +#define TOK_ADDQUOTE "!?" /* 33 + 63 */ +#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ +#define TOK_ADDGQUOTE "!@" /* 33 + 64 */ +#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ +#define TOK_ADDULINE "!B" /* 33 + 66 */ +#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ +#define TOK_DELULINE "!C" /* 33 + 67 */ +#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ +#define TOK_KNOCK "!D" /* 33 + 68 */ +#define MSG_SETTINGS "SETTINGS" /* Settings */ +#define TOK_SETTINGS "!E" /* 33 + 69 */ +#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ +#define TOK_IRCOPS "!F" /* 33 + 70 */ +#define MSG_SVSPART "SVSPART" /* SVSPART */ +#define TOK_SVSPART "!G" /* 33 + 71 */ +#define MSG_SAPART "SAPART" /* SAPART */ +#define TOK_SAPART "!H" /* 33 + 72 */ +#define MSG_VCTRL "VCTRL" /* VCTRL */ +#define TOK_VCTRL "!I" /* 33 + 73 */ +#define MSG_GCLIENT "GCLIENT" /* GLIENT */ +#define TOK_GCLIENT "!J" /* 33 + 74 */ +#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ +#define TOK_CHANNEL "!K" /* 33 + 75 */ +#define MSG_UPTIME "UPTIME" /* UPTIME */ +#define TOK_UPTIME "!L" /* 33 + 76 */ +#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ +#define TOK_FAILOPS "!M" /* 33 + 77 */ + +#define MSG_RPING "RPING" /* RPING */ +#define TOK_RPING "!P" /* 33 + 80 */ +#define MSG_RPONG "RPONG" /* RPONG */ +#define TOK_RPONG "!Q" /* 33 + 81 */ +#define MSG_UPING "UPING" /* UPING */ +#define TOK_UPING "!R" /* 33 + 82 */ +#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ +#define TOK_COPYRIGHT "!S" /* 33 + 83 */ +#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ +#define MSG_BS "BS" +#define TOK_BOTSERV "!T" /* 33 + 84 */ +#define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */ +#define MSG_RS "RS" +#define TOK_ROOTSERV "!U" /* 33 + 85 */ +#define MSG_SVINFO "SVINFO" +#define MSG_CAPAB "CAPAB" +#define MSG_BURST "BURST" +#define MSG_SJOIN "SJOIN" +#define MSG_CLIENT "CLIENT" +#define MSG_SMODE "SMODE" + + + +#define UMODE_INVISIBLE 0x0001 /* makes user invisible */ +#define UMODE_OPER 0x0002 /* Operator */ +#define UMODE_WALLOP 0x0004 /* send wallops to them */ +#define UMODE_FAILOP 0x0008 /* Shows some global messages */ +#define UMODE_HELPOP 0x0010 /* Help system operator */ +#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */ +#define UMODE_SERVICESOPER 0x0040 /* Services Oper */ +#ifndef ULTIMATE3 +#define UMODE_ADMIN 0x0080 /* Admin */ +#define UMODE_NETADMIN 0x10000 /* Network Admin */ +#define UMODE_SUPER 0x20000 /* Oper Is Protected from Kick's and Kill's */ +#define UMODE_RBOT 0x40000 /* Marks the client as a Registered Bot */ +#define UMODE_SBOT 0x80000 /* Marks the client as a Server Bot */ +#define UMODE_NGLOBAL 0x100000 /* See Network Globals */ +#define UMODE_NETINFO 0x400000 /* Server link, Delink Notces etc. */ +#define UMODE_MAGICK 0x800000 /* Allows Opers To See +s and +p Channels */ +#define UMODE_WATCHER 0x4000000 /* Recive Monitor Globals */ +#define UMODE_NETMON 0x8000000 /* Marks the client as an Network Monitor */ +#define UMODE_SERVADMIN 0x40000000 /* Marks the client as a Server Admin */ +#define UMODE_TECHADMIN 0x80000000 /* Marks the client as a Technical Admin */ +#define UMODE_DEAF 0x100000000 /* client is deaf on channels */ +#else +#define UMODE_SPY 0x0080 /* Oper Spy */ +#define UMODE_DCC 0x10000 /* Oper DCC Notices */ +#define UMODE_GLOBOPS 0x20000 /* send/recv global notices */ +#define UMODE_REJ 0x40000 /* see DCC reject notices */ +#define UMODE_ROUTE 0x80000 /* see Routing Notices */ +#define UMODE_SPAM 0x100000 /* see spambot warnings */ +#define UMODE_PROT 0x400000 /* protected IRC op */ +#define UMODE_GLOBCON 0x800000 /* Global Connect notices */ +#define UMODE_DEBUG 0x4000000 /* see debug notices */ +#define UMODE_DCCWARN 0x8000000 /* see DCC warnings */ +#endif + +#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */ +#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */ +#define UMODE_KILLS 0x0400 /* Show server-kills... */ +#define UMODE_CLIENT 0x0800 /* Show client information */ +#define UMODE_FLOOD 0x1000 /* Receive flood warnings */ +#define UMODE_CHATOP 0x2000 /* can receive chatops */ +#define UMODE_SERVICES 0x4000 /* services */ +#define UMODE_HIDE 0x8000 /* Hide from Nukes */ +#define UMODE_WHOIS 0x200000 /* Lets Opers see when people do a /WhoIs on them */ +#define UMODE_IRCADMIN 0x1000000 /* Marks the client as an IRC Administrator */ +#define UMODE_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */ + + + +#define SMODE_SSL 0x1 /* ssl client */ +#define SMODE_COADMIN 0x2 /* co admin on a server */ +#define SMODE_SERVADMIN 0x4 /* server admin */ +#define SMODE_COTECH 0x8 /* co-tech admin */ +#define SMODE_TECHADMIN 0x10 /* tech administrator */ +#define SMODE_CONET 0x20 /* Co-Network Admin */ +#define SMODE_NETADMIN 0x40 /* Network Admin */ +#define SMODE_GUEST 0x80 /* Guest Admin */ + + +#define MODE_CHANOP 0x0001 +#define MODE_HALFOP 0x0002 +#define MODE_VOICE 0x0004 +#define MODE_PRIVATE 0x0008 +#define MODE_SECRET 0x0010 +#define MODE_MODERATED 0x0020 +#define MODE_TOPICLIMIT 0x0040 +#define MODE_INVITEONLY 0x0080 +#define MODE_NOPRIVMSGS 0x0100 +#define MODE_KEY 0x0200 +#define MODE_EXCEPT 0x0400 +#define MODE_BAN 0x0800 +#define MODE_LIMIT 0x1000 +#define MODE_RGSTR 0x2000 +#define MODE_RGSTRONLY 0x4000 +#define MODE_OPERONLY 0x8000 +#define MODE_ADMONLY 0x10000 +#define MODE_LINK 0x20000 +#define MODE_NOCOLOR 0x40000 +#define MODE_STRIP 0x80000 +#define MODE_NOKNOCK 0x100000 +#define MODE_NOINVITE 0x200000 +#define MODE_FLOODLIMIT 0x400000 +#define MODE_CHANADMIN 0x800000 + + +#define is_hidden_chan(x) ((x) && (x->modes & (MODE_PRIVATE|MODE_SECRET|MODE_ADMONLY|MODE_OPERONLY))) +#define is_oper(x) ((x) && ((x->Umode & UMODE_OPER) || (x->Umode & UMODE_LOCOP))) + + +struct ircd_srv_ { + int uprot; + int modex; + int nicklg; + int gc; + char cloak[25]; + int burst; + int cmdcount; +} ircd_srv; + +typedef struct { + long mode; + char flag; + unsigned nickparam : 1; /* 1 = yes 0 = no */ + unsigned parameters : 1; + char sjoin; +} aCtab; + + + + + +typedef struct { + unsigned long umodes; + char mode; + int level; +} Oper_Modes; + + +aCtab cFlagTab[33]; +Oper_Modes usr_mds[29]; +Oper_Modes susr_mds[9]; + + + +/* function declarations */ +extern void init_ircd(); +extern void chanalert(char *,char *, ...); +extern int sserver_cmd(const char *, const int numeric, const char *); +extern int slogin_cmd(const char *, const int numeric, const char *, const char *); +extern int ssquit_cmd(const char *); +extern int sprotocol_cmd(const char *); +extern int squit_cmd(const char *, const char *); +extern int spart_cmd(const char *, const char *); +#ifdef ULTIMATE3 +extern int sjoin_cmd(const char *, const char *, unsigned long flag); +#else +extern int sjoin_cmd(const char *, const char *); +#endif +extern int schmode_cmd(const char *, const char *, const char *, const char *); +#ifndef ULTIMATE3 +extern int snewnick_cmd(const char *, const char *, const char *, const char *); +#else +extern int snewnick_cmd(const char *, const char *, const char *, const char *, long mode); +#endif +extern int sping_cmd(const char *from, const char *reply, const char *to); +extern int sumode_cmd(const char *who, const char *target, long mode); +extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); +extern int spong_cmd(const char *reply); +extern int snetinfo_cmd(); +extern int skill_cmd(const char *from, const char *target, const char *reason,...); +extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); +extern int snick_cmd(const char *oldnick, const char *newnick); +extern int sswhois_cmd(const char *target, const char *swhois); +extern int ssvsnick_cmd(const char *target, const char *newnick); +extern int ssvsjoin_cmd(const char *target, const char *chan); +extern int ssvspart_cmd(const char *target, const char *chan); +extern int ssvshost_cmd(const char *who, const char *vhost); +extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); +extern int swallops_cmd(const char *who, const char *msg,...); +extern int vctrl_cmd(); +extern int ssvinfo_cmd(); +extern int sburst_cmd(int b); +extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); +extern int srakill_cmd(const char *host, const char *ident); +extern int ssvshost_cmd(const char *who, const char *vhost); +extern int ssvskill_cmd(const char *who, const char *reason, ...); + +void Usr_Version(char *, char **, int argc); +void Usr_ShowMOTD(char *, char **, int argc); +void Usr_ShowADMIN(char *, char **, int argc); +void Usr_Showcredits(char *, char **, int argc); +void Usr_AddServer(char *, char **, int argc); +void Usr_DelServer(char *, char **, int argc); +void Usr_DelUser(char *, char **, int argc); +void Usr_Mode(char *, char **, int argc); +void Usr_Smode(char *, char **, int argc); +void Usr_Kill(char *, char **, int argc); +void Usr_Pong(char *, char **, int argc); +void Usr_Away(char *, char **, int argc); +void Usr_Nick(char *, char **, int argc); +void Usr_Topic(char *, char **, int argc); +void Usr_Kick(char *, char **, int argc); +void Usr_Join(char *, char **, int argc); +void Usr_Part(char *, char **, int argc); +void Usr_Stats(char *, char **, int argc); +void Usr_Vhost(char *, char **, int argc); +void Srv_Topic(char *, char **, int argc); +void Srv_Ping(char *, char **, int argc); +void Srv_Netinfo(char *, char **, int argc); +void Srv_Pass(char *, char **, int argc); +void Srv_Server(char *, char **, int argc); +void Srv_Squit(char *, char **, int argc); +void Srv_Nick(char *, char **, int argc); +void Srv_Svsnick(char *, char **, int argc); +void Srv_Kill(char *, char **, int argc); +void Srv_Connect(char *, char **, int argc); +void Srv_Svinfo(char *, char **, int argc); +void Srv_Burst(char *origin, char **argv, int argc); +void Srv_Sjoin(char *origin, char **argv, int argc); +void Srv_Tburst(char *origin, char **argv, int argc); +void Srv_Vctrl(char *origin, char **argv, int argc); +void Srv_Client(char *origin, char **argv, int argc); +void Srv_Smode(char *origin, char **argv, int argc); +int SignOn_NewBot(const char *, const char *, const char *, const char *, long); + + +#endif diff --git a/ChangeLog b/ChangeLog index b7f00008..fdefa590 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ NeoStats ChangeLog - Anything we add/remove/fix/change is in here (even our rant - users/servers/channels/modes now have a module data pointer - Fixed (again) FloodControl Code: BugID 18. Now uses svskill. Should be more robust. - Tested long and hard the Ultimate3 IRCd port. Should be good. :) + - Added Quantum/Bahamut/IRCu framework * NeoStats * Fish * Version 2.5.3 - Added ability to turn off StatServ wallops. "/msg statserv set msgthrottle off" - BugID#6 diff --git a/Ircu.c b/Ircu.c new file mode 100644 index 00000000..c32b7daa --- /dev/null +++ b/Ircu.c @@ -0,0 +1,946 @@ +/* NeoStats - IRC Statistical Services +** Copyright (c) 1999-2003 Adam Rutter, Justin Hammond +** http://www.neostats.net/ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +** USA +** +** NeoStats CVS Identification +** $Id: Ircu.c,v 1.1 2003/06/30 15:18:23 fishwaldo Exp $ +*/ + +#include "stats.h" +#include "ircd.h" +#include "sock.h" +#include "hybrid7.h" +#include "dl.h" +#include "log.h" + +/* this is the command list and associated functions to run */ +IntCommands cmd_list[] = { + /* Command Function srvmsg */ + {MSG_STATS, Usr_Stats, 1, 0} + , + {MSG_VERSION, Usr_Version, 1, 0} + , + {MSG_MOTD, Usr_ShowMOTD, 1, 0} + , + {MSG_ADMIN, Usr_ShowADMIN, 1, 0} + , + {MSG_CREDITS, Usr_Showcredits, 1, 0} + , + {MSG_SERVER, Usr_AddServer, 1, 0} + , + {MSG_SQUIT, Usr_DelServer, 1, 0} + , + {MSG_QUIT, Usr_DelUser, 1, 0} + , + {MSG_MODE, Usr_Mode, 1, 0} + , + {MSG_KILL, Usr_Kill, 1, 0} + , + {MSG_PONG, Usr_Pong, 1, 0} + , + {MSG_AWAY, Usr_Away, 1, 0} + , + {MSG_NICK, Usr_Nick, 1, 0} + , + {MSG_TOPIC, Usr_Topic, 1, 0} + , + {MSG_TOPIC, Usr_Topic, 0, 0} + , + {MSG_KICK, Usr_Kick, 1, 0} + , + {MSG_JOIN, Usr_Join, 1, 0} + , + {MSG_PART, Usr_Part, 1, 0} + , + {MSG_PING, Srv_Ping, 0, 0} + , + {MSG_SVINFO, Srv_Svinfo, 0, 0} + , + {MSG_PASS, Srv_Pass, 0, 0} + , + {MSG_SERVER, Srv_Server, 0, 0} + , + {MSG_SQUIT, Srv_Squit, 0, 0} + , + {MSG_NICK, Srv_Nick, 0, 0} + , + {MSG_KILL, Srv_Kill, 0, 0} + , + {MSG_EOB, Srv_Burst, 1, 0} + , + {MSG_SJOIN, Srv_Sjoin, 1, 0} + , + {NULL, NULL, 0, 0} +}; + +aCtab cFlagTab[] = { + {MODE_HALFOP, 'h', 1, 0, '%'} + , + {MODE_CHANOP, 'o', 1, 0, '@'} + , + {MODE_VOICE, 'v', 1, 0, '+'} + , + {MODE_SECRET, 's', 0, 0, 0} + , + {MODE_PRIVATE, 'p', 0, 0, 0} + , + {MODE_MODERATED, 'm', 0, 0, 0} + , + {MODE_TOPICLIMIT, 't', 0, 0, 0} + , + {MODE_INVITEONLY, 'i', 0, 0, 0} + , + {MODE_NOPRIVMSGS, 'n', 0, 0, 0} + , + {MODE_HIDEOPS, 'a', 0, 0, 0} + , + {MODE_LIMIT, 'l', 0, 1, 0} + , + {MODE_KEY, 'k', 0, 1, 0} + , + {MODE_BAN, 'b', 0, 1, 0} + , + {MODE_EXCEPT, 'e', 0, 1, 0} + , + {MODE_INVEX, 'I', 0, 1, 0} + , + {0x0, 0x0, 0x0, 0x0, 0x0} +}; + + +Oper_Modes usr_mds[] = { + {UMODE_OPER, 'o', 50} + , + {UMODE_ADMIN, 'A', 190} + , + {UMODE_BOTS, 'b', 0} + , + {UMODE_CCONN, 'c', 0} + , + {UMODE_DEBUG, 'd', 200} + , + {UMODE_FULL, 'f', 0} + , + {UMODE_CALLERID, 'g', 0} + , + {UMODE_INVISIBLE, 'i', 0} + , + {UMODE_SKILL, 'k', 0} + , + {UMODE_LOCOPS, 'l', 40} + , + {UMODE_NCHANGE, 'n', 0} + , + {UMODE_REJ, 'r', 0} + , + {UMODE_SERVNOTICE, 's', 0} + , + {UMODE_UNAUTH, 'u', 0} + , + {UMODE_WALLOP, 'w', 0} + , + {UMODE_EXTERNAL, 'x', 0} + , + {UMODE_SPY, 'y', 0} + , + {UMODE_OPERWALL, 'z', 0} + , + {UMODE_SERVICES, 'S', 0} + , + {0, 0, 0} +}; + +void init_ircd() +{ + /* count the number of commands */ + ircd_srv.cmdcount = ((sizeof(cmd_list) / sizeof(cmd_list[0])) - 1); +}; + +int seob_cmd(const char *server) +{ + sts(":%s %s", server, MSG_EOB); + return 1; +} + + +int sserver_cmd(const char *name, const int numeric, const char *infoline) +{ + sts(":%s %s %s %d :%s", me.name, MSG_SERVER, name, numeric, + infoline); + return 1; +} + +int slogin_cmd(const char *name, const int numeric, const char *infoline, + const char *pass) +{ + sts("%s %s :TS", MSG_PASS, pass); + sts("CAPAB :TS EX CHW IE EOB KLN GLN KNOCK HOPS HUB AOPS MX"); + sts("%s %s %d :%s", MSG_SERVER, name, numeric, infoline); + return 1; +} + +int ssquit_cmd(const char *server) +{ + sts("%s %s", MSG_SQUIT, server); + return 1; +} + +int sprotocol_cmd(const char *option) +{ + return 1; +} + +int squit_cmd(const char *who, const char *quitmsg) +{ + sts(":%s %s :%s", who, MSG_QUIT, quitmsg); + DelUser(who); + return 1; +} + +int spart_cmd(const char *who, const char *chan) +{ + sts(":%s %s %s", who, MSG_PART, chan); + part_chan(finduser(who), (char *) chan); + return 1; +} + +int sjoin_cmd(const char *who, const char *chan) +{ + sts(":%s %s 0 %s + :%s", me.name, MSG_SJOIN, chan, who); + join_chan(finduser(who), (char *) chan); + return 1; +} + +int schmode_cmd(const char *who, const char *chan, const char *mode, + const char *args) +{ + char **av; + int ac; + char tmp[512]; + + sts(":%s %s %s %s %s %lu", who, MSG_MODE, chan, mode, args, + time(NULL)); + snprintf(tmp, 512, "%s %s %s", chan, mode, args); + ac = split_buf(tmp, &av, 0); + ChanMode("", av, ac); + free(av); + return 1; +} +int snewnick_cmd(const char *nick, const char *ident, const char *host, + const char *realname, long mode) +{ + int i, j; + char newmode[20]; + newmode[0] = '+'; + j = 1; + for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) { + if (mode & usr_mds[i].umodes) { + newmode[j] = usr_mds[i].mode; + j++; + } + + } + newmode[j] = '\0'; + sts("%s %s 1 %lu %s %s %s %s :%s", MSG_NICK, nick, time(NULL), + newmode, ident, host, me.name, realname); + AddUser(nick, ident, host, me.name, 0, time(NULL)); + UserMode(nick, newmode, 0); + return 1; +} + +int sping_cmd(const char *from, const char *reply, const char *to) +{ + sts(":%s %s %s :%s", from, MSG_PING, reply, to); + return 1; +} + +int sumode_cmd(const char *who, const char *target, long mode) +{ + int i, j; + char newmode[20]; + newmode[0] = '+'; + j = 1; + for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) { + if (mode & usr_mds[i].umodes) { + newmode[j] = usr_mds[i].mode; + j++; + } + + } + newmode[j] = '\0'; + sts(":%s %s %s :%s", who, MSG_MODE, target, newmode); + UserMode(target, newmode, 0); + return 1; +} + +int snumeric_cmd(const int numeric, const char *target, const char *data, + ...) +{ + va_list ap; + char buf[512]; + va_start(ap, data); + vsnprintf(buf, 512, data, ap); + sts(":%s %d %s :%s", me.name, numeric, target, buf); + va_end(ap); + return 1; +} + +int spong_cmd(const char *reply) +{ + sts("%s %s", MSG_PONG, reply); + return 1; +} + + +int skill_cmd(const char *from, const char *target, const char *reason, + ...) +{ + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + sts(":%s %s %s :%s", from, MSG_KILL, target, buf); + va_end(ap); + DelUser(target); + return 1; +} +int ssvskill_cmd(const char *who, const char *reason, ...) +{ + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + sts(":%s %s %s :%s", me.name, MSG_KILL, + who, buf); + va_end(ap); +/* hybrid doesn't have svskill, so this is handled just like a normal kill */ + DelUser(who); + return 1; +} + +int ssmo_cmd(const char *from, const char *umodetarget, const char *msg) +{ + notice(s_Services, + "Warning, Module %s tried to SMO, which is not supported in Hybrid", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning, Module %s tried to SMO, which is not supported in Hybrid", + segvinmodule); + return 1; +} + +int snick_cmd(const char *oldnick, const char *newnick) +{ + Change_User(finduser(oldnick), newnick); + sts(":%s %s %s %d", oldnick, MSG_NICK, newnick, time(NULL)); + return 1; +} +int sswhois_cmd(const char *target, const char *swhois) +{ + notice(s_Services, + "Warning Module %s tried to SWHOIS, which is not supported in Hybrid", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning. Module %s tried to SWHOIS, which is not supported in Hybrid", + segvinmodule); + return 1; +} +int ssvsnick_cmd(const char *target, const char *newnick) +{ + notice(s_Services, + "Warning Module %s tried to SVSNICK, which is not supported in Hybrid", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning. Module %s tried to SVSNICK, which is not supported in Hybrid", + segvinmodule); + return 1; +} + +int ssvsjoin_cmd(const char *target, const char *chan) +{ + notice(s_Services, + "Warning Module %s tried to SJOIN, which is not supported in Hybrid", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning. Module %s tried to SJOIN, which is not supported in Hybrid", + segvinmodule); + return 1; +} + +int ssvspart_cmd(const char *target, const char *chan) +{ + notice(s_Services, + "Warning Module %s tried to SVSPART, which is not supported in Hybrid", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning. Module %s tried to SVSPART, which is not supported in Hybrid", + segvinmodule); + return 1; +} + +int skick_cmd(const char *who, const char *target, const char *chan, + const char *reason) +{ + sts(":%s %s %s %s :%s", who, MSG_KICK, chan, target, + (reason ? reason : "No Reason Given")); + part_chan(finduser(target), (char *) chan); + return 1; +} +int swallops_cmd(const char *who, const char *msg, ...) +{ + va_list ap; + char buf[512]; + va_start(ap, msg); + vsnprintf(buf, 512, msg, ap); + sts(":%s %s :%s", who, MSG_WALLOPS, buf); + va_end(ap); + return 1; +} + +int ssvshost_cmd(const char *who, const char *vhost) +{ + notice(s_Services, + "Warning Module %s tried to SVSHOST, which is not supported in Hybrid", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning. Module %s tried to SVSHOST, which is not supported in Hybrid", + segvinmodule); + return 1; +} + +int ssvinfo_cmd() +{ + sts("SVINFO 5 3 0 :%d", time(NULL)); + return 1; +} +int sburst_cmd(int b) +{ + if (b == 0) { + sts("BURST 0"); + } else { + sts("BURST"); + } + return 1; +} + +int sakill_cmd(const char *host, const char *ident, const char *setby, + const int length, const char *reason, ...) +{ + /* there isn't a akill on Hybrid, so we send a kline to all servers! */ + hscan_t ss; + hnode_t *sn; + Server *s; + + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + + hash_scan_begin(&ss, sh); + while ((sn = hash_scan_next(&ss)) != NULL) { + s = hnode_get(sn); + sts(":%s %s %s %lu %s %s :%s", setby, MSG_KLINE, s->name, + length, ident, host, buf); + } + va_end(ap); + return 1; +} +int srakill_cmd(const char *host, const char *ident) +{ + chanalert(s_Services, + "Please Manually remove KLINES using /unkline on each server"); + return 1; +} + + +void chanalert(char *who, char *buf, ...) +{ + va_list ap; + char tmp[512]; + char out[512]; + va_start(ap, buf); + vsnprintf(tmp, 512, buf, ap); + + if (me.onchan) { + snprintf(out, 512, ":%s PRIVMSG %s :%s", who, me.chan, + tmp); + nlog(LOG_DEBUG3, LOG_CORE, "SENT: %s", out); + sts("%s", out); + } + va_end(ap); +} +void prefmsg(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + if (me.want_privmsg) { + snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2); + } else { + snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2); + } + sts("%s", buf); + va_end(ap); +} +void privmsg(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2); + sts("%s", buf); + va_end(ap); +} + +void notice(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2); + sts("%s", buf); + va_end(ap); +} + + +void privmsg_list(char *to, char *from, const char **text) +{ + while (*text) { + if (**text) + prefmsg(to, from, "%s", *text); + else + prefmsg(to, from, " "); + text++; + } +} + + +void globops(char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + +/* Shmad - have to get rid of nasty term echos :-) */ + +/* Fish - now that was crackhead coding! */ + if (me.onchan) { + snprintf(buf, 512, ":%s GLOBOPS :%s", from, buf2); + sts("%s", buf); + } else { + nlog(LOG_NORMAL, LOG_CORE, "%s", buf2); + } + va_end(ap); +} + +void Srv_Sjoin(char *origin, char **argv, int argc) +{ + char nick[MAXNICK]; + long mode = 0; + long mode1 = 0; + char *modes; + int ok = 1, i, j = 3; + ModesParm *m; + Chans *c; + lnode_t *mn = NULL; + list_t *tl; + if (argc <= 2) { + modes = argv[1]; + } else { + modes = argv[2]; + } + + if (*modes == '#') { + join_chan(finduser(argv[4]), modes); + return; + } + tl = list_create(10); + + if (*modes != '+') { + goto nomodes; + } + while (*modes) { + for (i = 0; + i < ((sizeof(cFlagTab) / sizeof(cFlagTab[0])) - 1); + i++) { + if (*modes == cFlagTab[i].flag) { + if (cFlagTab[i].parameters) { + m = smalloc(sizeof(ModesParm)); + m->mode = cFlagTab[i].mode; + strncpy(m->param, argv[j], + PARAMSIZE); + mn = lnode_create(m); + if (!list_isfull(tl)) { + list_append(tl, mn); + } else { + nlog(LOG_CRITICAL, + LOG_CORE, + "Eeeek, tl list is full in Svr_Sjoin(ircd.c)"); + do_exit(0); + } + j++; + } else { + mode1 |= cFlagTab[i].mode; + } + } + } + modes++; + } + nomodes: + while (argc > j) { + modes = argv[j]; + mode = 0; + while (ok == 1) { + for (i = 0; + i < + ((sizeof(cFlagTab) / sizeof(cFlagTab[0])) - + 1); i++) { + if (cFlagTab[i].sjoin != 0) { + if (*modes == cFlagTab[i].sjoin) { + mode |= cFlagTab[i].mode; + modes++; + } + } + } + strncpy(nick, modes, MAXNICK); + ok = 0; + break; + } + join_chan(finduser(nick), argv[1]); + ChangeChanUserMode(findchan(argv[1]), finduser(nick), 1, + mode); + j++; + ok = 1; + } + c = findchan(argv[1]); + c->modes |= mode1; + if (!list_isempty(tl)) { + if (!list_isfull(c->modeparms)) { + list_transfer(c->modeparms, tl, list_first(tl)); + } else { + /* eeeeeeek, list is full! */ + nlog(LOG_CRITICAL, LOG_CORE, + "Eeeek, c->modeparms list is full in Svr_Sjoin(ircd.c)"); + do_exit(0); + } + } + list_destroy(tl); +} + +void Srv_Burst(char *origin, char **argv, int argc) +{ + if (argc > 0) { + if (ircd_srv.burst == 1) { + sburst_cmd(0); + ircd_srv.burst = 0; + me.synced = 1; + init_ServBot(); + } + } else { + ircd_srv.burst = 1; + } + seob_cmd(me.name); + init_ServBot(); +} + +void Srv_Connect(char *origin, char **argv, int argc) +{ + int i; + + for (i = 0; i < argc; i++) { + if (!strcasecmp("TOKEN", argv[i])) { + me.token = 1; + } + } +} + + +void Usr_Stats(char *origin, char **argv, int argc) +{ + User *u; + + u = finduser(origin); + if (!u) { + nlog(LOG_WARNING, LOG_CORE, + "Recieved a Message from a Unknown User! (%s)", + origin); + } + ShowStats(argv[0], u); +} + +void Usr_Version(char *origin, char **argv, int argc) +{ + snumeric_cmd(351, origin, "%d.%d.%d%s :%s -> %s %s", MAJOR, MINOR, + REV, version, me.name, version_date, version_time); +} +void Usr_ShowMOTD(char *origin, char **argv, int argc) +{ + ShowMOTD(origin); +} +void Usr_ShowADMIN(char *origin, char **argv, int argc) +{ + ShowADMIN(origin); +} +void Usr_Showcredits(char *origin, char **argv, int argc) +{ + Showcredits(origin); +} +void Usr_AddServer(char *origin, char **argv, int argc) +{ + AddServer(argv[0], origin, atoi(argv[1])); +} +void Usr_DelServer(char *origin, char **argv, int argc) +{ + DelServer(argv[0]); +} +void Usr_DelUser(char *origin, char **argv, int argc) +{ + DelUser(origin); +} +void Usr_Smode(char *origin, char **argv, int argc) +{ + if (!strchr(argv[0], '#')) { + /* its user svsmode change */ + UserMode(argv[0], argv[1], 0); + } else { + /* its a channel svsmode change */ + ChanMode(origin, argv, argc); + } +} +void Usr_Mode(char *origin, char **argv, int argc) +{ + if (!strchr(argv[0], '#')) { + nlog(LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[0]); + UserMode(argv[0], argv[1], 0); + } else { + ChanMode(origin, argv, argc); + } +} +void Usr_Kill(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(argv[0]); + if (u) { + KillUser(argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, "Can't find user %s for Kill", + argv[0]); + } +} +void Usr_Vhost(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(origin); + if (u) { + strncpy(u->vhost, argv[0], MAXHOST); + } +} +void Usr_Pong(char *origin, char **argv, int argc) +{ + Server *s; + s = findserver(argv[0]); + if (s) { + dopong(s); + } else { + nlog(LOG_NOTICE, LOG_CORE, + "Received PONG from unknown server: %s", argv[0]); + } +} +void Usr_Away(char *origin, char **argv, int argc) +{ + User *u = finduser(origin); + char *buf; + if (u) { + if (argc > 0) { + buf = joinbuf(argv, argc, 0); + } else { + buf = NULL; + } + Do_Away(u, buf); + if (argc > 0) { + free(buf); + } + } else { + nlog(LOG_NOTICE, LOG_CORE, + "Warning, Unable to find User %s for Away", origin); + } +} +void Usr_Nick(char *origin, char **argv, int argc) +{ + User *u = finduser(origin); + if (u) { + Change_User(u, argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Ehh, Can't find the user for %s", origin); + } + +} +void Usr_Topic(char *origin, char **argv, int argc) +{ + char *buf; + Chans *c; + c = findchan(argv[0]); + if (c) { + buf = joinbuf(argv, argc, 2); + Change_Topic(origin, c, time(NULL), buf); + free(buf); + } else { + nlog(LOG_WARNING, LOG_CORE, "Ehhh, Can't find Channel %s", + argv[0]); + } + +} + +void Usr_Kick(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(argv[1]); + if (u) { + kick_chan(u, argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Warning, Can't find user %s for kick %s", argv[1], + argv[0]); + } +} +void Usr_Join(char *origin, char **argv, int argc) +{ + char *s, *t; + t = argv[0]; + while (*(s = t)) { + t = s + strcspn(s, ","); + if (*t) + *t++ = 0; + join_chan(finduser(origin), s); + } +} +void Usr_Part(char *origin, char **argv, int argc) +{ + part_chan(finduser(origin), argv[0]); +} +void Srv_Ping(char *origin, char **argv, int argc) +{ + spong_cmd(argv[0]); +} + +void Srv_Svinfo(char *origin, char **argv, int argc) +{ + ssvinfo_cmd(); +} + +void Srv_Netinfo(char *origin, char **argv, int argc) +{ + me.onchan = 1; + ircd_srv.uprot = atoi(argv[2]); + strncpy(ircd_srv.cloak, argv[3], 10); + strncpy(me.netname, argv[7], MAXPASS); + init_ServBot(); + globops(me.name, "Link with Network \2Complete!\2"); + if (ircd_srv.uprot == 2109) { + me.usesmo = 1; + } + Module_Event("NETINFO", NULL, 0); + me.synced = 1; +} + +void Srv_Pass(char *origin, char **argv, int argc) +{ +} +void Srv_Server(char *origin, char **argv, int argc) +{ + Server *s; + if (*origin == 0) { + AddServer(argv[0], me.name, atoi(argv[1])); + } else { + AddServer(argv[0], origin, atoi(argv[1])); + } + s = findserver(argv[0]); + me.s = s; +} +void Srv_Squit(char *origin, char **argv, int argc) +{ + Server *s; + s = findserver(argv[0]); + if (s) { + DelServer(argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Waring, Squit from Unknown Server %s", argv[0]); + } + +} + +/* BE REALLY CAREFULL ABOUT THE ORDER OF THESE ifdef's */ + +void Srv_Nick(char *origin, char **argv, int argc) +{ + char *realname; + + AddUser(argv[0], argv[4], argv[5], argv[6], 0, + strtoul(argv[2], NULL, 10)); + realname = joinbuf(argv, argc, 7); + AddRealName(argv[0], realname); + free(realname); + nlog(LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[3]); + UserMode(argv[0], argv[3], 0); +} + +void Srv_Kill(char *origin, char **argv, int argc) +{ +} + +int SignOn_NewBot(const char *nick, const char *user, const char *host, + const char *rname, long Umode) +{ + snewnick_cmd(nick, user, host, rname, Umode); + + if ((me.allbots > 0) || (Umode & UMODE_SERVICES)) { + sjoin_cmd(nick, me.chan); + schmode_cmd(me.name, me.chan, "+o", nick); + } + return 1; +} diff --git a/Ircu.h b/Ircu.h new file mode 100644 index 00000000..71eeb377 --- /dev/null +++ b/Ircu.h @@ -0,0 +1,330 @@ +/* NeoStats - IRC Statistical Services +** Copyright (c) 1999-2003 Adam Rutter, Justin Hammond +** http://www.neostats.net/ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +** USA +** +** NeoStats CVS Identification +** $Id: Ircu.h,v 1.1 2003/06/30 15:18:23 fishwaldo Exp $ +*/ + + +#ifndef HYBRID7_H +#define HYBRID7_H + + + + +#define MSG_EOB "EOB" /* end of burst */ +#define MSG_PRIVATE "PRIVMSG" /* PRIV */ +#define MSG_WHO "WHO" /* WHO -> WHOC */ +#define MSG_WHOIS "WHOIS" /* WHOI */ +#define MSG_WHOWAS "WHOWAS" /* WHOW */ +#define MSG_USER "USER" /* USER */ +#define MSG_NICK "NICK" /* NICK */ +#define MSG_SERVER "SERVER" /* SERV */ +#define MSG_LIST "LIST" /* LIST */ +#define MSG_TOPIC "TOPIC" /* TOPI */ +#define MSG_INVITE "INVITE" /* INVI */ +#define MSG_VERSION "VERSION" /* VERS */ +#define MSG_QUIT "QUIT" /* QUIT */ +#define MSG_SQUIT "SQUIT" /* SQUI */ +#define MSG_KILL "KILL" /* KILL */ +#define MSG_INFO "INFO" /* INFO */ +#define MSG_LINKS "LINKS" /* LINK */ +#define MSG_WATCH "WATCH" /* WATCH */ +#define MSG_STATS "STATS" /* STAT */ +#define MSG_HELP "HELP" /* HELP */ +#define MSG_HELPOP "HELPOP" /* HELP */ +#define MSG_ERROR "ERROR" /* ERRO */ +#define MSG_AWAY "AWAY" /* AWAY */ +#define MSG_CONNECT "CONNECT" /* CONN */ +#define MSG_PING "PING" /* PING */ +#define MSG_PONG "PONG" /* PONG */ +#define MSG_OPER "OPER" /* OPER */ +#define MSG_PASS "PASS" /* PASS */ +#define MSG_WALLOPS "WALLOPS" /* WALL */ +#define MSG_TIME "TIME" /* TIME */ +#define MSG_NAMES "NAMES" /* NAME */ +#define MSG_ADMIN "ADMIN" /* ADMI */ +#define MSG_NOTICE "NOTICE" /* NOTI */ +#define MSG_JOIN "JOIN" /* JOIN */ +#define MSG_PART "PART" /* PART */ +#define MSG_LUSERS "LUSERS" /* LUSE */ +#define MSG_MOTD "MOTD" /* MOTD */ +#define MSG_MODE "MODE" /* MODE */ +#define MSG_KICK "KICK" /* KICK */ +#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ +#define MSG_USERHOST "USERHOST" /* USER -> USRH */ +#define MSG_ISON "ISON" /* ISON */ +#define MSG_SQUERY "SQUERY" /* SQUE */ +#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ +#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ +#define MSG_REHASH "REHASH" /* REHA */ +#define MSG_RESTART "RESTART" /* REST */ +#define MSG_CLOSE "CLOSE" /* CLOS */ +#define MSG_DIE "DIE" /* DIE */ +#define MSG_HASH "HASH" /* HASH */ +#define MSG_DNS "DNS" /* DNS -> DNSS */ +#define MSG_SILENCE "SILENCE" /* SILE */ +#define MSG_AKILL "AKILL" /* AKILL */ +#define MSG_KLINE "KLINE" /* KLINE */ +#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ +#define MSG_RAKILL "RAKILL" /* RAKILL */ +#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ +#define MSG_GOPER "GOPER" /* GOPER */ +#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ +#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ +#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ +#define MSG_TRACE "TRACE" /* TRAC */ +#define MSG_SQLINE "SQLINE" /* SQLINE */ +#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ +#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ +#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */ +#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */ +#define MSG_SVSKILL "SVSKILL" /* SVSKILL */ +#define MSG_NICKSERV "NICKSERV" /* NICKSERV */ +#define MSG_NS "NS" +#define MSG_CHANSERV "CHANSERV" /* CHANSERV */ +#define MSG_CS "CS" +#define MSG_OPERSERV "OPERSERV" /* OPERSERV */ +#define MSG_OS "OS" +#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */ +#define MSG_MS "MS" +#define MSG_SERVICES "SERVICES" /* SERVICES */ +#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ +#define MSG_SAMODE "SAMODE" /* SAMODE */ +#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ +#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ +#define MSG_ZLINE "ZLINE" /* ZLINE */ +#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ +#define MSG_NETINFO "NETINFO" /* NETINFO */ +#define MSG_RULES "RULES" /* RULES */ +#define MSG_MAP "MAP" /* MAP */ +#define MSG_NETG "NETG" /* NETG */ +#define MSG_ADCHAT "ADCHAT" /* Adchat */ +#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ +#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ +#define MSG_DELHUB "DELHUB" /* DELHUB */ +#define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */ +#define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */ +#define MSG_ADDOPER "ADDOPER" /* ADDOPER */ +#define MSG_DELOPER "DELOPER" /* DELOPER */ +#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ +#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ +#define MSG_GSOP "GSOP" /* GSOP */ +#define MSG_ISOPER "ISOPER" /* ISOPER */ +#define MSG_ADG "ADG" /* ADG */ +#define MSG_NMON "NMON" /* NMON */ +#define MSG_DALINFO "DALINFO" /* DALnet Credits */ +#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ +#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ +#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ +#define MSG_MONITOR "MONITOR" /* MONITOR */ +#define MSG_GLINE "GLINE" /* The awesome g-line */ +#define MSG_REMGLINE "REMGLINE" /* remove g-line */ +#define MSG_STATSERV "STATSERV" /* StatServ */ +#define MSG_RULESERV "RULESERV" /* RuleServ */ +#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ +#define MSG_TSCTL "TSCTL" /* TSCTL */ +#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ +#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ +#define MSG_SDESC "SDESC" /* SDESC */ +#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ +#define MSG_SETHOST "SETHOST" /* sethost */ +#define MSG_SETIDENT "SETIDENT" /* set ident */ +#define MSG_SETNAME "SETNAME" /* set Realname */ +#define MSG_CHGHOST "CHGHOST" /* Changehost */ +#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ +#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ +#define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */ +#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ +#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ +#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ +#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ +#define MSG_SETTINGS "SETTINGS" /* Settings */ +#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ +#define MSG_SVSPART "SVSPART" /* SVSPART */ +#define MSG_SAPART "SAPART" /* SAPART */ +#define MSG_VCTRL "VCTRL" /* VCTRL */ +#define MSG_GCLIENT "GCLIENT" /* GLIENT */ +#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ +#define MSG_UPTIME "UPTIME" /* UPTIME */ +#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ +#define MSG_RPING "RPING" /* RPING */ +#define MSG_RPONG "RPONG" /* RPONG */ +#define MSG_UPING "UPING" /* UPING */ +#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ +#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ +#define MSG_BS "BS" +#define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */ +#define MSG_SVINFO "SVINFO" +#define MSG_CAPAB "CAPAB" +#define MSG_BURST "BURST" +#define MSG_SJOIN "SJOIN" +#define MSG_TBURST "TBURST" + + + + +#define UMODE_OPER 0x0001 /* oper flag */ +#define UMODE_ADMIN 0x0002 /* admin flag */ +#define UMODE_BOTS 0x0004 /* shows bots */ +#define UMODE_CCONN 0x0008 /* shows client connections */ +#define UMODE_DEBUG 0x0010 /* show debug info */ +#define UMODE_FULL 0x0020 /* show full messages */ +#define UMODE_CALLERID 0x0040 /* client has callerid enabled */ +#define UMODE_INVISIBLE 0x0080 /* client has +i flag */ +#define UMODE_SKILL 0x0100 /* client see's server kills */ +#define UMODE_LOCOPS 0x0200 /* client is localop */ +#define UMODE_NCHANGE 0x0400 /* client can see nick change notices */ +#define UMODE_REJ 0x0800 /* client is registered */ +#define UMODE_SERVNOTICE 0x1000 /* client can see server notices */ +#define UMODE_UNAUTH 0x2000 /* client can see unauthd connections */ +#define UMODE_WALLOP 0x4000 /* client can get wallop messages */ +#define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */ +#define UMODE_SPY 0x10000 /* client can spy on user commands */ +#define UMODE_OPERWALL 0x20000 /* client gets operwalls */ +#define UMODE_SERVICES 0x40000 /* client is services */ + + +#define MODE_CHANOP 0x0001 +#define MODE_HALFOP 0x0002 +#define MODE_VOICE 0x0004 +#define MODE_PRIVATE 0x0008 +#define MODE_SECRET 0x0010 +#define MODE_MODERATED 0x0020 +#define MODE_TOPICLIMIT 0x0040 +#define MODE_INVITEONLY 0x0080 +#define MODE_NOPRIVMSGS 0x0100 +#define MODE_KEY 0x0200 +#define MODE_EXCEPT 0x0400 +#define MODE_BAN 0x0800 +#define MODE_LIMIT 0x1000 +#define MODE_HIDEOPS 0x2000 +#define MODE_INVEX 0x4000 + +#define is_hidden_chan(x) ((x) && (x->modes & MODE_SECRET)) +#define is_oper(x) ((x) && (x->Umode & UMODE_OPER)) + + +struct ircd_srv_ { + int uprot; + int modex; + int nicklg; + int gc; + char cloak[25]; + int burst; + int cmdcount; +} ircd_srv; + +typedef struct { + long mode; + char flag; + unsigned nickparam : 1; /* 1 = yes 0 = no */ + unsigned parameters : 1; + char sjoin; +} aCtab; + + + + + +typedef struct { + long umodes; + char mode; + int level; +} Oper_Modes; + + +aCtab cFlagTab[33]; +Oper_Modes usr_mds[20]; +Oper_Modes susr_mds[0]; + + + +/* function declarations */ +extern void init_ircd(); +extern void chanalert(char *,char *, ...); +extern int sserver_cmd(const char *, const int numeric, const char *); +extern int slogin_cmd(const char *, const int numeric, const char *, const char *); +extern int ssquit_cmd(const char *); +extern int sprotocol_cmd(const char *); +extern int squit_cmd(const char *, const char *); +extern int spart_cmd(const char *, const char *); +extern int sjoin_cmd(const char *, const char *); +extern int schmode_cmd(const char *, const char *, const char *, const char *); +extern int snewnick_cmd(const char *, const char *, const char *, const char *, long mode); +extern int sping_cmd(const char *from, const char *reply, const char *to); +extern int sumode_cmd(const char *who, const char *target, long mode); +extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); +extern int spong_cmd(const char *reply); +extern int snetinfo_cmd(); +extern int skill_cmd(const char *from, const char *target, const char *reason,...); +extern int ssvskill_cmd(const char *who, const char *reason, ...); +extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); +extern int snick_cmd(const char *oldnick, const char *newnick); +extern int sswhois_cmd(const char *target, const char *swhois); +extern int ssvsnick_cmd(const char *target, const char *newnick); +extern int ssvsjoin_cmd(const char *target, const char *chan); +extern int ssvspart_cmd(const char *target, const char *chan); +extern int ssvshost_cmd(const char *who, const char *vhost); +extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); +extern int swallops_cmd(const char *who, const char *msg,...); +extern int vctrl_cmd(); +extern int ssvinfo_cmd(); +extern int sburst_cmd(int b); +extern int seob_cmd(const char *server); +extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); +extern int srakill_cmd(const char *host, const char *ident); + + +void Usr_Version(char *, char **, int argc); +void Usr_ShowMOTD(char *, char **, int argc); +void Usr_ShowADMIN(char *, char **, int argc); +void Usr_Showcredits(char *, char **, int argc); +void Usr_AddServer(char *, char **, int argc); +void Usr_DelServer(char *, char **, int argc); +void Usr_DelUser(char *, char **, int argc); +void Usr_Mode(char *, char **, int argc); +void Usr_Smode(char *, char **, int argc); +void Usr_Kill(char *, char **, int argc); +void Usr_Pong(char *, char **, int argc); +void Usr_Away(char *, char **, int argc); +void Usr_Nick(char *, char **, int argc); +void Usr_Topic(char *, char **, int argc); +void Usr_Kick(char *, char **, int argc); +void Usr_Join(char *, char **, int argc); +void Usr_Part(char *, char **, int argc); +void Usr_Stats(char *, char **, int argc); +void Usr_Vhost(char *, char **, int argc); +void Srv_Topic(char *, char **, int argc); +void Srv_Ping(char *, char **, int argc); +void Srv_Netinfo(char *, char **, int argc); +void Srv_Pass(char *, char **, int argc); +void Srv_Server(char *, char **, int argc); +void Srv_Squit(char *, char **, int argc); +void Srv_Nick(char *, char **, int argc); +void Srv_Svsnick(char *, char **, int argc); +void Srv_Kill(char *, char **, int argc); +void Srv_Connect(char *, char **, int argc); +void Srv_Svinfo(char *, char **, int argc); +void Srv_Burst(char *origin, char **argv, int argc); +void Srv_Sjoin(char *origin, char **argv, int argc); +void Srv_Tburst(char *origin, char **argv, int argc); +int SignOn_NewBot(const char *, const char *, const char *, const char *, long); + +#endif diff --git a/QuantumIRCd.c b/QuantumIRCd.c new file mode 100644 index 00000000..11267ca7 --- /dev/null +++ b/QuantumIRCd.c @@ -0,0 +1,1283 @@ +/* NeoStats - IRC Statistical Services +** Copyright (c) 1999-2003 Adam Rutter, Justin Hammond +** http://www.neostats.net/ +** +** Portions Copyright (c) 2000-2001 ^Enigma^ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +** USA +** +** NeoStats CVS Identification +** $Id: QuantumIRCd.c,v 1.1 2003/06/30 15:18:23 fishwaldo Exp $ +*/ + +#include "stats.h" +#include "ircd.h" +#include "sock.h" +#include "Ultimate.h" +#include "dl.h" +#include "log.h" + + +IntCommands cmd_list[] = { + /* Command Function srvmsg */ + {MSG_STATS, Usr_Stats, 1, 0} + , + {TOK_STATS, Usr_Stats, 1, 0} + , + {MSG_SETHOST, Usr_Vhost, 1, 0} + , + {TOK_SETHOST, Usr_Vhost, 1, 0} + , + {MSG_VERSION, Usr_Version, 1, 0} + , + {TOK_VERSION, Usr_Version, 1, 0} + , + {MSG_MOTD, Usr_ShowMOTD, 1, 0} + , + {TOK_MOTD, Usr_ShowMOTD, 1, 0} + , + {MSG_CREDITS, Usr_Showcredits, 1, 0} + , + {TOK_CREDITS, Usr_Showcredits, 1, 0} + , + {MSG_SERVER, Usr_AddServer, 1, 0} + , + {TOK_SERVER, Usr_AddServer, 1, 0} + , + {MSG_SQUIT, Usr_DelServer, 1, 0} + , + {TOK_SQUIT, Usr_DelServer, 1, 0} + , + {MSG_QUIT, Usr_DelUser, 1, 0} + , + {TOK_QUIT, Usr_DelUser, 1, 0} + , + {MSG_MODE, Usr_Mode, 1, 0} + , + {TOK_MODE, Usr_Mode, 1, 0} + , + {MSG_SVSMODE, Usr_Smode, 1, 0} + , + {TOK_SVSMODE, Usr_Smode, 1, 0} + , + {MSG_KILL, Usr_Kill, 1, 0} + , + {TOK_KILL, Usr_Kill, 1, 0} + , + {MSG_PONG, Usr_Pong, 1, 0} + , + {TOK_PONG, Usr_Pong, 1, 0} + , + {MSG_AWAY, Usr_Away, 1, 0} + , + {TOK_AWAY, Usr_Away, 1, 0} + , + {MSG_NICK, Usr_Nick, 1, 0} + , + {TOK_NICK, Usr_Nick, 1, 0} + , + {MSG_TOPIC, Usr_Topic, 1, 0} + , + {TOK_TOPIC, Usr_Topic, 1, 0} + , + {MSG_KICK, Usr_Kick, 1, 0} + , + {TOK_KICK, Usr_Kick, 1, 0} + , + {MSG_JOIN, Usr_Join, 1, 0} + , + {TOK_JOIN, Usr_Join, 1, 0} + , + {MSG_PART, Usr_Part, 1, 0} + , + {TOK_PART, Usr_Part, 1, 0} + , + {MSG_PING, Srv_Ping, 0, 0} + , + {TOK_PING, Srv_Ping, 0, 0} + , +#ifndef ULTIMATE3 + {MSG_SNETINFO, Srv_Netinfo, 0, 0} + , + {TOK_SNETINFO, Srv_Netinfo, 0, 0} + , + +#endif +#ifdef ULTIMATE3 + {MSG_SVINFO, Srv_Svinfo, 0, 0} + , + {MSG_CAPAB, Srv_Connect, 0, 0} + , + {MSG_BURST, Srv_Burst, 0, 0} + , + {MSG_SJOIN, Srv_Sjoin, 1, 0} + , + {MSG_CLIENT, Srv_Client, 0, 0} + , + {MSG_SMODE, Srv_Smode, 1, 0} + , +#endif + {MSG_VCTRL, Srv_Vctrl, 0, 0} + , + {TOK_VCTRL, Srv_Vctrl, 0, 0} + , + {MSG_PASS, Srv_Pass, 0, 0} + , + {TOK_PASS, Srv_Pass, 0, 0} + , + {MSG_SERVER, Srv_Server, 0, 0} + , + {TOK_SERVER, Srv_Server, 0, 0} + , + {MSG_SQUIT, Srv_Squit, 0, 0} + , + {TOK_SQUIT, Srv_Squit, 0, 0} + , + {MSG_NICK, Srv_Nick, 0, 0} + , + {TOK_NICK, Srv_Nick, 0, 0} + , + {MSG_SVSNICK, Srv_Svsnick, 0, 0} + , + {TOK_SVSNICK, Srv_Svsnick, 0, 0} + , + {MSG_KILL, Srv_Kill, 0, 0} + , + {TOK_KILL, Srv_Kill, 0, 0} + , + {MSG_PROTOCTL, Srv_Connect, 0, 0} + , + {TOK_PROTOCTL, Srv_Connect, 0, 0} + , + {NULL, NULL, 0, 0} +}; + + + + +aCtab cFlagTab[] = { + {MODE_CHANOP, 'o', 1, 0, '@'} + , + {MODE_HALFOP, 'h', 1, 0, '%'} + , + {MODE_CHANADMIN, 'a', 1, 0, '!'} + , + {MODE_VOICE, 'v', 1, 0, '+'} + , + {MODE_BAN, 'b', 0, 1, 0} + , + {MODE_EXCEPT, 'e', 0, 1, 0} + , + {MODE_FLOODLIMIT, 'f', 0, 1, 0} + , /* Flood limiter */ + {MODE_INVITEONLY, 'i', 0, 0, 0} + , + {MODE_KEY, 'k', 0, 1, 0} + , + {MODE_LIMIT, 'l', 0, 1, 0} + , + {MODE_MODERATED, 'm', 0, 0, 0} + , + {MODE_NOPRIVMSGS, 'n', 0, 0, 0} + , + {MODE_PRIVATE, 'p', 0, 0, 0} + , + {MODE_RGSTR, 'r', 0, 0, 0} + , + {MODE_SECRET, 's', 0, 0, 0} + , + {MODE_TOPICLIMIT, 't', 0, 0, 0} + , + {MODE_NOCOLOR, 'x', 0, 0, 0} + , + {MODE_ADMONLY, 'A', 0, 0, 0} + , + {MODE_NOINVITE, 'I', 0, 0, 0} + , /* no invites */ + {MODE_NOKNOCK, 'K', 0, 0, 0} + , /* knock knock (no way!) */ + {MODE_LINK, 'L', 0, 1, 0} + , + {MODE_OPERONLY, 'O', 0, 0, 0} + , + {MODE_RGSTRONLY, 'R', 0, 0, 0} + , + {MODE_STRIP, 'S', 0, 0, 0} + , /* works? */ + {0x0, 0x0, 0x0, 0x0, 0x0} +}; + + +#ifdef ULTIMATE3 +Oper_Modes usr_mds[] = { + {UMODE_OPER, 'o', 50} + , + {UMODE_LOCOP, 'O', 40} + , + {UMODE_INVISIBLE, 'i', 0} + , + {UMODE_WALLOP, 'w', 0} + , + {UMODE_SERVNOTICE, 's', 0} + , + {UMODE_CLIENT, 'c', 0} + , + {UMODE_REGNICK, 'r', 10} + , + {UMODE_KILLS, 'k', 0} + , + {UMODE_FAILOP, 'g', 0} + , + {UMODE_HELPOP, 'h', 30} + , + {UMODE_FLOOD, 'f', 0} + , + {UMODE_SPY, 'y', 0} + , + {UMODE_DCC, 'D', 0} + , + {UMODE_GLOBOPS, 'g', 0} + , + {UMODE_CHATOP, 'c', 0} + , + {UMODE_SERVICESOPER, 'a', 100} + , + {UMODE_REJ, 'j', 0} + , + {UMODE_ROUTE, 'n', 0} + , + {UMODE_SPAM, 'm', 0} + , + {UMODE_HIDE, 'x', 0} + , + {UMODE_IRCADMIN, 'Z', 200} + , + {UMODE_SERVICESADMIN, 'P', 185} + , + {UMODE_SERVICES, 'S', 200} + , + {UMODE_PROT, 'p', 0} + , + {UMODE_GLOBCON, 'F', 0} + , + {UMODE_DEBUG, 'd', 0} + , + {UMODE_DCCWARN, 'd', 0} + , + {UMODE_WHOIS, 'W', 0} + , + {0, 0, 0} +}; + +Oper_Modes susr_mds[] = { + {SMODE_SSL, 's', 0} + , + {SMODE_COADMIN, 'a', 75} + , + {SMODE_SERVADMIN, 'A', 100} + , + {SMODE_COTECH, 't', 125} + , + {SMODE_TECHADMIN, 'T', 150} + , + {SMODE_CONET, 'n', 175} + , + {SMODE_NETADMIN, 'N', 190} + , + {SMODE_GUEST, 'G', 100} + , + {0, 0, 0} +}; + +#elif ULTIMATE +Oper_Modes usr_mds[] = { + {UMODE_OPER, 'o', 50} + , + {UMODE_LOCOP, 'O', 40} + , + {UMODE_INVISIBLE, 'i', 0} + , + {UMODE_WALLOP, 'w', 0} + , + {UMODE_FAILOP, 'g', 0} + , + {UMODE_HELPOP, 'h', 30} + , + {UMODE_SERVNOTICE, 's', 0} + , + {UMODE_KILLS, 'k', 0} + , + {UMODE_SERVICES, 'S', 200} + , + {UMODE_SERVICESADMIN, 'P', 200} + , + {UMODE_RBOT, 'B', 0} + , + {UMODE_SBOT, 'b', 0} + , + {UMODE_ADMIN, 'z', 70} + , + {UMODE_NETADMIN, 'N', 185} + , + {UMODE_TECHADMIN, 'T', 190} + , + {UMODE_CLIENT, 'c', 0} + , + {UMODE_FLOOD, 'f', 0} + , + {UMODE_REGNICK, 'r', 0} + , + {UMODE_HIDE, 'x', 0} + , + {UMODE_WATCHER, 'W', 0} + , + {UMODE_SERVICESOPER, 'a', 100} + , + {UMODE_SUPER, 'p', 40} + , + {UMODE_IRCADMIN, 'Z', 100} + , + {0, 0, 0} +}; +#endif + +void init_ircd() +{ + /* count the number of commands */ + ircd_srv.cmdcount = ((sizeof(cmd_list) / sizeof(cmd_list[0])) - 1); +}; + +int sserver_cmd(const char *name, const int numeric, const char *infoline) +{ + sts(":%s %s %s %d :%s", me.name, + (me.token ? TOK_SERVER : MSG_SERVER), name, numeric, infoline); + return 1; +} + +int slogin_cmd(const char *name, const int numeric, const char *infoline, + const char *pass) +{ +#ifndef ULTIMATE3 + sts("%s %s", (me.token ? TOK_PASS : MSG_PASS), pass); +#else + sts("%s %s :TS", (me.token ? TOK_PASS : MSG_PASS), pass); + sts("CAPAB TS5 BURST SSJ5 NICKIP CLIENT"); +#endif + sts("%s %s %d :%s", (me.token ? TOK_SERVER : MSG_SERVER), name, + numeric, infoline); + return 1; +} + +int ssquit_cmd(const char *server) +{ + sts("%s %s", (me.token ? TOK_SQUIT : MSG_SQUIT), server); + return 1; +} + +int sprotocol_cmd(const char *option) +{ +#ifndef ULTIMATE3 + sts("%s %s", (me.token ? TOK_PROTOCTL : MSG_PROTOCTL), option); +#endif + return 1; +} + +int squit_cmd(const char *who, const char *quitmsg) +{ + sts(":%s %s :%s", who, (me.token ? TOK_QUIT : MSG_QUIT), quitmsg); + DelUser(who); + return 1; +} + +int spart_cmd(const char *who, const char *chan) +{ + sts(":%s %s %s", who, (me.token ? TOK_PART : MSG_PART), chan); + part_chan(finduser(who), (char *) chan); + return 1; +} + +#ifdef ULTIMATE3 +int sjoin_cmd(const char *who, const char *chan, unsigned long chflag) +{ + char flag; + char mode[2]; + char **av; + int ac; + char tmp[512]; + switch (chflag) { + case MODE_CHANOP: + flag = '@'; + strcpy(mode, "0"); + break; + case MODE_HALFOP: + flag = '%'; + strcpy(mode, "h"); + break; + case MODE_VOICE: + flag = '+'; + strcpy(mode, "v"); + break; + case MODE_CHANADMIN: + flag = '!'; + strcpy(mode, "a"); + break; + default: + flag = ' '; + strcpy(mode, ""); + } + sts(":%s %s 0 %s + :%c%s", me.name, MSG_SJOIN, chan, flag, who); + join_chan(finduser(who), (char *) chan); + snprintf(tmp, 512, "%s +%s %s", chan, mode, who); + ac = split_buf(tmp, &av, 0); + ChanMode(me.name, av, ac); + free(av); + +#else +int sjoin_cmd(const char *who, const char *chan) +{ + sts(":%s %s %s", who, (me.token ? TOK_JOIN : MSG_JOIN), chan); + join_chan(finduser(who), (char *) chan); +#endif + return 1; +} + +int schmode_cmd(const char *who, const char *chan, const char *mode, + const char *args) +{ + char **av; + int ac; + char tmp[512]; + + sts(":%s %s %s %s %s %lu", me.name, + (me.token ? TOK_MODE : MSG_MODE), chan, mode, args, + time(NULL)); + snprintf(tmp, 512, "%s %s %s", chan, mode, args); + ac = split_buf(tmp, &av, 0); + ChanMode("", av, ac); + free(av); + return 1; +} + +#ifndef ULTIMATE3 +int snewnick_cmd(const char *nick, const char *ident, const char *host, + const char *realname) +{ + sts("%s %s 1 %lu %s %s %s 0 :%s", (me.token ? TOK_NICK : MSG_NICK), + nick, time(NULL), ident, host, me.name, realname); + AddUser(nick, ident, host, me.name, 0, time(NULL)); +#else +int snewnick_cmd(const char *nick, const char *ident, const char *host, + const char *realname, long mode) +{ + int i, j; + char newmode[20]; + newmode[0] = '+'; + j = 1; + for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) { + if (mode & usr_mds[i].umodes) { + newmode[j] = usr_mds[i].mode; + j++; + } + + } + newmode[j] = '\0'; + sts("%s %s 1 %lu %s %s %s %s 0 %lu :%s", + (me.token ? TOK_NICK : MSG_NICK), nick, time(NULL), newmode, + ident, host, me.name, time(NULL), realname); + AddUser(nick, ident, host, me.name, 0, time(NULL)); + UserMode(nick, newmode, 0); +#endif + return 1; +} + +int sping_cmd(const char *from, const char *reply, const char *to) +{ + sts(":%s %s %s :%s", from, (me.token ? TOK_PING : MSG_PING), reply, + to); + return 1; +} + +int sumode_cmd(const char *who, const char *target, long mode) +{ + int i, j; + char newmode[20]; + newmode[0] = '+'; + j = 1; + for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) { + if (mode & usr_mds[i].umodes) { + newmode[j] = usr_mds[i].mode; + j++; + } + + } + newmode[j] = '\0'; + sts(":%s %s %s :%s", who, (me.token ? TOK_MODE : MSG_MODE), target, + newmode); + UserMode(target, newmode, 0); + return 1; +} + +int snumeric_cmd(const int numeric, const char *target, const char *data, + ...) +{ + va_list ap; + char buf[512]; + va_start(ap, data); + vsnprintf(buf, 512, data, ap); + sts(":%s %d %s :%s", me.name, numeric, target, buf); + va_end(ap); + return 1; +} + +int spong_cmd(const char *reply) +{ + sts("%s %s", (me.token ? TOK_PONG : MSG_PONG), reply); + return 1; +} + +int snetinfo_cmd() +{ + sts(":%s %s 0 %d %d %s 0 0 0 :%s", me.name, MSG_SNETINFO, + time(NULL), ircd_srv.uprot, ircd_srv.cloak, me.netname); + return 1; +} + +int vctrl_cmd() +{ + sts("%s %d %d %d %d 0 0 0 0 0 0 0 0 0 0 :%s", MSG_VCTRL, + ircd_srv.uprot, ircd_srv.nicklg, ircd_srv.modex, ircd_srv.gc, + me.netname); + return 1; +} +int skill_cmd(const char *from, const char *target, const char *reason, + ...) +{ + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + sts(":%s %s %s :%s", from, (me.token ? TOK_KILL : MSG_KILL), + target, buf); + va_end(ap); + DelUser(target); + return 1; +} + +int ssvskill_cmd(const char *who, const char *reason, ...) +{ + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + sts(":%s %s %s :%s", me.name, MSG_SVSKILL, + who, buf); + va_end(ap); + return 1; +} + +int ssmo_cmd(const char *from, const char *umodetarget, const char *msg) +{ + chanalert(s_Services, + "Warning, Module %s tried to SMO, which is not supported in Ultimate", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning, Module %s tried to SMO, which is not supported in Ultimate", + segvinmodule); + return 1; +} + +int snick_cmd(const char *oldnick, const char *newnick) +{ + Change_User(finduser(oldnick), newnick); + sts(":%s %s %s %d", oldnick, (me.token ? TOK_NICK : MSG_NICK), + newnick, time(NULL)); + return 1; +} +int sswhois_cmd(const char *target, const char *swhois) +{ + chanalert(s_Services, + "Warning Module %s tried to SWHOIS, which is not supported in Ultimate", + segvinmodule); + nlog(LOG_NOTICE, LOG_CORE, + "Warning. Module %s tried to SWHOIS, which is not supported in Ultimate", + segvinmodule); + return 1; +} +int ssvsnick_cmd(const char *target, const char *newnick) +{ + sts("%s %s %s :%d", (me.token ? TOK_SVSNICK : MSG_SVSNICK), target, + newnick, time(NULL)); + return 1; +} + +int ssvsjoin_cmd(const char *target, const char *chan) +{ + sts("%s %s %s", (me.token ? TOK_SVSJOIN : MSG_SVSJOIN), target, + chan); + return 1; +} + +int ssvspart_cmd(const char *target, const char *chan) +{ + sts("%s %s %s", (me.token ? TOK_SVSPART : MSG_SVSPART), target, + chan); + return 1; +} + +int skick_cmd(const char *who, const char *target, const char *chan, + const char *reason) +{ + sts(":%s %s %s %s :%s", who, (me.token ? TOK_KICK : MSG_KICK), + chan, target, (reason ? reason : "No Reason Given")); + part_chan(finduser(target), (char *) chan); + return 1; +} +int swallops_cmd(const char *who, const char *msg, ...) +{ + va_list ap; + char buf[512]; + va_start(ap, msg); + vsnprintf(buf, 512, msg, ap); + sts(":%s %s :%s", who, (me.token ? TOK_WALLOPS : MSG_WALLOPS), + buf); + va_end(ap); + return 1; +} + +int ssvshost_cmd(const char *who, const char *vhost) +{ + User *u; + u = finduser(who); + if (!u) { + nlog(LOG_WARNING, LOG_CORE, + "Can't Find user %s for ssvshost_cmd", who); + return 0; + } else { + strncpy(u->vhost, vhost, MAXHOST); +#ifdef ULTIMATE3 + sts(":%s %s %s %s", me.name, + (me.token ? TOK_SETHOST : MSG_SETHOST), who, vhost); +#elif ULTIMATE + sts(":%s CHGHOST %s %s", me.name, who, vhost); +#endif + return 1; + } +} +int sakill_cmd(const char *host, const char *ident, const char *setby, + const int length, const char *reason, ...) +{ + va_list ap; + char buf[512]; + va_start(ap, reason); + vsnprintf(buf, 512, reason, ap); + sts(":%s %s %s %s %d %s %d :%s", me.name, + (me.token ? TOK_AKILL : MSG_AKILL), host, ident, length, setby, + time(NULL), buf); + va_end(ap); + return 1; +} + +int srakill_cmd(const char *host, const char *ident) +{ + sts(":%s %s %s %s", me.name, (me.token ? TOK_RAKILL : MSG_RAKILL), + host, ident); + return 1; +} + + +int ssvinfo_cmd() +{ + sts("SVINFO 5 3 0 :%d", time(NULL)); + return 1; +} +int sburst_cmd(int b) +{ + if (b == 0) { + sts("BURST 0"); + } else { + sts("BURST"); + } + return 1; +} + + + +void chanalert(char *who, char *buf, ...) +{ + va_list ap; + char tmp[512]; + char out[512]; + va_start(ap, buf); + vsnprintf(tmp, 512, buf, ap); + + if (me.onchan) { + snprintf(out, 512, ":%s PRIVMSG %s :%s", who, me.chan, + tmp); + nlog(LOG_DEBUG3, LOG_CORE, "SENT: %s", out); + sts("%s", out); + } + va_end(ap); +} +void prefmsg(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + if (me.want_privmsg) { + snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2); + } else { + snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2); + } + sts("%s", buf); + va_end(ap); +} +void privmsg(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2); + sts("%s", buf); + va_end(ap); +} + +void notice(char *to, const char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + if (findbot(to)) { + chanalert(s_Services, + "Message From our Bot(%s) to Our Bot(%s), Dropping Message", + from, to); + return; + } + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2); + sts("%s", buf); + va_end(ap); +} + + +void privmsg_list(char *to, char *from, const char **text) +{ + while (*text) { + if (**text) + prefmsg(to, from, "%s", *text); + else + prefmsg(to, from, " "); + text++; + } +} + + +void globops(char *from, char *fmt, ...) +{ + va_list ap; + char buf[512], buf2[512]; + + va_start(ap, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, ap); + +/* Shmad - have to get rid of nasty term echos :-) */ + +/* Fish - now that was crackhead coding! */ + if (me.onchan) { + snprintf(buf, 512, ":%s GLOBOPS :%s", from, buf2); + sts("%s", buf); + } else { + nlog(LOG_NORMAL, LOG_CORE, "%s", buf2); + } + va_end(ap); +} + + +void Srv_Sjoin(char *origin, char **argv, int argc) +{ + char nick[MAXNICK]; + long mode = 0; + long mode1 = 0; + char *modes; + int ok = 1, i, j = 3; + ModesParm *m; + Chans *c; + lnode_t *mn = NULL; + list_t *tl; + if (argc <= 2) { + modes = argv[1]; + } else { + modes = argv[2]; + } + + if (*modes == '#') { + join_chan(finduser(origin), modes); + return; + } + tl = list_create(10); + + if (*modes != '+') { + goto nomodes; + } + while (*modes) { + for (i = 0; + i < ((sizeof(cFlagTab) / sizeof(cFlagTab[0])) - 1); + i++) { + if (*modes == cFlagTab[i].flag) { + if (cFlagTab[i].parameters) { + m = smalloc(sizeof(ModesParm)); + m->mode = cFlagTab[i].mode; + strncpy(m->param, argv[j], + PARAMSIZE); + mn = lnode_create(m); + if (!list_isfull(tl)) { + list_append(tl, mn); + } else { + nlog(LOG_CRITICAL, + LOG_CORE, + "Eeeek, tl list is full in Svr_Sjoin(ircd.c)"); + do_exit(0); + } + j++; + } else { + mode1 |= cFlagTab[i].mode; + } + } + } + modes++; + } + nomodes: + while (argc > j) { + modes = argv[j]; + mode = 0; + while (ok == 1) { + for (i = 0; + i < + ((sizeof(cFlagTab) / sizeof(cFlagTab[0])) - + 1); i++) { + if (cFlagTab[i].sjoin != 0) { + if (*modes == cFlagTab[i].sjoin) { + mode |= cFlagTab[i].mode; + modes++; + i = -1; + } + } else { + /* sjoin's should be at the top of the list */ + ok = 0; + strncpy(nick, modes, MAXNICK); + break; + } + } + } + join_chan(finduser(nick), argv[1]); + ChangeChanUserMode(findchan(argv[1]), finduser(nick), 1, + mode); + j++; + ok = 1; + } + c = findchan(argv[1]); + c->modes |= mode1; + if (!list_isempty(tl)) { + if (!list_isfull(c->modeparms)) { + list_transfer(c->modeparms, tl, list_first(tl)); + } else { + /* eeeeeeek, list is full! */ + nlog(LOG_CRITICAL, LOG_CORE, + "Eeeek, c->modeparms list is full in Svr_Sjoin(ircd.c)"); + do_exit(0); + } + } + list_destroy(tl); +} + +void Srv_Burst(char *origin, char **argv, int argc) +{ + if (argc > 0) { + if (ircd_srv.burst == 1) { + sburst_cmd(0); + ircd_srv.burst = 0; + me.synced = 1; + init_ServBot(); + } + } else { + ircd_srv.burst = 1; + } +} + +void Srv_Connect(char *origin, char **argv, int argc) +{ + int i; + + for (i = 0; i < argc; i++) { + if (!strcasecmp("TOKEN", argv[i])) { + me.token = 1; + } +#ifdef ULTIMATE3 + if (!strcasecmp("CLIENT", argv[i])) { + me.client = 1; + } +#endif + } +} + + +void Usr_Stats(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(origin); + if (!u) { + nlog(LOG_WARNING, LOG_CORE, + "Recieved a Message from a Unknown User! (%s)", + origin); + return; + } + ShowStats(argv[0], u); +} + +void Usr_Version(char *origin, char **argv, int argc) +{ + snumeric_cmd(351, origin, "%d.%d.%d%s :%s -> %s %s", MAJOR, MINOR, + REV, version, me.name, version_date, version_time); +} +void Usr_ShowMOTD(char *origin, char **argv, int argc) +{ + ShowMOTD(origin); +} +void Usr_ShowADMIN(char *origin, char **argv, int argc) +{ + ShowADMIN(origin); +} +void Usr_Showcredits(char *origin, char **argv, int argc) +{ + Showcredits(origin); +} +void Usr_AddServer(char *origin, char **argv, int argc) +{ + AddServer(argv[0], origin, atoi(argv[1])); +} +void Usr_DelServer(char *origin, char **argv, int argc) +{ + DelServer(argv[0]); +} +void Usr_DelUser(char *origin, char **argv, int argc) +{ + DelUser(origin); +} +void Usr_Smode(char *origin, char **argv, int argc) +{ + if (!strchr(argv[0], '#')) { + /* its user svsmode change */ + UserMode(argv[0], argv[2], 0); + } else { + /* its a channel svsmode change */ + ChanMode(origin, argv, argc); + } +} +void Usr_Mode(char *origin, char **argv, int argc) +{ + if (!strchr(argv[0], '#')) { + nlog(LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[0]); + UserMode(argv[0], argv[1], 0); + } else { + ChanMode(origin, argv, argc); + } +} +void Usr_Kill(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(argv[0]); + if (u) { + KillUser(argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, "Can't find user %s for Kill", + argv[0]); + } +} +void Usr_Vhost(char *origin, char **argv, int argc) +{ + User *u; +#ifndef ULTIMATE3 + u = finduser(origin); +#else + u = finduser(argv[0]); +#endif + if (u) { +#ifndef ULTIMATE3 + strncpy(u->vhost, argv[0], MAXHOST); +#else + strncpy(u->vhost, argv[1], MAXHOST); +#endif + } +} +void Usr_Pong(char *origin, char **argv, int argc) +{ + Server *s; + s = findserver(argv[0]); + if (s) { + dopong(s); + } else { + nlog(LOG_NOTICE, LOG_CORE, + "Received PONG from unknown server: %s", argv[0]); + } +} +void Usr_Away(char *origin, char **argv, int argc) +{ + char *Buf; + User *u = finduser(origin); + if (u) { + if (argc > 0) { + Buf = joinbuf(argv, argc, 0); + } else { + Buf = NULL; + } + Do_Away(u, Buf); + if (argc > 0) { + free(Buf); + } + } else { + nlog(LOG_NOTICE, LOG_CORE, + "Warning, Unable to find User %s for Away", origin); + } +} +void Usr_Nick(char *origin, char **argv, int argc) +{ + User *u = finduser(origin); + if (u) { + Change_User(u, argv[0]); + } +} +void Usr_Topic(char *origin, char **argv, int argc) +{ + char *buf; + Chans *c; + c = findchan(argv[0]); + if (c) { + buf = joinbuf(argv, argc, 3); + Change_Topic(argv[1], c, atoi(argv[2]), buf); + free(buf); + } else { + nlog(LOG_WARNING, LOG_CORE, "Ehhh, Can't find Channel %s", + argv[0]); + } + +} + +void Usr_Kick(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(argv[1]); + if (u) { + kick_chan(u, argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Warning, Can't find user %s for kick %s", argv[1], + argv[0]); + } +} +void Usr_Join(char *origin, char **argv, int argc) +{ + char *s, *t; + t = argv[0]; + while (*(s = t)) { + t = s + strcspn(s, ","); + if (*t) + *t++ = 0; + join_chan(finduser(origin), s); + } +} +void Usr_Part(char *origin, char **argv, int argc) +{ + part_chan(finduser(origin), argv[0]); +} +void Srv_Ping(char *origin, char **argv, int argc) +{ + spong_cmd(argv[0]); +#ifdef ULTIMATE3 + if (ircd_srv.burst) { + sping_cmd(me.name, argv[0], argv[0]); + } +#endif +} + +void Srv_Vctrl(char *origin, char **argv, int argc) +{ + ircd_srv.uprot = atoi(argv[0]); + ircd_srv.nicklg = atoi(argv[1]); + ircd_srv.modex = atoi(argv[2]); + ircd_srv.gc = atoi(argv[3]); + strncpy(me.netname, argv[14], MAXPASS); + vctrl_cmd(); +} + +void Srv_Svinfo(char *origin, char **argv, int argc) +{ + ssvinfo_cmd(); +} + +#ifndef ULTIMATE3 +void Srv_Netinfo(char *origin, char **argv, int argc) +{ + me.onchan = 1; + ircd_srv.uprot = atoi(argv[2]); + strncpy(ircd_srv.cloak, argv[3], 10); + strncpy(me.netname, argv[7], MAXPASS); + + snetinfo_cmd(); + init_ServBot(); + globops(me.name, "Link with Network \2Complete!\2"); +#ifdef DEBUG + ns_debug_to_coders(me.chan); +#endif + if (ircd_srv.uprot == 2109) { + me.usesmo = 1; + } + Module_Event("NETINFO", NULL, 0); + me.synced = 1; +} +#endif + +void Srv_Pass(char *origin, char **argv, int argc) +{ +} +void Srv_Server(char *origin, char **argv, int argc) +{ + Server *s; + if (*origin == 0) { + AddServer(argv[0], me.name, atoi(argv[1])); + } else { + AddServer(argv[0], origin, atoi(argv[1])); + } + s = findserver(argv[0]); + me.s = s; +} +void Srv_Squit(char *origin, char **argv, int argc) +{ + Server *s; + s = findserver(argv[0]); + if (s) { + DelServer(argv[0]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Waring, Squit from Unknown Server %s", argv[0]); + } + +} + +/* BE REALLY CAREFULL ABOUT THE ORDER OF THESE ifdef's */ + +void Srv_Nick(char *origin, char **argv, int argc) +{ + char *realname; +#if ULTIMATE3 + AddUser(argv[0], argv[4], argv[5], argv[6], + strtoul(argv[8], NULL, 10), strtoul(argv[2], NULL, 10)); + realname = joinbuf(argv, argc, 9); + AddRealName(argv[0], realname); + free(realname); + nlog(LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[3]); + UserMode(argv[0], argv[3], 0); +#elif ULTIMATE + AddUser(argv[0], argv[3], argv[4], argv[5], 0, + strtoul(argv[2], NULL, 10)); + realname = joinbuf(argv, argc, 7); + AddRealName(argv[0], realname); + free(realname); +#endif +} + +/* Ultimate3 Client Support */ +#ifdef ULTIMATE3 +void Srv_Client(char *origin, char **argv, int argc) +{ + char *realname; + + AddUser(argv[0], argv[5], argv[6], argv[8], + strtoul(argv[10], NULL, 10), strtoul(argv[2], NULL, 10)); + realname = joinbuf(argv, argc, 11); + AddRealName(argv[0], realname); + free(realname); + nlog(LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[3]); + UserMode(argv[0], argv[3], 0); + nlog(LOG_DEBUG1, LOG_CORE, "Smode: SMode: %s", argv[4]); + UserMode(argv[0], argv[4], 1); + +} + +void Srv_Smode(char *origin, char **argv, int argc) +{ + UserMode(argv[0], argv[1], 1); +}; + +/* ultimate 3 */ +#endif + +void Srv_Svsnick(char *origin, char **argv, int argc) +{ + User *u; + u = finduser(argv[0]); + if (u) { + Change_User(u, argv[1]); + } else { + nlog(LOG_WARNING, LOG_CORE, + "Warning, Can't find user %s for SVSNICK", argv[0]); + } + +} +void Srv_Kill(char *origin, char **argv, int argc) +{ +} + + + +int SignOn_NewBot(const char *nick, const char *user, + const char *host, const char *rname, long Umode) +{ + +#ifdef ULTIMATE3 + snewnick_cmd(nick, user, host, rname, Umode); +#else + snewnick_cmd(nick, user, host, rname); + sumode_cmd(nick, nick, Umode); +#endif + if ((me.allbots > 0) || (Umode & UMODE_SERVICES)) { +#ifdef ULTIMATE3 + sjoin_cmd(nick, me.chan, MODE_CHANADMIN); +#else /* ulitmate3 */ + sjoin_cmd(nick, me.chan); +#endif + schmode_cmd(nick, me.chan, "+a", nick); + /* all bots join */ + } + return 1; +} diff --git a/QuantumIRCd.h b/QuantumIRCd.h new file mode 100644 index 00000000..13dd947a --- /dev/null +++ b/QuantumIRCd.h @@ -0,0 +1,526 @@ +/* NeoStats - IRC Statistical Services +** Copyright (c) 1999-2003 Adam Rutter, Justin Hammond +** http://www.neostats.net/ +** +** Portions Copyright (c) 2000-2001 ^Enigma^ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +** USA +** +** NeoStats CVS Identification +** $Id: QuantumIRCd.h,v 1.1 2003/06/30 15:18:23 fishwaldo Exp $ +*/ +#ifndef ULTIMATE_H +#define ULTIMATE_H + +/* we support tokens */ +#define HAVE_TOKEN_SUP + + +#define MSG_PRIVATE "PRIVMSG" /* PRIV */ +#define TOK_PRIVATE "!" /* 33 */ +#define MSG_WHO "WHO" /* WHO -> WHOC */ +#define TOK_WHO "\"" /* 34 */ +#define MSG_WHOIS "WHOIS" /* WHOI */ +#define TOK_WHOIS "#" /* 35 */ +#define MSG_WHOWAS "WHOWAS" /* WHOW */ +#define TOK_WHOWAS "$" /* 36 */ +#define MSG_USER "USER" /* USER */ +#define TOK_USER "%" /* 37 */ +#define MSG_NICK "NICK" /* NICK */ +#define TOK_NICK "&" /* 38 */ +#define MSG_SERVER "SERVER" /* SERV */ +#define TOK_SERVER "'" /* 39 */ +#define MSG_LIST "LIST" /* LIST */ +#define TOK_LIST "(" /* 40 */ +#define MSG_TOPIC "TOPIC" /* TOPI */ +#define TOK_TOPIC ")" /* 41 */ +#define MSG_INVITE "INVITE" /* INVI */ +#define TOK_INVITE "*" /* 42 */ +#define MSG_VERSION "VERSION" /* VERS */ +#define TOK_VERSION "+" /* 43 */ +#define MSG_QUIT "QUIT" /* QUIT */ +#define TOK_QUIT "," /* 44 */ +#define MSG_SQUIT "SQUIT" /* SQUI */ +#define TOK_SQUIT "-" /* 45 */ +#define MSG_KILL "KILL" /* KILL */ +#define TOK_KILL "." /* 46 */ +#define MSG_INFO "INFO" /* INFO */ +#define TOK_INFO "/" /* 47 */ +#define MSG_LINKS "LINKS" /* LINK */ +#define TOK_LINKS "0" /* 48 */ +#define MSG_WATCH "WATCH" /* WATCH */ +#define TOK_WATCH "1" /* 49 */ +#define MSG_STATS "STATS" /* STAT */ +#define TOK_STATS "2" /* 50 */ +#define MSG_HELP "HELP" /* HELP */ +#define MSG_HELPOP "HELPOP" /* HELP */ +#define TOK_HELP "4" /* 52 */ +#define MSG_ERROR "ERROR" /* ERRO */ +#define TOK_ERROR "5" /* 53 */ +#define MSG_AWAY "AWAY" /* AWAY */ +#define TOK_AWAY "6" /* 54 */ +#define MSG_CONNECT "CONNECT" /* CONN */ +#define TOK_CONNECT "7" /* 55 */ +#define MSG_PING "PING" /* PING */ +#define TOK_PING "8" /* 56 */ +#define MSG_PONG "PONG" /* PONG */ +#define TOK_PONG "9" /* 57 */ +#define MSG_OPER "OPER" /* OPER */ +#define TOK_OPER ";" /* 59 */ +#define MSG_PASS "PASS" /* PASS */ +#define TOK_PASS "<" /* 60 */ +#define MSG_WALLOPS "WALLOPS" /* WALL */ +#define TOK_WALLOPS "=" /* 61 */ +#define MSG_TIME "TIME" /* TIME */ +#define TOK_TIME ">" /* 62 */ +#define MSG_NAMES "NAMES" /* NAME */ +#define TOK_NAMES "?" /* 63 */ +#define MSG_ADMIN "ADMIN" /* ADMI */ +#define TOK_ADMIN "@" /* 64 */ +#define MSG_NOTICE "NOTICE" /* NOTI */ +#define TOK_NOTICE "B" /* 66 */ +#define MSG_JOIN "JOIN" /* JOIN */ +#define TOK_JOIN "C" /* 67 */ +#define MSG_PART "PART" /* PART */ +#define TOK_PART "D" /* 68 */ +#define MSG_LUSERS "LUSERS" /* LUSE */ +#define TOK_LUSERS "E" /* 69 */ +#define MSG_MOTD "MOTD" /* MOTD */ +#define TOK_MOTD "F" /* 70 */ +#define MSG_MODE "MODE" /* MODE */ +#define TOK_MODE "G" /* 71 */ +#define MSG_KICK "KICK" /* KICK */ +#define TOK_KICK "H" /* 72 */ +#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ +#define TOK_SERVICE "I" /* 73 */ +#define MSG_USERHOST "USERHOST" /* USER -> USRH */ +#define TOK_USERHOST "J" /* 74 */ +#define MSG_ISON "ISON" /* ISON */ +#define TOK_ISON "K" /* 75 */ +#define MSG_SQUERY "SQUERY" /* SQUE */ +#define TOK_SQUERY "L" /* 76 */ +#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ +#define TOK_SERVLIST "M" /* 77 */ +#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ +#define TOK_SERVSET "N" /* 78 */ +#define MSG_REHASH "REHASH" /* REHA */ +#define TOK_REHASH "O" /* 79 */ +#define MSG_RESTART "RESTART" /* REST */ +#define TOK_RESTART "P" /* 80 */ +#define MSG_CLOSE "CLOSE" /* CLOS */ +#define TOK_CLOSE "Q" /* 81 */ +#define MSG_DIE "DIE" /* DIE */ +#define TOK_DIE "R" /* 82 */ +#define MSG_HASH "HASH" /* HASH */ +#define TOK_HASH "S" /* 83 */ +#define MSG_DNS "DNS" /* DNS -> DNSS */ +#define TOK_DNS "T" /* 84 */ +#define MSG_SILENCE "SILENCE" /* SILE */ +#define TOK_SILENCE "U" /* 85 */ +#define MSG_AKILL "AKILL" /* AKILL */ +#define TOK_AKILL "V" /* 86 */ +#define MSG_KLINE "KLINE" /* KLINE */ +#define TOK_KLINE "W" /* 87 */ +#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ +#define TOK_UNKLINE "X" /* 88 */ +#define MSG_RAKILL "RAKILL" /* RAKILL */ +#define TOK_RAKILL "Y" /* 89 */ +#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ +#define TOK_GNOTICE "Z" /* 90 */ +#define MSG_GOPER "GOPER" /* GOPER */ +#define TOK_GOPER "[" /* 91 */ +#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ +#define TOK_GLOBOPS "]" /* 93 */ +#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ +#define TOK_LOCOPS "^" /* 94 */ +#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ +#define TOK_PROTOCTL "_" /* 95 */ +#define MSG_TRACE "TRACE" /* TRAC */ +#define TOK_TRACE "b" /* 98 */ +#define MSG_SQLINE "SQLINE" /* SQLINE */ +#define TOK_SQLINE "c" /* 99 */ +#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ +#define TOK_UNSQLINE "d" /* 100 */ +#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ +#define TOK_SVSNICK "e" /* 101 */ +#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */ +#define TOK_SVSNOOP "f" /* 101 */ +#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */ +#define TOK_IDENTIFY "g" /* 103 */ +#define MSG_SVSKILL "SVSKILL" /* SVSKILL */ +#define TOK_SVSKILL "h" /* 104 */ +#define MSG_NICKSERV "NICKSERV" /* NICKSERV */ +#define MSG_NS "NS" +#define TOK_NICKSERV "i" /* 105 */ +#define MSG_CHANSERV "CHANSERV" /* CHANSERV */ +#define MSG_CS "CS" +#define TOK_CHANSERV "j" /* 106 */ +#define MSG_OPERSERV "OPERSERV" /* OPERSERV */ +#define MSG_OS "OS" +#define TOK_OPERSERV "k" /* 107 */ +#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */ +#define MSG_MS "MS" +#define TOK_MEMOSERV "l" /* 108 */ +#define MSG_SERVICES "SERVICES" /* SERVICES */ +#define TOK_SERVICES "m" /* 109 */ +#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ +#define TOK_SVSMODE "n" /* 110 */ +#define MSG_SAMODE "SAMODE" /* SAMODE */ +#define TOK_SAMODE "o" /* 111 */ +#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ +#define TOK_CHATOPS "p" /* 112 */ +#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ +#define TOK_HELPSERV "r" /* 114 */ +#define MSG_ZLINE "ZLINE" /* ZLINE */ +#define TOK_ZLINE "s" /* 115 */ +#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ +#define TOK_UNZLINE "t" /* 116 */ +#define MSG_NETINFO "NETINFO" /* NETINFO */ +#define TOK_NETINFO "u" /* 117 */ +#define MSG_RULES "RULES" /* RULES */ +#define TOK_RULES "v" /* 118 */ +#define MSG_MAP "MAP" /* MAP */ +#define TOK_MAP "w" /* 119 */ +#define MSG_NETG "NETG" /* NETG */ +#define TOK_NETG "x" /* 120 */ +#define MSG_ADCHAT "ADCHAT" /* Adchat */ +#define TOK_ADCHAT "y" /* 121 */ +#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ +#define TOK_MAKEPASS "z" /* 122 */ +#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ +#define TOK_ADDHUB "{" /* 123 */ +#define MSG_DELHUB "DELHUB" /* DELHUB */ +#define TOK_DELHUB "|" /* 124 */ +#define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */ +#define TOK_ADDCNLINE "}" /* 125 */ +#define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */ +#define TOK_DELCNLINE "~" /* 126 */ +#define MSG_ADDOPER "ADDOPER" /* ADDOPER */ +#define TOK_ADDOPER "" /* 127 */ +#define MSG_DELOPER "DELOPER" /* DELOPER */ +#define TOK_DELOPER "!!" /* 33 + 33 */ +#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ +#define TOK_ADDQLINE "!\"" /* 33 + 34 */ +#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ +#define TOK_DELQLINE "!#" /* 33 + 35 */ +#define MSG_GSOP "GSOP" /* GSOP */ +#define TOK_GSOP "!$" /* 33 + 36 */ +#define MSG_ISOPER "ISOPER" /* ISOPER */ +#define TOK_ISOPER "!%" /* 33 + 37 */ +#define MSG_ADG "ADG" /* ADG */ +#define TOK_ADG "!&" /* 33 + 38 */ +#define MSG_NMON "NMON" /* NMON */ +#define TOK_NMON "!'" /* 33 + 39 */ +#define MSG_DALINFO "DALINFO" /* DALnet Credits */ +#define TOK_DALINFO "!(" /* 33 + 40 */ +#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ +#define TOK_CREDITS "!)" /* 33 + 41 */ +#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ +#define TOK_OPERMOTD "!*" /* 33 + 42 */ +#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ +#define TOK_REMREHASH "!+" /* 33 + 43 */ +#define MSG_MONITOR "MONITOR" /* MONITOR */ +#define TOK_MONITOR "!," /* 33 + 44 */ +#define MSG_GLINE "GLINE" /* The awesome g-line */ +#define TOK_GLINE "!-" /* 33 + 45 */ +#define MSG_REMGLINE "REMGLINE" /* remove g-line */ +#define TOK_REMGLINE "!." /* 33 + 46 */ +#define MSG_STATSERV "STATSERV" /* StatServ */ +#define TOK_STATSERV "!/" /* 33 + 47 */ +#define MSG_RULESERV "RULESERV" /* RuleServ */ +#define TOK_RULESERV "!0" /* 33 + 48 */ +#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ +#define TOK_SNETINFO "!1" /* 33 + 49 */ +#define MSG_TSCTL "TSCTL" /* TSCTL */ +#define TOK_TSCTL "!3" /* 33 + 51 */ +#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ +#define TOK_SVSJOIN "!4" /* 33 + 52 */ +#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ +#define TOK_SAJOIN "!5" /* 33 + 53 */ +#define MSG_SDESC "SDESC" /* SDESC */ +#define TOK_SDESC "!6" /* 33 + 54 */ +#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ +#define TOK_UNREALINFO "!7" /* 33 + 55 */ +#define MSG_SETHOST "SETHOST" /* sethost */ +#define TOK_SETHOST "!8" /* 33 + 56 */ +#define MSG_SETIDENT "SETIDENT" /* set ident */ +#define TOK_SETIDENT "!9" /* 33 + 57 */ +#define MSG_SETNAME "SETNAME" /* set Realname */ +#define TOK_SETNAME "!;" /* 33 + 59 */ +#define MSG_CHGHOST "CHGHOST" /* Changehost */ +#define TOK_CHGHOST "!<" /* 33 + 60 */ +#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ +#define TOK_CHGIDENT "!=" /* 33 + 61 */ +#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ +#define TOK_RANDQUOTE "!>" /* 33 + 62 */ +#define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */ +#define TOK_ADDQUOTE "!?" /* 33 + 63 */ +#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ +#define TOK_ADDGQUOTE "!@" /* 33 + 64 */ +#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ +#define TOK_ADDULINE "!B" /* 33 + 66 */ +#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ +#define TOK_DELULINE "!C" /* 33 + 67 */ +#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ +#define TOK_KNOCK "!D" /* 33 + 68 */ +#define MSG_SETTINGS "SETTINGS" /* Settings */ +#define TOK_SETTINGS "!E" /* 33 + 69 */ +#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ +#define TOK_IRCOPS "!F" /* 33 + 70 */ +#define MSG_SVSPART "SVSPART" /* SVSPART */ +#define TOK_SVSPART "!G" /* 33 + 71 */ +#define MSG_SAPART "SAPART" /* SAPART */ +#define TOK_SAPART "!H" /* 33 + 72 */ +#define MSG_VCTRL "VCTRL" /* VCTRL */ +#define TOK_VCTRL "!I" /* 33 + 73 */ +#define MSG_GCLIENT "GCLIENT" /* GLIENT */ +#define TOK_GCLIENT "!J" /* 33 + 74 */ +#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ +#define TOK_CHANNEL "!K" /* 33 + 75 */ +#define MSG_UPTIME "UPTIME" /* UPTIME */ +#define TOK_UPTIME "!L" /* 33 + 76 */ +#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ +#define TOK_FAILOPS "!M" /* 33 + 77 */ + +#define MSG_RPING "RPING" /* RPING */ +#define TOK_RPING "!P" /* 33 + 80 */ +#define MSG_RPONG "RPONG" /* RPONG */ +#define TOK_RPONG "!Q" /* 33 + 81 */ +#define MSG_UPING "UPING" /* UPING */ +#define TOK_UPING "!R" /* 33 + 82 */ +#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ +#define TOK_COPYRIGHT "!S" /* 33 + 83 */ +#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ +#define MSG_BS "BS" +#define TOK_BOTSERV "!T" /* 33 + 84 */ +#define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */ +#define MSG_RS "RS" +#define TOK_ROOTSERV "!U" /* 33 + 85 */ +#define MSG_SVINFO "SVINFO" +#define MSG_CAPAB "CAPAB" +#define MSG_BURST "BURST" +#define MSG_SJOIN "SJOIN" +#define MSG_CLIENT "CLIENT" +#define MSG_SMODE "SMODE" + + + +#define UMODE_INVISIBLE 0x0001 /* makes user invisible */ +#define UMODE_OPER 0x0002 /* Operator */ +#define UMODE_WALLOP 0x0004 /* send wallops to them */ +#define UMODE_FAILOP 0x0008 /* Shows some global messages */ +#define UMODE_HELPOP 0x0010 /* Help system operator */ +#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */ +#define UMODE_SERVICESOPER 0x0040 /* Services Oper */ +#ifndef ULTIMATE3 +#define UMODE_ADMIN 0x0080 /* Admin */ +#define UMODE_NETADMIN 0x10000 /* Network Admin */ +#define UMODE_SUPER 0x20000 /* Oper Is Protected from Kick's and Kill's */ +#define UMODE_RBOT 0x40000 /* Marks the client as a Registered Bot */ +#define UMODE_SBOT 0x80000 /* Marks the client as a Server Bot */ +#define UMODE_NGLOBAL 0x100000 /* See Network Globals */ +#define UMODE_NETINFO 0x400000 /* Server link, Delink Notces etc. */ +#define UMODE_MAGICK 0x800000 /* Allows Opers To See +s and +p Channels */ +#define UMODE_WATCHER 0x4000000 /* Recive Monitor Globals */ +#define UMODE_NETMON 0x8000000 /* Marks the client as an Network Monitor */ +#define UMODE_SERVADMIN 0x40000000 /* Marks the client as a Server Admin */ +#define UMODE_TECHADMIN 0x80000000 /* Marks the client as a Technical Admin */ +#define UMODE_DEAF 0x100000000 /* client is deaf on channels */ +#else +#define UMODE_SPY 0x0080 /* Oper Spy */ +#define UMODE_DCC 0x10000 /* Oper DCC Notices */ +#define UMODE_GLOBOPS 0x20000 /* send/recv global notices */ +#define UMODE_REJ 0x40000 /* see DCC reject notices */ +#define UMODE_ROUTE 0x80000 /* see Routing Notices */ +#define UMODE_SPAM 0x100000 /* see spambot warnings */ +#define UMODE_PROT 0x400000 /* protected IRC op */ +#define UMODE_GLOBCON 0x800000 /* Global Connect notices */ +#define UMODE_DEBUG 0x4000000 /* see debug notices */ +#define UMODE_DCCWARN 0x8000000 /* see DCC warnings */ +#endif + +#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */ +#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */ +#define UMODE_KILLS 0x0400 /* Show server-kills... */ +#define UMODE_CLIENT 0x0800 /* Show client information */ +#define UMODE_FLOOD 0x1000 /* Receive flood warnings */ +#define UMODE_CHATOP 0x2000 /* can receive chatops */ +#define UMODE_SERVICES 0x4000 /* services */ +#define UMODE_HIDE 0x8000 /* Hide from Nukes */ +#define UMODE_WHOIS 0x200000 /* Lets Opers see when people do a /WhoIs on them */ +#define UMODE_IRCADMIN 0x1000000 /* Marks the client as an IRC Administrator */ +#define UMODE_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */ + + + +#define SMODE_SSL 0x1 /* ssl client */ +#define SMODE_COADMIN 0x2 /* co admin on a server */ +#define SMODE_SERVADMIN 0x4 /* server admin */ +#define SMODE_COTECH 0x8 /* co-tech admin */ +#define SMODE_TECHADMIN 0x10 /* tech administrator */ +#define SMODE_CONET 0x20 /* Co-Network Admin */ +#define SMODE_NETADMIN 0x40 /* Network Admin */ +#define SMODE_GUEST 0x80 /* Guest Admin */ + + +#define MODE_CHANOP 0x0001 +#define MODE_HALFOP 0x0002 +#define MODE_VOICE 0x0004 +#define MODE_PRIVATE 0x0008 +#define MODE_SECRET 0x0010 +#define MODE_MODERATED 0x0020 +#define MODE_TOPICLIMIT 0x0040 +#define MODE_INVITEONLY 0x0080 +#define MODE_NOPRIVMSGS 0x0100 +#define MODE_KEY 0x0200 +#define MODE_EXCEPT 0x0400 +#define MODE_BAN 0x0800 +#define MODE_LIMIT 0x1000 +#define MODE_RGSTR 0x2000 +#define MODE_RGSTRONLY 0x4000 +#define MODE_OPERONLY 0x8000 +#define MODE_ADMONLY 0x10000 +#define MODE_LINK 0x20000 +#define MODE_NOCOLOR 0x40000 +#define MODE_STRIP 0x80000 +#define MODE_NOKNOCK 0x100000 +#define MODE_NOINVITE 0x200000 +#define MODE_FLOODLIMIT 0x400000 +#define MODE_CHANADMIN 0x800000 + + +#define is_hidden_chan(x) ((x) && (x->modes & (MODE_PRIVATE|MODE_SECRET|MODE_ADMONLY|MODE_OPERONLY))) +#define is_oper(x) ((x) && ((x->Umode & UMODE_OPER) || (x->Umode & UMODE_LOCOP))) + + +struct ircd_srv_ { + int uprot; + int modex; + int nicklg; + int gc; + char cloak[25]; + int burst; + int cmdcount; +} ircd_srv; + +typedef struct { + long mode; + char flag; + unsigned nickparam : 1; /* 1 = yes 0 = no */ + unsigned parameters : 1; + char sjoin; +} aCtab; + + + + + +typedef struct { + unsigned long umodes; + char mode; + int level; +} Oper_Modes; + + +aCtab cFlagTab[33]; +Oper_Modes usr_mds[29]; +Oper_Modes susr_mds[9]; + + + +/* function declarations */ +extern void init_ircd(); +extern void chanalert(char *,char *, ...); +extern int sserver_cmd(const char *, const int numeric, const char *); +extern int slogin_cmd(const char *, const int numeric, const char *, const char *); +extern int ssquit_cmd(const char *); +extern int sprotocol_cmd(const char *); +extern int squit_cmd(const char *, const char *); +extern int spart_cmd(const char *, const char *); +#ifdef ULTIMATE3 +extern int sjoin_cmd(const char *, const char *, unsigned long flag); +#else +extern int sjoin_cmd(const char *, const char *); +#endif +extern int schmode_cmd(const char *, const char *, const char *, const char *); +#ifndef ULTIMATE3 +extern int snewnick_cmd(const char *, const char *, const char *, const char *); +#else +extern int snewnick_cmd(const char *, const char *, const char *, const char *, long mode); +#endif +extern int sping_cmd(const char *from, const char *reply, const char *to); +extern int sumode_cmd(const char *who, const char *target, long mode); +extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); +extern int spong_cmd(const char *reply); +extern int snetinfo_cmd(); +extern int skill_cmd(const char *from, const char *target, const char *reason,...); +extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); +extern int snick_cmd(const char *oldnick, const char *newnick); +extern int sswhois_cmd(const char *target, const char *swhois); +extern int ssvsnick_cmd(const char *target, const char *newnick); +extern int ssvsjoin_cmd(const char *target, const char *chan); +extern int ssvspart_cmd(const char *target, const char *chan); +extern int ssvshost_cmd(const char *who, const char *vhost); +extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); +extern int swallops_cmd(const char *who, const char *msg,...); +extern int vctrl_cmd(); +extern int ssvinfo_cmd(); +extern int sburst_cmd(int b); +extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); +extern int srakill_cmd(const char *host, const char *ident); +extern int ssvshost_cmd(const char *who, const char *vhost); +extern int ssvskill_cmd(const char *who, const char *reason, ...); + +void Usr_Version(char *, char **, int argc); +void Usr_ShowMOTD(char *, char **, int argc); +void Usr_ShowADMIN(char *, char **, int argc); +void Usr_Showcredits(char *, char **, int argc); +void Usr_AddServer(char *, char **, int argc); +void Usr_DelServer(char *, char **, int argc); +void Usr_DelUser(char *, char **, int argc); +void Usr_Mode(char *, char **, int argc); +void Usr_Smode(char *, char **, int argc); +void Usr_Kill(char *, char **, int argc); +void Usr_Pong(char *, char **, int argc); +void Usr_Away(char *, char **, int argc); +void Usr_Nick(char *, char **, int argc); +void Usr_Topic(char *, char **, int argc); +void Usr_Kick(char *, char **, int argc); +void Usr_Join(char *, char **, int argc); +void Usr_Part(char *, char **, int argc); +void Usr_Stats(char *, char **, int argc); +void Usr_Vhost(char *, char **, int argc); +void Srv_Topic(char *, char **, int argc); +void Srv_Ping(char *, char **, int argc); +void Srv_Netinfo(char *, char **, int argc); +void Srv_Pass(char *, char **, int argc); +void Srv_Server(char *, char **, int argc); +void Srv_Squit(char *, char **, int argc); +void Srv_Nick(char *, char **, int argc); +void Srv_Svsnick(char *, char **, int argc); +void Srv_Kill(char *, char **, int argc); +void Srv_Connect(char *, char **, int argc); +void Srv_Svinfo(char *, char **, int argc); +void Srv_Burst(char *origin, char **argv, int argc); +void Srv_Sjoin(char *origin, char **argv, int argc); +void Srv_Tburst(char *origin, char **argv, int argc); +void Srv_Vctrl(char *origin, char **argv, int argc); +void Srv_Client(char *origin, char **argv, int argc); +void Srv_Smode(char *origin, char **argv, int argc); +int SignOn_NewBot(const char *, const char *, const char *, const char *, long); + + +#endif diff --git a/config.h.in b/config.h.in index 4dee3603..2ffa1de6 100644 --- a/config.h.in +++ b/config.h.in @@ -122,6 +122,15 @@ /* enable Mystic support */ #undef MYSTIC +/* enable Bahamut support */ +#undef BAHAMUT + +/* enable Quantum support */ +#undef QUANTUM + +/* enable Ircu support */ +#undef IRCU + /* Version number of package */ #undef VERSION diff --git a/configure b/configure index 4f84ab3f..dc936656 100755 --- a/configure +++ b/configure @@ -846,7 +846,10 @@ Optional Features: --enable-ultimate3 - enable Ultimate 3.x.x IRCD Support --enable-hybrid7 - enable Hybrid7 IRCD Support --enable-neoircd - enable NeoIRCd IRCD Support - --enable-mystic - enabled Mystic IRCd 1.1.x Support + --enable-quantum - enable Quantum IRCD Support + --enable-mystic - enable Mystic IRCD Support + --enable-bahamut - enable Bahamut IRCD Support + --enable-ircu - enable IRCu IRCD Support --enable-auth=TYPE - what type of Authentication to use. See Readme File --enable-raw - Enable Raw command --enable-modules="MODULES" - space seperated list of modules to compile @@ -1279,10 +1282,10 @@ cat >>confdefs.h <<\_ACEOF _ACEOF cat >>confdefs.h <<\_ACEOF -#define REV 3 +#define REV 4 _ACEOF -VERSION=2.5.3 +VERSION=2.5.4 CFLAGS="$CFLAGS -O2" @@ -5268,36 +5271,6 @@ echo "${ECHO_T}no" >&6 fi; -echo "$as_me:$LINENO: checking Whether to Enable Mystic 1.1.x IRCD Support..." >&5 -echo $ECHO_N "checking Whether to Enable Mystic 1.1.x IRCD Support...... $ECHO_C" >&6 - -# Check whether --enable-mystic or --disable-mystic was given. -if test "${enable_mystic+set}" = set; then - enableval="$enable_mystic" - case "$enableval" in - yes) - -cat >>confdefs.h <<\_ACEOF -#define MYSTIC 1 -_ACEOF - - IRCD_FILES_SRC="mystic.c" - IRCD_FILES_OBJS="mystic.o" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - ;; - *) - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - ;; -esac -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi; - - - echo "$as_me:$LINENO: checking Whether to Enable NeoIRCd IRCD Support..." >&5 echo $ECHO_N "checking Whether to Enable NeoIRCd IRCD Support...... $ECHO_C" >&6 # Check whether --enable-neoircd or --disable-neoircd was given. @@ -5326,6 +5299,114 @@ echo "${ECHO_T}no" >&6 fi; +echo "$as_me:$LINENO: checking Whether to Enable Quantum IRCD Support..." >&5 +echo $ECHO_N "checking Whether to Enable Quantum IRCD Support...... $ECHO_C" >&6 +# Check whether --enable-quantum or --disable-quantum was given. +if test "${enable_quantum+set}" = set; then + enableval="$enable_quantum" + case "$enableval" in + yes) + +cat >>confdefs.h <<\_ACEOF +#define QUANTUM 1 +_ACEOF + + IRCD_FILES_SRC="QuantumIRCd.c" + IRCD_FILES_OBJS="QuantumIRCd.o" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; +esac +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi; + +echo "$as_me:$LINENO: checking Whether to Enable Mystic IRCD Support..." >&5 +echo $ECHO_N "checking Whether to Enable Mystic IRCD Support...... $ECHO_C" >&6 +# Check whether --enable-mystic or --disable-mystic was given. +if test "${enable_mystic+set}" = set; then + enableval="$enable_mystic" + case "$enableval" in + yes) + +cat >>confdefs.h <<\_ACEOF +#define MYSTIC 1 +_ACEOF + + IRCD_FILES_SRC="Mystic.c" + IRCD_FILES_OBJS="Mystic.o" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; +esac +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi; + +echo "$as_me:$LINENO: checking Whether to Enable Bahamut IRCD Support..." >&5 +echo $ECHO_N "checking Whether to Enable Bahamut IRCD Support...... $ECHO_C" >&6 +# Check whether --enable-bahamut or --disable-bahamut was given. +if test "${enable_bahamut+set}" = set; then + enableval="$enable_bahamut" + case "$enableval" in + yes) + +cat >>confdefs.h <<\_ACEOF +#define BAHAMUT 1 +_ACEOF + + IRCD_FILES_SRC="Bahamut.c" + IRCD_FILES_OBJS="Bahamut.o" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; +esac +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi; + +echo "$as_me:$LINENO: checking Whether to Enable IRCu IRCD Support..." >&5 +echo $ECHO_N "checking Whether to Enable IRCu IRCD Support...... $ECHO_C" >&6 +# Check whether --enable-ircu or --disable-ircu was given. +if test "${enable_ircu+set}" = set; then + enableval="$enable_ircu" + case "$enableval" in + yes) + +cat >>confdefs.h <<\_ACEOF +#define IRCU 1 +_ACEOF + + IRCD_FILES_SRC="Ircu.c" + IRCD_FILES_OBJS="Ircu.o" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; +esac +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi; + echo "$as_me:$LINENO: checking A compatible IRCD is specified" >&5 echo $ECHO_N "checking A compatible IRCD is specified... $ECHO_C" >&6 case "$IRCD_FILES_SRC" in @@ -5340,16 +5421,23 @@ echo "${ECHO_T}yes" >&6 "hybrid7.c") echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 - echo "*******************************************************" - echo "Hybrid7 Support is very very experimental at the moment" - echo "Please report any bugs, or Desyncs to:" - echo "http://www.neostats.net/boards" - echo "*******************************************************" ;; - "mystic.c") - echo "$as_me:$LINENO: result: yes" >&5 + "Mystic.c") + echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 - ;; + ;; + "QuantumIRCd.c") + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + ;; + "Bahamut.c") + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + ;; + "Ircu.c") + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + ;; "neoircd.c") echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 diff --git a/configure.in b/configure.in index 07ce447b..4b2b1d86 100644 --- a/configure.in +++ b/configure.in @@ -198,6 +198,70 @@ esac], AC_MSG_RESULT(no) ) +dnl check to see if we should enable Quantum IRCD Support +AC_MSG_CHECKING(Whether to Enable Quantum IRCD Support...) +AC_ARG_ENABLE(quantum, [ --enable-quantum - enable Quantum IRCD Support], +[ case "$enableval" in + yes) + AC_DEFINE(QUANTUM, 1, 'Enable Quantum Support') + IRCD_FILES_SRC="QuantumIRCd.c" + IRCD_FILES_OBJS="QuantumIRCd.o" + AC_MSG_RESULT(yes) + ;; + *) + AC_MSG_RESULT(no) + ;; +esac], +AC_MSG_RESULT(no)) + +dnl check to see if we should enable Mystic IRCD Support +AC_MSG_CHECKING(Whether to Enable Mystic IRCD Support...) +AC_ARG_ENABLE(mystic, [ --enable-mystic - enable Mystic IRCD Support], +[ case "$enableval" in + yes) + AC_DEFINE(MYSTIC, 1, 'Enable Mystic Support') + IRCD_FILES_SRC="Mystic.c" + IRCD_FILES_OBJS="Mystic.o" + AC_MSG_RESULT(yes) + ;; + *) + AC_MSG_RESULT(no) + ;; +esac], +AC_MSG_RESULT(no)) + +dnl check to see if we should enable Bahamut IRCD Support +AC_MSG_CHECKING(Whether to Enable Bahamut IRCD Support...) +AC_ARG_ENABLE(bahamut, [ --enable-bahamut - enable Bahamut IRCD Support], +[ case "$enableval" in + yes) + AC_DEFINE(BAHAMUT, 1, 'Enable Bahamut Support') + IRCD_FILES_SRC="Bahamut.c" + IRCD_FILES_OBJS="Bahamut.o" + AC_MSG_RESULT(yes) + ;; + *) + AC_MSG_RESULT(no) + ;; +esac], +AC_MSG_RESULT(no)) + +dnl check to see if we should enable IRCu IRCD Support +AC_MSG_CHECKING(Whether to Enable IRCu IRCD Support...) +AC_ARG_ENABLE(ircu, [ --enable-ircu - enable IRCu IRCD Support], +[ case "$enableval" in + yes) + AC_DEFINE(IRCU, 1, 'Enable IRCu Support') + IRCD_FILES_SRC="Ircu.c" + IRCD_FILES_OBJS="Ircu.o" + AC_MSG_RESULT(yes) + ;; + *) + AC_MSG_RESULT(no) + ;; +esac], +AC_MSG_RESULT(no)) + AC_MSG_CHECKING(A compatible IRCD is specified) case "$IRCD_FILES_SRC" in "Ultimate.c") @@ -208,11 +272,18 @@ case "$IRCD_FILES_SRC" in ;; "hybrid7.c") AC_MSG_RESULT(yes) - echo "*******************************************************" - echo "Hybrid7 Support is very very experimental at the moment" - echo "Please report any bugs, or Desyncs to:" - echo "http://www.neostats.net/boards" - echo "*******************************************************" + ;; + "Mystic.c") + AC_MSG_RESULT(yes) + ;; + "QuantumIRCd.c") + AC_MSG_RESULT(yes) + ;; + "Bahamut.c") + AC_MSG_RESULT(yes) + ;; + "Ircu.c") + AC_MSG_RESULT(yes) ;; "neoircd.c") AC_MSG_RESULT(yes) diff --git a/main.c b/main.c index 8e8b0ae7..ff46db41 100755 --- a/main.c +++ b/main.c @@ -22,7 +22,7 @@ ** USA ** ** NeoStats CVS Identification -** $Id: main.c,v 1.95 2003/06/13 13:11:49 fishwaldo Exp $ +** $Id: main.c,v 1.96 2003/06/30 15:18:24 fishwaldo Exp $ */ #include @@ -51,6 +51,14 @@ const char version[] = "(UL)"; const char version[] = "(H)"; #elif NEOIRCD const char version[] = "(N)"; +#elif MYSTIC +const char version[] = "(M)"; +#elif QUANTUM +const char version[] = "(Q)"; +#elif IRCU +const char version[] = "(IRCU)"; +#elif BAHAMUT +const char version[] = "(B)"; #endif diff --git a/stats.h b/stats.h index da54376d..5472ac09 100644 --- a/stats.h +++ b/stats.h @@ -20,7 +20,7 @@ ** USA ** ** NeoStats CVS Identification -** $Id: stats.h,v 1.84 2003/06/26 05:49:45 fishwaldo Exp $ +** $Id: stats.h,v 1.85 2003/06/30 15:18:24 fishwaldo Exp $ */ #ifndef STATS_H @@ -58,6 +58,12 @@ #include "neoircd.h" #elif MYSTIC == 1 #include "mystic.h" +#elif IRCU == 1 +#include "Ircu.h" +#elif BAHAMUT == 1 +#include "Bahamut.h" +#elif QUANTUM == 1 +#include "QuantumIRCd.h" #else #error Error, you must select a IRCD to use. See ./configure --help for more information #endif