ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/channel.c
Revision: 7997
Committed: Tue Mar 14 13:17:52 2017 UTC (8 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 33779 byte(s)
Log Message:
- Rename get_client_name() to client_get_name()

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

Properties

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