Added diffs/ directory for various patches/diffs with the features which are unuseful at this moment, but could be used later, added dyn-cmodes diff there

This commit is contained in:
Valery Yatsko 2008-04-08 21:10:23 +04:00
parent 20961eeada
commit b865be9e33
1 changed files with 284 additions and 0 deletions

284
diffs/dyn-cmodes.diff Normal file
View File

@ -0,0 +1,284 @@
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 include/chmode.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/chmode.h Tue Apr 08 17:28:26 2008 +0400
@@ -0,0 +1,67 @@
+/*
+ * charybdis: An advanced ircd.
+ * chmode.h: The ircd channel header.
+ *
+ * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
+ * Copyright (C) 1996-2002 Hybrid Development Team
+ * Copyright (C) 2002-2004 ircd-ratbox development team
+ * Copyright (C) 2008 charybdis development team
+ *
+ * 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * $Id$
+ */
+
+#ifndef INCLUDED_chmode_h
+#define INCLUDED_chmode_h
+
+extern void chm_nosuch(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 chm_simple(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 chm_ban(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 chm_staff(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 chm_forward(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 chm_throttle(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 chm_key(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 chm_limit(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 chm_regonly(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 chm_op(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 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
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();