static int cb_join(aClient *sptr, aChannel *chptr, char *parv[]) { aModeB *p = NULL; if (!can_join(sptr, sptr, chptr, NULL, NULL, parv)) /* test for operoverride or invite */ { return HOOK_CONTINUE; } if (chptr->mode.extmode & EXTCMODE_BANLINK) /* mode +B set? */ { if (is_banned(sptr, chptr, BANCHK_JOIN)) /* user is banned? */ { p = (aModeB *) extcmode_get_struct(chptr->mode.extmodeparam, 'B'); if (p && p->val) { sendto_one(sptr, ":%s 470 %s %s (you are banned) transferring you to %s", me.name, sptr->name, chptr->chname, p->val); parv[0] = sptr->name; parv[1] = p->val; do_join(sptr, sptr, 2, parv); return HOOK_DENY; } } } return HOOK_CONTINUE; }
/* * write the "simple" list of channel modes for channel chptr onto buffer mbuf * with the parameters in pbuf. */ void channel_modes(aClient *cptr, char *mbuf, char *pbuf, aChannel *chptr) { aCtab *tab = &cFlagTab[0]; char bcbuf[1024]; int ismember; #ifdef EXTCMODE int i; #endif ismember = (IsMember(cptr, chptr) || IsServer(cptr) || IsULine(cptr)) ? 1 : 0; *pbuf = '\0'; *mbuf++ = '+'; /* Paramless first */ while (tab->mode != 0x0) { if ((chptr->mode.mode & tab->mode)) if (!tab->parameters) *mbuf++ = tab->flag; tab++; } #ifdef EXTCMODE for (i=0; i <= Channelmode_highest; i++) { if (Channelmode_Table[i].flag && !Channelmode_Table[i].paracount && (chptr->mode.extmode & Channelmode_Table[i].mode)) *mbuf++ = Channelmode_Table[i].flag; } #endif if (chptr->mode.limit) { *mbuf++ = 'l'; if (ismember) (void)ircsprintf(pbuf, "%d ", chptr->mode.limit); } if (*chptr->mode.key) { *mbuf++ = 'k'; if (ismember) { /* FIXME: hope pbuf is long enough */ (void)snprintf(bcbuf, sizeof bcbuf, "%s ", chptr->mode.key); (void)strcat(pbuf, bcbuf); } } if (*chptr->mode.link) { *mbuf++ = 'L'; if (ismember) { /* FIXME: is pbuf long enough? */ (void)snprintf(bcbuf, sizeof bcbuf, "%s ", chptr->mode.link); (void)strcat(pbuf, bcbuf); } } /* if we add more parameter modes, add a space to the strings here --Stskeeps */ #ifdef NEWCHFLOODPROT if (chptr->mode.floodprot) #else if (chptr->mode.per) #endif { *mbuf++ = 'f'; if (ismember) { #ifdef NEWCHFLOODPROT ircsprintf(bcbuf, "%s ", channel_modef_string(chptr->mode.floodprot)); #else if (chptr->mode.kmode == 1) ircsprintf(bcbuf, "*%i:%i ", chptr->mode.msgs, chptr->mode.per); else ircsprintf(bcbuf, "%i:%i ", chptr->mode.msgs, chptr->mode.per); #endif (void)strcat(pbuf, bcbuf); } } #ifdef EXTCMODE for (i=0; i <= Channelmode_highest; i++) { if (Channelmode_Table[i].flag && Channelmode_Table[i].paracount && (chptr->mode.extmode & Channelmode_Table[i].mode)) { *mbuf++ = Channelmode_Table[i].flag; if (ismember) { strcat(pbuf, Channelmode_Table[i].get_param(extcmode_get_struct(chptr->mode.extmodeparam, Channelmode_Table[i].flag))); strcat(pbuf, " "); } } } #endif /* Remove the trailing space from the parameters -- codemastr */ if (*pbuf) pbuf[strlen(pbuf)-1]=0; *mbuf++ = '\0'; return; }
/* * write the "simple" list of channel modes for channel chptr onto buffer mbuf * with the parameters in pbuf. */ void channel_modes(aClient *cptr, char *mbuf, char *pbuf, size_t mbuf_size, size_t pbuf_size, aChannel *chptr) { aCtab *tab = &cFlagTab[0]; char bcbuf[1024]; int ismember; int i; if (!(mbuf_size && pbuf_size)) return; ismember = (IsMember(cptr, chptr) || IsServer(cptr) || IsULine(cptr)) ? 1 : 0; *pbuf = '\0'; *mbuf++ = '+'; mbuf_size--; /* Paramless first */ while (mbuf_size && tab->mode != 0x0) { if ((chptr->mode.mode & tab->mode)) if (!tab->parameters) { *mbuf++ = tab->flag; mbuf_size--; } tab++; } for (i=0; i <= Channelmode_highest; i++) { if (!mbuf_size) break; if (Channelmode_Table[i].flag && !Channelmode_Table[i].paracount && (chptr->mode.extmode & Channelmode_Table[i].mode)) { *mbuf++ = Channelmode_Table[i].flag; mbuf_size--; } } if (chptr->mode.limit) { if (mbuf_size) { *mbuf++ = 'l'; mbuf_size--; } if (ismember) { ircsnprintf(pbuf, pbuf_size, "%d ", chptr->mode.limit); pbuf_size-=strlen(pbuf); pbuf+=strlen(pbuf); } } if (*chptr->mode.key) { if (mbuf_size) { *mbuf++ = 'k'; mbuf_size--; } if (ismember && pbuf_size) { ircsnprintf(pbuf, pbuf_size, "%s ", chptr->mode.key); pbuf_size-=strlen(pbuf); pbuf+=strlen(pbuf); } } if (*chptr->mode.link) { if (mbuf_size) { *mbuf++ = 'L'; mbuf_size--; } if (ismember && pbuf_size) { ircsnprintf(pbuf, pbuf_size, "%s ", chptr->mode.link); pbuf_size-=strlen(pbuf); pbuf+=strlen(pbuf); } } /* if we add more parameter modes, add a space to the strings here --Stskeeps */ if (chptr->mode.floodprot) { if (mbuf_size) { *mbuf++ = 'f'; mbuf_size--; } if (ismember && pbuf_size) { ircsnprintf(pbuf, pbuf_size, "%s ", channel_modef_string(chptr->mode.floodprot)); pbuf_size-=strlen(pbuf); pbuf+=strlen(pbuf); } } for (i=0; i <= Channelmode_highest; i++) { if (Channelmode_Table[i].flag && Channelmode_Table[i].paracount && (chptr->mode.extmode & Channelmode_Table[i].mode)) { if (mbuf_size) { *mbuf++ = Channelmode_Table[i].flag; mbuf_size--; } if (ismember) { ircsnprintf(pbuf, pbuf_size, "%s ", Channelmode_Table[i].get_param(extcmode_get_struct(chptr->mode.extmodeparam, Channelmode_Table[i].flag))); pbuf_size-=strlen(pbuf); pbuf+=strlen(pbuf); } } } /* Remove the trailing space from the parameters -- codemastr */ if (*pbuf) pbuf[strlen(pbuf)-1]=0; if (!mbuf_size) mbuf--; *mbuf++ = '\0'; return; }