Applying dyn-cmodes.diff - first step in implementing channel module

addition in extensions
This commit is contained in:
Valery V Yatsko 2008-06-24 20:45:19 +04:00
parent 193b048113
commit 75818939ab
7 changed files with 40 additions and 284 deletions

View File

@ -258,7 +258,7 @@ extern void send_cap_mode_changes(struct Client *client_p, struct Client *source
extern void set_channel_mode(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
extern const struct mode_letter chmode_flags[];
extern int chmode_flags[256];
extern struct ChannelMode chmode_table[256];

View File

@ -62,4 +62,6 @@ extern void chm_voice(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void construct_noparam_modes(void);
#endif

View File

@ -564,48 +564,6 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
{
switch (*(s++))
{
case 'i':
mode.mode |= MODE_INVITEONLY;
break;
case 'n':
mode.mode |= MODE_NOPRIVMSGS;
break;
case 'p':
mode.mode |= MODE_PRIVATE;
break;
case 's':
mode.mode |= MODE_SECRET;
break;
case 'm':
mode.mode |= MODE_MODERATED;
break;
case 't':
mode.mode |= MODE_TOPICLIMIT;
break;
case 'r':
mode.mode |= MODE_REGONLY;
break;
case 'L':
mode.mode |= MODE_EXLIMIT;
break;
case 'P':
mode.mode |= MODE_PERMANENT;
break;
case 'c':
mode.mode |= MODE_NOCOLOR;
break;
case 'g':
mode.mode |= MODE_FREEINVITE;
break;
case 'z':
mode.mode |= MODE_OPMODERATE;
break;
case 'F':
mode.mode |= MODE_FREETARGET;
break;
case 'Q':
mode.mode |= MODE_DISFORWARD;
break;
case 'f':
rb_strlcpy(mode.forward, parv[4 + args], sizeof(mode.forward));
args++;
@ -632,6 +590,11 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
if(parc < 5 + args)
return 0;
break;
default:
if(chmode_flags[(int) *s] != 0)
{
mode.mode |= chmode_flags[(int) *s];
}
}
}
@ -1061,30 +1024,30 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
int i;
/* ok, first get a list of modes we need to add */
for (i = 0; chmode_flags[i].letter; i++)
for (i = 0; i < 256; i++)
{
if((mode->mode & chmode_flags[i].mode) && !(oldmode->mode & chmode_flags[i].mode))
if((mode->mode & chmode_flags[i]) && !(oldmode->mode & chmode_flags[i]))
{
if(dir != MODE_ADD)
{
*mbuf++ = '+';
dir = MODE_ADD;
}
*mbuf++ = chmode_flags[i].letter;
*mbuf++ = i;
}
}
/* now the ones we need to remove. */
for (i = 0; chmode_flags[i].letter; i++)
for (i = 0; i < 256; i++)
{
if((oldmode->mode & chmode_flags[i].mode) && !(mode->mode & chmode_flags[i].mode))
if((oldmode->mode & chmode_flags[i]) && !(mode->mode & chmode_flags[i]))
{
if(dir != MODE_DEL)
{
*mbuf++ = '-';
dir = MODE_DEL;
}
*mbuf++ = chmode_flags[i].letter;
*mbuf++ = i;
}
}

View File

@ -1,213 +0,0 @@
diff -r e6b8fd0ebc1f include/channel.h
--- a/include/channel.h Tue Apr 08 16:14:01 2008 +0400
+++ b/include/channel.h Tue Apr 08 17:28:26 2008 +0400
@@ -258,7 +258,7 @@
extern void set_channel_mode(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
-extern const struct mode_letter chmode_flags[];
+extern int chmode_flags[256];
extern struct ChannelMode chmode_table[256];
diff -r e6b8fd0ebc1f modules/core/m_join.c
--- a/modules/core/m_join.c Tue Apr 08 16:14:01 2008 +0400
+++ b/modules/core/m_join.c Tue Apr 08 17:28:26 2008 +0400
@@ -581,48 +581,6 @@
{
switch (*(s++))
{
- case 'i':
- mode.mode |= MODE_INVITEONLY;
- break;
- case 'n':
- mode.mode |= MODE_NOPRIVMSGS;
- break;
- case 'p':
- mode.mode |= MODE_PRIVATE;
- break;
- case 's':
- mode.mode |= MODE_SECRET;
- break;
- case 'm':
- mode.mode |= MODE_MODERATED;
- break;
- case 't':
- mode.mode |= MODE_TOPICLIMIT;
- break;
- case 'r':
- mode.mode |= MODE_REGONLY;
- break;
- case 'L':
- mode.mode |= MODE_EXLIMIT;
- break;
- case 'P':
- mode.mode |= MODE_PERMANENT;
- break;
- case 'c':
- mode.mode |= MODE_NOCOLOR;
- break;
- case 'g':
- mode.mode |= MODE_FREEINVITE;
- break;
- case 'z':
- mode.mode |= MODE_OPMODERATE;
- break;
- case 'F':
- mode.mode |= MODE_FREETARGET;
- break;
- case 'Q':
- mode.mode |= MODE_DISFORWARD;
- break;
case 'f':
strlcpy(mode.forward, parv[4 + args], sizeof(mode.forward));
args++;
@@ -649,6 +607,11 @@
if(parc < 5 + args)
return 0;
break;
+ default:
+ if(chmode_flags[(int) *s] != 0)
+ {
+ mode.mode |= chmode_flags[(int) *s];
+ }
}
}
@@ -1124,30 +1087,30 @@
int i;
/* ok, first get a list of modes we need to add */
- for (i = 0; chmode_flags[i].letter; i++)
+ for (i = 0; i < 256; i++)
{
- if((mode->mode & chmode_flags[i].mode) && !(oldmode->mode & chmode_flags[i].mode))
+ if((mode->mode & chmode_flags[i]) && !(oldmode->mode & chmode_flags[i]))
{
if(dir != MODE_ADD)
{
*mbuf++ = '+';
dir = MODE_ADD;
}
- *mbuf++ = chmode_flags[i].letter;
+ *mbuf++ = i;
}
}
/* now the ones we need to remove. */
- for (i = 0; chmode_flags[i].letter; i++)
+ for (i = 0; i < 256; i++)
{
- if((oldmode->mode & chmode_flags[i].mode) && !(mode->mode & chmode_flags[i].mode))
+ if((oldmode->mode & chmode_flags[i]) && !(mode->mode & chmode_flags[i]))
{
if(dir != MODE_DEL)
{
*mbuf++ = '-';
dir = MODE_DEL;
}
- *mbuf++ = chmode_flags[i].letter;
+ *mbuf++ = i;
}
}
diff -r e6b8fd0ebc1f src/channel.c
--- a/src/channel.c Tue Apr 08 16:14:01 2008 +0400
+++ b/src/channel.c Tue Apr 08 17:28:26 2008 +0400
@@ -1080,25 +1080,6 @@
}
}
-const struct mode_letter chmode_flags[] =
-{
- {MODE_INVITEONLY, 'i'},
- {MODE_MODERATED, 'm'},
- {MODE_NOPRIVMSGS, 'n'},
- {MODE_PRIVATE, 'p'},
- {MODE_SECRET, 's'},
- {MODE_TOPICLIMIT, 't'},
- {MODE_NOCOLOR, 'c'},
- {MODE_FREEINVITE, 'g'},
- {MODE_OPMODERATE, 'z'},
- {MODE_EXLIMIT, 'L'},
- {MODE_PERMANENT, 'P'},
- {MODE_FREETARGET, 'F'},
- {MODE_DISFORWARD, 'Q'},
- {MODE_REGONLY, 'r'},
- {0, '\0'}
-};
-
/* channel_modes()
*
* inputs - pointer to channel
@@ -1121,9 +1102,9 @@
*mbuf++ = '+';
*pbuf = '\0';
- for (i = 0; chmode_flags[i].mode; ++i)
- if(chptr->mode.mode & chmode_flags[i].mode)
- *mbuf++ = chmode_flags[i].letter;
+ for (i = 0; i < 256; i++)
+ if(chptr->mode.mode & chmode_flags[i])
+ *mbuf++ = i;
if(chptr->mode.limit)
{
diff -r e6b8fd0ebc1f src/chmode.c
--- a/src/chmode.c Tue Apr 08 16:14:01 2008 +0400
+++ b/src/chmode.c Tue Apr 08 17:28:26 2008 +0400
@@ -42,6 +42,7 @@
#include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
#include "s_newconf.h"
#include "logger.h"
+#include "chmode.h"
/* bitmasks for error returns, so we send once per call */
#define SM_ERR_NOTS 0x00000001 /* No TS on channel */
@@ -67,6 +68,27 @@
static int mode_count;
static int mode_limit;
static int mask_pos;
+
+int chmode_flags[256];
+void
+construct_noparam_modes(void)
+{
+ int i;
+
+ for(i = 0; i < 256; i++)
+ {
+ if( (chmode_table[i].set_func == chm_simple) ||
+ (chmode_table[i].set_func == chm_staff) ||
+ (chmode_table[i].set_func == chm_regonly))
+ {
+ chmode_flags[i] = chmode_table[i].mode_type;
+ }
+ else
+ {
+ chmode_flags[i] = 0;
+ }
+ }
+}
int
get_channel_access(struct Client *source_p, struct membership *msptr)
diff -r e6b8fd0ebc1f src/ircd.c
--- a/src/ircd.c Tue Apr 08 16:14:01 2008 +0400
+++ b/src/ircd.c Tue Apr 08 17:28:26 2008 +0400
@@ -66,6 +66,7 @@
#include "patchlevel.h"
#include "serno.h"
#include "sslproc.h"
+#include "chmode.h"
/* /quote set variables */
struct SetOptions GlobalSetOptions;
@@ -594,6 +595,7 @@
init_client();
initUser();
init_hook();
+ construct_noparam_modes();
init_channels();
initclass();
initwhowas();

View File

@ -1071,25 +1071,6 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in
}
}
const struct mode_letter chmode_flags[] =
{
{MODE_INVITEONLY, 'i'},
{MODE_MODERATED, 'm'},
{MODE_NOPRIVMSGS, 'n'},
{MODE_PRIVATE, 'p'},
{MODE_SECRET, 's'},
{MODE_TOPICLIMIT, 't'},
{MODE_NOCOLOR, 'c'},
{MODE_FREEINVITE, 'g'},
{MODE_OPMODERATE, 'z'},
{MODE_EXLIMIT, 'L'},
{MODE_PERMANENT, 'P'},
{MODE_FREETARGET, 'F'},
{MODE_DISFORWARD, 'Q'},
{MODE_REGONLY, 'r'},
{0, '\0'}
};
/* channel_modes()
*
* inputs - pointer to channel
@ -1112,9 +1093,9 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
*mbuf++ = '+';
*pbuf = '\0';
for (i = 0; chmode_flags[i].mode; ++i)
if(chptr->mode.mode & chmode_flags[i].mode)
*mbuf++ = chmode_flags[i].letter;
for (i = 0; i < 256; i++)
if(chptr->mode.mode & chmode_flags[i])
*mbuf++ = i;
if(chptr->mode.limit)
{

View File

@ -62,6 +62,27 @@ static int mode_count;
static int mode_limit;
static int mask_pos;
int chmode_flags[256];
void
construct_noparam_modes(void)
{
int i;
for(i = 0; i < 256; i++)
{
if( (chmode_table[i].set_func == chm_simple) ||
(chmode_table[i].set_func == chm_staff) ||
(chmode_table[i].set_func == chm_regonly))
{
chmode_flags[i] = chmode_table[i].mode_type;
}
else
{
chmode_flags[i] = 0;
}
}
}
static int
get_channel_access(struct Client *source_p, struct membership *msptr)
{

View File

@ -64,6 +64,7 @@
#include "patchlevel.h"
#include "serno.h"
#include "sslproc.h"
#include "chmode.h"
/* /quote set variables */
struct SetOptions GlobalSetOptions;
@ -744,6 +745,7 @@ main(int argc, char *argv[])
rb_dlinkAddAlloc(&me, &global_serv_list);
construct_umodebuf();
construct_noparam_modes();
check_class();
write_pidfile(pidFileName);