ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/channel_mode.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/channel_mode.c (file contents):
Revision 4102 by michael, Sun Jun 29 19:35:28 2014 UTC vs.
Revision 4962 by michael, Mon Dec 1 13:08:31 2014 UTC

# Line 15 | Line 15
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 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
20   */
21  
# Line 83 | Line 83 | const struct mode_letter chan_modes[] =
83   static char *
84   check_string(char *s)
85   {
86 <  char *str = s;
86 >  char *const str = s;
87    static char star[] = "*";
88  
89    if (EmptyString(str))
# Line 112 | Line 112 | int
112   add_id(struct Client *client_p, struct Channel *chptr, char *banid, unsigned int type)
113   {
114    dlink_list *list = NULL;
115 <  dlink_node *ptr = NULL;
116 <  struct Ban *banptr = NULL;
115 >  dlink_node *node = NULL;
116 >  struct Ban *ban = NULL;
117    size_t len = 0;
118    char name[NICKLEN + 1] = "";
119    char user[USERLEN + 1] = "";
# Line 129 | Line 129 | add_id(struct Client *client_p, struct C
129  
130      if (num_mask >= ConfigChannel.max_bans)
131      {
132 <      sendto_one_numeric(client_p, &me, ERR_BANLISTFULL, chptr->chname, banid);
132 >      sendto_one_numeric(client_p, &me, ERR_BANLISTFULL, chptr->name, banid);
133        return 0;
134      }
135  
# Line 151 | Line 151 | add_id(struct Client *client_p, struct C
151     * Re-assemble a new n!u@h and print it back to banid for sending
152     * the mode to the channel.
153     */
154 <  len = sprintf(banid, "%s!%s@%s", name, user, host);
154 >  len = snprintf(banid, IRCD_BUFSIZE, "%s!%s@%s", name, user, host);
155  
156    switch (type)
157    {
158      case CHFL_BAN:
159        list = &chptr->banlist;
160 <      clear_ban_cache(chptr);
160 >      clear_ban_cache_channel(chptr);
161        break;
162      case CHFL_EXCEPTION:
163        list = &chptr->exceptlist;
164 <      clear_ban_cache(chptr);
164 >      clear_ban_cache_channel(chptr);
165        break;
166      case CHFL_INVEX:
167        list = &chptr->invexlist;
# Line 171 | Line 171 | add_id(struct Client *client_p, struct C
171        return 0;
172    }
173  
174 <  DLINK_FOREACH(ptr, list->head)
174 >  DLINK_FOREACH(node, list->head)
175    {
176 <    banptr = ptr->data;
176 >    ban = node->data;
177  
178 <    if (!irccmp(banptr->name, name) &&
179 <        !irccmp(banptr->user, user) &&
180 <        !irccmp(banptr->host, host))
178 >    if (!irccmp(ban->name, name) &&
179 >        !irccmp(ban->user, user) &&
180 >        !irccmp(ban->host, host))
181        return 0;
182    }
183  
184 <  banptr = mp_pool_get(ban_pool);
185 <  banptr->name = xstrdup(name);
186 <  banptr->user = xstrdup(user);
187 <  banptr->host = xstrdup(host);
188 <  banptr->when = CurrentTime;
189 <  banptr->len = len - 2;  /* -2 for ! + @ */
190 <  banptr->type = parse_netmask(host, &banptr->addr, &banptr->bits);
184 >  ban = mp_pool_get(ban_pool);
185 >  ban->name = xstrdup(name);
186 >  ban->user = xstrdup(user);
187 >  ban->host = xstrdup(host);
188 >  ban->when = CurrentTime;
189 >  ban->len = len - 2;  /* -2 for ! + @ */
190 >  ban->type = parse_netmask(host, &ban->addr, &ban->bits);
191  
192    if (IsClient(client_p))
193    {
194 <    banptr->who = MyCalloc(strlen(client_p->name) +
195 <                           strlen(client_p->username) +
196 <                           strlen(client_p->host) + 3);
197 <    sprintf(banptr->who, "%s!%s@%s", client_p->name,
194 >    ban->who = MyCalloc(strlen(client_p->name) +
195 >                        strlen(client_p->username) +
196 >                        strlen(client_p->host) + 3);
197 >    sprintf(ban->who, "%s!%s@%s", client_p->name,
198              client_p->username, client_p->host);
199    }
200    else if (IsHidden(client_p) || (IsServer(client_p) && ConfigServerHide.hide_servers))
201 <    banptr->who = xstrdup(me.name);
201 >    ban->who = xstrdup(me.name);
202    else
203 <    banptr->who = xstrdup(client_p->name);
203 >    ban->who = xstrdup(client_p->name);
204  
205 <  dlinkAdd(banptr, &banptr->node, list);
205 >  dlinkAdd(ban, &ban->node, list);
206  
207    return 1;
208   }
# Line 218 | Line 218 | static int
218   del_id(struct Channel *chptr, char *banid, unsigned int type)
219   {
220    dlink_list *list = NULL;
221 <  dlink_node *ptr = NULL;
221 >  dlink_node *node = NULL;
222    char name[NICKLEN + 1] = "";
223    char user[USERLEN + 1] = "";
224    char host[HOSTLEN + 1] = "";
# Line 241 | Line 241 | del_id(struct Channel *chptr, char *bani
241     * Re-assemble a new n!u@h and print it back to banid for sending
242     * the mode to the channel.
243     */
244 <  sprintf(banid, "%s!%s@%s", name, user, host);
244 >  snprintf(banid, IRCD_BUFSIZE, "%s!%s@%s", name, user, host);
245  
246    switch (type)
247    {
248      case CHFL_BAN:
249        list = &chptr->banlist;
250 <      clear_ban_cache(chptr);
250 >      clear_ban_cache_channel(chptr);
251        break;
252      case CHFL_EXCEPTION:
253        list = &chptr->exceptlist;
254 <      clear_ban_cache(chptr);
254 >      clear_ban_cache_channel(chptr);
255        break;
256      case CHFL_INVEX:
257        list = &chptr->invexlist;
# Line 261 | Line 261 | del_id(struct Channel *chptr, char *bani
261        return 0;
262    }
263  
264 <  DLINK_FOREACH(ptr, list->head)
264 >  DLINK_FOREACH(node, list->head)
265    {
266 <    struct Ban *banptr = ptr->data;
266 >    struct Ban *ban = node->data;
267  
268 <    if (!irccmp(name, banptr->name) &&
269 <        !irccmp(user, banptr->user) &&
270 <        !irccmp(host, banptr->host))
268 >    if (!irccmp(name, ban->name) &&
269 >        !irccmp(user, ban->user) &&
270 >        !irccmp(host, ban->host))
271      {
272 <      remove_ban(banptr, list);
272 >      remove_ban(ban, list);
273        return 1;
274      }
275    }
# Line 347 | Line 347 | fix_key(char *arg)
347   * side effects - clear ban cache
348   */
349   void
350 < clear_ban_cache(struct Channel *chptr)
350 > clear_ban_cache_channel(struct Channel *chptr)
351   {
352 <  dlink_node *ptr = NULL;
352 >  dlink_node *node = NULL;
353  
354 <  DLINK_FOREACH(ptr, chptr->members.head)
354 >  DLINK_FOREACH(node, chptr->locmembers.head)
355    {
356 <    struct Membership *ms = ptr->data;
357 <
358 <    if (MyConnect(ms->client_p))
359 <      ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED);
356 >    struct Membership *member = node->data;
357 >    member->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED);
358    }
359   }
360  
361   void
362   clear_ban_cache_client(struct Client *client_p)
363   {
364 <  dlink_node *ptr = NULL;
364 >  dlink_node *node = NULL;
365  
366 <  DLINK_FOREACH(ptr, client_p->channel.head)
366 >  DLINK_FOREACH(node, client_p->channel.head)
367    {
368 <    struct Membership *ms = ptr->data;
369 <    ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED);
368 >    struct Membership *member = node->data;
369 >    member->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED);
370    }
371   }
372  
# Line 409 | Line 407 | chm_simple(struct Client *source_p, stru
407      if (!(*errors & SM_ERR_NOOPS))
408        sendto_one_numeric(source_p, &me,
409                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
410 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
410 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
411 >
412      *errors |= SM_ERR_NOOPS;
413      return;
414    }
# Line 435 | Line 434 | chm_simple(struct Client *source_p, stru
434      mode_changes[mode_count].letter = c;
435      mode_changes[mode_count].arg = NULL;
436      mode_changes[mode_count].id = NULL;
437 <    mode_changes[mode_count].dir = dir;
439 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
437 >    mode_changes[mode_count++].dir = dir;
438    }
439    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
440    {
# Line 447 | Line 445 | chm_simple(struct Client *source_p, stru
445      mode_changes[mode_count].letter = c;
446      mode_changes[mode_count].arg = NULL;
447      mode_changes[mode_count].id = NULL;
448 <    mode_changes[mode_count].dir = dir;
451 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
448 >    mode_changes[mode_count++].dir = dir;
449    }
450   }
451  
# Line 461 | Line 458 | chm_registered(struct Client *source_p,
458      if (!(*errors & SM_ERR_ONLYSERVER))
459        sendto_one_numeric(source_p, &me,
460                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
461 <                         ERR_ONLYSERVERSCANCHANGE, chptr->chname);
461 >                         ERR_ONLYSERVERSCANCHANGE, chptr->name);
462 >
463      *errors |= SM_ERR_ONLYSERVER;
464      return;
465    }
# Line 487 | Line 485 | chm_registered(struct Client *source_p,
485      mode_changes[mode_count].letter = c;
486      mode_changes[mode_count].arg = NULL;
487      mode_changes[mode_count].id = NULL;
488 <    mode_changes[mode_count].dir = dir;
491 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
488 >    mode_changes[mode_count++].dir = dir;
489    }
490    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
491    {
# Line 499 | Line 496 | chm_registered(struct Client *source_p,
496      mode_changes[mode_count].letter = c;
497      mode_changes[mode_count].arg = NULL;
498      mode_changes[mode_count].id = NULL;
499 <    mode_changes[mode_count].dir = dir;
503 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
499 >    mode_changes[mode_count++].dir = dir;
500    }
501   }
502  
# Line 513 | Line 509 | chm_operonly(struct Client *source_p, st
509      if (!(*errors & SM_ERR_NOOPS))
510        sendto_one_numeric(source_p, &me,
511                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
512 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
512 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
513  
514      *errors |= SM_ERR_NOOPS;
515      return;
# Line 541 | Line 537 | chm_operonly(struct Client *source_p, st
537      mode_changes[mode_count].letter = c;
538      mode_changes[mode_count].arg = NULL;
539      mode_changes[mode_count].id = NULL;
540 <    mode_changes[mode_count].dir = dir;
545 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
540 >    mode_changes[mode_count++].dir = dir;
541    }
542    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
543    {
# Line 553 | Line 548 | chm_operonly(struct Client *source_p, st
548      mode_changes[mode_count].letter = c;
549      mode_changes[mode_count].arg = NULL;
550      mode_changes[mode_count].id = NULL;
551 <    mode_changes[mode_count].dir = dir;
557 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
551 >    mode_changes[mode_count++].dir = dir;
552    }
553   }
554  
# Line 566 | Line 560 | chm_ban(struct Client *source_p, struct
560  
561    if (dir == MODE_QUERY || parc <= *parn)
562    {
563 <    dlink_node *ptr = NULL;
563 >    dlink_node *node = NULL;
564  
565      if (*errors & SM_ERR_RPL_B)
566        return;
567  
568      *errors |= SM_ERR_RPL_B;
569  
570 <    DLINK_FOREACH(ptr, chptr->banlist.head)
570 >    DLINK_FOREACH(node, chptr->banlist.head)
571      {
572 <      const struct Ban *banptr = ptr->data;
573 <      sendto_one_numeric(source_p, &me, RPL_BANLIST, chptr->chname,
574 <                         banptr->name, banptr->user, banptr->host,
575 <                         banptr->who, banptr->when);
572 >      const struct Ban *ban = node->data;
573 >      sendto_one_numeric(source_p, &me, RPL_BANLIST, chptr->name,
574 >                         ban->name, ban->user, ban->host,
575 >                         ban->who, ban->when);
576      }
577  
578 <    sendto_one_numeric(source_p, &me, RPL_ENDOFBANLIST, chptr->chname);
578 >    sendto_one_numeric(source_p, &me, RPL_ENDOFBANLIST, chptr->name);
579      return;
580    }
581  
# Line 590 | Line 584 | chm_ban(struct Client *source_p, struct
584      if (!(*errors & SM_ERR_NOOPS))
585        sendto_one_numeric(source_p, &me,
586                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
587 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
587 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
588 >
589      *errors |= SM_ERR_NOOPS;
590      return;
591    }
# Line 600 | Line 595 | chm_ban(struct Client *source_p, struct
595  
596    mask = nuh_mask[*parn];
597    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
598 <  ++*parn;
598 >  ++(*parn);
599  
600    if (!MyConnect(source_p))
601      if (strchr(mask, ' '))
# Line 623 | Line 618 | chm_ban(struct Client *source_p, struct
618    mode_changes[mode_count].letter = c;
619    mode_changes[mode_count].arg = mask;
620    mode_changes[mode_count].id = NULL;
621 <  mode_changes[mode_count].dir = dir;
627 <  mode_changes[mode_count++].mems = ALL_MEMBERS;
621 >  mode_changes[mode_count++].dir = dir;
622   }
623  
624   static void
# Line 635 | Line 629 | chm_except(struct Client *source_p, stru
629  
630    if (dir == MODE_QUERY || parc <= *parn)
631    {
632 <    dlink_node *ptr = NULL;
632 >    dlink_node *node = NULL;
633  
634      if (*errors & SM_ERR_RPL_E)
635        return;
636  
637      *errors |= SM_ERR_RPL_E;
638  
639 <    DLINK_FOREACH(ptr, chptr->exceptlist.head)
639 >    DLINK_FOREACH(node, chptr->exceptlist.head)
640      {
641 <      const struct Ban *banptr = ptr->data;
641 >      const struct Ban *ban = node->data;
642  
643 <      sendto_one_numeric(source_p, &me, RPL_EXCEPTLIST, chptr->chname,
644 <                         banptr->name, banptr->user, banptr->host,
645 <                         banptr->who, banptr->when);
643 >      sendto_one_numeric(source_p, &me, RPL_EXCEPTLIST, chptr->name,
644 >                         ban->name, ban->user, ban->host,
645 >                         ban->who, ban->when);
646      }
647  
648 <    sendto_one_numeric(source_p, &me, RPL_ENDOFEXCEPTLIST, chptr->chname);
648 >    sendto_one_numeric(source_p, &me, RPL_ENDOFEXCEPTLIST, chptr->name);
649      return;
650    }
651  
# Line 660 | Line 654 | chm_except(struct Client *source_p, stru
654      if (!(*errors & SM_ERR_NOOPS))
655        sendto_one_numeric(source_p, &me,
656                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
657 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
657 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
658 >
659      *errors |= SM_ERR_NOOPS;
660      return;
661    }
# Line 670 | Line 665 | chm_except(struct Client *source_p, stru
665  
666    mask = nuh_mask[*parn];
667    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
668 <  ++*parn;
668 >  ++(*parn);
669  
670    if (!MyConnect(source_p))
671      if (strchr(mask, ' '))
# Line 693 | Line 688 | chm_except(struct Client *source_p, stru
688    mode_changes[mode_count].letter = c;
689    mode_changes[mode_count].arg = mask;
690    mode_changes[mode_count].id = NULL;
691 <  mode_changes[mode_count].dir = dir;
697 <  mode_changes[mode_count++].mems = ALL_MEMBERS;
691 >  mode_changes[mode_count++].dir = dir;
692   }
693  
694   static void
# Line 705 | Line 699 | chm_invex(struct Client *source_p, struc
699  
700    if (dir == MODE_QUERY || parc <= *parn)
701    {
702 <    dlink_node *ptr = NULL;
702 >    dlink_node *node = NULL;
703  
704      if (*errors & SM_ERR_RPL_I)
705        return;
706  
707      *errors |= SM_ERR_RPL_I;
708  
709 <    DLINK_FOREACH(ptr, chptr->invexlist.head)
709 >    DLINK_FOREACH(node, chptr->invexlist.head)
710      {
711 <      const struct Ban *banptr = ptr->data;
711 >      const struct Ban *ban = node->data;
712  
713 <      sendto_one_numeric(source_p, &me, RPL_INVEXLIST, chptr->chname,
714 <                         banptr->name, banptr->user, banptr->host,
715 <                         banptr->who, banptr->when);
713 >      sendto_one_numeric(source_p, &me, RPL_INVEXLIST, chptr->name,
714 >                         ban->name, ban->user, ban->host,
715 >                         ban->who, ban->when);
716      }
717  
718 <    sendto_one_numeric(source_p, &me, RPL_ENDOFINVEXLIST, chptr->chname);
718 >    sendto_one_numeric(source_p, &me, RPL_ENDOFINVEXLIST, chptr->name);
719      return;
720    }
721  
# Line 730 | Line 724 | chm_invex(struct Client *source_p, struc
724      if (!(*errors & SM_ERR_NOOPS))
725        sendto_one_numeric(source_p, &me,
726                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
727 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
727 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
728 >
729      *errors |= SM_ERR_NOOPS;
730      return;
731    }
# Line 740 | Line 735 | chm_invex(struct Client *source_p, struc
735  
736    mask = nuh_mask[*parn];
737    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
738 <  ++*parn;
738 >  ++(*parn);
739  
740    if (!MyConnect(source_p))
741      if (strchr(mask, ' '))
# Line 763 | Line 758 | chm_invex(struct Client *source_p, struc
758    mode_changes[mode_count].letter = c;
759    mode_changes[mode_count].arg = mask;
760    mode_changes[mode_count].id = NULL;
761 <  mode_changes[mode_count].dir = dir;
767 <  mode_changes[mode_count++].mems = ALL_MEMBERS;
761 >  mode_changes[mode_count++].dir = dir;
762   }
763  
764   static void
# Line 779 | Line 773 | chm_voice(struct Client *source_p, struc
773      if (!(*errors & SM_ERR_NOOPS))
774        sendto_one_numeric(source_p, &me,
775                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
776 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
776 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
777 >
778      *errors |= SM_ERR_NOOPS;
779      return;
780    }
# Line 793 | Line 788 | chm_voice(struct Client *source_p, struc
788    if ((member = find_channel_link(target_p, chptr)) == NULL)
789    {
790      if (!(*errors & SM_ERR_NOTONCHANNEL))
791 <      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->chname);
791 >      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
792 >
793      *errors |= SM_ERR_NOTONCHANNEL;
794      return;
795    }
# Line 804 | Line 800 | chm_voice(struct Client *source_p, struc
800    /* no redundant mode changes */
801    if (dir == MODE_ADD &&  has_member_flags(member, CHFL_VOICE))
802      return;
803 +
804    if (dir == MODE_DEL && !has_member_flags(member, CHFL_VOICE))
805      return;
806  
807    mode_changes[mode_count].letter = c;
808    mode_changes[mode_count].arg = target_p->name;
809    mode_changes[mode_count].id = target_p->id;
810 <  mode_changes[mode_count].dir = dir;
814 <  mode_changes[mode_count++].mems = ALL_MEMBERS;
810 >  mode_changes[mode_count++].dir = dir;
811  
812    if (dir == MODE_ADD)
813      AddMemberFlag(member, CHFL_VOICE);
# Line 831 | Line 827 | chm_hop(struct Client *source_p, struct
827      if (!(*errors & SM_ERR_NOOPS))
828        sendto_one_numeric(source_p, &me,
829                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
830 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
830 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
831 >
832      *errors |= SM_ERR_NOOPS;
833      return;
834    }
# Line 845 | Line 842 | chm_hop(struct Client *source_p, struct
842    if ((member = find_channel_link(target_p, chptr)) == NULL)
843    {
844      if (!(*errors & SM_ERR_NOTONCHANNEL))
845 <      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->chname);
845 >      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
846 >
847      *errors |= SM_ERR_NOTONCHANNEL;
848      return;
849    }
# Line 856 | Line 854 | chm_hop(struct Client *source_p, struct
854    /* no redundant mode changes */
855    if (dir == MODE_ADD &&  has_member_flags(member, CHFL_HALFOP))
856      return;
857 +
858    if (dir == MODE_DEL && !has_member_flags(member, CHFL_HALFOP))
859      return;
860  
861    mode_changes[mode_count].letter = c;
862    mode_changes[mode_count].arg = target_p->name;
863    mode_changes[mode_count].id = target_p->id;
864 <  mode_changes[mode_count].dir = dir;
866 <  mode_changes[mode_count++].mems = ALL_MEMBERS;
864 >  mode_changes[mode_count++].dir = dir;
865  
866    if (dir == MODE_ADD)
867      AddMemberFlag(member, CHFL_HALFOP);
# Line 883 | Line 881 | chm_op(struct Client *source_p, struct C
881      if (!(*errors & SM_ERR_NOOPS))
882        sendto_one_numeric(source_p, &me,
883                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
884 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
884 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
885 >
886      *errors |= SM_ERR_NOOPS;
887      return;
888    }
# Line 897 | Line 896 | chm_op(struct Client *source_p, struct C
896    if ((member = find_channel_link(target_p, chptr)) == NULL)
897    {
898      if (!(*errors & SM_ERR_NOTONCHANNEL))
899 <      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->chname);
899 >      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
900 >
901      *errors |= SM_ERR_NOTONCHANNEL;
902      return;
903    }
# Line 908 | Line 908 | chm_op(struct Client *source_p, struct C
908    /* no redundant mode changes */
909    if (dir == MODE_ADD &&  has_member_flags(member, CHFL_CHANOP))
910      return;
911 +
912    if (dir == MODE_DEL && !has_member_flags(member, CHFL_CHANOP))
913      return;
914  
915    mode_changes[mode_count].letter = c;
916    mode_changes[mode_count].arg = target_p->name;
917    mode_changes[mode_count].id = target_p->id;
918 <  mode_changes[mode_count].dir = dir;
918 <  mode_changes[mode_count++].mems = ALL_MEMBERS;
918 >  mode_changes[mode_count++].dir = dir;
919  
920    if (dir == MODE_ADD)
921      AddMemberFlag(member, CHFL_CHANOP);
# Line 934 | Line 934 | chm_limit(struct Client *source_p, struc
934      if (!(*errors & SM_ERR_NOOPS))
935        sendto_one_numeric(source_p, &me,
936                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
937 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
937 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
938      *errors |= SM_ERR_NOOPS;
939      return;
940    }
# Line 944 | Line 944 | chm_limit(struct Client *source_p, struc
944  
945    if (dir == MODE_ADD && parc > *parn)
946    {
947 <    char *lstr = parv[(*parn)++];
947 >    char *const lstr = parv[(*parn)++];
948  
949      if (EmptyString(lstr) || (limit = atoi(lstr)) <= 0)
950        return;
# Line 959 | Line 959 | chm_limit(struct Client *source_p, struc
959      mode_changes[mode_count].letter = c;
960      mode_changes[mode_count].arg = lstr;
961      mode_changes[mode_count].id = NULL;
962 <    mode_changes[mode_count].dir = dir;
963 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
962 >    mode_changes[mode_count++].dir = dir;
963  
964      chptr->mode.limit = limit;
965    }
# Line 974 | Line 973 | chm_limit(struct Client *source_p, struc
973      mode_changes[mode_count].letter = c;
974      mode_changes[mode_count].arg = NULL;
975      mode_changes[mode_count].id = NULL;
976 <    mode_changes[mode_count].dir = dir;
978 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
976 >    mode_changes[mode_count++].dir = dir;
977    }
978   }
979  
# Line 988 | Line 986 | chm_key(struct Client *source_p, struct
986      if (!(*errors & SM_ERR_NOOPS))
987        sendto_one_numeric(source_p, &me,
988                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
989 <                         ERR_CHANOPRIVSNEEDED, chptr->chname);
989 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
990      *errors |= SM_ERR_NOOPS;
991      return;
992    }
# Line 998 | Line 996 | chm_key(struct Client *source_p, struct
996  
997    if (dir == MODE_ADD && parc > *parn)
998    {
999 <    char *key = fix_key(parv[(*parn)++]);
999 >    char *const key = fix_key(parv[(*parn)++]);
1000  
1001      if (EmptyString(key))
1002        return;
# Line 1014 | Line 1012 | chm_key(struct Client *source_p, struct
1012      mode_changes[mode_count].letter = c;
1013      mode_changes[mode_count].arg = chptr->mode.key;
1014      mode_changes[mode_count].id = NULL;
1015 <    mode_changes[mode_count].dir = dir;
1018 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
1015 >    mode_changes[mode_count++].dir = dir;
1016    }
1017    else if (dir == MODE_DEL)
1018    {
1019      if (parc > *parn)
1020 <      (*parn)++;
1020 >      ++(*parn);
1021  
1022      if (chptr->mode.key[0] == '\0')
1023        return;
# Line 1030 | Line 1027 | chm_key(struct Client *source_p, struct
1027      mode_changes[mode_count].letter = c;
1028      mode_changes[mode_count].arg = "*";
1029      mode_changes[mode_count].id = NULL;
1030 <    mode_changes[mode_count].dir = dir;
1034 <    mode_changes[mode_count++].mems = ALL_MEMBERS;
1030 >    mode_changes[mode_count++].dir = dir;
1031    }
1032   }
1033  
# Line 1346 | Line 1342 | send_mode_changes_server(struct Client *
1342    parptr = parabuf;
1343  
1344    mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id,
1345 <                 (unsigned long)chptr->channelts, chptr->chname);
1345 >                 (unsigned long)chptr->creationtime, chptr->name);
1346  
1347    /* Loop the list of modes we have */
1348    for (unsigned i = 0; i < mode_count; ++i)
# Line 1373 | Line 1369 | send_mode_changes_server(struct Client *
1369          (pbl + arglen + BAN_FUDGE) >= MODEBUFLEN)
1370      {
1371        if (nc)
1372 <        sendto_server(source_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
1372 >        sendto_server(source_p, 0, 0, "%s %s", modebuf, parabuf);
1373  
1374        nc = 0;
1375        mc = 0;
1376  
1377        mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id,
1378 <                     (unsigned long)chptr->channelts, chptr->chname);
1378 >                     (unsigned long)chptr->creationtime, chptr->name);
1379  
1380        pbl = 0;
1381        parabuf[0] = '\0';
# Line 1395 | Line 1391 | send_mode_changes_server(struct Client *
1391  
1392      modebuf[mbl++] = mode_changes[i].letter;
1393      modebuf[mbl] = '\0';
1394 <    nc++;
1394 >    ++nc;
1395  
1396      if (arg)
1397      {
1398        len = sprintf(parptr, "%s ", arg);
1399        pbl += len;
1400        parptr += len;
1401 <      mc++;
1401 >      ++mc;
1402      }
1403    }
1404  
# Line 1410 | Line 1406 | send_mode_changes_server(struct Client *
1406      parabuf[pbl - 1] = '\0';
1407  
1408    if (nc)
1409 <    sendto_server(source_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
1409 >    sendto_server(source_p, 0, 0, "%s %s", modebuf, parabuf);
1410   }
1411  
1412   /* void send_mode_changes(struct Client *client_p,
# Line 1440 | Line 1436 | send_mode_changes(struct Client *source_
1436    if (IsServer(source_p))
1437      mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) ||
1438                     ConfigServerHide.hide_servers) ?
1439 <                   me.name : source_p->name, chptr->chname);
1439 >                   me.name : source_p->name, chptr->name);
1440    else
1441      mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1442 <                   source_p->username, source_p->host, chptr->chname);
1442 >                   source_p->username, source_p->host, chptr->name);
1443  
1444    parabuf[0] = '\0';
1445    parptr = parabuf;
1446  
1447    for (unsigned int i = 0; i < mode_count; ++i)
1448    {
1449 <    if (mode_changes[i].letter == 0 ||
1454 <        mode_changes[i].mems == ONLY_SERVERS)
1449 >    if (mode_changes[i].letter == 0)
1450        continue;
1451  
1452      arg = mode_changes[i].arg;
# Line 1460 | Line 1455 | send_mode_changes(struct Client *source_
1455      else
1456        arglen = 0;
1457  
1458 <    if ((mc == MAXMODEPARAMS)  ||
1458 >    if ((mc == MAXMODEPARAMS) ||
1459          ((arglen + mbl + pbl + 2) > IRCD_BUFSIZE) ||
1460          ((arglen + pbl + BAN_FUDGE) >= MODEBUFLEN))
1461      {
# Line 1468 | Line 1463 | send_mode_changes(struct Client *source_
1463          modebuf[mbl - 1] = '\0';
1464  
1465        if (nc)
1466 <        sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", modebuf, parabuf);
1466 >        sendto_channel_local(0, chptr, "%s %s", modebuf, parabuf);
1467  
1468        nc = 0;
1469        mc = 0;
# Line 1476 | Line 1471 | send_mode_changes(struct Client *source_
1471        if (IsServer(source_p))
1472          mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) ||
1473                         ConfigServerHide.hide_servers) ?
1474 <                       me.name : source_p->name, chptr->chname);
1474 >                       me.name : source_p->name, chptr->name);
1475        else
1476          mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1477 <                       source_p->username, source_p->host, chptr->chname);
1477 >                       source_p->username, source_p->host, chptr->name);
1478  
1479        pbl = 0;
1480        parabuf[0] = '\0';
# Line 1495 | Line 1490 | send_mode_changes(struct Client *source_
1490  
1491      modebuf[mbl++] = mode_changes[i].letter;
1492      modebuf[mbl] = '\0';
1493 <    nc++;
1493 >    ++nc;
1494  
1495      if (arg)
1496      {
1497        len = sprintf(parptr, "%s ", arg);
1498        pbl += len;
1499        parptr += len;
1500 <      mc++;
1500 >      ++mc;
1501      }
1502    }
1503  
# Line 1510 | Line 1505 | send_mode_changes(struct Client *source_
1505      parabuf[pbl - 1] = '\0';
1506  
1507    if (nc)
1508 <    sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", modebuf, parabuf);
1508 >    sendto_channel_local(0, chptr, "%s %s", modebuf, parabuf);
1509  
1510    send_mode_changes_server(source_p, chptr);
1511   }

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)