From 82ae1cbf63db7e10d7d0e1ecd1a70125a571a8a8 Mon Sep 17 00:00:00 2001 From: codemastr Date: Sun, 2 Sep 2001 23:39:16 +0000 Subject: [PATCH] Moved /svso and /svsnick to modules --- Changes | 1 + src/modules/Makefile.in | 12 ++- src/modules/l_commands.c | 6 ++ src/modules/m_svsnick.c | 147 +++++++++++++++++++++++++++++ src/modules/m_svso.c | 195 +++++++++++++++++++++++++++++++++++++++ src/packet.c | 2 - src/s_svs.c | 63 ------------- src/s_user.c | 56 ----------- 8 files changed, 359 insertions(+), 123 deletions(-) create mode 100644 src/modules/m_svsnick.c create mode 100644 src/modules/m_svso.c diff --git a/Changes b/Changes index 430f31dfd..afe010101 100644 --- a/Changes +++ b/Changes @@ -836,3 +836,4 @@ seen. gmtime warning still there - Modified updconf to reflect the except socks -> except scan change - Fixed a typo in the win32 makefile - Made the config a bit more sturdy (would have done more, but got boring :P) +- Moved /svso and /svsnick to modules diff --git a/src/modules/Makefile.in b/src/modules/Makefile.in index 93606993c..a4efc1f36 100644 --- a/src/modules/Makefile.in +++ b/src/modules/Makefile.in @@ -27,12 +27,12 @@ INCLUDES = ../include/struct.h ../include/config.h \ R_MODULES=m_sethost.so m_chghost.so m_chgident.so m_setname.so \ m_setident.so m_sdesc.so m_svsmode.so m_swhois.so\ m_svsmotd.so m_svsnline.so m_who.so m_mkpasswd.so \ - m_away.so m_svsnoop.so \ + m_away.so m_svsnoop.so m_svso.so m_svsnick.so \ scan.so scan_socks.so scan_http.so web/httpd.so COMMANDS=m_sethost.c m_chghost.c m_chgident.c m_setname.c m_setident.c \ m_sdesc.c m_svsmode.c m_swhois.c m_svsmotd.c m_svsnline.c \ - m_who.c m_mkpasswd.c m_away.c m_svsnoop.c + m_who.c m_mkpasswd.c m_away.c m_svsnoop.c m_svso.c m_svsnick.c MODULES=commands.so $(R_MODULES) MODULEFLAGS=@MODULEFLAGS@ @@ -101,6 +101,14 @@ m_svsnoop.so: m_svsnoop.c $(INCLUDES) $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ -o m_svsnoop.so m_svsnoop.c +m_svso.so: m_svso.c $(INCLUDES) + $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ + -o m_svso.so m_svso.c + +m_svsnick.so: m_svsnick.c $(INCLUDES) + $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ + -o m_svsnick.so m_svsnick.c + scan.so: scan.c $(INCLUDES) $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ -o scan.so scan.c diff --git a/src/modules/l_commands.c b/src/modules/l_commands.c index f9c6e119e..bf42c2b35 100644 --- a/src/modules/l_commands.c +++ b/src/modules/l_commands.c @@ -95,6 +95,8 @@ int l_commands_init(int module_load) m_mkpasswd_init(module_load); m_away_init(module_load); m_svsnoop_init(module_load); + m_svso_init(module_load); + m_svsnick_init(module_load); #ifdef SCAN_API module_depend_resolve(&scan_socks_depend[0]); m_scan_init(module_load); @@ -122,6 +124,8 @@ void l_commands_load(int module_load) m_mkpasswd_load(module_load); m_away_load(module_load); m_svsnoop_load(module_load); + m_svso_load(module_load); + m_svsnick_load(module_load); #ifdef SCAN_API m_scan_load(module_load); scan_socks_load(module_load); @@ -148,6 +152,8 @@ void l_commands_unload(void) m_mkpasswd_unload(); m_away_unload(); m_svsnoop_unload(); + m_svso_unload(); + m_svsnick_unload(); #ifdef SCAN_API scan_socks_unload(); m_scan_unload(); diff --git a/src/modules/m_svsnick.c b/src/modules/m_svsnick.c new file mode 100644 index 000000000..095a4eba3 --- /dev/null +++ b/src/modules/m_svsnick.c @@ -0,0 +1,147 @@ +/* + * IRC - Internet Relay Chat, src/modules/m_svsnick.c + * (C) 2001 The UnrealIRCd Team + * + * svsnick command + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "config.h" +#include "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "msg.h" +#include "channel.h" +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#endif +#include +#include "h.h" +#ifdef STRIPBADWORDS +#include "badwords.h" +#endif +#ifdef _WIN32 +#include "version.h" +#endif + +DLLFUNC int m_svsnick(aClient *cptr, aClient *sptr, int parc, char *parv[]); + +#define MSG_SVSNICK "SVSNICK" +#define TOK_SVSNICK "e" + + +#ifndef DYNAMIC_LINKING +ModuleInfo m_svsnick_info +#else +#define m_svsnick_info mod_header +ModuleInfo mod_header +#endif + = { + 2, + "test", + "$Id$", + "command /svsnick", + NULL, + NULL + }; + +#ifdef DYNAMIC_LINKING +DLLFUNC int mod_init(int module_load) +#else +int m_svsnick_init(int module_load) +#endif +{ + add_Command(MSG_SVSNICK, TOK_SVSNICK, m_svsnick, MAXPARA); +} + +#ifdef DYNAMIC_LINKING +DLLFUNC int mod_load(int module_load) +#else +int m_svsnick_load(int module_load) +#endif +{ +} + +#ifdef DYNAMIC_LINKING +DLLFUNC void mod_unload(void) +#else +void m_svsnick_unload(void) +#endif +{ + if (del_Command(MSG_SVSNICK, TOK_SVSNICK, m_svsnick) < 0) + { + sendto_realops("Failed to delete commands when unloading %s", + m_svsnick_info.name); + } +} +/* +** m_svsnick +** parv[0] = sender +** parv[1] = old nickname +** parv[2] = new nickname +** parv[3] = timestamp +*/ +int m_svsnick(aClient *cptr, aClient *sptr, int parc, char *parv[]) +{ + aClient *acptr; + + if (!IsULine(sptr) || parc < 4 || (strlen(parv[2]) > NICKLEN)) + return -1; /* This looks like an error anyway -Studded */ + if (!hunt_server(cptr, sptr, ":%s SVSNICK %s %s :%s", 1, parc, parv) != HUNTED_ISME) + { + if ((acptr = find_person(parv[1], NULL))) + { + if (find_client(parv[2], NULL)) /* Collision */ + return exit_client(cptr, acptr, sptr, + "Nickname collision due to Services enforced " + "nickname change, your nick was overruled"); + if (do_nick_name(parv[2]) == 0) + return 0; + acptr->umodes &= ~UMODE_REGNICK; + acptr->lastnick = TS2ts(parv[3]); + sendto_common_channels(acptr, ":%s NICK :%s", parv[1], + parv[2]); + if (IsPerson(acptr)) + add_history(acptr, 1); + sendto_serv_butone_token(NULL, parv[1], MSG_NICK, + TOK_NICK, "%s :%i", parv[2], TS2ts(parv[3])); + if (acptr->name[0]) + { + (void)del_from_client_hash_table(acptr->name, acptr); + if (IsPerson(acptr)) + hash_check_watch(acptr, RPL_LOGOFF); + } + if (MyClient(acptr)) + { + RunHook2(HOOKTYPE_LOCAL_NICKCHANGE, acptr, parv[2]); + } + (void)strcpy(acptr->name, parv[2]); + (void)add_to_client_hash_table(parv[2], acptr); + if (IsPerson(acptr)) + hash_check_watch(acptr, RPL_LOGON); + + } + } + return 0; +} diff --git a/src/modules/m_svso.c b/src/modules/m_svso.c new file mode 100644 index 000000000..8da41d309 --- /dev/null +++ b/src/modules/m_svso.c @@ -0,0 +1,195 @@ +/* + * IRC - Internet Relay Chat, src/modules/m_svso.c + * (C) 2001 The UnrealIRCd Team + * + * svso command + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "config.h" +#include "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "msg.h" +#include "channel.h" +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#endif +#include +#include "h.h" +#ifdef STRIPBADWORDS +#include "badwords.h" +#endif +#ifdef _WIN32 +#include "version.h" +#endif + +DLLFUNC int m_svso(aClient *cptr, aClient *sptr, int parc, char *parv[]); + +#define MSG_SVSO "SVSO" +#define TOK_SVSO "BB" + +#define STAR1 OFLAG_SADMIN|OFLAG_ADMIN|OFLAG_NETADMIN|OFLAG_COADMIN +#define STAR2 OFLAG_TECHADMIN|OFLAG_ZLINE|OFLAG_HIDE|OFLAG_WHOIS +#define STAR3 OFLAG_INVISIBLE +int oper_access[] = { + ~(STAR1 | STAR2 | STAR3), '*', + OFLAG_LOCAL, 'o', + OFLAG_GLOBAL, 'O', + OFLAG_REHASH, 'r', + OFLAG_EYES, 'e', + OFLAG_DIE, 'D', + OFLAG_RESTART, 'R', + OFLAG_HELPOP, 'h', + OFLAG_GLOBOP, 'g', + OFLAG_WALLOP, 'w', + OFLAG_LOCOP, 'l', + OFLAG_LROUTE, 'c', + OFLAG_GROUTE, 'L', + OFLAG_LKILL, 'k', + OFLAG_GKILL, 'K', + OFLAG_KLINE, 'b', + OFLAG_UNKLINE, 'B', + OFLAG_LNOTICE, 'n', + OFLAG_GNOTICE, 'G', + OFLAG_ADMIN, 'A', + OFLAG_SADMIN, 'a', + OFLAG_NETADMIN, 'N', + OFLAG_COADMIN, 'C', + OFLAG_TECHADMIN, 'T', + OFLAG_UMODEC, 'u', + OFLAG_UMODEF, 'f', + OFLAG_ZLINE, 'z', + OFLAG_WHOIS, 'W', + OFLAG_HIDE, 'H', + OFLAG_INVISIBLE, '^', + 0, 0 +}; + +extern ircstats IRCstats; + +#ifndef DYNAMIC_LINKING +ModuleInfo m_svso_info +#else +#define m_svso_info mod_header +ModuleInfo mod_header +#endif + = { + 2, + "test", + "$Id$", + "command /svso", + NULL, + NULL + }; + +#ifdef DYNAMIC_LINKING +DLLFUNC int mod_init(int module_load) +#else +int m_svso_init(int module_load) +#endif +{ + add_Command(MSG_SVSO, TOK_SVSO, m_svso, MAXPARA); +} + +#ifdef DYNAMIC_LINKING +DLLFUNC int mod_load(int module_load) +#else +int m_svso_load(int module_load) +#endif +{ +} + +#ifdef DYNAMIC_LINKING +DLLFUNC void mod_unload(void) +#else +void m_svso_unload(void) +#endif +{ + if (del_Command(MSG_SVSO, TOK_SVSO, m_svso) < 0) + { + sendto_realops("Failed to delete commands when unloading %s", + m_svso_info.name); + } +} +/* +** m_svso - Stskeeps +** parv[0] = sender prefix +** parv[1] = nick +** parv[2] = options +*/ + +int m_svso(aClient *cptr, aClient *sptr, int parc, char *parv[]) +{ + aClient *acptr; + long fLag; + + if (!IsULine(sptr)) + return 0; + + if (parc < 3) + return 0; + + if (!(acptr = find_client(parv[1], (aClient *)NULL))) + return 0; + + if (!MyClient(acptr)) + { + sendto_one(acptr, ":%s SVSO %s %s", parv[0], parv[1], parv[2]); + return 0; + } + + if (*parv[2] == '+') + { + int *i, flag; + char *m = NULL; + for (m = (parv[2] + 1); *m; m++) + { + for (i = oper_access; flag = *i; i += 2) + { + if (*m == (char) *(i + 1)) + { + acptr->user->oflag |= flag; + break; + } + } + } + } + if (*parv[2] == '-') + { + fLag = acptr->umodes; + if (IsAnOper(acptr)) + IRCstats.operators--; + acptr->umodes &= + ~(UMODE_OPER | UMODE_LOCOP | UMODE_HELPOP |UMODE_SERVICES | + UMODE_SADMIN | UMODE_ADMIN); + acptr->umodes &= + ~(UMODE_NETADMIN | UMODE_TECHADMIN | UMODE_WHOIS); + acptr->umodes &= + ~(UMODE_KIX | UMODE_HIDING | UMODE_DEAF | UMODE_HIDEOPER); + acptr->user->oflag = 0; + acptr->user->snomask &= ~(SNO_CLIENT|SNO_FLOOD|SNO_FCLIENT|SNO_EYES|SNO_VHOST); + send_umode_out(acptr, acptr, fLag); + } +} diff --git a/src/packet.c b/src/packet.c index 61086b173..6d0863e63 100644 --- a/src/packet.c +++ b/src/packet.c @@ -147,7 +147,6 @@ void init_CommandHash(void) add_CommandX(MSG_QUIT, TOK_QUIT, m_quit, MAXPARA, M_UNREGISTERED|M_USER); add_Command(MSG_WATCH, TOK_WATCH, m_watch, 1); add_Command(MSG_USERHOST, TOK_USERHOST, m_userhost, 1); - add_Command(MSG_SVSNICK, TOK_SVSNICK, m_svsnick, MAXPARA); add_Command(MSG_LUSERS, TOK_LUSERS, m_lusers, MAXPARA); add_Command(MSG_TOPIC, TOK_TOPIC, m_topic, MAXPARA); add_Command(MSG_INVITE, TOK_INVITE, m_invite, MAXPARA); @@ -224,7 +223,6 @@ void init_CommandHash(void) add_Command(MSG_SAJOIN, TOK_SAJOIN, m_sajoin, MAXPARA); add_Command(MSG_SVSPART, TOK_SVSPART, m_svspart, MAXPARA); add_Command(MSG_SAPART, TOK_SAPART, m_sapart, MAXPARA); - add_Command(MSG_SVSO, TOK_SVSO, m_svso, MAXPARA); add_Command(MSG_SVSFLINE, TOK_SVSFLINE, m_svsfline, MAXPARA); add_Command(MSG_TKL, TOK_TKL, m_tkl, MAXPARA); add_Command(MSG_VHOST, TOK_VHOST, m_vhost, MAXPARA); diff --git a/src/s_svs.c b/src/s_svs.c index f6c6ff581..8f3621c41 100644 --- a/src/s_svs.c +++ b/src/s_svs.c @@ -224,69 +224,6 @@ void strrangetok(char *in, char *out, char tok, short first, short last) { } out[j] = 0; } - - -/* -** m_svso - Stskeeps -** parv[0] = sender prefix -** parv[1] = nick -** parv[2] = options -*/ - -int m_svso(aClient *cptr, aClient *sptr, int parc, char *parv[]) -{ - aClient *acptr; - long fLag; - - if (!IsULine(sptr)) - return 0; - - if (parc < 3) - return 0; - - if (!(acptr = find_client(parv[1], (aClient *)NULL))) - return 0; - - if (!MyClient(acptr)) - { - sendto_one(acptr, ":%s SVSO %s %s", parv[0], parv[1], parv[2]); - return 0; - } - - if (*parv[2] == '+') - { - int *i, flag; - char *m = NULL; - for (m = (parv[2] + 1); *m; m++) - { - for (i = oper_access; flag = *i; i += 2) - { - if (*m == (char) *(i + 1)) - { - acptr->user->oflag |= flag; - break; - } - } - } - } - if (*parv[2] == '-') - { - fLag = acptr->umodes; - if (IsAnOper(acptr)) - IRCstats.operators--; - acptr->umodes &= - ~(UMODE_OPER | UMODE_LOCOP | UMODE_HELPOP | UMODE_SERVICES | - UMODE_SADMIN | UMODE_ADMIN); - acptr->umodes &= - ~(UMODE_NETADMIN | UMODE_TECHADMIN | UMODE_WHOIS); - acptr->umodes &= - ~(UMODE_KIX | UMODE_HIDING | UMODE_DEAF | UMODE_HIDEOPER); - acptr->user->oflag = 0; - acptr->user->snomask &= ~(SNO_CLIENT|SNO_FLOOD|SNO_FCLIENT|SNO_EYES|SNO_VHOST); - send_umode_out(acptr, acptr, fLag); - } -} - /* ** m_akill; ** parv[0] = sender prefix diff --git a/src/s_user.c b/src/s_user.c index 261b1c758..37d24a91b 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1046,62 +1046,6 @@ static int register_user(cptr, sptr, nick, username, umode, virthost) return 0; } -/* -** m_svsnick -** parv[0] = sender -** parv[1] = old nickname -** parv[2] = new nickname -** parv[3] = timestamp -*/ -int m_svsnick(cptr, sptr, parc, parv) - aClient *cptr, *sptr; - int parc; - char *parv[]; -{ - aClient *acptr; - - if (!IsULine(sptr) || parc < 4 || (strlen(parv[2]) > NICKLEN)) - return -1; /* This looks like an error anyway -Studded */ - - if (!hunt_server(cptr, sptr, ":%s SVSNICK %s %s :%s", 1, parc, - parv) != HUNTED_ISME) - { - if ((acptr = find_person(parv[1], NULL))) - { - if (find_client(parv[2], NULL)) /* Collision */ - return exit_client(cptr, acptr, sptr, - "Nickname collision due to Services enforced " - "nickname change, your nick was overruled"); - if (do_nick_name(parv[2]) == 0) - return 0; - acptr->umodes &= ~UMODE_REGNICK; - acptr->lastnick = TS2ts(parv[3]); - sendto_common_channels(acptr, ":%s NICK :%s", parv[1], - parv[2]); - if (IsPerson(acptr)) - add_history(acptr, 1); - sendto_serv_butone_token(NULL, parv[1], MSG_NICK, - TOK_NICK, "%s :%i", parv[2], TS2ts(parv[3])); - if (acptr->name[0]) - { - (void)del_from_client_hash_table(acptr->name, acptr); - if (IsPerson(acptr)) - hash_check_watch(acptr, RPL_LOGOFF); - } - if (MyClient(acptr)) - { - RunHook2(HOOKTYPE_LOCAL_NICKCHANGE, acptr, parv[2]); - } - (void)strcpy(acptr->name, parv[2]); - (void)add_to_client_hash_table(parv[2], acptr); - if (IsPerson(acptr)) - hash_check_watch(acptr, RPL_LOGON); - - } - } - return 0; -} - /* ** m_nick ** parv[0] = sender prefix