summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ircd.c6
-rw-r--r--src/protocol/bahamut.c138
-rw-r--r--src/protocol/bahamut.h1
-rw-r--r--src/protocol/charybdis.c90
-rw-r--r--src/protocol/charybdis.h1
-rw-r--r--src/protocol/inspircd11.c133
-rwxr-xr-xsrc/protocol/inspircd11.h1
-rw-r--r--src/protocol/ratbox.c88
-rw-r--r--src/protocol/ratbox.h3
-rw-r--r--src/protocol/unreal32.c145
-rw-r--r--src/protocol/unreal32.h1
11 files changed, 223 insertions, 384 deletions
diff --git a/src/ircd.c b/src/ircd.c
index a49f79b7d..e02df19ca 100644
--- a/src/ircd.c
+++ b/src/ircd.c
@@ -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);
}
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c
index c72e802cd..a7b7a7fd0 100644
--- a/src/protocol/bahamut.c
+++ b/src/protocol/bahamut.c
@@ -148,75 +148,55 @@ IRCDCAPAB myIrcdcap[] = {
};
-void bahamut_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;
- }
- }
+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[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)
diff --git a/src/protocol/bahamut.h b/src/protocol/bahamut.h
index 509965a1c..a6e73c07a 100644
--- a/src/protocol/bahamut.h
+++ b/src/protocol/bahamut.h
@@ -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);
diff --git a/src/protocol/charybdis.c b/src/protocol/charybdis.c
index b3e2337f7..e2983561f 100644
--- a/src/protocol/charybdis.c
+++ b/src/protocol/charybdis.c
@@ -146,49 +146,33 @@ IRCDCAPAB myIrcdcap[] = {
/*******************************************************************/
-void charybdis_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;
- }
- }
+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[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",
diff --git a/src/protocol/charybdis.h b/src/protocol/charybdis.h
index 6df395c73..2613abf40 100644
--- a/src/protocol/charybdis.h
+++ b/src/protocol/charybdis.h
@@ -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);
diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c
index e86724526..e196539aa 100644
--- a/src/protocol/inspircd11.c
+++ b/src/protocol/inspircd11.c
@@ -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)
-{
- 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;
- }
- }
+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[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.
diff --git a/src/protocol/inspircd11.h b/src/protocol/inspircd11.h
index bd6311ca7..547ec945b 100755
--- a/src/protocol/inspircd11.h
+++ b/src/protocol/inspircd11.h
@@ -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);
diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c
index f27c8d821..0a3b510ca 100644
--- a/src/protocol/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -145,49 +145,33 @@ IRCDCAPAB myIrcdcap[] = {
0, 0, 0}
};
-void ratbox_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;
- }
- }
+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[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.
diff --git a/src/protocol/ratbox.h b/src/protocol/ratbox.h
index 028248126..3096e6e01 100644
--- a/src/protocol/ratbox.h
+++ b/src/protocol/ratbox.h
@@ -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;
diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c
index ad8a3f968..2f1775e01 100644
--- a/src/protocol/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -415,81 +415,56 @@ CUMode myCumodes[128] = {
};
-void unreal_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;
- }
- }
+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) 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* */
diff --git a/src/protocol/unreal32.h b/src/protocol/unreal32.h
index 4880809af..7d6a3b635 100644
--- a/src/protocol/unreal32.h
+++ b/src/protocol/unreal32.h
@@ -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);