ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/channel.c
Revision: 5852
Committed: Mon Apr 27 17:55:01 2015 UTC (10 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 34757 byte(s)
Log Message:
- Renamed clear_invites() to clear_invites_channel()
- Added separate clear_invites_client()

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 5347 * 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 4565 * 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 3944 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 4094 struct event splitmode_event =
51     {
52     .name = "check_splitmode",
53     .handler = check_splitmode,
54 michael 4133 .when = 5
55 michael 4094 };
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 michael 5796 add_capability("EX", CAP_EX);
66     add_capability("IE", CAP_IE);
67 adx 30
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 4815 struct Membership *member = NULL;
85 adx 30
86 michael 5590 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 4618 who->servptr->name, chptr->name);
113 adx 30 }
114     }
115    
116     chptr->last_join_time = CurrentTime;
117     }
118    
119 michael 4815 member = mp_pool_get(member_pool);
120     member->client_p = who;
121     member->chptr = chptr;
122     member->flags = flags;
123 adx 30
124 michael 4815 dlinkAdd(member, &member->channode, &chptr->members);
125 michael 4170
126     if (MyConnect(who))
127 michael 4815 dlinkAdd(member, &member->locchannode, &chptr->locmembers);
128 michael 4170
129 michael 4815 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 4977 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 4170
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 4785 send_members(struct Client *client_p, const struct Channel *chptr,
163 michael 3145 char *modebuf, char *parabuf)
164 adx 30 {
165 michael 4388 char buf[IRCD_BUFSIZE] = "";
166 michael 4800 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 4818 me.id, (unsigned long)chptr->creationtime,
172 michael 4618 chptr->name, modebuf, parabuf);
173 adx 30
174 michael 4800 DLINK_FOREACH(node, chptr->members.head)
175 adx 30 {
176 michael 4815 const struct Membership *member = node->data;
177 adx 30
178 michael 4815 tlen = strlen(member->client_p->id) + 1; /* +1 for space */
179 adx 30
180 michael 4815 if (member->flags & CHFL_CHANOP)
181 michael 3250 ++tlen;
182 michael 4815 if (member->flags & CHFL_HALFOP)
183 michael 3250 ++tlen;
184 michael 4815 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 3782 * 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 4815 if (member->flags & CHFL_CHANOP)
199 michael 3140 *t++ = '@';
200 michael 4815 if (member->flags & CHFL_HALFOP)
201 michael 3140 *t++ = '%';
202 michael 4815 if (member->flags & CHFL_VOICE)
203 adx 356 *t++ = '+';
204 adx 30
205 michael 4815 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 3997 * \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 4785 send_mode_list(struct Client *client_p, const struct Channel *chptr,
226 michael 4391 const dlink_list *list, const char flag)
227 adx 30 {
228 michael 4800 const dlink_node *node = NULL;
229 michael 4388 char mbuf[IRCD_BUFSIZE] = "";
230 michael 3215 char pbuf[IRCD_BUFSIZE] = "";
231 michael 3523 int tlen, mlen, cur_len;
232 michael 3144 char *pp = pbuf;
233 adx 30
234 michael 4977 if (!list->length)
235 adx 30 return;
236    
237 michael 4388 mlen = snprintf(mbuf, sizeof(mbuf), ":%s BMASK %lu %s %c :", me.id,
238 michael 4818 (unsigned long)chptr->creationtime, chptr->name, flag);
239 michael 3135 cur_len = mlen;
240 adx 30
241 michael 4800 DLINK_FOREACH(node, list->head)
242 adx 30 {
243 michael 4815 const struct Ban *ban = node->data;
244 adx 30
245 michael 4815 tlen = ban->len + 3; /* +3 for ! + @ + space */
246 adx 30
247     /*
248 michael 3996 * 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 4388 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 4815 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 4388 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 3421
295 michael 5590 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 3421 return p - name <= CHANNELLEN;
314 adx 30 }
315    
316     void
317 michael 4815 remove_ban(struct Ban *ban, dlink_list *list)
318 adx 30 {
319 michael 4815 dlinkDelete(&ban->node, list);
320     mp_pool_release(ban);
321 adx 30 }
322    
323     /* free_channel_list()
324     *
325     * inputs - pointer to dlink_list
326     * output - NONE
327     * side effects -
328     */
329     void
330     free_channel_list(dlink_list *list)
331     {
332 michael 4800 dlink_node *node = NULL, *node_next = NULL;
333 adx 30
334 michael 4800 DLINK_FOREACH_SAFE(node, node_next, list->head)
335     remove_ban(node->data, list);
336 adx 30 }
337    
338 michael 4618 /*! \brief Get Channel block for name (and allocate a new channel
339 adx 30 * block, if it didn't exist before)
340 michael 4618 * \param name Channel name
341 michael 3308 * \return Channel block
342 adx 30 */
343     struct Channel *
344 michael 4618 make_channel(const char *name)
345 adx 30 {
346     struct Channel *chptr = NULL;
347    
348 michael 4618 assert(!EmptyString(name));
349 adx 30
350 michael 1654 chptr = mp_pool_get(channel_pool);
351 adx 30
352 michael 3308 /* Doesn't hurt to set it here */
353 michael 4818 chptr->creationtime = CurrentTime;
354 michael 632 chptr->last_join_time = CurrentTime;
355 adx 30
356 michael 4618 strlcpy(chptr->name, name, sizeof(chptr->name));
357 michael 3944 dlinkAdd(chptr, &chptr->node, &channel_list);
358 adx 30
359     hash_add_channel(chptr);
360    
361     return chptr;
362     }
363    
364 michael 3308 /*! \brief Walk through this channel, and destroy it.
365     * \param chptr Channel pointer
366 adx 30 */
367     void
368     destroy_channel(struct Channel *chptr)
369     {
370 michael 5852 clear_invites_channel(chptr);
371 adx 30
372 michael 3308 /* Free ban/exception/invex lists */
373 adx 30 free_channel_list(&chptr->banlist);
374     free_channel_list(&chptr->exceptlist);
375     free_channel_list(&chptr->invexlist);
376    
377 michael 3944 dlinkDelete(&chptr->node, &channel_list);
378 adx 30 hash_del_channel(chptr);
379    
380 michael 1654 mp_pool_release(chptr);
381 adx 30 }
382    
383     /*!
384 michael 3308 * \param chptr Pointer to channel
385     * \return String pointer "=" if public, "@" if secret else "*"
386 adx 30 */
387     static const char *
388 michael 1013 channel_pub_or_secret(const struct Channel *chptr)
389 adx 30 {
390     if (SecretChannel(chptr))
391     return "@";
392     if (PrivateChannel(chptr))
393     return "*";
394     return "=";
395     }
396    
397     /*! \brief lists all names on given channel
398 michael 3308 * \param source_p Pointer to client struct requesting names
399     * \param chptr Pointer to channel block
400     * \param show_eon Show RPL_ENDOFNAMES numeric or not
401 adx 30 * (don't want it with /names with no params)
402     */
403     void
404     channel_member_names(struct Client *source_p, struct Channel *chptr,
405     int show_eon)
406     {
407 michael 4800 const dlink_node *node = NULL;
408 michael 4388 char buf[IRCD_BUFSIZE + 1] = "";
409 adx 30 char *t = NULL, *start = NULL;
410     int tlen = 0;
411 michael 4833 const int is_member = IsMember(source_p, chptr);
412     const int multi_prefix = HasCap(source_p, CAP_MULTI_PREFIX) != 0;
413     const int uhnames = HasCap(source_p, CAP_UHNAMES) != 0;
414 adx 30
415 michael 5590 assert(IsClient(source_p));
416    
417 adx 30 if (PubChannel(chptr) || is_member)
418     {
419 michael 4388 t = buf + snprintf(buf, sizeof(buf), numeric_form(RPL_NAMREPLY),
420     me.name, source_p->name,
421 michael 4618 channel_pub_or_secret(chptr), chptr->name);
422 adx 30 start = t;
423    
424 michael 4800 DLINK_FOREACH(node, chptr->members.head)
425 adx 30 {
426 michael 4815 const struct Membership *member = node->data;
427 adx 30
428 michael 4815 if (HasUMode(member->client_p, UMODE_INVISIBLE) && !is_member)
429 adx 30 continue;
430    
431 michael 2910 if (!uhnames)
432 michael 4815 tlen = strlen(member->client_p->name) + 1; /* +1 for space */
433 michael 2910 else
434 michael 4815 tlen = strlen(member->client_p->name) + strlen(member->client_p->username) +
435     strlen(member->client_p->host) + 3; /* +3 for ! + @ + space */
436 adx 30
437 michael 506 if (!multi_prefix)
438     {
439 michael 4815 if (member->flags & (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE))
440 michael 506 ++tlen;
441     }
442     else
443     {
444 michael 4815 if (member->flags & CHFL_CHANOP)
445 michael 506 ++tlen;
446 michael 4815 if (member->flags & CHFL_HALFOP)
447 michael 506 ++tlen;
448 michael 4815 if (member->flags & CHFL_VOICE)
449 michael 506 ++tlen;
450     }
451    
452 michael 4388 if (t + tlen - buf > IRCD_BUFSIZE - 2)
453 adx 30 {
454     *(t - 1) = '\0';
455 michael 4388 sendto_one(source_p, "%s", buf);
456 adx 30 t = start;
457     }
458    
459 michael 2910 if (!uhnames)
460 michael 4815 t += sprintf(t, "%s%s ", get_member_status(member, multi_prefix),
461     member->client_p->name);
462 michael 2910 else
463 michael 4815 t += sprintf(t, "%s%s!%s@%s ", get_member_status(member, multi_prefix),
464     member->client_p->name, member->client_p->username,
465     member->client_p->host);
466 adx 30 }
467    
468 michael 3215 if (tlen)
469 adx 30 {
470     *(t - 1) = '\0';
471 michael 4388 sendto_one(source_p, "%s", buf);
472 adx 30 }
473     }
474    
475     if (show_eon)
476 michael 4618 sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, chptr->name);
477 adx 30 }
478    
479 michael 3308 /*! \brief Adds client to invite list
480     * \param chptr Pointer to channel block
481     * \param who Pointer to client to add invite to
482 adx 30 */
483     void
484     add_invite(struct Channel *chptr, struct Client *who)
485     {
486 michael 5590 assert(IsClient(who));
487    
488 adx 30 del_invite(chptr, who);
489    
490     /*
491 michael 3308 * Delete last link in chain if the list is max length
492 adx 30 */
493 michael 4588 if (dlink_list_length(&who->connection->invited) >=
494 michael 3933 ConfigChannel.max_channels)
495 michael 4588 del_invite(who->connection->invited.tail->data, who);
496 adx 30
497 michael 3308 /* Add client to channel invite list */
498 adx 30 dlinkAdd(who, make_dlink_node(), &chptr->invites);
499    
500 michael 3308 /* Add channel to the end of the client invite list */
501 michael 4588 dlinkAdd(chptr, make_dlink_node(), &who->connection->invited);
502 adx 30 }
503    
504     /*! \brief Delete Invite block from channel invite list
505     * and client invite list
506 michael 3308 * \param chptr Pointer to Channel struct
507     * \param who Pointer to client to remove invites from
508 adx 30 */
509     void
510     del_invite(struct Channel *chptr, struct Client *who)
511     {
512 michael 4800 dlink_node *node = NULL;
513 adx 30
514 michael 4800 if ((node = dlinkFindDelete(&who->connection->invited, chptr)))
515     free_dlink_node(node);
516 adx 30
517 michael 4800 if ((node = dlinkFindDelete(&chptr->invites, who)))
518     free_dlink_node(node);
519 adx 30 }
520    
521 michael 4811 /*! \brief Removes all invites of a specific channel
522     * \param chptr Pointer to Channel struct
523     */
524     void
525 michael 5852 clear_invites_channel(struct Channel *chptr)
526 michael 4811 {
527     dlink_node *node = NULL, *node_next = NULL;
528    
529     DLINK_FOREACH_SAFE(node, node_next, chptr->invites.head)
530     del_invite(chptr, node->data);
531     }
532    
533 michael 5852 void
534     clear_invites_client(struct Client *source_p)
535     {
536     dlink_node *node = NULL, *node_next = NULL;
537    
538     DLINK_FOREACH_SAFE(node, node_next, source_p->connection->invited.head)
539     del_invite(node->data, source_p);
540     }
541    
542 adx 30 /* get_member_status()
543     *
544     * inputs - pointer to struct Membership
545     * - YES if we can combine different flags
546     * output - string either @, +, % or "" depending on whether
547     * chanop, voiced or user
548     * side effects -
549     *
550     * NOTE: Returned string is usually a static buffer
551     * (like in get_client_name)
552     */
553     const char *
554 michael 4815 get_member_status(const struct Membership *member, const int combine)
555 adx 30 {
556 michael 4047 static char buffer[4]; /* 4 for @%+\0 */
557 michael 1902 char *p = buffer;
558 adx 30
559 michael 4815 if (member->flags & CHFL_CHANOP)
560 adx 30 {
561     if (!combine)
562     return "@";
563     *p++ = '@';
564     }
565    
566 michael 4815 if (member->flags & CHFL_HALFOP)
567 adx 30 {
568     if (!combine)
569     return "%";
570     *p++ = '%';
571     }
572    
573 michael 4815 if (member->flags & CHFL_VOICE)
574 adx 30 *p++ = '+';
575     *p = '\0';
576    
577     return buffer;
578     }
579    
580     /*!
581 michael 3308 * \param who Pointer to Client to check
582     * \param list Pointer to ban list to search
583 adx 30 * \return 1 if ban found for given n!u\@h mask, 0 otherwise
584     */
585     static int
586     find_bmask(const struct Client *who, const dlink_list *const list)
587     {
588 michael 4800 const dlink_node *node = NULL;
589 adx 30
590 michael 4800 DLINK_FOREACH(node, list->head)
591 adx 30 {
592 michael 4815 const struct Ban *ban = node->data;
593 adx 30
594 michael 4815 if (!match(ban->name, who->name) && !match(ban->user, who->username))
595 michael 371 {
596 michael 4815 switch (ban->type)
597 michael 371 {
598     case HM_HOST:
599 michael 4815 if (!match(ban->host, who->host) || !match(ban->host, who->sockhost))
600 michael 371 return 1;
601     break;
602     case HM_IPV4:
603 michael 4588 if (who->connection->aftype == AF_INET)
604 michael 4815 if (match_ipv4(&who->connection->ip, &ban->addr, ban->bits))
605 michael 371 return 1;
606     break;
607     case HM_IPV6:
608 michael 4588 if (who->connection->aftype == AF_INET6)
609 michael 4815 if (match_ipv6(&who->connection->ip, &ban->addr, ban->bits))
610 michael 371 return 1;
611     break;
612     default:
613     assert(0);
614     }
615     }
616 adx 30 }
617    
618     return 0;
619     }
620    
621     /*!
622 michael 3308 * \param chptr Pointer to channel block
623     * \param who Pointer to client to check access fo
624 adx 30 * \return 0 if not banned, 1 otherwise
625     */
626     int
627 michael 1013 is_banned(const struct Channel *chptr, const struct Client *who)
628 adx 30 {
629 michael 632 if (find_bmask(who, &chptr->banlist))
630 michael 1495 if (!find_bmask(who, &chptr->exceptlist))
631 michael 632 return 1;
632 adx 30
633 michael 632 return 0;
634 adx 30 }
635    
636 michael 3308 /*! Tests if a client can join a certain channel
637     * \param source_p Pointer to client attempting to join
638     * \param chptr Pointer to channel
639     * \param key Key sent by client attempting to join if present
640 adx 30 * \return ERR_BANNEDFROMCHAN, ERR_INVITEONLYCHAN, ERR_CHANNELISFULL
641     * or 0 if allowed to join.
642     */
643 michael 1834 int
644 michael 4785 can_join(struct Client *source_p, const struct Channel *chptr, const char *key)
645 adx 30 {
646 michael 2246 if ((chptr->mode.mode & MODE_SSLONLY) && !HasUMode(source_p, UMODE_SSL))
647 michael 1150 return ERR_SSLONLYCHAN;
648    
649 michael 1173 if ((chptr->mode.mode & MODE_REGONLY) && !HasUMode(source_p, UMODE_REGISTERED))
650     return ERR_NEEDREGGEDNICK;
651    
652 michael 1219 if ((chptr->mode.mode & MODE_OPERONLY) && !HasUMode(source_p, UMODE_OPER))
653 michael 1150 return ERR_OPERONLYCHAN;
654    
655 adx 30 if (chptr->mode.mode & MODE_INVITEONLY)
656 michael 4588 if (!dlinkFind(&source_p->connection->invited, chptr))
657 michael 1495 if (!find_bmask(source_p, &chptr->invexlist))
658 adx 30 return ERR_INVITEONLYCHAN;
659    
660 michael 1430 if (chptr->mode.key[0] && (!key || strcmp(chptr->mode.key, key)))
661 adx 30 return ERR_BADCHANNELKEY;
662    
663     if (chptr->mode.limit && dlink_list_length(&chptr->members) >=
664     chptr->mode.limit)
665     return ERR_CHANNELISFULL;
666    
667 michael 2208 if (is_banned(chptr, source_p))
668     return ERR_BANNEDFROMCHAN;
669    
670 michael 1834 return 0;
671 adx 30 }
672    
673     int
674 michael 4815 has_member_flags(const struct Membership *member, const unsigned int flags)
675 adx 30 {
676 michael 4815 return member && (member->flags & flags);
677 adx 30 }
678    
679     struct Membership *
680     find_channel_link(struct Client *client_p, struct Channel *chptr)
681     {
682 michael 4800 dlink_node *node = NULL;
683 adx 30
684     if (!IsClient(client_p))
685     return NULL;
686    
687 michael 2567 if (dlink_list_length(&chptr->members) < dlink_list_length(&client_p->channel))
688     {
689 michael 4800 DLINK_FOREACH(node, chptr->members.head)
690     if (((struct Membership *)node->data)->client_p == client_p)
691     return node->data;
692 michael 2567 }
693     else
694     {
695 michael 4800 DLINK_FOREACH(node, client_p->channel.head)
696     if (((struct Membership *)node->data)->chptr == chptr)
697     return node->data;
698 michael 2567 }
699 adx 30
700     return NULL;
701     }
702    
703 michael 4783 /*! Checks if a message contains control codes
704 michael 3888 * \param message The actual message string the client wants to send
705     * \return 1 if the message does contain any control codes, 0 otherwise
706 michael 1937 */
707     static int
708     msg_has_ctrls(const char *message)
709     {
710     const unsigned char *p = (const unsigned char *)message;
711    
712     for (; *p; ++p)
713     {
714     if (*p > 31 || *p == 1)
715 michael 3952 continue; /* No control code or CTCP */
716 michael 1937
717 michael 3888 if (*p == 27) /* Escape */
718 michael 1937 {
719 michael 3888 /* ISO 2022 charset shift sequence */
720 michael 1937 if (*(p + 1) == '$' ||
721     *(p + 1) == '(')
722     {
723     ++p;
724     continue;
725     }
726     }
727    
728 michael 3888 return 1; /* Control code */
729 michael 1937 }
730    
731 michael 4783 return 0; /* No control code found */
732 michael 1937 }
733    
734 michael 3308 /*! Tests if a client can send to a channel
735     * \param chptr Pointer to Channel struct
736     * \param source_p Pointer to Client struct
737 michael 4815 * \param member Pointer to Membership struct (can be NULL)
738 michael 3308 * \param message The actual message string the client wants to send
739 adx 30 * \return CAN_SEND_OPV if op or voiced on channel\n
740     * CAN_SEND_NONOP if can send to channel but is not an op\n
741 michael 1173 * ERR_CANNOTSENDTOCHAN or ERR_NEEDREGGEDNICK if they cannot send to channel\n
742 adx 30 */
743     int
744 michael 1937 can_send(struct Channel *chptr, struct Client *source_p,
745 michael 4815 struct Membership *member, const char *message)
746 adx 30 {
747 michael 4785 const struct MaskItem *conf = NULL;
748 michael 1858
749 michael 1219 if (IsServer(source_p) || HasFlag(source_p, FLAGS_SERVICE))
750 adx 30 return CAN_SEND_OPV;
751    
752 michael 565 if (MyClient(source_p) && !IsExemptResv(source_p))
753 michael 4340 if (!(HasUMode(source_p, UMODE_OPER) && ConfigGeneral.oper_pass_resv))
754 michael 4618 if ((conf = match_find_resv(chptr->name)) && !resv_find_exempt(source_p, conf))
755 michael 1834 return ERR_CANNOTSENDTOCHAN;
756 adx 30
757 michael 1944 if ((chptr->mode.mode & MODE_NOCTRL) && msg_has_ctrls(message))
758     return ERR_NOCTRLSONCHAN;
759 michael 4884
760 michael 5464 if (chptr->mode.mode & MODE_NOCTCP)
761 michael 5465 if (*message == '\001' && strncmp(message + 1, "ACTION ", 7))
762 michael 5464 return ERR_NOCTCP;
763    
764 michael 4815 if (member || (member = find_channel_link(source_p, chptr)))
765 michael 5583 if (member->flags & (CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE))
766 adx 30 return CAN_SEND_OPV;
767 michael 4884
768 michael 4815 if (!member && (chptr->mode.mode & MODE_NOPRIVMSGS))
769 michael 2441 return ERR_CANNOTSENDTOCHAN;
770 michael 4884
771 michael 1944 if (chptr->mode.mode & MODE_MODERATED)
772     return ERR_CANNOTSENDTOCHAN;
773 michael 4884
774 michael 1954 if ((chptr->mode.mode & MODE_MODREG) && !HasUMode(source_p, UMODE_REGISTERED))
775 michael 1944 return ERR_NEEDREGGEDNICK;
776 adx 30
777 michael 3308 /* Cache can send if banned */
778 michael 1944 if (MyClient(source_p))
779     {
780 michael 4815 if (member)
781 adx 30 {
782 michael 4815 if (member->flags & CHFL_BAN_SILENCED)
783 michael 1834 return ERR_CANNOTSENDTOCHAN;
784 adx 30
785 michael 4815 if (!(member->flags & CHFL_BAN_CHECKED))
786 adx 30 {
787     if (is_banned(chptr, source_p))
788     {
789 michael 5583 member->flags |= (CHFL_BAN_CHECKED | CHFL_BAN_SILENCED);
790 michael 1834 return ERR_CANNOTSENDTOCHAN;
791 adx 30 }
792    
793 michael 4815 member->flags |= CHFL_BAN_CHECKED;
794 adx 30 }
795     }
796 michael 1944 else if (is_banned(chptr, source_p))
797 michael 1941 return ERR_CANNOTSENDTOCHAN;
798     }
799 adx 30
800     return CAN_SEND_NONOP;
801     }
802    
803     /*! \brief Updates the client's oper_warn_count_down, warns the
804     * IRC operators if necessary, and updates
805     * join_leave_countdown as needed.
806 michael 3308 * \param source_p Pointer to struct Client to check
807     * \param name Channel name or NULL if this is a part.
808 adx 30 */
809     void
810     check_spambot_warning(struct Client *source_p, const char *name)
811     {
812     int t_delta = 0;
813     int decrement_count = 0;
814    
815     if ((GlobalSetOptions.spam_num &&
816 michael 4588 (source_p->connection->join_leave_count >=
817 adx 30 GlobalSetOptions.spam_num)))
818     {
819 michael 4588 if (source_p->connection->oper_warn_count_down > 0)
820     source_p->connection->oper_warn_count_down--;
821 adx 30 else
822 michael 4588 source_p->connection->oper_warn_count_down = 0;
823 adx 30
824 michael 4588 if (source_p->connection->oper_warn_count_down == 0)
825 adx 30 {
826 michael 3308 /* It's already known as a possible spambot */
827 michael 3235 if (name)
828 michael 1618 sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
829 adx 30 "User %s (%s@%s) trying to join %s is a possible spambot",
830     source_p->name, source_p->username,
831     source_p->host, name);
832     else
833 michael 1618 sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
834 adx 30 "User %s (%s@%s) is a possible spambot",
835     source_p->name, source_p->username,
836     source_p->host);
837 michael 4588 source_p->connection->oper_warn_count_down = OPER_SPAM_COUNTDOWN;
838 adx 30 }
839     }
840     else
841     {
842 michael 4588 if ((t_delta = (CurrentTime - source_p->connection->last_leave_time)) >
843 adx 30 JOIN_LEAVE_COUNT_EXPIRE_TIME)
844     {
845     decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME);
846 michael 4884
847 michael 4588 if (decrement_count > source_p->connection->join_leave_count)
848     source_p->connection->join_leave_count = 0;
849 adx 30 else
850 michael 4588 source_p->connection->join_leave_count -= decrement_count;
851 adx 30 }
852     else
853     {
854 michael 4588 if ((CurrentTime - (source_p->connection->last_join_time)) <
855 adx 30 GlobalSetOptions.spam_time)
856 michael 4588 source_p->connection->join_leave_count++; /* It's a possible spambot */
857 adx 30 }
858    
859 michael 3215 if (name)
860 michael 4588 source_p->connection->last_join_time = CurrentTime;
861 adx 30 else
862 michael 4588 source_p->connection->last_leave_time = CurrentTime;
863 adx 30 }
864     }
865    
866 michael 3308 /*! \brief Compares usercount and servercount against their split
867 adx 30 * values and adjusts splitmode accordingly
868     * \param unused Unused address pointer
869     */
870     void
871     check_splitmode(void *unused)
872     {
873     if (splitchecking && (ConfigChannel.no_join_on_split ||
874     ConfigChannel.no_create_on_split))
875     {
876 michael 4209 const unsigned int server = dlink_list_length(&global_server_list);
877 adx 30
878     if (!splitmode && ((server < split_servers) || (Count.total < split_users)))
879     {
880     splitmode = 1;
881    
882 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
883 adx 30 "Network split, activating splitmode");
884 michael 4094 event_add(&splitmode_event, NULL);
885 adx 30 }
886 michael 4066 else if (splitmode && (server >= split_servers) && (Count.total >= split_users))
887 adx 30 {
888     splitmode = 0;
889    
890 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
891 adx 30 "Network rejoined, deactivating splitmode");
892 michael 4094 event_delete(&splitmode_event);
893 adx 30 }
894     }
895     }
896    
897 michael 3308 /*! \brief Sets the channel topic for a certain channel
898 adx 30 * \param chptr Pointer to struct Channel
899     * \param topic The topic string
900     * \param topic_info n!u\@h formatted string of the topic setter
901 michael 3308 * \param topicts Timestamp on the topic
902     * \param local Whether the topic is set by a local client
903 adx 30 */
904     void
905 michael 3941 channel_set_topic(struct Channel *chptr, const char *topic,
906 michael 1751 const char *topic_info, time_t topicts, int local)
907 adx 30 {
908 michael 1751 if (local)
909 michael 4340 strlcpy(chptr->topic, topic, IRCD_MIN(sizeof(chptr->topic), ConfigServerInfo.max_topic_length + 1));
910 michael 1751 else
911     strlcpy(chptr->topic, topic, sizeof(chptr->topic));
912    
913 michael 1203 strlcpy(chptr->topic_info, topic_info, sizeof(chptr->topic_info));
914 michael 2345 chptr->topic_time = topicts;
915 adx 30 }
916 michael 3912
917     /* do_join_0()
918     *
919     * inputs - pointer to client doing join 0
920     * output - NONE
921     * side effects - Use has decided to join 0. This is legacy
922     * from the days when channels were numbers not names. *sigh*
923     * There is a bunch of evilness necessary here due to
924     * anti spambot code.
925     */
926     void
927     channel_do_join_0(struct Client *source_p)
928     {
929 michael 4800 dlink_node *node = NULL, *node_next = NULL;
930 michael 3912
931     if (source_p->channel.head)
932     if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER))
933     check_spambot_warning(source_p, NULL);
934    
935 michael 4800 DLINK_FOREACH_SAFE(node, node_next, source_p->channel.head)
936 michael 3912 {
937 michael 4800 struct Channel *chptr = ((struct Membership *)node->data)->chptr;
938 michael 3912
939 michael 4962 sendto_server(source_p, 0, 0, ":%s PART %s",
940 michael 4618 source_p->id, chptr->name);
941 michael 4795 sendto_channel_local(0, chptr, ":%s!%s@%s PART %s",
942 michael 3912 source_p->name, source_p->username,
943 michael 4618 source_p->host, chptr->name);
944 michael 3912
945 michael 4800 remove_user_from_channel(node->data);
946 michael 3912 }
947     }
948    
949     static char *
950     channel_find_last0(struct Client *source_p, char *chanlist)
951     {
952     int join0 = 0;
953    
954     for (char *p = chanlist; *p; ++p) /* Find last "JOIN 0" */
955     {
956     if (*p == '0' && (*(p + 1) == ',' || *(p + 1) == '\0'))
957     {
958 michael 4756 if (*(p + 1) == ',')
959 michael 3912 ++p;
960    
961     chanlist = p + 1;
962     join0 = 1;
963     }
964     else
965     {
966     while (*p != ',' && *p != '\0') /* Skip past channel name */
967     ++p;
968    
969     if (*p == '\0') /* Hit the end */
970     break;
971     }
972     }
973    
974     if (join0)
975     channel_do_join_0(source_p);
976    
977     return chanlist;
978     }
979    
980     void
981 michael 3937 channel_do_join(struct Client *source_p, char *channel, char *key_list)
982 michael 3912 {
983     char *p = NULL;
984 michael 3937 char *chan = NULL;
985 michael 3912 char *chan_list = NULL;
986     struct Channel *chptr = NULL;
987     struct MaskItem *conf = NULL;
988 michael 4785 const struct ClassItem *const class = get_class_ptr(&source_p->connection->confs);
989 michael 3912 int i = 0;
990     unsigned int flags = 0;
991    
992 michael 5590 assert(IsClient(source_p));
993    
994 michael 3937 chan_list = channel_find_last0(source_p, channel);
995 michael 3912
996     for (chan = strtoken(&p, chan_list, ","); chan;
997     chan = strtoken(&p, NULL, ","))
998     {
999     const char *key = NULL;
1000    
1001     /* If we have any more keys, take the first for this channel. */
1002     if (!EmptyString(key_list) && (key_list = strchr(key = key_list, ',')))
1003     *key_list++ = '\0';
1004    
1005     /* Empty keys are the same as no keys. */
1006     if (key && *key == '\0')
1007     key = NULL;
1008    
1009     if (!check_channel_name(chan, 1))
1010     {
1011     sendto_one_numeric(source_p, &me, ERR_BADCHANNAME, chan);
1012     continue;
1013     }
1014    
1015     if (!IsExemptResv(source_p) &&
1016 michael 4340 !(HasUMode(source_p, UMODE_OPER) && ConfigGeneral.oper_pass_resv) &&
1017 michael 3912 ((conf = match_find_resv(chan)) && !resv_find_exempt(source_p, conf)))
1018     {
1019     ++conf->count;
1020     sendto_one_numeric(source_p, &me, ERR_CHANBANREASON,
1021     chan, conf->reason ? conf->reason : "Reserved channel");
1022 michael 4151 sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
1023 michael 3912 "Forbidding reserved channel %s from user %s",
1024     chan, get_client_name(source_p, HIDE_IP));
1025     continue;
1026     }
1027    
1028     if (dlink_list_length(&source_p->channel) >=
1029 michael 3933 ((class->max_channels) ? class->max_channels : ConfigChannel.max_channels))
1030 michael 3912 {
1031     sendto_one_numeric(source_p, &me, ERR_TOOMANYCHANNELS, chan);
1032     break;
1033     }
1034    
1035     if ((chptr = hash_find_channel(chan)))
1036     {
1037     if (IsMember(source_p, chptr))
1038     continue;
1039    
1040     if (splitmode && !HasUMode(source_p, UMODE_OPER) &&
1041     ConfigChannel.no_join_on_split)
1042     {
1043 michael 4618 sendto_one_numeric(source_p, &me, ERR_UNAVAILRESOURCE, chptr->name);
1044 michael 3912 continue;
1045     }
1046    
1047     /*
1048     * can_join checks for +i key, bans.
1049     */
1050     if ((i = can_join(source_p, chptr, key)))
1051     {
1052 michael 4618 sendto_one_numeric(source_p, &me, i, chptr->name);
1053 michael 3912 continue;
1054     }
1055    
1056     /*
1057     * This should never be the case unless there is some sort of
1058     * persistant channels.
1059     */
1060 michael 4977 if (!dlink_list_length(&chptr->members))
1061 michael 3912 flags = CHFL_CHANOP;
1062     else
1063     flags = 0;
1064     }
1065     else
1066     {
1067     if (splitmode && !HasUMode(source_p, UMODE_OPER) &&
1068     (ConfigChannel.no_create_on_split || ConfigChannel.no_join_on_split))
1069     {
1070     sendto_one_numeric(source_p, &me, ERR_UNAVAILRESOURCE, chan);
1071     continue;
1072     }
1073    
1074     flags = CHFL_CHANOP;
1075     chptr = make_channel(chan);
1076     }
1077    
1078     if (!HasUMode(source_p, UMODE_OPER))
1079 michael 4618 check_spambot_warning(source_p, chptr->name);
1080 michael 3912
1081     add_user_to_channel(chptr, source_p, flags, 1);
1082    
1083     /*
1084 michael 5545 * Set timestamp if appropriate, and propagate
1085 michael 3912 */
1086     if (flags == CHFL_CHANOP)
1087     {
1088 michael 4818 chptr->creationtime = CurrentTime;
1089 michael 3912 chptr->mode.mode |= MODE_TOPICLIMIT;
1090     chptr->mode.mode |= MODE_NOPRIVMSGS;
1091    
1092 michael 4962 sendto_server(source_p, 0, 0, ":%s SJOIN %lu %s +nt :@%s",
1093 michael 4818 me.id, (unsigned long)chptr->creationtime,
1094 michael 4618 chptr->name, source_p->id);
1095 michael 3912
1096     /*
1097     * Notify all other users on the new channel
1098     */
1099 michael 4792 sendto_channel_local_butone(NULL, CAP_EXTENDED_JOIN, 0, chptr, ":%s!%s@%s JOIN %s %s :%s",
1100     source_p->name, source_p->username,
1101     source_p->host, chptr->name,
1102 michael 4819 (!IsDigit(source_p->account[0]) && source_p->account[0] != '*') ? source_p->account : "*",
1103 michael 4792 source_p->info);
1104     sendto_channel_local_butone(NULL, 0, CAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN :%s",
1105     source_p->name, source_p->username,
1106     source_p->host, chptr->name);
1107 michael 4795 sendto_channel_local(0, chptr, ":%s MODE %s +nt",
1108 michael 4618 me.name, chptr->name);
1109 michael 3912
1110     if (source_p->away[0])
1111 michael 4792 sendto_channel_local_butone(source_p, CAP_AWAY_NOTIFY, 0, chptr,
1112 michael 3912 ":%s!%s@%s AWAY :%s",
1113     source_p->name, source_p->username,
1114     source_p->host, source_p->away);
1115     }
1116     else
1117     {
1118 michael 4962 sendto_server(source_p, 0, 0, ":%s JOIN %lu %s +",
1119 michael 4818 source_p->id, (unsigned long)chptr->creationtime,
1120 michael 4618 chptr->name);
1121 michael 3912
1122 michael 4792 sendto_channel_local_butone(NULL, CAP_EXTENDED_JOIN, 0, chptr, ":%s!%s@%s JOIN %s %s :%s",
1123     source_p->name, source_p->username,
1124     source_p->host, chptr->name,
1125 michael 4819 (!IsDigit(source_p->account[0]) && source_p->account[0] != '*') ? source_p->account : "*",
1126 michael 4792 source_p->info);
1127     sendto_channel_local_butone(NULL, 0, CAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN :%s",
1128     source_p->name, source_p->username,
1129     source_p->host, chptr->name);
1130    
1131 michael 3912 if (source_p->away[0])
1132 michael 4792 sendto_channel_local_butone(source_p, CAP_AWAY_NOTIFY, 0, chptr,
1133 michael 3912 ":%s!%s@%s AWAY :%s",
1134     source_p->name, source_p->username,
1135     source_p->host, source_p->away);
1136     }
1137    
1138     del_invite(chptr, source_p);
1139    
1140     if (chptr->topic[0])
1141     {
1142 michael 4618 sendto_one_numeric(source_p, &me, RPL_TOPIC, chptr->name, chptr->topic);
1143     sendto_one_numeric(source_p, &me, RPL_TOPICWHOTIME, chptr->name,
1144 michael 3912 chptr->topic_info, chptr->topic_time);
1145     }
1146    
1147     channel_member_names(source_p, chptr, 1);
1148    
1149 michael 4588 source_p->connection->last_join_time = CurrentTime;
1150 michael 3912 }
1151     }
1152    
1153     /*! \brief Removes a client from a specific channel
1154     * \param source_p Pointer to source client to remove
1155     * \param name Name of channel to remove from
1156     * \param reason Part reason to show
1157     */
1158     static void
1159     channel_part_one_client(struct Client *source_p, const char *name, const char *reason)
1160     {
1161     struct Channel *chptr = NULL;
1162 michael 4815 struct Membership *member = NULL;
1163 michael 3912
1164     if ((chptr = hash_find_channel(name)) == NULL)
1165     {
1166     sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, name);
1167     return;
1168     }
1169    
1170 michael 4815 if ((member = find_channel_link(source_p, chptr)) == NULL)
1171 michael 3912 {
1172 michael 4618 sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, chptr->name);
1173 michael 3912 return;
1174     }
1175    
1176     if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER))
1177     check_spambot_warning(source_p, NULL);
1178    
1179     /*
1180     * Remove user from the old channel (if any)
1181     * only allow /part reasons in -m chans
1182     */
1183     if (*reason && (!MyConnect(source_p) ||
1184 michael 4815 ((can_send(chptr, source_p, member, reason) &&
1185 michael 4588 (source_p->connection->firsttime + ConfigGeneral.anti_spam_exit_message_time)
1186 michael 3912 < CurrentTime))))
1187     {
1188 michael 4962 sendto_server(source_p, 0, 0, ":%s PART %s :%s",
1189 michael 4618 source_p->id, chptr->name, reason);
1190 michael 4795 sendto_channel_local(0, chptr, ":%s!%s@%s PART %s :%s",
1191 michael 3912 source_p->name, source_p->username,
1192 michael 4618 source_p->host, chptr->name, reason);
1193 michael 3912 }
1194     else
1195     {
1196 michael 4962 sendto_server(source_p, 0, 0, ":%s PART %s",
1197 michael 4618 source_p->id, chptr->name);
1198 michael 4795 sendto_channel_local(0, chptr, ":%s!%s@%s PART %s",
1199 michael 3912 source_p->name, source_p->username,
1200 michael 4618 source_p->host, chptr->name);
1201 michael 3912 }
1202    
1203 michael 4815 remove_user_from_channel(member);
1204 michael 3912 }
1205    
1206     void
1207 michael 4785 channel_do_part(struct Client *source_p, char *channel, const char *reason)
1208 michael 3912 {
1209     char *p = NULL, *name = NULL;
1210 michael 4785 char buf[KICKLEN + 1] = "";
1211 michael 3912
1212 michael 5590 assert(IsClient(source_p));
1213    
1214 michael 3937 if (!EmptyString(reason))
1215 michael 4785 strlcpy(buf, reason, sizeof(buf));
1216 michael 3912
1217 michael 3937 for (name = strtoken(&p, channel, ","); name;
1218 michael 3912 name = strtoken(&p, NULL, ","))
1219 michael 4785 channel_part_one_client(source_p, name, buf);
1220 michael 3912 }

Properties

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