Rename channel_modes() to channel_modes_real(), and use macros to build both the mode list, and the mlock list.

This commit is contained in:
William Pitcock 2010-03-07 22:22:14 -06:00
parent d09bb8aeb0
commit a51c452643
2 changed files with 16 additions and 13 deletions

View file

@ -238,7 +238,9 @@ extern void channel_member_names(struct Channel *chptr, struct Client *,
extern void del_invite(struct Channel *chptr, struct Client *who); extern void del_invite(struct Channel *chptr, struct Client *who);
const char *channel_modes(struct Channel *chptr, struct Client *who); const char *channel_modes_real(struct Channel *chptr, struct Mode *mode, struct Client *who);
#define channel_modes(chptr, who) channel_modes_real(chptr, &(chptr)->mode, who)
#define channel_mlock(chptr, who) channel_modes_real(chptr, &(chptr)->mode_lock, who)
extern struct Channel *find_bannickchange_channel(struct Client *client_p); extern struct Channel *find_bannickchange_channel(struct Client *client_p);

View file

@ -1073,9 +1073,10 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in
} }
} }
/* channel_modes() /* channel_modes_real()
* *
* inputs - pointer to channel * inputs - pointer to channel
* - pointer to channel Mode struct
* - pointer to client * - pointer to client
* output - string with simple modes * output - string with simple modes
* side effects - result from previous calls overwritten * side effects - result from previous calls overwritten
@ -1083,7 +1084,7 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in
* Stolen from ShadowIRCd 4 --nenolod * Stolen from ShadowIRCd 4 --nenolod
*/ */
const char * const char *
channel_modes(struct Channel *chptr, struct Client *client_p) channel_modes_real(struct Channel *chptr, struct Mode *mode, struct Client *client_p)
{ {
int i; int i;
char buf1[BUFSIZE]; char buf1[BUFSIZE];
@ -1096,40 +1097,40 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
*pbuf = '\0'; *pbuf = '\0';
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
if(chptr->mode.mode & chmode_flags[i]) if(mode->mode & chmode_flags[i])
*mbuf++ = i; *mbuf++ = i;
if(chptr->mode.limit) if(mode->limit)
{ {
*mbuf++ = 'l'; *mbuf++ = 'l';
if(!IsClient(client_p) || IsMember(client_p, chptr)) if(!IsClient(client_p) || IsMember(client_p, chptr))
pbuf += rb_sprintf(pbuf, " %d", chptr->mode.limit); pbuf += rb_sprintf(pbuf, " %d", mode->limit);
} }
if(*chptr->mode.key) if(*mode->key)
{ {
*mbuf++ = 'k'; *mbuf++ = 'k';
if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr)) if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
pbuf += rb_sprintf(pbuf, " %s", chptr->mode.key); pbuf += rb_sprintf(pbuf, " %s", mode->key);
} }
if(chptr->mode.join_num) if(mode->join_num)
{ {
*mbuf++ = 'j'; *mbuf++ = 'j';
if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr)) if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
pbuf += rb_sprintf(pbuf, " %d:%d", chptr->mode.join_num, pbuf += rb_sprintf(pbuf, " %d:%d", mode->join_num,
chptr->mode.join_time); mode->oin_time);
} }
if(*chptr->mode.forward && (ConfigChannel.use_forward || !IsClient(client_p))) if(*mode->forward && (ConfigChannel.use_forward || !IsClient(client_p)))
{ {
*mbuf++ = 'f'; *mbuf++ = 'f';
if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr)) if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
pbuf += rb_sprintf(pbuf, " %s", chptr->mode.forward); pbuf += rb_sprintf(pbuf, " %s", mode->forward);
} }
*mbuf = '\0'; *mbuf = '\0';