ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/cmode.C
(Generate patch)

Comparing ermyth/src/cmode.C (file contents):
Revision 1.5 by pippijn, Thu Aug 30 19:56:24 2007 UTC vs.
Revision 1.6 by pippijn, Wed Sep 5 11:23:15 2007 UTC

3 * Rights to this code are documented in doc/pod/license.pod. 3 * Rights to this code are documented in doc/pod/license.pod.
4 * 4 *
5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) 5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 */ 6 */
7 7
8static char const rcsid[] = "$Id: cmode.C,v 1.5 2007/08/30 19:56:24 pippijn Exp $"; 8static char const rcsid[] = "$Id: cmode.C,v 1.6 2007/09/05 11:23:15 pippijn Exp $";
9 9
10#include "atheme.h" 10#include "atheme.h"
11#include <account/chanacs.h> 11#include <account/chanacs.h>
12#include <account/mychan.h> 12#include <account/mychan.h>
13 13
46void 46void
47channel_mode (user_t *source, channel_t *chan, int parc, char const * const parv[]) 47channel_mode (user_t *source, channel_t *chan, int parc, char const * const parv[])
48{ 48{
49 bool matched = false; 49 bool matched = false;
50 bool simple_modes_changed = false; 50 bool simple_modes_changed = false;
51 int i, parpos = 0, whatt = MTYPE_NUL; 51 int i, parpos = 0;
52 mtype whatt = MTYPE_NUL;
52 unsigned int newlimit; 53 unsigned int newlimit;
53 char const *pos = parv[0]; 54 char const *pos = parv[0];
54 mychan_t *mc; 55 mychan_t *mc;
55 chanuser_t *cu = NULL; 56 chanuser_t *cu = NULL;
56 user_t *first_deopped_service = NULL; 57 user_t *first_deopped_service = NULL;
454static void 455static void
455modestack_flush (struct modestackdata *md) 456modestack_flush (struct modestackdata *md)
456{ 457{
457 char buf[512]; 458 char buf[512];
458 char *end, *p; 459 char *end, *p;
459 int dir = MTYPE_NUL; 460 mtype dir = MTYPE_NUL;
460 int i; 461 int i;
461 462
462 p = buf; 463 p = buf;
463 end = buf + sizeof buf; 464 end = buf + sizeof buf;
464 465
559 modestackdata.channel = channel; 560 modestackdata.channel = channel;
560 return &modestackdata; 561 return &modestackdata;
561} 562}
562 563
563static void 564static void
564modestack_add_simple (struct modestackdata *md, int dir, int flags) 565modestack_add_simple (struct modestackdata *md, mtype dir, int flags)
565{ 566{
566 if (dir == MTYPE_ADD) 567 if (dir == MTYPE_ADD)
567 md->modes_on |= flags, md->modes_off &= ~flags; 568 md->modes_on |= flags, md->modes_off &= ~flags;
568 else if (dir == MTYPE_DEL) 569 else if (dir == MTYPE_DEL)
569 md->modes_off |= flags, md->modes_on &= ~flags; 570 md->modes_off |= flags, md->modes_on &= ~flags;
570 else 571 else
571 slog (LG_ERROR, "modestack_add_simple(): invalid direction"); 572 slog (LG_ERROR, "modestack_add_simple(): invalid direction");
572} 573}
573 574
574static void 575static void
575modestack_add_limit (struct modestackdata *md, int dir, unsigned int limit) 576modestack_add_limit (struct modestackdata *md, mtype dir, unsigned int limit)
576{ 577{
577 md->limitused = 0; 578 md->limitused = 0;
578 modestack_calclen (md); 579 modestack_calclen (md);
579 if (md->paramcount >= MAXMODES) 580 if (md->paramcount >= MAXMODES)
580 modestack_flush (md); 581 modestack_flush (md);
590 slog (LG_ERROR, "modestack_add_limit(): invalid direction"); 591 slog (LG_ERROR, "modestack_add_limit(): invalid direction");
591 md->limitused = 1; 592 md->limitused = 1;
592} 593}
593 594
594static void 595static void
595modestack_add_ext (struct modestackdata *md, int dir, int i, char const * const value) 596modestack_add_ext (struct modestackdata *md, mtype dir, int i, char const * const value)
596{ 597{
597 md->extmodesused[i] = 0; 598 md->extmodesused[i] = 0;
598 modestack_calclen (md); 599 modestack_calclen (md);
599 if (md->paramcount >= MAXMODES) 600 if (md->paramcount >= MAXMODES)
600 modestack_flush (md); 601 modestack_flush (md);
610 slog (LG_ERROR, "modestack_add_ext(): invalid direction"); 611 slog (LG_ERROR, "modestack_add_ext(): invalid direction");
611 md->extmodesused[i] = 1; 612 md->extmodesused[i] = 1;
612} 613}
613 614
614static void 615static void
615modestack_add_param (struct modestackdata *md, int dir, char type, char const * const value) 616modestack_add_param (struct modestackdata *md, mtype dir, char type, char const * const value)
616{ 617{
617 char *p; 618 char *p;
618 int n = 0, i; 619 int n = 0, i;
619 char dir2 = MTYPE_NUL; 620 char dir2 = MTYPE_NUL;
620 char str[3]; 621 char str[3];
702 } 703 }
703} 704}
704 705
705/* stack simple modes without parameters */ 706/* stack simple modes without parameters */
706void 707void
707modestack_mode_simple (char *source, channel_t *channel, int dir, int flags) 708modestack_mode_simple (char *source, channel_t *channel, mtype dir, int flags)
708{ 709{
709 struct modestackdata *md; 710 struct modestackdata *md;
710 711
711 if (flags == 0) 712 if (flags == 0)
712 return; 713 return;
716 md->event = event_add_once ("flush_cmode_callback", modestack_flush_callback, md, 0); 717 md->event = event_add_once ("flush_cmode_callback", modestack_flush_callback, md, 0);
717} 718}
718 719
719/* stack a limit */ 720/* stack a limit */
720void 721void
721modestack_mode_limit (char *source, channel_t *channel, int dir, unsigned int limit) 722modestack_mode_limit (char *source, channel_t *channel, mtype dir, unsigned int limit)
722{ 723{
723 struct modestackdata *md; 724 struct modestackdata *md;
724 725
725 md = modestack_init (source, channel); 726 md = modestack_init (source, channel);
726 modestack_add_limit (md, dir, limit); 727 modestack_add_limit (md, dir, limit);
728 md->event = event_add_once ("flush_cmode_callback", modestack_flush_callback, md, 0); 729 md->event = event_add_once ("flush_cmode_callback", modestack_flush_callback, md, 0);
729} 730}
730 731
731/* stack a non-standard type C mode */ 732/* stack a non-standard type C mode */
732void 733void
733modestack_mode_ext (char *source, channel_t *channel, int dir, int i, char const * const value) 734modestack_mode_ext (char *source, channel_t *channel, mtype dir, int i, char const * const value)
734{ 735{
735 struct modestackdata *md; 736 struct modestackdata *md;
736 737
737 md = modestack_init (source, channel); 738 md = modestack_init (source, channel);
738 if (i < 0 || i >= MAXEXTMODES) 739 if (i < 0 || i >= MAXEXTMODES)
745 md->event = event_add_once ("flush_cmode_callback", modestack_flush_callback, md, 0); 746 md->event = event_add_once ("flush_cmode_callback", modestack_flush_callback, md, 0);
746} 747}
747 748
748/* stack a type A, B or E mode */ 749/* stack a type A, B or E mode */
749void 750void
750modestack_mode_param (char *source, channel_t *channel, int dir, char type, char const * const value) 751modestack_mode_param (char *source, channel_t *channel, mtype dir, char type, char const * const value)
751{ 752{
752 struct modestackdata *md; 753 struct modestackdata *md;
753 754
754 md = modestack_init (source, channel); 755 md = modestack_init (source, channel);
755 modestack_add_param (md, dir, type, value); 756 modestack_add_param (md, dir, type, value);
838void 839void
839check_modes (mychan_t *mychan, bool sendnow) 840check_modes (mychan_t *mychan, bool sendnow)
840{ 841{
841 int modes; 842 int modes;
842 int i; 843 int i;
843 metadata::item *md; 844 metadata *md;
844 char *p, *q; 845 char *p, *q;
845 char str2[512]; 846 char str2[512];
846 847
847 if (!mychan || !mychan->chan) 848 if (!mychan || !mychan->chan)
848 return; 849 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines