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 module_modes ModuleModes
;
51 struct Message join_msgtab
= {
52 "JOIN", 0, 0, 0, MFLG_SLOW
,
53 {mg_unreg
, {m_join
, 2}, {ms_join
, 2}, mg_ignore
, mg_ignore
, {m_join
, 2}}
56 struct Message svsjoin_msgtab
= {
57 "SVSJOIN", 0, 0, 0, MFLG_SLOW
,
58 {mg_ignore
, mg_ignore
, mg_ignore
, mg_ignore
, {me_svsjoin
, 3}, mg_ignore
}
61 struct Message sjoin_msgtab
= {
62 "SJOIN", 0, 0, 0, MFLG_SLOW
,
63 {mg_unreg
, mg_ignore
, mg_ignore
, {ms_sjoin
, 4}, mg_ignore
, mg_ignore
}
66 mapi_clist_av1 join_clist
[] = { &join_msgtab
, &svsjoin_msgtab
, &sjoin_msgtab
, NULL
};
68 DECLARE_MODULE_AV1(join
, NULL
, NULL
, join_clist
, NULL
, NULL
, "$Revision: 3494 $");
70 static void set_final_mode(struct Mode
*mode
, struct Mode
*oldmode
);
71 static void remove_our_modes(struct Channel
*chptr
, struct Client
*source_p
);
73 static void remove_ban_list(struct Channel
*chptr
, struct Client
*source_p
,
74 rb_dlink_list
* list
, char c
, int mems
);
76 static char modebuf
[MODEBUFLEN
];
77 static char omodebuf
[MODEBUFLEN
];
78 static char parabuf
[MODEBUFLEN
];
79 static const char *para
[MAXMODEPARAMS
];
80 static char *mbuf
, *ombuf
;
86 * parv[2] = channel password (key)
89 m_join(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
91 user_join(client_p
, source_p
, parv
[1], parc
> 2 ? parv
[2] : NULL
); /* channel.c */
97 * me_svsjoin - small function to allow services to forcejoin clients, mainly for ns_ajoin
98 * parv[1] = user to act on (join to a channel)
100 * This does allow opers to "forcejoin" users to channels with operserv/raw or by writing a
101 * custom module (where they can make it not log anything), but the former bitches that it's
102 * being used and the latter...Can probably be done anyway with enough hackyness if this
103 * command didn't exist so it's not all that bad.
106 me_svsjoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
108 struct Client
*target_p
;
110 if(!(source_p
->flags
& FLAGS_SERVICE
))
113 if((target_p
= find_person(parv
[1])) == NULL
)
116 if(!MyClient(target_p
))
119 user_join(&me
, target_p
, parv
[2], NULL
);
125 * parv[1] = channel TS
127 * parv[3] = "+", formerly channel modes but now unused
128 * alternatively, a single "0" parameter parts all channels
131 ms_join(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
133 struct Channel
*chptr
;
134 static struct Mode mode
;
138 int keep_our_modes
= YES
;
139 int keep_new_modes
= YES
;
140 rb_dlink_node
*ptr
, *next_ptr
;
142 /* special case for join 0 */
143 if((parv
[1][0] == '0') && (parv
[1][1] == '\0') && parc
== 2)
145 do_join_0(client_p
, source_p
);
152 if(!IsChannelName(parv
[2]) || !check_channel_name(parv
[2]))
155 /* joins for local channels cant happen. */
156 if(parv
[2][0] == '&')
161 mode
.key
[0] = mode
.forward
[0] = '\0';
162 mode
.mode
= mode
.limit
= mode
.join_num
= mode
.join_time
= 0;
164 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
167 newts
= atol(parv
[1]);
168 oldts
= chptr
->channelts
;
170 #ifdef IGNORE_BOGUS_TS
171 if(newts
< 800000000)
173 sendto_realops_snomask(SNO_DEBUG
, L_ALL
,
174 "*** Bogus TS %ld on %s ignored from %s",
175 (long) newts
, chptr
->chname
, client_p
->name
);
176 newts
= (oldts
== 0) ? oldts
: 800000000;
179 /* making a channel TS0 */
180 if(!isnew
&& !newts
&& oldts
)
182 sendto_channel_local(ALL_MEMBERS
, chptr
,
183 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to 0",
184 me
.name
, chptr
->chname
, chptr
->chname
, (long) oldts
);
185 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
186 "Server %s changing TS on %s from %ld to 0",
187 source_p
->name
, chptr
->chname
, (long) oldts
);
192 chptr
->channelts
= newts
;
193 else if(newts
== 0 || oldts
== 0)
194 chptr
->channelts
= 0;
195 else if(newts
== oldts
)
197 else if(newts
< oldts
)
200 chptr
->channelts
= newts
;
205 /* Lost the TS, other side wins, so remove modes on this side */
208 set_final_mode(&mode
, &chptr
->mode
);
210 remove_our_modes(chptr
, source_p
);
211 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->invites
.head
)
213 del_invite(chptr
, ptr
->data
);
215 /* If setting -j, clear join throttle state -- jilles */
216 chptr
->join_count
= chptr
->join_delta
= 0;
217 sendto_channel_local(ALL_MEMBERS
, chptr
,
218 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld",
219 me
.name
, chptr
->chname
, chptr
->chname
,
220 (long) oldts
, (long) newts
);
221 /* Update capitalization in channel name, this makes the
222 * capitalization timestamped like modes are -- jilles */
223 strcpy(chptr
->chname
, parv
[2]);
225 sendto_channel_local(ALL_MEMBERS
, chptr
,
227 source_p
->servptr
->name
,
228 chptr
->chname
, modebuf
, parabuf
);
229 if(*omodebuf
!= '\0')
230 sendto_channel_local(ONLY_OPERS
, chptr
,
232 source_p
->servptr
->name
,
233 chptr
->chname
, modebuf
, parabuf
);
234 *omodebuf
= *modebuf
= *parabuf
= '\0';
237 if(!IsMember(source_p
, chptr
))
239 add_user_to_channel(chptr
, source_p
, CHFL_PEON
);
240 if (chptr
->mode
.join_num
&&
241 rb_current_time() - chptr
->join_delta
>= chptr
->mode
.join_time
)
243 chptr
->join_count
= 0;
244 chptr
->join_delta
= rb_current_time();
247 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN :%s",
248 source_p
->name
, source_p
->username
,
249 source_p
->host
, chptr
->chname
);
252 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
254 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
);
259 ms_sjoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
261 static char buf_uid
[BUFSIZE
];
262 static const char empty_modes
[] = "0";
263 struct Channel
*chptr
;
264 struct Client
*target_p
, *fakesource_p
;
267 static struct Mode mode
, *oldmode
;
270 int keep_our_modes
= 1;
271 int keep_new_modes
= 1;
282 int i
, joinc
= 0, timeslice
= 0;
283 static char empty
[] = "";
284 rb_dlink_node
*ptr
, *next_ptr
;
286 if(!IsChannelName(parv
[2]) || !check_channel_name(parv
[2]))
289 /* SJOIN's for local channels can't happen. */
293 omodebuf
[0] = modebuf
[0] = parabuf
[0] = mode
.key
[0] = mode
.forward
[0] = '\0';
294 pargs
= mode
.mode
= mode
.limit
= mode
.join_num
= mode
.join_time
= 0;
296 /* Hide connecting server on netburst -- jilles */
297 if (ConfigServerHide
.flatten_links
&& !HasSentEob(source_p
))
300 fakesource_p
= source_p
;
304 newts
= atol(parv
[1]);
312 rb_strlcpy(mode
.forward
, parv
[4 + args
], sizeof(mode
.forward
));
318 sscanf(parv
[4 + args
], "%d:%d", &joinc
, ×lice
);
320 mode
.join_num
= joinc
;
321 mode
.join_time
= timeslice
;
326 rb_strlcpy(mode
.key
, parv
[4 + args
], sizeof(mode
.key
));
332 mode
.limit
= atoi(parv
[4 + args
]);
338 if(chmode_flags
[(int) *s
] != 0)
340 mode
.mode
|= chmode_flags
[(int) *s
];
349 /* remove any leading spaces */
356 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
357 return 0; /* channel name too long? */
360 oldts
= chptr
->channelts
;
361 oldmode
= &chptr
->mode
;
363 #ifdef IGNORE_BOGUS_TS
364 if(newts
< 800000000)
366 sendto_realops_snomask(SNO_DEBUG
, L_ALL
,
367 "*** Bogus TS %ld on %s ignored from %s",
368 (long) newts
, chptr
->chname
, client_p
->name
);
370 newts
= (oldts
== 0) ? oldts
: 800000000;
373 if(!isnew
&& !newts
&& oldts
)
375 sendto_channel_local(ALL_MEMBERS
, chptr
,
376 ":%s NOTICE %s :*** Notice -- TS for %s "
377 "changed from %ld to 0",
378 me
.name
, chptr
->chname
, chptr
->chname
, (long) oldts
);
379 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
380 "Server %s changing TS on %s from %ld to 0",
381 source_p
->name
, chptr
->chname
, (long) oldts
);
386 chptr
->channelts
= newts
;
388 else if(newts
== 0 || oldts
== 0)
389 chptr
->channelts
= 0;
390 else if(newts
== oldts
)
392 else if(newts
< oldts
)
394 /* If configured, kick people trying to join +i/+k
395 * channels by recreating them on split servers.
396 * Don't kick if the source has sent EOB (services
397 * deopping everyone by TS-1 SJOIN).
399 if (ConfigChannel
.kick_on_split_riding
&&
400 !HasSentEob(source_p
) &&
401 ((mode
.mode
& MODE_INVITEONLY
) ||
402 (mode
.key
[0] != 0 && irccmp(mode
.key
, oldmode
->key
) != 0)))
404 struct membership
*msptr
;
406 int l
= rb_dlink_list_length(&chptr
->members
);
408 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->locmembers
.head
)
411 who
= msptr
->client_p
;
412 sendto_one(who
, ":%s KICK %s %s :Net Rider",
413 me
.name
, chptr
->chname
, who
->name
);
415 sendto_server(NULL
, chptr
, CAP_TS6
, NOCAPS
,
416 ":%s KICK %s %s :Net Rider",
417 me
.id
, chptr
->chname
,
419 remove_user_from_channel(msptr
);
425 /* Channel was emptied, create a new one */
426 if((chptr
= get_or_create_channel(source_p
, parv
[2], &isnew
)) == NULL
)
427 return 0; /* oops! */
429 oldmode
= &chptr
->mode
;
433 chptr
->channelts
= newts
;
440 else if(keep_our_modes
)
442 mode
.mode
|= oldmode
->mode
;
443 if(oldmode
->limit
> mode
.limit
)
444 mode
.limit
= oldmode
->limit
;
445 if(strcmp(mode
.key
, oldmode
->key
) < 0)
446 strcpy(mode
.key
, oldmode
->key
);
447 if(oldmode
->join_num
> mode
.join_num
||
448 (oldmode
->join_num
== mode
.join_num
&&
449 oldmode
->join_time
> mode
.join_time
))
451 mode
.join_num
= oldmode
->join_num
;
452 mode
.join_time
= oldmode
->join_time
;
454 if(irccmp(mode
.forward
, oldmode
->forward
) < 0)
455 strcpy(mode
.forward
, oldmode
->forward
);
459 /* If setting -j, clear join throttle state -- jilles */
461 chptr
->join_count
= chptr
->join_delta
= 0;
464 set_final_mode(&mode
, oldmode
);
467 /* Lost the TS, other side wins, so remove modes on this side */
470 remove_our_modes(chptr
, fakesource_p
);
471 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->invites
.head
)
473 del_invite(chptr
, ptr
->data
);
476 if(rb_dlink_list_length(&chptr
->banlist
) > 0)
477 remove_ban_list(chptr
, fakesource_p
, &chptr
->banlist
, 'b', ALL_MEMBERS
);
478 if(rb_dlink_list_length(&chptr
->exceptlist
) > 0)
479 remove_ban_list(chptr
, fakesource_p
, &chptr
->exceptlist
,
481 if(rb_dlink_list_length(&chptr
->invexlist
) > 0)
482 remove_ban_list(chptr
, fakesource_p
, &chptr
->invexlist
,
484 if(rb_dlink_list_length(&chptr
->quietlist
) > 0)
485 remove_ban_list(chptr
, fakesource_p
, &chptr
->quietlist
,
489 sendto_channel_local(ALL_MEMBERS
, chptr
,
490 ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld",
491 me
.name
, chptr
->chname
, chptr
->chname
,
492 (long) oldts
, (long) newts
);
493 /* Update capitalization in channel name, this makes the
494 * capitalization timestamped like modes are -- jilles */
495 strcpy(chptr
->chname
, parv
[2]);
499 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s MODE %s %s %s",
500 fakesource_p
->name
, chptr
->chname
, modebuf
, parabuf
);
502 if(*omodebuf
!= '\0')
503 sendto_channel_local(ONLY_OPERS
, chptr
, ":%s MODE %s %s %s",
504 fakesource_p
->name
, chptr
->chname
, omodebuf
, parabuf
);
506 *omodebuf
= *modebuf
= *parabuf
= '\0';
508 if(parv
[3][0] != '0' && keep_new_modes
)
509 modes
= channel_modes(chptr
, source_p
);
513 mlen_uid
= rb_sprintf(buf_uid
, ":%s SJOIN %ld %s %s :",
514 use_id(source_p
), (long) chptr
->channelts
, parv
[2], modes
);
515 ptr_uid
= buf_uid
+ mlen_uid
;
519 para
[0] = para
[1] = para
[2] = para
[3] = empty
;
521 len_nick
= len_uid
= 0;
523 /* if theres a space, theres going to be more than one nick, change the
524 * first space to \0, so s is just the first nick, and point p to the
527 if((p
= strchr(s
, ' ')) != NULL
)
538 for (i
= 0; i
< 4; i
++)
562 /* if the client doesnt exist or is fake direction, skip. */
563 if(!(target_p
= find_client(s
)) ||
564 (target_p
->from
!= client_p
) || !IsPerson(target_p
))
567 /* we assume for these we can fit at least one nick/uid in.. */
569 /* check we can fit another status+nick+space into a buffer */
570 if((mlen_uid
+ len_uid
+ IDLEN
+ 3) > (BUFSIZE
- 3))
572 *(ptr_uid
- 1) = '\0';
573 sendto_server(client_p
->from
, NULL
, CAP_TS6
, NOCAPS
, "%s", buf_uid
);
574 ptr_uid
= buf_uid
+ mlen_uid
;
606 /* copy the nick to the two buffers */
607 len
= rb_sprintf(ptr_uid
, "%s ", use_id(target_p
));
614 if(!IsMember(target_p
, chptr
))
616 add_user_to_channel(chptr
, target_p
, fl
);
617 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN :%s",
619 target_p
->username
, target_p
->host
, parv
[2]);
623 /* If anyone can think of a way to do this that doesn't make babies cry
624 * I would love to hear it - Taros */
629 para
[pargs
++] = target_p
->name
;
633 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
636 if(pargs
>= MAXMODEPARAMS
)
639 sendto_channel_local(ALL_MEMBERS
, chptr
,
640 ":%s MODE %s %s %s %s %s %s",
641 fakesource_p
->name
, chptr
->chname
,
643 para
[0], para
[1], para
[2], para
[3]);
646 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
651 para
[pargs
++] = target_p
->name
;
655 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
658 if(pargs
>= MAXMODEPARAMS
)
661 sendto_channel_local(ALL_MEMBERS
, chptr
,
662 ":%s MODE %s %s %s %s %s %s",
663 fakesource_p
->name
, chptr
->chname
,
665 para
[0], para
[1], para
[2], para
[3]);
668 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
673 para
[pargs
++] = target_p
->name
;
677 /* its possible the +a has filled up MAXMODEPARAMS, if so, start
680 if(pargs
>= MAXMODEPARAMS
)
683 sendto_channel_local(ALL_MEMBERS
, chptr
,
684 ":%s MODE %s %s %s %s %s %s",
685 fakesource_p
->name
, chptr
->chname
,
687 para
[0], para
[1], para
[2], para
[3]);
690 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
695 para
[pargs
++] = target_p
->name
;
698 else if(fl
& CHFL_CHANOP
)
701 para
[pargs
++] = target_p
->name
;
705 /* its possible the +o has filled up MAXMODEPARAMS, if so, start
708 if(pargs
>= MAXMODEPARAMS
)
711 sendto_channel_local(ALL_MEMBERS
, chptr
,
712 ":%s MODE %s %s %s %s %s %s",
713 fakesource_p
->name
, chptr
->chname
,
715 para
[0], para
[1], para
[2], para
[3]);
718 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
723 para
[pargs
++] = target_p
->name
;
727 /* its possible the +o has filled up MAXMODEPARAMS, if so, start
730 if(pargs
>= MAXMODEPARAMS
)
733 sendto_channel_local(ALL_MEMBERS
, chptr
,
734 ":%s MODE %s %s %s %s %s %s",
735 fakesource_p
->name
, chptr
->chname
,
737 para
[0], para
[1], para
[2], para
[3]);
740 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
745 para
[pargs
++] = target_p
->name
;
748 else if(fl
& CHFL_HALFOP
)
751 para
[pargs
++] = target_p
->name
;
755 /* its possible the +h has filled up MAXMODEPARAMS, if so, start
758 if(pargs
>= MAXMODEPARAMS
)
761 sendto_channel_local(ALL_MEMBERS
, chptr
,
762 ":%s MODE %s %s %s %s %s %s",
763 fakesource_p
->name
, chptr
->chname
,
765 para
[0], para
[1], para
[2], para
[3]);
768 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
773 para
[pargs
++] = target_p
->name
;
776 else if(fl
& CHFL_VOICE
)
779 para
[pargs
++] = target_p
->name
;
782 if(pargs
>= MAXMODEPARAMS
)
785 sendto_channel_local(ALL_MEMBERS
, chptr
,
786 ":%s MODE %s %s %s %s %s %s",
789 modebuf
, para
[0], para
[1], para
[2], para
[3]);
792 para
[0] = para
[1] = para
[2] = para
[3] = NULL
;
797 /* p points to the next nick */
800 /* if there was a trailing space and p was pointing to it, then we
801 * need to exit.. this has the side effect of breaking double spaces
802 * in an sjoin.. but that shouldnt happen anyway
804 if(s
&& (*s
== '\0'))
807 /* if p was NULL due to no spaces, s wont exist due to the above, so
808 * we cant check it for spaces.. if there are no spaces, then when
809 * we next get here, s will be NULL
811 if(s
&& ((p
= strchr(s
, ' ')) != NULL
))
820 sendto_channel_local(ALL_MEMBERS
, chptr
,
821 ":%s MODE %s %s %s %s %s %s",
822 fakesource_p
->name
, chptr
->chname
, modebuf
,
823 para
[0], CheckEmpty(para
[1]),
824 CheckEmpty(para
[2]), CheckEmpty(para
[3]));
827 if(!joins
&& !(chptr
->mode
.mode
& ModuleModes
.MODE_PERMANENT
) && isnew
)
829 destroy_channel(chptr
);
834 /* Keep the colon if we're sending an SJOIN without nicks -- jilles */
837 *(ptr_uid
- 1) = '\0';
840 sendto_server(client_p
->from
, NULL
, CAP_TS6
, NOCAPS
, "%s", buf_uid
);
847 set_final_mode(struct Mode
*mode
, struct Mode
*oldmode
)
849 int dir
= MODE_QUERY
, odir
= MODE_QUERY
;
850 char *pbuf
= parabuf
;
854 /* ok, first get a list of modes we need to add */
855 for (i
= 0; i
< 256; i
++)
857 if((mode
->mode
& chmode_flags
[i
]) && !(oldmode
->mode
& chmode_flags
[i
]))
859 if (chmode_table
[i
].set_func
== chm_hidden
)
881 /* now the ones we need to remove. */
882 for (i
= 0; i
< 256; i
++)
884 if((oldmode
->mode
& chmode_flags
[i
]) && !(mode
->mode
& chmode_flags
[i
]))
886 if(chmode_table
[i
].set_func
== chm_hidden
)
907 if(oldmode
->limit
&& !mode
->limit
)
916 if(oldmode
->key
[0] && !mode
->key
[0])
924 len
= rb_sprintf(pbuf
, "%s ", oldmode
->key
);
927 if(oldmode
->join_num
&& !mode
->join_num
)
936 if(oldmode
->forward
[0] && !mode
->forward
[0])
945 if(mode
->limit
&& oldmode
->limit
!= mode
->limit
)
953 len
= rb_sprintf(pbuf
, "%d ", mode
->limit
);
956 if(mode
->key
[0] && strcmp(oldmode
->key
, mode
->key
))
964 len
= rb_sprintf(pbuf
, "%s ", mode
->key
);
967 if(mode
->join_num
&& (oldmode
->join_num
!= mode
->join_num
|| oldmode
->join_time
!= mode
->join_time
))
975 len
= rb_sprintf(pbuf
, "%d:%d ", mode
->join_num
, mode
->join_time
);
978 if(mode
->forward
[0] && strcmp(oldmode
->forward
, mode
->forward
) && ModuleModes
.MODE_FORWARD
)
986 len
= rb_sprintf(pbuf
, "%s ", mode
->forward
);
1000 remove_our_modes(struct Channel
*chptr
, struct Client
*source_p
)
1002 struct membership
*msptr
;
1004 char lmodebuf
[MODEBUFLEN
];
1005 char *lpara
[MAXMODEPARAMS
];
1012 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1015 RB_DLINK_FOREACH(ptr
, chptr
->members
.head
)
1019 /* If anyone can think of a way to do this that doesn't make babies cry
1020 * I would love to hear it - Taros */
1024 msptr
->flags
&= ~CHFL_ADMIN
;
1025 lpara
[count
++] = msptr
->client_p
->name
;
1028 /* Make sure it fits if +h, +o, or +v are involved */
1029 if(is_chanop(msptr
))
1031 if(count
>= MAXMODEPARAMS
)
1034 sendto_channel_local(ALL_MEMBERS
, chptr
,
1035 ":%s MODE %s %s %s %s %s %s",
1036 source_p
->name
, chptr
->chname
,
1037 lmodebuf
, lpara
[0], lpara
[1],
1038 lpara
[2], lpara
[3]);
1040 /* preserve the initial '-' */
1045 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1049 msptr
->flags
&= ~CHFL_CHANOP
;
1050 lpara
[count
++] = msptr
->client_p
->name
;
1053 if(is_halfop(msptr
))
1055 if(count
>= MAXMODEPARAMS
)
1058 sendto_channel_local(ALL_MEMBERS
, chptr
,
1059 ":%s MODE %s %s %s %s %s %s",
1060 source_p
->name
, chptr
->chname
,
1061 lmodebuf
, lpara
[0], lpara
[1],
1062 lpara
[2], lpara
[3]);
1064 /* preserve the initial '-' */
1069 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1073 msptr
->flags
&= ~CHFL_HALFOP
;
1074 lpara
[count
++] = msptr
->client_p
->name
;
1077 if(is_voiced(msptr
))
1079 if(count
>= MAXMODEPARAMS
)
1082 sendto_channel_local(ALL_MEMBERS
, chptr
,
1083 ":%s MODE %s %s %s %s %s %s",
1084 source_p
->name
, chptr
->chname
,
1085 lmodebuf
, lpara
[0], lpara
[1],
1086 lpara
[2], lpara
[3]);
1088 /* preserve the initial '-' */
1093 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1097 msptr
->flags
&= ~CHFL_VOICE
;
1098 lpara
[count
++] = msptr
->client_p
->name
;
1102 else if(is_chanop(msptr
))
1104 msptr
->flags
&= ~CHFL_CHANOP
;
1105 lpara
[count
++] = msptr
->client_p
->name
;
1108 /* Make sure it fits if +h or +v are involved */
1109 if(is_halfop(msptr
))
1111 if(count
>= MAXMODEPARAMS
)
1114 sendto_channel_local(ALL_MEMBERS
, chptr
,
1115 ":%s MODE %s %s %s %s %s %s",
1116 source_p
->name
, chptr
->chname
,
1117 lmodebuf
, lpara
[0], lpara
[1],
1118 lpara
[2], lpara
[3]);
1120 /* preserve the initial '-' */
1125 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1129 msptr
->flags
&= ~CHFL_HALFOP
;
1130 lpara
[count
++] = msptr
->client_p
->name
;
1133 if(is_voiced(msptr
))
1135 if(count
>= MAXMODEPARAMS
)
1138 sendto_channel_local(ALL_MEMBERS
, chptr
,
1139 ":%s MODE %s %s %s %s %s %s",
1140 source_p
->name
, chptr
->chname
,
1141 lmodebuf
, lpara
[0], lpara
[1],
1142 lpara
[2], lpara
[3]);
1144 /* preserve the initial '-' */
1149 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1153 msptr
->flags
&= ~CHFL_VOICE
;
1154 lpara
[count
++] = msptr
->client_p
->name
;
1158 else if(is_halfop(msptr
))
1160 msptr
->flags
&= ~CHFL_HALFOP
;
1161 lpara
[count
++] = msptr
->client_p
->name
;
1164 /* +hv, might not fit so check. */
1165 if(is_voiced(msptr
))
1167 if(count
>= MAXMODEPARAMS
)
1170 sendto_channel_local(ALL_MEMBERS
, chptr
,
1171 ":%s MODE %s %s %s %s %s %s",
1172 source_p
->name
, chptr
->chname
,
1173 lmodebuf
, lpara
[0], lpara
[1],
1174 lpara
[2], lpara
[3]);
1176 /* preserve the initial '-' */
1181 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1185 msptr
->flags
&= ~CHFL_VOICE
;
1186 lpara
[count
++] = msptr
->client_p
->name
;
1190 else if(is_voiced(msptr
))
1192 msptr
->flags
&= ~CHFL_VOICE
;
1193 lpara
[count
++] = msptr
->client_p
->name
;
1199 if(count
>= MAXMODEPARAMS
)
1202 sendto_channel_local(ALL_MEMBERS
, chptr
,
1203 ":%s MODE %s %s %s %s %s %s",
1204 source_p
->name
, chptr
->chname
, lmodebuf
,
1205 lpara
[0], lpara
[1], lpara
[2], lpara
[3]);
1210 for(i
= 0; i
< MAXMODEPARAMS
; i
++)
1218 sendto_channel_local(ALL_MEMBERS
, chptr
,
1219 ":%s MODE %s %s %s %s %s %s",
1220 source_p
->name
, chptr
->chname
, lmodebuf
,
1221 EmptyString(lpara
[0]) ? "" : lpara
[0],
1222 EmptyString(lpara
[1]) ? "" : lpara
[1],
1223 EmptyString(lpara
[2]) ? "" : lpara
[2],
1224 EmptyString(lpara
[3]) ? "" : lpara
[3]);
1229 /* remove_ban_list()
1231 * inputs - channel, source, list to remove, char of mode, caps needed
1233 * side effects - given list is removed, with modes issued to local clients
1236 remove_ban_list(struct Channel
*chptr
, struct Client
*source_p
,
1237 rb_dlink_list
* list
, char c
, int mems
)
1239 static char lmodebuf
[BUFSIZE
];
1240 static char lparabuf
[BUFSIZE
];
1243 rb_dlink_node
*next_ptr
;
1246 int cur_len
, mlen
, plen
;
1250 cur_len
= mlen
= rb_sprintf(lmodebuf
, ":%s MODE %s -", source_p
->name
, chptr
->chname
);
1251 mbuf
= lmodebuf
+ mlen
;
1253 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, list
->head
)
1257 /* trailing space, and the mode letter itself */
1258 plen
= strlen(banptr
->banstr
) + 2;
1260 if(count
>= MAXMODEPARAMS
|| (cur_len
+ plen
) > BUFSIZE
- 4)
1262 /* remove trailing space */
1266 sendto_channel_local(mems
, chptr
, "%s %s", lmodebuf
, lparabuf
);
1269 mbuf
= lmodebuf
+ mlen
;
1276 pbuf
+= rb_sprintf(pbuf
, "%s ", banptr
->banstr
);
1284 sendto_channel_local(mems
, chptr
, "%s %s", lmodebuf
, lparabuf
);
1286 list
->head
= list
->tail
= NULL
;