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 3149 by michael, Fri Mar 14 12:38:27 2014 UTC vs.
Revision 3153 by michael, Fri Mar 14 15:39:21 2014 UTC

# Line 421 | Line 421 | clear_ban_cache_client(struct Client *cl
421  
422   /* Mode functions handle mode changes for a particular mode... */
423   static void
424 < chm_nosuch(struct Client *client_p, struct Client *source_p,
424 > chm_nosuch(struct Client *source_p,
425             struct Channel *chptr, int parc, int *parn,
426             char **parv, int *errors, int alev, int dir, char c, unsigned int d)
427   {
# Line 433 | Line 433 | chm_nosuch(struct Client *client_p, stru
433   }
434  
435   static void
436 < chm_simple(struct Client *client_p, struct Client *source_p, struct Channel *chptr,
436 > chm_simple(struct Client *source_p, struct Channel *chptr,
437             int parc, int *parn, char **parv, int *errors, int alev, int dir,
438             char c, unsigned int d)
439   {
# Line 487 | Line 487 | chm_simple(struct Client *client_p, stru
487   }
488  
489   static void
490 < chm_registered(struct Client *client_p, struct Client *source_p, struct Channel *chptr,
491 <           int parc, int *parn, char **parv, int *errors, int alev, int dir,
492 <           char c, unsigned int d)
490 > chm_registered(struct Client *source_p, struct Channel *chptr,
491 >               int parc, int *parn, char **parv, int *errors, int alev, int dir,
492 >               char c, unsigned int d)
493   {
494    if (!IsServer(source_p) && !HasFlag(source_p, FLAGS_SERVICE))
495    {
# Line 540 | Line 540 | chm_registered(struct Client *client_p,
540   }
541  
542   static void
543 < chm_operonly(struct Client *client_p, struct Client *source_p, struct Channel *chptr,
544 <            int parc, int *parn, char **parv, int *errors, int alev, int dir,
545 <            char c, unsigned int d)
543 > chm_operonly(struct Client *source_p, struct Channel *chptr,
544 >             int parc, int *parn, char **parv, int *errors, int alev, int dir,
545 >             char c, unsigned int d)
546   {
547    if ((alev < CHACCESS_HALFOP) ||
548        ((d == MODE_PRIVATE) && (alev < CHACCESS_CHANOP)))
# Line 600 | Line 600 | chm_operonly(struct Client *client_p, st
600   }
601  
602   static void
603 < chm_ban(struct Client *client_p, struct Client *source_p,
603 > chm_ban(struct Client *source_p,
604          struct Channel *chptr, int parc, int *parn,
605          char **parv, int *errors, int alev, int dir, char c, unsigned int d)
606   {
# Line 644 | Line 644 | chm_ban(struct Client *client_p, struct
644    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
645    ++*parn;
646  
647 <  if (IsServer(client_p))
647 >  if (!MyConnect(source_p))
648      if (strchr(mask, ' '))
649        return;
650  
# Line 670 | Line 670 | chm_ban(struct Client *client_p, struct
670   }
671  
672   static void
673 < chm_except(struct Client *client_p, struct Client *source_p,
673 > chm_except(struct Client *source_p,
674             struct Channel *chptr, int parc, int *parn,
675             char **parv, int *errors, int alev, int dir, char c, unsigned int d)
676   {
# Line 715 | Line 715 | chm_except(struct Client *client_p, stru
715    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
716    ++*parn;
717  
718 <  if (IsServer(client_p))
718 >  if (!MyConnect(source_p))
719      if (strchr(mask, ' '))
720        return;
721  
# Line 741 | Line 741 | chm_except(struct Client *client_p, stru
741   }
742  
743   static void
744 < chm_invex(struct Client *client_p, struct Client *source_p,
744 > chm_invex(struct Client *source_p,
745            struct Channel *chptr, int parc, int *parn,
746            char **parv, int *errors, int alev, int dir, char c, unsigned int d)
747   {
# Line 786 | Line 786 | chm_invex(struct Client *client_p, struc
786    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
787    ++*parn;
788  
789 <  if (IsServer(client_p))
789 >  if (!MyConnect(source_p))
790      if (strchr(mask, ' '))
791        return;
792  
# Line 812 | Line 812 | chm_invex(struct Client *client_p, struc
812   }
813  
814   static void
815 < chm_voice(struct Client *client_p, struct Client *source_p,
815 > chm_voice(struct Client *source_p,
816            struct Channel *chptr, int parc, int *parn,
817            char **parv, int *errors, int alev, int dir, char c, unsigned int d)
818   {
# Line 872 | Line 872 | chm_voice(struct Client *client_p, struc
872  
873   #ifdef HALFOPS
874   static void
875 < chm_hop(struct Client *client_p, struct Client *source_p,
876 <       struct Channel *chptr, int parc, int *parn,
877 <       char **parv, int *errors, int alev, int dir, char c, unsigned int d)
875 > chm_hop(struct Client *source_p,
876 >        struct Channel *chptr, int parc, int *parn,
877 >        char **parv, int *errors, int alev, int dir, char c, unsigned int d)
878   {
879    const char *opnick = NULL;
880    struct Client *target_p;
# Line 949 | Line 949 | chm_hop(struct Client *client_p, struct
949   #endif
950  
951   static void
952 < chm_op(struct Client *client_p, struct Client *source_p,
952 > chm_op(struct Client *source_p,
953         struct Channel *chptr, int parc, int *parn,
954         char **parv, int *errors, int alev, int dir, char c, unsigned int d)
955   {
# Line 1011 | Line 1011 | chm_op(struct Client *client_p, struct C
1011   }
1012  
1013   static void
1014 < chm_limit(struct Client *client_p, struct Client *source_p,
1014 > chm_limit(struct Client *source_p,
1015            struct Channel *chptr, int parc, int *parn,
1016            char **parv, int *errors, int alev, int dir, char c, unsigned int d)
1017   {
1018 <  unsigned int i;
1019 <  int limit;
1020 <  char *lstr;
1018 >  unsigned int i = 0;
1019 >  int limit = 0;
1020  
1021    if (alev < CHACCESS_HALFOP)
1022    {
# Line 1034 | Line 1033 | chm_limit(struct Client *client_p, struc
1033  
1034    if ((dir == MODE_ADD) && parc > *parn)
1035    {
1036 <    lstr = parv[(*parn)++];
1036 >    char *lstr = parv[(*parn)++];
1037  
1038 <    if ((limit = atoi(lstr)) <= 0)
1038 >    if (EmptyString(lstr) || (limit = atoi(lstr)) <= 0)
1039        return;
1040  
1041      sprintf(lstr, "%d", limit);
1042  
1043 <    /* if somebody sets MODE #channel +ll 1 2, accept latter --fl */
1044 <    for (i = 0; i < mode_count; i++)
1043 >    /* If somebody sets MODE #channel +ll 1 2, accept latter --fl */
1044 >    for (i = 0; i < mode_count; ++i)
1045        if (mode_changes[i].letter == c && mode_changes[i].dir == MODE_ADD)
1046          mode_changes[i].letter = 0;
1047  
# Line 1070 | Line 1069 | chm_limit(struct Client *client_p, struc
1069   }
1070  
1071   static void
1072 < chm_key(struct Client *client_p, struct Client *source_p,
1072 > chm_key(struct Client *source_p,
1073          struct Channel *chptr, int parc, int *parn,
1074          char **parv, int *errors, int alev, int dir, char c, unsigned int d)
1075   {
1076 <  unsigned int i;
1078 <  char *key;
1076 >  unsigned int i = 0;
1077  
1078    if (alev < CHACCESS_HALFOP)
1079    {
# Line 1092 | Line 1090 | chm_key(struct Client *client_p, struct
1090  
1091    if ((dir == MODE_ADD) && parc > *parn)
1092    {
1093 <    key = parv[(*parn)++];
1093 >    char *key = parv[(*parn)++];
1094  
1095      if (MyClient(source_p))
1096        fix_key(key);
1097      else
1098        fix_key_old(key);
1099  
1100 <    if (*key == '\0')
1100 >    if (EmptyString(key))
1101        return;
1102  
1103      assert(key[0] != ' ');
1104      strlcpy(chptr->mode.key, key, sizeof(chptr->mode.key));
1105  
1106 <    /* if somebody does MODE #channel +kk a b, accept latter --fl */
1107 <    for (i = 0; i < mode_count; i++)
1106 >    /* If somebody does MODE #channel +kk a b, accept latter --fl */
1107 >    for (i = 0; i < mode_count; ++i)
1108        if (mode_changes[i].letter == c && mode_changes[i].dir == MODE_ADD)
1109          mode_changes[i].letter = 0;
1110  
# Line 1136 | Line 1134 | chm_key(struct Client *client_p, struct
1134  
1135   struct ChannelMode
1136   {
1137 <  void (*func)(struct Client *, struct Client *,
1137 >  void (*func)(struct Client *,
1138                 struct Channel *, int, int *, char **,
1139                 int *, int, int, char, unsigned int);
1140    unsigned int d;
# Line 1439 | Line 1437 | get_channel_access(const struct Client *
1437    return CHACCESS_PEON;
1438   }
1439  
1440 < /* void send_cap_mode_changes(struct Client *client_p,
1443 < *                        struct Client *source_p,
1444 < *                        struct Channel *chptr, int cap, int nocap)
1440 > /* send_mode_changes_server()
1441   * Input: The client sending(client_p), the source client(source_p),
1442   *        the channel to send mode changes for(chptr)
1443   * Output: None.
1444 < * Side-effects: Sends the appropriate mode changes to capable servers.
1449 < *
1450 < * send_cap_mode_changes() will loop the server list itself, because
1451 < * at this point in time we have 4 capabs for channels, CAP_IE, CAP_EX,
1452 < * and a server could support any number of these..
1453 < * so we make the modebufs per server, tailoring them to each servers
1454 < * specific demand.  Its not very pretty, but its one of the few realistic
1455 < * ways to handle having this many capabs for channel modes.. --fl_
1444 > * Side-effects: Sends the appropriate mode changes to servers.
1445   *
1457 * Reverted back to my original design, except that we now keep a count
1458 * of the number of servers which each combination as an optimisation, so
1459 * the capabs combinations which are not needed are not worked out. -A1kmm
1446   */
1461 /* rewritten to ensure parabuf < MODEBUFLEN -db */
1462
1447   static void
1448 < send_mode_changes_server(struct Client *client_p, struct Client *source_p,
1465 <                         struct Channel *chptr)
1448 > send_mode_changes_server(struct Client *source_p, struct Channel *chptr)
1449   {
1450    unsigned int i;
1451 <  int mbl, pbl, arglen, nc, mc;
1452 <  int len;
1451 >  int mbl = 0, pbl = 0, arglen = 0, nc = 0, mc = 0;
1452 >  int len = 0;
1453    const char *arg = NULL;
1454    char *parptr;
1455    int dir = MODE_QUERY;
1456  
1474  mc = 0;
1475  nc = 0;
1476  pbl = 0;
1477
1457    parabuf[0] = '\0';
1458    parptr = parabuf;
1459  
1460    mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id,
1461                   (unsigned long)chptr->channelts, chptr->chname);
1462  
1463 <  /* loop the list of - modes we have */
1463 >  /* loop the list of modes we have */
1464    for (i = 0; i < mode_count; ++i)
1465    {
1487    /* if they dont support the cap we need, or they do support a cap they
1488     * cant have, then dont add it to the modebuf.. that way they wont see
1489     * the mode
1490     */
1466      if (mode_changes[i].letter == 0) /* XXX: can it ever happen? */
1467        continue;
1468  
# Line 1501 | Line 1476 | send_mode_changes_server(struct Client *
1476      else
1477        arglen = 0;
1478  
1504
1479      /*
1480       * If we're creeping past the buf size, we need to send it and make
1481       * another line for the other modes
# Line 1511 | Line 1485 | send_mode_changes_server(struct Client *
1485          (pbl + arglen + BAN_FUDGE) >= MODEBUFLEN)
1486      {
1487        if (nc != 0)
1488 <        sendto_server(client_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
1488 >        sendto_server(source_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
1489        nc = 0;
1490        mc = 0;
1491  
# Line 1547 | Line 1521 | send_mode_changes_server(struct Client *
1521      parabuf[pbl - 1] = '\0';
1522  
1523    if (nc != 0)
1524 <    sendto_server(client_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
1524 >    sendto_server(source_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
1525   }
1526  
1527   /* void send_mode_changes(struct Client *client_p,
# Line 1562 | Line 1536 | send_mode_changes_server(struct Client *
1536   */
1537   /* ensure parabuf < MODEBUFLEN -db */
1538   static void
1539 < send_mode_changes(struct Client *client_p, struct Client *source_p,
1566 <                  struct Channel *chptr)
1539 > send_mode_changes(struct Client *source_p, struct Channel *chptr)
1540   {
1541    unsigned int i;
1542 <  int mbl, pbl, arglen, nc, mc;
1543 <  int len;
1542 >  int mbl = 0, pbl = 0, arglen = 0, nc = 0, mc = 0;
1543 >  int len = 0;
1544    const char *arg = NULL;
1545    char *parptr;
1546    int dir = MODE_QUERY;
1547  
1548 <  /* bail out if we have nothing to do... */
1548 >  /* Bail out if we have nothing to do... */
1549    if (!mode_count)
1550      return;
1551  
# Line 1584 | Line 1557 | send_mode_changes(struct Client *client_
1557      mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1558                     source_p->username, source_p->host, chptr->chname);
1559  
1587  mc = 0;
1588  nc = 0;
1589  pbl = 0;
1590
1560    parabuf[0] = '\0';
1561    parptr = parabuf;
1562  
# Line 1656 | Line 1625 | send_mode_changes(struct Client *client_
1625    if (nc != 0)
1626      sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", modebuf, parabuf);
1627  
1628 <  nc = 0;
1660 <  mc = 0;
1661 <
1662 <  send_mode_changes_server(client_p, source_p, chptr);
1628 >  send_mode_changes_server(source_p, chptr);
1629   }
1630  
1631   /* void set_channel_mode(struct Client *client_p, struct Client *source_p,
# Line 1674 | Line 1640 | send_mode_changes(struct Client *client_
1640   *               clients.
1641   */
1642   void
1643 < set_channel_mode(struct Client *client_p, struct Client *source_p, struct Channel *chptr,
1643 > set_channel_mode(struct Client *source_p, struct Channel *chptr,
1644                   struct Membership *member, int parc, char *parv[])
1645   {
1646    int dir = MODE_ADD;
# Line 1705 | Line 1671 | set_channel_mode(struct Client *client_p
1671        {
1672          struct ChannelMode *tptr = &ModeTable[(unsigned char)c];
1673  
1674 <        tptr->func(client_p, source_p, chptr, parc, &parn,
1675 <                   parv, &errors, alevel, dir, c, tptr->d);
1674 >        tptr->func(source_p, chptr, parc, &parn, parv,
1675 >                   &errors, alevel, dir, c, tptr->d);
1676          break;
1677        }
1678      }
1679    }
1680  
1681 <  send_mode_changes(client_p, source_p, chptr);
1681 >  send_mode_changes(source_p, chptr);
1682   }

Diff Legend

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