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 4800 by michael, Tue Oct 28 13:59:43 2014 UTC vs.
Revision 4884 by michael, Tue Nov 18 16:22:34 2014 UTC

# 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 113 | Line 113 | add_id(struct Client *client_p, struct C
113   {
114    dlink_list *list = NULL;
115    dlink_node *node = NULL;
116 <  struct Ban *banptr = NULL;
116 >  struct Ban *ban = NULL;
117    size_t len = 0;
118    char name[NICKLEN + 1] = "";
119    char user[USERLEN + 1] = "";
# 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 173 | Line 173 | add_id(struct Client *client_p, struct C
173  
174    DLINK_FOREACH(node, list->head)
175    {
176 <    banptr = node->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 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 263 | Line 263 | del_id(struct Channel *chptr, char *bani
263  
264    DLINK_FOREACH(node, list->head)
265    {
266 <    struct Ban *banptr = node->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 *node = NULL;
353  
354    DLINK_FOREACH(node, chptr->locmembers.head)
355    {
356 <    struct Membership *ms = node->data;
357 <    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  
# Line 365 | Line 365 | clear_ban_cache_client(struct Client *cl
365  
366    DLINK_FOREACH(node, client_p->channel.head)
367    {
368 <    struct Membership *ms = node->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 408 | Line 408 | chm_simple(struct Client *source_p, stru
408        sendto_one_numeric(source_p, &me,
409                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
410                           ERR_CHANOPRIVSNEEDED, chptr->name);
411 +
412      *errors |= SM_ERR_NOOPS;
413      return;
414    }
# Line 458 | Line 459 | chm_registered(struct Client *source_p,
459        sendto_one_numeric(source_p, &me,
460                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
461                           ERR_ONLYSERVERSCANCHANGE, chptr->name);
462 +
463      *errors |= SM_ERR_ONLYSERVER;
464      return;
465    }
# Line 567 | Line 569 | chm_ban(struct Client *source_p, struct
569  
570      DLINK_FOREACH(node, chptr->banlist.head)
571      {
572 <      const struct Ban *banptr = node->data;
572 >      const struct Ban *ban = node->data;
573        sendto_one_numeric(source_p, &me, RPL_BANLIST, chptr->name,
574 <                         banptr->name, banptr->user, banptr->host,
575 <                         banptr->who, banptr->when);
574 >                         ban->name, ban->user, ban->host,
575 >                         ban->who, ban->when);
576      }
577  
578      sendto_one_numeric(source_p, &me, RPL_ENDOFBANLIST, chptr->name);
# Line 583 | Line 585 | chm_ban(struct Client *source_p, struct
585        sendto_one_numeric(source_p, &me,
586                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
587                           ERR_CHANOPRIVSNEEDED, chptr->name);
588 +
589      *errors |= SM_ERR_NOOPS;
590      return;
591    }
# Line 635 | Line 638 | chm_except(struct Client *source_p, stru
638  
639      DLINK_FOREACH(node, chptr->exceptlist.head)
640      {
641 <      const struct Ban *banptr = node->data;
641 >      const struct Ban *ban = node->data;
642  
643        sendto_one_numeric(source_p, &me, RPL_EXCEPTLIST, chptr->name,
644 <                         banptr->name, banptr->user, banptr->host,
645 <                         banptr->who, banptr->when);
644 >                         ban->name, ban->user, ban->host,
645 >                         ban->who, ban->when);
646      }
647  
648      sendto_one_numeric(source_p, &me, RPL_ENDOFEXCEPTLIST, chptr->name);
# Line 652 | Line 655 | chm_except(struct Client *source_p, stru
655        sendto_one_numeric(source_p, &me,
656                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
657                           ERR_CHANOPRIVSNEEDED, chptr->name);
658 +
659      *errors |= SM_ERR_NOOPS;
660      return;
661    }
# Line 704 | Line 708 | chm_invex(struct Client *source_p, struc
708  
709      DLINK_FOREACH(node, chptr->invexlist.head)
710      {
711 <      const struct Ban *banptr = node->data;
711 >      const struct Ban *ban = node->data;
712  
713        sendto_one_numeric(source_p, &me, RPL_INVEXLIST, chptr->name,
714 <                         banptr->name, banptr->user, banptr->host,
715 <                         banptr->who, banptr->when);
714 >                         ban->name, ban->user, ban->host,
715 >                         ban->who, ban->when);
716      }
717  
718      sendto_one_numeric(source_p, &me, RPL_ENDOFINVEXLIST, chptr->name);
# Line 721 | Line 725 | chm_invex(struct Client *source_p, struc
725        sendto_one_numeric(source_p, &me,
726                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
727                           ERR_CHANOPRIVSNEEDED, chptr->name);
728 +
729      *errors |= SM_ERR_NOOPS;
730      return;
731    }
# Line 769 | Line 774 | chm_voice(struct Client *source_p, struc
774        sendto_one_numeric(source_p, &me,
775                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
776                           ERR_CHANOPRIVSNEEDED, chptr->name);
777 +
778      *errors |= SM_ERR_NOOPS;
779      return;
780    }
# Line 783 | Line 789 | chm_voice(struct Client *source_p, struc
789    {
790      if (!(*errors & SM_ERR_NOTONCHANNEL))
791        sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
792 +
793      *errors |= SM_ERR_NOTONCHANNEL;
794      return;
795    }
# Line 793 | 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  
# Line 820 | Line 828 | chm_hop(struct Client *source_p, struct
828        sendto_one_numeric(source_p, &me,
829                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
830                           ERR_CHANOPRIVSNEEDED, chptr->name);
831 +
832      *errors |= SM_ERR_NOOPS;
833      return;
834    }
# Line 834 | Line 843 | chm_hop(struct Client *source_p, struct
843    {
844      if (!(*errors & SM_ERR_NOTONCHANNEL))
845        sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
846 +
847      *errors |= SM_ERR_NOTONCHANNEL;
848      return;
849    }
# Line 844 | 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  
# Line 871 | Line 882 | chm_op(struct Client *source_p, struct C
882        sendto_one_numeric(source_p, &me,
883                           alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
884                           ERR_CHANOPRIVSNEEDED, chptr->name);
885 +
886      *errors |= SM_ERR_NOOPS;
887      return;
888    }
# Line 885 | Line 897 | chm_op(struct Client *source_p, struct C
897    {
898      if (!(*errors & SM_ERR_NOTONCHANNEL))
899        sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
900 +
901      *errors |= SM_ERR_NOTONCHANNEL;
902      return;
903    }
# Line 895 | 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  
# Line 930 | 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 982 | 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 1328 | 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->name);
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 1361 | Line 1375 | send_mode_changes_server(struct Client *
1375        mc = 0;
1376  
1377        mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id,
1378 <                     (unsigned long)chptr->channelts, chptr->name);
1378 >                     (unsigned long)chptr->creationtime, chptr->name);
1379  
1380        pbl = 0;
1381        parabuf[0] = '\0';

Diff Legend

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