diff --git a/Changes b/Changes index d42af3292..8d041a98f 100644 --- a/Changes +++ b/Changes @@ -602,4 +602,4 @@ seen. gmtime warning still there - Fixed a /rehash bug dealing with echoing to stderr - Added MAXCONNECTIONS to configure - Added a little utility to make converting an m_* command to a module easier - +- Moved m_svsmode and m_svs2mode to m_svsmode.so and updated modulize a bit diff --git a/m_template.c b/m_template.c index 1ac03b7f6..868e8a7ec 100644 --- a/m_template.c +++ b/m_template.c @@ -1,7 +1,25 @@ /* - * Module skeleton, by Carsten V. Munk 2001 - * May be used, modified, or changed by anyone, no license applies. - * You may relicense this, to any license + * IRC - Internet Relay Chat, src/modules/%FILE + * (C) 2001 The UnrealIRCd Team + * + * %DESC% + * + * 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" diff --git a/modulize b/modulize index d3f7445af..5b66a00cb 100755 --- a/modulize +++ b/modulize @@ -9,7 +9,10 @@ sed "s/%UCOMMAND%/$UCOMMAND/g" $1.tmp >$1.tmp.1 mv $1.tmp.1 $1.tmp sed "s/%MAXPARA%/$4/g" $1.tmp >$1.tmp.1 mv $1.tmp.1 $1.tmp - +sed "s/%FILE%/$6/g" $1.tmp >$1.tmp.1 +mv $1.tmp.1 $1.tmp +sed "s/%DESC%/$7/g" $1.tmp >$1.tmp.1 +mv $1.tmp.1 $1.tmp cat >> $1.tmp << __EOF__ `cat $5` __EOF__ diff --git a/src/modules/Makefile.in b/src/modules/Makefile.in index dca55ef73..7323571c1 100644 --- a/src/modules/Makefile.in +++ b/src/modules/Makefile.in @@ -20,10 +20,10 @@ #*/ R_MODULES=m_sethost.so m_chghost.so m_chgident.so m_setname.so \ - m_setident.so m_sdesc.so scan.so scan_socks.so blackhole.so + m_setident.so m_sdesc.so m_svsmode.so scan.so scan_socks.so blackhole.so COMMANDS=m_sethost.c m_chghost.c m_chgident.c m_setname.c m_setident.c \ - m_sdesc.c + m_sdesc.c m_svsmode.c MODULES=commands.so $(R_MODULES) MODULEFLAGS=@MODULEFLAGS@ @@ -60,6 +60,9 @@ m_sdesc.so: m_sdesc.c $(INCLUDES) $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ -o m_sdesc.so m_sdesc.c +m_svsmode.so: m_svsmode.c $(INCLUDES) + $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ + -o m_svsmode.so m_svsmode.c scan.so: scan.c $(INCLUDES) $(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \ diff --git a/src/modules/l_commands.c b/src/modules/l_commands.c index 27d0fccb0..6ba4e64ee 100644 --- a/src/modules/l_commands.c +++ b/src/modules/l_commands.c @@ -86,6 +86,7 @@ void l_commands_init(void) m_chgident_init(); m_setident_init(); m_sdesc_init(); + m_svsmode_init(); module_buffer = &l_commands_info; } diff --git a/src/modules/m_svsmode.c b/src/modules/m_svsmode.c new file mode 100644 index 000000000..1a2d661e5 --- /dev/null +++ b/src/modules/m_svsmode.c @@ -0,0 +1,312 @@ +/* + * IRC - Internet Relay Chat, src/modules/scan.c + * (C) 2001 The UnrealIRCd Team + * + * SVSMODE and SVS2MODE commands + * + * 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 "userload.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_svsmode(aClient *cptr, aClient *sptr, int parc, char *parv[]); +DLLFUNC int m_svs2mode(aClient *cptr, aClient *sptr, int parc, char *parv[]); + +extern ircstats IRCstats; +extern int user_modes[]; +#define MSG_SVSMODE "SVSMODE" +#define TOK_SVSMODE "n" +#define MSG_SVS2MODE "SVS2MODE" +#define TOK_SVS2MODE "v" + +ModuleInfo m_svsmode_info + = { + 1, + "test", + "$Id$", + "command /svsmode and svs2mode", + NULL, + NULL + }; + +#ifdef DYNAMIC_LINKING +DLLFUNC void mod_init(void) +#else +void m_svsmode_init(void) +#endif +{ + module_buffer = &m_svsmode_info; + add_Command(MSG_SVSMODE, TOK_SVSMODE, m_svsmode, MAXPARA); + add_Command(MSG_SVS2MODE, TOK_SVS2MODE, m_svs2mode, MAXPARA); +} + +#ifdef DYNAMIC_LINKING +DLLFUNC void mod_load(void) +#else +void m_svsmode_load(void) +#endif +{ +} + +#ifdef DYNAMIC_LINKING +DLLFUNC void mod_unload(void) +#else +void m_svsmode_unload(void) +#endif +{ + if (del_Command(MSG_SVSMODE, TOK_SVSMODE, m_svsmode) < 0 || del_Command(MSG_SVS2MODE, TOK_SVS2MODE, m_svs2mode) < 0) + { + sendto_realops("Failed to delete commands when unloading %s", + m_svsmode_info.name); + } +} +/* + * m_svsmode() added by taz + * parv[0] - sender + * parv[1] - username to change mode for + * parv[2] - modes to change + * parv[3] - Service Stamp (if mode == d) + */ +int m_svsmode(cptr, sptr, parc, parv) + aClient *cptr, *sptr; + int parc; + char *parv[]; +{ + int flag; + int *s; + char **p, *m; + aClient *acptr; + int what, setflags; + + if (!IsULine(sptr)) + return 0; + + what = MODE_ADD; + + if (parc < 3) + return 0; + + if (!(acptr = find_person(parv[1], NULL))) + return 0; + setflags = 0; + for (s = user_modes; (flag = *s); s += 2) + if (acptr->umodes & flag) + setflags |= flag; + /* + * parse mode change string(s) + */ + for (p = &parv[2]; p && *p; p++) + for (m = *p; *m; m++) + switch (*m) + { + case '+': + what = MODE_ADD; + break; + case '-': + what = MODE_DEL; + break; + /* we may not get these, + * but they shouldnt be in default + */ + case ' ': + case '\n': + case '\r': + case '\t': + break; + case 'i': + if (what == MODE_ADD + && !(acptr->umodes & UMODE_INVISIBLE)) + { + IRCstats.invisible++; + } + if (what == MODE_DEL + && (acptr->umodes & UMODE_INVISIBLE)) + { + + IRCstats.invisible--; + } + goto setmodex; + case 'o': + if (what == MODE_ADD + && !(acptr->umodes & UMODE_OPER)) + IRCstats.operators++; + if (what == MODE_DEL + && (acptr->umodes & UMODE_OPER)) + IRCstats.operators--; + goto setmodex; + case 'd': + if (parv[3] && isdigit(*parv[3])) + { + acptr->user->servicestamp = + strtoul(parv[3], NULL, 10); + + break; + } + default: + setmodex: + for (s = user_modes; (flag = *s); s += 2) + if (*m == (char)(*(s + 1))) + { + if (what == MODE_ADD) + acptr->umodes |= flag; + else + acptr->umodes &= + ~flag; + break; + } + break; + } + if (parc > 3) + sendto_serv_butone_token(cptr, parv[0], MSG_SVSMODE, + TOK_SVSMODE, "%s %s %s", parv[1], parv[2], parv[3]); + else + sendto_serv_butone_token(cptr, parv[0], MSG_SVSMODE, + TOK_SVSMODE, "%s %s", parv[1], parv[2]); + + return 0; +} + +/* + * m_svs2mode() added by Potvin + * parv[0] - sender + * parv[1] - username to change mode for + * parv[2] - modes to change + * parv[3] - Service Stamp (if mode == d) + */ +int m_svs2mode(cptr, sptr, parc, parv) + aClient *cptr, *sptr; + int parc; + char *parv[]; +{ + int flag; + int *s; + char **p, *m; + aClient *acptr; + int what, setflags; + char buf[BUFSIZE]; + + + if (!IsULine(sptr)) + return 0; + + what = MODE_ADD; + + if (parc < 3) + return 0; + setflags = 0; + for (s = user_modes; (flag = *s); s += 2) + if (acptr->umodes & flag) + setflags |= flag; + /* + * parse mode change string(s) + */ + for (p = &parv[2]; p && *p; p++) + for (m = *p; *m; m++) + switch (*m) + { + case '+': + what = MODE_ADD; + break; + case '-': + what = MODE_DEL; + break; + /* we may not get these, + * but they shouldnt be in default + */ + case ' ': + case '\n': + case '\r': + case '\t': + break; + case 'd': + if (parv[3] && (isdigit(*parv[3]))) + { + acptr->user->servicestamp = + strtoul(parv[3], NULL, 10); + } + break; + case 'i': + if (what == MODE_ADD + && !(acptr->umodes & UMODE_INVISIBLE)) + { + IRCstats.invisible++; + } + if (what == MODE_DEL + && (acptr->umodes & UMODE_INVISIBLE)) + { + IRCstats.invisible--; + } + goto setmodey; + case 'o': + if (acptr->srvptr->flags & FLAGS_QUARANTINE) + break; + if (what == MODE_ADD + && !(acptr->umodes & UMODE_OPER)) + IRCstats.operators++; + if (what == MODE_DEL + && (acptr->umodes & UMODE_OPER)) + IRCstats.operators--; + default: + setmodey: + for (s = user_modes; (flag = *s); s += 2) + if (*m == (char)(*(s + 1))) + { + if (what == MODE_ADD) + acptr->umodes |= flag; + else + acptr->umodes &= + ~flag; + break; + } + break; + } + + if (parc > 3) + sendto_serv_butone_token(cptr, parv[0], MSG_SVS2MODE, + TOK_SVS2MODE, "%s %s %s", parv[1], parv[2], parv[3]); + else + sendto_serv_butone_token(cptr, parv[0], MSG_SVS2MODE, + TOK_SVS2MODE, "%s %s", parv[1], parv[2]); + + send_umode(NULL, acptr, setflags, ALL_UMODES, buf); + if (MyClient(acptr) && buf[0] && buf[1]) + sendto_one(acptr, ":%s MODE %s :%s", parv[0], parv[1], buf); + return 0; +} diff --git a/src/packet.c b/src/packet.c index 682f271c3..c7e4bbb4e 100644 --- a/src/packet.c +++ b/src/packet.c @@ -148,7 +148,6 @@ void init_CommandHash(void) 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_SVSMODE, TOK_SVSMODE, m_svsmode, MAXPARA); add_Command(MSG_LUSERS, TOK_LUSERS, m_lusers, MAXPARA); add_Command(MSG_IDENTIFY, TOK_IDENTIFY, m_identify, 1); add_Command(MSG_CHANSERV, TOK_CHANSERV, m_chanserv, 1); @@ -221,7 +220,6 @@ void init_CommandHash(void) add_Command(MSG_GLINE, TOK_GLINE, m_gline, MAXPARA); add_Command(MSG_REMGLINE, TOK_REMGLINE, m_remgline, MAXPARA); add_Command(MSG_DALINFO, TOK_DALINFO, m_dalinfo, MAXPARA); - add_Command(MSG_SVS2MODE, TOK_SVS2MODE, m_svs2mode, MAXPARA); add_Command(MSG_MKPASSWD, TOK_MKPASSWD, m_mkpasswd, MAXPARA); add_Command(MSG_ADDLINE, TOK_ADDLINE, m_addline, 1); add_Command(MSG_ADMINCHAT, TOK_ADMINCHAT, m_admins, 1); diff --git a/src/s_user.c b/src/s_user.c index 575c73a25..9ab66325d 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -64,7 +64,7 @@ extern char *me_hash; extern ircstats IRCstats; extern char backupbuf[]; static char buf[BUFSIZE], buf2[BUFSIZE]; -static int user_modes[] = { UMODE_OPER, 'o', +int user_modes[] = { UMODE_OPER, 'o', UMODE_LOCOP, 'O', UMODE_INVISIBLE, 'i', UMODE_WALLOP, 'w', @@ -4653,228 +4653,6 @@ int m_umode2(cptr, sptr, parc, parv) m_umode(cptr, sptr, 3, xparv); } -/* - * m_svs2mode() added by Potvin - * parv[0] - sender - * parv[1] - username to change mode for - * parv[2] - modes to change - * parv[3] - Service Stamp (if mode == d) - */ -int m_svs2mode(cptr, sptr, parc, parv) - aClient *cptr, *sptr; - int parc; - char *parv[]; -{ - int flag; - int *s; - char **p, *m; - aClient *acptr; - int what, setflags; - - if (!IsULine(sptr)) - return 0; - - what = MODE_ADD; - - if (parc < 3) - return 0; - - if (!(acptr = find_person(parv[1], NULL))) - return 0; - - setflags = 0; - for (s = user_modes; (flag = *s); s += 2) - if (acptr->umodes & flag) - setflags |= flag; - /* - * parse mode change string(s) - */ - for (p = &parv[2]; p && *p; p++) - for (m = *p; *m; m++) - switch (*m) - { - case '+': - what = MODE_ADD; - break; - case '-': - what = MODE_DEL; - break; - /* we may not get these, - * but they shouldnt be in default - */ - case ' ': - case '\n': - case '\r': - case '\t': - break; - case 'l': - if (parv[3] && isdigit(*parv[3])) - max_global_count = atoi(parv[3]); - break; - case 'd': - if (parv[3] && (isdigit(*parv[3]))) - { - acptr->user->servicestamp = - strtoul(parv[3], NULL, 10); - } - break; - case 'i': - if (what == MODE_ADD - && !(acptr->umodes & UMODE_INVISIBLE)) - { - IRCstats.invisible++; - } - if (what == MODE_DEL - && (acptr->umodes & UMODE_INVISIBLE)) - { - IRCstats.invisible--; - } - goto setmodey; - case 'o': - if (acptr->srvptr->flags & FLAGS_QUARANTINE) - break; - if (what == MODE_ADD - && !(acptr->umodes & UMODE_OPER)) - IRCstats.operators++; - if (what == MODE_DEL - && (acptr->umodes & UMODE_OPER)) - IRCstats.operators--; - default: - setmodey: - for (s = user_modes; (flag = *s); s += 2) - if (*m == (char)(*(s + 1))) - { - if (what == MODE_ADD) - acptr->umodes |= flag; - else - acptr->umodes &= - ~flag; - break; - } - break; - } - - if (parc > 3) - sendto_serv_butone_token(cptr, parv[0], MSG_SVS2MODE, - TOK_SVS2MODE, "%s %s %s", parv[1], parv[2], parv[3]); - else - sendto_serv_butone_token(cptr, parv[0], MSG_SVS2MODE, - TOK_SVS2MODE, "%s %s", parv[1], parv[2]); - - send_umode(NULL, acptr, setflags, ALL_UMODES, buf); - if (MyClient(acptr) && buf[0] && buf[1]) - sendto_one(acptr, ":%s MODE %s :%s", parv[0], parv[1], buf); - return 0; -} - -/* - * m_svsmode() added by taz - * parv[0] - sender - * parv[1] - username to change mode for - * parv[2] - modes to change - * parv[3] - Service Stamp (if mode == d) - */ -int m_svsmode(cptr, sptr, parc, parv) - aClient *cptr, *sptr; - int parc; - char *parv[]; -{ - int flag; - int *s; - char **p, *m; - aClient *acptr; - int what, setflags; - - if (!IsULine(sptr)) - return 0; - - what = MODE_ADD; - - if (parc < 3) - return 0; - - if (!(acptr = find_person(parv[1], NULL))) - return 0; - - setflags = 0; - for (s = user_modes; (flag = *s); s += 2) - if (acptr->umodes & flag) - setflags |= flag; - /* - * parse mode change string(s) - */ - for (p = &parv[2]; p && *p; p++) - for (m = *p; *m; m++) - switch (*m) - { - case '+': - what = MODE_ADD; - break; - case '-': - what = MODE_DEL; - break; - /* we may not get these, - * but they shouldnt be in default - */ - case ' ': - case '\n': - case '\r': - case '\t': - break; - case 'i': - if (what == MODE_ADD - && !(acptr->umodes & UMODE_INVISIBLE)) - { - IRCstats.invisible++; - } - if (what == MODE_DEL - && (acptr->umodes & UMODE_INVISIBLE)) - { - - IRCstats.invisible--; - } - goto setmodex; - case 'o': - if (what == MODE_ADD - && !(acptr->umodes & UMODE_OPER)) - IRCstats.operators++; - if (what == MODE_DEL - && (acptr->umodes & UMODE_OPER)) - IRCstats.operators--; - goto setmodex; - case 'd': - if (parv[3] && isdigit(*parv[3])) - { - acptr->user->servicestamp = - strtoul(parv[3], NULL, 10); - - break; - } - default: - setmodex: - for (s = user_modes; (flag = *s); s += 2) - if (*m == (char)(*(s + 1))) - { - if (what == MODE_ADD) - acptr->umodes |= flag; - else - acptr->umodes &= - ~flag; - break; - } - break; - } - - - if (parc > 3) - sendto_serv_butone_token(cptr, parv[0], MSG_SVSMODE, - TOK_SVSMODE, "%s %s %s", parv[1], parv[2], parv[3]); - else - sendto_serv_butone_token(cptr, parv[0], MSG_SVSMODE, - TOK_SVSMODE, "%s %s", parv[1], parv[2]); - - return 0; -} /* * send the MODE string for user (user) to connection cptr