2 * ircd-ratbox: A slightly useful ircd.
3 * m_join.c: Joins a channel.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
37 #include "s_newconf.h"
44 static int m_join(struct Client
*, struct Client
*, int, const char **);
45 static int me_svsjoin(struct Client
*, struct Client
*, int, const char **);
46 static int ms_join(struct Client
*, struct Client
*, int, const char **);
47 static int ms_sjoin(struct Client
*, struct Client
*, int, const char **);
49 struct Message join_msgtab
= {
50 "JOIN", 0, 0, 0, MFLG_SLOW
,
51 {mg_unreg
, {m_join
, 2}, {ms_join
, 2}, mg_ignore
, mg_ignore
, {m_join
, 2}}
54 struct Message svsjoin_msgtab
= {
55 "SVSJOIN", 0, 0, 0, MFLG_SLOW
,
56 {mg_ignore
, mg_ignore
, mg_ignore
, mg_ignore
, {me_svsjoin
, 3}, mg_ignore
}
59 struct Message sjoin_msgtab
= {
60 "SJOIN", 0, 0, 0, MFLG_SLOW
,
61 {mg_unreg
, mg_ignore
, mg_ignore
, {ms_sjoin
, 4}, mg_ignore
, mg_ignore
}
64 mapi_clist_av1 join_clist
[] = { &join_msgtab
, &svsjoin_msgtab
, &sjoin_msgtab
, NULL
};
66 DECLARE_MODULE_AV1(join
, NULL
, NULL
, join_clist
, NULL
, NULL
, "$Revision: 3494 $");
68 static void set_final_mode(struct Mode
*mode
, struct Mode
*oldmode
);
69 static void remove_our_modes(struct Channel
*chptr
, struct Client
*source_p
);
71 static void remove_ban_list(struct Channel
*chptr
, struct Client
*source_p
,
72 rb_dlink_list
* list
, char c
, int mems
);
74 static char modebuf
[MODEBUFLEN
];
75 static char omodebuf
[MODEBUFLEN
];
76 static char parabuf
[MODEBUFLEN
];
77 static const char *para
[MAXMODEPARAMS
];
78 static char *mbuf
, *ombuf
;
84 * parv[2] = channel password (key)
87 m_join(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
89 user_join(client_p
, source_p
, parv
[1], parc
> 2 ? parv
[2] : NULL
); /* channel.c */
95 * me_svsjoin - small function to allow services to forcejoin clients, mainly for ns_ajoin
96 * parv[1] = user to act on (join to a channel)
98 * This does allow opers to "forcejoin" users to channels with operserv/raw or by writing a
99 * custom module (where they can make it not log anything), but the former bitches that it's
100 * being used and the latter...Can probably be done anyway with enough hackyness if this
101 * command didn't exist so it's not all that bad.
104 me_svsjoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
106 struct Client
*target_p
;
108 if(!(source_p
->flags
& FLAGS_SERVICE
))
111 if((target_p
= find_person(parv
[1])) == NULL
)
114 if(!MyClient(target_p
))
117 user_join(&me
, target_p
, parv
[2], NULL
);
123 * parv[1] = channel TS
125 * parv[3] = "+", formerly channel modes but now unused
126 * alternatively, a single "0" parameter parts all channels
129 ms_join(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
131 struct Channel
*chptr
;
132 static struct Mode mode
;
136 int keep_our_modes
= YES
;
137 int keep_new_modes
= YES
;
138 rb_dlink_node
*ptr
, *next_ptr
;
140 /* special case for join 0 */
141 if((parv
[1][0] == '0') && (parv
[1][1] == '\0') && parc
== 2)
143 do_join_0(client_p
, source_p
);
150 if(!IsChannelName(parv
[2]) || !check_channel_name(parv
[2]))
153 /* joins for local channels cant happen. */
154 if(parv
[2][0] == '&')
159 mode
.key
[0] = mode
.forward
[0] = '\0';
160 mode
.mode
= mode
.limit
= mode
.join_num
= mode
.join_time
= 0;
162 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
165 newts
= atol(parv
[1]);
166 oldts
= chptr
->channelts
;
168 #ifdef IGNORE_BOGUS_TS
169 if(newts
< 800000000)
171 sendto_realops_snomask(SNO_DEBUG
, L_ALL
,
172 "*** Bogus TS %ld on %s ignored from %s",
173 (long) newts
, chptr
->chname
, client_p
->name
);
174 newts
= (oldts
== 0) ? oldts
: 800000000;
177 /* making a channel TS0 */
178 if(!isnew
&& !newts
&& oldts
)
180 sendto_channel_local(ALL_MEMBERS
, chptr
,
181 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to 0",
182 me
.name
, chptr
->chname
, chptr
->chname
, (long) oldts
);
183 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
184 "Server %s changing TS on %s from %ld to 0",
185 source_p
->name
, chptr
->chname
, (long) oldts
);
190 chptr
->channelts
= newts
;
191 else if(newts
== 0 || oldts
== 0)
192 chptr
->channelts
= 0;
193 else if(newts
== oldts
)
195 else if(newts
< oldts
)
198 chptr
->channelts
= newts
;
203 /* Lost the TS, other side wins, so remove modes on this side */
206 set_final_mode(&mode
, &chptr
->mode
);
208 remove_our_modes(chptr
, source_p
);
209 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->invites
.head
)
211 del_invite(chptr
, ptr
->data
);
213 /* If setting -j, clear join throttle state -- jilles */
214 chptr
->join_count
= chptr
->join_delta
= 0;
215 sendto_channel_local(ALL_MEMBERS
, chptr
,
216 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld",
217 me
.name
, chptr
->chname
, chptr
->chname
,
218 (long) oldts
, (long) newts
);
219 /* Update capitalization in channel name, this makes the
220 * capitalization timestamped like modes are -- jilles */
221 strcpy(chptr
->chname
, parv
[2]);
223 sendto_channel_local(ALL_MEMBERS
, chptr
,
225 source_p
->servptr
->name
,
226 chptr
->chname
, modebuf
, parabuf
);
227 if(*omodebuf
!= '\0')
228 sendto_channel_local(ONLY_OPERS
, chptr
,
230 source_p
->servptr
->name
,
231 chptr
->chname
, modebuf
, parabuf
);
232 *omodebuf
= *modebuf
= *parabuf
= '\0';
234 /* since we're dropping our modes, we want to clear the mlock as well. --nenolod */
235 set_channel_mlock(client_p
, source_p
, chptr
, NULL
, FALSE
);
238 if(!IsMember(source_p
, chptr
))
240 add_user_to_channel(chptr
, source_p
, CHFL_PEON
);
241 if (chptr
->mode
.join_num
&&
242 rb_current_time() - chptr
->join_delta
>= chptr
->mode
.join_time
)
244 chptr
->join_count
= 0;
245 chptr
->join_delta
= rb_current_time();
248 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN :%s",
249 source_p
->name
, source_p
->username
,
250 source_p
->host
, chptr
->chname
);
253 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
255 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
);
260 ms_sjoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
262 static char buf_uid
[BUFSIZE
];
263 static const char empty_modes
[] = "0";
264 struct Channel
*chptr
;
265 struct Client
*target_p
, *fakesource_p
;
268 static struct Mode mode
, *oldmode
;
271 int keep_our_modes
= 1;
272 int keep_new_modes
= 1;
283 int i
, joinc
= 0, timeslice
= 0;
284 static char empty
[] = "";
285 rb_dlink_node
*ptr
, *next_ptr
;
287 if(!IsChannelName(parv
[2]) || !check_channel_name(parv
[2]))
290 /* SJOIN's for local channels can't happen. */
294 omodebuf
[0] = modebuf
[0] = parabuf
[0] = mode
.key
[0] = mode
.forward
[0] = '\0';
295 pargs
= mode
.mode
= mode
.limit
= mode
.join_num
= mode
.join_time
= 0;
297 /* Hide connecting server on netburst -- jilles */
298 if (ConfigServerHide
.flatten_links
&& !HasSentEob(source_p
))
301 fakesource_p
= source_p
;
305 newts
= atol(parv
[1]);
313 rb_strlcpy(mode
.forward
, parv
[4 + args
], sizeof(mode
.forward
));
319 sscanf(parv
[4 + args
], "%d:%d", &joinc
, ×lice
);
321 mode
.join_num
= joinc
;
322 mode
.join_time
= timeslice
;
327 rb_strlcpy(mode
.key
, parv
[4 + args
], sizeof(mode
.key
));
333 mode
.limit
= atoi(parv
[4 + args
]);
339 if(chmode_flags
[(int) *s
] != 0)
341 mode
.mode
|= chmode_flags
[(int) *s
];
350 /* remove any leading spaces */
357 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
358 return 0; /* channel name too long? */
361 oldts
= chptr
->channelts
;
362 oldmode
= &chptr
->mode
;
364 #ifdef IGNORE_BOGUS_TS
365 if(newts
< 800000000)
367 sendto_realops_snomask(SNO_DEBUG
, L_ALL
,
368 "*** Bogus TS %ld on %s ignored from %s",
369 (long) newts
, chptr
->chname
, client_p
->name
);
371 newts
= (oldts
== 0) ? oldts
: 800000000;
374 if(!isnew
&& !newts
&& oldts
)
376 sendto_channel_local(ALL_MEMBERS
, chptr
,
377 ":%s NOTICE %s :*** Notice -- TS for %s "
378 "changed from %ld to 0",
379 me
.name
, chptr
->chname
, chptr
->chname
, (long) oldts
);
380 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
381 "Server %s changing TS on %s from %ld to 0",
382 source_p
->name
, chptr
->chname
, (long) oldts
);
387 chptr
->channelts
= newts
;
389 else if(newts
== 0 || oldts
== 0)
390 chptr
->channelts
= 0;
391 else if(newts
== oldts
)
393 else if(newts
< oldts
)
395 /* If configured, kick people trying to join +i/+k
396 * channels by recreating them on split servers.
397 * Don't kick if the source has sent EOB (services
398 * deopping everyone by TS-1 SJOIN).
400 if (ConfigChannel
.kick_on_split_riding
&&
401 !HasSentEob(source_p
) &&
402 ((mode
.mode
& MODE_INVITEONLY
) ||
403 (mode
.key
[0] != 0 && irccmp(mode
.key
, oldmode
->key
) != 0)))
405 struct membership
*msptr
;
407 int l
= rb_dlink_list_length(&chptr
->members
);
409 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->locmembers
.head
)
412 who
= msptr
->client_p
;
413 sendto_one(who
, ":%s KICK %s %s :Net Rider",
414 me
.name
, chptr
->chname
, who
->name
);
416 sendto_server(NULL
, chptr
, CAP_TS6
, NOCAPS
,
417 ":%s KICK %s %s :Net Rider",
418 me
.id
, chptr
->chname
,
420 remove_user_from_channel(msptr
);
426 /* Channel was emptied, create a new one */
427 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
428 return 0; /* oops! */
430 oldmode
= &chptr
->mode
;
434 chptr
->channelts
= newts
;
441 else if(keep_our_modes
)
443 mode
.mode
|= oldmode
->mode
;
444 if(oldmode
->limit
> mode
.limit
)
445 mode
.limit
= oldmode
->limit
;
446 if(strcmp(mode
.key
, oldmode
->key
) < 0)
447 strcpy(mode
.key
, oldmode
->key
);
448 if(oldmode
->join_num
> mode
.join_num
||
449 (oldmode
->join_num
== mode
.join_num
&&
450 oldmode
->join_time
> mode
.join_time
))
452 mode
.join_num
= oldmode
->join_num
;
453 mode
.join_time
= oldmode
->join_time
;
455 if(irccmp(mode
.forward
, oldmode
->forward
) < 0)
456 strcpy(mode
.forward
, oldmode
->forward
);
460 /* If setting -j, clear join throttle state -- jilles */
462 chptr
->join_count
= chptr
->join_delta
= 0;
465 set_final_mode(&mode
, oldmode
);
468 /* Lost the TS, other side wins, so remove modes on this side */
471 remove_our_modes(chptr
, fakesource_p
);
472 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->invites
.head
)
474 del_invite(chptr
, ptr
->data
);
477 if(rb_dlink_list_length(&chptr
->banlist
) > 0)
478 remove_ban_list(chptr
, fakesource_p
, &chptr
->banlist
, 'b', ALL_MEMBERS
);
479 if(rb_dlink_list_length(&chptr
->exceptlist
) > 0)
480 remove_ban_list(chptr
, fakesource_p
, &chptr
->exceptlist
,
482 if(rb_dlink_list_length(&chptr
->invexlist
) > 0)
483 remove_ban_list(chptr
, fakesource_p
, &chptr
->invexlist
,
485 if(rb_dlink_list_length(&chptr
->quietlist
) > 0)
486 remove_ban_list(chptr
, fakesource_p
, &chptr
->quietlist
,
490 sendto_channel_local(ALL_MEMBERS
, chptr
,
491 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld",
492 me
.name
, chptr
->chname
, chptr
->chname
,
493 (long) oldts
, (long) newts
);
494 /* Update capitalization in channel name, this makes the
495 * capitalization timestamped like modes are -- jilles */
496 strcpy(chptr
->chname
, parv
[2]);
498 /* since we're dropping our modes, we want to clear the mlock as well. --nenolod */
499 set_channel_mlock(client_p
, source_p
, chptr
, NULL
, FALSE
);
503 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s MODE %s %s %s",
504 fakesource_p
->name
, chptr
->chname
, modebuf
, parabuf
);
506 if(*omodebuf
!= '\0')
507 sendto_channel_local(ONLY_OPERS
, chptr
, ":%s MODE %s %s %s",
508 fakesource_p
->name
, chptr
->chname
, omodebuf
, parabuf
);
510 *omodebuf
= *modebuf
= *parabuf
= '\0';
512 if(parv
[3][0] != '0' && keep_new_modes
)
513 modes
= channel_modes(chptr
, source_p
);
517 mlen_uid
= rb_sprintf(buf_uid
, ":%s SJOIN %ld %s %s :",
518 use_id(source_p
), (long) chptr
->channelts
, parv
[2], modes
);
519 ptr_uid
= buf_uid
+ mlen_uid
;
523 para
[0] = para
[1] = para
[2] = para
[3] = empty
;
525 len_nick
= len_uid
= 0;
527 /* if theres a space, theres going to be more than one nick, change the
528 * first space to \0, so s is just the first nick, and point p to the
531 if((p
= strchr(s
, ' ')) != NULL
)
542 for (i
= 0; i
< 4; i
++)
566 /* if the client doesnt exist or is fake direction, skip. */
567 if(!(target_p
= find_client(s
)) ||
568 (target_p
->from
!= client_p
) || !IsPerson(target_p
))
571 /* we assume for these we can fit at least one nick/uid in.. */
573 /* check we can fit another status+nick+space into a buffer */
574 if((mlen_uid
+ len_uid
+ IDLEN
+ 3) > (BUFSIZE
- 3))
576 *(ptr_uid
- 1) = '\0';
577 sendto_server(client_p
->from
, NULL
, CAP_TS6
, NOCAPS
, "%s", buf_uid
);
578 ptr_uid
= buf_uid
+ mlen_uid
;
610 /* copy the nick to the two buffers */
611 len
= rb_sprintf(ptr_uid
, "%s ", use_id(target_p
));
618 if(!IsMember(target_p
, chptr
))
620 add_user_to_channel(chptr
, target_p
, fl
);
621 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN :%s",
623 target_p
->username
, target_p
->host
, parv
[2]);
627 /* If anyone can think of a way to do this that doesn't make babies cry
628 * I would love to hear it - Taros */
633 para
[pargs
++] = target_p
->name
;
637 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
640 if(pargs
>= MAXMODEPARAMS
)
643 sendto_channel_local(ALL_MEMBERS
, chptr
,
644 ":%s MODE %s %s %s %s %s %s",
645 fakesource_p
->name
, chptr
->chname
,
647 para
[0], para
[1], para
[2], para
[3]);
650 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
655 para
[pargs
++] = target_p
->name
;
659 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
662 if(pargs
>= MAXMODEPARAMS
)
665 sendto_channel_local(ALL_MEMBERS
, chptr
,
666 ":%s MODE %s %s %s %s %s %s",
667 fakesource_p
->name
, chptr
->chname
,
669 para
[0], para
[1], para
[2], para
[3]);
672 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
677 para
[pargs
++] = target_p
->name
;
681 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
684 if(pargs
>= MAXMODEPARAMS
)
687 sendto_channel_local(ALL_MEMBERS
, chptr
,
688 ":%s MODE %s %s %s %s %s %s",
689 fakesource_p
->name
, chptr
->chname
,
691 para
[0], para
[1], para
[2], para
[3]);
694 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
699 para
[pargs
++] = target_p
->name
;
702 else if(fl
& CHFL_CHANOP
)
705 para
[pargs
++] = target_p
->name
;
709 /* its possible the +o has filled up MAXMODEPARAMS, if so, start
712 if(pargs
>= MAXMODEPARAMS
)
715 sendto_channel_local(ALL_MEMBERS
, chptr
,
716 ":%s MODE %s %s %s %s %s %s",
717 fakesource_p
->name
, chptr
->chname
,
719 para
[0], para
[1], para
[2], para
[3]);
722 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
727 para
[pargs
++] = target_p
->name
;
731 /* its possible the +o has filled up MAXMODEPARAMS, if so, start
734 if(pargs
>= MAXMODEPARAMS
)
737 sendto_channel_local(ALL_MEMBERS
, chptr
,
738 ":%s MODE %s %s %s %s %s %s",
739 fakesource_p
->name
, chptr
->chname
,
741 para
[0], para
[1], para
[2], para
[3]);
744 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
749 para
[pargs
++] = target_p
->name
;
752 else if(fl
& CHFL_HALFOP
)
755 para
[pargs
++] = target_p
->name
;
759 /* its possible the +h has filled up MAXMODEPARAMS, if so, start
762 if(pargs
>= MAXMODEPARAMS
)
765 sendto_channel_local(ALL_MEMBERS
, chptr
,
766 ":%s MODE %s %s %s %s %s %s",
767 fakesource_p
->name
, chptr
->chname
,
769 para
[0], para
[1], para
[2], para
[3]);
772 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
777 para
[pargs
++] = target_p
->name
;
780 else if(fl
& CHFL_VOICE
)
783 para
[pargs
++] = target_p
->name
;
786 if(pargs
>= MAXMODEPARAMS
)
789 sendto_channel_local(ALL_MEMBERS
, chptr
,
790 ":%s MODE %s %s %s %s %s %s",
793 modebuf
, para
[0], para
[1], para
[2], para
[3]);
796 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
801 /* p points to the next nick */
804 /* if there was a trailing space and p was pointing to it, then we
805 * need to exit.. this has the side effect of breaking double spaces
806 * in an sjoin.. but that shouldnt happen anyway
808 if(s
&& (*s
== '\0'))
811 /* if p was NULL due to no spaces, s wont exist due to the above, so
812 * we cant check it for spaces.. if there are no spaces, then when
813 * we next get here, s will be NULL
815 if(s
&& ((p
= strchr(s
, ' ')) != NULL
))
824 sendto_channel_local(ALL_MEMBERS
, chptr
,
825 ":%s MODE %s %s %s %s %s %s",
826 fakesource_p
->name
, chptr
->chname
, modebuf
,
827 para
[0], CheckEmpty(para
[1]),
828 CheckEmpty(para
[2]), CheckEmpty(para
[3]));
831 if(!joins
&& !(chptr
->mode
.mode
& MODE_PERMANENT
) && isnew
)
833 destroy_channel(chptr
);
838 /* Keep the colon if we're sending an SJOIN without nicks -- jilles */
841 *(ptr_uid
- 1) = '\0';
844 sendto_server(client_p
->from
, NULL
, CAP_TS6
, NOCAPS
, "%s", buf_uid
);
851 set_final_mode(struct Mode
*mode
, struct Mode
*oldmode
)
853 int dir
= MODE_QUERY
, odir
= MODE_QUERY
;
854 char *pbuf
= parabuf
;
858 /* ok, first get a list of modes we need to add */
859 for (i
= 0; i
< 256; i
++)
861 if((mode
->mode
& chmode_flags
[i
]) && !(oldmode
->mode
& chmode_flags
[i
]))
863 if (chmode_table
[i
].set_func
== chm_hidden
)
885 /* now the ones we need to remove. */
886 for (i
= 0; i
< 256; i
++)
888 if((oldmode
->mode
& chmode_flags
[i
]) && !(mode
->mode
& chmode_flags
[i
]))
890 if(chmode_table
[i
].set_func
== chm_hidden
)
911 if(oldmode
->limit
&& !mode
->limit
)
920 if(oldmode
->key
[0] && !mode
->key
[0])
928 len
= rb_sprintf(pbuf
, "%s ", oldmode
->key
);
931 if(oldmode
->join_num
&& !mode
->join_num
)
940 if(oldmode
->forward
[0] && !mode
->forward
[0])
949 if(mode
->limit
&& oldmode
->limit
!= mode
->limit
)
957 len
= rb_sprintf(pbuf
, "%d ", mode
->limit
);
960 if(mode
->key
[0] && strcmp(oldmode
->key
, mode
->key
))
968 len
= rb_sprintf(pbuf
, "%s ", mode
->key
);
971 if(mode
->join_num
&& (oldmode
->join_num
!= mode
->join_num
|| oldmode
->join_time
!= mode
->join_time
))
979 len
= rb_sprintf(pbuf
, "%d:%d ", mode
->join_num
, mode
->join_time
);
982 if(mode
->forward
[0] && strcmp(oldmode
->forward
, mode
->forward
) && ConfigChannel
.use_forward
)
990 len
= rb_sprintf(pbuf
, "%s ", mode
->forward
);
1004 remove_our_modes(struct Channel
*chptr
, struct Client
*source_p
)
1006 struct membership
*msptr
;
1008 char lmodebuf
[MODEBUFLEN
];
1009 char *lpara
[MAXMODEPARAMS
];
1016 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1019 RB_DLINK_FOREACH(ptr
, chptr
->members
.head
)
1023 /* If anyone can think of a way to do this that doesn't make babies cry
1024 * I would love to hear it - Taros */
1028 msptr
->flags
&= ~CHFL_ADMIN
;
1029 lpara
[count
++] = msptr
->client_p
->name
;
1032 /* Make sure it fits if +h, +o, or +v are involved */
1033 if(is_chanop(msptr
))
1035 if(count
>= MAXMODEPARAMS
)
1038 sendto_channel_local(ALL_MEMBERS
, chptr
,
1039 ":%s MODE %s %s %s %s %s %s",
1040 source_p
->name
, chptr
->chname
,
1041 lmodebuf
, lpara
[0], lpara
[1],
1042 lpara
[2], lpara
[3]);
1044 /* preserve the initial '-' */
1049 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1053 msptr
->flags
&= ~CHFL_CHANOP
;
1054 lpara
[count
++] = msptr
->client_p
->name
;
1057 if(is_halfop(msptr
))
1059 if(count
>= MAXMODEPARAMS
)
1062 sendto_channel_local(ALL_MEMBERS
, chptr
,
1063 ":%s MODE %s %s %s %s %s %s",
1064 source_p
->name
, chptr
->chname
,
1065 lmodebuf
, lpara
[0], lpara
[1],
1066 lpara
[2], lpara
[3]);
1068 /* preserve the initial '-' */
1073 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1077 msptr
->flags
&= ~CHFL_HALFOP
;
1078 lpara
[count
++] = msptr
->client_p
->name
;
1081 if(is_voiced(msptr
))
1083 if(count
>= MAXMODEPARAMS
)
1086 sendto_channel_local(ALL_MEMBERS
, chptr
,
1087 ":%s MODE %s %s %s %s %s %s",
1088 source_p
->name
, chptr
->chname
,
1089 lmodebuf
, lpara
[0], lpara
[1],
1090 lpara
[2], lpara
[3]);
1092 /* preserve the initial '-' */
1097 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1101 msptr
->flags
&= ~CHFL_VOICE
;
1102 lpara
[count
++] = msptr
->client_p
->name
;
1106 else if(is_chanop(msptr
))
1108 msptr
->flags
&= ~CHFL_CHANOP
;
1109 lpara
[count
++] = msptr
->client_p
->name
;
1112 /* Make sure it fits if +h or +v are involved */
1113 if(is_halfop(msptr
))
1115 if(count
>= MAXMODEPARAMS
)
1118 sendto_channel_local(ALL_MEMBERS
, chptr
,
1119 ":%s MODE %s %s %s %s %s %s",
1120 source_p
->name
, chptr
->chname
,
1121 lmodebuf
, lpara
[0], lpara
[1],
1122 lpara
[2], lpara
[3]);
1124 /* preserve the initial '-' */
1129 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1133 msptr
->flags
&= ~CHFL_HALFOP
;
1134 lpara
[count
++] = msptr
->client_p
->name
;
1137 if(is_voiced(msptr
))
1139 if(count
>= MAXMODEPARAMS
)
1142 sendto_channel_local(ALL_MEMBERS
, chptr
,
1143 ":%s MODE %s %s %s %s %s %s",
1144 source_p
->name
, chptr
->chname
,
1145 lmodebuf
, lpara
[0], lpara
[1],
1146 lpara
[2], lpara
[3]);
1148 /* preserve the initial '-' */
1153 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1157 msptr
->flags
&= ~CHFL_VOICE
;
1158 lpara
[count
++] = msptr
->client_p
->name
;
1162 else if(is_halfop(msptr
))
1164 msptr
->flags
&= ~CHFL_HALFOP
;
1165 lpara
[count
++] = msptr
->client_p
->name
;
1168 /* +hv, might not fit so check. */
1169 if(is_voiced(msptr
))
1171 if(count
>= MAXMODEPARAMS
)
1174 sendto_channel_local(ALL_MEMBERS
, chptr
,
1175 ":%s MODE %s %s %s %s %s %s",
1176 source_p
->name
, chptr
->chname
,
1177 lmodebuf
, lpara
[0], lpara
[1],
1178 lpara
[2], lpara
[3]);
1180 /* preserve the initial '-' */
1185 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1189 msptr
->flags
&= ~CHFL_VOICE
;
1190 lpara
[count
++] = msptr
->client_p
->name
;
1194 else if(is_voiced(msptr
))
1196 msptr
->flags
&= ~CHFL_VOICE
;
1197 lpara
[count
++] = msptr
->client_p
->name
;
1203 if(count
>= MAXMODEPARAMS
)
1206 sendto_channel_local(ALL_MEMBERS
, chptr
,
1207 ":%s MODE %s %s %s %s %s %s",
1208 source_p
->name
, chptr
->chname
, lmodebuf
,
1209 lpara
[0], lpara
[1], lpara
[2], lpara
[3]);
1214 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1222 sendto_channel_local(ALL_MEMBERS
, chptr
,
1223 ":%s MODE %s %s %s %s %s %s",
1224 source_p
->name
, chptr
->chname
, lmodebuf
,
1225 EmptyString(lpara
[0]) ? "" : lpara
[0],
1226 EmptyString(lpara
[1]) ? "" : lpara
[1],
1227 EmptyString(lpara
[2]) ? "" : lpara
[2],
1228 EmptyString(lpara
[3]) ? "" : lpara
[3]);
1233 /* remove_ban_list()
1235 * inputs - channel, source, list to remove, char of mode, caps needed
1237 * side effects - given list is removed, with modes issued to local clients
1240 remove_ban_list(struct Channel
*chptr
, struct Client
*source_p
,
1241 rb_dlink_list
* list
, char c
, int mems
)
1243 static char lmodebuf
[BUFSIZE
];
1244 static char lparabuf
[BUFSIZE
];
1247 rb_dlink_node
*next_ptr
;
1250 int cur_len
, mlen
, plen
;
1254 cur_len
= mlen
= rb_sprintf(lmodebuf
, ":%s MODE %s -", source_p
->name
, chptr
->chname
);
1255 mbuf
= lmodebuf
+ mlen
;
1257 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, list
->head
)
1261 /* trailing space, and the mode letter itself */
1262 plen
= strlen(banptr
->banstr
) + 2;
1264 if(count
>= MAXMODEPARAMS
|| (cur_len
+ plen
) > BUFSIZE
- 4)
1266 /* remove trailing space */
1270 sendto_channel_local(mems
, chptr
, "%s %s", lmodebuf
, lparabuf
);
1273 mbuf
= lmodebuf
+ mlen
;
1280 pbuf
+= rb_sprintf(pbuf
, "%s ", banptr
->banstr
);
1288 sendto_channel_local(mems
, chptr
, "%s %s", lmodebuf
, lparabuf
);
1290 list
->head
= list
->tail
= NULL
;