Generating cflags bufs dynamically: one for RPL_MYINFO and one for

supported.c
This commit is contained in:
Valery V Yatsko 2008-06-25 07:51:32 +04:00
parent 57d299acbd
commit 2392eb24cd
5 changed files with 49 additions and 5 deletions

View File

@ -68,5 +68,7 @@ extern void chm_voice(struct Client *source_p, struct Channel *chptr,
extern void construct_noparam_modes(void); extern void construct_noparam_modes(void);
extern void find_orphaned_cflags(void); extern void find_orphaned_cflags(void);
extern unsigned int find_cflag_slot(void); extern unsigned int find_cflag_slot(void);
extern char cflagsbuf[256];
extern char cflagsmyinfo[256];
#endif #endif

View File

@ -65,14 +65,22 @@ static int mode_limit;
static int mode_limit_simple; static int mode_limit_simple;
static int mask_pos; static int mask_pos;
char cflagsbuf[256];
char cflagsmyinfo[256];
int chmode_flags[256]; int chmode_flags[256];
/* OPTIMIZE ME! -- dwr */ /* OPTIMIZE ME! -- dwr */
void void
construct_noparam_modes(void) construct_noparam_modes(void)
{ {
int i; int i;
char *ptr = cflagsbuf;
char *ptr2 = cflagsmyinfo;
static int prev_chmode_flags[256]; static int prev_chmode_flags[256];
*ptr = '\0';
*ptr2 = '\0';
for(i = 0; i < 256; i++) for(i = 0; i < 256; i++)
{ {
if( !(chmode_table[i].set_func == chm_ban) && if( !(chmode_table[i].set_func == chm_ban) &&
@ -105,7 +113,40 @@ construct_noparam_modes(void)
} }
else else
prev_chmode_flags[i] = chmode_flags[i]; prev_chmode_flags[i] = chmode_flags[i];
switch (chmode_flags[i])
{
case MODE_EXLIMIT:
case MODE_DISFORWARD:
if(ConfigChannel.use_forward)
{
*ptr++ = (char) i;
}
break;
case MODE_REGONLY:
if(rb_dlink_list_length(&service_list))
{
*ptr++ = (char) i;
}
break;
default:
if(chmode_flags[i] != 0)
{
*ptr++ = (char) i;
}
}
/* Should we leave orphaned check here? -- dwr */
if(!(chmode_table[i].set_func == chm_nosuch) && !(chmode_table[i].set_func == chm_orphaned))
{
*ptr2++ = (char) i;
}
} }
*ptr++ = '\0';
*ptr2++ = '\0';
} }
/* /*

View File

@ -24,7 +24,7 @@ static const char * replies[] = {
/* 001 RPL_WELCOME, */ ":Welcome to the %s Internet Relay Chat Network %s", /* 001 RPL_WELCOME, */ ":Welcome to the %s Internet Relay Chat Network %s",
/* 002 RPL_YOURHOST,*/ ":Your host is %s, running version %s", /* 002 RPL_YOURHOST,*/ ":Your host is %s, running version %s",
/* 003 RPL_CREATED, */ ":This server was created %s", /* 003 RPL_CREATED, */ ":This server was created %s",
/* 004 RPL_MYINFO, */ "%s %s %s biklmnopstveqrcgzjfILPQF bkloveqjfI", /* 004 RPL_MYINFO, */ "%s %s %s %s bkloveqjfI",
/* 005 RPL_ISUPPORT, */ "%s :are supported by this server", /* 005 RPL_ISUPPORT, */ "%s :are supported by this server",
/* 006 */ NULL, /* 006 */ NULL,
/* 007 */ NULL, /* 007 */ NULL,

View File

@ -53,6 +53,7 @@
#include "snomask.h" #include "snomask.h"
#include "blacklist.h" #include "blacklist.h"
#include "substitution.h" #include "substitution.h"
#include "chmode.h"
static void report_and_set_user_flags(struct Client *, struct ConfItem *); static void report_and_set_user_flags(struct Client *, struct ConfItem *);
void user_welcome(struct Client *source_p); void user_welcome(struct Client *source_p);
@ -1187,7 +1188,7 @@ user_welcome(struct Client *source_p)
sendto_one_numeric(source_p, RPL_YOURHOST, form_str(RPL_YOURHOST), sendto_one_numeric(source_p, RPL_YOURHOST, form_str(RPL_YOURHOST),
get_listener_name(source_p->localClient->listener), ircd_version); get_listener_name(source_p->localClient->listener), ircd_version);
sendto_one_numeric(source_p, RPL_CREATED, form_str(RPL_CREATED), creation); sendto_one_numeric(source_p, RPL_CREATED, form_str(RPL_CREATED), creation);
sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, ircd_version, umodebuf); sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, ircd_version, umodebuf, cflagsmyinfo);
show_isupport(source_p); show_isupport(source_p);

View File

@ -87,6 +87,7 @@
#include "ircd.h" #include "ircd.h"
#include "s_conf.h" #include "s_conf.h"
#include "supported.h" #include "supported.h"
#include "chmode.h"
rb_dlink_list isupportlist; rb_dlink_list isupportlist;
@ -209,12 +210,11 @@ isupport_chanmodes(const void *ptr)
{ {
static char result[80]; static char result[80];
rb_snprintf(result, sizeof result, "%s%sbq,k,%slj,imnpst%scgzLP%s", rb_snprintf(result, sizeof result, "%s%sbq,k,%slj,%s",
ConfigChannel.use_except ? "e" : "", ConfigChannel.use_except ? "e" : "",
ConfigChannel.use_invex ? "I" : "", ConfigChannel.use_invex ? "I" : "",
ConfigChannel.use_forward ? "f" : "", ConfigChannel.use_forward ? "f" : "",
rb_dlink_list_length(&service_list) ? "r" : "", cflagsbuf);
ConfigChannel.use_forward ? "QF" : "");
return result; return result;
} }