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 user_join(&me
, target_p
, parv
[2], NULL
);
120 * parv[1] = channel TS
122 * parv[3] = "+", formerly channel modes but now unused
123 * alternatively, a single "0" parameter parts all channels
126 ms_join(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
128 struct Channel
*chptr
;
129 static struct Mode mode
;
133 int keep_our_modes
= YES
;
134 int keep_new_modes
= YES
;
135 rb_dlink_node
*ptr
, *next_ptr
;
137 /* special case for join 0 */
138 if((parv
[1][0] == '0') && (parv
[1][1] == '\0') && parc
== 2)
140 do_join_0(client_p
, source_p
);
147 if(!IsChannelName(parv
[2]) || !check_channel_name(parv
[2]))
150 /* joins for local channels cant happen. */
151 if(parv
[2][0] == '&')
156 mode
.key
[0] = mode
.forward
[0] = '\0';
157 mode
.mode
= mode
.limit
= mode
.join_num
= mode
.join_time
= 0;
159 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
162 newts
= atol(parv
[1]);
163 oldts
= chptr
->channelts
;
165 #ifdef IGNORE_BOGUS_TS
166 if(newts
< 800000000)
168 sendto_realops_snomask(SNO_DEBUG
, L_ALL
,
169 "*** Bogus TS %ld on %s ignored from %s",
170 (long) newts
, chptr
->chname
, client_p
->name
);
171 newts
= (oldts
== 0) ? oldts
: 800000000;
174 /* making a channel TS0 */
175 if(!isnew
&& !newts
&& oldts
)
177 sendto_channel_local(ALL_MEMBERS
, chptr
,
178 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to 0",
179 me
.name
, chptr
->chname
, chptr
->chname
, (long) oldts
);
180 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
181 "Server %s changing TS on %s from %ld to 0",
182 source_p
->name
, chptr
->chname
, (long) oldts
);
187 chptr
->channelts
= newts
;
188 else if(newts
== 0 || oldts
== 0)
189 chptr
->channelts
= 0;
190 else if(newts
== oldts
)
192 else if(newts
< oldts
)
195 chptr
->channelts
= newts
;
200 /* Lost the TS, other side wins, so remove modes on this side */
203 set_final_mode(&mode
, &chptr
->mode
);
205 remove_our_modes(chptr
, source_p
);
206 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->invites
.head
)
208 del_invite(chptr
, ptr
->data
);
210 /* If setting -j, clear join throttle state -- jilles */
211 chptr
->join_count
= chptr
->join_delta
= 0;
212 sendto_channel_local(ALL_MEMBERS
, chptr
,
213 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld",
214 me
.name
, chptr
->chname
, chptr
->chname
,
215 (long) oldts
, (long) newts
);
216 /* Update capitalization in channel name, this makes the
217 * capitalization timestamped like modes are -- jilles */
218 strcpy(chptr
->chname
, parv
[2]);
220 sendto_channel_local(ALL_MEMBERS
, chptr
,
222 source_p
->servptr
->name
,
223 chptr
->chname
, modebuf
, parabuf
);
224 if(*omodebuf
!= '\0')
225 sendto_channel_local(ONLY_OPERS
, chptr
,
227 source_p
->servptr
->name
,
228 chptr
->chname
, modebuf
, parabuf
);
229 *omodebuf
= *modebuf
= *parabuf
= '\0';
232 if(!IsMember(source_p
, chptr
))
234 add_user_to_channel(chptr
, source_p
, CHFL_PEON
);
235 if (chptr
->mode
.join_num
&&
236 rb_current_time() - chptr
->join_delta
>= chptr
->mode
.join_time
)
238 chptr
->join_count
= 0;
239 chptr
->join_delta
= rb_current_time();
242 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN :%s",
243 source_p
->name
, source_p
->username
,
244 source_p
->host
, chptr
->chname
);
247 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
249 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
);
254 ms_sjoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
256 static char buf_uid
[BUFSIZE
];
257 static const char empty_modes
[] = "0";
258 struct Channel
*chptr
;
259 struct Client
*target_p
, *fakesource_p
;
262 static struct Mode mode
, *oldmode
;
265 int keep_our_modes
= 1;
266 int keep_new_modes
= 1;
277 int i
, joinc
= 0, timeslice
= 0;
278 static char empty
[] = "";
279 rb_dlink_node
*ptr
, *next_ptr
;
281 if(!IsChannelName(parv
[2]) || !check_channel_name(parv
[2]))
284 /* SJOIN's for local channels can't happen. */
288 omodebuf
[0] = modebuf
[0] = parabuf
[0] = mode
.key
[0] = mode
.forward
[0] = '\0';
289 pargs
= mode
.mode
= mode
.limit
= mode
.join_num
= mode
.join_time
= 0;
291 /* Hide connecting server on netburst -- jilles */
292 if (ConfigServerHide
.flatten_links
&& !HasSentEob(source_p
))
295 fakesource_p
= source_p
;
299 newts
= atol(parv
[1]);
307 rb_strlcpy(mode
.forward
, parv
[4 + args
], sizeof(mode
.forward
));
313 sscanf(parv
[4 + args
], "%d:%d", &joinc
, ×lice
);
315 mode
.join_num
= joinc
;
316 mode
.join_time
= timeslice
;
321 rb_strlcpy(mode
.key
, parv
[4 + args
], sizeof(mode
.key
));
327 mode
.limit
= atoi(parv
[4 + args
]);
333 if(chmode_flags
[(int) *s
] != 0)
335 mode
.mode
|= chmode_flags
[(int) *s
];
344 /* remove any leading spaces */
351 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
352 return 0; /* channel name too long? */
355 oldts
= chptr
->channelts
;
356 oldmode
= &chptr
->mode
;
358 #ifdef IGNORE_BOGUS_TS
359 if(newts
< 800000000)
361 sendto_realops_snomask(SNO_DEBUG
, L_ALL
,
362 "*** Bogus TS %ld on %s ignored from %s",
363 (long) newts
, chptr
->chname
, client_p
->name
);
365 newts
= (oldts
== 0) ? oldts
: 800000000;
368 if(!isnew
&& !newts
&& oldts
)
370 sendto_channel_local(ALL_MEMBERS
, chptr
,
371 ":%s NOTICE %s :*** Notice -- TS for %s "
372 "changed from %ld to 0",
373 me
.name
, chptr
->chname
, chptr
->chname
, (long) oldts
);
374 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
375 "Server %s changing TS on %s from %ld to 0",
376 source_p
->name
, chptr
->chname
, (long) oldts
);
381 chptr
->channelts
= newts
;
383 else if(newts
== 0 || oldts
== 0)
384 chptr
->channelts
= 0;
385 else if(newts
== oldts
)
387 else if(newts
< oldts
)
389 /* If configured, kick people trying to join +i/+k
390 * channels by recreating them on split servers.
391 * Don't kick if the source has sent EOB (services
392 * deopping everyone by TS-1 SJOIN).
394 if (ConfigChannel
.kick_on_split_riding
&&
395 !HasSentEob(source_p
) &&
396 ((mode
.mode
& MODE_INVITEONLY
) ||
397 (mode
.key
[0] != 0 && irccmp(mode
.key
, oldmode
->key
) != 0)))
399 struct membership
*msptr
;
401 int l
= rb_dlink_list_length(&chptr
->members
);
403 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->locmembers
.head
)
406 who
= msptr
->client_p
;
407 sendto_one(who
, ":%s KICK %s %s :Net Rider",
408 me
.name
, chptr
->chname
, who
->name
);
410 sendto_server(NULL
, chptr
, CAP_TS6
, NOCAPS
,
411 ":%s KICK %s %s :Net Rider",
412 me
.id
, chptr
->chname
,
414 remove_user_from_channel(msptr
);
420 /* Channel was emptied, create a new one */
421 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
422 return 0; /* oops! */
424 oldmode
= &chptr
->mode
;
428 chptr
->channelts
= newts
;
435 else if(keep_our_modes
)
437 mode
.mode
|= oldmode
->mode
;
438 if(oldmode
->limit
> mode
.limit
)
439 mode
.limit
= oldmode
->limit
;
440 if(strcmp(mode
.key
, oldmode
->key
) < 0)
441 strcpy(mode
.key
, oldmode
->key
);
442 if(oldmode
->join_num
> mode
.join_num
||
443 (oldmode
->join_num
== mode
.join_num
&&
444 oldmode
->join_time
> mode
.join_time
))
446 mode
.join_num
= oldmode
->join_num
;
447 mode
.join_time
= oldmode
->join_time
;
449 if(irccmp(mode
.forward
, oldmode
->forward
) < 0)
450 strcpy(mode
.forward
, oldmode
->forward
);
454 /* If setting -j, clear join throttle state -- jilles */
456 chptr
->join_count
= chptr
->join_delta
= 0;
459 set_final_mode(&mode
, oldmode
);
462 /* Lost the TS, other side wins, so remove modes on this side */
465 remove_our_modes(chptr
, fakesource_p
);
466 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->invites
.head
)
468 del_invite(chptr
, ptr
->data
);
471 if(rb_dlink_list_length(&chptr
->banlist
) > 0)
472 remove_ban_list(chptr
, fakesource_p
, &chptr
->banlist
, 'b', ALL_MEMBERS
);
473 if(rb_dlink_list_length(&chptr
->exceptlist
) > 0)
474 remove_ban_list(chptr
, fakesource_p
, &chptr
->exceptlist
,
476 if(rb_dlink_list_length(&chptr
->invexlist
) > 0)
477 remove_ban_list(chptr
, fakesource_p
, &chptr
->invexlist
,
479 if(rb_dlink_list_length(&chptr
->quietlist
) > 0)
480 remove_ban_list(chptr
, fakesource_p
, &chptr
->quietlist
,
484 sendto_channel_local(ALL_MEMBERS
, chptr
,
485 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld",
486 me
.name
, chptr
->chname
, chptr
->chname
,
487 (long) oldts
, (long) newts
);
488 /* Update capitalization in channel name, this makes the
489 * capitalization timestamped like modes are -- jilles */
490 strcpy(chptr
->chname
, parv
[2]);
494 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s MODE %s %s %s",
495 fakesource_p
->name
, chptr
->chname
, modebuf
, parabuf
);
497 if(*omodebuf
!= '\0')
498 sendto_channel_local(ONLY_OPERS
, chptr
, ":%s MODE %s %s %s",
499 fakesource_p
->name
, chptr
->chname
, omodebuf
, parabuf
);
501 *omodebuf
= *modebuf
= *parabuf
= '\0';
503 if(parv
[3][0] != '0' && keep_new_modes
)
504 modes
= channel_modes(chptr
, source_p
);
508 mlen_uid
= rb_sprintf(buf_uid
, ":%s SJOIN %ld %s %s :",
509 use_id(source_p
), (long) chptr
->channelts
, parv
[2], modes
);
510 ptr_uid
= buf_uid
+ mlen_uid
;
514 para
[0] = para
[1] = para
[2] = para
[3] = empty
;
516 len_nick
= len_uid
= 0;
518 /* if theres a space, theres going to be more than one nick, change the
519 * first space to \0, so s is just the first nick, and point p to the
522 if((p
= strchr(s
, ' ')) != NULL
)
533 for (i
= 0; i
< 2; i
++)
557 /* if the client doesnt exist or is fake direction, skip. */
558 if(!(target_p
= find_client(s
)) ||
559 (target_p
->from
!= client_p
) || !IsPerson(target_p
))
562 /* we assume for these we can fit at least one nick/uid in.. */
564 /* check we can fit another status+nick+space into a buffer */
565 if((mlen_uid
+ len_uid
+ IDLEN
+ 3) > (BUFSIZE
- 3))
567 *(ptr_uid
- 1) = '\0';
568 sendto_server(client_p
->from
, NULL
, CAP_TS6
, NOCAPS
, "%s", buf_uid
);
569 ptr_uid
= buf_uid
+ mlen_uid
;
601 /* copy the nick to the two buffers */
602 len
= rb_sprintf(ptr_uid
, "%s ", use_id(target_p
));
609 if(!IsMember(target_p
, chptr
))
611 add_user_to_channel(chptr
, target_p
, fl
);
612 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN :%s",
614 target_p
->username
, target_p
->host
, parv
[2]);
618 /* If anyone can think of a way to do this that doesn't make babies cry
619 * I would love to hear it - Taros */
624 para
[pargs
++] = target_p
->name
;
628 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
631 if(pargs
>= MAXMODEPARAMS
)
634 sendto_channel_local(ALL_MEMBERS
, chptr
,
635 ":%s MODE %s %s %s %s %s %s",
636 fakesource_p
->name
, chptr
->chname
,
638 para
[0], para
[1], para
[2], para
[3]);
641 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
646 para
[pargs
++] = target_p
->name
;
650 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
653 if(pargs
>= MAXMODEPARAMS
)
656 sendto_channel_local(ALL_MEMBERS
, chptr
,
657 ":%s MODE %s %s %s %s %s %s",
658 fakesource_p
->name
, chptr
->chname
,
660 para
[0], para
[1], para
[2], para
[3]);
663 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
668 para
[pargs
++] = target_p
->name
;
672 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
675 if(pargs
>= MAXMODEPARAMS
)
678 sendto_channel_local(ALL_MEMBERS
, chptr
,
679 ":%s MODE %s %s %s %s %s %s",
680 fakesource_p
->name
, chptr
->chname
,
682 para
[0], para
[1], para
[2], para
[3]);
685 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
690 para
[pargs
++] = target_p
->name
;
696 para
[pargs
++] = target_p
->name
;
700 /* its possible the +o has filled up MAXMODEPARAMS, if so, start
703 if(pargs
>= MAXMODEPARAMS
)
706 sendto_channel_local(ALL_MEMBERS
, chptr
,
707 ":%s MODE %s %s %s %s %s %s",
708 fakesource_p
->name
, chptr
->chname
,
710 para
[0], para
[1], para
[2], para
[3]);
713 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
718 para
[pargs
++] = target_p
->name
;
722 /* its possible the +o has filled up MAXMODEPARAMS, if so, start
725 if(pargs
>= MAXMODEPARAMS
)
728 sendto_channel_local(ALL_MEMBERS
, chptr
,
729 ":%s MODE %s %s %s %s %s %s",
730 fakesource_p
->name
, chptr
->chname
,
732 para
[0], para
[1], para
[2], para
[3]);
735 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
740 para
[pargs
++] = target_p
->name
;
746 para
[pargs
++] = target_p
->name
;
750 /* its possible the +h has filled up MAXMODEPARAMS, if so, start
753 if(pargs
>= MAXMODEPARAMS
)
756 sendto_channel_local(ALL_MEMBERS
, chptr
,
757 ":%s MODE %s %s %s %s %s %s",
758 fakesource_p
->name
, chptr
->chname
,
760 para
[0], para
[1], para
[2], para
[3]);
763 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
768 para
[pargs
++] = target_p
->name
;
771 else if(fl
& CHFL_VOICE
)
774 para
[pargs
++] = target_p
->name
;
777 if(pargs
>= MAXMODEPARAMS
)
780 sendto_channel_local(ALL_MEMBERS
, chptr
,
781 ":%s MODE %s %s %s %s %s %s",
784 modebuf
, para
[0], para
[1], para
[2], para
[3]);
787 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
792 /* p points to the next nick */
795 /* if there was a trailing space and p was pointing to it, then we
796 * need to exit.. this has the side effect of breaking double spaces
797 * in an sjoin.. but that shouldnt happen anyway
799 if(s
&& (*s
== '\0'))
802 /* if p was NULL due to no spaces, s wont exist due to the above, so
803 * we cant check it for spaces.. if there are no spaces, then when
804 * we next get here, s will be NULL
806 if(s
&& ((p
= strchr(s
, ' ')) != NULL
))
815 sendto_channel_local(ALL_MEMBERS
, chptr
,
816 ":%s MODE %s %s %s %s %s %s",
817 fakesource_p
->name
, chptr
->chname
, modebuf
,
818 para
[0], CheckEmpty(para
[1]),
819 CheckEmpty(para
[2]), CheckEmpty(para
[3]));
822 if(!joins
&& !(chptr
->mode
.mode
& MODE_PERMANENT
) && isnew
)
824 destroy_channel(chptr
);
829 /* Keep the colon if we're sending an SJOIN without nicks -- jilles */
832 *(ptr_uid
- 1) = '\0';
835 sendto_server(client_p
->from
, NULL
, CAP_TS6
, NOCAPS
, "%s", buf_uid
);
842 set_final_mode(struct Mode
*mode
, struct Mode
*oldmode
)
844 int dir
= MODE_QUERY
, odir
= MODE_QUERY
;
845 char *pbuf
= parabuf
;
849 /* ok, first get a list of modes we need to add */
850 for (i
= 0; i
< 256; i
++)
852 if((mode
->mode
& chmode_flags
[i
]) && !(oldmode
->mode
& chmode_flags
[i
]))
854 if (chmode_table
[i
].set_func
== chm_hidden
)
876 /* now the ones we need to remove. */
877 for (i
= 0; i
< 256; i
++)
879 if((oldmode
->mode
& chmode_flags
[i
]) && !(mode
->mode
& chmode_flags
[i
]))
881 if(chmode_table
[i
].set_func
== chm_hidden
)
902 if(oldmode
->limit
&& !mode
->limit
)
911 if(oldmode
->key
[0] && !mode
->key
[0])
919 len
= rb_sprintf(pbuf
, "%s ", oldmode
->key
);
922 if(oldmode
->join_num
&& !mode
->join_num
)
931 if(oldmode
->forward
[0] && !mode
->forward
[0])
940 if(mode
->limit
&& oldmode
->limit
!= mode
->limit
)
948 len
= rb_sprintf(pbuf
, "%d ", mode
->limit
);
951 if(mode
->key
[0] && strcmp(oldmode
->key
, mode
->key
))
959 len
= rb_sprintf(pbuf
, "%s ", mode
->key
);
962 if(mode
->join_num
&& (oldmode
->join_num
!= mode
->join_num
|| oldmode
->join_time
!= mode
->join_time
))
970 len
= rb_sprintf(pbuf
, "%d:%d ", mode
->join_num
, mode
->join_time
);
973 if(mode
->forward
[0] && strcmp(oldmode
->forward
, mode
->forward
) && ConfigChannel
.use_forward
)
981 len
= rb_sprintf(pbuf
, "%s ", mode
->forward
);
995 remove_our_modes(struct Channel
*chptr
, struct Client
*source_p
)
997 struct membership
*msptr
;
999 char lmodebuf
[MODEBUFLEN
];
1000 char *lpara
[MAXMODEPARAMS
];
1007 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1010 RB_DLINK_FOREACH(ptr
, chptr
->members
.head
)
1014 /* If anyone can think of a way to do this that doesn't make babies cry
1015 * I would love to hear it - Taros */
1019 msptr
->flags
&= ~CHFL_ADMIN
;
1020 lpara
[count
++] = msptr
->client_p
->name
;
1023 /* Make sure it fits if +h, +o, or +v are involved */
1024 if(is_chanop(msptr
))
1026 if(count
>= MAXMODEPARAMS
)
1029 sendto_channel_local(ALL_MEMBERS
, chptr
,
1030 ":%s MODE %s %s %s %s %s %s",
1031 source_p
->name
, chptr
->chname
,
1032 lmodebuf
, lpara
[0], lpara
[1],
1033 lpara
[2], lpara
[3]);
1035 /* preserve the initial '-' */
1040 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1044 msptr
->flags
&= ~CHFL_CHANOP
;
1045 lpara
[count
++] = msptr
->client_p
->name
;
1048 if(is_halfop(msptr
))
1050 if(count
>= MAXMODEPARAMS
)
1053 sendto_channel_local(ALL_MEMBERS
, chptr
,
1054 ":%s MODE %s %s %s %s %s %s",
1055 source_p
->name
, chptr
->chname
,
1056 lmodebuf
, lpara
[0], lpara
[1],
1057 lpara
[2], lpara
[3]);
1059 /* preserve the initial '-' */
1064 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1068 msptr
->flags
&= ~CHFL_HALFOP
;
1069 lpara
[count
++] = msptr
->client_p
->name
;
1072 if(is_voiced(msptr
))
1074 if(count
>= MAXMODEPARAMS
)
1077 sendto_channel_local(ALL_MEMBERS
, chptr
,
1078 ":%s MODE %s %s %s %s %s %s",
1079 source_p
->name
, chptr
->chname
,
1080 lmodebuf
, lpara
[0], lpara
[1],
1081 lpara
[2], lpara
[3]);
1083 /* preserve the initial '-' */
1088 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1092 msptr
->flags
&= ~CHFL_VOICE
;
1093 lpara
[count
++] = msptr
->client_p
->name
;
1097 else if(is_chanop(msptr
))
1099 msptr
->flags
&= ~CHFL_CHANOP
;
1100 lpara
[count
++] = msptr
->client_p
->name
;
1103 /* Make sure it fits if +h or +v are involved */
1104 if(is_halfop(msptr
))
1106 if(count
>= MAXMODEPARAMS
)
1109 sendto_channel_local(ALL_MEMBERS
, chptr
,
1110 ":%s MODE %s %s %s %s %s %s",
1111 source_p
->name
, chptr
->chname
,
1112 lmodebuf
, lpara
[0], lpara
[1],
1113 lpara
[2], lpara
[3]);
1115 /* preserve the initial '-' */
1120 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1124 msptr
->flags
&= ~CHFL_HALFOP
;
1125 lpara
[count
++] = msptr
->client_p
->name
;
1128 if(is_voiced(msptr
))
1130 if(count
>= MAXMODEPARAMS
)
1133 sendto_channel_local(ALL_MEMBERS
, chptr
,
1134 ":%s MODE %s %s %s %s %s %s",
1135 source_p
->name
, chptr
->chname
,
1136 lmodebuf
, lpara
[0], lpara
[1],
1137 lpara
[2], lpara
[3]);
1139 /* preserve the initial '-' */
1144 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1148 msptr
->flags
&= ~CHFL_VOICE
;
1149 lpara
[count
++] = msptr
->client_p
->name
;
1153 else if(is_halfop(msptr
))
1155 msptr
->flags
&= ~CHFL_HALFOP
;
1156 lpara
[count
++] = msptr
->client_p
->name
;
1159 /* +hv, might not fit so check. */
1160 if(is_voiced(msptr
))
1162 if(count
>= MAXMODEPARAMS
)
1165 sendto_channel_local(ALL_MEMBERS
, chptr
,
1166 ":%s MODE %s %s %s %s %s %s",
1167 source_p
->name
, chptr
->chname
,
1168 lmodebuf
, lpara
[0], lpara
[1],
1169 lpara
[2], lpara
[3]);
1171 /* preserve the initial '-' */
1176 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1180 msptr
->flags
&= ~CHFL_VOICE
;
1181 lpara
[count
++] = msptr
->client_p
->name
;
1185 else if(is_voiced(msptr
))
1187 msptr
->flags
&= ~CHFL_VOICE
;
1188 lpara
[count
++] = msptr
->client_p
->name
;
1194 if(count
>= MAXMODEPARAMS
)
1197 sendto_channel_local(ALL_MEMBERS
, chptr
,
1198 ":%s MODE %s %s %s %s %s %s",
1199 source_p
->name
, chptr
->chname
, lmodebuf
,
1200 lpara
[0], lpara
[1], lpara
[2], lpara
[3]);
1205 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1213 sendto_channel_local(ALL_MEMBERS
, chptr
,
1214 ":%s MODE %s %s %s %s %s %s",
1215 source_p
->name
, chptr
->chname
, lmodebuf
,
1216 EmptyString(lpara
[0]) ? "" : lpara
[0],
1217 EmptyString(lpara
[1]) ? "" : lpara
[1],
1218 EmptyString(lpara
[2]) ? "" : lpara
[2],
1219 EmptyString(lpara
[3]) ? "" : lpara
[3]);
1224 /* remove_ban_list()
1226 * inputs - channel, source, list to remove, char of mode, caps needed
1228 * side effects - given list is removed, with modes issued to local clients
1231 remove_ban_list(struct Channel
*chptr
, struct Client
*source_p
,
1232 rb_dlink_list
* list
, char c
, int mems
)
1234 static char lmodebuf
[BUFSIZE
];
1235 static char lparabuf
[BUFSIZE
];
1238 rb_dlink_node
*next_ptr
;
1241 int cur_len
, mlen
, plen
;
1245 cur_len
= mlen
= rb_sprintf(lmodebuf
, ":%s MODE %s -", source_p
->name
, chptr
->chname
);
1246 mbuf
= lmodebuf
+ mlen
;
1248 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, list
->head
)
1252 /* trailing space, and the mode letter itself */
1253 plen
= strlen(banptr
->banstr
) + 2;
1255 if(count
>= MAXMODEPARAMS
|| (cur_len
+ plen
) > BUFSIZE
- 4)
1257 /* remove trailing space */
1261 sendto_channel_local(mems
, chptr
, "%s %s", lmodebuf
, lparabuf
);
1264 mbuf
= lmodebuf
+ mlen
;
1271 pbuf
+= rb_sprintf(pbuf
, "%s ", banptr
->banstr
);
1279 sendto_channel_local(mems
, chptr
, "%s %s", lmodebuf
, lparabuf
);
1281 list
->head
= list
->tail
= NULL
;