ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/channel.c
Revision: 8276
Committed: Wed Sep 27 18:53:50 2017 UTC (6 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 33684 byte(s)
Log Message:
- channel.c:check_spambot_warning(): stylistic changes; improve readability

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

Properties

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