1
0
mirror of https://github.com/anope/anope.git synced 2026-07-07 19:03:14 +02:00

Added set_umode(), valid_nick(), valid_chan(), and flood_mode_check() from previous commits back in.

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1289 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Naram Qashat cyberbotx@cyberbotx.com
2008-10-01 19:16:23 +00:00
parent eca7e89612
commit 5d127f021d
12 changed files with 218 additions and 384 deletions
-5
View File
@@ -1083,10 +1083,6 @@ typedef struct ircd_proto_ {
void (*ircd_cmd_242)(const char *buf);
void (*ircd_cmd_243)(const char *buf);
void (*ircd_cmd_211)(const char *buf);
void (*ircd_set_umode)(User *user, int ac, const char **av);
int (*ircd_valid_nick)(const char *nick);
int (*ircd_valid_chan)(const char *chan);
int (*ircd_flood_mode_check)(const char *value);
} IRCDProto;
typedef struct ircd_modes_ {
@@ -1381,7 +1377,6 @@ class IRCDProtoNew {
cmd_server(jserver, 2, rbuf);
new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
}
virtual void set_umode(User *, int, const char **) = 0;
virtual int valid_nick(const char *) { return 1; }
virtual int valid_chan(const char *) { return 1; }
+3 -3
View File
@@ -65,7 +65,7 @@ void initIrcdProto()
void anope_set_umode(User *user, int ac, const char **av)
{
ircdproto.ircd_set_umode(user, ac, av);
ircdprotonew->set_umode(user, ac, av);
}
void anope_cmd_svsnoop(const char *server, int set)
@@ -548,12 +548,12 @@ void anope_cmd_jupe(const char *jserver, const char *who, const char *reason)
int anope_valid_nick(const char *nick)
{
return ircdproto.ircd_valid_nick(nick);
return ircdprotonew->valid_nick(nick);
}
int anope_valid_chan(const char *chan)
{
return ircdproto.ircd_valid_chan(chan);
return ircdprotonew->valid_chan(chan);
}
+48 -88
View File
@@ -148,75 +148,55 @@ IRCDCAPAB myIrcdcap[] = {
};
void bahamut_set_umode(User * user, int ac, const char **av)
void BahamutIRCdProto::set_umode(User *user, int ac, const char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
ac--;
if (debug)
alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD
*/
if (add)
user->mode |= umodes[(int) *modes];
else
user->mode &= ~umodes[(int) *modes];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'a':
if (UnRestrictSAdmin) {
break;
}
if (add && !is_services_admin(user)) {
common_svsmode(user, "-a", NULL);
user->mode &= ~UMODE_a;
}
break;
case 'd':
if (ac == 0) {
alog("user: umode +d with no parameter (?) for user %s",
user->nick);
break;
}
ac--;
av++;
user->svid = strtoul(*av, NULL, 0);
break;
case 'o':
if (add) {
opcnt++;
if (WallOper)
anope_cmd_global(s_OperServ,
"\2%s\2 is now an IRC operator.",
user->nick);
display_news(user, NEWS_OPER);
} else {
opcnt--;
}
break;
case 'r':
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
}
break;
}
}
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
--ac;
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'a':
if (UnRestrictSAdmin) break;
if (add && !is_services_admin(user)) {
common_svsmode(user, "-a", NULL);
user->mode &= ~UMODE_a;
}
break;
case 'd':
if (!ac) {
alog("user: umode +d with no parameter (?) for user %s", user->nick);
break;
}
--ac;
++av;
user->svid = strtoul(*av, NULL, 0);
break;
case 'o':
if (add) {
++opcnt;
if (WallOper) anope_cmd_global(s_OperServ, "\2%s\2 is now an IRC operator.", user->nick);
display_news(user, NEWS_OPER);
}
else --opcnt;
break;
case 'r':
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
}
}
}
}
@@ -1273,26 +1253,6 @@ int BahamutIRCdProto::flood_mode_check(const char *value)
else return 0;
}
/*
1 = valid nick
0 = nick is in valid
*/
int bahamut_valid_nick(const char *nick)
{
/* no hard coded invalid nicks */
return 1;
}
/*
1 = valid chan
0 = nick is in chan
*/
int bahamut_valid_chan(const char *chan)
{
/* no silly invalid chans */
return 1;
}
/* this avoids "undefined symbol" messages of those whom try to load mods that
call on this function */
void bahamut_cmd_chghost(const char *nick, const char *vhost)
-1
View File
@@ -58,7 +58,6 @@
#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
void bahamut_set_umode(User * user, int ac, const char **av);
void bahamut_cmd_372(const char *source, const char *msg);
void bahamut_cmd_372_error(const char *source);
void bahamut_cmd_375(const char *source);
+30 -58
View File
@@ -146,49 +146,33 @@ IRCDCAPAB myIrcdcap[] = {
/*******************************************************************/
void charybdis_set_umode(User * user, int ac, const char **av)
void CharybdisProto::set_umode(User *user, int ac, const char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
ac--;
if (debug)
alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD
*/
if (add)
user->mode |= umodes[(int) *modes];
else
user->mode &= ~umodes[(int) *modes];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'o':
if (add) {
opcnt++;
if (WallOper)
anope_cmd_global(s_OperServ,
"\2%s\2 is now an IRC operator.",
user->nick);
display_news(user, NEWS_OPER);
} else {
opcnt--;
}
break;
}
}
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
--ac;
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'o':
if (add) {
++opcnt;
if (WallOper) anope_cmd_global(s_OperServ, "\2%s\2 is now an IRC operator.", user->nick);
display_news(user, NEWS_OPER);
}
else --opcnt;
}
}
}
unsigned long umodes[128] = {
@@ -1489,25 +1473,13 @@ int anope_event_error(const char *source, int ac, const char **av)
1 = valid nick
0 = nick is in valid
*/
int charybdis_valid_nick(const char *nick)
int CharybdisProto::valid_nick(const char *nick)
{
/* TS6 Save extension -Certus */
if (isdigit(*nick))
return 0;
return 1;
/* TS6 Save extension -Certus */
if (isdigit(*nick)) return 0;
return 1;
}
/*
1 = valid chan
0 = chan is invalid
*/
int charybdis_valid_chan(const char *chan)
{
/* no hard coded invalid chan */
return 1;
}
int charybdis_send_account(int argc, char **argv)
{
send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s :%s",
-1
View File
@@ -46,7 +46,6 @@
#define DEFAULT_MLOCK CMODE_n | CMODE_t
void charybdis_set_umode(User * user, int ac, const char **av);
void charybdis_cmd_372(const char *source, const char *msg);
void charybdis_cmd_372_error(const char *source);
void charybdis_cmd_375(const char *source);
+50 -81
View File
@@ -394,77 +394,57 @@ static int has_messagefloodmod = 0;
static int has_banexceptionmod = 0;
static int has_inviteexceptionmod = 0;
void inspircd_set_umode(User * user, int ac, const char **av)
void InspIRCdProto::set_umode(User *user, int ac, const char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
ac--;
if (debug)
alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD
*/
if (add)
user->mode |= umodes[(int) *modes];
else
user->mode &= ~umodes[(int) *modes];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'd':
if (ac == 0) {
break;
}
ac--;
av++;
user->svid = strtoul(*av, NULL, 0);
break;
case 'o':
if (add) {
opcnt++;
if (WallOper) {
anope_cmd_global(s_OperServ,
"\2%s\2 is now an IRC operator.",
user->nick);
}
display_news(user, NEWS_OPER);
} else {
opcnt--;
}
break;
case 'a':
if (UnRestrictSAdmin) {
break;
}
if (add && !is_services_admin(user)) {
common_svsmode(user, "-a", NULL);
user->mode &= ~UMODE_a;
}
break;
case 'r':
user->svid = (add ? user->timestamp : 0);
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
}
break;
case 'x':
if (add) user->chost = user->vhost;
update_host(user);
break;
}
}
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
--ac;
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'd':
if (!ac) break;
--ac;
++av;
user->svid = strtoul(*av, NULL, 0);
break;
case 'o':
if (add) {
++opcnt;
if (WallOper) anope_cmd_global(s_OperServ, "\2%s\2 is now an IRC operator.", user->nick);
display_news(user, NEWS_OPER);
}
else --opcnt;
break;
case 'a':
if (UnRestrictSAdmin) break;
if (add && !is_services_admin(user)) {
common_svsmode(user, "-a", NULL);
user->mode &= ~UMODE_a;
}
break;
case 'r':
user->svid = add ? user->timestamp : 0;
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
}
break;
case 'x':
if (add) user->chost = user->vhost;
update_host(user);
}
}
}
@@ -1521,17 +1501,6 @@ int InspIRCdProto::flood_mode_check(const char *value)
else return 0;
}
int inspircd_valid_nick(const char *nick)
{
return 1;
}
int inspircd_valid_chan(const char *chan)
{
return 1;
}
/**
* Tell anope which function we want to perform each task inside of anope.
* These prototypes must match what anope expects.
-1
View File
@@ -51,7 +51,6 @@
#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
void inspircd_set_umode(User * user, int ac, const char **av);
void inspircd_cmd_372(const char *source, const char *msg);
void inspircd_cmd_372_error(const char *source);
void inspircd_cmd_375(const char *source);
+29 -57
View File
@@ -145,49 +145,33 @@ IRCDCAPAB myIrcdcap[] = {
0, 0, 0}
};
void ratbox_set_umode(User * user, int ac, const char **av)
void RatboxProto::set_umode(User *user, int ac, const char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
ac--;
if (debug)
alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD
*/
if (add)
user->mode |= umodes[(int) *modes];
else
user->mode &= ~umodes[(int) *modes];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'o':
if (add) {
opcnt++;
if (WallOper)
anope_cmd_global(s_OperServ,
"\2%s\2 is now an IRC operator.",
user->nick);
display_news(user, NEWS_OPER);
} else {
opcnt--;
}
break;
}
}
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
--ac;
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'o':
if (add) {
++opcnt;
if (WallOper) anope_cmd_global(s_OperServ, "\2%s\2 is now an IRC operator.", user->nick);
display_news(user, NEWS_OPER);
}
else --opcnt;
}
}
}
unsigned long umodes[128] = {
@@ -1388,25 +1372,13 @@ int anope_event_error(const char *source, int ac, const char **av)
1 = valid nick
0 = nick is in valid
*/
int ratbox_valid_nick(const char *nick)
int RatboxProto::valid_nick(const char *nick)
{
/* TS6 Save extension -Certus */
if (isdigit(*nick))
return 0;
/* TS6 Save extension -Certus */
if (isdigit(*nick)) return 0;
return 1;
}
/*
1 = valid chan
0 = chan is in valid
*/
int ratbox_valid_chan(const char *chan)
{
/* no hard coded invalid chans */
return 1;
}
/**
* Tell anope which function we want to perform each task inside of anope.
* These prototypes must match what anope expects.
+2 -1
View File
@@ -45,7 +45,6 @@
#define DEFAULT_MLOCK CMODE_n | CMODE_t
void ratbox_set_umode(User * user, int ac, const char **av);
void ratbox_cmd_372(const char *source, const char *msg);
void ratbox_cmd_372_error(const char *source);
void ratbox_cmd_375(const char *source);
@@ -92,4 +91,6 @@ class RatboxProto : public IRCDProtoNew {
void cmd_unsgline(const char *);
void cmd_sgline(const char *, const char *);
void cmd_server(const char *, int, const char *);
void set_umode(User *, int, const char **);
int valid_nick(const char *);
} ircd_proto;
+56 -87
View File
@@ -415,81 +415,56 @@ CUMode myCumodes[128] = {
};
void unreal_set_umode(User * user, int ac, const char **av)
void UnrealIRCdProto::set_umode(User *user, int ac, const char **av)
{
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
ac--;
if (!user || !modes) {
/* Prevent NULLs from doing bad things */
return;
}
if (debug)
alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD
*/
if (add)
user->mode |= umodes[(int) *modes];
else
user->mode &= ~umodes[(int) *modes];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'd':
if (ac <= 0) {
break;
}
ac--;
av++;
if (av) {
user->svid = strtoul(*av, NULL, 0);
}
break;
case 'o':
if (add) {
opcnt++;
if (WallOper) {
anope_cmd_global(s_OperServ,
"\2%s\2 is now an IRC operator.",
user->nick);
}
display_news(user, NEWS_OPER);
} else {
opcnt--;
}
break;
case 'a':
if (UnRestrictSAdmin) {
break;
}
if (add && !is_services_admin(user)) {
common_svsmode(user, "-a", NULL);
user->mode &= ~UMODE_a;
}
break;
case 'r':
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
}
break;
case 'x':
update_host(user);
break;
}
}
int add = 1; /* 1 if adding modes, 0 if deleting */
const char *modes = av[0];
--ac;
if (!user || !modes) return; /* Prevent NULLs from doing bad things */
if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes);
while (*modes) {
/* This looks better, much better than "add ? (do_add) : (do_remove)".
* At least this is readable without paying much attention :) -GD */
if (add) user->mode |= umodes[static_cast<int>(*modes)];
else user->mode &= ~umodes[static_cast<int>(*modes)];
switch (*modes++) {
case '+':
add = 1;
break;
case '-':
add = 0;
break;
case 'd':
if (ac <= 0) break;
--ac;
++av;
if (av) user->svid = strtoul(*av, NULL, 0);
break;
case 'o':
if (add) {
++opcnt;
if (WallOper) anope_cmd_global(s_OperServ, "\2%s\2 is now an IRC operator.", user->nick);
display_news(user, NEWS_OPER);
}
else --opcnt;
break;
case 'a':
if (UnRestrictSAdmin) break;
if (add && !is_services_admin(user)) {
common_svsmode(user, "-a", NULL);
user->mode &= ~UMODE_a;
}
break;
case 'r':
if (add && !nick_identified(user)) {
common_svsmode(user, "-r", NULL);
user->mode &= ~UMODE_r;
}
break;
case 'x':
update_host(user);
}
}
}
@@ -1556,22 +1531,16 @@ int UnrealIRCdProto::flood_mode_check(const char *value)
1 = valid nick
0 = nick is in valid
*/
int unreal_valid_nick(const char *nick)
int UnrealIRCdProto::valid_nick(const char *nick)
{
if (!stricmp("ircd", nick)) {
return 0;
}
if (!stricmp("irc", nick)) {
return 0;
}
return 1;
if (!stricmp("ircd", nick) || !stricmp("irc", nick)) return 0;
return 1;
}
int unreal_valid_chan(const char *chan) {
if (strchr(chan, ':')) {
return 0;
}
return 1;
int UnrealIRCdProto::valid_chan(const char *chan)
{
if (strchr(chan, ':')) return 0;
return 1;
}
/* *INDENT-OFF* */
-1
View File
@@ -80,7 +80,6 @@
#define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r
void unreal_set_umode(User * user, int ac, const char **av);
void unreal_cmd_372(const char *source, const char *msg);
void unreal_cmd_372_error(const char *source);
void unreal_cmd_375(const char *source);