ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/channel.c
Revision: 5591
Committed: Tue Feb 17 17:55:40 2015 UTC (9 years, 1 month ago) by michael
Content type: text/x-csrc
File size: 34670 byte(s)
Log Message:
- Sprinkle some assert()

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2916 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 5346 * Copyright (c) 1997-2015 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22     /*! \file channel.c
23     * \brief Responsible for managing channels, members, bans and topics
24 knight 31 * \version $Id$
25 adx 30 */
26    
27     #include "stdinc.h"
28 michael 1011 #include "list.h"
29 adx 30 #include "channel.h"
30     #include "channel_mode.h"
31     #include "client.h"
32     #include "hash.h"
33 michael 1632 #include "conf.h"
34 michael 371 #include "hostmask.h"
35 adx 30 #include "irc_string.h"
36     #include "ircd.h"
37     #include "numeric.h"
38 michael 3347 #include "server.h"
39 adx 30 #include "send.h"
40     #include "event.h"
41     #include "memory.h"
42 michael 1654 #include "mempool.h"
43 michael 3347 #include "misc.h"
44 michael 1826 #include "resv.h"
45 adx 30
46 michael 3235
47 michael 3945 dlink_list channel_list;
48 michael 1654 mp_pool_t *ban_pool; /*! \todo ban_pool shouldn't be a global var */
49 adx 30
50 michael 4095 struct event splitmode_event =
51     {
52     .name = "check_splitmode",
53     .handler = check_splitmode,
54 michael 4132 .when = 5
55 michael 4095 };
56    
57 michael 3250 static mp_pool_t *member_pool, *channel_pool;
58 adx 30
59    
60     /*! \brief Initializes the channel blockheap, adds known channel CAPAB
61     */
62     void
63 michael 1798 channel_init(void)
64 adx 30 {
65     add_capability("EX", CAP_EX, 1);
66     add_capability("IE", CAP_IE, 1);
67    
68 michael 1654 channel_pool = mp_pool_new(sizeof(struct Channel), MP_CHUNK_SIZE_CHANNEL);
69     ban_pool = mp_pool_new(sizeof(struct Ban), MP_CHUNK_SIZE_BAN);
70     member_pool = mp_pool_new(sizeof(struct Membership), MP_CHUNK_SIZE_MEMBER);
71 adx 30 }
72    
73 michael 3308 /*! \brief Adds a user to a channel by adding another link to the
74 adx 30 * channels member chain.
75 michael 3308 * \param chptr Pointer to channel to add client to
76     * \param who Pointer to client (who) to add
77     * \param flags Flags for chanops etc
78     * \param flood_ctrl Whether to count this join in flood calculations
79 adx 30 */
80     void
81     add_user_to_channel(struct Channel *chptr, struct Client *who,
82     unsigned int flags, int flood_ctrl)
83     {
84 michael 4816 struct Membership *member = NULL;
85 adx 30
86 michael 5591 assert(IsClient(who));
87    
88 adx 30 if (GlobalSetOptions.joinfloodtime > 0)
89     {
90     if (flood_ctrl)
91 michael 3250 ++chptr->number_joined;
92 adx 30
93     chptr->number_joined -= (CurrentTime - chptr->last_join_time) *
94     (((float)GlobalSetOptions.joinfloodcount) /
95     (float)GlobalSetOptions.joinfloodtime);
96    
97     if (chptr->number_joined <= 0)
98     {
99     chptr->number_joined = 0;
100     ClearJoinFloodNoticed(chptr);
101     }
102     else if (chptr->number_joined >= GlobalSetOptions.joinfloodcount)
103     {
104     chptr->number_joined = GlobalSetOptions.joinfloodcount;
105    
106     if (!IsSetJoinFloodNoticed(chptr))
107     {
108     SetJoinFloodNoticed(chptr);
109 michael 1618 sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
110 adx 30 "Possible Join Flooder %s on %s target: %s",
111     get_client_name(who, HIDE_IP),
112 michael 4617 who->servptr->name, chptr->name);
113 adx 30 }
114     }
115    
116     chptr->last_join_time = CurrentTime;
117     }
118    
119 michael 4816 member = mp_pool_get(member_pool);
120     member->client_p = who;
121     member->chptr = chptr;
122     member->flags = flags;
123 adx 30
124 michael 4816 dlinkAdd(member, &member->channode, &chptr->members);
125 michael 4171
126     if (MyConnect(who))
127 michael 4816 dlinkAdd(member, &member->locchannode, &chptr->locmembers);
128 michael 4171
129 michael 4816 dlinkAdd(member, &member->usernode, &who->channel);
130 adx 30 }
131    
132 michael 3308 /*! \brief Deletes an user from a channel by removing a link in the
133 adx 30 * channels member chain.
134 michael 3308 * \param member Pointer to Membership struct
135 adx 30 */
136     void
137     remove_user_from_channel(struct Membership *member)
138     {
139 michael 4976 struct Client *const client_p = member->client_p;
140     struct Channel *const chptr = member->chptr;
141 adx 30
142     dlinkDelete(&member->channode, &chptr->members);
143 michael 4171
144     if (MyConnect(client_p))
145     dlinkDelete(&member->locchannode, &chptr->locmembers);
146    
147 adx 30 dlinkDelete(&member->usernode, &client_p->channel);
148    
149 michael 1654 mp_pool_release(member);
150 adx 30
151 michael 1011 if (chptr->members.head == NULL)
152 adx 30 destroy_channel(chptr);
153     }
154    
155     /* send_members()
156     *
157     * inputs -
158     * output - NONE
159     * side effects -
160     */
161     static void
162 michael 4784 send_members(struct Client *client_p, const struct Channel *chptr,
163 michael 3145 char *modebuf, char *parabuf)
164 adx 30 {
165 michael 4389 char buf[IRCD_BUFSIZE] = "";
166 michael 4801 const dlink_node *node = NULL;
167 adx 30 int tlen; /* length of text to append */
168     char *t, *start; /* temp char pointer */
169    
170 michael 1847 start = t = buf + snprintf(buf, sizeof(buf), ":%s SJOIN %lu %s %s %s:",
171 michael 4817 me.id, (unsigned long)chptr->creationtime,
172 michael 4617 chptr->name, modebuf, parabuf);
173 adx 30
174 michael 4801 DLINK_FOREACH(node, chptr->members.head)
175 adx 30 {
176 michael 4816 const struct Membership *member = node->data;
177 adx 30
178 michael 4816 tlen = strlen(member->client_p->id) + 1; /* +1 for space */
179 adx 30
180 michael 4816 if (member->flags & CHFL_CHANOP)
181 michael 3250 ++tlen;
182 michael 4816 if (member->flags & CHFL_HALFOP)
183 michael 3250 ++tlen;
184 michael 4816 if (member->flags & CHFL_VOICE)
185 michael 3250 ++tlen;
186 adx 30
187 michael 3250 /*
188     * Space will be converted into CR, but we also need space for LF..
189 michael 3783 * That's why we use '- 1' here -adx
190 michael 3250 */
191 michael 1330 if (t + tlen - buf > IRCD_BUFSIZE - 1)
192 adx 30 {
193 michael 3250 *(t - 1) = '\0'; /* Kill the space and terminate the string */
194 adx 30 sendto_one(client_p, "%s", buf);
195     t = start;
196     }
197    
198 michael 4816 if (member->flags & CHFL_CHANOP)
199 michael 3140 *t++ = '@';
200 michael 4816 if (member->flags & CHFL_HALFOP)
201 michael 3140 *t++ = '%';
202 michael 4816 if (member->flags & CHFL_VOICE)
203 adx 356 *t++ = '+';
204 adx 30
205 michael 4816 strcpy(t, member->client_p->id);
206 michael 3135
207 adx 30 t += strlen(t);
208     *t++ = ' ';
209     }
210    
211 michael 3250 /* Should always be non-NULL unless we have a kind of persistent channels */
212 michael 3235 if (chptr->members.head)
213 michael 3250 t--; /* Take the space out */
214 adx 30 *t = '\0';
215     sendto_one(client_p, "%s", buf);
216     }
217    
218 michael 3308 /*! \brief Sends +b/+e/+I
219     * \param client_p Client pointer to server
220     * \param chptr Pointer to channel
221 michael 3998 * \param list Pointer to list of modes to send
222 michael 3308 * \param flag Char flag flagging type of mode. Currently this can be 'b', e' or 'I'
223 adx 30 */
224     static void
225 michael 4784 send_mode_list(struct Client *client_p, const struct Channel *chptr,
226 michael 4390 const dlink_list *list, const char flag)
227 adx 30 {
228 michael 4801 const dlink_node *node = NULL;
229 michael 4389 char mbuf[IRCD_BUFSIZE] = "";
230 michael 3215 char pbuf[IRCD_BUFSIZE] = "";
231 michael 3524 int tlen, mlen, cur_len;
232 michael 3144 char *pp = pbuf;
233 adx 30
234 michael 4976 if (!list->length)
235 adx 30 return;
236    
237 michael 4389 mlen = snprintf(mbuf, sizeof(mbuf), ":%s BMASK %lu %s %c :", me.id,
238 michael 4817 (unsigned long)chptr->creationtime, chptr->name, flag);
239 michael 3135 cur_len = mlen;
240 adx 30
241 michael 4801 DLINK_FOREACH(node, list->head)
242 adx 30 {
243 michael 4816 const struct Ban *ban = node->data;
244 adx 30
245 michael 4816 tlen = ban->len + 3; /* +3 for ! + @ + space */
246 adx 30
247     /*
248 michael 3995 * Send buffer and start over if we cannot fit another ban
249 adx 30 */
250 michael 3135 if (cur_len + (tlen - 1) > IRCD_BUFSIZE - 2)
251 adx 30 {
252 michael 3250 *(pp - 1) = '\0'; /* Get rid of trailing space on buffer */
253 michael 4389 sendto_one(client_p, "%s%s", mbuf, pbuf);
254 adx 30
255 michael 3135 cur_len = mlen;
256 adx 30 pp = pbuf;
257     }
258    
259 michael 4816 pp += sprintf(pp, "%s!%s@%s ", ban->name, ban->user, ban->host);
260 adx 30 cur_len += tlen;
261     }
262    
263 michael 3250 *(pp - 1) = '\0'; /* Get rid of trailing space on buffer */
264 michael 4389 sendto_one(client_p, "%s%s", mbuf, pbuf);
265 adx 30 }
266    
267 michael 3308 /*! \brief Send "client_p" a full list of the modes for channel chptr
268     * \param client_p Pointer to client client_p
269     * \param chptr Pointer to channel pointer
270 adx 30 */
271     void
272     send_channel_modes(struct Client *client_p, struct Channel *chptr)
273     {
274 michael 3145 char modebuf[MODEBUFLEN] = "";
275     char parabuf[MODEBUFLEN] = "";
276    
277 adx 30 channel_modes(chptr, client_p, modebuf, parabuf);
278     send_members(client_p, chptr, modebuf, parabuf);
279    
280     send_mode_list(client_p, chptr, &chptr->banlist, 'b');
281 michael 1661 send_mode_list(client_p, chptr, &chptr->exceptlist, 'e');
282     send_mode_list(client_p, chptr, &chptr->invexlist, 'I');
283 adx 30 }
284    
285 michael 3308 /*! \brief Check channel name for invalid characters
286     * \param name Pointer to channel name string
287     * \param local Indicates whether it's a local or remote creation
288 michael 632 * \return 0 if invalid, 1 otherwise
289 adx 30 */
290     int
291 michael 1847 check_channel_name(const char *name, const int local)
292 adx 30 {
293 michael 632 const char *p = name;
294 michael 3422
295 michael 5591 assert(!EmptyString(p));
296 adx 30
297 michael 632 if (!IsChanPrefix(*p))
298     return 0;
299 adx 30
300 db 633 if (!local || !ConfigChannel.disable_fake_channels)
301 michael 632 {
302     while (*++p)
303 db 634 if (!IsChanChar(*p))
304 michael 632 return 0;
305     }
306     else
307     {
308     while (*++p)
309 db 634 if (!IsVisibleChanChar(*p))
310 michael 632 return 0;
311     }
312    
313 michael 3422 return p - name <= CHANNELLEN;
314 adx 30 }
315    
316     void
317 michael 4816 remove_ban(struct Ban *ban, dlink_list *list)
318 adx 30 {
319 michael 4816 dlinkDelete(&ban->node, list);
320 adx 30
321 michael 4816 MyFree(ban->name);
322     MyFree(ban->user);
323     MyFree(ban->host);
324     MyFree(ban->who);
325 adx 30
326 michael 4816 mp_pool_release(ban);
327 adx 30 }
328    
329     /* free_channel_list()
330     *
331     * inputs - pointer to dlink_list
332     * output - NONE
333     * side effects -
334     */
335     void
336     free_channel_list(dlink_list *list)
337     {
338 michael 4801 dlink_node *node = NULL, *node_next = NULL;
339 adx 30
340 michael 4801 DLINK_FOREACH_SAFE(node, node_next, list->head)
341     remove_ban(node->data, list);
342 adx 30
343     assert(list->tail == NULL && list->head == NULL);
344     }
345    
346 michael 4617 /*! \brief Get Channel block for name (and allocate a new channel
347 adx 30 * block, if it didn't exist before)
348 michael 4617 * \param name Channel name
349 michael 3308 * \return Channel block
350 adx 30 */
351     struct Channel *
352 michael 4617 make_channel(const char *name)
353 adx 30 {
354     struct Channel *chptr = NULL;
355    
356 michael 4617 assert(!EmptyString(name));
357 adx 30
358 michael 1654 chptr = mp_pool_get(channel_pool);
359 adx 30
360 michael 3308 /* Doesn't hurt to set it here */
361 michael 4817 chptr->creationtime = CurrentTime;
362 michael 632 chptr->last_join_time = CurrentTime;
363 adx 30
364 michael 4617 strlcpy(chptr->name, name, sizeof(chptr->name));
365 michael 3945 dlinkAdd(chptr, &chptr->node, &channel_list);
366 adx 30
367     hash_add_channel(chptr);
368    
369     return chptr;
370     }
371    
372 michael 3308 /*! \brief Walk through this channel, and destroy it.
373     * \param chptr Channel pointer
374 adx 30 */
375     void
376     destroy_channel(struct Channel *chptr)
377     {
378 michael 4812 clear_invites(chptr);
379 adx 30
380 michael 3308 /* Free ban/exception/invex lists */
381 adx 30 free_channel_list(&chptr->banlist);
382     free_channel_list(&chptr->exceptlist);
383     free_channel_list(&chptr->invexlist);
384    
385 michael 3945 dlinkDelete(&chptr->node, &channel_list);
386 adx 30 hash_del_channel(chptr);
387    
388 michael 1654 mp_pool_release(chptr);
389 adx 30 }
390    
391     /*!
392 michael 3308 * \param chptr Pointer to channel
393     * \return String pointer "=" if public, "@" if secret else "*"
394 adx 30 */
395     static const char *
396 michael 1013 channel_pub_or_secret(const struct Channel *chptr)
397 adx 30 {
398     if (SecretChannel(chptr))
399     return "@";
400     if (PrivateChannel(chptr))
401     return "*";
402     return "=";
403     }
404    
405     /*! \brief lists all names on given channel
406 michael 3308 * \param source_p Pointer to client struct requesting names
407     * \param chptr Pointer to channel block
408     * \param show_eon Show RPL_ENDOFNAMES numeric or not
409 adx 30 * (don't want it with /names with no params)
410     */
411     void
412     channel_member_names(struct Client *source_p, struct Channel *chptr,
413     int show_eon)
414     {
415 michael 4801 const dlink_node *node = NULL;
416 michael 4389 char buf[IRCD_BUFSIZE + 1] = "";
417 adx 30 char *t = NULL, *start = NULL;
418     int tlen = 0;
419 michael 4834 const int is_member = IsMember(source_p, chptr);
420     const int multi_prefix = HasCap(source_p, CAP_MULTI_PREFIX) != 0;
421     const int uhnames = HasCap(source_p, CAP_UHNAMES) != 0;
422 adx 30
423 michael 5591 assert(IsClient(source_p));
424    
425 adx 30 if (PubChannel(chptr) || is_member)
426     {
427 michael 4389 t = buf + snprintf(buf, sizeof(buf), numeric_form(RPL_NAMREPLY),
428     me.name, source_p->name,
429 michael 4617 channel_pub_or_secret(chptr), chptr->name);
430 adx 30 start = t;
431    
432 michael 4801 DLINK_FOREACH(node, chptr->members.head)
433 adx 30 {
434 michael 4816 const struct Membership *member = node->data;
435 adx 30
436 michael 4816 if (HasUMode(member->client_p, UMODE_INVISIBLE) && !is_member)
437 adx 30 continue;
438    
439 michael 2910 if (!uhnames)
440 michael 4816 tlen = strlen(member->client_p->name) + 1; /* +1 for space */
441 michael 2910 else
442 michael 4816 tlen = strlen(member->client_p->name) + strlen(member->client_p->username) +
443     strlen(member->client_p->host) + 3; /* +3 for ! + @ + space */
444 adx 30
445 michael 506 if (!multi_prefix)
446     {
447 michael 4816 if (member->flags & (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE))
448 michael 506 ++tlen;
449     }
450     else
451     {
452 michael 4816 if (member->flags & CHFL_CHANOP)
453 michael 506 ++tlen;
454 michael 4816 if (member->flags & CHFL_HALFOP)
455 michael 506 ++tlen;
456 michael 4816 if (member->flags & CHFL_VOICE)
457 michael 506 ++tlen;
458     }
459    
460 michael 4389 if (t + tlen - buf > IRCD_BUFSIZE - 2)
461 adx 30 {
462     *(t - 1) = '\0';
463 michael 4389 sendto_one(source_p, "%s", buf);
464 adx 30 t = start;
465     }
466    
467 michael 2910 if (!uhnames)
468 michael 4816 t += sprintf(t, "%s%s ", get_member_status(member, multi_prefix),
469     member->client_p->name);
470 michael 2910 else
471 michael 4816 t += sprintf(t, "%s%s!%s@%s ", get_member_status(member, multi_prefix),
472     member->client_p->name, member->client_p->username,
473     member->client_p->host);
474 adx 30 }
475    
476 michael 3215 if (tlen)
477 adx 30 {
478     *(t - 1) = '\0';
479 michael 4389 sendto_one(source_p, "%s", buf);
480 adx 30 }
481     }
482    
483     if (show_eon)
484 michael 4617 sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, chptr->name);
485 adx 30 }
486    
487 michael 3308 /*! \brief Adds client to invite list
488     * \param chptr Pointer to channel block
489     * \param who Pointer to client to add invite to
490 adx 30 */
491     void
492     add_invite(struct Channel *chptr, struct Client *who)
493     {
494 michael 5591 assert(IsClient(who));
495    
496 adx 30 del_invite(chptr, who);
497    
498     /*
499 michael 3308 * Delete last link in chain if the list is max length
500 adx 30 */
501 michael 4589 if (dlink_list_length(&who->connection->invited) >=
502 michael 3934 ConfigChannel.max_channels)
503 michael 4589 del_invite(who->connection->invited.tail->data, who);
504 adx 30
505 michael 3308 /* Add client to channel invite list */
506 adx 30 dlinkAdd(who, make_dlink_node(), &chptr->invites);
507    
508 michael 3308 /* Add channel to the end of the client invite list */
509 michael 4589 dlinkAdd(chptr, make_dlink_node(), &who->connection->invited);
510 adx 30 }
511    
512     /*! \brief Delete Invite block from channel invite list
513     * and client invite list
514 michael 3308 * \param chptr Pointer to Channel struct
515     * \param who Pointer to client to remove invites from
516 adx 30 */
517     void
518     del_invite(struct Channel *chptr, struct Client *who)
519     {
520 michael 4801 dlink_node *node = NULL;
521 adx 30
522 michael 4801 if ((node = dlinkFindDelete(&who->connection->invited, chptr)))
523     free_dlink_node(node);
524 adx 30
525 michael 4801 if ((node = dlinkFindDelete(&chptr->invites, who)))
526     free_dlink_node(node);
527 adx 30 }
528    
529 michael 4812 /*! \brief Removes all invites of a specific channel
530     * \param chptr Pointer to Channel struct
531     */
532     void
533     clear_invites(struct Channel *chptr)
534     {
535     dlink_node *node = NULL, *node_next = NULL;
536    
537     DLINK_FOREACH_SAFE(node, node_next, chptr->invites.head)
538     del_invite(chptr, node->data);
539     }
540    
541 adx 30 /* get_member_status()
542     *
543     * inputs - pointer to struct Membership
544     * - YES if we can combine different flags
545     * output - string either @, +, % or "" depending on whether
546     * chanop, voiced or user
547     * side effects -
548     *
549     * NOTE: Returned string is usually a static buffer
550     * (like in get_client_name)
551     */
552     const char *
553 michael 4816 get_member_status(const struct Membership *member, const int combine)
554 adx 30 {
555 michael 4046 static char buffer[4]; /* 4 for @%+\0 */
556 michael 1902 char *p = buffer;
557 adx 30
558 michael 4816 if (member->flags & CHFL_CHANOP)
559 adx 30 {
560     if (!combine)
561     return "@";
562     *p++ = '@';
563     }
564    
565 michael 4816 if (member->flags & CHFL_HALFOP)
566 adx 30 {
567     if (!combine)
568     return "%";
569     *p++ = '%';
570     }
571    
572 michael 4816 if (member->flags & CHFL_VOICE)
573 adx 30 *p++ = '+';
574     *p = '\0';
575    
576     return buffer;
577     }
578    
579     /*!
580 michael 3308 * \param who Pointer to Client to check
581     * \param list Pointer to ban list to search
582 adx 30 * \return 1 if ban found for given n!u\@h mask, 0 otherwise
583     */
584     static int
585     find_bmask(const struct Client *who, const dlink_list *const list)
586     {
587 michael 4801 const dlink_node *node = NULL;
588 adx 30
589 michael 4801 DLINK_FOREACH(node, list->head)
590 adx 30 {
591 michael 4816 const struct Ban *ban = node->data;
592 adx 30
593 michael 4816 if (!match(ban->name, who->name) && !match(ban->user, who->username))
594 michael 371 {
595 michael 4816 switch (ban->type)
596 michael 371 {
597     case HM_HOST:
598 michael 4816 if (!match(ban->host, who->host) || !match(ban->host, who->sockhost))
599 michael 371 return 1;
600     break;
601     case HM_IPV4:
602 michael 4589 if (who->connection->aftype == AF_INET)
603 michael 4816 if (match_ipv4(&who->connection->ip, &ban->addr, ban->bits))
604 michael 371 return 1;
605     break;
606     case HM_IPV6:
607 michael 4589 if (who->connection->aftype == AF_INET6)
608 michael 4816 if (match_ipv6(&who->connection->ip, &ban->addr, ban->bits))
609 michael 371 return 1;
610     break;
611     default:
612     assert(0);
613     }
614     }
615 adx 30 }
616    
617     return 0;
618     }
619    
620     /*!
621 michael 3308 * \param chptr Pointer to channel block
622     * \param who Pointer to client to check access fo
623 adx 30 * \return 0 if not banned, 1 otherwise
624     */
625     int
626 michael 1013 is_banned(const struct Channel *chptr, const struct Client *who)
627 adx 30 {
628 michael 632 if (find_bmask(who, &chptr->banlist))
629 michael 1495 if (!find_bmask(who, &chptr->exceptlist))
630 michael 632 return 1;
631 adx 30
632 michael 632 return 0;
633 adx 30 }
634    
635 michael 3308 /*! Tests if a client can join a certain channel
636     * \param source_p Pointer to client attempting to join
637     * \param chptr Pointer to channel
638     * \param key Key sent by client attempting to join if present
639 adx 30 * \return ERR_BANNEDFROMCHAN, ERR_INVITEONLYCHAN, ERR_CHANNELISFULL
640     * or 0 if allowed to join.
641     */
642 michael 1834 int
643 michael 4784 can_join(struct Client *source_p, const struct Channel *chptr, const char *key)
644 adx 30 {
645 michael 2246 if ((chptr->mode.mode & MODE_SSLONLY) && !HasUMode(source_p, UMODE_SSL))
646 michael 1150 return ERR_SSLONLYCHAN;
647    
648 michael 1173 if ((chptr->mode.mode & MODE_REGONLY) && !HasUMode(source_p, UMODE_REGISTERED))
649     return ERR_NEEDREGGEDNICK;
650    
651 michael 1219 if ((chptr->mode.mode & MODE_OPERONLY) && !HasUMode(source_p, UMODE_OPER))
652 michael 1150 return ERR_OPERONLYCHAN;
653    
654 adx 30 if (chptr->mode.mode & MODE_INVITEONLY)
655 michael 4589 if (!dlinkFind(&source_p->connection->invited, chptr))
656 michael 1495 if (!find_bmask(source_p, &chptr->invexlist))
657 adx 30 return ERR_INVITEONLYCHAN;
658    
659 michael 1430 if (chptr->mode.key[0] && (!key || strcmp(chptr->mode.key, key)))
660 adx 30 return ERR_BADCHANNELKEY;
661    
662     if (chptr->mode.limit && dlink_list_length(&chptr->members) >=
663     chptr->mode.limit)
664     return ERR_CHANNELISFULL;
665    
666 michael 2208 if (is_banned(chptr, source_p))
667     return ERR_BANNEDFROMCHAN;
668    
669 michael 1834 return 0;
670 adx 30 }
671    
672     int
673 michael 4816 has_member_flags(const struct Membership *member, const unsigned int flags)
674 adx 30 {
675 michael 4816 return member && (member->flags & flags);
676 adx 30 }
677    
678     struct Membership *
679     find_channel_link(struct Client *client_p, struct Channel *chptr)
680     {
681 michael 4801 dlink_node *node = NULL;
682 adx 30
683     if (!IsClient(client_p))
684     return NULL;
685    
686 michael 2567 if (dlink_list_length(&chptr->members) < dlink_list_length(&client_p->channel))
687     {
688 michael 4801 DLINK_FOREACH(node, chptr->members.head)
689     if (((struct Membership *)node->data)->client_p == client_p)
690     return node->data;
691 michael 2567 }
692     else
693     {
694 michael 4801 DLINK_FOREACH(node, client_p->channel.head)
695     if (((struct Membership *)node->data)->chptr == chptr)
696     return node->data;
697 michael 2567 }
698 adx 30
699     return NULL;
700     }
701    
702 michael 4782 /*! Checks if a message contains control codes
703 michael 3889 * \param message The actual message string the client wants to send
704     * \return 1 if the message does contain any control codes, 0 otherwise
705 michael 1937 */
706     static int
707     msg_has_ctrls(const char *message)
708     {
709     const unsigned char *p = (const unsigned char *)message;
710    
711     for (; *p; ++p)
712     {
713     if (*p > 31 || *p == 1)
714 michael 3953 continue; /* No control code or CTCP */
715 michael 1937
716 michael 3889 if (*p == 27) /* Escape */
717 michael 1937 {
718 michael 3889 /* ISO 2022 charset shift sequence */
719 michael 1937 if (*(p + 1) == '$' ||
720     *(p + 1) == '(')
721     {
722     ++p;
723     continue;
724     }
725     }
726    
727 michael 3889 return 1; /* Control code */
728 michael 1937 }
729    
730 michael 4782 return 0; /* No control code found */
731 michael 1937 }
732    
733 michael 3308 /*! Tests if a client can send to a channel
734     * \param chptr Pointer to Channel struct
735     * \param source_p Pointer to Client struct
736 michael 4816 * \param member Pointer to Membership struct (can be NULL)
737 michael 3308 * \param message The actual message string the client wants to send
738 adx 30 * \return CAN_SEND_OPV if op or voiced on channel\n
739     * CAN_SEND_NONOP if can send to channel but is not an op\n
740 michael 1173 * ERR_CANNOTSENDTOCHAN or ERR_NEEDREGGEDNICK if they cannot send to channel\n
741 adx 30 */
742     int
743 michael 1937 can_send(struct Channel *chptr, struct Client *source_p,
744 michael 4816 struct Membership *member, const char *message)
745 adx 30 {
746 michael 4784 const struct MaskItem *conf = NULL;
747 michael 1858
748 michael 1219 if (IsServer(source_p) || HasFlag(source_p, FLAGS_SERVICE))
749 adx 30 return CAN_SEND_OPV;
750    
751 michael 565 if (MyClient(source_p) && !IsExemptResv(source_p))
752 michael 4341 if (!(HasUMode(source_p, UMODE_OPER) && ConfigGeneral.oper_pass_resv))
753 michael 4617 if ((conf = match_find_resv(chptr->name)) && !resv_find_exempt(source_p, conf))
754 michael 1834 return ERR_CANNOTSENDTOCHAN;
755 adx 30
756 michael 1944 if ((chptr->mode.mode & MODE_NOCTRL) && msg_has_ctrls(message))
757     return ERR_NOCTRLSONCHAN;
758 michael 4883
759 michael 5463 if (chptr->mode.mode & MODE_NOCTCP)
760 michael 5466 if (*message == '\001' && strncmp(message + 1, "ACTION ", 7))
761 michael 5463 return ERR_NOCTCP;
762    
763 michael 4816 if (member || (member = find_channel_link(source_p, chptr)))
764 michael 5582 if (member->flags & (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE))
765 adx 30 return CAN_SEND_OPV;
766 michael 4883
767 michael 4816 if (!member && (chptr->mode.mode & MODE_NOPRIVMSGS))
768 michael 2441 return ERR_CANNOTSENDTOCHAN;
769 michael 4883
770 michael 1944 if (chptr->mode.mode & MODE_MODERATED)
771     return ERR_CANNOTSENDTOCHAN;
772 michael 4883
773 michael 1954 if ((chptr->mode.mode & MODE_MODREG) && !HasUMode(source_p, UMODE_REGISTERED))
774 michael 1944 return ERR_NEEDREGGEDNICK;
775 adx 30
776 michael 3308 /* Cache can send if banned */
777 michael 1944 if (MyClient(source_p))
778     {
779 michael 4816 if (member)
780 adx 30 {
781 michael 4816 if (member->flags & CHFL_BAN_SILENCED)
782 michael 1834 return ERR_CANNOTSENDTOCHAN;
783 adx 30
784 michael 4816 if (!(member->flags & CHFL_BAN_CHECKED))
785 adx 30 {
786     if (is_banned(chptr, source_p))
787     {
788 michael 5582 member->flags |= (CHFL_BAN_CHECKED | CHFL_BAN_SILENCED);
789 michael 1834 return ERR_CANNOTSENDTOCHAN;
790 adx 30 }
791    
792 michael 4816 member->flags |= CHFL_BAN_CHECKED;
793 adx 30 }
794     }
795 michael 1944 else if (is_banned(chptr, source_p))
796 michael 1941 return ERR_CANNOTSENDTOCHAN;
797     }
798 adx 30
799     return CAN_SEND_NONOP;
800     }
801    
802     /*! \brief Updates the client's oper_warn_count_down, warns the
803     * IRC operators if necessary, and updates
804     * join_leave_countdown as needed.
805 michael 3308 * \param source_p Pointer to struct Client to check
806     * \param name Channel name or NULL if this is a part.
807 adx 30 */
808     void
809     check_spambot_warning(struct Client *source_p, const char *name)
810     {
811     int t_delta = 0;
812     int decrement_count = 0;
813    
814     if ((GlobalSetOptions.spam_num &&
815 michael 4589 (source_p->connection->join_leave_count >=
816 adx 30 GlobalSetOptions.spam_num)))
817     {
818 michael 4589 if (source_p->connection->oper_warn_count_down > 0)
819     source_p->connection->oper_warn_count_down--;
820 adx 30 else
821 michael 4589 source_p->connection->oper_warn_count_down = 0;
822 adx 30
823 michael 4589 if (source_p->connection->oper_warn_count_down == 0)
824 adx 30 {
825 michael 3308 /* It's already known as a possible spambot */
826 michael 3235 if (name)
827 michael 1618 sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
828 adx 30 "User %s (%s@%s) trying to join %s is a possible spambot",
829     source_p->name, source_p->username,
830     source_p->host, name);
831     else
832 michael 1618 sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
833 adx 30 "User %s (%s@%s) is a possible spambot",
834     source_p->name, source_p->username,
835     source_p->host);
836 michael 4589 source_p->connection->oper_warn_count_down = OPER_SPAM_COUNTDOWN;
837 adx 30 }
838     }
839     else
840     {
841 michael 4589 if ((t_delta = (CurrentTime - source_p->connection->last_leave_time)) >
842 adx 30 JOIN_LEAVE_COUNT_EXPIRE_TIME)
843     {
844     decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME);
845 michael 4883
846 michael 4589 if (decrement_count > source_p->connection->join_leave_count)
847     source_p->connection->join_leave_count = 0;
848 adx 30 else
849 michael 4589 source_p->connection->join_leave_count -= decrement_count;
850 adx 30 }
851     else
852     {
853 michael 4589 if ((CurrentTime - (source_p->connection->last_join_time)) <
854 adx 30 GlobalSetOptions.spam_time)
855 michael 4589 source_p->connection->join_leave_count++; /* It's a possible spambot */
856 adx 30 }
857    
858 michael 3215 if (name)
859 michael 4589 source_p->connection->last_join_time = CurrentTime;
860 adx 30 else
861 michael 4589 source_p->connection->last_leave_time = CurrentTime;
862 adx 30 }
863     }
864    
865 michael 3308 /*! \brief Compares usercount and servercount against their split
866 adx 30 * values and adjusts splitmode accordingly
867     * \param unused Unused address pointer
868     */
869     void
870     check_splitmode(void *unused)
871     {
872     if (splitchecking && (ConfigChannel.no_join_on_split ||
873     ConfigChannel.no_create_on_split))
874     {
875 michael 4208 const unsigned int server = dlink_list_length(&global_server_list);
876 adx 30
877     if (!splitmode && ((server < split_servers) || (Count.total < split_users)))
878     {
879     splitmode = 1;
880    
881 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
882 adx 30 "Network split, activating splitmode");
883 michael 4095 event_add(&splitmode_event, NULL);
884 adx 30 }
885 michael 4065 else if (splitmode && (server >= split_servers) && (Count.total >= split_users))
886 adx 30 {
887     splitmode = 0;
888    
889 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
890 adx 30 "Network rejoined, deactivating splitmode");
891 michael 4095 event_delete(&splitmode_event);
892 adx 30 }
893     }
894     }
895    
896 michael 3308 /*! \brief Sets the channel topic for a certain channel
897 adx 30 * \param chptr Pointer to struct Channel
898     * \param topic The topic string
899     * \param topic_info n!u\@h formatted string of the topic setter
900 michael 3308 * \param topicts Timestamp on the topic
901     * \param local Whether the topic is set by a local client
902 adx 30 */
903     void
904 michael 3940 channel_set_topic(struct Channel *chptr, const char *topic,
905 michael 1751 const char *topic_info, time_t topicts, int local)
906 adx 30 {
907 michael 1751 if (local)
908 michael 4341 strlcpy(chptr->topic, topic, IRCD_MIN(sizeof(chptr->topic), ConfigServerInfo.max_topic_length + 1));
909 michael 1751 else
910     strlcpy(chptr->topic, topic, sizeof(chptr->topic));
911    
912 michael 1203 strlcpy(chptr->topic_info, topic_info, sizeof(chptr->topic_info));
913 michael 2345 chptr->topic_time = topicts;
914 adx 30 }
915 michael 3913
916     /* do_join_0()
917     *
918     * inputs - pointer to client doing join 0
919     * output - NONE
920     * side effects - Use has decided to join 0. This is legacy
921     * from the days when channels were numbers not names. *sigh*
922     * There is a bunch of evilness necessary here due to
923     * anti spambot code.
924     */
925     void
926     channel_do_join_0(struct Client *source_p)
927     {
928 michael 4801 dlink_node *node = NULL, *node_next = NULL;
929 michael 3913
930     if (source_p->channel.head)
931     if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER))
932     check_spambot_warning(source_p, NULL);
933    
934 michael 4801 DLINK_FOREACH_SAFE(node, node_next, source_p->channel.head)
935 michael 3913 {
936 michael 4801 struct Channel *chptr = ((struct Membership *)node->data)->chptr;
937 michael 3913
938 michael 4963 sendto_server(source_p, 0, 0, ":%s PART %s",
939 michael 4617 source_p->id, chptr->name);
940 michael 4794 sendto_channel_local(0, chptr, ":%s!%s@%s PART %s",
941 michael 3913 source_p->name, source_p->username,
942 michael 4617 source_p->host, chptr->name);
943 michael 3913
944 michael 4801 remove_user_from_channel(node->data);
945 michael 3913 }
946     }
947    
948     static char *
949     channel_find_last0(struct Client *source_p, char *chanlist)
950     {
951     int join0 = 0;
952    
953     for (char *p = chanlist; *p; ++p) /* Find last "JOIN 0" */
954     {
955     if (*p == '0' && (*(p + 1) == ',' || *(p + 1) == '\0'))
956     {
957 michael 4757 if (*(p + 1) == ',')
958 michael 3913 ++p;
959    
960     chanlist = p + 1;
961     join0 = 1;
962     }
963     else
964     {
965     while (*p != ',' && *p != '\0') /* Skip past channel name */
966     ++p;
967    
968     if (*p == '\0') /* Hit the end */
969     break;
970     }
971     }
972    
973     if (join0)
974     channel_do_join_0(source_p);
975    
976     return chanlist;
977     }
978    
979     void
980 michael 3936 channel_do_join(struct Client *source_p, char *channel, char *key_list)
981 michael 3913 {
982     char *p = NULL;
983 michael 3936 char *chan = NULL;
984 michael 3913 char *chan_list = NULL;
985     struct Channel *chptr = NULL;
986     struct MaskItem *conf = NULL;
987 michael 4784 const struct ClassItem *const class = get_class_ptr(&source_p->connection->confs);
988 michael 3913 int i = 0;
989     unsigned int flags = 0;
990    
991 michael 5591 assert(IsClient(source_p));
992    
993 michael 3936 chan_list = channel_find_last0(source_p, channel);
994 michael 3913
995     for (chan = strtoken(&p, chan_list, ","); chan;
996     chan = strtoken(&p, NULL, ","))
997     {
998     const char *key = NULL;
999    
1000     /* If we have any more keys, take the first for this channel. */
1001     if (!EmptyString(key_list) && (key_list = strchr(key = key_list, ',')))
1002     *key_list++ = '\0';
1003    
1004     /* Empty keys are the same as no keys. */
1005     if (key && *key == '\0')
1006     key = NULL;
1007    
1008     if (!check_channel_name(chan, 1))
1009     {
1010     sendto_one_numeric(source_p, &me, ERR_BADCHANNAME, chan);
1011     continue;
1012     }
1013    
1014     if (!IsExemptResv(source_p) &&
1015 michael 4341 !(HasUMode(source_p, UMODE_OPER) && ConfigGeneral.oper_pass_resv) &&
1016 michael 3913 ((conf = match_find_resv(chan)) && !resv_find_exempt(source_p, conf)))
1017     {
1018     ++conf->count;
1019     sendto_one_numeric(source_p, &me, ERR_CHANBANREASON,
1020     chan, conf->reason ? conf->reason : "Reserved channel");
1021 michael 4152 sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
1022 michael 3913 "Forbidding reserved channel %s from user %s",
1023     chan, get_client_name(source_p, HIDE_IP));
1024     continue;
1025     }
1026    
1027     if (dlink_list_length(&source_p->channel) >=
1028 michael 3934 ((class->max_channels) ? class->max_channels : ConfigChannel.max_channels))
1029 michael 3913 {
1030     sendto_one_numeric(source_p, &me, ERR_TOOMANYCHANNELS, chan);
1031     break;
1032     }
1033    
1034     if ((chptr = hash_find_channel(chan)))
1035     {
1036     if (IsMember(source_p, chptr))
1037     continue;
1038    
1039     if (splitmode && !HasUMode(source_p, UMODE_OPER) &&
1040     ConfigChannel.no_join_on_split)
1041     {
1042 michael 4617 sendto_one_numeric(source_p, &me, ERR_UNAVAILRESOURCE, chptr->name);
1043 michael 3913 continue;
1044     }
1045    
1046     /*
1047     * can_join checks for +i key, bans.
1048     */
1049     if ((i = can_join(source_p, chptr, key)))
1050     {
1051 michael 4617 sendto_one_numeric(source_p, &me, i, chptr->name);
1052 michael 3913 continue;
1053     }
1054    
1055     /*
1056     * This should never be the case unless there is some sort of
1057     * persistant channels.
1058     */
1059 michael 4976 if (!dlink_list_length(&chptr->members))
1060 michael 3913 flags = CHFL_CHANOP;
1061     else
1062     flags = 0;
1063     }
1064     else
1065     {
1066     if (splitmode && !HasUMode(source_p, UMODE_OPER) &&
1067     (ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split))
1068     {
1069     sendto_one_numeric(source_p, &me, ERR_UNAVAILRESOURCE, chan);
1070     continue;
1071     }
1072    
1073     flags = CHFL_CHANOP;
1074     chptr = make_channel(chan);
1075     }
1076    
1077     if (!HasUMode(source_p, UMODE_OPER))
1078 michael 4617 check_spambot_warning(source_p, chptr->name);
1079 michael 3913
1080     add_user_to_channel(chptr, source_p, flags, 1);
1081    
1082     /*
1083 michael 5546 * Set timestamp if appropriate, and propagate
1084 michael 3913 */
1085     if (flags == CHFL_CHANOP)
1086     {
1087 michael 4817 chptr->creationtime = CurrentTime;
1088 michael 3913 chptr->mode.mode |= MODE_TOPICLIMIT;
1089     chptr->mode.mode |= MODE_NOPRIVMSGS;
1090    
1091 michael 4963 sendto_server(source_p, 0, 0, ":%s SJOIN %lu %s +nt :@%s",
1092 michael 4817 me.id, (unsigned long)chptr->creationtime,
1093 michael 4617 chptr->name, source_p->id);
1094 michael 3913
1095     /*
1096     * Notify all other users on the new channel
1097     */
1098 michael 4793 sendto_channel_local_butone(NULL, CAP_EXTENDED_JOIN, 0, chptr, ":%s!%s@%s JOIN %s %s :%s",
1099     source_p->name, source_p->username,
1100     source_p->host, chptr->name,
1101 michael 4820 (!IsDigit(source_p->account[0]) && source_p->account[0] != '*') ? source_p->account : "*",
1102 michael 4793 source_p->info);
1103     sendto_channel_local_butone(NULL, 0, CAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN :%s",
1104     source_p->name, source_p->username,
1105     source_p->host, chptr->name);
1106 michael 4794 sendto_channel_local(0, chptr, ":%s MODE %s +nt",
1107 michael 4617 me.name, chptr->name);
1108 michael 3913
1109     if (source_p->away[0])
1110 michael 4793 sendto_channel_local_butone(source_p, CAP_AWAY_NOTIFY, 0, chptr,
1111 michael 3913 ":%s!%s@%s AWAY :%s",
1112     source_p->name, source_p->username,
1113     source_p->host, source_p->away);
1114     }
1115     else
1116     {
1117 michael 4963 sendto_server(source_p, 0, 0, ":%s JOIN %lu %s +",
1118 michael 4817 source_p->id, (unsigned long)chptr->creationtime,
1119 michael 4617 chptr->name);
1120 michael 3913
1121 michael 4793 sendto_channel_local_butone(NULL, CAP_EXTENDED_JOIN, 0, chptr, ":%s!%s@%s JOIN %s %s :%s",
1122     source_p->name, source_p->username,
1123     source_p->host, chptr->name,
1124 michael 4820 (!IsDigit(source_p->account[0]) && source_p->account[0] != '*') ? source_p->account : "*",
1125 michael 4793 source_p->info);
1126     sendto_channel_local_butone(NULL, 0, CAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN :%s",
1127     source_p->name, source_p->username,
1128     source_p->host, chptr->name);
1129    
1130 michael 3913 if (source_p->away[0])
1131 michael 4793 sendto_channel_local_butone(source_p, CAP_AWAY_NOTIFY, 0, chptr,
1132 michael 3913 ":%s!%s@%s AWAY :%s",
1133     source_p->name, source_p->username,
1134     source_p->host, source_p->away);
1135     }
1136    
1137     del_invite(chptr, source_p);
1138    
1139     if (chptr->topic[0])
1140     {
1141 michael 4617 sendto_one_numeric(source_p, &me, RPL_TOPIC, chptr->name, chptr->topic);
1142     sendto_one_numeric(source_p, &me, RPL_TOPICWHOTIME, chptr->name,
1143 michael 3913 chptr->topic_info, chptr->topic_time);
1144     }
1145    
1146     channel_member_names(source_p, chptr, 1);
1147    
1148 michael 4589 source_p->connection->last_join_time = CurrentTime;
1149 michael 3913 }
1150     }
1151    
1152     /*! \brief Removes a client from a specific channel
1153     * \param source_p Pointer to source client to remove
1154     * \param name Name of channel to remove from
1155     * \param reason Part reason to show
1156     */
1157     static void
1158     channel_part_one_client(struct Client *source_p, const char *name, const char *reason)
1159     {
1160     struct Channel *chptr = NULL;
1161 michael 4816 struct Membership *member = NULL;
1162 michael 3913
1163     if ((chptr = hash_find_channel(name)) == NULL)
1164     {
1165     sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, name);
1166     return;
1167     }
1168    
1169 michael 4816 if ((member = find_channel_link(source_p, chptr)) == NULL)
1170 michael 3913 {
1171 michael 4617 sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, chptr->name);
1172 michael 3913 return;
1173     }
1174    
1175     if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER))
1176     check_spambot_warning(source_p, NULL);
1177    
1178     /*
1179     * Remove user from the old channel (if any)
1180     * only allow /part reasons in -m chans
1181     */
1182     if (*reason && (!MyConnect(source_p) ||
1183 michael 4816 ((can_send(chptr, source_p, member, reason) &&
1184 michael 4589 (source_p->connection->firsttime + ConfigGeneral.anti_spam_exit_message_time)
1185 michael 3913 < CurrentTime))))
1186     {
1187 michael 4963 sendto_server(source_p, 0, 0, ":%s PART %s :%s",
1188 michael 4617 source_p->id, chptr->name, reason);
1189 michael 4794 sendto_channel_local(0, chptr, ":%s!%s@%s PART %s :%s",
1190 michael 3913 source_p->name, source_p->username,
1191 michael 4617 source_p->host, chptr->name, reason);
1192 michael 3913 }
1193     else
1194     {
1195 michael 4963 sendto_server(source_p, 0, 0, ":%s PART %s",
1196 michael 4617 source_p->id, chptr->name);
1197 michael 4794 sendto_channel_local(0, chptr, ":%s!%s@%s PART %s",
1198 michael 3913 source_p->name, source_p->username,
1199 michael 4617 source_p->host, chptr->name);
1200 michael 3913 }
1201    
1202 michael 4816 remove_user_from_channel(member);
1203 michael 3913 }
1204    
1205     void
1206 michael 4784 channel_do_part(struct Client *source_p, char *channel, const char *reason)
1207 michael 3913 {
1208     char *p = NULL, *name = NULL;
1209 michael 4784 char buf[KICKLEN + 1] = "";
1210 michael 3913
1211 michael 5591 assert(IsClient(source_p));
1212    
1213 michael 3936 if (!EmptyString(reason))
1214 michael 4784 strlcpy(buf, reason, sizeof(buf));
1215 michael 3913
1216 michael 3936 for (name = strtoken(&p, channel, ","); name;
1217 michael 3913 name = strtoken(&p, NULL, ","))
1218 michael 4784 channel_part_one_client(source_p, name, buf);
1219 michael 3913 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision