ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/core/m_sjoin.c
Revision: 4581
Committed: Mon Aug 25 10:33:40 2014 UTC (11 years ago) by michael
Content type: text/x-csrc
File size: 19526 byte(s)
Log Message:
- Fixed misspellings

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 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 michael 2820 /*! \file m_sjoin.c
23     * \brief Includes required functions for processing the SJOIN command.
24     * \version $Id$
25     */
26    
27 adx 30 #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     #include "irc_string.h"
34     #include "ircd.h"
35     #include "numeric.h"
36     #include "send.h"
37     #include "parse.h"
38     #include "modules.h"
39 michael 3347 #include "server.h"
40 michael 1309 #include "conf.h"
41 michael 3347 #include "misc.h"
42 adx 30
43    
44     static char modebuf[MODEBUFLEN];
45     static char parabuf[MODEBUFLEN];
46     static char sendbuf[MODEBUFLEN];
47     static const char *para[MAXMODEPARAMS];
48     static char *mbuf;
49     static int pargs;
50    
51     static void set_final_mode(struct Mode *, struct Mode *);
52     static void remove_our_modes(struct Channel *, struct Client *);
53     static void remove_a_mode(struct Channel *, struct Client *, int, char);
54 michael 3041 static void remove_ban_list(struct Channel *, struct Client *, dlink_list *, char);
55 adx 30
56 michael 885
57 adx 30 /* ms_sjoin()
58     *
59 michael 3120 * parv[0] - command
60 adx 30 * parv[1] - TS
61     * parv[2] - channel
62     * parv[3] - modes + n arguments (key and/or limit)
63     * parv[4+n] - flags+nick list (all in one parameter)
64     *
65     * process a SJOIN, taking the TS's into account to either ignore the
66     * incoming modes or undo the existing ones or merge them, and JOIN
67     * all the specified users while sending JOIN/MODEs to local clients
68     */
69 michael 2820 static int
70 michael 3156 ms_sjoin(struct Client *source_p, int parc, char *parv[])
71 adx 30 {
72 michael 632 struct Channel *chptr = NULL;
73     struct Client *target_p = NULL;
74 adx 30 time_t newts;
75     time_t oldts;
76     time_t tstosend;
77 michael 632 struct Mode mode, *oldmode;
78 adx 30 int args = 0;
79 michael 1243 char keep_our_modes = 1;
80     char keep_new_modes = 1;
81     char have_many_nicks = 0;
82 adx 30 int lcount;
83     char uid_prefix[4];
84 michael 3135 char *up = NULL;
85 adx 30 int len_uid = 0;
86 michael 632 int isnew = 0;
87 adx 30 int buflen = 0;
88 michael 2820 int slen;
89 adx 30 unsigned int fl;
90     char *s;
91 michael 2820 char *sptr;
92 michael 3135 char uid_buf[IRCD_BUFSIZE]; /* buffer for modes/prefixes */
93     char *uid_ptr;
94 adx 30 char *p; /* pointer used making sjbuf */
95     const char *servername = (ConfigServerHide.hide_servers || IsHidden(source_p)) ?
96 michael 2820 me.name : source_p->name;
97 adx 30
98 michael 3625 if (!IsServer(source_p))
99 michael 2820 return 0;
100 adx 30
101 michael 632 if (!check_channel_name(parv[2], 0))
102     {
103 michael 1618 sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
104 michael 3162 "*** Too long or invalid channel name from %s(via %s): %s",
105     source_p->name, source_p->from->name, parv[2]);
106 michael 2820 return 0;
107 michael 632 }
108 adx 30
109     modebuf[0] = '\0';
110     mbuf = modebuf;
111     pargs = 0;
112     newts = atol(parv[1]);
113    
114     mode.mode = 0;
115     mode.limit = 0;
116     mode.key[0] = '\0';
117    
118 michael 3750 for (const char *modes = parv[3]; *modes; ++modes)
119 adx 30 {
120 michael 3750 switch (*modes)
121 adx 30 {
122     case 'k':
123     strlcpy(mode.key, parv[4 + args], sizeof(mode.key));
124 michael 3750 ++args;
125 michael 632
126     if (parc < 5 + args)
127 michael 2820 return 0;
128 adx 30 break;
129 michael 3753
130 adx 30 case 'l':
131     mode.limit = atoi(parv[4 + args]);
132 michael 3750 ++args;
133 michael 632
134     if (parc < 5 + args)
135 michael 2820 return 0;
136 adx 30 break;
137 michael 3753
138     default:
139     mode.mode |= ModeTable[(unsigned char)*modes].d;
140     break;
141 adx 30 }
142     }
143    
144 michael 632 if ((chptr = hash_find_channel(parv[2])) == NULL)
145     {
146     isnew = 1;
147     chptr = make_channel(parv[2]);
148     }
149    
150 adx 30 parabuf[0] = '\0';
151 michael 632 oldts = chptr->channelts;
152 adx 30 oldmode = &chptr->mode;
153    
154 michael 4340 if (ConfigGeneral.ignore_bogus_ts)
155 adx 30 {
156     if (newts < 800000000)
157     {
158 michael 1618 sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
159 michael 3169 "*** Bogus TS %lu on %s ignored from %s(via %s)",
160 michael 2820 (unsigned long)newts, chptr->chname,
161 michael 3169 source_p->name, source_p->from->name);
162 adx 30
163     newts = (oldts == 0) ? 0 : 800000000;
164     }
165     }
166     else
167     {
168     if (!newts && !isnew && oldts)
169     {
170 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr,
171 michael 2820 ":%s NOTICE %s :*** Notice -- TS for %s changed from %lu to 0",
172     me.name, chptr->chname, chptr->chname, (unsigned long)oldts);
173 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
174 michael 2820 "Server %s changing TS on %s from %lu to 0",
175     source_p->name, chptr->chname, (unsigned long)oldts);
176 adx 30 }
177     }
178    
179     if (isnew)
180     chptr->channelts = tstosend = newts;
181     else if (newts == 0 || oldts == 0)
182     chptr->channelts = tstosend = 0;
183     else if (newts == oldts)
184     tstosend = oldts;
185     else if (newts < oldts)
186     {
187 michael 1243 keep_our_modes = 0;
188 adx 30 chptr->channelts = tstosend = newts;
189     }
190     else
191     {
192 michael 1243 keep_new_modes = 0;
193 adx 30 tstosend = oldts;
194     }
195    
196     if (!keep_new_modes)
197     mode = *oldmode;
198     else if (keep_our_modes)
199     {
200     mode.mode |= oldmode->mode;
201 michael 3246
202 adx 30 if (oldmode->limit > mode.limit)
203     mode.limit = oldmode->limit;
204     if (strcmp(mode.key, oldmode->key) < 0)
205 michael 3334 strlcpy(mode.key, oldmode->key, sizeof(mode.key));
206 adx 30 }
207 michael 3246
208 adx 30 set_final_mode(&mode, oldmode);
209     chptr->mode = mode;
210    
211     /* Lost the TS, other side wins, so remove modes on this side */
212     if (!keep_our_modes)
213     {
214     remove_our_modes(chptr, source_p);
215 michael 873
216 michael 1203 if (chptr->topic[0])
217 michael 873 {
218 michael 3941 channel_set_topic(chptr, "", "", 0, 0);
219 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s TOPIC %s :",
220 michael 873 (IsHidden(source_p) ||
221     ConfigServerHide.hide_servers) ?
222     me.name : source_p->name, chptr->chname);
223     }
224    
225 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr,
226 michael 2820 ":%s NOTICE %s :*** Notice -- TS for %s changed from %lu to %lu",
227     me.name, chptr->chname, chptr->chname,
228     (unsigned long)oldts, (unsigned long)newts);
229 adx 30 }
230    
231     if (*modebuf != '\0')
232     {
233     /* This _SHOULD_ be to ALL_MEMBERS
234     * It contains only +imnpstlk, etc */
235 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s %s",
236 michael 2820 servername, chptr->chname, modebuf, parabuf);
237 adx 30 }
238    
239 michael 3246 if (*parv[3] != '0' && keep_new_modes)
240 adx 30 channel_modes(chptr, source_p, modebuf, parabuf);
241     else
242     {
243     modebuf[0] = '0';
244     modebuf[1] = '\0';
245     }
246    
247 michael 1793 buflen = snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lu %s %s %s:",
248 michael 3186 source_p->id, (unsigned long)tstosend,
249 michael 1793 chptr->chname, modebuf, parabuf);
250 adx 30 uid_ptr = uid_buf + buflen;
251    
252 michael 3750 /*
253     * Check we can fit a nick on the end, as well as \r\n and a prefix "
254 adx 30 * @%+", and a space.
255     */
256     if (buflen >= (IRCD_BUFSIZE - IRCD_MAX(NICKLEN, IDLEN) - 2 - 3 - 1))
257     {
258 michael 1618 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
259 michael 3162 "Long SJOIN from server: %s(via %s) (ignored)",
260     source_p->name, source_p->from->name);
261 michael 2820 return 0;
262 adx 30 }
263    
264     mbuf = modebuf;
265     sendbuf[0] = '\0';
266     pargs = 0;
267    
268     *mbuf++ = '+';
269    
270     s = parv[args + 4];
271     while (*s == ' ')
272 michael 3750 ++s;
273 michael 3246
274     if ((p = strchr(s, ' ')))
275 adx 30 {
276     *p++ = '\0';
277 michael 3750
278 adx 30 while (*p == ' ')
279 michael 3750 ++p;
280 adx 30 have_many_nicks = *p;
281     }
282    
283     while (*s)
284     {
285 michael 1243 int valid_mode = 1;
286 adx 30 fl = 0;
287    
288     do
289     {
290     switch (*s)
291     {
292 michael 3750 case '@':
293     fl |= CHFL_CHANOP;
294     ++s;
295     break;
296     case '%':
297     fl |= CHFL_HALFOP;
298     ++s;
299     break;
300     case '+':
301     fl |= CHFL_VOICE;
302     ++s;
303     break;
304     default:
305     valid_mode = 0;
306     break;
307 adx 30 }
308     } while (valid_mode);
309    
310     /*
311 michael 4581 * If the client doesn't exist, or if it's fake direction/server, skip.
312 michael 4298 * we cannot send ERR_NOSUCHNICK here because if it's a UID, we cannot
313     * lookup the nick, and it's better to never send the numeric than only
314 adx 30 * sometimes.
315     */
316 michael 3750 if ((target_p = find_chasing(source_p, s)) == NULL || target_p->from != source_p->from)
317 adx 30 goto nextnick;
318    
319 michael 3186 len_uid = strlen(target_p->id);
320 adx 30 up = uid_prefix;
321    
322     if (keep_new_modes)
323     {
324     if (fl & CHFL_CHANOP)
325     {
326     *up++ = '@';
327 michael 2820 len_uid++;
328 adx 30 }
329 michael 3724
330 adx 30 if (fl & CHFL_HALFOP)
331     {
332     *up++ = '%';
333 michael 2820 len_uid++;
334 adx 30 }
335 michael 3724
336 adx 30 if (fl & CHFL_VOICE)
337     {
338     *up++ = '+';
339 michael 2820 len_uid++;
340 adx 30 }
341     }
342     else
343 michael 3695 fl = 0;
344    
345 michael 3135 *up = '\0';
346 adx 30
347     if ((uid_ptr - uid_buf + len_uid) > (IRCD_BUFSIZE - 2))
348     {
349 michael 3156 sendto_server(source_p, NOCAPS, NOCAPS, "%s", uid_buf);
350 michael 2820
351 michael 1793 buflen = snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lu %s %s %s:",
352 michael 3186 source_p->id, (unsigned long)tstosend,
353 michael 1793 chptr->chname, modebuf, parabuf);
354 adx 30 uid_ptr = uid_buf + buflen;
355     }
356    
357 michael 3186 uid_ptr += sprintf(uid_ptr, "%s%s ", uid_prefix, target_p->id);
358 michael 2820
359 adx 30 if (!IsMember(target_p, chptr))
360     {
361     add_user_to_channel(chptr, target_p, fl, !have_many_nicks);
362 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s JOIN :%s",
363 adx 30 target_p->name, target_p->username,
364     target_p->host, chptr->chname);
365 michael 1734 if (target_p->away[0])
366     sendto_channel_local_butone(target_p, 0, CAP_AWAY_NOTIFY, chptr,
367     ":%s!%s@%s AWAY :%s",
368     target_p->name, target_p->username,
369     target_p->host, target_p->away);
370 adx 30 }
371    
372     if (fl & CHFL_CHANOP)
373     {
374     *mbuf++ = 'o';
375     para[pargs++] = target_p->name;
376    
377     if (pargs >= MAXMODEPARAMS)
378     {
379 michael 2820 /*
380     * Ok, the code is now going to "walk" through
381     * sendbuf, filling in para strings. So, I will use sptr
382     * to point into the sendbuf.
383     * Notice, that ircsprintf() returns the number of chars
384     * successfully inserted into string.
385     * - Dianora
386     */
387 adx 30
388 michael 2820 sptr = sendbuf;
389 adx 30 *mbuf = '\0';
390 michael 2820
391 michael 3246 for (lcount = 0; lcount < MAXMODEPARAMS; ++lcount)
392 adx 30 {
393 michael 2820 slen = sprintf(sptr, " %s", para[lcount]); /* see? */
394     sptr += slen; /* ready for next */
395 adx 30 }
396 michael 3246
397 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s%s",
398 adx 30 servername, chptr->chname, modebuf, sendbuf);
399     mbuf = modebuf;
400     *mbuf++ = '+';
401    
402     sendbuf[0] = '\0';
403     pargs = 0;
404     }
405     }
406 michael 3724
407 adx 30 if (fl & CHFL_HALFOP)
408     {
409     *mbuf++ = 'h';
410     para[pargs++] = target_p->name;
411    
412     if (pargs >= MAXMODEPARAMS)
413     {
414     sptr = sendbuf;
415     *mbuf = '\0';
416 michael 3246
417     for (lcount = 0; lcount < MAXMODEPARAMS; ++lcount)
418 adx 30 {
419 michael 1793 slen = sprintf(sptr, " %s", para[lcount]);
420 adx 30 sptr += slen;
421     }
422 michael 3246
423 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s%s",
424 adx 30 servername, chptr->chname, modebuf, sendbuf);
425    
426     mbuf = modebuf;
427     *mbuf++ = '+';
428    
429     sendbuf[0] = '\0';
430     pargs = 0;
431     }
432     }
433 michael 3724
434 adx 30 if (fl & CHFL_VOICE)
435     {
436     *mbuf++ = 'v';
437     para[pargs++] = target_p->name;
438    
439     if (pargs >= MAXMODEPARAMS)
440     {
441 michael 2820 sptr = sendbuf;
442 adx 30 *mbuf = '\0';
443 michael 3246
444     for (lcount = 0; lcount < MAXMODEPARAMS; ++lcount)
445 adx 30 {
446 michael 1793 slen = sprintf(sptr, " %s", para[lcount]);
447 michael 2820 sptr += slen;
448 adx 30 }
449 michael 3246
450 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s%s",
451 adx 30 servername, chptr->chname, modebuf, sendbuf);
452    
453     mbuf = modebuf;
454     *mbuf++ = '+';
455    
456     sendbuf[0] = '\0';
457     pargs = 0;
458     }
459     }
460    
461     nextnick:
462     if ((s = p) == NULL)
463     break;
464 michael 3246
465 adx 30 while (*s == ' ')
466 michael 3246 ++s;
467    
468     if ((p = strchr(s, ' ')))
469 adx 30 {
470 michael 3246 *p++ = '\0';
471    
472 adx 30 while (*p == ' ')
473 michael 3246 ++p;
474 adx 30 }
475     }
476    
477     *mbuf = '\0';
478     *(uid_ptr - 1) = '\0';
479    
480     /*
481     * checking for lcount < MAXMODEPARAMS at this time is wrong
482     * since the code has already verified above that pargs < MAXMODEPARAMS
483     * checking for para[lcount] != '\0' is also wrong, since
484     * there is no place where para[lcount] is set!
485     * - Dianora
486     */
487    
488 michael 3246 if (pargs)
489 adx 30 {
490     sptr = sendbuf;
491    
492 michael 3246 for (lcount = 0; lcount < pargs; ++lcount)
493 adx 30 {
494 michael 1793 slen = sprintf(sptr, " %s", para[lcount]);
495 adx 30 sptr += slen;
496     }
497    
498 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s%s",
499 michael 3246 servername, chptr->chname, modebuf, sendbuf);
500 adx 30 }
501    
502 michael 4298 /*
503     * If this happens, it's the result of a malformed SJOIN
504 adx 30 * a remnant from the old persistent channel code. *sigh*
505     * Or it could be the result of a client just leaving
506     * and leaving us with a channel formed just as the client parts.
507     * - Dianora
508     */
509 michael 3246 if (!dlink_list_length(&chptr->members) && isnew)
510 adx 30 {
511     destroy_channel(chptr);
512 michael 2820 return 0;
513 adx 30 }
514    
515 michael 3246 if (*parv[4 + args] == '\0')
516 michael 2820 return 0;
517 adx 30
518 michael 3156 sendto_server(source_p, NOCAPS, NOCAPS, "%s", uid_buf);
519 adx 30
520 michael 3135 if (!keep_our_modes)
521 adx 30 {
522 michael 3246 if (dlink_list_length(&chptr->banlist))
523 michael 3156 remove_ban_list(chptr, source_p, &chptr->banlist, 'b');
524 adx 30
525 michael 3246 if (dlink_list_length(&chptr->exceptlist))
526 michael 3156 remove_ban_list(chptr, source_p, &chptr->exceptlist, 'e');
527 adx 30
528 michael 3246 if (dlink_list_length(&chptr->invexlist))
529 michael 3156 remove_ban_list(chptr, source_p, &chptr->invexlist, 'I');
530 adx 30 clear_ban_cache(chptr);
531 michael 2820 }
532    
533     return 0;
534 adx 30 }
535    
536     /* set_final_mode
537     *
538     * inputs - channel mode
539     * - old channel mode
540     * output - NONE
541     * side effects - walk through all the channel modes turning off modes
542     * that were on in oldmode but aren't on in mode.
543     * Then walk through turning on modes that are on in mode
544     * but were not set in oldmode.
545     */
546     static void
547     set_final_mode(struct Mode *mode, struct Mode *oldmode)
548     {
549     char *pbuf = parabuf;
550 michael 3750 int len = 0;
551 adx 30
552     *mbuf++ = '-';
553    
554 michael 3750 for (const struct mode_letter *tab = chan_modes; tab->letter; ++tab)
555 michael 1175 if ((tab->mode & oldmode->mode) &&
556     !(tab->mode & mode->mode))
557     *mbuf++ = tab->letter;
558 adx 30
559 michael 3246 if (oldmode->limit && mode->limit == 0)
560 adx 30 *mbuf++ = 'l';
561    
562     if (oldmode->key[0] && !mode->key[0])
563     {
564     *mbuf++ = 'k';
565 michael 1793 len = sprintf(pbuf, "%s ", oldmode->key);
566 adx 30 pbuf += len;
567     pargs++;
568     }
569    
570 michael 3246 if (*(mbuf - 1) == '-')
571     *(mbuf - 1) = '+';
572 adx 30 else
573     *mbuf++ = '+';
574    
575 michael 3750 for (const struct mode_letter *tab = chan_modes; tab->letter; ++tab)
576 michael 1175 if ((tab->mode & mode->mode) &&
577     !(tab->mode & oldmode->mode))
578     *mbuf++ = tab->letter;
579 adx 30
580 michael 3246 if (mode->limit && oldmode->limit != mode->limit)
581 adx 30 {
582     *mbuf++ = 'l';
583 michael 1793 len = sprintf(pbuf, "%d ", mode->limit);
584 adx 30 pbuf += len;
585     pargs++;
586     }
587    
588     if (mode->key[0] && strcmp(oldmode->key, mode->key))
589     {
590     *mbuf++ = 'k';
591 michael 1793 len = sprintf(pbuf, "%s ", mode->key);
592 adx 30 pbuf += len;
593     pargs++;
594     }
595 michael 3246
596     if (*(mbuf - 1) == '+')
597     *(mbuf - 1) = '\0';
598 adx 30 else
599     *mbuf = '\0';
600     }
601    
602     /* remove_our_modes()
603     *
604     * inputs - pointer to channel to remove modes from
605     * - client pointer
606     * output - NONE
607     * side effects - Go through the local members, remove all their
608     * chanop modes etc., this side lost the TS.
609     */
610     static void
611     remove_our_modes(struct Channel *chptr, struct Client *source_p)
612     {
613     remove_a_mode(chptr, source_p, CHFL_CHANOP, 'o');
614     remove_a_mode(chptr, source_p, CHFL_HALFOP, 'h');
615     remove_a_mode(chptr, source_p, CHFL_VOICE, 'v');
616     }
617    
618     /* remove_a_mode()
619     *
620     * inputs - pointer to channel
621     * - server or client removing the mode
622     * - mask o/h/v mask to be removed
623     * - flag o/h/v to be removed
624     * output - NONE
625     * side effects - remove ONE mode from all members of a channel
626     */
627     static void
628     remove_a_mode(struct Channel *chptr, struct Client *source_p,
629     int mask, char flag)
630     {
631 michael 3246 dlink_node *ptr = NULL;
632 adx 30 char lmodebuf[MODEBUFLEN];
633 michael 3246 char *sp = sendbuf;
634 adx 30 const char *lpara[MAXMODEPARAMS];
635 michael 3750 unsigned int count = 0;
636     int l = 0;
637 adx 30
638     mbuf = lmodebuf;
639     *mbuf++ = '-';
640     *sp = '\0';
641    
642     DLINK_FOREACH(ptr, chptr->members.head)
643     {
644 michael 3246 struct Membership *ms = ptr->data;
645 adx 30
646     if ((ms->flags & mask) == 0)
647     continue;
648    
649     ms->flags &= ~mask;
650    
651     lpara[count++] = ms->client_p->name;
652    
653     *mbuf++ = flag;
654    
655     if (count >= MAXMODEPARAMS)
656     {
657 michael 3750 for (unsigned int i = 0; i < MAXMODEPARAMS; ++i)
658 adx 30 {
659 michael 1793 l = sprintf(sp, " %s", lpara[i]);
660 michael 2820 sp += l;
661 adx 30 }
662    
663     *mbuf = '\0';
664 michael 2820 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s%s",
665     (IsHidden(source_p) || ConfigServerHide.hide_servers) ?
666     me.name : source_p->name,
667     chptr->chname, lmodebuf, sendbuf);
668 adx 30 mbuf = lmodebuf;
669     *mbuf++ = '-';
670     count = 0;
671     sp = sendbuf;
672     *sp = '\0';
673     }
674     }
675    
676 michael 3246 if (count)
677 adx 30 {
678     *mbuf = '\0';
679 michael 3246
680 michael 3750 for (unsigned int i = 0; i < count; ++i)
681 adx 30 {
682 michael 1793 l = sprintf(sp, " %s", lpara[i]);
683 adx 30 sp += l;
684     }
685 michael 3246
686 michael 2820 sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s%s",
687     (IsHidden(source_p) || ConfigServerHide.hide_servers) ?
688     me.name : source_p->name,
689     chptr->chname, lmodebuf, sendbuf);
690 adx 30 }
691     }
692    
693     /* remove_ban_list()
694     *
695 michael 3041 * inputs - channel, source, list to remove, char of mode
696 adx 30 * outputs - none
697 michael 3135 * side effects - given ban list is removed, modes are sent to local clients
698 adx 30 */
699     static void
700     remove_ban_list(struct Channel *chptr, struct Client *source_p,
701 michael 3041 dlink_list *list, char c)
702 adx 30 {
703     char lmodebuf[MODEBUFLEN];
704     char lparabuf[IRCD_BUFSIZE];
705 michael 3750 dlink_node *ptr = NULL, *ptr_next = NULL;
706 adx 30 char *pbuf = NULL;
707 michael 2820 int count = 0;
708 adx 30 int cur_len, mlen, plen;
709    
710     pbuf = lparabuf;
711 michael 3750 cur_len = mlen = snprintf(lmodebuf, sizeof(lmodebuf), ":%s MODE %s -",
712 michael 3749 source_p->name, chptr->chname);
713 adx 30 mbuf = lmodebuf + mlen;
714    
715 michael 3750 DLINK_FOREACH_SAFE(ptr, ptr_next, list->head)
716 adx 30 {
717 michael 3750 struct Ban *banptr = ptr->data;
718 adx 30
719     plen = banptr->len + 4; /* another +b and "!@ " */
720 michael 3246
721 adx 30 if (count >= MAXMODEPARAMS ||
722     (cur_len + 1 /* space between */ + (plen - 1)) > IRCD_BUFSIZE - 2)
723     {
724     /* NUL-terminate and remove trailing space */
725     *mbuf = *(pbuf - 1) = '\0';
726 michael 3135 sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", lmodebuf, lparabuf);
727 adx 30 cur_len = mlen;
728     mbuf = lmodebuf + mlen;
729     pbuf = lparabuf;
730     count = 0;
731 michael 2820 }
732 adx 30
733     *mbuf++ = c;
734     cur_len += plen;
735 michael 2296 pbuf += sprintf(pbuf, "%s!%s@%s ", banptr->name, banptr->user,
736 michael 1793 banptr->host);
737 adx 30 ++count;
738    
739     remove_ban(banptr, list);
740     }
741    
742     *mbuf = *(pbuf - 1) = '\0';
743 michael 1243 sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", lmodebuf, lparabuf);
744 adx 30 }
745 michael 1230
746 michael 2820 static struct Message sjoin_msgtab =
747     {
748 michael 4545 "SJOIN", NULL, 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
749 michael 2820 { m_unregistered, m_ignore, ms_sjoin, m_ignore, m_ignore, m_ignore }
750 michael 1230 };
751    
752     static void
753     module_init(void)
754     {
755     mod_add_cmd(&sjoin_msgtab);
756     }
757    
758     static void
759     module_exit(void)
760     {
761     mod_del_cmd(&sjoin_msgtab);
762     }
763    
764 michael 2820 struct module module_entry =
765     {
766 michael 1230 .node = { NULL, NULL, NULL },
767     .name = NULL,
768     .version = "$Revision$",
769     .handle = NULL,
770     .modinit = module_init,
771     .modexit = module_exit,
772     .flags = MODULE_FLAG_CORE
773     };

Properties

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