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 9bec26cc38
commit c18cb68b91
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 find_orphaned_cflags(void);
extern unsigned int find_cflag_slot(void);
extern char cflagsbuf[256];
extern char cflagsmyinfo[256];
#endif

View file

@ -65,14 +65,22 @@ static int mode_limit;
static int mode_limit_simple;
static int mask_pos;
char cflagsbuf[256];
char cflagsmyinfo[256];
int chmode_flags[256];
/* OPTIMIZE ME! -- dwr */
void
construct_noparam_modes(void)
{
int i;
char *ptr = cflagsbuf;
char *ptr2 = cflagsmyinfo;
static int prev_chmode_flags[256];
*ptr = '\0';
*ptr2 = '\0';
for(i = 0; i < 256; i++)
{
if( !(chmode_table[i].set_func == chm_ban) &&
@ -105,7 +113,40 @@ construct_noparam_modes(void)
}
else
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",
/* 002 RPL_YOURHOST,*/ ":Your host is %s, running version %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",
/* 006 */ NULL,
/* 007 */ NULL,

View file

@ -53,6 +53,7 @@
#include "snomask.h"
#include "blacklist.h"
#include "substitution.h"
#include "chmode.h"
static void report_and_set_user_flags(struct Client *, struct ConfItem *);
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),
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_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);

View file

@ -87,6 +87,7 @@
#include "ircd.h"
#include "s_conf.h"
#include "supported.h"
#include "chmode.h"
rb_dlink_list isupportlist;
@ -209,12 +210,11 @@ isupport_chanmodes(const void *ptr)
{
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_invex ? "I" : "",
ConfigChannel.use_forward ? "f" : "",
rb_dlink_list_length(&service_list) ? "r" : "",
ConfigChannel.use_forward ? "QF" : "");
cflagsbuf);
return result;
}